mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Add firmware support for hard sectors
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "fluxmap.h"
|
||||
#include "usb/usb.h"
|
||||
#include "fluxsink/fluxsink.h"
|
||||
#include "fmt/format.h"
|
||||
|
||||
FlagGroup hardwareFluxSinkFlags = {
|
||||
&usbFlags,
|
||||
@@ -15,17 +16,34 @@ static IntFlag indexMode(
|
||||
"index pulse source (0=drive, 1=300 RPM fake source, 2=360 RPM fake source",
|
||||
0);
|
||||
|
||||
static IntFlag hardSectorCount(
|
||||
{ "--write-hard-sector-count" },
|
||||
"number of hard sectors on the disk (0=soft sectors)",
|
||||
0);
|
||||
|
||||
void setHardwareFluxSinkDensity(bool high_density)
|
||||
{
|
||||
::high_density = high_density;
|
||||
}
|
||||
|
||||
void setHardwareFluxSinkHardSectorCount(int sectorCount)
|
||||
{
|
||||
::hardSectorCount.setDefaultValue(sectorCount);
|
||||
}
|
||||
|
||||
class HardwareFluxSink : public FluxSink
|
||||
{
|
||||
public:
|
||||
HardwareFluxSink(unsigned drive):
|
||||
_drive(drive)
|
||||
{
|
||||
if (hardSectorCount.get())
|
||||
{
|
||||
std::cerr << "Measuring rotational speed... " << std::flush;
|
||||
nanoseconds_t oneRevolution = usbGetRotationalPeriod(hardSectorCount);
|
||||
_hardSectorThreshold = oneRevolution * 3 / (4 * hardSectorCount);
|
||||
std::cerr << fmt::format("{}ms\n", oneRevolution / 1e6);
|
||||
}
|
||||
}
|
||||
|
||||
~HardwareFluxSink()
|
||||
@@ -38,11 +56,12 @@ public:
|
||||
usbSetDrive(_drive, high_density, indexMode);
|
||||
usbSeek(track);
|
||||
|
||||
return usbWrite(side, fluxmap.rawBytes());
|
||||
return usbWrite(side, fluxmap.rawBytes(), _hardSectorThreshold);
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned _drive;
|
||||
nanoseconds_t _hardSectorThreshold;
|
||||
};
|
||||
|
||||
std::unique_ptr<FluxSink> FluxSink::createHardwareFluxSink(unsigned drive)
|
||||
|
||||
Reference in New Issue
Block a user