[CLOSED] Memory allocation with pages.

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.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Memory allocation with pages.

Post by Brendan »

Hi,
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.
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.

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.
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)?
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.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
ExeTwezz
Member
Member
Posts: 104
Joined: Sun Sep 21, 2014 7:16 am
Libera.chat IRC: exetwezz

Re: [CLOSED] Memory allocation with pages.

Post by ExeTwezz »

Thank you all ;)
Post Reply