Skip to content

Commit

Permalink
zeal8bit: fix a regression that happened after the keyboard refactoring
Browse files Browse the repository at this point in the history
The interrupt handler needs to remap the kernel RAM to have access to the keyboard fifo.
This commit also fixes some comments.
  • Loading branch information
Zeal8bit committed Dec 28, 2024
1 parent cb00736 commit 91cc1bf
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
4 changes: 1 addition & 3 deletions target/zeal8bit/keyboard.asm
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ keyboard_fifo_size:
; Parameters:
; A - Value to enqueue in the FIFO
; Returns:
; A - Non-zero value on success, 0 if FIFO empty
; -
; Alters:
; A, HL
PUBLIC keyboard_enqueue
Expand Down Expand Up @@ -601,8 +601,6 @@ kb_buffer_size: DEFS 1
; Index of the cursor in the internal buffer
; 0 <= cursor <= KB_INTERNAL_BUFFER_SIZE - 1
kb_buffer_cursor: DEFS 1
; State that will be updated according to the keys received in non-blocking mode
kb_next_step: DEFS 2

SECTION DRIVER_BSS_ALIGN16
ALIGN 16
Expand Down
6 changes: 2 additions & 4 deletions target/zeal8bit/keyboard/ps2.asm
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ keyboard_impl_next_key:
call keyboard_dequeue
; If no character, return
ret z
; We just got a character, in D, check if we have to resume a previous
; We just got a character, in A, check if we have to resume a previous
; step on hold (non-blocking mode)
ld b, a
ld hl, (kb_next_step)
Expand Down Expand Up @@ -235,9 +235,7 @@ extended_scan:

PUBLIC keyboard_ps2_int_handler
keyboard_ps2_int_handler:
; Kernel RAM is now available!
; In the keyboard interrupt handler, we will retrieve the key that has just been
; pressed and put it in our FIFO
; Enqueue the PS/2 scan code we just received
in a, (KB_IO_ADDRESS)
jp keyboard_enqueue

Expand Down
11 changes: 11 additions & 0 deletions target/zeal8bit/pio.asm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
; SPDX-License-Identifier: Apache-2.0

INCLUDE "osconfig.asm"
INCLUDE "mmu_h.asm"
INCLUDE "errors_h.asm"
INCLUDE "drivers_h.asm"
INCLUDE "pio_h.asm"
Expand Down Expand Up @@ -59,6 +60,12 @@ interrupt_default_handler:
interrupt_pio_handler:
ex af, af'
exx
; The kernel RAM may NOT BE MAPPED, we have to map it here
MMU_GET_PAGE_NUMBER(MMU_PAGE_3)
; Save former page in D, we need it to restore it
ld d, a
MMU_MAP_KERNEL_RAM(MMU_PAGE_3)

; Check which pin triggered the interrupt, multiple pins can trigger
; this interrupt, so all pins shall be checked.
in a, (IO_PIO_SYSTEM_DATA)
Expand All @@ -76,6 +83,10 @@ interrupt_pio_handler:
bit IO_KEYBOARD_PIN, a
call z, keyboard_ps2_int_handler
ENDIF

ld a, d
MMU_SET_PAGE_NUMBER(MMU_PAGE_3)

exx
ex af, af'
ei
Expand Down
6 changes: 3 additions & 3 deletions target/zeal8bit/video.asm
Original file line number Diff line number Diff line change
Expand Up @@ -510,13 +510,13 @@ stdout_print_buffer:
ENDIF ; CONFIG_TARGET_STDOUT_VIDEO

; Routine called everytime a V-blank interrupt occurs
; Must not alter A
; Must not alter A, nor DE
PUBLIC video_vblank_isr
video_vblank_isr:
; Add 16(ms) to the counter
ld hl, (vblank_count)
ld de, 16
add hl, de
ld bc, 16
add hl, bc
ld (vblank_count), hl
ret

Expand Down

0 comments on commit 91cc1bf

Please sign in to comment.