summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2018-07-04 20:55:53 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2018-07-04 20:55:53 -0400
commit877e9bfe8e7d9e93536f4cb4af36aac65805be11 (patch)
treeaef4ef6d60f213a5fa54853ee3b45d7b2eb43ebd
parentc19a6ee17abf862115accd15876c64b7d39a7e9c (diff)
downloadminos-877e9bfe8e7d9e93536f4cb4af36aac65805be11.tar.gz
Begin refactoring ISR codeHEADmaster
-rw-r--r--constants.asm3
-rw-r--r--isr.asm19
-rw-r--r--kernel.asm39
3 files changed, 49 insertions, 12 deletions
diff --git a/constants.asm b/constants.asm
index ac6438a..16f7510 100644
--- a/constants.asm
+++ b/constants.asm
@@ -7,6 +7,9 @@ MAX_COLS equ 80
LENGTH_ROW equ 0A0h ; NOTE: length in bytes (80 * 2 = 160)
LENGTH_COL equ 02h ; NOTE: length in bytes (1 * 2 = 2)
+ISR_TEST equ 20h
+ISR_MINOS equ 21h
+
%include "colors.asm"
%include "ascii.asm" ; ASCII control codes
%include "scancodes.asm" ; Keyboard scancodes
diff --git a/isr.asm b/isr.asm
index 9ac6bb6..9bab410 100644
--- a/isr.asm
+++ b/isr.asm
@@ -1,5 +1,22 @@
int21:
- nop
+ cmp al, .fn_table_size
+ jg .return
+
+ push bx
+ push di
+ movsx bx, al
+ mov di, .fn_table
+ call [di+bx]
+ pop di
+ pop bx
+
+ .return:
+ iret
+
+ .fn_table:
+ dw memset
+ dw memcpy
+ .fn_table_size dw $-.fn_table
int22:
nop
int20:
diff --git a/kernel.asm b/kernel.asm
index f92b294..5ef64f0 100644
--- a/kernel.asm
+++ b/kernel.asm
@@ -88,6 +88,14 @@ kmain:
jle .info_disk_loop ; continue
.preload:
+ push ISR_TEST
+ push int20
+ call isr_inject
+
+ int 20h ; test routine
+
+ push ISR_MINOS
+ push int21
call isr_inject
.mainloop:
@@ -105,31 +113,40 @@ isr_inject:
push es
push ax
push bx
- push bp
+ push cx
+ push di
+ push ds
- mov ax, 0000h ; set ES to Interrupt Vector Table
+ mov ax, 0000h ; set DS/ES to Interrupt Vector Table
; (start of RAM)
mov es, ax
+ mov ds, ax
- mov bp, 20h * 4 ; Set vector (v = es:offset * 4))
- lea bx, [int22] ; Load address of ISR routine
- mov ax, cs ; Load code segment into AX
+ ;mov bp, 20h * 4 ; Set vector (v = es:offset * 4))
+ ;lea bx, [int22] ; Load address of ISR routine
+ mov bx, [bp + 4] ; ISR routine
+ mov di, [bp + 6] ; IVT offset
+ shl di, 2 ; IVT * 4
- mov word [es:bp], bx ; Store address of ISR routine
- mov word [es:bp+2], ax ; Store code segment of ISR routine
+ mov ax, cs ; Load code segment into AX
+ mov word [ds:di], bx ; Store address of ISR routine
+ mov word [ds:di+2], ax ; Store code segment of ISR routine
+ pop ds ; Restore DS so we can print
push bx
push ax
+ push word [bp + 6]
push msg_isr_fmt
call printf ; print injected ISR address
- add sp, 2 * 3 ; cleanup stack
+ add sp, 2 * 4 ; cleanup stack
- pop bp
+ pop di
+ pop cx
pop bx
pop ax
pop es
- int 20h ; test new ISR
+ ;int 20h ; test new ISR
mov sp, bp
pop bp
@@ -164,7 +181,7 @@ msg_entry_point_fmt:
db 'Kernel address: %5x:%4x - %5x:%4x (%d:%d - %d:%d)\n'
db 'Stack address : %5x:%4x (%d:%d)\n'
db 'Boot device : %2x\n\n', 0
-msg_isr_fmt: db "ISR %5x:%4x\n", 0
+msg_isr_fmt: db "ISR %2xh, %5x:%4x\n", 0
; Error messages
error_msg_panic: db "PANIC: ", 0