diff --git a/sim_disk.c b/sim_disk.c index 6e016fdd..899a077b 100644 --- a/sim_disk.c +++ b/sim_disk.c @@ -1077,6 +1077,7 @@ static t_offset get_ods2_filesystem_size (UNIT *uptr) { DEVICE *dptr; t_addr saved_capac; +struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx; t_offset temp_capac = 512 * (t_offset)0xFFFFFFFFu; /* Make sure we can access the largest sector */ uint32 capac_factor; ODS2_HomeBlock Home; @@ -1092,7 +1093,7 @@ if ((dptr = find_dev_from_unit (uptr)) == NULL) capac_factor = ((dptr->dwidth / dptr->aincr) == 16) ? 2 : 1; /* save capacity units (word: 2, byte: 1) */ saved_capac = uptr->capac; uptr->capac = (t_addr)(temp_capac/(capac_factor*((dptr->flags & DEV_SECTORS) ? 512 : 1))); -if (sim_disk_rdsect (uptr, 1, (uint8 *)&Home, NULL, 1)) +if (sim_disk_rdsect (uptr, 512 / ctx->sector_size, (uint8 *)&Home, NULL, sizeof (Home) / ctx->sector_size)) goto Return_Cleanup; CheckSum1 = ODSChecksum (&Home, (uint16)((((char *)&Home.hm2_w_checksum1)-((char *)&Home.hm2_l_homelbn))/2)); CheckSum2 = ODSChecksum (&Home, (uint16)((((char *)&Home.hm2_w_checksum2)-((char *)&Home.hm2_l_homelbn))/2)); @@ -1112,7 +1113,8 @@ if ((Home.hm2_l_homelbn == 0) || (Home.hm2_w_checksum1 != CheckSum1) || (Home.hm2_w_checksum2 != CheckSum2)) goto Return_Cleanup; -if (sim_disk_rdsect (uptr, Home.hm2_l_ibmaplbn+Home.hm2_w_ibmapsize+1, (uint8 *)&Header, NULL, 1)) +if (sim_disk_rdsect (uptr, (Home.hm2_l_ibmaplbn+Home.hm2_w_ibmapsize+1) * (512 / ctx->sector_size), + (uint8 *)&Header, NULL, sizeof (Header) / ctx->sector_size)) goto Return_Cleanup; CheckSum1 = ODSChecksum (&Header, 255); if (CheckSum1 != *(((uint16 *)&Header)+255)) /* Verify Checksum on BITMAP.SYS file header */ @@ -1134,7 +1136,7 @@ switch (Retr->fm2_r_word0_bits.fm2_v_format) break; } Retr = (ODS2_Retreval *)(((uint16 *)Retr)+Retr->fm2_r_word0_bits.fm2_v_format+1); -if (sim_disk_rdsect (uptr, ScbLbn, (uint8 *)&Scb, NULL, 1)) +if (sim_disk_rdsect (uptr, ScbLbn * (512 / ctx->sector_size), (uint8 *)&Scb, NULL, sizeof (Scb) / ctx->sector_size)) goto Return_Cleanup; CheckSum1 = ODSChecksum (&Scb, 255); if (CheckSum1 != *(((uint16 *)&Scb)+255)) /* Verify Checksum on Storage Control Block */ @@ -1160,6 +1162,7 @@ static t_offset get_ods1_filesystem_size (UNIT *uptr) { DEVICE *dptr; t_addr saved_capac; +struct disk_context *ctx = (struct disk_context *)uptr->disk_ctx; t_offset temp_capac = 512 * (t_offset)0xFFFFFFFFu; /* Make sure we can access the largest sector */ uint32 capac_factor; ODS1_HomeBlock Home; @@ -1176,7 +1179,7 @@ if ((dptr = find_dev_from_unit (uptr)) == NULL) capac_factor = ((dptr->dwidth / dptr->aincr) == 16) ? 2 : 1; /* save capacity units (word: 2, byte: 1) */ saved_capac = uptr->capac; uptr->capac = (t_addr)(temp_capac/(capac_factor*((dptr->flags & DEV_SECTORS) ? 512 : 1))); -if (sim_disk_rdsect (uptr, 1, (uint8 *)&Home, NULL, 1)) +if (sim_disk_rdsect (uptr, 512 / ctx->sector_size, (uint8 *)&Home, NULL, sizeof (Home) / ctx->sector_size)) goto Return_Cleanup; CheckSum1 = ODSChecksum (&Home, (uint16)((((char *)&Home.hm1_w_checksum1)-((char *)&Home.hm1_w_ibmapsize))/2)); CheckSum2 = ODSChecksum (&Home, (uint16)((((char *)&Home.hm1_w_checksum2)-((char *)&Home.hm1_w_ibmapsize))/2)); @@ -1189,7 +1192,8 @@ if ((Home.hm1_w_ibmapsize == 0) || (Home.hm1_w_checksum1 != CheckSum1) || (Home.hm1_w_checksum2 != CheckSum2)) goto Return_Cleanup; -if (sim_disk_rdsect (uptr, ((Home.hm1_l_ibmaplbn << 16) + ((Home.hm1_l_ibmaplbn >> 16) & 0xFFFF)) + Home.hm1_w_ibmapsize + 1, (uint8 *)&Header, NULL, 1)) +if (sim_disk_rdsect (uptr, (((Home.hm1_l_ibmaplbn << 16) + ((Home.hm1_l_ibmaplbn >> 16) & 0xFFFF)) + Home.hm1_w_ibmapsize + 1) * (512 / ctx->sector_size), + (uint8 *)&Header, NULL, sizeof (Header) / ctx->sector_size)) goto Return_Cleanup; CheckSum1 = ODSChecksum (&Header, 255); if (CheckSum1 != *(((uint16 *)&Header)+255)) /* Verify Checksum on BITMAP.SYS file header */ @@ -1197,7 +1201,7 @@ if (CheckSum1 != *(((uint16 *)&Header)+255)) /* Verify Checksum on BITMAP.SYS fi Retr = (ODS1_Retreval *)(((uint16*)(&Header))+Header.fh1_b_mpoffset); ScbLbn = (Retr->fm1_pointers[0].fm1_s_fm1def1.fm1_b_highlbn<<16)+Retr->fm1_pointers[0].fm1_s_fm1def1.fm1_w_lowlbn; -if (sim_disk_rdsect (uptr, ScbLbn, (uint8 *)Scb, NULL, 1)) +if (sim_disk_rdsect (uptr, ScbLbn * (512 / ctx->sector_size), (uint8 *)Scb, NULL, 512 / ctx->sector_size)) goto Return_Cleanup; if (Scb->scb_b_bitmapblks < 127) ret_val = (((t_offset)Scb->scb_r_blocks[Scb->scb_b_bitmapblks].scb_w_freeblks << 16) + Scb->scb_r_blocks[Scb->scb_b_bitmapblks].scb_w_freeptr) * 512;