简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM