page fault 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
mr. x

page fault handler

Post by mr. x »

What shall I do to prevent my page fault handler to not start recursing? (When setting the present bit)
mr. x

Re:page fault handler

Post by mr. x »

I'm getting page faults when I try to read from memory, even when I haven't enabled paging.
The address I'm trying to read is 0x9C0000.
When I try to read 0x200000 it crashes without a page fault.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:page fault handler

Post by Pype.Clicker »

well, one possible thing is to have something like

Code: Select all

pf_handler() {
    static int nested_pagefault=0;
    if (nested_pagefault) panic("Cannot handle page fault ...");
    nested_pagefault++;

    do_the_job();

    nested_pagefault--;
}
if a 'static' nested_pagefault doesn't suit your needs, you may try a thread_local one (but that supposes your OS has thread_local storage already)

if the PG bit of CR0 is cleared, then you shouldn't be receiving page faults (exception 0E). Are you sure your interrupt system is reliable ?
mr. x

Re:page fault handler

Post by mr. x »

Well, floppy and keyboard are using interrupts and both are working correctly.
mr. x

Re:page fault handler

Post by mr. x »

btw, here's my linking script:

Code: Select all

OUTPUT_FORMAT("binary")
ENTRY(_start)
OUTPUT("kernel.bin")

INPUT(kinit.o)
INPUT(kints.o)
INPUT(ints.o)
INPUT(driver_keyboard.o)
INPUT(driver_floppy.o)
INPUT(kernel.o)
INPUT(app_console.o)
INPUT(io.o)
INPUT(pic.o)
INPUT(idt.o)
INPUT(panic.o)
INPUT(doprintf.o)
INPUT(queue.o)
INPUT(string.o)
INPUT(memory.o)
INPUT(math.o)
INPUT(dma.o)
INPUT(driver_pefs.o)
INPUT(timer.o)
INPUT(mem_manager.o)

SECTIONS
{
  .text  0xFF800000 : {
    *(.text)
  }
  .data  : {
    *(.data)
  }
  .bss  :
  {                
    *(.bss)
  }
}
Pager

Re:page fault handler

Post by Pager »

Is it the 0xFFC'th entry or the 0xFFF'th entry which is used to point to the PageDirectory itself when we map the PageTables into the current address space? and can anyone clearly explain how this mapping the PageTables into the current address space works (in simple english).
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:page fault handler

Post by Pype.Clicker »

<timbot mode engaged>
Tim already did in one of its memory management tutorials on Bona Fide, iirc
<timbot mode disabled>
Post Reply