Paging question

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.
Post Reply
User avatar
samoz
Member
Member
Posts: 59
Joined: Sun Jun 01, 2008 1:16 pm

Paging question

Post by samoz »

Hi guys, I'm working on paging and using JamesM's tutorial and Intel manuals for reference.

I was reading over James' tutorial and I have a question about it. Here is James' code for a page:

Code: Select all

typedef struct page
{
   u32int present    : 1;   // Page present in memory
   u32int rw         : 1;   // Read-only if clear, readwrite if set
   u32int user       : 1;   // Supervisor level only if clear
   u32int accessed   : 1;   // Has the page been accessed since last refresh?
   u32int dirty      : 1;   // Has the page been written to since last refresh?
   u32int unused     : 7;   // Amalgamation of unused and reserved bits
   u32int frame      : 20;  // Frame address (shifted right 12 bits)
} page_t;
The Intel manual defines a write-through and a cache disabled bit between the user and accessed bit in the above code. I see that these bits are moved into the unused bit field, but won't this cause the bits to be ordered incorrectly? Can anyone give me some pointers on this? Because it looks like there is something wrong with grouping 7 bits together as unused to me.

Thanks!
Hexciting: An open source hex editor for the command line.
https://sourceforge.net/projects/hexciting/
Hangin10
Member
Member
Posts: 162
Joined: Wed Feb 27, 2008 12:40 am

Re: Paging question

Post by Hangin10 »

When in doubt, use the manual. :)
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Paging question

Post by Combuster »

Yes, that looks wrong to me as well :roll:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
tarrox
Posts: 19
Joined: Wed Dec 31, 2008 8:40 am

Re: Paging question

Post by tarrox »

Jeah it is kind of false. If you want here is my corrected version:

Code: Select all

	typedef struct
	{
		u32int present		: 1;	//
		u32int rw		: 1;	//read/write
		u32int user		: 1;	//1 = User, 0 = Supervisor
		u32int write_through: 1;	//
		u32int cache		: 1;	//
		u32int accessd		: 1;	//
		u32int dirty		: 1;	//Reserved
		u32int attributes	: 1;	//Size of the page 0 = 4096
		u32int global		: 1;	//Ignore
		u32int avail		: 3;	//for the programmer
		u32int frame		: 20;	//
	} page_t;
Post Reply