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

Method decodeSectorRecord

arch/mx/decoder.cc:50–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48 }
49
50 void decodeSectorRecord() override
51 {
52 /* Skip the ID pattern and track word, which is only present on the
53 * first sector. We don't trust the track word because some driver
54 * don't write it correctly. */
55
56 if (_currentSector == 0)
57 readRawBits(64);
58
59 auto bits = readRawBits((SECTOR_SIZE + 2) * 16);
60 auto bytes = decodeFmMfm(bits).slice(0, SECTOR_SIZE + 2);
61
62 uint16_t gotChecksum = 0;
63 ByteReader br(bytes);
64 for (int i = 0; i < (SECTOR_SIZE / 2); i++)
65 gotChecksum += br.read_be16();
66 uint16_t wantChecksum = br.read_be16();
67
68 _sector->logicalCylinder = _ltl->logicalCylinder;
69 _sector->logicalHead = _ltl->logicalHead;
70 _sector->logicalSector = _currentSector;
71 _sector->data = bytes.slice(0, SECTOR_SIZE).swab();
72 _sector->status =
73 (gotChecksum == wantChecksum) ? Sector::OK : Sector::BAD_CHECKSUM;
74 _currentSector++;
75 }
76
77private:
78 nanoseconds_t _clock;

Callers

nothing calls this directly

Calls 4

sliceMethod · 0.80
read_be16Method · 0.80
swabMethod · 0.80
decodeFmMfmFunction · 0.50

Tested by

no test coverage detected