Set Present Bit in Page Fault Exception Handler

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
wiseguyowj
Posts: 2
Joined: Fri Aug 19, 2011 4:49 am

Set Present Bit in Page Fault Exception Handler

Post by wiseguyowj »

Hi everyone,

I read a post from "Paging - OSDev Wiki" website here.

Right now, I have an assignment, which is to write a Page Fault Exception Handler. The Page Fault is caused by the present bit in the Page Table Entry is not set.

I'm stuck in changing the Page Table Entry present bit from 0 to 1. From the hints given, "You'll need to map some physical memory to the page table, set the present bit and then iretd to continue processing"

"When the CPU fires a page-not-present exception the CR2 register is populated with the linear address that caused the exception. The upper 10 bits specify the page directory entry (PDE) and the middle 10 bits specify the page table entry (PTE). First check the PDE and see if it's present bit is set, if not setup a page table and point the PDE to the base address of the page table, set the present bit and iretd. If the PDE is present then the present bit of the PTE will be cleared. You'll need to map some physical memory to the page table, set the present bit and then iretd to continue processing."

How Can I map some physical memory to the page table ??

Please Advice :)

Regards
WJ
wiseguyowj
Posts: 2
Joined: Fri Aug 19, 2011 4:49 am

Re: Set Present Bit in Page Fault Exception Handler

Post by wiseguyowj »

If i code in assembly language ,

for an example ..

The Page Table Entry to handle theaddress 0x890000 is 0x890066 and this indicates that the Present bit does not set.
How can I change the value to 0x890067 so that the present bit is set in my page fault exception handler and then iret to continue processing ?

My Page Table Base Pointer, the CR3 register is set to 0x6000.

Please advice :)
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: Set Present Bit in Page Fault Exception Handler

Post by Owen »

I'm sorry, but
  1. This is an assignment. The intention of most assignments is that you do the work yourself
  2. We will point you in the right direction (And Berkus has just done so), but do no more
  3. Even if this wasn't an assignment, we would be unlikely to point you further.
  4. The questions you are asking are predominantly basic programming, with a small portion of OS development specific content. As Berkus has just given you a pseudo-code version of the OS development portion, the remainder of the task reduces to basic programming. We do not teach basic programming as a matter of policy which keeps this community sustainable.
One presumes that someone on an OS development course should have been given all the information they need or pointers as to how to get said information.
Post Reply