GDT and memory

If you are new to OS Development, plan on spending some time here first before going into the other forums.

Moderator:Moderators

Post Reply
bill
Posts:4
Joined:Sun Feb 17, 2008 9:27 pm
GDT and memory

Post by bill » Sun Feb 17, 2008 10:15 pm

First of all hello everybody and great guide mike
:D
Ive been working thru the os dev tutorial but i seem to be kind of stuck. Im not very good at assembly but the real problem is i dont know much about the hardware side of computers. Ive been doing ok up until the protected mode tutorial. Heres a few things i dont really understand...

If i want to make a data descriptor that allows me to access any memory location I make the segment limit as high as i can (65535)(aka 0xFFFF) and make the base adress 0? I understand the base being 0 but what does segment limit mean?

Also, i was looking at this table from tutorial 7..
0x00000000 - 0x000003FF - Real Mode Interrupt Vector
0x00000400 - 0x000004FF - BIOS Data Area
0x00000500 - 0x00007BFF - Unused
0x00007C00 - 0x00007DFF - Our Bootloader
0x00007E00 - 0x0009FFFF - Unused
0x000A0000 - 0x000BFFFF - Video RAM (VRAM) Memory
0x000B0000 - 0x000B7777 - Monochrome Video Memory
0x000B8000 - 0x000BFFFF - Color Video Memory
0x000C0000 - 0x000C7FFF - Video ROM BIOS
0x000C8000 - 0x000EFFFF - BIOS Shadow Area
0x000F0000 - 0x000FFFFF - System BIOS
If im right this corresponds to RAM locations. however if i am able to do math then this table only goes up to 1 Mb. Thats not very much so im not sure whats going on lol? is the rest empty or is it not RAM?


If anyone can answer either of these then thank you :-)

User avatar
Mike
Site Admin
Posts:465
Joined:Sat Oct 20, 2007 7:58 pm
Contact:

Post by Mike » Sun Feb 17, 2008 10:54 pm

I am glad you like the series :)
If i want to make a data descriptor that allows me to access any memory location I make the segment limit as high as i can (65535)(aka 0xFFFF) and make the base adress 0? I understand the base being 0 but what does segment limit mean?
The segment limit is the highest address within the segment that can be addressed.

Remember that protected mode uses the selector:offset addressing mode. When referencing memory, we place the selector (0x8, for example.) into a segment register. the highest offset that the selector can reference is determined by the segment limit field.

The actual limit depends on if the Granularity bit is set. If it is set, the segment limit gets multiplied by 4K. This allows us to access alot more memory through the segment selector.
If im right this corresponds to RAM locations. however if i am able to do math then this table only goes up to 1 Mb. Thats not very much so im not sure whats going on lol? is the rest empty or is it not RAM?
You are correct in that the list only goes up to 1 MB. the reason being is because the memory map below 1 MB are the only addresses guaranteed to be there.

The rest of RAM is undefined. Memory locations can be free of use; mapped or used by hardware devices; or even holes in physical memory. We define what the rest of the memory is used for. For an example, our Kernel is loaded at the 1 MB physical address location.

I hope this helps :)
Lead Programmer for BrokenThorn Entertainment, Co.
Website: http://www.brokenthorn.com
Email: webmaster@brokenthorn.com

bill
Posts:4
Joined:Sun Feb 17, 2008 9:27 pm

Post by bill » Sun Feb 17, 2008 11:27 pm

tyvm that helps alot, will go and keep reading now =p

Post Reply