Would checking for a wrap-around be a definitive test?
Something along the lines of:
Code: Select all
GateA20Test:
Write X to 0x0
Write X to 0x100000
if ([0x0] == [0x100000])
goto GateA20Open;
else
useNextA20EnablingFunction;
goto GateA20Test
Code: Select all
GateA20Test:
Write X to 0x0
Write X to 0x100000
if ([0x0] == [0x100000])
goto GateA20Open;
else
useNextA20EnablingFunction;
goto GateA20Test
Address of the system-wide division overflow (/by 0) handler. If you have none of your own and do not intend to cause and handle division overflows, chances are, this is a rather useless one and whether it's restored to its original value or left corrupted, the handler won't be able to do anything meaningful (return, causing an infinite loop, reset the CPU, etc) anyway.SpyderTL wrote:However, memory address 0x00 may be used by something, like the real mode interrupt table. So you might not want to change that particular value.
An even safer route would involve using VM86 mode.neon wrote:You can use int 15h function 2403h and int 15h function 2402h to check for A20. Modern systems should support these.
You don't have to use 0 and 1MB. Testing using the boot loader signature (as was suggested above) and compare address 0:7dfe with ffff:7e0e, if they are the same, then you know A20 is not enabled. This is the safest route.
Do you have any examples of such systems? (Ideally, I'd like a copy of the BIOS ROM so I can examine it.)~ wrote:In some ancient 386DX machines, these functions, as well as the functions to retrieve the motherboard's memory map, make the whole system crash.
If you reset the system, the KBC is more likely there. That's another of its functions, and if you aren't careful you can reset the system at the same time that you're trying to enable the A20.Kazinsal wrote:When fiddling with A20, do not poke the keyboard controller unless you know for sure it's there. If it's not there, at best, you'll get nothing back. More likely, you'll hang or reset the system.
Best thing to do is ask the BIOS to do it for you, and if you really feel the need to do it yourself, you need to go through the ACPI tables and see if there's a keyboard controller present (you're looking for the IA-PC boot architecture flag word in the Fixed ACPI Description Table.)
Welcome to the rabbit hole that is operating systems development.
If the system resets or hangs when you frob the A20 line or the keyboard status port then you don't have a keyboard controller. Simple as that.~ wrote:If you reset the system, the KBC is more likely there. That's another of its functions, and if you aren't careful you can reset the system at the same time that you're trying to enable the A20.
False. You can definitely hang a system that has no keyboard controller just by attempting to read from or write to it once, no loops involved. See all x86 Macs.There's no way to hang the system, unless you use an infinite loop and a specific, real machine model that is known for not having a KBC. Also, at this point no other modern peripherals would use I/O ports or memory regions of legacy devices. It would make things much more dirty regardless of whether they are still there or not.
The added complexity/hassle of v86 mode crud is far more likely to cause problems/bugs that wouldn't have existed otherwise than it is to successfully work-around bugs that only exist in extremely rare cases. For a simple example, there's at least one "PXE ROM" implementation that hooks "int 0x15" (to steal/reserve memory that it uses) that also switches to/from protected mode (partly to access the NIC's memory mapped registers and partly because I suspect it's mostly written in 32-bit C) where attempting to use v86 mode will cause it to crash (because you can't expect to re-enable protected mode in CR0 when you're in v86 mode).~ wrote:The key is to use V86 tasks to call critical BIOS code through INT instructions at the time that it will protect us from any failure and then we will be able to actually complete the initialization of the system without letting it crash or hang by running extremely critical stuff directly in a vulnerable Real Mode environment directly.[/b]
That's because int 0x15 function 0xe881 is designed to be called from 32-bit protected mode; of course it won't work if you call it in real mode or v86 mode. It probably works on that computer, if you can figure out how to call it properly!Brendan wrote:Note: I do have a 75 MHz Pentium machine which locks up when "int 0x15, eax=0xE881" is called (which would probably lock up exactly the same if you used v86).
It's NOT designed to be called from protected mode. That doesn't even make any sense.Octocontrabass wrote:That's because int 0x15 function 0xe881 is designed to be called from 32-bit protected mode; of course it won't work if you call it in real mode or v86 mode. It probably works on that computer, if you can figure out how to call it properly!Brendan wrote:Note: I do have a 75 MHz Pentium machine which locks up when "int 0x15, eax=0xE881" is called (which would probably lock up exactly the same if you used v86).
I only use the "int 0x15" name because it's handled by the int 0x15 dispatcher; I have no idea how you're actually supposed to call it.Brendan wrote:It's NOT designed to be called from protected mode. That doesn't even make any sense.