Page 1 of 1

paging functionality

Posted: Sat Dec 15, 2007 12:46 am
by blound
I was working on my paging code and since this is my first OS i want to make sure I get enough functionality in so I do not have to keep coming back in later to add things.

I already have the physical memory manager working and it has methods for allocating contiguous pages or just a single page ( and freeing them ) so i believe that is done..

here is the main functions that are things outside the core paging might use (meaning i am not listing every helper function/macro)

Code: Select all

void allocatePageTable(uint pdir, uint virt, uint flags)

void MapPhysicalAddress(uint pdir, uint vaddr, uint paddr, uint flags)

void invlpg(uint addr)

/* allocates an address space for a new task   
    starting with 'pages' amount of pages
*/
void allocAddressSpace(int pages)
When it comes time to handle multitasking/ring 3 tasks will I need anything more flexible?

also I had a question about allocAddressSpace because I am not quite sure of the flow for it. I know that it will have to allocate at least one page to be the page directory for the new task, then to use the last entry trick map itself into the last slot, but what about for the rest of the entries? If I am going to have the kernels pages mapped into every task is this the place to do it? I thought it might be a good place to set the the permissions for the kernel regions ( I have my kernel mapped to 0xc0000000 and will let it expand to higher addresses) but I do not know if that is the best function to put it in.

and for clean design should MapPhysicalAddress be the only thing to ever call allocatePageTable? I could not think of any other function that would need a page table brought in, and once kmalloc is implemented all the other parts of the kernel that need memory should rely on that anyway

I realize there was alot of questions in here but I wanted to have everything clear before I finish the code and move on to multitasking.

Posted: Sat Dec 15, 2007 8:12 pm
by blound
I guess this is not an official "bump" since its only been a short time since I posted but I says alot of people have read the post

is it too long/filled with too many questions? Anything I can do to entice some discussion?

Posted: Sat Dec 15, 2007 8:58 pm
by piranha
A lot of time posts don't get answered for a while.

-JL

Posted: Sun Dec 16, 2007 4:20 am
by JamesM
Hi, Sorry I was drunk on rum when your question went up!

You will need a "cloneAddressSpace" function for when implementing "fork()" et al.
If I am going to have the kernels pages mapped into every task is this the place to do it? I thought it might be a good place to set the the permissions for the kernel regions ( I have my kernel mapped to 0xc0000000 and will let it expand to higher addresses) but I do not know if that is the best function to put it in.
Putting that functionality in the function that creates an address space seems like a good idea to me.
and for clean design should MapPhysicalAddress be the only thing to ever call allocatePageTable?
Yes.