PAGING, a pain for ever

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: PAGING, a pain for ever

Post by JamesM »

Hi,

As you've obviously got suitable answers from other people I'm going to ignore the last two questions that I didn't get time to answer earlier and focus on the text you linked to.
Example: 1000:1f00 = 10001f00
Unfortunately this isn't correct. Firstly, segment-offset pairs [of this kind] only exist in real mode and you're in pmode. Secondly, a linear address is calculated from a segment:offset pair by shifting the segment selector 4 bits left and adding the offset, giving you 20 bits (1MB) of addressable space (16+4 = 20).
To get a 20 bit address, you take the 32 bit, shift the bits to left, until the “12” last bits are “0”.
That's incorrect too - To get the 20-bit page directory/table index you logically shift a 32-bit address RIGHT by 12 bits, so that the most significant 12 bits are zero. It's important that it's a logical shift and not an algebraic one as the latter will implicitly sign extend for you. In C, avoid this by ensuring you use unsigned values.
6 bit: set this to “1” to make the page usable.
That's incorrect - you don't need to set bit 6. Unfortunately I'm at my girlfriend's house at the moment and don't have a PDF reader to look it up in the manuals to see what that bit exactly is, but it definately is not required to be set.
2 bit: if this is set to “1”, then the user level is “supervisor” if the bit is ”0”, then it is normal user.
The inverse - Set for user-mode access, clear for kernel only.

Your tutorial seems to be lacking any information about actually using the stuff in practice - the "last part", as you put it.

As English is clearly not your native language I decided to avoid my usual pedantic language and ambiguity analysis ;)

Anyway, I hope this helped a little.

Cheers,

James
User avatar
kmtdk
Member
Member
Posts: 263
Joined: Sat May 17, 2008 4:05 am
Location: Cyperspace, Denmark
Contact:

Re: PAGING, a pain for ever

Post by kmtdk »

You are right about, that english is not my native language, but as long as people understand me....
well, it helped much.
About the 6 bit, in the "diagram" it is said: "availble"; does that not mean that it can be used, if is not set ?
But what would you like to add to the "last part" ? (about the last part: an example code, i need to make one working, and since i dont have one...)


Kmtdk
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
Post Reply