在DOS实模式下直接存取4GB内存(3)
2015-06-24 01:06
导读:outportb(0x64,0xD1); KeyWait(); outportb(0x60,0xDF);//EnableA20with8042. KeyWait(); outportb(0x64,0xFF); KeyWait(); } voidLoadFSLimit4G(void) { A20Enable();//EnableA20 //*** DisableintsNullIDT //*** a
outportb(0x64,0xD1);
KeyWait();
outportb(0x60,0xDF); //Enable A20 with 8042.
KeyWait();
outportb(0x64,0xFF);
KeyWait ();
}
void LoadFSLimit4G(void)
{
A20Enable (); //Enable A20
//***
Disable ints & Null IDT
//***
asm {
CLI //Disable inerrupts
SIDT OldIDT //Save OLD IDTR
LIDT pdescr-tmp //Set up empty IDT.Disable any interrupts,
} // Include NMI.
//***
Lodd GDTR
//***
asm{ // The right Code is Real, But BC++ s Linker NOT
// Work with 32bits Code.
db 0x66 //32 bit Operation Prefix in 16 Bit DOS.
MOV CX,DS //MOV ECX,DS
db 0x66 //Get Data segment physical Address
SHL CX,4 //SHL ECX,4
MOV word ptr pdescr-tmp [0],(3*8-1)
//MOV word ptr pdescr-tmp [0], (3*8-1)
db 0x66
XOR AX,AX //XOR EAX,EAX
MOV AX,offset GDT-Table
// MOV AX,offset GDT-Table
db 0x66
ADD AX,CX //ADD EAX,ECX