Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Physical memory manager #5

Open
arthurmco opened this issue Jan 17, 2018 · 7 comments
Open

Physical memory manager #5

arthurmco opened this issue Jan 17, 2018 · 7 comments

Comments

@arthurmco
Copy link
Owner

arthurmco commented Jan 17, 2018

Design and create a physical memory manager, so we know how much memory we have, and what blocks are occupied

This will be the base for the virtual memory manager, and for virtual memory allocations, and paging

This might help with directions

@KingAkeem
Copy link

I'd like to help with this issue. I'm learning about kernels and I really would like to help design one.

@arthurmco
Copy link
Owner Author

Nice!

What are your ideas for this memory manager?

@KingAkeem
Copy link

I'm honestly not sure, would you be able to help me with designing it? I understand the theory behind memory management but I've yet to implement it. Do you have any suggestions?

@arthurmco
Copy link
Owner Author

I was thinking about starting with a simple bitmap-based physical memory manager, just to get started, and improving it over time.

In it, each bit would represent a physical page of memory, 4kb.

I am still reading about it, but I think it's OK for a start...

@KingAkeem
Copy link

So it's going to be a heap of memory with each block pointing to 4KB of memory?

@arthurmco
Copy link
Owner Author

No, more like this: http://wiki.osdev.org/Page_Frame_Allocation#Bitmap

Just a simple array for the bitmap. A heap would consume too much memory.

@arthurmco
Copy link
Owner Author

arthurmco commented Jan 21, 2018

I started doing the physical memory manager in a68ca7f.

It does basic things, but can be improved.

I did some TODO items in the PMM.cpp file, to be solved. I will replicate them here:

  • Use allocation flags, for each one of the memory areas
    This envolves setting a flag for each area that belongs to a determined group, e.g, memory < 16 MB might be used by some old devices, like the floppy or old hardware, that can't use a bigger physical address

  • The CheckPages() method.
    It's missing. We need a function that checks if we can allocate a big area. This is intended to be used by the VMM, that needs to allocate a certain quantity of memory, but it doesn't need to be physically contiguous. So, it can allocate, for example, 2 uncontiguous blocks of 8 pages if a single, contiguous block of 16 pages can't be allocated at once.

  • Detect overlapping zones, alert the user and do something sane
    Some real hardware overlap memory zones, like an old computer I have. Maybe detect what types they are and do something.

  • Merge contiguous zones with the same type
    This might be easy (I don't know, I didn't do it yet). Involves joining them if one ends where other starts and they have the same type.

arthurmco added a commit that referenced this issue Jan 21, 2018
This solves the allocation flags problem mentioned on #5, since the
type is controlled by a flag.

This differentiation happens on allocation, where the PMM determines
what address ranges are eligible for being allocatable in that moment,
and choosing the best among them.

Also, don't let the dude allocate pages from MMIO addresses, just map.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants