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

Method decodeSectorRecord

arch/northstar/decoder.cc:141–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139 }
140
141 void decodeSectorRecord() override
142 {
143 uint64_t id = toBytes(readRawBits(64)).reader().read_be64();
144 unsigned recordSize, payloadSize, headerSize;
145
146 if (id == MFM_ID)
147 {
148 recordSize = NORTHSTAR_ENCODED_SECTOR_SIZE_DD;
149 payloadSize = NORTHSTAR_PAYLOAD_SIZE_DD;
150 headerSize = NORTHSTAR_HEADER_SIZE_DD;
151 }
152 else
153 {
154 recordSize = NORTHSTAR_ENCODED_SECTOR_SIZE_SD;
155 payloadSize = NORTHSTAR_PAYLOAD_SIZE_SD;
156 headerSize = NORTHSTAR_HEADER_SIZE_SD;
157 }
158
159 auto rawbits = readRawBits(recordSize * 16);
160 auto bytes = decodeFmMfm(rawbits).slice(0, recordSize);
161 ByteReader br(bytes);
162
163 _sector->logicalHead = _ltl->logicalHead;
164 _sector->logicalSector = _hardSectorId;
165 _sector->logicalCylinder = _ltl->logicalCylinder;
166
167 if (headerSize == NORTHSTAR_HEADER_SIZE_DD)
168 {
169 br.read_8(); /* MFM second Sync char, usually 0xFB */
170 }
171
172 _sector->data = br.read(payloadSize);
173 uint8_t wantChecksum = br.read_8();
174 uint8_t gotChecksum =
175 northstarChecksum(bytes.slice(headerSize - 1, payloadSize));
176 _sector->status =
177 (wantChecksum == gotChecksum) ? Sector::OK : Sector::BAD_CHECKSUM;
178 }
179
180private:
181 const NorthstarDecoderProto& _config;

Callers

nothing calls this directly

Calls 8

northstarChecksumFunction · 0.85
read_be64Method · 0.80
readerMethod · 0.80
sliceMethod · 0.80
read_8Method · 0.80
toBytesFunction · 0.50
decodeFmMfmFunction · 0.50
readMethod · 0.45

Tested by

no test coverage detected