From: Tormod Volden Date: Mon, 7 Jan 2019 22:08:38 +0000 (+0100) Subject: dragon-mooh: Disable interrupts while writing task registers X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=4db2e688dd1f184b7bb68ca3832e06985d9c8a2c;p=FUZIX.git dragon-mooh: Disable interrupts while writing task registers 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 --- diff --git a/Kernel/platform-dragon-mooh/mem-mooh.s b/Kernel/platform-dragon-mooh/mem-mooh.s index 9c158c94..0f62bb4a 100644 --- a/Kernel/platform-dragon-mooh/mem-mooh.s +++ b/Kernel/platform-dragon-mooh/mem-mooh.s @@ -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