**I emulate on qemu**
Here are my routines:
Code: Select all
read_port:
mov edx, [esp + 4]
in al, dx
ret
write_port:
mov edx, [esp + 4]
mov al, [esp + 4 + 4]
out dx, al
ret
I understand the following:
Writing to port 0x64 is sending commands to the controller. (always)
Reading from port 0x64 is reading the status register of the controller. (always)
Reading/writing to port 0x60 has different functionalities.
Here's my first question: Where do these data buffers come into the picture?
That is, when one reads the status register, bit#0 and bit#1 tell us the status of the input and output buffers respectively. What are these? Do I "fill" this buffer whenever I write to 0x60/0x64? Am I reading from the input (output? from the perspective of the controller) buffer whenever I read from 0x60? I'm guessing that reading from 0x64 shouldn't affect the buffers because the status register is what's returned in that case (always?).
I was doing some experiments in my c kernel.
Code: Select all
uint32_t read_port (uint32_t portnumber);
void write_port (uint32_t portnumber,uint32_t data);
//printhex is function that prints the hex value of a 32 bit integer
kmain(){
write_port(0x64,0x20); //This command outputs the byte 0 of internal RAM : the CCB
printhex(read_port(0x64));
printhex(read_port(0x60));
write_port(0x64,0x23); //This command outputs the byte 3 of internal RAM
printhex(read_port(0x64));
printhex(read_port(0x60)); //I should be getting the value of byte 3 now?
}
I'm guessing that the status register has the value 1D.
Byte number 0 of internal RAM has the value 0x9C.
Byte number 3 of internal RAM has the value 0x61.
Is this right? But when I do this:
Code: Select all
kmain(){
write_port(0x64,0x23); //This command outputs the byte 3 of internal RAM
printhex(read_port(0x64));
printhex(read_port(0x60)); //I should be getting the value of byte 3 now?
}