I'm confused about paging implementations
Posted: Fri Dec 25, 2009 12:46 pm
Hi,
I am confused about paging implementations. It appears as there are two different ways to use paging. Which one is easier to implement. The wiki has a setup for paging which is in this article: Paging
these are the structures that I use that the wiki says to use
These are the structs from James Molloy's kernel tutorial:
Which paging setup should I use?
I am confused about paging implementations. It appears as there are two different ways to use paging. Which one is easier to implement. The wiki has a setup for paging which is in this article: Paging
these are the structures that I use that the wiki says to use
Code: Select all
typedef struct
{
u32int present : 1;
u32int rw : 1; // read-write
u32int user : 1;
u32int writethrough : 1;
u32int cachedisable : 1;
u32int accessed : 1;
u32int alwayszero : 1;
u32int size : 1; // 0 = 4-kB, 1 = 4-mB
u32int ignored : 1;
u32int available : 3;
u32int address : 20;
} page_dirent_t;
Code: Select all
typedef struct
{
u32int present : 1;
u32int rw : 1; // read-write
u32int user : 1;
u32int writethrough : 1;
u32int cachedisable : 1;
u32int accessed : 1;
u32int dirty : 1;
u32int alwayszero : 1;
u32int global : 1;
u32int available : 3;
u32int address : 20;
} page_t;
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;
typedef struct page_table
{
page_t pages[1024];
} page_table_t;
typedef struct page_directory
{
/**
Array of pointers to pagetables.
**/
page_table_t *tables[1024];
/**
Array of pointers to the pagetables above, but gives their *physical*
location, for loading into the CR3 register.
**/
u32int tablesPhysical[1024];
/**
The physical address of tablesPhysical. This comes into play
when we get our kernel heap allocated and the directory
may be in a different location in virtual memory.
**/
u32int physicalAddr;
} page_directory_t;