I want to implement 32-bit 4Gb Flat Memory mapping for an application, for this purpose I have to get and update Data Segment Descriptor and Code Segment Descriptors. By using assembly command "sgdt" i can get Global Descriptor Table but I am not sure if its CS or DS or any other descriptor. It would be really appreciated if some one can help me deal with this confusion.
I am relying on GRUB to set GDT that's why i don't know the exact location where it put all the segment descriptors. By viewing the GDT table entries I can see 5 same Code Segment Entries and 6 Same Data Segment entries, with base address of each entry set to '0' and limit of each set to '0xfffff'. Can you please tell me reason for these duplicate entries? And from these viewing, can you kindly confirm that Flat Memory mode is already being set by GRUB?
mov eax, cs
and index the table of GDT-entry structs. wiki.osdev.org/Global_Descriptor_Table. You're supposed to know what you put in the GDT, if you're writing your own OS. If you're on Linux, there's amodify_ldt
system call to ask the OS to create new GDT entries for you. What are you doing where you don't already have a 32-bit flat memory model? – Peter Cordes0xfffff
times 4k is 4GiB, and it does seem likely that GRUB would set up a flat memory model. That's what everyone wants. – Peter Cordeslgdt
– Michael Petch