dragon-mooh: Disable interrupts while writing task registers
authorTormod Volden <debian.tormod@gmail.com>
Mon, 7 Jan 2019 22:08:38 +0000 (23:08 +0100)
committerAlan Cox <alan@linux.intel.com>
Tue, 8 Jan 2019 17:06:54 +0000 (17:06 +0000)
map_kernel/map_process_always are in a few cases called with interrupt
enabled (e.g. from SPI transfer routines in common). If an interrupt
hits between writing "user" to map_copy and reading the process page
map, the intermediate map_save/map_restore during interrupt will restore
"user" map, and the process page map is gone.

Make map_kernel/map_process_always "atomic" to ensure that map_copy and
task registers are always coherent.

Note that we still rely on map_process_always/map_process_x to be called
with kernel being mapped so that we can read the process page map.

Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
Kernel/platform-dragon-mooh/mem-mooh.s

index 9c158c9..0f62bb4 100644 (file)
@@ -48,17 +48,20 @@ size_ram
 
 ; must preserve register a but not x
 map_kernel
+       pshs cc
        clr map_copy
        clr map_copy+1
        clr 0xff91      ; MMU task 0
-       rts
+       puls cc,pc
 
 map_process_a
-       pshs a,b,x,y
+       pshs cc,a,b,x,y
        bra map_x
 
+* might be called with interrupts enabled from drivers
 map_process_always
-       pshs a,b,x,y
+       pshs cc,a,b,x,y
+       orcc #0x10
        ldx U_DATA__U_PAGE
 map_x
        ; could try to skip this if maps already in place
@@ -72,7 +75,7 @@ maplp lda ,x+
        bne maplp
 mapdn  lda #1
        sta 0xff91      ; MMU task 1
-       puls a,b,x,y,pc
+       puls cc,a,b,x,y,pc
 fillm  lda -2,x        ; should not happen on first page
 fillp  sta ,y+         ; fill map by repeating last page
        decb