OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 7:30 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: OS program execution in depth.
PostPosted: Fri Sep 04, 2015 10:41 am 
Offline
Member
Member

Joined: Mon Apr 09, 2007 12:10 pm
Posts: 775
Location: London, UK
Segment registers (including CS) have both a visible and a hidden part. The visible part is what you write to/read from. The hidden part contains the base address of the segment, its limit and privilege levels. In real mode when you write to the visible part, it fills the hidden part with base = value * 0x10, limit = 0xffff. In protected mode, it gets these values from the GDT/LDT. This has the side effect of meaning the hidden parts are not updated if you change the GDT without also reloading the segment register.

When a (>= 80386) cpu starts, it sets the various parts of CS specially - the visible part reads 0xf000, but the base address in the hidden part is 0xffff0000. This is not something you can do programmatically from within real mode, and the next time CS is loaded then it will use the normal real mode rules. If you dump the value of CS from within bochs however, you will get the visible part, which is 0xf0000.

Regards,
John.

_________________
Tysos | rpi-boot


Top
 Profile  
 
 Post subject: Re: OS program execution in depth.
PostPosted: Fri Sep 04, 2015 1:46 pm 
Offline
Member
Member
User avatar

Joined: Fri Jan 16, 2009 8:34 pm
Posts: 284
Location: Louisiana, USA
jnc100 wrote:
Segment registers (including CS) have both a visible and a hidden part. The visible part is what you write to/read from. The hidden part contains the base address of the segment, its limit and privilege levels. In real mode when you write to the visible part, it fills the hidden part with base = value * 0x10, limit = 0xffff. In protected mode, it gets these values from the GDT/LDT. This has the side effect of meaning the hidden parts are not updated if you change the GDT without also reloading the segment register.

When a (>= 80386) cpu starts, it sets the various parts of CS specially - the visible part reads 0xf000, but the base address in the hidden part is 0xffff0000. This is not something you can do programmatically from within real mode, and the next time CS is loaded then it will use the normal real mode rules. If you dump the value of CS from within bochs however, you will get the visible part, which is 0xf0000.

Regards,
John.


Ok, that makes sense - guess I should read the manual more (way too long to read it all, I only read the parts I need when I need them...)

Thanks for the detailed explanation.

@OP: sorry to derail your topic, I couldn't help myself :) (but just maybe it was on topic just enough to be helpful to you and others :roll: )

_________________
BOS Source Thanks to GitHub
BOS Expanded Commentary
Both under active development!
Sortie wrote:
  • Don't play the role of an operating systems developer, be one.
  • Be truly afraid of undefined [behavior].
  • Your operating system should be itself, not fight what it is.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 27 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group