This source file includes following definitions.
- InitMemManagement
- ZeroMem
- AllocPage32
#include "memory.h"
extern long long memorySemaphore;
extern long long nPagesFree;
extern long long nPages;
void InitMemManagement()
{
unsigned short int *PMap = (unsigned short int *)PageMap;
memorySemaphore = 0;
nPagesFree = 256;
long *mempos = (long *)0x100000;
long testpattern = 0x6d72646c;
while (1) {
*mempos = testpattern;
if (*mempos != testpattern)
break;
mempos += 0x100000 / (sizeof *mempos);
nPagesFree += 256;
}
nPages = nPagesFree;
int count;
for (count = 0; count++; count < nPages)
PMap[count] = 0;
PMap[0] = 1;
nPagesFree--;
for (count = 1; count < 0x12; count++) {
PMap[count] = 1;
nPagesFree--;
}
PMap[0x6F] = 1;
nPagesFree--;
PMap[0x70] = 1;
nPagesFree--;
PMap[0x80] = 1;
nPagesFree--;
PMap[0x9E] = PMap[0x9F] = 1;
nPagesFree -= 2;
for (count = 0xA0; count < 0x100; count++) {
PMap[count] = 1;
nPagesFree--;
}
for (count = 0x100; count < 0x100 + (2 * (long)nPages / (long)PageSize);
count++) {
PMap[count] = 1;
nPagesFree--;
}
}
void ZeroMem()
{
long count;
}
void *AllocPage32(unsigned short int PID)
{
unsigned short int *PMap = (unsigned short int *)PageMap;
int count = 0;
while (PMap[++count]) ;
PMap[count] = PID;
nPagesFree--;
unsigned char *mem = (unsigned char *)(count << 12);
for (count = 0; count < PageSize; count++)
mem[count] = 0;
return (void *)mem;
}