{
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? */
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);
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:
.globl _dw_operation
.globl _dw_reset
- .area .text
+ ; imported
+ .globl map_process_always
+ .globl map_kernel
+
+ .area .common
_dw_reset:
; maybe reinitalise PIA here?
_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
@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