GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > PBC / V4-5-0
Constituent: pbc_bootshell     Tag: rad750
#include "PBC/PBC.h"
#include "string.h"
#include "pbc_sio.h"
#include "bootshell.h"
#include "pbc_memmap.h"
Include dependency graph for PBC_heap.c:
Functions | |
void * | calloc (unsigned int items, unsigned int size) |
Allocate cleared memory. | |
void | free (void *mem) |
Free allocated memory. | |
Variables | |
unsigned char * | pbc_heapNext = (unsigned char *)PBC_RAM_HEAP_ADRS |
unsigned long | pbc_heapCurrentSize = 0 |
unsigned long | pbc_heapAllocCalls = 0 |
unsigned long | pbc_heapFreeCalls = 0 |
unsigned int | pbc_heapOverflow = 0 |
CVS $Id: PBC_heap.c,v 1.7 2005/01/10 22:30:54 dmay Exp $
This file provides the dynamic memory allocation routines needed by the Primary Boot Code. The allocation model is very simple: memory is never returned to the heap. Once allocated the memory is never re-used.
It is intended that these allocation routines are used only by the ZLIB inflation routines, and only need to run once to get the RTOS up and running, so a simple allocation will do.
Three routines are provided:
calloc() is a drop-in replacement for the standard C-library calloc() call. It uses memset() to clear the memory allocated.
free() is a drop-in replacement for the standard C-library free() call. Since we never return memory to the heap, this is a no-op function.
PBC_DumpHeapStats() is used for debug. It dumps the heap usage stats to the serial port. This routine could be modified to provide telemetry during flight.
|
Allocate cleared memory. A drop-in replacement for the standard C-library calloc() call to be used by the primary boot code. It provides a very simple allocation model, no memory is returned to the heap. This function checks that the heap has not been overflowed (determined by PBC_RAM_HEAP_BYTES). If there is still room in the heap, calloc() returns pbc_heapNext, which is address of the next available storage. pbc_heapNext is incremented by the size of the current allocation to prepare for the next call. memset() is used to clear the allocated memory, as per the convention of calloc().
|
Here is the call graph for this function:
|
Free allocated memory. A drop-in replacement for the standard C-library free() call to be used by the primary boot code. In the simple allocation model used by the Primary Boot Code, the function is a no-op.
|
|
Number of calls to calloc() that have been made, used for statistics. |
|
Current size in bytes of the heap. Initialized to zero at compile time. |
|
Number of calls to free() that have been made, used for statistics. |
|
Next address to be returned by a call to calloc(). Initialized to the heap start address at compile time. |
|
Flag to indicate the PBC has run out of heap. Non-zero value indicates out-of-heap condition. |