1.1 --- a/src/wd279x.c Mon Dec 13 03:00:43 2010 +0000 1.2 +++ b/src/wd279x.c Tue Dec 14 02:41:40 2010 +0000 1.3 @@ -170,9 +170,9 @@ 1.4 // Get current status flags (set by last command) 1.5 // DRQ bit 1.6 if (ctx->cmd_has_drq) { 1.7 - printf("\tWDFDC rd sr, has drq, pos=%lu len=%lu\n", ctx->data_pos, ctx->data_len); 1.8 temp = ctx->status & ~0x03; 1.9 temp |= (ctx->data_pos < ctx->data_len) ? 0x02 : 0x00; 1.10 + printf("\tWDFDC rd sr, has drq, pos=%lu len=%lu, sr=0x%02X\n", ctx->data_pos, ctx->data_len, temp); 1.11 } else { 1.12 temp = ctx->status & ~0x01; 1.13 } 1.14 @@ -384,6 +384,20 @@ 1.15 ctx->head = (val & 0x02) ? 1 : 0; 1.16 printf("WD279X: READ SECTOR cmd=%02X chs=%d:%d:%d\n", cmd, ctx->track, ctx->head, ctx->sector); 1.17 // Read Sector or Read Sector Multiple 1.18 + 1.19 + // Check to see if the cyl, hd and sec are valid 1.20 + if ((ctx->track > (ctx->geom_tracks-1)) || (ctx->head > (ctx->geom_heads-1)) || (ctx->sector > ctx->geom_spt) || (ctx->sector == 0)) { 1.21 + fprintf(stderr, "*** WD2797 ALERT: CHS parameter limit exceeded! CHS=%d:%d:%d, maxCHS=%d:%d:%d\n", 1.22 + ctx->track, ctx->head, ctx->sector, 1.23 + ctx->geom_tracks-1, ctx->geom_heads-1, ctx->geom_spt); 1.24 + // CHS parameters exceed limits 1.25 + ctx->status = 0x10; // Record Not Found 1.26 + break; 1.27 + // Set IRQ only if IRQL has been cleared (no pending IRQs) 1.28 + ctx->irqe = ctx->irql ? ctx->irqe : true; 1.29 + ctx->irql = true; 1.30 + } 1.31 + 1.32 // reset data pointers 1.33 ctx->data_pos = ctx->data_len = 0; 1.34 1.35 @@ -395,7 +409,11 @@ 1.36 1.37 for (int i=0; i<temp; i++) { 1.38 // Calculate the LBA address of the required sector 1.39 - lba = ((((ctx->track * ctx->geom_heads) + ctx->head) * ctx->geom_spt) + ((ctx->sector + i - 1) % ctx->geom_spt)) * ctx->geom_secsz; 1.40 +// lba = ((((ctx->track * ctx->geom_heads) + ctx->head) * ctx->geom_spt) + ((ctx->sector + i - 1) % ctx->geom_spt)) * ctx->geom_secsz; 1.41 + // LBA = (C * nHeads * nSectors) + (H * nSectors) + S - 1 1.42 + lba = (((ctx->track * ctx->geom_heads * ctx->geom_spt) + (ctx->head * ctx->geom_spt) + ctx->sector) + i) - 1; 1.43 + // convert LBA to byte address 1.44 + lba *= ctx->geom_secsz; 1.45 printf("\tREAD lba = %lu\n", lba); 1.46 1.47 // Read the sector from the file 1.48 @@ -408,7 +426,7 @@ 1.49 ctx->status = 0; 1.50 // B6 = 0 1.51 // B5 = Record Type -- 1 = deleted, 0 = normal. We can't emulate anything but normal data blocks. 1.52 - // B4 = Record Not Found. We're not going to see this... FIXME-not emulated 1.53 + // B4 = Record Not Found. Basically, the CHS parameters are bullcrap. 1.54 // B3 = CRC Error. Not possible. 1.55 // B2 = Lost Data. Caused if DRQ isn't serviced in time. FIXME-not emulated 1.56 // B1 = DRQ. Data request.