dragon: SAM implementation of the user memory copier
authorAlan Cox <alan@etchedpixels.co.uk>
Fri, 28 Nov 2014 22:05:47 +0000 (22:05 +0000)
committerAlan Cox <alan@etchedpixels.co.uk>
Fri, 28 Nov 2014 22:05:47 +0000 (22:05 +0000)
Kernel/platform-dragon/usermem_sam.s [new file with mode: 0644]

diff --git a/Kernel/platform-dragon/usermem_sam.s b/Kernel/platform-dragon/usermem_sam.s
new file mode 100644 (file)
index 0000000..b21ecf5
--- /dev/null
@@ -0,0 +1,116 @@
+       .module usermem
+
+;
+;      6809 + SAM copy to and from userspace
+;
+;      This is linked by the 6881 using platforms only. MMU based
+;      machines simply don't need it.
+
+
+       include "kernel.def"
+        include "../kernel09.def"
+
+       .globl __ugetc
+       .globl __ugetw
+       .globl __uget
+       .globl __ugets
+
+       .globl __uputc
+       .globl __uputw
+       .globl __uput
+       .globl __uzero
+
+       .area .common
+
+__ugetc:
+       SAM_USER
+       ldb ,x
+       lda #0
+       tfr d,x
+       SAM_KERNEL
+       rts
+
+__ugetw:
+       SAM_USER
+       ldx ,x
+       SAM_KERNEL
+       rts
+
+__uget:
+       pshs u,y
+       ldu 6,s         ; user address
+       ldy 8,s         ; count
+ugetl:
+       lda ,x++
+       SAM_USER
+       sta ,u++
+       SAM_KERNEL
+       leay -1,y
+       cmpy #0
+       bne ugetl
+       puls u,y,pc
+
+__ugets:
+       pshs u,y
+       ldu 6,s         ; user address
+       ldy 8,s         ; count
+ugetsl:
+       SAM_USER
+       lda ,x++
+       beq ugetse
+       SAM_KERNEL
+       sta ,u++
+       leay -1,y
+       cmpy #0
+       bne ugetsl
+       ldx #0xffff     ; unterminated - error
+       lda #0
+       sta -1,u        ; force termination
+       puls u,y,pc
+
+ugetse:
+       SAM_KERNEL
+       sta ,u
+       ldx #0
+       puls u,y,pc
+
+
+__uputc:
+       SAM_USER
+       stb ,x
+       SAM_KERNEL
+       rts
+
+__uputw:
+       SAM_USER
+       ldb 2,s
+       stb ,x
+       SAM_KERNEL
+       rts
+
+__uput:
+       pshs u,y
+       ldu 6,s         ; user address
+       ldy 8,s         ; count
+uputl:
+       SAM_USER
+       lda ,x++
+       SAM_KERNEL
+       sta ,u++
+       leay -1,y
+       cmpy #0
+       bne uputl
+       puls u,y,pc
+
+__uzero:
+       pshs y
+       lda #0
+       ldy 6,s
+       SAM_USER
+uzloop:
+       sta ,x+
+       leay -1,y
+       cmpy #0
+       bne uzloop
+       SAM_KERNEL
+       puls y,pc