From 601b9d2c0ec55122e7b7248cf5c6c1772bcceb27 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 16 May 2015 00:32:24 +0100 Subject: [PATCH] trs80: fix hard disk problems - Sector offset was wrong so it didn't interoperate - User mode fetched only half the sectors so execve broke on hd - Tools replicated hd offset bug With these fixed you can partition and run FUZIX on the hard disk device even if set up directly or under another OS. Swap still blows up but this doesn't appear to be an hd bug at this point --- Kernel/platform-trs80/devhd.c | 4 ++-- Kernel/platform-trs80/devhd_discard.c | 4 ++-- Kernel/tools/trslabel.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Kernel/platform-trs80/devhd.c b/Kernel/platform-trs80/devhd.c index 70f11880..71064159 100644 --- a/Kernel/platform-trs80/devhd.c +++ b/Kernel/platform-trs80/devhd.c @@ -79,7 +79,7 @@ int hd_transfer(uint8_t minor, bool is_read, uint8_t rawflag) if (((uint16_t)udata.u_offset|udata.u_count) & BLKMASK) goto bad2; dptr = (uint16_t)udata.u_base; - nblock = udata.u_count >> 9; + nblock = udata.u_count >> 8; block = udata.u_offset >> 9; hd_page = udata.u_page; } else if (rawflag == 2) { @@ -99,7 +99,7 @@ int hd_transfer(uint8_t minor, bool is_read, uint8_t rawflag) hd_seccnt = 1; sector = block; - sector = ((sector << 1) & 0x1E) | 0x01; + sector = (sector << 1) & 0x1E; cyl = block >> 4; diff --git a/Kernel/platform-trs80/devhd_discard.c b/Kernel/platform-trs80/devhd_discard.c index d5dd0a2e..0c3615a8 100644 --- a/Kernel/platform-trs80/devhd_discard.c +++ b/Kernel/platform-trs80/devhd_discard.c @@ -22,7 +22,7 @@ static void hd_swapon(struct minipart *p, unsigned int d, unsigned int i) We need 32K per process: hardwire it here - FIX if you change the mapping model */ - swap_dev = (d << 4) + i + 1 + 0x100; + swap_dev = (d << 4) + i + 1; if (cyls >= MAX_SWAPS) cyls = MAX_SWAPS - 1; @@ -48,7 +48,7 @@ void hd_probe(void) } hd_seccnt = 1; hd_sdh = 0x80 | (dev << 3); - hd_secnum = 2; + hd_secnum = 1; hd_cyllo = 0; hd_cylhi = 0; hd_cmd = HDCMD_READ; diff --git a/Kernel/tools/trslabel.c b/Kernel/tools/trslabel.c index 0895f5ef..97d909ad 100644 --- a/Kernel/tools/trslabel.c +++ b/Kernel/tools/trslabel.c @@ -33,7 +33,7 @@ int main(int argc, const char *argv[]) { p.g.cyl = buf[28] | (buf[29] << 8); p.g.head = buf[30]; printf("Disk is %d cylinders, %d heads\n", p.g.cyl, p.g.head); - p.g.sec = 16; + p.g.sec = 32; p.g.precomp = 0; p.g.land = p.g.cyl + 1; p.g.seek = 0; @@ -46,7 +46,7 @@ int main(int argc, const char *argv[]) { /* FIXME: should fill in matching LBA bits */ - if (fseek(vol, 512 + 384L, SEEK_SET) < 0) { + if (fseek(vol, 256 + 384L, SEEK_SET) < 0) { perror(argv[1]); exit(1); } -- 2.34.1