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.
I suggest you read the wiki and JamesM's tutorials for more information. They're invaluable sources of information for this kind of stuff.
EDIT: Oh, and the Intel manuals are wonderful too.
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
Yea you gotta read a lot first. That code works, but if you understand paging, then you understand what the whole point of it is and why it is used. 32 bit processors have the ability to access 4gb of memory without paging; paging exists for a whole lot of other reasons. Your code shows us that you know roughly what the definition of a directory and table are, and how to tell the processor to use paging. Also your code will crash the machine as is, because your tables havnt been initialized. Paging is actually real simple, but its not intuitive and can take a while to get your head around it
Hm, the only thing thats actually "wrong" with that code is that page_table_entry contains more then just a frame address. With that it would triple fault immediately do to the currently running code being unpaged. Also, I personally prefer separating page table entries from page directory entries do to them having different purposes and different (although slightly) formats.
Other then that the code looks good so far
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
You won't be able to access the page tables as an array (because the pointer does not only contain the address, but also some flags). You can read more about paging in Intel's software developer manual, Volume 3a, chapter 3.7.6
Visit https://gzalo.com : my web site with electronic circuits, articles, schematics, pcb, calculators, and other things related to electronics.