I'm using these structs.
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 pwt : 1;
u32int pcd : 1;
u32int accessed : 1; // Has the page been accessed since last refresh?
u32int dirty : 1; // Has the page been written to since last refresh?
u32int pat : 1;
u32int global : 1;
u32int unused : 3;
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
{
page_table_t *tables[1024];
} page_directory_t;
I'm using kmalloc_ap from james molloy kernel tuts.
I don't want to use his version paging though, I would like to do the
recursive directory. I need help setting this up.
in my init_paging:
kernel_dir = kmalloc_a(sizeof(page_directory_t));
clear(kernel_dir);
//Is this how I would set the last entry to point to itself?
kernel_dir->tables[1023] = kernel_dir;
then I go on mapping pages using james's code and when
I get to setting cr3 do I use the kernel_dir pointer?
cr3_write(kernel_dir);
then
cr0 |= X86_CR0_PG;
I also need to see how to set a page dir entry and page table entry.
I have kmalloc_ap(size, &phys);
returns I guess a va address and phys containes the physical address.
How do I set a pde entry?
kernel_dir->tables[?] = ???
I think I have the pte figured out.
Thank You
Bo Hunter
x86 paging using structures
-
- Posts: 9
- Joined: Tue Sep 14, 2010 5:13 pm
Re: x86 paging using structures
Yea, I figured that much, I just wonder from my kmalloc_ap function that allocates
aligned memory and returns the physical address in a out parameter, how do I
create a page table to store in the
kernel_dir->tables[?] = the pointer returned from kmalloc_ap or the physical address
kernel_dir->tables[?] = physical | 0x7;
Thank You
Bo Hunter
aligned memory and returns the physical address in a out parameter, how do I
create a page table to store in the
kernel_dir->tables[?] = the pointer returned from kmalloc_ap or the physical address
kernel_dir->tables[?] = physical | 0x7;
Thank You
Bo Hunter