coco3: bugfix uget/uput: don't assume regular kernel mapping
authorBrett Gordon <beretta42@gmail.com>
Thu, 22 Oct 2015 17:37:28 +0000 (13:37 -0400)
committerBrett Gordon <beretta42@gmail.com>
Sat, 24 Oct 2015 15:01:29 +0000 (11:01 -0400)
the kernel mmu could be another state - namely a video state.

Kernel/platform-coco3/usermem_gime.s

index bc981e4..cfc5228 100644 (file)
@@ -207,6 +207,10 @@ a@ std     ,u
 ;;; remapping the mmu, copies those bytes, *then* re-computes the
 ;;; mmu banking and repeats until all bytes are transfered.
 uxfer:
+       ;; save kernel mmu mapping
+       ldd     $ffa8
+       ldx     $ffaa
+       pshs    d,x
        ;; make a data stack
        leau    -8,s            ; allow 4 levels in S
        ;; calc max src
@@ -265,24 +269,25 @@ a@        lda     ,u+             ; get a byte
        leay    -1,y            ; bump counter
        bne     a@              ; loop if not done
        ;; end inner loop
+       puls    u               ; restore data stack
        ;; clean up kernel mmu's for next mapping or returning
-       ldd     #$0001          ; restore kernel mapping (manually)
-       std     $ffa8
-       ldd     #$0203
-       std     $ffaa   
+       puls    d,x
+       pshs    d,x
+       std     0xffa8
+       stx     0xffaa
        ;; increment out loop variables
-       puls    u               ; restore data stack
        ldd     krn             ; add this iteration's byte count
        addd    icount          ; from source address
-       std     krn             ; 
+       std     krn             ;
        ldd     usr             ; add this iteration's byte count
        addd    icount          ; from destination address
-       std     usr             ; 
+       std     usr             ;
        ldd     count           ; subtract this iteration's byte count
        subd    icount          ; from total byte to copy
        std     count
        lbne    b@              ; if bytes left to copy then repeat
        ;; return
+       leas    4,s             ; drop saved kernel map
        ldx     #0              ; return #0 - success
        puls    u,y,cc,pc       ; return