Not able to enable A20 (SOLVED)
Posted: Sun Apr 22, 2007 5:04 am
Hello everyone, this is my first post
A year ago i wanted to write a bootsector and a little kernel for learning purposes but i was too busy and i didn't understand everything. Now i have more time and a better grasp of the theory behind OS developement so i gave it another shot.
I have a simple bootloader that enables protected mode and now i want to enable the A20 gate, but i'm having a hard time doing that. I've read a couple of tutorials and the 8042 keyboard controller info and i found out that some sites don't give correct information. So i tried to figure it out with the datasheet and i've come up with some code:
The routines:
And the code that actually (tries to) enable A20:
Yes i like to overcomment, i'm a forgetful person
So this doesn't work (i'm trying with VMware Server). I know there are a lot of methods for enabling A20 but i can't find decent tutorials on the net so i wanted to try the old fashioned keyboard controller trick. Can anyone explain why this isn't working and how i can solve it? And if someone can give me some links to decent tutorials with different A20 enabling methods, i'd be very grateful
Thanks in advance
EDIT: It seems that this wasn't the problem. The code above works on every pc in my house (i have about 6) but it was in the code that called the a20_enable function. The last line of code (ret) is where it went wrong, because i mixed jmp's and call's, so when i did ret it had nowhere to return to because it was jmp'ed there (DOH!).
But my second question still remains: if anyone has a link to a decent tutorial that shows different A20 enabling methods, i'd be grateful
A year ago i wanted to write a bootsector and a little kernel for learning purposes but i was too busy and i didn't understand everything. Now i have more time and a better grasp of the theory behind OS developement so i gave it another shot.
I have a simple bootloader that enables protected mode and now i want to enable the A20 gate, but i'm having a hard time doing that. I've read a couple of tutorials and the 8042 keyboard controller info and i found out that some sites don't give correct information. So i tried to figure it out with the datasheet and i've come up with some code:
The routines:
Code: Select all
a20_wait_for_clear: ; wait for the keyboard controller to clear
xor al, al ; empty al
in al, 0x64 ; read port 0x64 (status register of keyb. controller)
test al, 00000010b ; check if bit 1 is clear (no data for keyb. controller waiting)
jnz a20_wait_for_clear ; if not, try again
ret
a20_wait_for_full:
xor al, al ; empty al
in al, 0x64 ; read port 0x64 (status register of keyb. controller)
test al, 00000001b ; check if bit 0 is not clear (keyb. controller has data for us)
jz a20_wait_for_full ; if clear, try again
ret
a20_read_output_port:
mov al, 0xD0 ; move the 'read output port'-command to al
out 0x64, al ; send the command to keyb. controller
call a20_wait_for_full ; wait until the keyb. controller processes the command
xor al, al ; empty al
in al, 0x60 ; read the result of the command to al
ret
a20_write_output_port:
mov al, 0xD1 ; move the 'write output port'-command to al
out 0x64, al ; send the command to keyb. controller
call a20_wait_for_clear ; wait until keyb. controller processed the command
mov al, [a20command] ; move the command we want to send to al
out 0x60, al ; send the command to the dataregister (0x60)
ret
Code: Select all
a20_enable:
call a20_wait_for_clear ; wait for the keyb. controller to become ready
call a20_read_output_port ; read the output port of keyb. controller
or al, 00000010b ; set the A20-bit
mov [a20command], al ; save the command
call a20_wait_for_clear ; wait for the keyb. controller to become ready
call a20_write_output_port ; write the command to the keyb. controller
call a20_wait_for_clear ; wait for the keyb. controller to become ready
call a20_read_output_port ; read the output port of keyb. controller
test al, 00000010b ; test if the A20-bit is enabled
jz halt ; if not then halt
ret
So this doesn't work (i'm trying with VMware Server). I know there are a lot of methods for enabling A20 but i can't find decent tutorials on the net so i wanted to try the old fashioned keyboard controller trick. Can anyone explain why this isn't working and how i can solve it? And if someone can give me some links to decent tutorials with different A20 enabling methods, i'd be very grateful
Thanks in advance
EDIT: It seems that this wasn't the problem. The code above works on every pc in my house (i have about 6) but it was in the code that called the a20_enable function. The last line of code (ret) is where it went wrong, because i mixed jmp's and call's, so when i did ret it had nowhere to return to because it was jmp'ed there (DOH!).
But my second question still remains: if anyone has a link to a decent tutorial that shows different A20 enabling methods, i'd be grateful