dragon-nx32: Copy dw_transaction() from coco3
authorTony Jewell <tonyjewell@gmail.com>
Sat, 21 May 2016 21:17:17 +0000 (23:17 +0200)
committerAlan Cox <alan@linux.intel.com>
Sun, 22 May 2016 19:07:24 +0000 (20:07 +0100)
Kernel/platform-dragon-nx32/drivewire.s

index 7e58f9b..3b90bb8 100644 (file)
@@ -9,6 +9,7 @@
        ; exported
        .globl _dw_operation
        .globl _dw_reset
+       .globl _dw_transaction
 
        .globl _dw_lpr
        .globl _dw_lpr_close
 
        .area .common
 
+_dw_transaction:
+       pshs    cc,y            ; save caller
+       orcc    #0x50           ; stop interrupts
+       ldy     5,s             ; Y = number of bytes to send
+       beq     out@            ; no byte to write - leave
+       jsr     DWWrite         ; send to DW
+       ldx     7,s             ; X is receive buffer
+       ldy     9,s             ; Y = number of bytes to receive
+       beq     out@            ; no bytes to send - leave
+       jsr     DWRead          ; read in that many bytes
+       bcs     frame@          ; C set on framing error
+       bne     part@           ; Z zet on all bytes received
+out@   ldx     #0              ; no error
+       puls    cc,y,pc         ; return
+frame@ ldx     #-1             ; frame error
+       puls    cc,y,pc         ; return
+part@  ldx     #-2             ; not all bytes received!
+       puls    cc,y,pc         ; return
+
 _dw_reset:
        ; maybe reinitalise PIA here?
        ; and send DW_INIT request to server?