Skip to content

Commit 830f4ac

Browse files
authored
Merge pull request #180 from np511/master
Make ioSendPacket and ioRegisterHandler thread-safe
2 parents d60a3e8 + 5fb3aff commit 830f4ac

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/00/link.asm

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ default_header_handlers_end:
9898
ioRegisterHandler:
9999
push hl
100100
push de
101+
push bc
102+
ld c, a
103+
ld a, i
104+
push af
105+
ld a, c
106+
di
101107
push af
102108
push bc
103109
push ix
@@ -123,6 +129,11 @@ ioRegisterHandler:
123129
ld (hl), b \ dec hl
124130
pop af
125131
ld (hl), a
132+
pop af
133+
jp po, _
134+
ei
135+
_:
136+
pop bc
126137
pop de
127138
pop hl
128139
ret
@@ -150,6 +161,9 @@ ioRegisterHandler:
150161
;; will end in tears.
151162
ioSendPacket:
152163
push bc
164+
push af
165+
ld a,i
166+
di
153167
push af
154168
; io_tx_header_ix is 0xFF when ready to send
155169
ld a, (io_tx_header_ix)
@@ -185,11 +199,19 @@ _: ld (io_tx_header), de
185199
out (PORT_LINK_ASSIST_ENABLE), a
186200
pop de
187201
pop hl
202+
pop af
203+
jp po, _
204+
ei
205+
_:
188206
pop af
189207
pop bc
190208
cp a
191209
ret
192210
.abort:
211+
pop af
212+
jp po, _
213+
ei
214+
_:
193215
pop af \ ld b, a \ or 1 \ ld a, b
194216
pop bc \ ret ; Packet in progress, GTFO
195217

0 commit comments

Comments
 (0)