Load my kernel in a direction which can be divided by 4096
Not strictly necessary. Only saves you a few computations and bytes.
Add padding to all kernel with Align(4096) in the linker file in each section
not necessary either. The only real reason to do this is that pages start on a 4096-byte boundary and you might waste a page if the kernel doesn't start on a boundary, or you want different permissions for code or data parts of the kernel.
Make a symbol at the end so I know where can I start allocating memory
that's for memory management. It's not necessarily part of initializing paging itself, but something you can use in the process. It's handy to have nevertheless as it allows you to dynamically determine how much space to reserve for the kernel
Alloc page_directory and page_table aligned at 4K
if you plan on using 4M pages, you don't necessarily need page tables. Conversely, you might want more than one page table to start with.
Set all kernel pages to be read and writeable by the kernel but not user
See the note above, you may want to map parts (code, readonly data) as not-writable.
Make kernel virtual address the same linear address
The main reason for this is that when paging is enabled the code that is currently being executed doesn't get "changed". For higher-half kernels the virtual address does not match the
physical address.
Set video framebuffer page/s read and write only by kernel
Handy to have, but not strictly necessary either. My kernel for one has a different way of doing things.
Add a Page fault handler at interrupt 14
You haven't got a default handler yet?
Send the linear address of page_directory to CR3
it seems to me that you're confusing virtual, linear and physical addresses:
Code: Select all
virtual address -----------> linear address ------------> physical address
segmentation paging
Set on the paging bit in CR0
Obviously