VOGONS


First post, by Battler

User metadata
Rank Member
Rank
Member

What happens on real hardware if you enable A20 on the KBC Output Port, but then disable it on Port 92h? Does it stay enabled (the two are OR'ed) or disabled (the two are AND'ed)? And what happens when you do it the other way around - disable A20 on the KBC Out Port and then enable it on Port 92h?

Also, what is the state of A20 after a soft reset and after a hard reset?

Reply 1 of 2, by superfury

User metadata
Rank l33t++
Rank
l33t++

Afaik the two are OR'ed. The order of enabling and disabling doesn't affect it(they're two seperated chips or chipset driving it) after all.

Afaik the state of A20 on powerup of the machine is set to on(8042 on, port 92h off), but after that it's just what was last programmed.

UniPCemu simply does a simple thing: only when emulation is started(initialization of all hardware) it clears A20 bit on System Control Port A and clears(XT) or sets(AT and up) the A20 bit(bit 1) on the 8042(KBC as you call it, although KBC implies no mouse, which it can have on newer machines(on the second PS/2 port)) output port. In all other cases(CPU reset, reboot etc.) it's just left to whatever the value was.

I've checked this with Barotto in the past: https://github.com/barotto/test386.asm/issues … mment-470646476 . It's that post and the 3 posts after it where we verify it's behaviour.
Simply said: it's motherboard-specific. It's probably left alone when resetting/triple faulting, but apparently(if http://www.rcollins.org/Productivity/A20Reset.html is to be believed for the untested motherboards) they're left alone for all motherboards(and we've already found out that isn't the case or some weird behaviour in the memory bus for one device: the generic 486dx-50 machine. And the PS/1 2133 (486dx) seems to set it. But the PS/1 2011 (286) and PS/1 2121 (386sx) honor it's set value.

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 2 of 2, by superfury

User metadata
Rank l33t++
Rank
l33t++

And of course, there's a little thing breaking the compatibility with A20 disabled during reset on the Compaq Deskpro 386: https://github.com/Meowlithius/pcjs-wiki/blob … o-386-update.md
It explains that those machines only clear A20 when the mask is reset and 0x100000-0x1fffff is addressed. So 0xffffxxxx will actually access 0xffffxxxx, so the BIOS will load and run regardless, not #UD faulting?

So, that means that the invalid address method of #UD faulting(my example of the red A being printed) should fail on Compaq Deskpro machines?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io