Example #1
0
        public static int InitBlock(HeapBlock *b, UInt32 size, UInt32 bsize)
        {
            UInt32 bcnt;

            b->size  = size - (UInt32)sizeof(HeapBlock);
            b->bsize = bsize;

            bcnt = size / bsize;
            byte *bm = (byte *)&b[1];

            /* clear bitmap */
            for (uint x = 0; x < bcnt; ++x)
            {
                bm[x] = 0;
            }

            /* reserve room for bitmap */
            bcnt = (bcnt / bsize) * bsize < bcnt ? bcnt / bsize + 1 : bcnt / bsize;
            for (uint x = 0; x < bcnt; ++x)
            {
                bm[x] = 5;
            }

            b->lfb = bcnt - 1;

            b->used = bcnt;
            b->next = null;

            return(1);
        }
Example #2
0
        public static int AddBlock(HeapBlock *b)
        {
            EnterCritical("AddBlock");

            b->next = fblock;
            fblock  = b;

            ExitCritical();

            return(1);
        }
Example #3
0
        public static UInt32 GetTotalMem()
        {
            HeapBlock *cBlock = fblock;
            UInt32     result = 0;

            while (cBlock != null)
            {
                result += cBlock->size;
                cBlock  = cBlock->next;
            }
            return(result);
        }
Example #4
0
        public static void InitFixedHeap()
        {
            if (!FixedHeapInitialised)
            {
                Heap.Init();

                HeapBlock *heapPtr = (HeapBlock *)Heap.GetFixedHeapPtr();
                Heap.InitBlock(heapPtr, Heap.GetFixedHeapSize(), 32);
                Heap.AddBlock(heapPtr);

                FixedHeapInitialised = true;
            }
        }
Example #5
0
        public static int AddBlock(UInt32 addr, UInt32 size, UInt32 bsize)
        {
            HeapBlock *b;
            UInt32     bcnt;
            UInt32     x;
            byte *     bm;

            b        = (HeapBlock *)addr;
            b->size  = size - (UInt32)sizeof(HeapBlock);
            b->bsize = bsize;

            b->next = fblock;
            fblock  = b;

            bcnt = size / bsize;
            bm   = (byte *)&b[1];

            /* clear bitmap */
            for (x = 0; x < bcnt; ++x)
            {
                bm[x] = 0;
            }

            /* reserve room for bitmap */
            bcnt = (bcnt / bsize) * bsize < bcnt ? bcnt / bsize + 1 : bcnt / bsize;
            for (x = 0; x < bcnt; ++x)
            {
                bm[x] = 5;
            }

            b->lfb = bcnt - 1;

            b->used = bcnt;

            return(1);
        }
Example #6
0
 public static void Init()
 {
     fblock = (HeapBlock *)0;
 }
Example #7
0
 public static UInt32 GetFreeMem(HeapBlock *aBlock)
 {
     return(aBlock->size - (aBlock->used * aBlock->bsize));
 }
Example #8
0
 public static UInt32 GetUsedMem(HeapBlock *aBlock)
 {
     return(aBlock->used * aBlock->bsize);
 }
Example #9
0
        public static int AddBlock(UInt32 addr, UInt32 size, UInt32 bsize)
        {
            HeapBlock* b;
            UInt32 bcnt;
            UInt32 x;
            byte* bm;

            b = (HeapBlock*)addr;
            b->size = size - (UInt32)sizeof(HeapBlock);
            b->bsize = bsize;

            b->next = fblock;
            fblock = b;

            bcnt = size / bsize;
            bm = (byte*)&b[1];

            /* clear bitmap */
            for (x = 0; x < bcnt; ++x)
            {
                bm[x] = 0;
            }

            /* reserve room for bitmap */
            bcnt = (bcnt / bsize) * bsize < bcnt ? bcnt / bsize + 1 : bcnt / bsize;
            for (x = 0; x < bcnt; ++x)
            {
                bm[x] = 5;
            }

            b->lfb = bcnt - 1;

            b->used = bcnt;

            return 1;
        }
Example #10
0
 public static void Init()
 {
     fblock = (HeapBlock*)0;
 }
Example #11
0
 public static void Init()
 {
     fblock = null;
 }
Example #12
0
 public static void Load(HeapBlock *heapPtr, SpinLock heapLock)
 {
     fblock                = heapPtr;
     AccessLock            = heapLock;
     AccessLockInitialised = (AccessLock != null);
 }
Example #13
0
        public static int AddBlock(HeapBlock* b)
        {
            EnterCritical("AddBlock");

            b->next = fblock;
            fblock = b;

            ExitCritical();

            return 1;
        }
Example #14
0
 public static void Init()
 {
     fblock = null;
 }
Example #15
0
 public static void Load(HeapBlock* heapPtr, SpinLock heapLock)
 {
     fblock = heapPtr;
     AccessLock = heapLock;
     AccessLockInitialised = (AccessLock != null);
 }