My boot loader has passed control to second stage in protected mode. This example shows how to determine if A20 is on or not, by probing memory. I will eventually use color saved @ [A20_STATUS]. Colors conform to BIOS/DOS color mapping.
Test_A20: ; Now we can turn A20 on. Point to a pair of locations where wrap around can be determined.
movesi, 0x7d2c; Point to any volatile place in boot sector
btsedi, 20; Point to same address in next meg of memory
; Procedure will set of 4 colors.
; (1) Green, A20 was already on
; (2) Yellow, Fast A20 gate succeeded, but took ECX times
; (3) Brown, A20 activated using fast method
; (4) Red, couldn't turn on A20 so alternate method must be implemented
movdl, GREEN; Assume A20 is already.
orecx, -1; Large retry count, but probably won't be needed.
; Will loop back to here until retry count in ECX is exhausted.
lodsd; Read dword from boot sector
noteax; Invert 32 bits
stosd; Write back
cmp [esi - 4], eax; Are they the same
jnz.Ok; ZF = 1, A20 is already on. Probably in BOCHS.
; Set color to YELLOW indicating gate was not active, but this method succeeded.
; *** TO DO ***
; This is where an alternate method would be implemented, but all my test computers
; succeeded with this method, so I'll assume most others will work too.
movdl, RED; All methods will fall through to here if they fail.
.Ok: incecx; Bump ECX. It will be NULL if gate was already on
; We will always get to this point unless in BOCHS or another emulator where A20 is
; already on. If method only needed to be used once, color will not be changed
notecx; Indicates actual number of retries
jz@F; Don't change if we only tried Fast A20 gate once.
movdl, BROWN; Indicates there were retrys with fast method
@@: mov [A20_STATUS], dl; Write status of operation to scatch area
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum