Skip to content

Commit

Permalink
Revert "enhancement: Add harddrive 0x76 partition support updates and…
Browse files Browse the repository at this point in the history
… fixes."

This reverts commit fc7e427
It caused issues with writing partition tables to HDFs
  • Loading branch information
midwan committed Nov 13, 2023
1 parent 6e24c57 commit 494761c
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 247 deletions.
32 changes: 12 additions & 20 deletions src/filesys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7894,7 +7894,6 @@ static void dump_partinfo (struct hardfiledata *hfd, uae_u8 *pp)
uae_u32 block, flags;
uae_u8 buf[512];
TCHAR dt[32];
uae_u32 error = 0;

flags = rl (pp + 20);
pp[37 + pp[36]] = 0;
Expand Down Expand Up @@ -7923,7 +7922,7 @@ static void dump_partinfo (struct hardfiledata *hfd, uae_u8 *pp)
write_log (_T("Empty drive\n"));
} else {
block = lowcyl * surfaces * spt;
if (hdf_read (hfd, buf, (uae_u64)blocksize * block, sizeof buf, &error)) {
if (hdf_read (hfd, buf, (uae_u64)blocksize * block, sizeof buf)) {
write_log (_T("First block %d dostype: %08X (%s)\n"), block, rl (buf), dostypes (dt, rl (buf)));
} else {
write_log (_T("First block %d read failed!\n"), block);
Expand Down Expand Up @@ -7956,7 +7955,6 @@ static void dumprdbblock(const uae_u8 *buf, int block)
static void dump_rdb (UnitInfo *uip, struct hardfiledata *hfd, uae_u8 *bufrdb, uae_u8 *buf, int readblocksize)
{
TCHAR dt[32];
uae_u32 error = 0;

write_log (_T("RDB: HostID: %08x Flags: %08x\n"),
rl (bufrdb + 3 * 4), rl (bufrdb + 5 * 4));
Expand All @@ -7977,7 +7975,7 @@ static void dump_rdb (UnitInfo *uip, struct hardfiledata *hfd, uae_u8 *bufrdb, u
break;
}
memset (buf, 0, readblocksize);
hdf_read (hfd, buf, partblock * hfd->ci.blocksize, readblocksize, &error);
hdf_read (hfd, buf, partblock * hfd->ci.blocksize, readblocksize);
if (!rdb_checksum ("PART", buf, partblock)) {
write_log (_T("RDB: checksum error PART block %d\n"), partblock);
dumprdbblock(buf, partblock);
Expand All @@ -8000,7 +7998,7 @@ static void dump_rdb (UnitInfo *uip, struct hardfiledata *hfd, uae_u8 *bufrdb, u
break;
}
memset (buf, 0, readblocksize);
hdf_read (hfd, buf, fileblock * hfd->ci.blocksize, readblocksize, &error);
hdf_read (hfd, buf, fileblock * hfd->ci.blocksize, readblocksize);
if (!rdb_checksum ("FSHD", buf, fileblock)) {
write_log (_T("RDB: checksum error FSHD block %d\n"), fileblock);
dumprdbblock(buf, fileblock);
Expand Down Expand Up @@ -8050,7 +8048,6 @@ static int pt_babe(TrapContext *ctx, uae_u8 *bufrdb, UnitInfo *uip, int unit_no,
struct hardfiledata *hfd = &uip->hf;
struct uaedev_config_info *ci = &uip[unit_no].hf.ci;
uae_u32 bad;
uae_u32 error = 0;

uae_u32 bs = (bufrdb[0x20] << 24) | (bufrdb[0x21] << 16) | (bufrdb[0x22] << 8) | (bufrdb[0x23] << 0);
int bscnt;
Expand All @@ -8065,7 +8062,7 @@ static int pt_babe(TrapContext *ctx, uae_u8 *bufrdb, UnitInfo *uip, int unit_no,
if (bad) {
if (bad * hfd->ci.blocksize > FILESYS_MAX_BLOCKSIZE)
return 0;
hdf_read_rdb(hfd, bufrdb2, bad * hfd->ci.blocksize, hfd->ci.blocksize, &error);
hdf_read_rdb(hfd, bufrdb2, bad * hfd->ci.blocksize, hfd->ci.blocksize);
if (bufrdb2[0] != 0xBA || bufrdb2[1] != 0xD1)
return 0;
}
Expand Down Expand Up @@ -8142,7 +8139,6 @@ static int pt_rdsk (TrapContext *ctx, uae_u8 *bufrdb, int rdblock, UnitInfo *uip
TCHAR *s;
bool showdebug = partnum == 0;
int cnt;
uae_u32 error = 0;

blocksize = rl (bufrdb + 16);
readblocksize = blocksize > hfd->ci.blocksize ? blocksize : hfd->ci.blocksize;
Expand Down Expand Up @@ -8187,7 +8183,7 @@ static int pt_rdsk (TrapContext *ctx, uae_u8 *bufrdb, int rdblock, UnitInfo *uip
goto error;
}
memset (buf, 0, readblocksize);
hdf_read (hfd, buf, partblock * hfd->ci.blocksize, readblocksize, &error);
hdf_read (hfd, buf, partblock * hfd->ci.blocksize, readblocksize);
if (!rdb_checksum ("PART", buf, partblock)) {
err = -2;
write_log(_T("RDB: checksum error in PART block %d\n"), partblock);
Expand Down Expand Up @@ -8265,7 +8261,7 @@ static int pt_rdsk (TrapContext *ctx, uae_u8 *bufrdb, int rdblock, UnitInfo *uip
goto error;
}
memset (buf, 0, readblocksize);
hdf_read (hfd, buf, fileblock * hfd->ci.blocksize, readblocksize, &error);
hdf_read (hfd, buf, fileblock * hfd->ci.blocksize, readblocksize);
if (!rdb_checksum ("FSHD", buf, fileblock)) {
write_log (_T("RDB: checksum error in FSHD block %d\n"), fileblock);
dumprdbblock(buf, fileblock);
Expand Down Expand Up @@ -8300,7 +8296,7 @@ static int pt_rdsk (TrapContext *ctx, uae_u8 *bufrdb, int rdblock, UnitInfo *uip
if (!legalrdbblock (uip, lsegblock))
goto error;
memset (buf, 0, readblocksize);
hdf_read (hfd, buf, lsegblock * hfd->ci.blocksize, readblocksize, &error);
hdf_read (hfd, buf, lsegblock * hfd->ci.blocksize, readblocksize);
if (!rdb_checksum("LSEG", buf, lsegblock)) {
write_log(_T("RDB: checksum error in LSEG block %d\n"), lsegblock);
dumprdbblock(buf, lsegblock);
Expand Down Expand Up @@ -8334,7 +8330,6 @@ static int rdb_mount (TrapContext *ctx, UnitInfo *uip, int unit_no, int partnum,
struct hardfiledata *hfd = &uip->hf;
int lastblock = 63, rdblock;
uae_u8 bufrdb[FILESYS_MAX_BLOCKSIZE];
uae_u32 error = 0;

write_log (_T("%s:\n"), uip->rootdir);
if (hfd->drive_empty) {
Expand All @@ -8359,8 +8354,8 @@ static int rdb_mount (TrapContext *ctx, UnitInfo *uip, int unit_no, int partnum,
}

for (rdblock = 0; rdblock < lastblock; rdblock++) {
hdf_read_rdb (hfd, bufrdb, rdblock * hfd->ci.blocksize, hfd->ci.blocksize, &error);
if (!error && rdblock == 0 && bufrdb[0] == 0xBA && bufrdb[1] == 0xBE) {
hdf_read_rdb (hfd, bufrdb, rdblock * hfd->ci.blocksize, hfd->ci.blocksize);
if (rdblock == 0 && bufrdb[0] == 0xBA && bufrdb[1] == 0xBE) {
// A2090 "BABE" partition table?
int v = pt_babe(ctx, bufrdb, uip, unit_no, partnum, parmpacket);
if (v)
Expand All @@ -8371,14 +8366,13 @@ static int rdb_mount (TrapContext *ctx, UnitInfo *uip, int unit_no, int partnum,
return pt_rdsk(ctx, bufrdb, rdblock, uip, unit_no, partnum, parmpacket);
}
if (!memcmp ("RDSK", bufrdb, 4)) {
uae_u32 error = 0;
bufrdb[0xdc] = 0;
bufrdb[0xdd] = 0;
bufrdb[0xde] = 0;
bufrdb[0xdf] = 0;
if (rdb_checksum ("RDSK", bufrdb, rdblock)) {
write_log (_T("Windows 95/98/ME trashed RDB detected, fixing..\n"));
hdf_write (hfd, bufrdb, rdblock * hfd->ci.blocksize, hfd->ci.blocksize, &error);
hdf_write (hfd, bufrdb, rdblock * hfd->ci.blocksize, hfd->ci.blocksize);
return pt_rdsk(ctx, bufrdb, rdblock, uip, unit_no, partnum, parmpacket);
}
}
Expand Down Expand Up @@ -8444,7 +8438,6 @@ static int dofakefilesys (TrapContext *ctx, UnitInfo *uip, uaecptr parmpacket, s
int ver = -1, rev = -1;
uae_u32 dostype;
bool autofs = false;
uae_u32 error = 0;

// we already have custom filesystem loaded for earlier hardfile?
if (!ci->forceload) {
Expand All @@ -8461,7 +8454,7 @@ static int dofakefilesys (TrapContext *ctx, UnitInfo *uip, uaecptr parmpacket, s

if (!ci->dostype) {
memset (buf, 0, 4);
hdf_read (&uip->hf, buf, 0, 512, &error);
hdf_read (&uip->hf, buf, 0, 512);
dostype = (buf[0] << 24) | (buf[1] << 16) |(buf[2] << 8) | buf[3];
} else {
dostype = ci->dostype;
Expand Down Expand Up @@ -8588,7 +8581,6 @@ static uae_u32 REGPARAM2 filesys_dev_storeinfo (TrapContext *ctx)
int unit_no = no & 65535;
int sub_no = no >> 16;
int type;
uae_u32 error = 0;

if (unit_no >= MAX_FILESYSTEM_UNITS)
return -2;
Expand Down Expand Up @@ -8718,7 +8710,7 @@ static uae_u32 REGPARAM2 filesys_dev_storeinfo (TrapContext *ctx)
memset(buf, 0, sizeof buf);
if (ci->dostype) { // forced dostype?
trap_put_long(ctx, parmpacket + 80, ci->dostype); /* dostype */
} else if (hdf_read (&uip[unit_no].hf, buf, 0, sizeof buf, &error)) {
} else if (hdf_read (&uip[unit_no].hf, buf, 0, sizeof buf)) {
uae_u32 dt = rl (buf);
if (dt != 0x00000000 && dt != 0xffffffff)
trap_put_long(ctx, parmpacket + 80, dt);
Expand Down
8 changes: 3 additions & 5 deletions src/gayle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1425,9 +1425,8 @@ static void check_sram_flush (int addr)
int start = pcmcia_write_min & mask;
int end = (pcmcia_write_max + blocksize - 1) & mask;
int len = end - start;
uae_u32 error = 0;
if (len > 0) {
hdf_write (&pcmcia_disk->hfd, pcmcia_common + start, start, len, &error);
hdf_write (&pcmcia_disk->hfd, pcmcia_common + start, start, len);
pcmcia_write_min = -1;
pcmcia_write_max = -1;
}
Expand Down Expand Up @@ -1512,7 +1511,6 @@ static int initpcmcia (const TCHAR *path, int readonly, int type, int reset, str

if (!pcmcia_disk->hfd.drive_empty) {
int extrasize = 0;
uae_u32 error = 0;
pcmcia_common_size = (int)pcmcia_disk->hfd.virtsize;
if (pcmcia_disk->hfd.virtsize > 4 * 1024 * 1024) {
write_log (_T("PCMCIA SRAM: too large device, %llu bytes\n"), pcmcia_disk->hfd.virtsize);
Expand All @@ -1523,10 +1521,10 @@ static int initpcmcia (const TCHAR *path, int readonly, int type, int reset, str
pcmcia_common_size = 4 * 1024 * 1024;
}
pcmcia_common = xcalloc (uae_u8, pcmcia_common_size);
hdf_read (&pcmcia_disk->hfd, pcmcia_common, 0, pcmcia_common_size, &error);
hdf_read (&pcmcia_disk->hfd, pcmcia_common, 0, pcmcia_common_size);
pcmcia_card = 1;
if (extrasize >= 512 && extrasize < 1 * 1024 * 1024) {
hdf_read(&pcmcia_disk->hfd, pcmcia_attrs, pcmcia_common_size, extrasize, &error);
hdf_read(&pcmcia_disk->hfd, pcmcia_attrs, pcmcia_common_size, extrasize);
write_log(_T("PCMCIA SRAM: Attribute data read %ld bytes\n"), extrasize);
pcmcia_attrs_full = 1;
} else {
Expand Down
Loading

0 comments on commit 494761c

Please sign in to comment.