cannot address more than 1 mb

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.
Post Reply
osmosys
Posts: 14
Joined: Sun Oct 05, 2008 4:33 am

cannot address more than 1 mb

Post 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
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: cannot address more than 1 mb

Post 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).
If you have seen bad English in my words, tell me what's wrong, please.
osmosys
Posts: 14
Joined: Sun Oct 05, 2008 4:33 am

Re: cannot address more than 1 mb

Post 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..
User avatar
codemastersnake
Member
Member
Posts: 148
Joined: Sun Nov 07, 2004 12:00 am
Contact:

Re: cannot address more than 1 mb

Post 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 :)
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: cannot address more than 1 mb

Post 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?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
PatrickV
Member
Member
Posts: 151
Joined: Sun Jul 06, 2008 7:50 pm
Location: New Zealand
Contact:

Re: cannot address more than 1 mb

Post by PatrickV »

It could be that you not have setout your protected mode right. You know 32 bit. That what could be the problem
Post Reply