File size: 1,610 Bytes
806d4b5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
U0 MemDemo()
{
I64 i;
"$HL,1$$BLACK$
#define MEM_PAG_BITS 9
#define MEM_PAG_SIZE (1<<MEM_PAG_BITS)
#define MEM_HEAP_HASH_SIZE 1024
#define MEM_FREE_PAG_HASH_SIZE 0x100
#define MEM_EXTRA_HASH2_PAGS 2
public class CBlkPool
{
CMemBlk *free_pag_hash[MEM_FREE_PAG_HASH_SIZE],
*free_pag_hash2[64-MEM_PAG_BITS];
};
public class CHeapCtrl
{
CBlkPool *bp;
CMemUnused *heap_hash[MEM_HEAP_HASH_SIZE/sizeof(U8 *)];
};
public class CTask //The Fs segment reg points to current CTask.
{
CHeapCtrl *code_heap,*data_heap;
};
$HL,0$$FG$
";
"$PURPLE$Chunks in increments of 8 bytes, owned by the task.$FG$\n";
for (i=sizeof(CMemUnused);i<MEM_HEAP_HASH_SIZE;i+=8)
if (i==0x48)
"...\n";
else if (!(0x48<i<0x3C8))
"Fs->data_heap->heap_hash[%X/8]"
"$BLACK$ -->$FG$[X]$BLACK$ -->$FG$[X]$BLACK$ -->$FG$\n",i;
"\n\n";
"$PURPLE$Pages of 512 bytes, owned by the system.$FG$\n";
for (i=MEM_HEAP_HASH_SIZE;i<MEM_FREE_PAG_HASH_SIZE*MEM_PAG_SIZE;
i+=MEM_PAG_SIZE)
if (i==0x1200)
"...\n";
else if (!(0x1200<i<0x1F200))
"Fs->data_heap->bp->free_pag_hash[%X/512]"
"$BLACK$ -->$FG$[X]$BLACK$ -->$FG$[X]$BLACK$ -->$FG$\n",i;
"\n\n";
"$PURPLE$Powers of two, owned by the system.$FG$\n";
for (i=Bsf(MEM_FREE_PAG_HASH_SIZE*MEM_PAG_SIZE);i<64;i++)
if (i==0x1A)
"...\n";
else if (!(0x1A<=i<=0x36))
"Fs->data_heap->bp->free_pag_hash2[%X] %016X"
"$BLACK$ -->$FG$[X]$BLACK$ -->$FG$[X]$BLACK$ -->$FG$\n",i,
1<<i+MEM_EXTRA_HASH2_PAGS*MEM_PAG_SIZE;
"\n\n";
}
MemDemo;
|