Skip to content

Commit 4e5730c

Browse files
committed
fix(fdc): implemented preliminary response for reading
1 parent 6cb0dcb commit 4e5730c

2 files changed

Lines changed: 28 additions & 5 deletions

File tree

src/fdc.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,12 +352,28 @@ static uint8_t exec_read_data(uint8_t value) {
352352
}
353353

354354
static void post_exec_read_data(void) {
355+
rw_args_t *rw_args = (rw_args_t *)args;
356+
355357
LOG_DEBUG("Read has ended\n");
356358
// TODO(giulio): populate result (which is pretty the same for read,
357359
// write, ...)
358360
memset(result, 0x00, sizeof(result));
359361

360362
// TODO(giuliof): populate result as in datasheet (see table 2)
363+
/* ST0 */
364+
// Current head position
365+
result[0] |= rw_args->unit_select;
366+
result[0] |= rw_args->head_address ? FDC_ST0_HD : 0;
367+
/* ST1 */
368+
result[1] |= 0; // TODO(giuliof): populate this
369+
/* ST2 */
370+
result[2] |= 0; // TODO(giuliof): populate this
371+
/* CHR */
372+
result[3] = rw_args->cylinder;
373+
result[4] = rw_args->head;
374+
result[5] = rw_args->record;
375+
/* Sector size factor */
376+
result[6] = rw_args->n;
361377
}
362378

363379
// Recalibrate:

src/tests/test_fdc.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,17 @@ Test(ceda_fdc, readCommand) {
176176
fdc_out(FDC_ADDR_DATA_REGISTER, FDC_READ_DATA);
177177

178178
// 1st argument is number of drive
179-
fdc_out(FDC_ADDR_DATA_REGISTER, 0);
179+
fdc_out(FDC_ADDR_DATA_REGISTER, 2 | 1 << 2);
180180
// 2nd argument is cylinder number
181-
fdc_out(FDC_ADDR_DATA_REGISTER, 1);
181+
fdc_out(FDC_ADDR_DATA_REGISTER, 7);
182182
// 3rd argument is head number
183183
fdc_out(FDC_ADDR_DATA_REGISTER, 1);
184184
// 4th argument is record number
185-
fdc_out(FDC_ADDR_DATA_REGISTER, 1);
185+
fdc_out(FDC_ADDR_DATA_REGISTER, 5);
186186
// 5th argument is bytes per sector factor
187187
fdc_out(FDC_ADDR_DATA_REGISTER, 1);
188188
// 6th argument is EOT
189-
fdc_out(FDC_ADDR_DATA_REGISTER, 2);
189+
fdc_out(FDC_ADDR_DATA_REGISTER, 10);
190190
// 7th argument is GPL
191191
fdc_out(FDC_ADDR_DATA_REGISTER, 0);
192192
// 8th argument is DTL
@@ -221,5 +221,12 @@ Test(ceda_fdc, readCommand) {
221221
// Execution is finished, but still busy waiting for read of results
222222
assert_fdc_sr(FDC_ST_RQM);
223223

224-
// TODO: check te content of result (currently not implemented)
224+
// check the content of result
225+
cr_expect_eq(result[0], FDC_ST0_HD | 2);
226+
cr_expect_eq(result[1], 0);
227+
cr_expect_eq(result[2], 0);
228+
cr_expect_eq(result[3], 7);
229+
cr_expect_eq(result[4], 1);
230+
cr_expect_eq(result[5], 6);
231+
cr_expect_eq(result[6], 1);
225232
}

0 commit comments

Comments
 (0)