Import backup from 2004-06-01
This commit is contained in:
1 parent
6d941b7b16
commit
b4aca026d4
17 files changed
+419
-161
No files matched your search
+2
-3
@@ -8,8 +8,8 @@
|
||||
|
||||
//The total amount of physical memory available (bytes, 1 bit per page)
|
||||
#define BITMAP_SIZE 0x20000
|
||||
dword mm_totalmem;
|
||||
dword mm_megabytes;
|
||||
dword mm_totalmem = 0;
|
||||
dword mm_megabytes = 0;
|
||||
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,7 +17,6 @@ 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;
|
||||
|
||||
+25
-17
@@ -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
|
||||
// It sets up the final page directory/page table setup and maps video memory, if present
|
||||
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,13 +30,6 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +122,7 @@ void *malloc(unsigned int bytes)
|
||||
void *vmm_getFreeChunk(unsigned int bytes)
|
||||
{
|
||||
HeapEntry *he = firstHeapEntry;
|
||||
while (he)
|
||||
for (;;)
|
||||
{
|
||||
if (he->attributes == VMM_HE_FREE)
|
||||
{
|
||||
@@ -150,6 +143,8 @@ void *vmm_getFreeChunk(unsigned int bytes)
|
||||
}
|
||||
}
|
||||
he = (HeapEntry *)he->link;
|
||||
if (!he)
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -166,7 +161,7 @@ void vmm_coalesceHeapEntry(HeapEntry *he)
|
||||
return;
|
||||
}
|
||||
HeapEntry *hec = firstHeapEntry;
|
||||
while (hec)
|
||||
for (;;)
|
||||
{
|
||||
if (hec->attributes == he->attributes)
|
||||
{
|
||||
@@ -183,6 +178,8 @@ void vmm_coalesceHeapEntry(HeapEntry *he)
|
||||
}
|
||||
}
|
||||
hec = (HeapEntry *)hec->link;
|
||||
if (!hec)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,9 +259,12 @@ void vmm_addHeapEntryBlock()
|
||||
HeapEntry *vmm_getLastHeapEntry()
|
||||
{
|
||||
HeapEntry *he = firstHeapEntry;
|
||||
while (he)
|
||||
for (;;)
|
||||
{
|
||||
if (he->link == 0)
|
||||
return he;
|
||||
he = (HeapEntry *)he->link;
|
||||
return he;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -272,11 +272,13 @@ HeapEntry *vmm_getLastHeapEntry()
|
||||
HeapEntry *vmm_getFirstHoleHeapEntry(unsigned int minBytes)
|
||||
{
|
||||
HeapEntry *he = firstHeapEntry;
|
||||
while (he)
|
||||
for (;;)
|
||||
{
|
||||
if ((he->attributes == VMM_HE_HOLE) && (he->size >= minBytes))
|
||||
return he;
|
||||
he = (HeapEntry *)he->link;
|
||||
if (!he)
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -286,11 +288,13 @@ HeapEntry *vmm_getFirstHoleHeapEntry(unsigned int minBytes)
|
||||
HeapEntry *vmm_getFirstUnusedHeapEntry()
|
||||
{
|
||||
HeapEntry *he = firstHeapEntry;
|
||||
while (he)
|
||||
for (;;)
|
||||
{
|
||||
if (he->attributes == VMM_HE_UNUSED)
|
||||
return he;
|
||||
he = (HeapEntry *)he->link;
|
||||
if (!he)
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -301,11 +305,13 @@ unsigned int vmm_heapEntriesLeft()
|
||||
{
|
||||
HeapEntry *he = firstHeapEntry;
|
||||
unsigned int entries = 0;
|
||||
while (he)
|
||||
for (;;)
|
||||
{
|
||||
if (he->attributes == VMM_HE_UNUSED)
|
||||
entries++;
|
||||
he = (HeapEntry *)he->link;
|
||||
if (!he)
|
||||
break;
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
@@ -327,11 +333,13 @@ int free(void *ptr)
|
||||
HeapEntry *vmm_getHeapEntryByBase(unsigned int base)
|
||||
{
|
||||
HeapEntry *he = firstHeapEntry;
|
||||
while (he)
|
||||
for (;;)
|
||||
{
|
||||
if (he->base == base)
|
||||
return he;
|
||||
he = (HeapEntry *)he->link;
|
||||
if (!he)
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user