From: Tormod Volden Date: Tue, 12 May 2015 21:09:39 +0000 (+0200) Subject: dragon-nx32: Raw support on DriveWire (limited to blocks) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=6329af7172f6a51b760c1d10fe1e4fab98c3b7ba;p=FUZIX.git dragon-nx32: Raw support on DriveWire (limited to blocks) CONFIG_LEGACY_EXEC is still left in place until floppy driver also gets raw support. Signed-off-by: Tormod Volden --- diff --git a/Kernel/platform-dragon-nx32/devdw.c b/Kernel/platform-dragon-nx32/devdw.c index 0034a7de..4d1b81dc 100644 --- a/Kernel/platform-dragon-nx32/devdw.c +++ b/Kernel/platform-dragon-nx32/devdw.c @@ -20,18 +20,26 @@ static int dw_transfer(uint8_t minor, bool is_read, uint8_t rawflag) { blkno_t block; uint16_t dptr; - int ct = 0; + int nblock; int tries; uint8_t err; uint8_t *driveptr = dw_tab + minor; - uint8_t cmd[5]; + uint8_t cmd[6]; irqflags_t irq; - if(rawflag) + if (rawflag == 0) { + dptr = (uint16_t)udata.u_buf->bf_data; + block = udata.u_buf->bf_blk; + nblock = 2; + } else if (rawflag == 1) { + if (((uint16_t)udata.u_offset|udata.u_count) & BLKMASK) + goto bad2; + dptr = (uint16_t)udata.u_base; + block = udata.u_offset >> 9; + nblock = udata.u_count >> 8; + } else goto bad2; - dptr = (uint16_t)udata.u_buf->bf_data; - block = udata.u_buf->bf_blk; // kprintf("Issue command: drive %d\n", minor); /* maybe mimicking floppy driver more than needed? */ @@ -40,11 +48,12 @@ static int dw_transfer(uint8_t minor, bool is_read, uint8_t rawflag) cmd[2] = (block << 1) & 0xFF; cmd[3] = dptr >> 8; cmd[4] = dptr & 0xFF; + cmd[5] = rawflag; *driveptr = minor; /* pass minor (drive number) through here for now */ - while (ct < 2) { + while (nblock--) { for (tries = 0; tries < 4 ; tries++) { - // kprintf("dw_operation on block %d ct %d\n", block, ct); + // kprintf("dw_operation block %d left %d\n", block, nblock); irq = di(); /* for now block interrupts for whole operation */ err = dw_operation(cmd, driveptr); irqrestore(irq); @@ -58,7 +67,8 @@ static int dw_transfer(uint8_t minor, bool is_read, uint8_t rawflag) goto bad; cmd[3]++; /* Move on 256 bytes in the buffer */ cmd[2]++; /* Next sector for 2nd block */ - ct++; + if (cmd[2] == 0) + cmd[1]++; } return 1; bad: diff --git a/Kernel/platform-dragon-nx32/drivewire.s b/Kernel/platform-dragon-nx32/drivewire.s index babebeb9..f1718edf 100644 --- a/Kernel/platform-dragon-nx32/drivewire.s +++ b/Kernel/platform-dragon-nx32/drivewire.s @@ -10,7 +10,11 @@ .globl _dw_operation .globl _dw_reset - .area .text + ; imported + .globl map_process_always + .globl map_kernel + + .area .common _dw_reset: ; maybe reinitalise PIA here? @@ -20,9 +24,13 @@ _dw_reset: _dw_operation: pshs y ; get parameters from C, X points to cmd packet - ldy 4,s ; driveptr + ldy 4,s ; driveptr (dw_tab in .bss so kernel bank) lda ,y ; for now, contains minor = drive number directly - ldb ,x ; write flag + ldb 5,x ; rawflag + pshs b + beq @nomap + jsr map_process_always +@nomap ldb ,x ; write flag ; buffer location into Y ldy 3,x ; sector number into X @@ -35,9 +43,12 @@ _dw_operation: @done bcs @err bne @err ldx #0 +@fin tst ,s+ + beq @ret + jsr map_kernel @ret puls y,pc @err ldx #0xFFFF - bra @ret + bra @fin ; Write a sector to the DriveWire server ; Drive number in A, sector number in X, buffer location in Y