Page 1 of 1

Paging, Again :(

Posted: Tue Jul 08, 2008 3:06 pm
by finarfin
I'm asking again help about paging.

At this time, my OS, boot and load correctly a page Dir and page table, so i'm in paged mode.
I'm blocked here, because i don't know how to proceed.

Now what things i have to program next?

It's strange, globally i know what i have to program, a memory allocator, several utility functions for page managing, function for copy kernle into a new pageDir/pageTable but i'm still confused.

In other words, after creation of the first pageDir, pageTable, function that enables it, what are the next things to do.
(i have already enabled paging)

I have to start thinking at a malloc function? Or it is too early.
I have to write first page fault function? Or i need first to create an allocator?

Exactly how a malloc function work? It require an address to paging memory manager, and obtain it, after when i try to access that location a page_fault occur, and i have to map that address (requiring a page to physical memory manager)?
It is correct?

I read several tutorials (also JamesM tutorial), but i'm still confused.
In jamesM tutorial for example, he use a variable placement_address, but what is it start address? The variable end (declared in ld script file) which start value is supposed to have?

I hope yuo may help me.

P.S Once again, sorry for my english (i restart to study it :D )

Re: Paging, Again :(

Posted: Tue Jul 08, 2008 3:48 pm
by Omega
End should be the offset where your loader stopped and your kernel starts. Check out James' tutorial again and read on to the Heap and VFS, I think he does more with paging in those. Your next step would be to create the Heap as denoted by James' guide. Good Luck.

Re: Paging, Again :(

Posted: Tue Jul 08, 2008 5:34 pm
by Adek336
You might want to try write an interface, first, that is writing down the signatures of the functions you'd use, like for example

Code: Select all

you need heap
void *kmalloc(size_t s);
void kfree(void *ptr);

you'd like to manage your paging structures, to have heap;
addr_t alloc_page(); //to get a physical address of a free page; you may want to have some sort of collection of free physical pages
void disalloc_page(addr_t page);   //to return a physical page back to the pool

uint32 pte_val(addr_t logi); //a function to return the PTE entry corresponding to the logical address [logi]
void pte_map(addr_t logi, uint32 pte); // a function to set the PTE entry of a logical address; do you want this function to flush TLB? or maybe another function should flush so that you may use pte_map() in a for-loop for bulk amounts of changes

....   //more functions you thing of during design :)
this is an example interface you might want to do it another way; you're free and encouraged to experiment in your project :mrgreen:

Re: Paging, Again :(

Posted: Mon Jul 14, 2008 3:01 pm
by finarfin
Ok now other questions came, i'm reading JamesM tutorials, but there is a thing that is not clear,
the variable placement_address is the same for every page_dir, or not?

In my interpretation, every page dir, must have his own placement_address (if we have a multitasking environment, and every task with is own address space).

Is that corret? If not, why?

Please help me, i'm very confused :shock: