A20 and protected mode

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Lovmy
Posts: 17
Joined: Fri Oct 05, 2007 5:58 am

A20 and protected mode

Post by Lovmy »

Hello,

Sorry me English is not very well.

I don't understand why we must activate A20 line before switch to protected mode. Actually i don't make this and my program work fine.

With A0 to A19 address line we can acces from 0 to FFFFF memory (1Mo).
With A20 activated, we can acces from 0 to 1FFFFF memory (2Mo).

In protected mode adresse are coded on 32 bits, from 0 to FFFFFFFF (4Go).
What's the role of A20 line here ? To acces to memory from 1 to 2Mo if i return to real mode ?

Can you explain me ?
Thank you very much !
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Hi,

It's mainly a compatibility thing. On some machines you will find that if A20 is not activated, you will only be able to access every other MiB of address space in PMode. It may be that emulators/modern PC's don't do this - but better to be safe.

Cheers,
Adam
User avatar
Zacariaz
Member
Member
Posts: 1069
Joined: Tue May 22, 2007 2:36 pm
Contact:

Post by Zacariaz »

so i might not need to enable a20 at all? how do i investigate that?
This was supposed to be a cool signature...
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

just try if its enabled or not :wink:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Post by bewing »

Ah, c'mon. It's only 30 or 40 lines of cut-and-paste assembly to stuff into your bootloader.
Lovmy
Posts: 17
Joined: Fri Oct 05, 2007 5:58 am

Example

Post by Lovmy »

Hello,

Can you write example of code to activate A20 adress line ?

It's code to put before LGDT ? (in real mode) ?

Thank you !
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Please seearch the wiki and google before posting - there are countless examples available.

A20 Line
Post Reply