From 4761aee038cbda03f75a545b358549c73ec21c13 Mon Sep 17 00:00:00 2001 From: geijoenr Date: Tue, 30 May 2017 19:59:48 +0200 Subject: [PATCH] msx2: save map_table before switching pages If an interrupt happens between setting the mapper register and the update of map_table, map_save will take the wrong input for restoring the mapping when returning from the interrupt. By saving the map_table at the beginning we ensure that no matter when the interrupt happens, map_restore sets the right pages. This prevents some random hangs when doing lots of usermem operations. --- Kernel/platform-msx2/msx2.s | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/Kernel/platform-msx2/msx2.s b/Kernel/platform-msx2/msx2.s index c360e0ae..c130814e 100644 --- a/Kernel/platform-msx2/msx2.s +++ b/Kernel/platform-msx2/msx2.s @@ -187,22 +187,25 @@ map_kernel: map_process_2: push de + push bc push af ld de, #map_table ; Write only so cache in RAM - ld a, (hl) - ld (de), a - out (0xFC), a ; Low 16K - inc hl - inc de - ld a, (hl) - out (0xFD), a ; Next 16K - ld (de), a - inc hl - inc de - ld a, (hl) ; Next 16K. Leave the common for the task - out (0xFE), a ; switcher - ld (de), a + ld (de), a + ld bc, #4 + ldir + dec hl + dec hl + dec hl + dec hl + ld c, #0xFC + ld b, #4 + outi + inc c + outi + inc c + outi pop af + pop bc pop de ret ; @@ -218,7 +221,8 @@ map_restore: ; ; Save the current mapping. ; -map_save: push hl +map_save: + push hl ld hl, (map_table) ld (map_savearea), hl ld hl, (map_table + 2) -- 2.34.1