Page 1 of 1

The A20 Problem (JOS)

Posted: Tue Apr 02, 2013 9:52 am
by gapry
The snippet code as following is enable A20 for JOS. It has a problem which confuse for me. The "$0xdf" is a command, not data.It should be out to port 0x64, which is command port. In fact, It port to 0x60, which is data port.
Here, exist two methods (Method 3.1 & Method 3.2) : http://www.brokenthorn.com/Resources/OSDev9.html
So, my question is : Why port to 0x60 (outb %al, %0x60) at last ?

Code: Select all

seta20.1:
  inb     $0x64,%al               # Wait for not busy
  testb   $0x2,%al
  jnz     seta20.1

  movb    $0xd1,%al               # 0xd1 -> port 0x64
  outb    %al,$0x64                                                                                

seta20.2:
  inb     $0x64,%al               # Wait for not busy
  testb   $0x2,%al
  jnz     seta20.2

  movb    $0xdf,%al               # 0xdf -> port 0x60
  outb    %al,$0x60

Re: The A20 Problem (JOS)

Posted: Tue Apr 02, 2013 11:00 am
by iansjack

Re: The A20 Problem (JOS)

Posted: Tue Apr 02, 2013 11:08 am
by gapry
Thanks.

Here, it's picture for KBC http://aodfaq.wikispaces.com/mkbc

The port 0x60 is Data Port, 0xD1 and 0xDF is a command, not Data. So, my question become that "Why send the Command (0xD1, 0xDF, 0xDD) to the Data Port (0x60)? It should be Command Port (0x64)."

Re: The A20 Problem (JOS)

Posted: Tue Apr 02, 2013 11:52 am
by iansjack
Writing 0xd1 to the control port tells the controller to write the next byte sent to the data port to the Controller Output Port. Read about the 8042 controller in the Wiki: http://wiki.osdev.org/%228042%22_PS/2_C ... r_IO_Ports

Re: The A20 Problem (JOS)

Posted: Sat Apr 06, 2013 9:52 am
by gapry
Thanks, I wanna confirm my understanding.

"Writing 0xd1 to the control port tells the controller to write the next byte sent to the data port to the Controller Output Port."

The 0xdf is command which can enable the A20. Finally, the A20 can enable successfully.

But, it exist a question for me.

Following above the resource, it exists a method:
http://www.brokenthorn.com/Resources/OSDev9.html

Code: Select all

; Method 3.1: Enables A20 through keyboard controller
mov al, 0xdd	; command 0xdd: enable a20
out 0x64, al	; send command to controller
What is different between them?

Re: The A20 Problem (JOS)

Posted: Sat Apr 06, 2013 10:31 am
by iansjack
As your link says "Not all controllers support this method". The difference is portability.