i found some pseudo code on how to do this and did it in asm. Can you guys critique it for me? i think it makes the PC reset for some reason, am i sending keyboard wrong command? Thanks.
/---------------------Code Snippet-------------------\
;; src coded by xsism
;; put this in your kernel
;; give me some credit
cli
;; 'wait keyboard to clear' function
wkc:
in al, 0x64
test al, 2
jnz wkc
ret
;------------------;
call wkc ; wait for buffer to clear
mov al, 0xAD ; disable keyboard
out 0x64, al ; send to command port
call wkc ; wait for buffer
mov al, 0xD0 ; disable keyboard
out 0x64, al ; send to port
call wkc ; wait for buffer
in al, 0x60 ; save byte status from kbd port to 'al'
push ax ; save byte in stack
call wkc ; wait for buffer
mov al, 0xD1 ; write to output port
out 0x64, al ; send to port
call wkc ; wait for buffer
pop ax ; restore byte
or al,2 ; * turn on a20 bit *
out 0x60, al ; send to command port
call wkc ; wait for buffer
mov al, 0xAE ; re-enable keyboard
out 0x64, al ; send to command port
sti
\-----------------------End Code Snippet---------------------/
regards,
mr. xsism
enabling a20 line
Re:enabling a20 line
ASM isn't C.
The assembler doesn't know or care that wkc is a function so your code falls through the cli, through the wkc function, and if the keyboard isn't already clear it tries to return. Seeing as it was never called in the first place the value of IP it pops off the stack on ret is unlikely to take it anywhere pleasant.
Code: Select all
cli
;; 'wait keyboard to clear' function
wkc:
in al, 0x64
test al, 2
jnz wkc
ret
;------------------;
Re:enabling a20 line
that cli should be after the wkc function.
that isn't how i implement it in my kernel. close enough though. thx 4 the advice
regards,
mr. xsism
that isn't how i implement it in my kernel. close enough though. thx 4 the advice
regards,
mr. xsism