6809: remove the old SAM hacks
authorAlan Cox <alan@linux.intel.com>
Fri, 4 May 2018 09:02:19 +0000 (10:02 +0100)
committerAlan Cox <alan@linux.intel.com>
Fri, 4 May 2018 09:02:19 +0000 (10:02 +0100)
It's a crazy way to run a system and it messes up stuff for everything else.
We don't use it since removing the original dragon hack kernel.

Kernel/lowlevel-6809.s

index 6ca0547..e81e80b 100644 (file)
 ;
 ; Called by swi, which has already saved our CPU state for us
 ;
-; The lack of shared RAM leads to the rather ugly SAM_ macros needing to
-; be here for SAM based boxes as we have no valid stack at this point
-;
 unix_syscall_entry:
-       SAM_KERNEL      ; stack now invalid
-
        leax 14,s       ; 12 stacked by the swi + return address of caller
        ldy #U_DATA__U_ARGN
-       SAM_USER
        ldd 4,s         ; first argument in swi stacked X
-       SAM_KERNEL
        std ,y++
-       SAM_USER
        ldd ,x++        ; second argument from caller's stack
-       SAM_KERNEL
        std ,y++
-       SAM_USER
        ldd ,x++        ; third
-       SAM_KERNEL
        std ,y++
-       SAM_USER
        ldd ,x++        ; fourth
-       SAM_KERNEL
        std ,y++
-       SAM_USER
        ldd 1,s         ; stacked D register -> syscall number
-       SAM_KERNEL
        stb U_DATA__U_CALLNO
         ; save process stack pointer (in user page)
         sts U_DATA__U_SYSCALL_SP
@@ -125,14 +110,11 @@ unix_syscall_entry:
 
         ; switch back to user stack
         lds U_DATA__U_SYSCALL_SP
-       ; stack is no longer valid
 
-       SAM_USER
        ; stack is now valid but user stack
         ; check for signals, call the handlers
         jsr dispatch_process_signal
 
-       SAM_KERNEL
         ; check if error condition to be signalled on return
         ldd U_DATA__U_ERROR
        beq not_error
@@ -145,18 +127,14 @@ not_error:
         ldx U_DATA__U_RETVAL
 unix_return:
        ; we never make a syscall from in kernel space
-       SAM_USER
        stx 4,s         ; replace stacked values before rti
        std 1,s
        rti
-
 ;
-;      In SAM land this function is called on the user stack with the user
-;      memory mapped, we must rts on the right bank !
+;      We must rts on the right bank !
 ;
 dispatch_process_signal:
         ; check if any signal outstanding
-       SAM_KERNEL
         ldb U_DATA__U_CURSIG
         beq dosigrts
         ; put number in X as the argument for the signal handler
@@ -165,9 +143,6 @@ dispatch_process_signal:
        tfr d,x
 
        lslb            ;       2 bytes per entry
-;
-;      FIXME: must save Y for same ??
-;
         ; load the address of signal handler function
        ldy #U_DATA__U_SIGVEC
        ldu b,y         ; now u = udata.u_sigvec[cursig]
@@ -183,7 +158,6 @@ dispatch_process_signal:
        clr ,y
 
         ldy #signal_return
-       SAM_USER
         pshs y      ; push return address
 
         andcc #0xef
@@ -191,12 +165,7 @@ dispatch_process_signal:
 
 signal_return:
         orcc #0x10
-;
-;      FIXME: port over the Z80 loop and check for next signal
-;
 dosigrts:
-       ; right stack for the rts instruction
-       SAM_USER
         rts
 
 _doexec:
@@ -215,7 +184,6 @@ _doexec:
        ; At this point the stack goes invalid
         lds U_DATA__U_ISP
        andcc #0xef                     ; IRQs on
-       SAM_USER                        ; Stack valid, go to user code
         jmp ,x
 
 ;
@@ -223,18 +191,7 @@ _doexec:
 ;      poll ttys from it. The more logic we could move to common here the
 ;      better.
 ;
-;      For SAM based machines this involves some craziness as we have no
-;      common inter-bank RAM. In the SAM case we will always enter with
-;      the kernel mapped, but our stack on entry is likely to be invalid
-;
-;      Thus we have to have inlined SAM conditionals - bletch
-;
-;      Y is used for the SAM logic so preserve it always
-;
 interrupt_handler:
-           SAM_SAVE            ; loads Y
-           SAM_KERNEL
-
            ; Do not use the stack before the switch...
 
            ; FIXME: add profil support here (need to keep profil ptrs
@@ -245,16 +202,12 @@ interrupt_handler:
 
             ; switch stacks
             sts istack_switched_sp
-           ; Unlike Z80 even the istack is banked, it's only valid on some
-           ; SAM based boxes when SAM_KERNEL is true
             lds #istack_top-2
            ; FIXME: check store/dec order might not need to be -2 here!!!!
 
            jsr map_save
 
-           SAM_USER
            lda 0               ; save address 0 contents for checking
-           SAM_KERNEL
 
            ; preserves registers
            jsr map_kernel
@@ -286,9 +239,6 @@ in_kernel:
            ; _need_resched, and will only do so if the caller was in
            ; user space so has a free kernel stack
 
-           ;
-           ; Y is caller saves so we'll get the right Y back
-           ; for our SAM_RESTORE
             jsr _platform_interrupt
 
             clr _inint
@@ -319,8 +269,6 @@ in_kernel:
            ; the user stack and map ourself in
            jsr map_process_always
            lds U_DATA__U_SYSCALL_SP
-           ; do the map on the user stack (for SAM switching)
-           SAM_USER
            bra intdone
 
            ; Not task switching - the easy and usual path
@@ -331,18 +279,15 @@ no_switch:
            ; pre-emption is handled differently...
            jsr map_restore
            lds istack_switched_sp
-           SAM_USER
 
 intdone: 
             ; we're not in kernel mode, check for signals
-           ; runs off the user stack so need user ram mapped on a SAM
-           ; based platform
+           ; runs off the user stack
            pshs y
             jsr dispatch_process_signal
            puls y
 
 interrupt_return:
-           SAM_RESTORE                 ; uses the saved Y
             rti
 interrupt_return_x:
            tfr x,s
@@ -358,11 +303,9 @@ trap_signal:
 
 ;  Called from process context (hopefully)
 null_handler:
-           SAM_KERNEL
            ; kernel jump to NULL is bad
            lda U_DATA__U_INSYS
            beq trap_illegal
-           SAM_USER
            ; user is merely not good
            ; check order of push arguments !!
             ldx #7
@@ -394,7 +337,6 @@ nmimsg:     .ascii "[NMI]"
             .db 13,10,0
 
 nmi_handler:
-       SAM_KERNEL
        lds #istack_top-2               ; We aren't coming back so this is ok
        jsr map_kernel
         ldx #nmimsg