Memory Management for Dummies??
Memory Management for Dummies??
Okay I have started to read the memory management information on OSdever, and on the wiki here, but I really just need to see a well documented implementation of it in action. I don't need something optimized just something that will show me how it works. I will do optimization and possibly even completely design my own system but first I need to see an example of how everything works. Does anybody know of a good example that I could look at?
Getting back in the game.
-
- Member
- Posts: 368
- Joined: Sun Sep 23, 2007 4:52 am
Well, I don't have any memory management at this point, my kerenl boots loads GDT IDT isrs and irqs 1 and 2. It prints some stuff on the screen and accepts input with a couple semi-console like features. I would assume that I have to manage the physical memory first. I am not really sure though. I learn better through doing then I do from reading.
edit: I would request a high-level language example. I don't think I know ASM well enough to extract what I need from it. but I can figure out any highlevel language even if I don't know it yet.
edit: I would request a high-level language example. I don't think I know ASM well enough to extract what I need from it. but I can figure out any highlevel language even if I don't know it yet.
Getting back in the game.
I was looking at your paging tutorial, you don't define several variables.
kernel_directory
current_directory
placement_address
tables_idx
why are they not defined. you also don't say what files the functions and everything are being placed in. I can't download your source code since I am at work but I would really like to get this running so I can see it working and then I will be able to personalize it and learn from it.
kernel_directory
current_directory
placement_address
tables_idx
why are they not defined. you also don't say what files the functions and everything are being placed in. I can't download your source code since I am at work but I would really like to get this running so I can see it working and then I will be able to personalize it and learn from it.
Getting back in the game.
Hi!
Kernel_directory and current_directory are just globals of type pagedirectory_t. They're defined at the top of the paging.c file. I didn't paste all the globals/#includes etc in - thought people could work it out themselves! I might add them now though...
placement_address is similar: in my code it is defined as
Where end is a constant defined in the linker script. I must have forgotten to add that in - sorry!
tables_idx does not exist: I can't find a reference to that anywhere on the page. The nearest I found was table_idx:
As you can see table_idx there is defined as a local.
Cheers for looking at it, seems there are some omissions on my part! If you'd been able to get the code hopefully it would have all been explained!
Kernel_directory and current_directory are just globals of type pagedirectory_t. They're defined at the top of the paging.c file. I didn't paste all the globals/#includes etc in - thought people could work it out themselves! I might add them now though...
placement_address is similar: in my code it is defined as
Code: Select all
u32int placement_address = &end;
tables_idx does not exist: I can't find a reference to that anywhere on the page. The nearest I found was table_idx:
Code: Select all
page_t *get_page(u32int address, int make, page_directory_t *dir)
{
// Turn the address into an index.
address /= 0x1000;
// Find the page table containing this address.
u32int table_idx = address / 1024;
if (dir->tables[table_idx]) // If this table is already assigned
{
return &dir->tables[table_idx]->pages[address%1024];
}
else if(make)
{
u32int tmp;
dir->tables[table_idx] = (page_table_t*)kmalloc_ap(sizeof(page_table_t), &tmp);
dir->tablesPhysical[table_idx] = tmp | 0x7; // PRESENT, RW, US.
return &dir->tables[table_idx]->pages[address%1024];
}
else
{
return 0;
}
}
Cheers for looking at it, seems there are some omissions on my part! If you'd been able to get the code hopefully it would have all been explained!
Okay. I asked this in the general programming forum but I don't know how long it will be until someone answers the question so I will also ask it here. I am getting an unresolved external error for my memset function but it isn't external and is not declared so anywhere. any ideas?
Getting back in the game.