From 45493ea4f12deeb5f544d79fd209b5ab552c0d02 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Wed, 16 May 2018 22:18:14 +0100 Subject: [PATCH] trs80: fix a tiny race in the floppy code We could otherwise take an NMI in a IRQ held over until the EI. When that happens we mangle the wrong stack and .... splat! --- Kernel/platform-trs80/floppy.s | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Kernel/platform-trs80/floppy.s b/Kernel/platform-trs80/floppy.s index 2456b2dd..592222ce 100644 --- a/Kernel/platform-trs80/floppy.s +++ b/Kernel/platform-trs80/floppy.s @@ -61,6 +61,9 @@ nap: dec bc ; ; The motor off logic is driven from hardware ; +; fdc_active must never be set when interrupts are enabled or we may +; take a motor off during an interrupt... +; fd_nmi_handler: push af push bc @@ -185,17 +188,16 @@ rwiowt: djnz rwiowt ; Status registers ; fdxferdone: - ei -fdxferdone2: xor a ld (fdc_active), a + ei in a, (FDCREG) and #0x19 ; Error bits + busy bit 0, a ; Wait for busy to drop, return in a ret z ld a, (fdcctrl) out (FDCCTRL), a - jr fdxferdone2 + jr fdxferdone ; ; Read from the disk - HL points to the target buffer ; -- 2.34.1