2

Whenever I try to write a pixel to the LFB of VESA mode, I get a page fault where the page is present and has been read. My paging implementation is from James Molloy's OS series. I've tried identity mapping the LFB as follows:

for (unsigned int i = 0xFD000000; i < 0xFE000000; i += 0x1000) {
    page_t* pg = get_page(i, 1, kernel_directory);
    alloc_page(pg, 1, 1);
}

These are the prototypes for those functions:

page_t* get_page(uint32_t address, int make, page_directory_t* dir);
void alloc_frame(page_t* page, int is_kernel, int is_writeable);

When paging is disabled, I'm able to write pixels to the LFB without any issues. Am I identity mapping the LFB incorrectly? Is there something else I need to do to identity map it correctly? Any suggestions?

Razor
  • 1,778
  • 4
  • 19
  • 36
Phillip
  • 1,205
  • 3
  • 15
  • 22

1 Answers1

0

When paging is disabled, your accessing address is the physical address. However, when paging is enabled, your accessing address is virtual, so you should first map the address region you will access to a phsyical address region. This can be implemented by the remap_pfn_range or nopage function, as introduced here.

Akr
  • 179
  • 2
  • 4
  • 13
  • 1
    The original poster isn't using Linux, they are creating their own OS – Michael Petch Jul 13 '17 at 14:56
  • Paging is a mechanism of the hardware (CPU and MMU), so it is no matter what OS you are writing. You must abide the paging rules the hardware has defined when you turn on its paging mechanism. – Akr Jul 14 '17 at 00:50
  • Yes, but Linux routines won't help him with the code from [James Molloy's OS series](http://www.jamesmolloy.co.uk/tutorial_html/) – Michael Petch Jul 14 '17 at 00:52
  • Well, no. But I think it is easier for one to learn implementing his own mapping function from the Linux implementations. – Akr Jul 14 '17 at 02:57