From: Alan Cox Date: Sun, 6 Nov 2016 23:50:24 +0000 (+0000) Subject: coco2: ide fixes X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=ada6ce5be8747b956b2d22275d2336e6529fa0c5;p=FUZIX.git coco2: ide fixes --- diff --git a/Kernel/platform-coco2cart/Makefile b/Kernel/platform-coco2cart/Makefile index dbcf0d6c..fd712bbd 100644 --- a/Kernel/platform-coco2cart/Makefile +++ b/Kernel/platform-coco2cart/Makefile @@ -56,7 +56,7 @@ image: crt0.o bootstrap.o commonmem.o coco2.o discard.o ../simple.o \ ../start.o ../version.o ../lowlevel-6809.o \ tricks.o main.o ../timer.o ../kdata.o devices.o \ - drivewire.o devdw.o mini_ide.o mini_ide_discard.o \ + drivewire.o devdw.o mini_ide.o mini_ide_discard.o ide.o \ ../devio.o ../filesys.o ../process.o ../inode.o ../syscall_fs.o \ ../syscall_proc.o ../syscall_other.o ../mm.o ../swap.o \ ../tty.o ../devsys.o ../usermem.o usermem.o ../syscall_fs2.o \ diff --git a/Kernel/platform-coco2cart/ide.s b/Kernel/platform-coco2cart/ide.s index 8a5d8cbf..fa28f39c 100644 --- a/Kernel/platform-coco2cart/ide.s +++ b/Kernel/platform-coco2cart/ide.s @@ -6,16 +6,12 @@ .globl _devide_read_data .globl _devide_write_data - - .globl _blk_op + .globl _idepage include "kernel.def" include "../kernel09.def" .area .common - -; -; Standard mapping for Glenside style IDE ; ; We don't really support swap properly but what we do is sufficient ; for a simple memory mapping. @@ -24,10 +20,9 @@ _devide_read_data: pshs y,dp lda #0xFF tfr a,dp - ldx _blk_op leay 512,x sty endp - tst _blk_op+2 + tst _idepage beq readword jsr map_process_always readword: @@ -43,10 +38,9 @@ _devide_write_data: pshs y,dp lda #0xFF tfr a,dp - ldx _blk_op leay 512,x sty endp - tst _blk_op+2 + tst _idepage beq writeword jsr map_process_always writeword: @@ -59,4 +53,5 @@ writeword: puls y,dp,pc endp: .dw 0 - +_idepage: + .db 0 diff --git a/Kernel/platform-coco2cart/mini_ide.c b/Kernel/platform-coco2cart/mini_ide.c index 724a16f7..ce7f484d 100644 --- a/Kernel/platform-coco2cart/mini_ide.c +++ b/Kernel/platform-coco2cart/mini_ide.c @@ -18,6 +18,12 @@ uint8_t ide_present = 0; #define cmd ((volatile uint8_t *)0xFF57) #define datal ((volatile uint8_t *)0xFF58) +/* Assembler glue */ + +extern void devide_read_data(uint8_t *p); +extern void devide_write_data(uint8_t *p); +extern uint8_t idepage; + /* FIXME: switch to the correct mpi slot on entry */ static int ide_transfer(uint8_t minor, bool is_read, uint8_t rawflag) { @@ -26,8 +32,11 @@ static int ide_transfer(uint8_t minor, bool is_read, uint8_t rawflag) kprintf("IDE xfer dev %d r %d rf %d sec %d\n", minor, is_read, rawflag, udata.u_block); + if (rawflag == 1 && d_blkoff(9)) return -1; + + idepage = rawflag; while(*status & 0x80); /* Wait !BUSY */ *devh = (minor & 0x80) ? 0xF0 : 0xE0 ; /* LBA, device */ @@ -43,18 +52,11 @@ static int ide_transfer(uint8_t minor, bool is_read, uint8_t rawflag) while(udata.u_nblock--) { unsigned int i; while(!(*status & 0x08)); /* Wait DRQ */ - if (is_read) { - for (i = 0; i < 256; i++) { - *dptr++ = *data; - *dptr++ = *datal; - } - } else { - for (i = 0; i < 256; i++) { - *datal = dptr[1]; - *data = *dptr++; - dptr++; - } - } + if (is_read) + devide_read_data(dptr); + else + devide_write_data(dptr); + dptr += 512; } while(*status & 0x80); /* Wait !BUSY */ if (*status & 0x01) { /* Error */