mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Change the global config variable to a globalConfig() function.
This commit is contained in:
@@ -12,7 +12,7 @@ FluxmapReader::FluxmapReader(const Fluxmap& fluxmap):
|
||||
_fluxmap(fluxmap),
|
||||
_bytes(fluxmap.ptr()),
|
||||
_size(fluxmap.bytes()),
|
||||
_config(config.decoder())
|
||||
_config(globalConfig().decoder())
|
||||
{
|
||||
rewind();
|
||||
}
|
||||
@@ -132,7 +132,8 @@ FluxPattern::FluxPattern(unsigned bits, uint64_t pattern): _bits(bits)
|
||||
|
||||
bool FluxPattern::matches(const unsigned* end, FluxMatch& match) const
|
||||
{
|
||||
const double clockDecodeThreshold = config.decoder().bit_error_threshold();
|
||||
const double clockDecodeThreshold =
|
||||
globalConfig().decoder().bit_error_threshold();
|
||||
const unsigned* start = end - _intervals.size();
|
||||
unsigned candidatelength = std::accumulate(start, end - _lowzero, 0);
|
||||
if (!candidatelength)
|
||||
|
||||
@@ -48,7 +48,7 @@ nanoseconds_t Encoder::calculatePhysicalClockPeriod(
|
||||
nanoseconds_t targetClockPeriod, nanoseconds_t targetRotationalPeriod)
|
||||
{
|
||||
nanoseconds_t currentRotationalPeriod =
|
||||
config.drive().rotational_period_ms() * 1e6;
|
||||
globalConfig().drive().rotational_period_ms() * 1e6;
|
||||
if (currentRotationalPeriod == 0)
|
||||
error(
|
||||
"you must set --drive.rotational_period_ms as it can't be "
|
||||
|
||||
21
lib/flags.cc
21
lib/flags.cc
@@ -52,7 +52,7 @@ void FlagGroup::applyOption(const OptionProto& option)
|
||||
log("OPTION: {}",
|
||||
option.has_message() ? option.message() : option.comment());
|
||||
|
||||
config.MergeFrom(option.config());
|
||||
globalConfig().MergeFrom(option.config());
|
||||
}
|
||||
|
||||
bool FlagGroup::applyOption(const std::string& optionName)
|
||||
@@ -70,10 +70,10 @@ bool FlagGroup::applyOption(const std::string& optionName)
|
||||
return false;
|
||||
};
|
||||
|
||||
if (searchOptionList(config.option()))
|
||||
if (searchOptionList(globalConfig().option()))
|
||||
return true;
|
||||
|
||||
for (const auto& optionGroup : config.option_group())
|
||||
for (const auto& optionGroup : globalConfig().option_group())
|
||||
{
|
||||
if (searchOptionList(optionGroup.option()))
|
||||
return true;
|
||||
@@ -213,7 +213,7 @@ std::vector<std::string> FlagGroup::parseFlagsWithFilenames(int argc,
|
||||
|
||||
/* Apply any default options in groups. */
|
||||
|
||||
for (auto& group : config.option_group())
|
||||
for (auto& group : globalConfig().option_group())
|
||||
{
|
||||
const OptionProto* defaultOption = &*group.option().begin();
|
||||
bool isSet = false;
|
||||
@@ -232,7 +232,7 @@ std::vector<std::string> FlagGroup::parseFlagsWithFilenames(int argc,
|
||||
|
||||
/* Next, any standalone options. */
|
||||
|
||||
for (auto& option : config.option())
|
||||
for (auto& option : globalConfig().option())
|
||||
{
|
||||
if (options.find(option.name()) != options.end())
|
||||
{
|
||||
@@ -249,7 +249,7 @@ std::vector<std::string> FlagGroup::parseFlagsWithFilenames(int argc,
|
||||
|
||||
for (auto [k, v] : overrides)
|
||||
{
|
||||
ProtoField protoField = resolveProtoPath(&config, k);
|
||||
ProtoField protoField = resolveProtoPath(&globalConfig(), k);
|
||||
setProtoFieldFromString(protoField, v);
|
||||
}
|
||||
|
||||
@@ -295,7 +295,8 @@ ConfigProto FlagGroup::parseSingleConfigFile(const std::string& filename,
|
||||
ss << f.rdbuf();
|
||||
|
||||
ConfigProto config;
|
||||
if (!google::protobuf::TextFormat::MergeFromString(ss.str(), &config))
|
||||
if (!google::protobuf::TextFormat::MergeFromString(
|
||||
ss.str(), &globalConfig()))
|
||||
error("couldn't load external config proto");
|
||||
return config;
|
||||
}
|
||||
@@ -304,7 +305,7 @@ ConfigProto FlagGroup::parseSingleConfigFile(const std::string& filename,
|
||||
void FlagGroup::parseConfigFile(const std::string& filename,
|
||||
const std::map<std::string, const ConfigProto*>& configFiles)
|
||||
{
|
||||
config.MergeFrom(parseSingleConfigFile(filename, configFiles));
|
||||
globalConfig().MergeFrom(parseSingleConfigFile(filename, configFiles));
|
||||
}
|
||||
|
||||
void FlagGroup::checkInitialised() const
|
||||
@@ -368,7 +369,7 @@ static void doHelp()
|
||||
static void doShowConfig()
|
||||
{
|
||||
std::string s;
|
||||
google::protobuf::TextFormat::PrintToString(config, &s);
|
||||
google::protobuf::TextFormat::PrintToString(globalConfig(), &s);
|
||||
std::cout << s << '\n';
|
||||
|
||||
exit(0);
|
||||
@@ -376,7 +377,7 @@ static void doShowConfig()
|
||||
|
||||
static void doDoc()
|
||||
{
|
||||
const auto fields = findAllProtoFields(&config);
|
||||
const auto fields = findAllProtoFields(&globalConfig());
|
||||
for (const auto field : fields)
|
||||
{
|
||||
const std::string& path = field.first;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace
|
||||
|
||||
bool singlesided(void)
|
||||
{
|
||||
return config.heads().start() == config.heads().end();
|
||||
return globalConfig().heads().start() == globalConfig().heads().end();
|
||||
}
|
||||
|
||||
class A2RFluxSink : public FluxSink
|
||||
@@ -38,7 +38,8 @@ namespace
|
||||
|
||||
log("A2R: writing A2R {} file containing {} tracks\n",
|
||||
singlesided() ? "single sided" : "double sided",
|
||||
config.tracks().end() - config.tracks().start() + 1);
|
||||
globalConfig().tracks().end() -
|
||||
globalConfig().tracks().start() + 1);
|
||||
|
||||
time_t now{std::time(nullptr)};
|
||||
auto t = gmtime(&now);
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
track->add_flux(fluxBytes);
|
||||
}
|
||||
|
||||
proto.mutable_drive()->MergeFrom(config.drive());
|
||||
proto.mutable_drive()->MergeFrom(globalConfig().drive());
|
||||
saveFl2File(_filename, proto);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ void FluxSink::updateConfigForFilename(
|
||||
[](auto& s, auto* proto)
|
||||
{
|
||||
proto->set_type(FluxSinkProto::DRIVE);
|
||||
config.mutable_drive()->set_drive(std::stoi(s));
|
||||
globalConfig().mutable_drive()->set_drive(std::stoi(s));
|
||||
}},
|
||||
};
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@ public:
|
||||
public:
|
||||
void writeFlux(int track, int side, const Fluxmap& fluxmap) override
|
||||
{
|
||||
usbSetDrive(config.drive().drive(),
|
||||
config.drive().high_density(),
|
||||
config.drive().index_mode());
|
||||
usbSetDrive(globalConfig().drive().drive(),
|
||||
globalConfig().drive().high_density(),
|
||||
globalConfig().drive().index_mode());
|
||||
#if 0
|
||||
if (fluxSourceSinkFortyTrack)
|
||||
{
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
|
||||
operator std::string() const
|
||||
{
|
||||
return fmt::format("drive {}", config.drive().drive());
|
||||
return fmt::format("drive {}", globalConfig().drive().drive());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
_fileheader.start_track = strackno(minTrack, minSide);
|
||||
_fileheader.end_track = strackno(maxTrack, maxSide);
|
||||
_fileheader.flags = SCP_FLAG_INDEXED;
|
||||
if (config.drive().tpi() != 48)
|
||||
if (globalConfig().drive().tpi() != 48)
|
||||
_fileheader.flags |= SCP_FLAG_96TPI;
|
||||
_fileheader.cell_width = 0;
|
||||
if ((minSide == 0) && (maxSide == 0))
|
||||
|
||||
@@ -78,15 +78,15 @@ public:
|
||||
if (disktype == 1)
|
||||
{
|
||||
/* 5.25" with quarter stepping. */
|
||||
::config.mutable_drive()->set_tracks(160);
|
||||
::config.mutable_drive()->set_heads(1);
|
||||
::config.mutable_drive()->set_head_width(4);
|
||||
::config.mutable_drive()->set_tpi(48 * 4);
|
||||
::globalConfig().mutable_drive()->set_tracks(160);
|
||||
::globalConfig().mutable_drive()->set_heads(1);
|
||||
::globalConfig().mutable_drive()->set_head_width(4);
|
||||
::globalConfig().mutable_drive()->set_tpi(48 * 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 3.5". */
|
||||
::config.mutable_drive()->set_tpi(135);
|
||||
::globalConfig().mutable_drive()->set_tpi(135);
|
||||
}
|
||||
|
||||
Bytes stream = findChunk("STRM");
|
||||
|
||||
@@ -37,9 +37,10 @@ public:
|
||||
{
|
||||
_proto = loadFl2File(_config.filename());
|
||||
|
||||
if (::config.has_drive())
|
||||
warning("FLUX: overriding drive configuration with flux file contents");
|
||||
::config.mutable_drive()->MergeFrom(_proto.drive());
|
||||
if (::globalConfig().has_drive())
|
||||
warning(
|
||||
"FLUX: overriding drive configuration with flux file contents");
|
||||
::globalConfig().mutable_drive()->MergeFrom(_proto.drive());
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -102,7 +102,7 @@ void FluxSource::updateConfigForFilename(
|
||||
[](auto& s, auto* proto)
|
||||
{
|
||||
proto->set_type(FluxSourceProto::DRIVE);
|
||||
config.mutable_drive()->set_drive(std::stoi(s));
|
||||
globalConfig().mutable_drive()->set_drive(std::stoi(s));
|
||||
}},
|
||||
{std::regex("^flx:(.*)$"),
|
||||
[](auto& s, auto* proto)
|
||||
|
||||
@@ -29,14 +29,15 @@ private:
|
||||
|
||||
std::unique_ptr<const Fluxmap> next()
|
||||
{
|
||||
usbSetDrive(config.drive().drive(),
|
||||
config.drive().high_density(),
|
||||
config.drive().index_mode());
|
||||
usbSetDrive(globalConfig().drive().drive(),
|
||||
globalConfig().drive().high_density(),
|
||||
globalConfig().drive().index_mode());
|
||||
usbSeek(_track);
|
||||
|
||||
Bytes data = usbRead(_head,
|
||||
config.drive().sync_with_index(),
|
||||
config.drive().revolutions() * _fluxsource._oneRevolution,
|
||||
globalConfig().drive().sync_with_index(),
|
||||
globalConfig().drive().revolutions() *
|
||||
_fluxsource._oneRevolution,
|
||||
_fluxsource._hardSectorThreshold);
|
||||
auto fluxmap = std::make_unique<Fluxmap>();
|
||||
fluxmap->appendBytes(data);
|
||||
|
||||
@@ -43,8 +43,8 @@ public:
|
||||
error("input not a SCP file");
|
||||
|
||||
int tpi = (_header.flags & SCP_FLAG_96TPI) ? 96 : 48;
|
||||
if (!::config.drive().has_tpi())
|
||||
::config.mutable_drive()->set_tpi(tpi);
|
||||
if (!::globalConfig().drive().has_tpi())
|
||||
::globalConfig().mutable_drive()->set_tpi(tpi);
|
||||
|
||||
_resolution = 25 * (_header.resolution + 1);
|
||||
int startSide = (_header.heads == 2) ? 1 : 0;
|
||||
|
||||
@@ -56,27 +56,27 @@ public:
|
||||
inputFile.read((char*)trackTable.begin(), trackTable.size());
|
||||
ByteReader trackTableReader(trackTable);
|
||||
|
||||
if (config.encoder().format_case() !=
|
||||
if (globalConfig().encoder().format_case() !=
|
||||
EncoderProto::FormatCase::FORMAT_NOT_SET)
|
||||
log("D88: overriding configured format");
|
||||
|
||||
auto ibm = config.mutable_encoder()->mutable_ibm();
|
||||
auto ibm = globalConfig().mutable_encoder()->mutable_ibm();
|
||||
int clockRate = 500;
|
||||
if (mediaFlag == 0x20)
|
||||
{
|
||||
log("D88: forcing high density mode");
|
||||
config.mutable_drive()->set_high_density(true);
|
||||
config.mutable_layout()->set_tpi(96);
|
||||
globalConfig().mutable_drive()->set_high_density(true);
|
||||
globalConfig().mutable_layout()->set_tpi(96);
|
||||
}
|
||||
else
|
||||
{
|
||||
log("D88: forcing single/double density mode");
|
||||
clockRate = 300;
|
||||
config.mutable_drive()->set_high_density(false);
|
||||
config.mutable_layout()->set_tpi(48);
|
||||
globalConfig().mutable_drive()->set_high_density(false);
|
||||
globalConfig().mutable_layout()->set_tpi(48);
|
||||
}
|
||||
|
||||
auto layout = config.mutable_layout();
|
||||
auto layout = globalConfig().mutable_layout();
|
||||
std::unique_ptr<Image> image(new Image);
|
||||
for (int track = 0; track < trackTableSize / 4; track++)
|
||||
{
|
||||
|
||||
@@ -91,11 +91,11 @@ public:
|
||||
trackCount++;
|
||||
}
|
||||
|
||||
auto layout = config.mutable_layout();
|
||||
if (config.encoder().format_case() ==
|
||||
auto layout = globalConfig().mutable_layout();
|
||||
if (globalConfig().encoder().format_case() ==
|
||||
EncoderProto::FormatCase::FORMAT_NOT_SET)
|
||||
{
|
||||
auto ibm = config.mutable_encoder()->mutable_ibm();
|
||||
auto ibm = globalConfig().mutable_encoder()->mutable_ibm();
|
||||
auto trackdata = ibm->add_trackdata();
|
||||
trackdata->set_target_clock_period_us(2);
|
||||
|
||||
@@ -134,7 +134,7 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
config.mutable_decoder()->mutable_ibm();
|
||||
globalConfig().mutable_decoder()->mutable_ibm();
|
||||
}
|
||||
|
||||
image->calculateSize();
|
||||
|
||||
@@ -70,11 +70,11 @@ public:
|
||||
trackCount++;
|
||||
}
|
||||
|
||||
auto layout = config.mutable_layout();
|
||||
if (config.encoder().format_case() ==
|
||||
auto layout = globalConfig().mutable_layout();
|
||||
if (globalConfig().encoder().format_case() ==
|
||||
EncoderProto::FormatCase::FORMAT_NOT_SET)
|
||||
{
|
||||
auto ibm = config.mutable_encoder()->mutable_ibm();
|
||||
auto ibm = globalConfig().mutable_encoder()->mutable_ibm();
|
||||
auto trackdata = ibm->add_trackdata();
|
||||
trackdata->set_target_clock_period_us(2);
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ public:
|
||||
TrackHeader header = {0, 0, 0, 0, 0};
|
||||
TrackHeader previousheader = {0, 0, 0, 0, 0};
|
||||
|
||||
auto layout = config.mutable_layout();
|
||||
auto layout = globalConfig().mutable_layout();
|
||||
|
||||
unsigned n = 0;
|
||||
unsigned headerPtr = 0;
|
||||
@@ -259,7 +259,7 @@ public:
|
||||
headerPtr++;
|
||||
}
|
||||
|
||||
auto ibm = config.mutable_encoder()->mutable_ibm();
|
||||
auto ibm = globalConfig().mutable_encoder()->mutable_ibm();
|
||||
auto trackdata = ibm->add_trackdata();
|
||||
|
||||
auto layoutdata = layout->add_layoutdata();
|
||||
@@ -443,7 +443,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
if (config.encoder().format_case() !=
|
||||
if (globalConfig().encoder().format_case() !=
|
||||
EncoderProto::FormatCase::FORMAT_NOT_SET)
|
||||
log("IMD: overriding configured format");
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
if (!inputFile.is_open())
|
||||
error("cannot open input file");
|
||||
|
||||
auto layout = config.layout();
|
||||
auto layout = globalConfig().layout();
|
||||
if (!layout.tracks() || !layout.sides())
|
||||
error(
|
||||
"IMG: bad configuration; did you remember to set the "
|
||||
|
||||
@@ -49,16 +49,16 @@ public:
|
||||
error("NFD: unsupported number of heads");
|
||||
}
|
||||
|
||||
if (config.encoder().format_case() !=
|
||||
if (globalConfig().encoder().format_case() !=
|
||||
EncoderProto::FormatCase::FORMAT_NOT_SET)
|
||||
log("NFD: overriding configured format");
|
||||
|
||||
auto ibm = config.mutable_encoder()->mutable_ibm();
|
||||
auto layout = config.mutable_layout();
|
||||
auto ibm = globalConfig().mutable_encoder()->mutable_ibm();
|
||||
auto layout = globalConfig().mutable_layout();
|
||||
log("NFD: HD 1.2MB mode");
|
||||
log("NFD: forcing hign density mode");
|
||||
config.mutable_drive()->set_high_density(true);
|
||||
config.mutable_layout()->set_tpi(96);
|
||||
globalConfig().mutable_drive()->set_high_density(true);
|
||||
globalConfig().mutable_layout()->set_tpi(96);
|
||||
|
||||
std::unique_ptr<Image> image(new Image);
|
||||
for (int track = 0; track < 163; track++)
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
{
|
||||
const Geometry geometry = image.getGeometry();
|
||||
|
||||
auto& layout = config.layout();
|
||||
auto& layout = globalConfig().layout();
|
||||
int tracks = layout.has_tracks() ? layout.tracks() : geometry.numTracks;
|
||||
int sides = layout.has_sides() ? layout.sides() : geometry.numSides;
|
||||
|
||||
|
||||
@@ -10,15 +10,16 @@ bool approximatelyEqual(float a, float b, float epsilon)
|
||||
|
||||
static unsigned getTrackStep()
|
||||
{
|
||||
if (!config.layout().tpi())
|
||||
error("no layout TPI set");
|
||||
if (!config.drive().tpi())
|
||||
error("no drive TPI set");
|
||||
if (!globalConfig().layout().tpi())
|
||||
error("no layout TPI set");
|
||||
if (!globalConfig().drive().tpi())
|
||||
error("no drive TPI set");
|
||||
|
||||
if (config.layout().tpi() == 0.0)
|
||||
error("layout TPI is zero; this shouldn't happen?");
|
||||
if (globalConfig().layout().tpi() == 0.0)
|
||||
error("layout TPI is zero; this shouldn't happen?");
|
||||
|
||||
float trackStepFactor = config.drive().tpi() / config.layout().tpi();
|
||||
float trackStepFactor =
|
||||
globalConfig().drive().tpi() / globalConfig().layout().tpi();
|
||||
|
||||
if (!approximatelyEqual(trackStepFactor, round(trackStepFactor), 0.001))
|
||||
error(
|
||||
@@ -33,37 +34,37 @@ static unsigned getTrackStep()
|
||||
|
||||
unsigned Layout::remapTrackPhysicalToLogical(unsigned ptrack)
|
||||
{
|
||||
return (ptrack - config.drive().head_bias()) / getTrackStep();
|
||||
return (ptrack - globalConfig().drive().head_bias()) / getTrackStep();
|
||||
}
|
||||
|
||||
unsigned Layout::remapTrackLogicalToPhysical(unsigned ltrack)
|
||||
{
|
||||
return config.drive().head_bias() + ltrack * getTrackStep();
|
||||
return globalConfig().drive().head_bias() + ltrack * getTrackStep();
|
||||
}
|
||||
|
||||
unsigned Layout::remapSidePhysicalToLogical(unsigned pside)
|
||||
{
|
||||
return pside ^ config.layout().swap_sides();
|
||||
return pside ^ globalConfig().layout().swap_sides();
|
||||
}
|
||||
|
||||
unsigned Layout::remapSideLogicalToPhysical(unsigned lside)
|
||||
{
|
||||
return lside ^ config.layout().swap_sides();
|
||||
return lside ^ globalConfig().layout().swap_sides();
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<const TrackInfo>> Layout::computeLocations()
|
||||
{
|
||||
std::set<unsigned> tracks;
|
||||
if (config.has_tracks())
|
||||
tracks = iterate(config.tracks());
|
||||
if (globalConfig().has_tracks())
|
||||
tracks = iterate(globalConfig().tracks());
|
||||
else
|
||||
tracks = iterate(0, config.layout().tracks());
|
||||
tracks = iterate(0, globalConfig().layout().tracks());
|
||||
|
||||
std::set<unsigned> heads;
|
||||
if (config.has_heads())
|
||||
heads = iterate(config.heads());
|
||||
if (globalConfig().has_heads())
|
||||
heads = iterate(globalConfig().heads());
|
||||
else
|
||||
heads = iterate(0, config.layout().sides());
|
||||
heads = iterate(0, globalConfig().layout().sides());
|
||||
|
||||
std::vector<std::shared_ptr<const TrackInfo>> locations;
|
||||
for (unsigned logicalTrack : tracks)
|
||||
@@ -96,7 +97,7 @@ void Layout::getBounds(
|
||||
std::vector<std::pair<int, int>> Layout::getTrackOrdering(
|
||||
unsigned guessedTracks, unsigned guessedSides)
|
||||
{
|
||||
auto layout = config.layout();
|
||||
auto layout = globalConfig().layout();
|
||||
int tracks = layout.has_tracks() ? layout.tracks() : guessedTracks;
|
||||
int sides = layout.has_sides() ? layout.sides() : guessedSides;
|
||||
|
||||
@@ -178,7 +179,7 @@ std::shared_ptr<const TrackInfo> Layout::getLayoutOfTrack(
|
||||
auto trackInfo = std::make_shared<TrackInfo>();
|
||||
|
||||
LayoutProto::LayoutdataProto layoutdata;
|
||||
for (const auto& f : config.layout().layoutdata())
|
||||
for (const auto& f : globalConfig().layout().layoutdata())
|
||||
{
|
||||
if (f.has_track() && f.has_up_to_track() &&
|
||||
((logicalTrack < f.track()) || (logicalTrack > f.up_to_track())))
|
||||
@@ -192,13 +193,14 @@ std::shared_ptr<const TrackInfo> Layout::getLayoutOfTrack(
|
||||
layoutdata.MergeFrom(f);
|
||||
}
|
||||
|
||||
trackInfo->numTracks = config.layout().tracks();
|
||||
trackInfo->numSides = config.layout().sides();
|
||||
trackInfo->numTracks = globalConfig().layout().tracks();
|
||||
trackInfo->numSides = globalConfig().layout().sides();
|
||||
trackInfo->sectorSize = layoutdata.sector_size();
|
||||
trackInfo->logicalTrack = logicalTrack;
|
||||
trackInfo->logicalSide = logicalSide;
|
||||
trackInfo->physicalTrack = remapTrackLogicalToPhysical(logicalTrack);
|
||||
trackInfo->physicalSide = logicalSide ^ config.layout().swap_sides();
|
||||
trackInfo->physicalSide =
|
||||
logicalSide ^ globalConfig().layout().swap_sides();
|
||||
trackInfo->groupSize = getTrackStep();
|
||||
trackInfo->diskSectorOrder = expandSectorList(layoutdata.physical());
|
||||
trackInfo->naturalSectorOrder = trackInfo->diskSectorOrder;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "lib/common.pb.h"
|
||||
#include <regex>
|
||||
|
||||
ConfigProto config = []()
|
||||
static ConfigProto config = []()
|
||||
{
|
||||
ConfigProto config;
|
||||
config.mutable_drive()->set_drive(0);
|
||||
@@ -11,6 +11,11 @@ ConfigProto config = []()
|
||||
return config;
|
||||
}();
|
||||
|
||||
ConfigProto& globalConfig()
|
||||
{
|
||||
return config;
|
||||
}
|
||||
|
||||
static double toFloat(const std::string& value)
|
||||
{
|
||||
try
|
||||
|
||||
20
lib/proto.h
20
lib/proto.h
@@ -6,22 +6,28 @@
|
||||
|
||||
extern void setRange(RangeProto* range, const std::string& data);
|
||||
|
||||
typedef std::pair<google::protobuf::Message*, const google::protobuf::FieldDescriptor*> ProtoField;
|
||||
typedef std::pair<google::protobuf::Message*,
|
||||
const google::protobuf::FieldDescriptor*>
|
||||
ProtoField;
|
||||
|
||||
extern ProtoField resolveProtoPath(google::protobuf::Message* message, const std::string& path);
|
||||
extern void setProtoFieldFromString(ProtoField& protoField, const std::string& value);
|
||||
extern void setProtoByString(google::protobuf::Message* message, const std::string& path, const std::string& value);
|
||||
extern ProtoField resolveProtoPath(
|
||||
google::protobuf::Message* message, const std::string& path);
|
||||
extern void setProtoFieldFromString(
|
||||
ProtoField& protoField, const std::string& value);
|
||||
extern void setProtoByString(google::protobuf::Message* message,
|
||||
const std::string& path,
|
||||
const std::string& value);
|
||||
|
||||
extern std::set<unsigned> iterate(const RangeProto& range);
|
||||
extern std::set<unsigned> iterate(unsigned start, unsigned count);
|
||||
|
||||
extern std::map<std::string, const google::protobuf::FieldDescriptor*>
|
||||
findAllProtoFields(google::protobuf::Message* message);
|
||||
findAllProtoFields(google::protobuf::Message* message);
|
||||
|
||||
extern ConfigProto parseConfigBytes(const std::string_view& bytes);
|
||||
|
||||
extern ConfigProto config;
|
||||
extern const std::map<std::string, const ConfigProto*> formats;
|
||||
|
||||
#endif
|
||||
extern ConfigProto& globalConfig();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -61,13 +61,13 @@ void measureDiskRotation(
|
||||
log(BeginSpeedOperationLogMessage());
|
||||
|
||||
int retries = 5;
|
||||
usbSetDrive(config.drive().drive(),
|
||||
config.drive().high_density(),
|
||||
config.drive().index_mode());
|
||||
oneRevolution = config.drive().rotational_period_ms() * 1e6;
|
||||
if (config.drive().hard_sector_count() != 0)
|
||||
hardSectorThreshold =
|
||||
oneRevolution * 3 / (4 * config.drive().hard_sector_count());
|
||||
usbSetDrive(globalConfig().drive().drive(),
|
||||
globalConfig().drive().high_density(),
|
||||
globalConfig().drive().index_mode());
|
||||
oneRevolution = globalConfig().drive().rotational_period_ms() * 1e6;
|
||||
if (globalConfig().drive().hard_sector_count() != 0)
|
||||
hardSectorThreshold = oneRevolution * 3 /
|
||||
(4 * globalConfig().drive().hard_sector_count());
|
||||
else
|
||||
hardSectorThreshold = 0;
|
||||
|
||||
@@ -76,15 +76,17 @@ void measureDiskRotation(
|
||||
log(BeginOperationLogMessage{"Measuring drive rotational speed"});
|
||||
do
|
||||
{
|
||||
oneRevolution =
|
||||
usbGetRotationalPeriod(config.drive().hard_sector_count());
|
||||
if (config.drive().hard_sector_count() != 0)
|
||||
hardSectorThreshold = oneRevolution * 3 /
|
||||
(4 * config.drive().hard_sector_count());
|
||||
oneRevolution = usbGetRotationalPeriod(
|
||||
globalConfig().drive().hard_sector_count());
|
||||
if (globalConfig().drive().hard_sector_count() != 0)
|
||||
hardSectorThreshold =
|
||||
oneRevolution * 3 /
|
||||
(4 * globalConfig().drive().hard_sector_count());
|
||||
|
||||
retries--;
|
||||
} while ((oneRevolution == 0) && (retries > 0));
|
||||
config.mutable_drive()->set_rotational_period_ms(oneRevolution / 1e6);
|
||||
globalConfig().mutable_drive()->set_rotational_period_ms(
|
||||
oneRevolution / 1e6);
|
||||
log(EndOperationLogMessage{});
|
||||
}
|
||||
|
||||
@@ -189,7 +191,7 @@ BadSectorsState combineRecordAndSectors(TrackFlux& trackFlux,
|
||||
|
||||
static void adjustTrackOnError(FluxSource& fluxSource, int baseTrack)
|
||||
{
|
||||
switch (config.drive().error_behaviour())
|
||||
switch (globalConfig().drive().error_behaviour())
|
||||
{
|
||||
case DriveProto::NOTHING:
|
||||
break;
|
||||
@@ -215,7 +217,7 @@ ReadResult readGroup(FluxSourceIteratorHolder& fluxSourceIteratorHolder,
|
||||
ReadResult result = BAD_AND_CAN_NOT_RETRY;
|
||||
|
||||
for (unsigned offset = 0; offset < trackInfo->groupSize;
|
||||
offset += config.drive().head_width())
|
||||
offset += globalConfig().drive().head_width())
|
||||
{
|
||||
auto& fluxSourceIterator = fluxSourceIteratorHolder.getIterator(
|
||||
trackInfo->physicalTrack + offset, trackInfo->physicalSide);
|
||||
@@ -226,7 +228,7 @@ ReadResult readGroup(FluxSourceIteratorHolder& fluxSourceIteratorHolder,
|
||||
trackInfo->physicalTrack + offset, trackInfo->physicalSide});
|
||||
std::shared_ptr<const Fluxmap> fluxmap = fluxSourceIterator.next();
|
||||
// ->rescale(
|
||||
// 1.0 / config.flux_source().rescale());
|
||||
// 1.0 / globalConfig().flux_source().rescale());
|
||||
log(EndReadOperationLogMessage());
|
||||
log("{0} ms in {1} bytes",
|
||||
(int)(fluxmap->duration() / 1e6),
|
||||
@@ -238,7 +240,7 @@ ReadResult readGroup(FluxSourceIteratorHolder& fluxSourceIteratorHolder,
|
||||
HAS_NO_BAD_SECTORS)
|
||||
{
|
||||
result = GOOD_READ;
|
||||
if (config.decoder().skip_unnecessary_tracks())
|
||||
if (globalConfig().decoder().skip_unnecessary_tracks())
|
||||
return result;
|
||||
}
|
||||
else if (fluxSourceIterator.hasNext())
|
||||
@@ -265,18 +267,18 @@ void writeTracks(FluxSink& fluxSink,
|
||||
|
||||
testForEmergencyStop();
|
||||
|
||||
int retriesRemaining = config.decoder().retries();
|
||||
int retriesRemaining = globalConfig().decoder().retries();
|
||||
for (;;)
|
||||
{
|
||||
for (int offset = 0; offset < trackInfo->groupSize;
|
||||
offset += config.drive().head_width())
|
||||
offset += globalConfig().drive().head_width())
|
||||
{
|
||||
unsigned physicalTrack = trackInfo->physicalTrack + offset;
|
||||
|
||||
log(BeginWriteOperationLogMessage{
|
||||
physicalTrack, trackInfo->physicalSide});
|
||||
|
||||
if (offset == config.drive().group_offset())
|
||||
if (offset == globalConfig().drive().group_offset())
|
||||
{
|
||||
auto fluxmap = producer(trackInfo);
|
||||
if (!fluxmap)
|
||||
@@ -452,7 +454,7 @@ std::shared_ptr<TrackFlux> readAndDecodeTrack(FluxSource& fluxSource,
|
||||
trackFlux->trackInfo = trackInfo;
|
||||
|
||||
FluxSourceIteratorHolder fluxSourceIteratorHolder(fluxSource);
|
||||
int retriesRemaining = config.decoder().retries();
|
||||
int retriesRemaining = globalConfig().decoder().retries();
|
||||
for (;;)
|
||||
{
|
||||
auto result =
|
||||
@@ -486,8 +488,9 @@ std::shared_ptr<const DiskFlux> readDiskCommand(
|
||||
FluxSource& fluxSource, Decoder& decoder)
|
||||
{
|
||||
std::unique_ptr<FluxSink> outputFluxSink;
|
||||
if (config.decoder().has_copy_flux_to())
|
||||
outputFluxSink = FluxSink::create(config.decoder().copy_flux_to());
|
||||
if (globalConfig().decoder().has_copy_flux_to())
|
||||
outputFluxSink =
|
||||
FluxSink::create(globalConfig().decoder().copy_flux_to());
|
||||
|
||||
auto diskflux = std::make_shared<DiskFlux>();
|
||||
|
||||
@@ -513,7 +516,7 @@ std::shared_ptr<const DiskFlux> readDiskCommand(
|
||||
*data->fluxmap);
|
||||
}
|
||||
|
||||
if (config.decoder().dump_records())
|
||||
if (globalConfig().decoder().dump_records())
|
||||
{
|
||||
std::vector<std::shared_ptr<const Record>> sorted_records;
|
||||
|
||||
@@ -540,7 +543,7 @@ std::shared_ptr<const DiskFlux> readDiskCommand(
|
||||
}
|
||||
}
|
||||
|
||||
if (config.decoder().dump_sectors())
|
||||
if (globalConfig().decoder().dump_sectors())
|
||||
{
|
||||
auto collected_sectors = collectSectors(trackFlux->sectors, false);
|
||||
std::vector<std::shared_ptr<const Sector>> sorted_sectors(
|
||||
@@ -592,8 +595,9 @@ void readDiskCommand(
|
||||
auto diskflux = readDiskCommand(fluxsource, decoder);
|
||||
|
||||
writer.printMap(*diskflux->image);
|
||||
if (config.decoder().has_write_csv_to())
|
||||
writer.writeCsv(*diskflux->image, config.decoder().write_csv_to());
|
||||
if (globalConfig().decoder().has_write_csv_to())
|
||||
writer.writeCsv(
|
||||
*diskflux->image, globalConfig().decoder().write_csv_to());
|
||||
writer.writeMappedImage(*diskflux->image);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@ static std::shared_ptr<CandidateDevice> selectDevice()
|
||||
"no devices found (is one plugged in? Do you have the "
|
||||
"appropriate permissions?");
|
||||
|
||||
if (config.usb().has_serial())
|
||||
if (globalConfig().usb().has_serial())
|
||||
{
|
||||
auto wantedSerial = config.usb().serial();
|
||||
auto wantedSerial = globalConfig().usb().serial();
|
||||
for (auto& c : candidates)
|
||||
{
|
||||
if (c->serial == wantedSerial)
|
||||
@@ -63,10 +63,10 @@ USB* get_usb_impl()
|
||||
{
|
||||
/* Special case for certain configurations. */
|
||||
|
||||
if (config.usb().has_greaseweazle() &&
|
||||
config.usb().greaseweazle().has_port())
|
||||
if (globalConfig().usb().has_greaseweazle() &&
|
||||
globalConfig().usb().greaseweazle().has_port())
|
||||
{
|
||||
const auto& conf = config.usb().greaseweazle();
|
||||
const auto& conf = globalConfig().usb().greaseweazle();
|
||||
log("Using GreaseWeazle on serial port {}", conf.port());
|
||||
return createGreaseWeazleUsb(conf.port(), conf);
|
||||
}
|
||||
@@ -85,7 +85,7 @@ USB* get_usb_impl()
|
||||
candidate->serial,
|
||||
candidate->serialPort);
|
||||
return createGreaseWeazleUsb(
|
||||
candidate->serialPort, config.usb().greaseweazle());
|
||||
candidate->serialPort, globalConfig().usb().greaseweazle());
|
||||
|
||||
default:
|
||||
error("internal");
|
||||
|
||||
@@ -88,8 +88,8 @@ public:
|
||||
dev.readOnly = false;
|
||||
dev.isNativeDev = true;
|
||||
dev.devType = DEVTYPE_FLOPDD;
|
||||
dev.cylinders = config.layout().tracks();
|
||||
dev.heads = config.layout().sides();
|
||||
dev.cylinders = globalConfig().layout().tracks();
|
||||
dev.heads = globalConfig().layout().sides();
|
||||
dev.sectors = Layout::getLayoutOfTrack(0, 0)->numSectors;
|
||||
adfInitDevice(&dev, nullptr, false);
|
||||
int res = adfCreateFlop(&dev, (char*)volumeName.c_str(), 0);
|
||||
|
||||
@@ -126,7 +126,8 @@ class CbmfsFilesystem : public Filesystem
|
||||
bam.resize(fs->getLogicalSectorCount());
|
||||
usedBlocks = 0;
|
||||
unsigned block = 0;
|
||||
for (int track = 0; track < config.layout().tracks(); track++)
|
||||
for (int track = 0; track < globalConfig().layout().tracks();
|
||||
track++)
|
||||
{
|
||||
uint8_t blocks = br.read_8();
|
||||
uint32_t bitmap = br.read_le24();
|
||||
|
||||
@@ -151,7 +151,7 @@ void Filesystem::discardChanges()
|
||||
Filesystem::Filesystem(std::shared_ptr<SectorInterface> sectors):
|
||||
_sectors(sectors)
|
||||
{
|
||||
auto& layout = config.layout();
|
||||
auto& layout = globalConfig().layout();
|
||||
if (!layout.has_tracks() || !layout.has_sides())
|
||||
error(
|
||||
"FS: filesystem support cannot be used without concrete layout "
|
||||
@@ -224,6 +224,7 @@ std::unique_ptr<Filesystem> Filesystem::createFilesystem(
|
||||
|
||||
std::unique_ptr<Filesystem> Filesystem::createFilesystemFromConfig()
|
||||
{
|
||||
ConfigProto& config = globalConfig();
|
||||
std::shared_ptr<SectorInterface> sectorInterface;
|
||||
if (config.has_flux_source() || config.has_flux_sink())
|
||||
{
|
||||
|
||||
@@ -19,7 +19,8 @@ static StringFlag destFlux({"--dest", "-d"},
|
||||
"",
|
||||
[](const auto& value)
|
||||
{
|
||||
FluxSink::updateConfigForFilename(config.mutable_flux_sink(), value);
|
||||
FluxSink::updateConfigForFilename(
|
||||
globalConfig().mutable_flux_sink(), value);
|
||||
});
|
||||
|
||||
static IntFlag destTrack({"--cylinder", "-c"}, "track to write to", 0);
|
||||
@@ -50,7 +51,7 @@ static IntFlag buckets({"--buckets"}, "Number of heatmap buckets", 250);
|
||||
* https://ai.googleblog.com/2019/08/turbo-improved-rainbow-colormap-for.html
|
||||
*/
|
||||
static const uint8_t turbo_srgb_bytes[256][3] = {
|
||||
// clang-format off
|
||||
// clang-format off
|
||||
{48, 18, 59 }, {50, 21, 67 }, {51, 24, 74 }, {52, 27, 81 },
|
||||
{53, 30, 88 }, {54, 33, 95 }, {55, 36, 102}, {56, 39, 109},
|
||||
{57, 42, 115}, {58, 45, 121}, {59, 47, 128}, {60, 50, 134},
|
||||
@@ -115,7 +116,7 @@ static const uint8_t turbo_srgb_bytes[256][3] = {
|
||||
{158, 16, 1 }, {155, 15, 1 }, {152, 14, 1 }, {149, 13, 1 },
|
||||
{146, 11, 1 }, {142, 10, 1 }, {139, 9, 2 }, {136, 8, 2 },
|
||||
{133, 7, 2 }, {129, 6, 2 }, {126, 5, 2 }, {122, 4, 3 }
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static void palette(double value, agg::srgba8* pixel)
|
||||
@@ -246,15 +247,15 @@ static void draw_x_graticules(Agg2D& painter,
|
||||
|
||||
int mainAnalyseDriveResponse(int argc, const char* argv[])
|
||||
{
|
||||
config.mutable_flux_source()->set_type(FluxSourceProto::DRIVE);
|
||||
globalConfig().mutable_flux_source()->set_type(FluxSourceProto::DRIVE);
|
||||
flags.parseFlagsWithConfigFiles(argc, argv, {});
|
||||
|
||||
if (config.flux_sink().type() != FluxSinkProto::DRIVE)
|
||||
if (globalConfig().flux_sink().type() != FluxSinkProto::DRIVE)
|
||||
error("this only makes sense with a real disk drive");
|
||||
|
||||
usbSetDrive(config.drive().drive(),
|
||||
config.drive().high_density(),
|
||||
config.drive().index_mode());
|
||||
usbSetDrive(globalConfig().drive().drive(),
|
||||
globalConfig().drive().high_density(),
|
||||
globalConfig().drive().index_mode());
|
||||
usbSeek(destTrack);
|
||||
|
||||
std::cout << "Measuring rotational speed...\n";
|
||||
|
||||
@@ -19,7 +19,7 @@ static StringFlag sourceFlux({"--source", "-s"},
|
||||
[](const auto& value)
|
||||
{
|
||||
FluxSource::updateConfigForFilename(
|
||||
config.mutable_flux_source(), value);
|
||||
globalConfig().mutable_flux_source(), value);
|
||||
});
|
||||
|
||||
static IntFlag trackFlag({"--cylinder", "-c"}, "Track to read.", 0);
|
||||
@@ -132,11 +132,11 @@ static nanoseconds_t guessClock(const Fluxmap& fluxmap)
|
||||
|
||||
int mainInspect(int argc, const char* argv[])
|
||||
{
|
||||
config.mutable_flux_source()->set_type(FluxSourceProto::DRIVE);
|
||||
globalConfig().mutable_flux_source()->set_type(FluxSourceProto::DRIVE);
|
||||
flags.parseFlagsWithConfigFiles(argc, argv, {});
|
||||
|
||||
std::unique_ptr<FluxSource> fluxSource(
|
||||
FluxSource::create(config.flux_source()));
|
||||
FluxSource::create(globalConfig().flux_source()));
|
||||
const auto fluxmap = fluxSource->readFlux(trackFlag, headFlag)->next();
|
||||
|
||||
std::cout << fmt::format("0x{:x} bytes of data in {:.3f}ms\n",
|
||||
@@ -220,7 +220,7 @@ int mainInspect(int argc, const char* argv[])
|
||||
"\n\nAligned bitstream from {:.3f}ms follows:\n",
|
||||
fmr.tell().ns() / 1000000.0);
|
||||
|
||||
FluxDecoder decoder(&fmr, clockPeriod, config.decoder());
|
||||
FluxDecoder decoder(&fmr, clockPeriod, globalConfig().decoder());
|
||||
while (!fmr.eof())
|
||||
{
|
||||
std::cout << fmt::format("{:06x} {: 10.3f} : ",
|
||||
@@ -245,7 +245,7 @@ int mainInspect(int argc, const char* argv[])
|
||||
dumpRawFlag.get(),
|
||||
fmr.tell().ns() / 1000000.0);
|
||||
|
||||
FluxDecoder decoder(&fmr, clockPeriod, config.decoder());
|
||||
FluxDecoder decoder(&fmr, clockPeriod, globalConfig().decoder());
|
||||
for (int i = 0; i < dumpRawFlag; i++)
|
||||
decoder.readBit();
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ static StringFlag sourceFlux({"-s", "--source"},
|
||||
[](const auto& value)
|
||||
{
|
||||
FluxSource::updateConfigForFilename(
|
||||
config.mutable_flux_source(), value);
|
||||
globalConfig().mutable_flux_source(), value);
|
||||
});
|
||||
|
||||
static StringFlag destFlux({"-d", "--dest"},
|
||||
@@ -31,7 +31,8 @@ static StringFlag destFlux({"-d", "--dest"},
|
||||
"",
|
||||
[](const auto& value)
|
||||
{
|
||||
FluxSink::updateConfigForFilename(config.mutable_flux_sink(), value);
|
||||
FluxSink::updateConfigForFilename(
|
||||
globalConfig().mutable_flux_sink(), value);
|
||||
});
|
||||
|
||||
static StringFlag srcTracks({"--cylinders", "-c"},
|
||||
@@ -39,7 +40,7 @@ static StringFlag srcTracks({"--cylinders", "-c"},
|
||||
"",
|
||||
[](const auto& value)
|
||||
{
|
||||
setRange(config.mutable_tracks(), value);
|
||||
setRange(globalConfig().mutable_tracks(), value);
|
||||
});
|
||||
|
||||
static StringFlag srcHeads({"--heads", "-h"},
|
||||
@@ -47,25 +48,26 @@ static StringFlag srcHeads({"--heads", "-h"},
|
||||
"",
|
||||
[](const auto& value)
|
||||
{
|
||||
setRange(config.mutable_heads(), value);
|
||||
setRange(globalConfig().mutable_heads(), value);
|
||||
});
|
||||
|
||||
int mainRawRead(int argc, const char* argv[])
|
||||
{
|
||||
setRange(config.mutable_tracks(), "0-79");
|
||||
setRange(config.mutable_heads(), "0-1");
|
||||
setRange(globalConfig().mutable_tracks(), "0-79");
|
||||
setRange(globalConfig().mutable_heads(), "0-1");
|
||||
|
||||
if (argc == 1)
|
||||
showProfiles("rawread", formats);
|
||||
config.mutable_flux_source()->set_type(FluxSourceProto::DRIVE);
|
||||
globalConfig().mutable_flux_source()->set_type(FluxSourceProto::DRIVE);
|
||||
flags.parseFlagsWithConfigFiles(argc, argv, formats);
|
||||
|
||||
if (config.flux_sink().type() == FluxSinkProto::DRIVE)
|
||||
if (globalConfig().flux_sink().type() == FluxSinkProto::DRIVE)
|
||||
error("you can't use rawread to write to hardware");
|
||||
|
||||
std::unique_ptr<FluxSource> fluxSource(
|
||||
FluxSource::create(config.flux_source()));
|
||||
std::unique_ptr<FluxSink> fluxSink(FluxSink::create(config.flux_sink()));
|
||||
FluxSource::create(globalConfig().flux_source()));
|
||||
std::unique_ptr<FluxSink> fluxSink(
|
||||
FluxSink::create(globalConfig().flux_sink()));
|
||||
|
||||
rawReadDiskCommand(*fluxSource, *fluxSink);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ static StringFlag sourceFlux({"--source", "-s"},
|
||||
[](const auto& value)
|
||||
{
|
||||
FluxSource::updateConfigForFilename(
|
||||
config.mutable_flux_source(), value);
|
||||
globalConfig().mutable_flux_source(), value);
|
||||
});
|
||||
|
||||
static StringFlag destFlux({"--dest", "-d"},
|
||||
@@ -26,7 +26,8 @@ static StringFlag destFlux({"--dest", "-d"},
|
||||
"",
|
||||
[](const auto& value)
|
||||
{
|
||||
FluxSink::updateConfigForFilename(config.mutable_flux_sink(), value);
|
||||
FluxSink::updateConfigForFilename(
|
||||
globalConfig().mutable_flux_sink(), value);
|
||||
});
|
||||
|
||||
static StringFlag destTracks({"--cylinders", "-c"},
|
||||
@@ -34,7 +35,7 @@ static StringFlag destTracks({"--cylinders", "-c"},
|
||||
"",
|
||||
[](const auto& value)
|
||||
{
|
||||
setRange(config.mutable_tracks(), value);
|
||||
setRange(globalConfig().mutable_tracks(), value);
|
||||
});
|
||||
|
||||
static StringFlag destHeads({"--heads", "-h"},
|
||||
@@ -42,32 +43,33 @@ static StringFlag destHeads({"--heads", "-h"},
|
||||
"",
|
||||
[](const auto& value)
|
||||
{
|
||||
setRange(config.mutable_heads(), value);
|
||||
setRange(globalConfig().mutable_heads(), value);
|
||||
});
|
||||
|
||||
static ActionFlag eraseFlag({"--erase"},
|
||||
"erases the destination",
|
||||
[]()
|
||||
{
|
||||
config.mutable_flux_source()->set_type(FluxSourceProto::ERASE);
|
||||
globalConfig().mutable_flux_source()->set_type(FluxSourceProto::ERASE);
|
||||
});
|
||||
|
||||
int mainRawWrite(int argc, const char* argv[])
|
||||
{
|
||||
setRange(config.mutable_tracks(), "0-79");
|
||||
setRange(config.mutable_heads(), "0-1");
|
||||
setRange(globalConfig().mutable_tracks(), "0-79");
|
||||
setRange(globalConfig().mutable_heads(), "0-1");
|
||||
|
||||
if (argc == 1)
|
||||
showProfiles("rawwrite", formats);
|
||||
config.mutable_flux_sink()->set_type(FluxSinkProto::DRIVE);
|
||||
globalConfig().mutable_flux_sink()->set_type(FluxSinkProto::DRIVE);
|
||||
flags.parseFlagsWithConfigFiles(argc, argv, formats);
|
||||
|
||||
if (config.flux_source().type() == FluxSourceProto::DRIVE)
|
||||
if (globalConfig().flux_source().type() == FluxSourceProto::DRIVE)
|
||||
error("you can't use rawwrite to read from hardware");
|
||||
|
||||
std::unique_ptr<FluxSource> fluxSource(
|
||||
FluxSource::create(config.flux_source()));
|
||||
std::unique_ptr<FluxSink> fluxSink(FluxSink::create(config.flux_sink()));
|
||||
FluxSource::create(globalConfig().flux_source()));
|
||||
std::unique_ptr<FluxSink> fluxSink(
|
||||
FluxSink::create(globalConfig().flux_sink()));
|
||||
|
||||
writeRawDiskCommand(*fluxSource, *fluxSink);
|
||||
return 0;
|
||||
|
||||
@@ -23,7 +23,7 @@ static StringFlag sourceFlux({"-s", "--source"},
|
||||
[](const auto& value)
|
||||
{
|
||||
FluxSource::updateConfigForFilename(
|
||||
config.mutable_flux_source(), value);
|
||||
globalConfig().mutable_flux_source(), value);
|
||||
});
|
||||
|
||||
static StringFlag destImage({"-o", "--output"},
|
||||
@@ -32,7 +32,7 @@ static StringFlag destImage({"-o", "--output"},
|
||||
[](const auto& value)
|
||||
{
|
||||
ImageWriter::updateConfigForFilename(
|
||||
config.mutable_image_writer(), value);
|
||||
globalConfig().mutable_image_writer(), value);
|
||||
});
|
||||
|
||||
static StringFlag copyFluxTo({"--copy-flux-to"},
|
||||
@@ -41,7 +41,7 @@ static StringFlag copyFluxTo({"--copy-flux-to"},
|
||||
[](const auto& value)
|
||||
{
|
||||
FluxSink::updateConfigForFilename(
|
||||
config.mutable_decoder()->mutable_copy_flux_to(), value);
|
||||
globalConfig().mutable_decoder()->mutable_copy_flux_to(), value);
|
||||
});
|
||||
|
||||
static StringFlag srcTracks({"--cylinders", "-c"},
|
||||
@@ -49,7 +49,7 @@ static StringFlag srcTracks({"--cylinders", "-c"},
|
||||
"",
|
||||
[](const auto& value)
|
||||
{
|
||||
setRange(config.mutable_tracks(), value);
|
||||
setRange(globalConfig().mutable_tracks(), value);
|
||||
});
|
||||
|
||||
static StringFlag srcHeads({"--heads", "-h"},
|
||||
@@ -57,24 +57,24 @@ static StringFlag srcHeads({"--heads", "-h"},
|
||||
"",
|
||||
[](const auto& value)
|
||||
{
|
||||
setRange(config.mutable_heads(), value);
|
||||
setRange(globalConfig().mutable_heads(), value);
|
||||
});
|
||||
|
||||
int mainRead(int argc, const char* argv[])
|
||||
{
|
||||
if (argc == 1)
|
||||
showProfiles("read", formats);
|
||||
config.mutable_flux_source()->set_type(FluxSourceProto::DRIVE);
|
||||
globalConfig().mutable_flux_source()->set_type(FluxSourceProto::DRIVE);
|
||||
flags.parseFlagsWithConfigFiles(argc, argv, formats);
|
||||
|
||||
if (config.decoder().copy_flux_to().type() == FluxSinkProto::DRIVE)
|
||||
if (globalConfig().decoder().copy_flux_to().type() == FluxSinkProto::DRIVE)
|
||||
error("you cannot copy flux to a hardware device");
|
||||
|
||||
std::unique_ptr<FluxSource> fluxSource(
|
||||
FluxSource::create(config.flux_source()));
|
||||
std::unique_ptr<Decoder> decoder(Decoder::create(config.decoder()));
|
||||
FluxSource::create(globalConfig().flux_source()));
|
||||
std::unique_ptr<Decoder> decoder(Decoder::create(globalConfig().decoder()));
|
||||
std::unique_ptr<ImageWriter> writer(
|
||||
ImageWriter::create(config.image_writer()));
|
||||
ImageWriter::create(globalConfig().image_writer()));
|
||||
|
||||
readDiskCommand(*fluxSource, *decoder, *writer);
|
||||
|
||||
|
||||
@@ -13,19 +13,21 @@ static StringFlag sourceFlux({"-s", "--source"},
|
||||
[](const auto& value)
|
||||
{
|
||||
FluxSource::updateConfigForFilename(
|
||||
config.mutable_flux_source(), value);
|
||||
globalConfig().mutable_flux_source(), value);
|
||||
});
|
||||
|
||||
int mainRpm(int argc, const char* argv[])
|
||||
{
|
||||
flags.parseFlagsWithConfigFiles(argc, argv, {});
|
||||
|
||||
if (config.flux_source().type() != FluxSourceProto::DRIVE)
|
||||
if (globalConfig().flux_source().type() != FluxSourceProto::DRIVE)
|
||||
error("this only makes sense with a real disk drive");
|
||||
|
||||
usbSetDrive(config.drive().drive(), false, config.drive().index_mode());
|
||||
usbSetDrive(globalConfig().drive().drive(),
|
||||
false,
|
||||
globalConfig().drive().index_mode());
|
||||
nanoseconds_t period =
|
||||
usbGetRotationalPeriod(config.drive().hard_sector_count());
|
||||
usbGetRotationalPeriod(globalConfig().drive().hard_sector_count());
|
||||
if (period != 0)
|
||||
std::cout << "Rotational period is " << period / 1000000 << " ms ("
|
||||
<< 60e9 / period << " rpm)" << std::endl;
|
||||
|
||||
@@ -13,7 +13,7 @@ static StringFlag sourceFlux({"-s", "--source"},
|
||||
[](const auto& value)
|
||||
{
|
||||
FluxSource::updateConfigForFilename(
|
||||
config.mutable_flux_source(), value);
|
||||
globalConfig().mutable_flux_source(), value);
|
||||
});
|
||||
|
||||
static IntFlag track({"--cylinder", "-c"}, "track to seek to", 0);
|
||||
@@ -24,10 +24,12 @@ int mainSeek(int argc, const char* argv[])
|
||||
{
|
||||
flags.parseFlagsWithConfigFiles(argc, argv, {});
|
||||
|
||||
if (config.flux_source().type() != FluxSourceProto::DRIVE)
|
||||
if (globalConfig().flux_source().type() != FluxSourceProto::DRIVE)
|
||||
error("this only makes sense with a real disk drive");
|
||||
|
||||
usbSetDrive(config.drive().drive(), false, config.drive().index_mode());
|
||||
usbSetDrive(globalConfig().drive().drive(),
|
||||
false,
|
||||
globalConfig().drive().index_mode());
|
||||
usbSeek(track);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ static StringFlag sourceImage({"--input", "-i"},
|
||||
[](const auto& value)
|
||||
{
|
||||
ImageReader::updateConfigForFilename(
|
||||
config.mutable_image_reader(), value);
|
||||
globalConfig().mutable_image_reader(), value);
|
||||
});
|
||||
|
||||
static StringFlag destFlux({"--dest", "-d"},
|
||||
@@ -32,9 +32,10 @@ static StringFlag destFlux({"--dest", "-d"},
|
||||
"",
|
||||
[](const auto& value)
|
||||
{
|
||||
FluxSink::updateConfigForFilename(config.mutable_flux_sink(), value);
|
||||
FluxSink::updateConfigForFilename(
|
||||
globalConfig().mutable_flux_sink(), value);
|
||||
FluxSource::updateConfigForFilename(
|
||||
config.mutable_flux_source(), value);
|
||||
globalConfig().mutable_flux_source(), value);
|
||||
});
|
||||
|
||||
static StringFlag destTracks({"--cylinders", "-c"},
|
||||
@@ -42,7 +43,7 @@ static StringFlag destTracks({"--cylinders", "-c"},
|
||||
"",
|
||||
[](const auto& value)
|
||||
{
|
||||
setRange(config.mutable_tracks(), value);
|
||||
setRange(globalConfig().mutable_tracks(), value);
|
||||
});
|
||||
|
||||
static StringFlag destHeads({"--heads", "-h"},
|
||||
@@ -50,7 +51,7 @@ static StringFlag destHeads({"--heads", "-h"},
|
||||
"",
|
||||
[](const auto& value)
|
||||
{
|
||||
setRange(config.mutable_heads(), value);
|
||||
setRange(globalConfig().mutable_heads(), value);
|
||||
});
|
||||
|
||||
static ActionFlag noVerifyFlag({"--no-verify", "-n"},
|
||||
@@ -64,25 +65,27 @@ int mainWrite(int argc, const char* argv[])
|
||||
{
|
||||
if (argc == 1)
|
||||
showProfiles("write", formats);
|
||||
config.mutable_flux_sink()->set_type(FluxSinkProto::DRIVE);
|
||||
globalConfig().mutable_flux_sink()->set_type(FluxSinkProto::DRIVE);
|
||||
if (verify)
|
||||
config.mutable_flux_source()->set_type(FluxSourceProto::DRIVE);
|
||||
globalConfig().mutable_flux_source()->set_type(FluxSourceProto::DRIVE);
|
||||
flags.parseFlagsWithConfigFiles(argc, argv, formats);
|
||||
|
||||
std::unique_ptr<ImageReader> reader(
|
||||
ImageReader::create(config.image_reader()));
|
||||
ImageReader::create(globalConfig().image_reader()));
|
||||
std::shared_ptr<Image> image = reader->readMappedImage();
|
||||
|
||||
std::unique_ptr<Encoder> encoder(Encoder::create(config.encoder()));
|
||||
std::unique_ptr<FluxSink> fluxSink(FluxSink::create(config.flux_sink()));
|
||||
std::unique_ptr<Encoder> encoder(Encoder::create(globalConfig().encoder()));
|
||||
std::unique_ptr<FluxSink> fluxSink(
|
||||
FluxSink::create(globalConfig().flux_sink()));
|
||||
|
||||
std::unique_ptr<Decoder> decoder;
|
||||
if (config.has_decoder() && verify)
|
||||
decoder = Decoder::create(config.decoder());
|
||||
if (globalConfig().has_decoder() && verify)
|
||||
decoder = Decoder::create(globalConfig().decoder());
|
||||
|
||||
std::unique_ptr<FluxSource> fluxSource;
|
||||
if (verify && (config.flux_source().type() == FluxSourceProto::DRIVE))
|
||||
fluxSource = FluxSource::create(config.flux_source());
|
||||
if (verify &&
|
||||
(globalConfig().flux_source().type() == FluxSourceProto::DRIVE))
|
||||
fluxSource = FluxSource::create(globalConfig().flux_source());
|
||||
|
||||
writeDiskCommand(
|
||||
*image, *encoder, *fluxSink, decoder.get(), fluxSource.get());
|
||||
|
||||
@@ -22,9 +22,9 @@ static StringFlag image({"-i", "--image"},
|
||||
[](const auto& value)
|
||||
{
|
||||
ImageReader::updateConfigForFilename(
|
||||
config.mutable_image_reader(), value);
|
||||
globalConfig().mutable_image_reader(), value);
|
||||
ImageWriter::updateConfigForFilename(
|
||||
config.mutable_image_writer(), value);
|
||||
globalConfig().mutable_image_writer(), value);
|
||||
});
|
||||
|
||||
static StringFlag flux({"-f", "--flux"},
|
||||
@@ -33,6 +33,7 @@ static StringFlag flux({"-f", "--flux"},
|
||||
[](const auto& value)
|
||||
{
|
||||
FluxSource::updateConfigForFilename(
|
||||
config.mutable_flux_source(), value);
|
||||
FluxSink::updateConfigForFilename(config.mutable_flux_sink(), value);
|
||||
globalConfig().mutable_flux_source(), value);
|
||||
FluxSink::updateConfigForFilename(
|
||||
globalConfig().mutable_flux_sink(), value);
|
||||
});
|
||||
|
||||
@@ -163,7 +163,8 @@ private:
|
||||
if (!_explorerFluxmap || (desiredTrack != _explorerTrack) ||
|
||||
(desiredSide != _explorerSide))
|
||||
{
|
||||
auto fluxSource = FluxSource::create(config.flux_source());
|
||||
auto fluxSource =
|
||||
FluxSource::create(globalConfig().flux_source());
|
||||
_explorerFluxmap =
|
||||
fluxSource->readFlux(desiredTrack, desiredSide)->next();
|
||||
_explorerTrack = desiredTrack;
|
||||
|
||||
@@ -180,7 +180,7 @@ public:
|
||||
if (formatSelection == wxNOT_FOUND)
|
||||
error("no format selected");
|
||||
|
||||
config.Clear();
|
||||
globalConfig().Clear();
|
||||
auto formatName = _formatNames[formatChoice->GetSelection()];
|
||||
FlagGroup::parseConfigFile(formatName, formats);
|
||||
|
||||
@@ -196,9 +196,9 @@ public:
|
||||
|
||||
auto serial = _selectedDevice;
|
||||
if (!serial.empty() && (serial[0] == '/'))
|
||||
setProtoByString(&config, "usb.greaseweazle.port", serial);
|
||||
setProtoByString(&globalConfig(), "usb.greaseweazle.port", serial);
|
||||
else
|
||||
setProtoByString(&config, "usb.serial", serial);
|
||||
setProtoByString(&globalConfig(), "usb.serial", serial);
|
||||
|
||||
ClearLog();
|
||||
|
||||
@@ -208,14 +208,15 @@ public:
|
||||
{
|
||||
case SELECTEDSOURCE_REAL:
|
||||
{
|
||||
config.mutable_drive()->set_high_density(_selectedHighDensity);
|
||||
config.MergeFrom(*_selectedDriveType);
|
||||
globalConfig().mutable_drive()->set_high_density(
|
||||
_selectedHighDensity);
|
||||
globalConfig().MergeFrom(*_selectedDriveType);
|
||||
|
||||
std::string filename = _selectedDrive ? "drive:1" : "drive:0";
|
||||
FluxSink::updateConfigForFilename(
|
||||
config.mutable_flux_sink(), filename);
|
||||
globalConfig().mutable_flux_sink(), filename);
|
||||
FluxSource::updateConfigForFilename(
|
||||
config.mutable_flux_source(), filename);
|
||||
globalConfig().mutable_flux_source(), filename);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -223,18 +224,21 @@ public:
|
||||
case SELECTEDSOURCE_FLUX:
|
||||
{
|
||||
FluxSink::updateConfigForFilename(
|
||||
config.mutable_flux_sink(), _selectedFluxfilename);
|
||||
globalConfig().mutable_flux_sink(), _selectedFluxfilename);
|
||||
FluxSource::updateConfigForFilename(
|
||||
config.mutable_flux_source(), _selectedFluxfilename);
|
||||
globalConfig().mutable_flux_source(),
|
||||
_selectedFluxfilename);
|
||||
break;
|
||||
}
|
||||
|
||||
case SELECTEDSOURCE_IMAGE:
|
||||
{
|
||||
ImageReader::updateConfigForFilename(
|
||||
config.mutable_image_reader(), _selectedImagefilename);
|
||||
globalConfig().mutable_image_reader(),
|
||||
_selectedImagefilename);
|
||||
ImageWriter::updateConfigForFilename(
|
||||
config.mutable_image_writer(), _selectedImagefilename);
|
||||
globalConfig().mutable_image_writer(),
|
||||
_selectedImagefilename);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -254,7 +258,7 @@ public:
|
||||
{
|
||||
auto key = setting.substr(0, equals);
|
||||
auto value = setting.substr(equals + 1);
|
||||
setProtoByString(&config, key, value);
|
||||
setProtoByString(&globalConfig(), key, value);
|
||||
}
|
||||
else
|
||||
FlagGroup::parseConfigFile(setting, formats);
|
||||
@@ -585,12 +589,12 @@ private:
|
||||
formatOptionsContainer, wxID_ANY, "(no format selected)"));
|
||||
else
|
||||
{
|
||||
config.Clear();
|
||||
globalConfig().Clear();
|
||||
std::string formatName =
|
||||
_formatNames[formatChoice->GetSelection()];
|
||||
FlagGroup::parseConfigFile(formatName, formats);
|
||||
|
||||
for (auto& group : config.option_group())
|
||||
for (auto& group : globalConfig().option_group())
|
||||
{
|
||||
sizer->Add(new wxStaticText(formatOptionsContainer,
|
||||
wxID_ANY,
|
||||
@@ -642,7 +646,7 @@ private:
|
||||
|
||||
/* Anything that's _not_ in a group gets a checkbox. */
|
||||
|
||||
for (auto& option : config.option())
|
||||
for (auto& option : globalConfig().option())
|
||||
{
|
||||
auto* choice = new wxCheckBox(
|
||||
formatOptionsContainer, wxID_ANY, option.comment());
|
||||
@@ -665,7 +669,8 @@ private:
|
||||
});
|
||||
}
|
||||
|
||||
if (config.option().empty() && config.option_group().empty())
|
||||
if (globalConfig().option().empty() &&
|
||||
globalConfig().option_group().empty())
|
||||
sizer->Add(new wxStaticText(formatOptionsContainer,
|
||||
wxID_ANY,
|
||||
"(no options for this format)"));
|
||||
|
||||
@@ -98,8 +98,9 @@ public:
|
||||
|
||||
Environment::reset();
|
||||
|
||||
auto fluxSource = FluxSource::create(config.flux_source());
|
||||
auto decoder = Decoder::create(config.decoder());
|
||||
auto fluxSource =
|
||||
FluxSource::create(globalConfig().flux_source());
|
||||
auto decoder = Decoder::create(globalConfig().decoder());
|
||||
auto diskflux = readDiskCommand(*fluxSource, *decoder);
|
||||
|
||||
runOnUiThread(
|
||||
@@ -123,12 +124,15 @@ public:
|
||||
{
|
||||
SetPage(MainWindow::PAGE_IMAGER);
|
||||
PrepareConfig();
|
||||
if (!config.has_image_reader())
|
||||
if (!globalConfig().has_image_reader())
|
||||
error("This format cannot be read from images.");
|
||||
|
||||
auto filename = wxFileSelector("Choose a image file to read",
|
||||
/* default_path= */ wxEmptyString,
|
||||
/* default_filename= */ config.image_reader().filename(),
|
||||
/* default_filename= */
|
||||
globalConfig()
|
||||
.image_reader()
|
||||
.filename(),
|
||||
/* default_extension= */ wxEmptyString,
|
||||
/* wildcard= */ wxEmptyString,
|
||||
/* flags= */ wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
||||
@@ -136,9 +140,9 @@ public:
|
||||
return;
|
||||
|
||||
ImageReader::updateConfigForFilename(
|
||||
config.mutable_image_reader(), filename.ToStdString());
|
||||
globalConfig().mutable_image_reader(), filename.ToStdString());
|
||||
ImageWriter::updateConfigForFilename(
|
||||
config.mutable_image_writer(), filename.ToStdString());
|
||||
globalConfig().mutable_image_writer(), filename.ToStdString());
|
||||
visualiser->Clear();
|
||||
_currentDisk = nullptr;
|
||||
|
||||
@@ -146,17 +150,20 @@ public:
|
||||
QueueJob(
|
||||
[this]()
|
||||
{
|
||||
auto image = ImageReader::create(config.image_reader())
|
||||
->readMappedImage();
|
||||
auto encoder = Encoder::create(config.encoder());
|
||||
auto fluxSink = FluxSink::create(config.flux_sink());
|
||||
auto image =
|
||||
ImageReader::create(globalConfig().image_reader())
|
||||
->readMappedImage();
|
||||
auto encoder = Encoder::create(globalConfig().encoder());
|
||||
auto fluxSink =
|
||||
FluxSink::create(globalConfig().flux_sink());
|
||||
|
||||
std::unique_ptr<Decoder> decoder;
|
||||
std::unique_ptr<FluxSource> fluxSource;
|
||||
if (config.has_decoder())
|
||||
if (globalConfig().has_decoder())
|
||||
{
|
||||
decoder = Decoder::create(config.decoder());
|
||||
fluxSource = FluxSource::create(config.flux_source());
|
||||
decoder = Decoder::create(globalConfig().decoder());
|
||||
fluxSource =
|
||||
FluxSource::create(globalConfig().flux_source());
|
||||
}
|
||||
|
||||
writeDiskCommand(*image,
|
||||
@@ -243,13 +250,16 @@ public:
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!config.has_image_writer())
|
||||
if (!globalConfig().has_image_writer())
|
||||
error("This format cannot be saved.");
|
||||
|
||||
auto filename =
|
||||
wxFileSelector("Choose the name of the image file to write",
|
||||
/* default_path= */ wxEmptyString,
|
||||
/* default_filename= */ config.image_writer().filename(),
|
||||
/* default_filename= */
|
||||
globalConfig()
|
||||
.image_writer()
|
||||
.filename(),
|
||||
/* default_extension= */ wxEmptyString,
|
||||
/* wildcard= */ wxEmptyString,
|
||||
/* flags= */ wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||
@@ -257,7 +267,7 @@ public:
|
||||
return;
|
||||
|
||||
ImageWriter::updateConfigForFilename(
|
||||
config.mutable_image_writer(), filename.ToStdString());
|
||||
globalConfig().mutable_image_writer(), filename.ToStdString());
|
||||
|
||||
auto image = _currentDisk->image;
|
||||
|
||||
@@ -265,7 +275,7 @@ public:
|
||||
[image, this]()
|
||||
{
|
||||
auto imageWriter =
|
||||
ImageWriter::create(config.image_writer());
|
||||
ImageWriter::create(globalConfig().image_writer());
|
||||
imageWriter->writeMappedImage(*image);
|
||||
});
|
||||
}
|
||||
@@ -290,14 +300,15 @@ public:
|
||||
return;
|
||||
|
||||
FluxSink::updateConfigForFilename(
|
||||
config.mutable_flux_sink(), filename.ToStdString());
|
||||
globalConfig().mutable_flux_sink(), filename.ToStdString());
|
||||
|
||||
QueueJob(
|
||||
[this]()
|
||||
{
|
||||
auto fluxSource =
|
||||
FluxSource::createMemoryFluxSource(*_currentDisk);
|
||||
auto fluxSink = FluxSink::create(config.flux_sink());
|
||||
auto fluxSink =
|
||||
FluxSink::create(globalConfig().flux_sink());
|
||||
writeRawDiskCommand(*fluxSource, *fluxSink);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ public:
|
||||
void ShowConfig()
|
||||
{
|
||||
std::string s;
|
||||
google::protobuf::TextFormat::PrintToString(config, &s);
|
||||
google::protobuf::TextFormat::PrintToString(globalConfig(), &s);
|
||||
_configWindow->GetTextControl()->Clear();
|
||||
_configWindow->GetTextControl()->AppendText(s);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,8 @@ static void setBlock(
|
||||
static void testPartialExtent()
|
||||
{
|
||||
auto sectors = std::make_shared<TestSectorInterface>();
|
||||
auto fs = Filesystem::createCpmFsFilesystem(config.filesystem(), sectors);
|
||||
auto fs =
|
||||
Filesystem::createCpmFsFilesystem(globalConfig().filesystem(), sectors);
|
||||
|
||||
setBlock(sectors,
|
||||
0,
|
||||
@@ -91,7 +92,8 @@ static void testPartialExtent()
|
||||
static void testLogicalExtents()
|
||||
{
|
||||
auto sectors = std::make_shared<TestSectorInterface>();
|
||||
auto fs = Filesystem::createCpmFsFilesystem(config.filesystem(), sectors);
|
||||
auto fs =
|
||||
Filesystem::createCpmFsFilesystem(globalConfig().filesystem(), sectors);
|
||||
|
||||
setBlock(sectors,
|
||||
0,
|
||||
@@ -141,7 +143,7 @@ int main(void)
|
||||
}
|
||||
}
|
||||
)M";
|
||||
google::protobuf::TextFormat::MergeFromString(text, &config);
|
||||
google::protobuf::TextFormat::MergeFromString(text, &globalConfig());
|
||||
|
||||
testPartialExtent();
|
||||
testLogicalExtents();
|
||||
|
||||
@@ -19,8 +19,9 @@ static std::string cleanup(const std::string& s)
|
||||
|
||||
static void load_config(const std::string s)
|
||||
{
|
||||
config.Clear();
|
||||
if (!google::protobuf::TextFormat::MergeFromString(cleanup(s), &config))
|
||||
globalConfig().Clear();
|
||||
if (!google::protobuf::TextFormat::MergeFromString(
|
||||
cleanup(s), &globalConfig()))
|
||||
error("couldn't load test config");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user