Add 01h and 02h for DOSAPI
This commit is contained in:
parent
4b9d6da85c
commit
0094ee6b95
19
kernel/dosapi.asm
Normal file
19
kernel/dosapi.asm
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
isr_dosmain:
|
||||
cmp ah, 0x01
|
||||
je isr_getc_echo
|
||||
cmp ah, 0x02
|
||||
je isr_putc
|
||||
iret
|
||||
|
||||
isr_getc_echo:
|
||||
mov ah, 0x00
|
||||
int 0x16
|
||||
cmp al, 0x00
|
||||
je isr_getc_echo
|
||||
iret
|
||||
|
||||
isr_putc:
|
||||
mov al, dl
|
||||
call kputc
|
||||
iret
|
@ -1,22 +1,39 @@
|
||||
; Data table for interrupts
|
||||
; cs:word for service routine
|
||||
intr_table:
|
||||
dw iret ; 0 Divide by Zero
|
||||
dw iret ; 1 Single Step
|
||||
dw iret ; 2 Parity error routine (NMI)
|
||||
dw debug_reg_ir ; 3 Break
|
||||
dw iret ; 4 Overflow
|
||||
dw iret ; 5 Print Screen
|
||||
dw iret ; 6 Mouse button control
|
||||
dw iret ; 7 Reserved
|
||||
dw irq0 ; 8 System Clock interrupt
|
||||
dw irq1 ; 9 Keyboard interrupt
|
||||
dw irq2 ; 10 RTC interrupt
|
||||
dw irq3 ; 11 COMMS
|
||||
dw irq4 ; 12 COMMS
|
||||
dw irq5 ; 13 Hard Disk
|
||||
dw irq6 ; 14 Floppy Disk interrupt routine
|
||||
dw irq7 ; 15 Printer interrupt
|
||||
intr_table0:
|
||||
dw iret ; 00 Divide by Zero
|
||||
dw iret ; 01 Single Step
|
||||
dw iret ; 02 Parity error routine (NMI)
|
||||
dw debug_reg_ir ; 03 Break
|
||||
dw iret ; 04 Overflow
|
||||
dw iret ; 05 Print Screen
|
||||
dw iret ; 06 Mouse button control
|
||||
dw isr_dosmain ; 07 Reserved
|
||||
dw irq0 ; 08 System Clock interrupt
|
||||
dw irq1 ; 09 Keyboard interrupt
|
||||
dw irq2 ; 0a RTC interrupt
|
||||
dw irq3 ; 0b COMMS
|
||||
dw irq4 ; 0c COMMS
|
||||
dw irq5 ; 0d Hard Disk
|
||||
dw irq6 ; 0e Floppy Disk interrupt routine
|
||||
dw irq7 ; 0f Printer interrupt
|
||||
intr_table2:
|
||||
dw iret ; 20
|
||||
dw isr_dosmain ; 21
|
||||
dw iret ; 22
|
||||
dw iret ; 23
|
||||
dw iret ; 24
|
||||
dw iret ; 25
|
||||
dw iret ; 26
|
||||
dw iret ; 27
|
||||
dw iret ; 28
|
||||
dw iret ; 29
|
||||
dw iret ; 2a
|
||||
dw iret ; 2b
|
||||
dw iret ; 2c
|
||||
dw iret ; 2d
|
||||
dw iret ; 2e
|
||||
dw iret ; 2f
|
||||
|
||||
; LSB is IRQ0, MSB is IRQ16
|
||||
; A IRQ will set their bit to 1, so userspace may poll it via wait_irq
|
||||
@ -34,17 +51,26 @@ intr_init:
|
||||
mov di, 0x0100 ; write to offset of int 0x40 address
|
||||
mov cx, 0x0020 ; 0x10 vectors, segment:offset each
|
||||
repe movsw
|
||||
; now setup our own handlers
|
||||
; now setup our own handlers (0x0n)
|
||||
mov ax, cs
|
||||
mov ds, ax ; read from local segment
|
||||
mov si, intr_table ; read from intr_table
|
||||
mov si, intr_table0 ; read from intr_table
|
||||
mov di, 0x0000 ; write to start of IVT table
|
||||
mov cx, 0x0010 ; 0x10 vectors, one offset each
|
||||
.loop:
|
||||
movsw ; read offset, write offset
|
||||
.loop0:
|
||||
movsw ; read offset; write offset
|
||||
mov ax,cs
|
||||
stosw ; write segment
|
||||
loop .loop
|
||||
loop .loop0
|
||||
; second vector block (0x2n)
|
||||
mov si, intr_table2 ; read from intr_table
|
||||
mov di, 0x0080 ; write to int 20h vector and above
|
||||
mov cx, 0x0010 ; 0x10 vectors, one offset each
|
||||
.loop2:
|
||||
movsw ; read offset; write offset
|
||||
mov ax,cs
|
||||
stosw ; write segment
|
||||
loop .loop2
|
||||
pop es
|
||||
pop ds
|
||||
ret
|
||||
@ -57,11 +83,6 @@ irq0:
|
||||
irq1:
|
||||
int 0x49
|
||||
or byte [intr_flip], 0x02
|
||||
push ax
|
||||
mov ax, [intr_flip]
|
||||
call kprint8
|
||||
mov word [intr_flip], 0x0000
|
||||
pop ax
|
||||
jmp irqret
|
||||
|
||||
irq2:
|
||||
|
@ -14,15 +14,21 @@ main:
|
||||
|
||||
int 3
|
||||
|
||||
mov ah, 0x01
|
||||
int 0x21
|
||||
mov dl, al
|
||||
mov ah, 0x02
|
||||
int 0x21
|
||||
|
||||
sti
|
||||
.halt:
|
||||
hlt
|
||||
jmp .halt
|
||||
|
||||
%include "heap.asm"
|
||||
%include "intr.asm"
|
||||
%include "debug.asm"
|
||||
%include "kprintf.asm"
|
||||
%include "dosapi.asm"
|
||||
|
||||
_reloc_end:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user