Page 1 of 1

cannot address more than 1 mb

Posted: Sat Oct 25, 2008 1:40 am
by osmosys
first of all to begin this is my code that enables A20.

Code: Select all

/* to enable the A20 address line inorder to address more than 1MB of memory */
        call    empty_8042
        movb    $0xd1,%al
        out     %al,$0x64
        call    empty_8042
        movb    $0xdf,%al
        out     %al,$0x60
        call    empty_8042
	jmp	A20ENABLED


/* this function repeatedly checks the keyboard controller 8042 */
empty_8042:
	.word	0x00eb,0x00eb
        in      $0x64,%al
        test    $0x2,%al
        jnz     empty_8042
        ret
the qemu shows that A20 has been enabled.
now this is my GDT

Code: Select all

gdtstructure:
	.2byte	0x27		/* limit of the gdt */
	.4byte	gdtstart	/* base address of gdt */

gdtstart:

	/* null descriptor to ensure that no segment registers get loaded with value 0 */
	/* causes "GENERAL PROTECTION FAULT" if we try to access this gdt entry */
	.4byte	0
	.4byte	0

	/* code segment for our bootloader */
	.2byte	0xFFFF, 0
	.byte	0, 0x9A, 0x4F, 0

	/* data segment for our bootloader */
	.2byte	0xFFFF, 0
	.byte	0, 0x92, 0x4F, 0	

	/* code segment for our kernel */
	.2byte	0xFFFF, 0000
	.byte	10, 0x9A, 0x4F, 0

	/* data segment for our kernel */
	.2byte	0xFFFF, 0
	.byte	10, 0x92, 0x4F, 0

but i cannot access the memory in the fifth entry of GDT.this what i was trying to do.i didn't enable paging.

Code: Select all

   mov $0x20,%eax
     mov %ds,%ebx
    mov %eax,%ds
    movb $'A',0x8000
    movb 0x8000,%al
    movb %al,0xb8000
    movb $0x1e,0xb8001
mov %ebx,%ds

when i tried to print the character that i had written, i am not getting the result.

is the problem because A20 was not enabled properly.
should i need to do anything more

Re: cannot address more than 1 mb

Posted: Sat Oct 25, 2008 4:47 am
by egos
The last two descriptors contain segment base 0xA0000. Therefore to write the character to the address 0xB8000 you must use the displacement 0x18000 (0xB8000=0xA0000+0x18000).

Re: cannot address more than 1 mb

Posted: Sat Oct 25, 2008 11:14 am
by osmosys
thanks friend...actually i meant base address as 0x100000...i completely forgot that "0x" that made it read as hexadecimal..sorry everyone..really a stupid one..

Re: cannot address more than 1 mb

Posted: Sun Oct 26, 2008 4:31 am
by codemastersnake
osmosys wrote:thanks friend...actually i meant base address as 0x100000...i completely forgot that "0x" that made it read as hexadecimal..sorry everyone..really a stupid one..
no question is stupid untill it has an answer :)

Re: cannot address more than 1 mb

Posted: Mon Oct 27, 2008 4:26 am
by Combuster
mov $0x20,%eax
mov %ds,%ebx
Where is this being executed? real mode, unreal mode, protected mode, long mode? what is the code size at that point?

Re: cannot address more than 1 mb

Posted: Mon Oct 27, 2008 8:10 pm
by PatrickV
It could be that you not have setout your protected mode right. You know 32 bit. That what could be the problem