MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / AgatDecoder

Class AgatDecoder

arch/agat/decoder.cc:43–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41static const FluxMatchers ALL_PATTERNS = {&SECTOR_PATTERN, &DATA_PATTERN};
42
43class AgatDecoder : public Decoder
44{
45public:
46 AgatDecoder(const DecoderProto& config): Decoder(config) {}
47
48 nanoseconds_t advanceToNextRecord() override
49 {
50 return seekToPattern(ALL_PATTERNS);
51 }
52
53 void decodeSectorRecord() override
54 {
55 if (readRaw64() != SECTOR_ID)
56 return;
57
58 auto bytes = decodeFmMfm(readRawBits(64)).slice(0, 4);
59 if (bytes[3] != 0x5a)
60 return;
61
62 _sector->logicalCylinder = bytes[1] >> 1;
63 _sector->logicalSector = bytes[2];
64 _sector->logicalHead = bytes[1] & 1;
65 _sector->status = Sector::DATA_MISSING; /* unintuitive but correct */
66 }
67
68 void decodeDataRecord() override
69 {
70 if (readRaw64() != DATA_ID)
71 return;
72
73 Bytes bytes = decodeFmMfm(readRawBits((AGAT_SECTOR_SIZE + 2) * 16))
74 .slice(0, AGAT_SECTOR_SIZE + 2);
75
76 if (bytes[AGAT_SECTOR_SIZE + 1] != 0x5a)
77 return;
78
79 _sector->data = bytes.slice(0, AGAT_SECTOR_SIZE);
80 uint8_t wantChecksum = bytes[AGAT_SECTOR_SIZE];
81 uint8_t gotChecksum = agatChecksum(_sector->data);
82 _sector->status =
83 (wantChecksum == gotChecksum) ? Sector::OK : Sector::BAD_CHECKSUM;
84 }
85};
86
87std::unique_ptr<Decoder> createAgatDecoder(const DecoderProto& config)
88{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected