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>
; 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
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