Re: Memory allocation with pages.
Posted: Sun Oct 05, 2014 12:47 am
Hi,
Also note that this is a relatively common trick used by a lot of people as a temporary thing during boot (e.g. before the kernel has setup the virtual address space properly and mapped/shifted itself to 0xFFFFFFFF80000000); where that temporary "mapping of the first 4 MiB of the physical address space" is removed after.
Cheers,
Brendan
In that case; there's nothing wrong with having pages mapped into the "mapping of the first 4 MiB of the physical address space" and also mapped elsewhere or used as page tables, etc.ExeTwezz wrote:In my kernel the first physical 4 MB are mapped to the first virtual 4 MB. The first 640 KB are in the stack of free physical pages yet (until I will more understand). All the 4 MB are marked as free in the page table.
Also note that this is a relatively common trick used by a lot of people as a temporary thing during boot (e.g. before the kernel has setup the virtual address space properly and mapped/shifted itself to 0xFFFFFFFF80000000); where that temporary "mapping of the first 4 MiB of the physical address space" is removed after.
Normally boot code gets a "memory map" from the firmware and passes it to your kernel; and when initialising the physical memory manager you parse this "memory map" and find any/all "usable RAM" areas from it. Then (for each "usable RAM" area) you break it up into pages; and (for each page in a "usable RAM" area), make sure that you aren't actually using the page (e.g. for kernel, etc), and tell the physical memory manager the page is free/usable RAM.ExeTwezz wrote:And I want free physical pages to be more than 160 (160 * 4096 = 655360 = 640 KB). How can I do that (how to split the memory)?
Cheers,
Brendan