OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Apr 24, 2024 8:21 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Physical Memory Management
PostPosted: Thu Jun 12, 2008 4:09 am 
Offline
Member
Member
User avatar

Joined: Thu Jun 05, 2008 9:23 am
Posts: 46
Location: Austria
Hi

I have spend a day writing a physical memory manager for my kernel using a bitmap to keep track of allocations.

To further tweak what i wrote, i wanted to get some comments from you guru's :)

The implementation does (seems to) work, but i'm unsure if i haven't left some concrete blocks in it slowing me down :) And i'm not sure if all my calculations for addresses/offsets/etc. are correct, so that i may miss some areas of memory while searching for free pages, etc.

i attached both the header and c file, maybe somebody has some time to look at it. if not, maybe the code is good enough, to help others out writing their own physical memory manager....

how i use it:

i call SxPhysMemInit(), then i call SxPhysMemAddRegion for each of the mmap entries with type 1 reported by GRUB.

i maybe have to also mention that i use Microsofts Visual C++ to compile this ;) so maybe gcc will not work out of the box...


Attachments:
File comment: memory manager sources (c/h)
physmem.tar.gz [2.23 KiB]
Downloaded 75 times
Top
 Profile  
 
 Post subject: Re: Physical Memory Management
PostPosted: Sat Jun 21, 2008 8:28 am 
Offline
Member
Member
User avatar

Joined: Sat Jul 07, 2007 7:49 pm
Posts: 131
Hi,

I took a quick look at your code, and i have some comments.

In my design i have a allocpage() and freepage() wich just returns / frees 1 physical page at the time. These functions are in my code 1 line statements. Very easy code. Then i have a vmalloc & vfree on top of that.

My vmalloc and vfree contains a self maintainable linked list of areas in vmem that are allocated, and the routines update the asking process pdir and ptab with the info. All pages are set to non-present so that i dont do a allocpage() befor i get a PF for a request to one of the addresses in the allocated vm region.

I have also a Flag attribute to my malloc to force it to do allocpage() on vmalloc. I have also a few flags for having malloc() do zerofill.

Just want to comment on your use of Vc++ for doing stuff like this. I do the same. For code with liked lists, bit-fippling etc its very good to debug code in Vc++ i use it alot.

Good luck with your coding!

-
Thomas


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 128 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group