Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set up a new stack segment for programs in x86 to separate from my kernel?

I am developing a 32 bit OS and I need to be able to set up NEW data segments/stack segments for programs. However I can not find ANY good information about how to use these segment registers in protected mode. I really need to be able to set up a new stack segment so my programs are not sharing the same stack as the kernel.

like image 918
user1454902 Avatar asked Dec 08 '25 06:12

user1454902


1 Answers

In x86 protected mode the segment registers points to GDT selectors.

1 . So we need to setup the proper selectors for each segments expecially for cs, ds, ss before far jump to protected mode. 2 . Selectors are 8byte length, which defines the base, limit and access permissions. Please see the below link for your reference http://en.wikibooks.org/wiki/X86_Assembly/Global_Descriptor_Table, http://www.jamesmolloy.co.uk/tutorial_html/4.-The%20GDT%20and%20IDT.html, http://en.wikipedia.org/wiki/Global_Descriptor_Table. 3 . If you need more on this please reply me, i can show you my simple OS code which sets the proper the GDT and enter into protected mode.

like image 166
Mohanraj Avatar answered Dec 10 '25 06:12

Mohanraj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!