Paging help

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
YDeeps1
Member
Member
Posts: 69
Joined: Tue Aug 31, 2021 7:25 am
Discord: speedy.dev
Contact:

Paging help

Post by YDeeps1 »

I am quite new to paging and I am quite confused by it.
Mainly I am wondering what the first steps should be to enabling paging - what should I do?
How should I handle pages during context switches?
Why do both the page directory and entry want a 12 bit address? What are the differences?
I am getting weird undefined behavior after enabling paging and so I assume I need to perform some kind of kernel mapping - how do I make it map to a physical address by default?
Thanks!
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Paging help

Post by iansjack »

Although written with Rust in mind, rather than C, this article https://os.phil-opp.com/paging-introduction/ gives a good introduction to paging and how it is implemented on x86 processors.

As to your specific question about context switches, each process will have its own page table; when switching processes you update cr3 to point to the appropriate table.
Post Reply