In Kern/pmap. C, the following code will be added. You must know that boot_alloc will only allocate linear addresses, and page_alloc will be used to build the paging between virtual pages and physical pages.
//////////////////////////////////////// //////////////////////////////
// Create initial page Directory.
Kern_pgdir = (pde_t *) boot_alloc (pgsize );
Memset (kern_pgdir, 0, pgsize );
Here is a question: memset only accepts virtual addresses. Here, the kern_pgdir allocated by boot_alloc is a linear address. "No physical ing is established ", how can we use memset to fill all the data in the address indicated by kern_pgdir Out Of The pgsize space with 0.
Double quotation marks have already been added to the above words. Hey hey, it indicates this is an illusion, or I do not understand it thoroughly. here, I would like to thank Eric eshyong and the essential friends on C & Linux who have discussed the issue with me.
In the code above, the page is still enabled, but no page ing has been created. this is because the author of the Jos kernel manually and statically completed some memory ing, and this part of memory is the first 4 m of the physical memory (0x400000)
In Kern/entrypgdir. c
Note that [m) [kernbase, kernbase + 4 m) of the virtual address is mapped to the same physical address range [m)
The so-called static ing is manual... the address pages are allocated as follows ....
Revisit the page table setup in Kern/entry. S and Kern/entrypgdir. c. immediately after we turn on paging, EIP is still a low number (a little over 1 MB ). at what point do we transition to running at an EIP above kernbase? What
Makes it possible for us to continue executing at a low EIP between when we enable paging and when we begin running at an EIP above kernbase? Why is this transition necessary?
This is equivalent to answering this question. When paging is enabled just now (Cr0 in entry. s)
# Turn on paging.movl%cr0, %eaxorl$(CR0_PE|CR0_PG|CR0_WP), %eaxmovl%eax, %cr0
Then, the EIP instruction register points to the low space of the address (a little more than 1 m)
The JMP code changes the address space and the paging mechanism starts to work.
Now that the paging function is enabled, you should map the High-address kernbase to the physical address. We have done it before. Here we will set the virtual address [m) [kernbase, kernbase + 4 m) The two ranges are mapped to the same physical address range [m). The purpose is not to make the instruction addressing affected by address space changes.
(This code is important for me to give it over and over again)
Back to our original question
//////////////////////////////////////// //////////////////////////////
// Create initial page Directory.
Kern_pgdir = (pde_t *) boot_alloc (pgsize );
Memset (kern_pgdir, 0, pgsize );
Here is a question: memset only accepts virtual addresses. Here, the kern_pgdir allocated by boot_alloc is a linear address. "No physical ing is established ", how can we use memset to fill all the data in the address indicated by kern_pgdir Out Of The pgsize space with 0.
In this step, boot_alloc is indeed the applied linear address, but note that! These addresses have long been statically mapped. In this case, kern_pgdir gets a linear address, but it does not need page_alloc to dynamically allocate the actual memory, because it has been allocated before.
The parameters accepted by memset are also linear (virtual ).
October 2014, before miaoyin Temple
Thoughts on the physical address ing problem before Jos does not page