From: Alan Cox Date: Mon, 4 Mar 2019 01:28:21 +0000 (+0000) Subject: pentagon: IDE interface update X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=9fb6958147172f955b66be5e0915cc4db8ef6a2f;p=FUZIX.git pentagon: IDE interface update This gets us to the point that we parse the partition table and then fail to load init. --- diff --git a/Kernel/dev/zx/nemoide.c b/Kernel/dev/zx/nemoide.c new file mode 100644 index 00000000..a0864849 --- /dev/null +++ b/Kernel/dev/zx/nemoide.c @@ -0,0 +1,77 @@ +#include +#include +#include +#include +#include +#include +#include + +/* We have to provide slightly custom methods here because of the banked + kernel */ +COMMON_MEMORY + +void devide_read_data(void) __naked +{ + __asm + ld a, (_blk_op+BLKPARAM_IS_USER_OFFSET) ; blkparam.is_user + ld hl, (_blk_op+BLKPARAM_ADDR_OFFSET) ; blkparam.addr + ld bc, #IDE_REG_DATA_LATCH ; setup port number + ; and count + push af +#ifdef SWAPDEV + cp #2 + jr nz, not_swapin + ld a, (_blk_op+BLKPARAM_SWAP_PAGE) ; blkparam.swap_page + call map_for_swap + jr doread +not_swapin: +#endif + or a ; test is_user + call nz, map_process_always ; map user memory first if required +doread: +readword: + in a,(0x10) ; Read a word + ld (hl),a ; Store the byte we got + inc hl + ini ; Now store the latched byte + jr nz, readword + pop af + or a + jp nz, map_kernel_restore ; else map kernel then return + ret + __endasm; +} + +void devide_write_data(void) __naked +{ + __asm + ld a, (_blk_op+BLKPARAM_IS_USER_OFFSET) ; blkparam.is_user + ld hl, (_blk_op+BLKPARAM_ADDR_OFFSET) ; blkparam.addr + ld bc, #IDE_REG_DATA_LATCH ; setup port number + ; and count + push af +#ifdef SWAPDEV + cp #2 + jr nz, not_swapout + ld a, (_blk_op+BLKPARAM_SWAP_PAGE) ; blkparam.swap_page + call map_for_swap + jr dowrite +not_swapout: +#endif + or a ; test is_user + call nz, map_process_always ; else map user memory first if required +dowrite: + ; Write is somewhat ugly +writeword: + ld a,(hl) + inc hl ; data byte + outi ; latch a byte + out (0x10),a ; write the data + ; and thus the latch + jr nz, writeword + pop af + or a + jp nz, map_kernel_restore ; else map kernel then return + ret + __endasm; +} diff --git a/Kernel/platform-pentagon/Makefile b/Kernel/platform-pentagon/Makefile index fb31a420..0b5adba5 100644 --- a/Kernel/platform-pentagon/Makefile +++ b/Kernel/platform-pentagon/Makefile @@ -2,7 +2,7 @@ CSRCS = devtty.c devices.c main.c CDSRCS = discard.c DSRCS = ../dev/devide.c ../dev/devsd.c ../dev/blkdev.c DDSRCS = ../dev/devide_discard.c ../dev/devsd_discard.c ../dev/mbr.c -DZSRCS = ../dev/zx/divide.c ../dev/zx/zxmmc.c ../dev/zx/zxkeyboard.c +DZSRCS = ../dev/zx/nemoide.c ../dev/zx/zxmmc.c ../dev/zx/zxkeyboard.c DZSRCS += ../dev/zx/devinput.c ../dev/zx/bankbig.c DDZSRCS = ASRCS = crt0.s pentagon.s zxvideo.s diff --git a/Kernel/platform-pentagon/README b/Kernel/platform-pentagon/README index 1ed6be8c..e69cea93 100644 --- a/Kernel/platform-pentagon/README +++ b/Kernel/platform-pentagon/README @@ -42,12 +42,12 @@ We run with the following mapping 8400-BFFF _DISCARD area - blown away when we exec init (tons of room in this space) C000-FFFF - 0: 0000-3FFF + 0: 0000-3FFF (Kernel data/common) 1: Kernel CODE (fairly full) 2: Mapped at 0x8000-0xBFFF (holds current process copy) 3: User process 4: User process - 5: Mapped at 0x4000-0x7FFF (Sceen, Kernel data/common) + 5: Mapped at 0x4000-0x7FFF (Screen, spare) 6: Kernel CODE2 (fairly full) 7: CODE3, Video (lots of room) @@ -55,6 +55,10 @@ User processes live in 3/4 and 8+. We have copy stuff back and forth to page 2 due to the memory manager liits. To Do: +- Debug the rest +- Write SMUC and Nemo ATA driver code +- Work out what we need to do for Pentagon v Scorpion etc +- Floppy driver - Why does ls /bin lose the lowest pixel row of the 'yes' command ? (Seems we lose the bottom line of the left most char - off by one bug @@ -62,7 +66,6 @@ To Do: - Enable interrupts during swap - 6 or 5bit wide fonts (42, 51 column) - Optimize zxvid - especially scrolling -- SMUC and similar IDE options - Move vtborder to common - See if we can in fact keep 6000-7FFF clear. If so we can look at ldir switching another 8K up and down to give 40K program sizes @@ -83,11 +86,3 @@ Does mean we need to patch our kernel to grab the next instruction, and then put it back all under di but it does look doable. -TODO - -- Write spectrum style and also disk boot style loaders -- Debug the loading -- Debug the rest -- Write SMUC and Nemo ATA driver code -- Work out what we need to do for Pentagon v Scorpion etc -- Floppy driver diff --git a/Kernel/platform-pentagon/fuzix.lnk b/Kernel/platform-pentagon/fuzix.lnk index b7e5cfd2..736ab54a 100644 --- a/Kernel/platform-pentagon/fuzix.lnk +++ b/Kernel/platform-pentagon/fuzix.lnk @@ -45,7 +45,7 @@ platform-pentagon/devide.rel platform-pentagon/devide_discard.rel platform-pentagon/devsd.rel platform-pentagon/devsd_discard.rel -platform-pentagon/divide.rel +platform-pentagon/nemoide.rel platform-pentagon/zxmmc.rel platform-pentagon/mbr.rel platform-pentagon/blkdev.rel diff --git a/Kernel/platform-pentagon/platform_ide.h b/Kernel/platform-pentagon/platform_ide.h index 2141fda7..41c64856 100644 --- a/Kernel/platform-pentagon/platform_ide.h +++ b/Kernel/platform-pentagon/platform_ide.h @@ -1,12 +1,10 @@ /* - * DivIDE interface + * NemoIDE interface * - * This is a 16bit interface with a latched data port. Each read - * from A3 fetches a word then returns low then high etc. In the other - * direction it latches then writes. + * This is a 16bit interface with a latched data port. * - * The latch is reset to the first state by any other port access in the - * IDE space (so the command write sets it up nicely for us) + * The latch means we have to work from two ports which is ugly but + * at least it's not using the high bits of the address. */ #define ide_select(x) @@ -14,16 +12,21 @@ #define IDE_DRIVE_COUNT 2 -#define IDE_REG_DATA 0xA3 -#define IDE_REG_ERROR 0xA7 -#define IDE_REG_FEATURES 0xA7 -#define IDE_REG_SEC_COUNT 0xAB -#define IDE_REG_LBA_0 0xAF -#define IDE_REG_LBA_1 0xB3 -#define IDE_REG_LBA_2 0xB7 -#define IDE_REG_LBA_3 0xBB -#define IDE_REG_DEVHEAD 0xBB -#define IDE_REG_STATUS 0xBF -#define IDE_REG_COMMAND 0xBF +#define IDE_SFR __sfr + +#define IDE_REG_DATA 0x10 +#define IDE_REG_DATA_LATCH 0x11 +#define IDE_REG_ERROR 0x30 +#define IDE_REG_FEATURES 0x30 +#define IDE_REG_SEC_COUNT 0x50 +#define IDE_REG_LBA_0 0x70 +#define IDE_REG_LBA_1 0x90 +#define IDE_REG_LBA_2 0xB0 +#define IDE_REG_LBA_3 0xD0 +#define IDE_REG_DEVHEAD 0xD0 +#define IDE_REG_STATUS 0xF0 +#define IDE_REG_COMMAND 0xF0 + +#define IDE_REG_CONTROL 0xC8 #define IDE_NONSTANDARD_XFER