dukedevon wrote:
Code: Select all
typedef struct page {
unsigned int present : 1; // Page present in memory
unsigned int rw : 1; // Read-only if clear, readwrite if set
unsigned int user : 1; // Supervisor level only if clear
unsigned int accessed : 1; // Has the page been accessed since last refresh?
unsigned int dirty : 1; // Has the page been written to since last refresh?
unsigned int unused : 7; // Amalgamation of unused and reserved bits
unsigned int frame : 20; // Frame address (shifted right 12 bits)
} page_t;
Curious. Are you sure the bit fields struct page are honestly mapped and all the sizes are right?
I've never seen things that low made in HLL, might be worth chacking if something like struct padding or packing got in the way. try using Bochs I/O debugger to look at what is being constructed at the address you give into cr3. (If you don't know how, learning that is a must).
dukedevon wrote:
Code: Select all
typedef struct page_table {
page_t pages[1024];
} page_table_t;
typedef struct page_directory {
page_table_t *tables[1024];
unsigned int tablesPhysical[1024];
unsigned int physicalAddr;
} page_directory_t;
struct page_directory looks like you're doing something quite wrong, if a pointer to it is what goes to cr3.
cr3 should point on an array of 1024 page directory descriptors, similar and slightly different from struct page, each of which points to some page table.
Then, i think the cr3 address should be page-aligned. If all else fails, try putting page directory on a $1000-aligned address.
dukedevon wrote:I must admit that I'm still missing a decent overview of the whole paging thing. Up until now, learning by doing did suffice. What actually should be in there?
The wiki here seems descriptive enough:
http://wiki.osdev.org/Paging