From the OSDev page on the A20 line, the code for enabling A20 is given as:
enable_A20:
cli
call a20wait
mov al,0xAD
out 0x64,al
call a20wait
mov al,0xD0
out 0x64,al
call a20wait2
in al,0x60
push eax
call a20wait
mov al,0xD1
out 0x64,al
call a20wait
pop eax
or al,2
out 0x60,al
call a20wait
mov al,0xAE
out 0x64,al
call a20wait
sti
ret
a20wait:
in al,0x64
test al,2
jnz a20wait
ret
a20wait2:
in al,0x64
test al,1
jz a20wait2
ret
a20wait
waits on the input buffer and a20wait2
on the output buffer.
From what I understood, writing to/reading from 0x64 access the command/status register and not the buffer registers.
Then why are there are so many waits on the input/output buffers ? Shouldn't there be one on the output buffer before reading the status register, and one on the input buffer after writing the new command byte ?
I tried disabling all other wait calls except the two I mentioned in the previous paragraph and it worked fine. But I'm curious as to why they are there. Is there some other reason ?