27 lines
685 B
C
27 lines
685 B
C
#include "mem.h"
|
|
#include "vga.h"
|
|
|
|
struct mem_desc *page_desc = (struct mem_desc *)&__ld_kernel_end;
|
|
|
|
int memInit(unsigned long upper_mem)
|
|
{
|
|
printString("Free Mem going from ");
|
|
printInt((unsigned long)&__ld_kernel_end);
|
|
printString(" to ");
|
|
printInt(upper_mem * 1024);
|
|
printString("\n");
|
|
unsigned long memdesc_end =
|
|
(unsigned long)page_desc +
|
|
((upper_mem) / (PAGE_SIZE / 1024)) * sizeof(struct mem_desc);
|
|
uint lastUsed = (memdesc_end >> PAGE_SHIFT) + 1;
|
|
for (uint i = 0; i < (upper_mem / (PAGE_SIZE / 1024)); i++) {
|
|
struct mem_desc *mem = &page_desc[i];
|
|
if (i < lastUsed)
|
|
mem->ref = 1;
|
|
else
|
|
mem->ref = 0;
|
|
mem->phy_addr = i * PAGE_SIZE;
|
|
}
|
|
return 0;
|
|
}
|