Import backup from 2004-05-23
This commit is contained in:
1 parent
a982312d2c
commit
6d941b7b16
12 files changed
+85
-59
No files matched your search
+3
-2
@@ -8,8 +8,8 @@
|
||||
|
||||
//The total amount of physical memory available (bytes, 1 bit per page)
|
||||
#define BITMAP_SIZE 0x20000
|
||||
dword mm_totalmem = 0;
|
||||
dword mm_megabytes = 0;
|
||||
dword mm_totalmem;
|
||||
dword mm_megabytes;
|
||||
byte page_bitmap[BITMAP_SIZE]; //used to store a bit for each page that is used, 0 if available
|
||||
//0x20000*(8 bits/byte)=0x100000 pages in 4gb total
|
||||
|
||||
@@ -17,6 +17,7 @@ byte page_bitmap[BITMAP_SIZE]; //used to store a bit for each page that is used,
|
||||
// memory areas returned by bios interrupt 0x8E20
|
||||
void mm_init()
|
||||
{
|
||||
mm_totalmem = mm_megabytes = 0;
|
||||
dword memmap_entries = *(dword *)BOOT_MEMMAP_ENTRIES;
|
||||
memmap_entry *maps = (memmap_entry *) BOOT_FIRST_MEMMAP;
|
||||
dword a;
|
||||
|
||||
+17
-25
@@ -8,18 +8,18 @@
|
||||
#include "vmm.h"
|
||||
#include "asmfuncs.h"
|
||||
#include "mm/mm.h"
|
||||
#include "video/video.h"
|
||||
|
||||
HeapEntry *firstHeapEntry = (HeapEntry *)0xD0000000; //this is where heap memory starts
|
||||
|
||||
// This is the initialization procedure for the Virtual Memory Manager
|
||||
// It sets up the final page directory/page table setup and maps video memory, if present
|
||||
// It sets up the final page directory/page table setup
|
||||
void vmm_init()
|
||||
{
|
||||
unsigned int *pageTables = (unsigned int *)0xC0104000; //this is the location of the page directory
|
||||
pageTables[0x3FF] = 0x104000|0x03; //the last page directory entry points to the page directory itself
|
||||
pageTables[0] = 0;
|
||||
invlpg_(0);
|
||||
|
||||
unsigned int firstHeapEntryBlock = (unsigned int)mm_palloc();
|
||||
vmm_map1((unsigned int)firstHeapEntry, firstHeapEntryBlock);
|
||||
HeapEntryBlock *heb = (HeapEntryBlock *)firstHeapEntry;
|
||||
@@ -30,6 +30,13 @@ void vmm_init()
|
||||
heb->entry[1].base = (unsigned int)firstHeapEntry+4096; //this is the start of the rest of the kernel's heap memory
|
||||
heb->entry[1].size = 0x10000000-4096; //the rest of the kernel's heap memory: 256mb - 4kb
|
||||
heb->entry[1].attributes = VMM_HE_HOLE; //this is a hole - an unmapped section of heap memory
|
||||
|
||||
unsigned int vidPages = video_getWidth() * video_getHeight() * (video_getBitsPerPixel() >> 3);
|
||||
if (vidPages % 4096)
|
||||
vidPages = (vidPages >> 12) + 1;
|
||||
else
|
||||
vidPages = (vidPages >> 12);
|
||||
vmm_mapn(0xF0000000, video_getPhysBasePtr(), vidPages);
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +129,7 @@ void *malloc(unsigned int bytes)
|
||||
void *vmm_getFreeChunk(unsigned int bytes)
|
||||
{
|
||||
HeapEntry *he = firstHeapEntry;
|
||||
for (;;)
|
||||
while (he)
|
||||
{
|
||||
if (he->attributes == VMM_HE_FREE)
|
||||
{
|
||||
@@ -143,8 +150,6 @@ void *vmm_getFreeChunk(unsigned int bytes)
|
||||
}
|
||||
}
|
||||
he = (HeapEntry *)he->link;
|
||||
if (!he)
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -161,7 +166,7 @@ void vmm_coalesceHeapEntry(HeapEntry *he)
|
||||
return;
|
||||
}
|
||||
HeapEntry *hec = firstHeapEntry;
|
||||
for (;;)
|
||||
while (hec)
|
||||
{
|
||||
if (hec->attributes == he->attributes)
|
||||
{
|
||||
@@ -178,8 +183,6 @@ void vmm_coalesceHeapEntry(HeapEntry *he)
|
||||
}
|
||||
}
|
||||
hec = (HeapEntry *)hec->link;
|
||||
if (!hec)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,12 +262,9 @@ void vmm_addHeapEntryBlock()
|
||||
HeapEntry *vmm_getLastHeapEntry()
|
||||
{
|
||||
HeapEntry *he = firstHeapEntry;
|
||||
for (;;)
|
||||
{
|
||||
if (he->link == 0)
|
||||
return he;
|
||||
while (he)
|
||||
he = (HeapEntry *)he->link;
|
||||
}
|
||||
return he;
|
||||
}
|
||||
|
||||
|
||||
@@ -272,13 +272,11 @@ HeapEntry *vmm_getLastHeapEntry()
|
||||
HeapEntry *vmm_getFirstHoleHeapEntry(unsigned int minBytes)
|
||||
{
|
||||
HeapEntry *he = firstHeapEntry;
|
||||
for (;;)
|
||||
while (he)
|
||||
{
|
||||
if ((he->attributes == VMM_HE_HOLE) && (he->size >= minBytes))
|
||||
return he;
|
||||
he = (HeapEntry *)he->link;
|
||||
if (!he)
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -288,13 +286,11 @@ HeapEntry *vmm_getFirstHoleHeapEntry(unsigned int minBytes)
|
||||
HeapEntry *vmm_getFirstUnusedHeapEntry()
|
||||
{
|
||||
HeapEntry *he = firstHeapEntry;
|
||||
for (;;)
|
||||
while (he)
|
||||
{
|
||||
if (he->attributes == VMM_HE_UNUSED)
|
||||
return he;
|
||||
he = (HeapEntry *)he->link;
|
||||
if (!he)
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -305,13 +301,11 @@ unsigned int vmm_heapEntriesLeft()
|
||||
{
|
||||
HeapEntry *he = firstHeapEntry;
|
||||
unsigned int entries = 0;
|
||||
for (;;)
|
||||
while (he)
|
||||
{
|
||||
if (he->attributes == VMM_HE_UNUSED)
|
||||
entries++;
|
||||
he = (HeapEntry *)he->link;
|
||||
if (!he)
|
||||
break;
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
@@ -333,13 +327,11 @@ int free(void *ptr)
|
||||
HeapEntry *vmm_getHeapEntryByBase(unsigned int base)
|
||||
{
|
||||
HeapEntry *he = firstHeapEntry;
|
||||
for (;;)
|
||||
while (he)
|
||||
{
|
||||
if (he->base == base)
|
||||
return he;
|
||||
he = (HeapEntry *)he->link;
|
||||
if (!he)
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user