Feat: Keyboard strokes working and in buffer
This commit is contained in:
+8
-31
@@ -1,6 +1,10 @@
|
||||
; File: elevator.asm
|
||||
; Stage 2 Bootloader - No size limit!
|
||||
; Job: Load kernel, set up GDT, switch to 64-bit mode, jump to kernel
|
||||
%ifndef KERNEL_SECTORS
|
||||
%define KERNEL_SECTORS 10 ; fallback default if build.sh doesn't override it
|
||||
%endif
|
||||
|
||||
[org 0x7e00]
|
||||
[bits 16]
|
||||
|
||||
@@ -104,7 +108,7 @@ load_kernel:
|
||||
|
||||
; Set up DAP (Disk Address Packet)
|
||||
mov word [dap_size], 0x10
|
||||
mov word [dap_sectors], 10
|
||||
mov word [dap_sectors], KERNEL_SECTORS
|
||||
mov word [dap_offset], 0x0000
|
||||
mov word [dap_segment], 0x1000
|
||||
mov dword [dap_lba_low], 6 ; LBA 6 = bytes 3072+ (sector 7 in CHS)
|
||||
@@ -136,7 +140,7 @@ load_kernel:
|
||||
|
||||
; Read using CHS
|
||||
mov ah, 0x02 ; Read function
|
||||
mov al, 10 ; Number of sectors
|
||||
mov al, KERNEL_SECTORS ; Number of sectors
|
||||
mov ch, 0 ; Cylinder 0
|
||||
mov cl, 7 ; Sector 7
|
||||
mov dh, 0 ; Head 0
|
||||
@@ -490,7 +494,6 @@ pm_msg: db '[PM32] Setting up Long Mode...', 0
|
||||
; 64-BIT LONG MODE
|
||||
; ============================================================
|
||||
[bits 64]
|
||||
[extern __keyboard_buffer_push] ; External function to push key into keyboard buffer
|
||||
long_mode:
|
||||
; Set up segments
|
||||
mov ax, 0x20
|
||||
@@ -518,8 +521,6 @@ long_mode:
|
||||
mov rsi, before_kernel_msg
|
||||
call print_64
|
||||
|
||||
sti ; Enable interrupts before jumping to kernel
|
||||
|
||||
; JUMP TO KERNEL!
|
||||
call KERNEL_OFFSET
|
||||
|
||||
@@ -624,32 +625,6 @@ setup_pic:
|
||||
|
||||
ret
|
||||
|
||||
; keyboard handler - Catch PIC interrupt
|
||||
keyboard_handler:
|
||||
push rax
|
||||
push rdx
|
||||
push rdi
|
||||
push r8
|
||||
|
||||
mov dx, 0x60
|
||||
in al, dx
|
||||
|
||||
; convert ASCII
|
||||
; assuming output on r8 (as an example)
|
||||
|
||||
; Acording to x86_64 SystemV
|
||||
mov rdi, r8
|
||||
call __keyboard_buffer_push
|
||||
|
||||
mov al, 0x20
|
||||
out 0x20, al
|
||||
|
||||
pop r8
|
||||
pop rdi
|
||||
pop rdx
|
||||
pop rax
|
||||
iretq
|
||||
|
||||
; Exception handler - shows what went wrong
|
||||
exception_handler:
|
||||
; Save registers
|
||||
@@ -707,6 +682,8 @@ exception_handler:
|
||||
|
||||
; Dummy interrupt handler for IRQs (not CPU exceptions)
|
||||
dummy_handler:
|
||||
mov al, 0x20
|
||||
out 0x20, al ; Send EOI to PIC
|
||||
iretq
|
||||
|
||||
idt_descriptor:
|
||||
|
||||
Reference in New Issue
Block a user