PMode mem moving doesn´t work

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.
drizzt

Re:PMode mem moving doesn´t work

Post by drizzt »

Another way to enable A20 gate is with BIOS INT 0x15, but it works only in recent BIOS:
(from Ralph Brown interrupt list)
INT 15 AX=2400 disable A20
INT 15 AX=2401 enable A20
INT 15 AX=2402 query status A20
INT 15 AX=2403 query A20 support (kbd or port 92)

Return:
If successful: CF clear, AH = 00h
On error: CF set, AH = status
Status: 01h keyboard controller is in secure mode
86h function not supported
For AX=2402 the status (0: disabled, 1: enabled) is returned in AL
For AX=2403 the status (bit 0: kbd, bit 1: port 92) is returned in BX

Note that this could work in your real hardware, but could crash in another one... A20 is a bad thing! People hate it but it continue to exist!
The best way to enable A20 gate without problem would be to begin with the keyboard controller and continue with the other methods. At every step you could test if A20 has been enabled... in this case you can stop this boring routine and continue with the next one ;)
FlashBurn

Re:PMode mem moving doesn´t work

Post by FlashBurn »

I still have problems with this **** a20gate >:( . I attached my new code. Maybe you have a look at it.

[attachment deleted by admin]
FlashBurn

Re:PMode mem moving doesn´t work

Post by FlashBurn »

Isn?t here anyone who have an idea, what it also could be for a problem?! I think it?s the a20gate, but I?m not sure. Maybe there is another way how I could test if the a20gate is on or not?!
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:PMode mem moving doesn´t work

Post by Pype.Clicker »

Code: Select all

volatile extern char mem[];

char zero=mem[0]; char mega=mem[0x10000];

mem[0]=1; mem[0x10000]=2;
switch(mem[0]) {
case 2: printf("A20 gate disabled. Good for old' 8086 progz");
break;
case 1: printf("A20 gate enabled. Good for newOS");
break;
default: printf("dude, you should not overclock like that!");
}
mem[0]=zero;
mem[0x10000]=mega;
FlashBurn

Re:PMode mem moving doesn´t work

Post by FlashBurn »

And how could I do this in asm?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:PMode mem moving doesn´t work

Post by Pype.Clicker »

replace = with moves and switch with compares :)

Code: Select all

mem[0]=1 --> mov byte [0],1
pini

Re:PMode mem moving doesn´t work

Post by pini »

Using port 0x92 to enable/disable the A-20 gate is possible,but this is *not* a standard implementation, so you should prefer the use of the keyboard controller at port 0x64 (put 0xD1 and then 0xDF to open it).

mem moving over the first meg limit implies you have a correct GDT with at least one descriptor that has a limit high enough.
Then you have to make one of the segment register (prefer FS or GS to others) point to this descriptor.

To move your data from below to above the first meg, you must use segment override. For example, with NASM code :

Code: Select all

; Assuming FS points to the correct GDT descriptor
; And ESI contains the source linear address
; and EDI contains the destination linear address

mov eax,dword [fs:esi]
mov dword [fs:edi],eax
But maybe the 'dword' operand size may not be necessary : check out by yourself.
FlashBurn

Re:PMode mem moving doesn´t work

Post by FlashBurn »

Ok, I tested your version, but it also wont work on a real pc :( This is my GDT, maybe the failure is there.

Code: Select all

GDT:
   db 0x00               ;(0000: Null Descriptor:) Bits 07-00 of Limit
   db 0x00               ;Bits 15-08 of Limit
   db 0x00               ;Bits 07-00 of Base
   db 0x00               ;Bits 15-08 of Base
   db 0x00               ;Bits 23-16 of Base
   db 0x00               ;Access Byte
   db 0x80               ;Flags & Bits 19-16 of Limit
   db 0x00               ;Bits 31-24 of Base

   db 0xFF               ;(0008: Code Segment Descriptor:) Bits 07-00 of Limit
   db 0xFF               ;Bits 15-08 of Limit
   db 0x00               ;Bits 07-00 of Base
   db 0x00               ;Bits 15-08 of Base
   db 0x00               ;Bits 23-16 of Base
   db 0x9A               ;Access Byte
   db 0xCF               ;Flags & Bits 19-16 of Limit
   db 0x00               ;Bits 31-24 of Base

   db 0xFF               ;(0010: Data Segment Descriptor:) Bits 07-00 of Limit
   db 0xFF               ;Bits 15-08 of Limit
   db 0x00               ;Bits 07-00 of Base
   db 0x00               ;Bits 15-08 of Base
   db 0x00               ;Bits 23-16 of Base
   db 0x92               ;Access Byte
   db 0xCF               ;Flags & Bits 19-16 of Limit
   db 0x00               ;Bits 31-24 of Base
GDT_END:
FlashBurn

Re:PMode mem moving doesn´t work

Post by FlashBurn »

I thank you all for your help! I have the problem now. It was the ecx register, because I was writing the number of the moves in the cx register!
Adrian

Re:PMode mem moving doesn´t work

Post by Adrian »

It would be wise to test, if A20 is enabled. In real mode: if it isn't, byte 0xFFFF:0x10 is the same as 0:0. In protected mode, byte 0x100000 (six zeros) is the same as 0.

Don't know how to put it in asm, I think pascal will do.

Code: Select all

if (mem[0xffff:0x10) <> mem[0:0]) then
 begin
  is_A20_enabled:=true;
  exit;
 end;
inc(mem[0xffff:0x10]);
if (mem[0xffff:0x10) <> mem[0:0]) then
 begin
  is_A20_enabled:=true;
  exit;
 end;
dec(mem[0xffff:0x10]);
Post Reply