]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Virtual RDB >512 block size support.
authorToni Wilen <twilen@winuae.net>
Sat, 16 Jun 2018 19:10:49 +0000 (22:10 +0300)
committerToni Wilen <twilen@winuae.net>
Sat, 16 Jun 2018 19:10:49 +0000 (22:10 +0300)
hardfile.cpp
ide.cpp
scsi.cpp

index 2f1b20fec9d0deb2bd828799a02581a417f82a68..f015ab549984fb1d3955fda7a9c6a876b691da17 100644 (file)
@@ -365,21 +365,23 @@ static uae_u32 get_filesys_version(uae_u8 *fs, int size)
        return (ver << 16) | rev;
 }
 
+// hardware block size is always 256 or 512
+// filesystem block size can be 256, 512 or larger
 static void create_virtual_rdb (struct hardfiledata *hfd)
 {
        uae_u8 *rdb, *part, *denv, *fs;
-       int blocksize = hfd->ci.blocksize;
-       int bs = blocksize;
-       int minblocksize = blocksize >= 512 ? 512 : blocksize;
+       int fsblocksize = hfd->ci.blocksize;
+       int hardblocksize = fsblocksize >= 512 ? 512 : 256;
        int cyl = hfd->ci.surfaces * hfd->ci.sectors;
-       int cyls = (262144 + (cyl * bs) - 1) / (cyl * bs);
-       int size = cyl * cyls * bs;
+       int cyls = (262144 + (cyl * fsblocksize) - 1) / (cyl * fsblocksize);
+       int size = cyl * cyls * fsblocksize;
        int idx = 0;
        uae_u8 *filesys = NULL;
        int filesyslen = 0;
        uae_u32 fsver = 0;
 
-       write_log(_T("Creating virtual RDB (RDB size=%d (%d blocks). H=%d S=%d)\n"), size, size / bs, hfd->ci.surfaces, hfd->ci.sectors);
+       write_log(_T("Creating virtual RDB (RDB size=%d, %d blocks). H=%d S=%d HBS=%d FSBS=%d)\n"),
+               size, size / hardblocksize, hfd->ci.surfaces, hfd->ci.sectors, hardblocksize, fsblocksize);
 
        if (hfd->ci.filesys[0]) {
                struct zfile *f = NULL;
@@ -404,7 +406,7 @@ static void create_virtual_rdb (struct hardfiledata *hfd)
        pl(rdb, 1, 256 / 4);
        pl(rdb, 2, 0); // chksum
        pl(rdb, 3, 7); // hostid
-       pl(rdb, 4, blocksize); // blockbytes
+       pl(rdb, 4, hardblocksize); // blockbytes
        pl(rdb, 5, 0); // flags
        pl(rdb, 6, -1); // badblock
        pl(rdb, 7, idx + 1); // part
@@ -446,7 +448,7 @@ static void create_virtual_rdb (struct hardfiledata *hfd)
        rdb_crc (rdb);
        idx++;
 
-       part = rdb + blocksize * idx;
+       part = rdb + hardblocksize * idx;
        pl(part, 0, 0x50415254); // "PART"
        pl(part, 1, 256 / 4);
        pl(part, 2, 0); // chksum
@@ -460,7 +462,7 @@ static void create_virtual_rdb (struct hardfiledata *hfd)
        ua_copy ((char*)part + 9 * 4 + 1, 30, hfd->ci.devname);
        denv = part + 128;
        pl(denv, 0, 16);
-       pl(denv, 1, 512 / 4);
+       pl(denv, 1, fsblocksize / 4);
        pl(denv, 2, 0); // secorg
        pl(denv, 3, hfd->ci.surfaces);
        pl(denv, 4, 1);
@@ -480,7 +482,7 @@ static void create_virtual_rdb (struct hardfiledata *hfd)
        idx++;
 
        if (filesys) {
-               fs = rdb + blocksize * idx;
+               fs = rdb + hardblocksize * idx;
                pl(fs, 0, 0x46534844); // "FSHD"
                pl(fs, 1, 256 / 4);
                pl(fs, 2, 0); // chksum
@@ -499,12 +501,12 @@ static void create_virtual_rdb (struct hardfiledata *hfd)
 
                int offset = 0;
                for (;;) {
-                       uae_u8 *lseg = rdb + blocksize * idx;
-                       int lsegdatasize = minblocksize - 5 * 4;
-                       if (lseg + blocksize > rdb + size)
+                       uae_u8 *lseg = rdb + hardblocksize * idx;
+                       int lsegdatasize = hardblocksize - 5 * 4;
+                       if (lseg + hardblocksize > rdb + size)
                                break;
                        pl(lseg, 0, 0x4c534547); // "LSEG"
-                       pl(lseg, 1, minblocksize / 4);
+                       pl(lseg, 1, hardblocksize / 4);
                        pl(lseg, 2, 0); // chksum
                        pl(lseg, 3, 7); // hostid
                        int v = filesyslen - offset;
diff --git a/ide.cpp b/ide.cpp
index a2b68e8c88d1dfa2b1d9c101fe350f841807f145..1c2e2ac655922f1e04b09d737324ef99eed93c46 100644 (file)
--- a/ide.cpp
+++ b/ide.cpp
@@ -1656,7 +1656,7 @@ struct ide_hdf *add_ide_unit (struct ide_hdf **idetable, int max, int ch, struct
                        return NULL;
 
                ide->max_multiple_mode = 128;
-               ide->blocksize = ide->hdhfd.hfd.ci.blocksize;
+               ide->blocksize = ide->hdhfd.hfd.virtual_rdb ? 512 : ide->hdhfd.hfd.ci.blocksize;
                ide->max_lba = ide->hdhfd.size / ide->blocksize;
                ide->lba48 = (ide->hdhfd.hfd.ci.unit_special_flags & 1) || ide->hdhfd.size >= 128 * (uae_u64)0x40000000 ? 1 : 0;
                ide->lba = true;
index b7dbfa1b1052a3cd3d7c7e1a5e919526a1fa28c6..5b42bf70dec18c34bd66e48d7cde4f11f7a6a1f0 100644 (file)
--- a/scsi.cpp
+++ b/scsi.cpp
@@ -530,7 +530,7 @@ struct scsi_data *scsi_alloc_hd(int id, struct hd_hardfiledata *hfd, int uae_uni
        sd->id = id;
        sd->nativescsiunit = -1;
        sd->cd_emu_unit = -1;
-       sd->blocksize = hfd->hfd.ci.blocksize;
+       sd->blocksize = hfd->hfd.virtual_rdb ? 512 : hfd->hfd.ci.blocksize;
        sd->device_type = UAEDEV_HDF;
        sd->uae_unitnum = uae_unitnum;
        allocscsibuf(sd);