GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > PBC / V4-5-0

Constituent: pbc_bootshell     Tag: rad750


Interface   Data Structures   File List   Data Fields   Globals  

PBC_heap.c File Reference

Primary Boot Code Allocation. More...

#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:

Include dependency graph

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

Detailed Description

Primary Boot Code Allocation.

Author:
Ray Caperoon
Date:
Tue Oct 14 08:00:48 2003
  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.


Function Documentation

void * calloc unsigned int  items,
unsigned int  size
 

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().

Parameters:
items number of items to allocate
size size in bytes of items to allocate
Return values:
. pointer to allocated memory
NULL if out of heap

Here is the call graph for this function:

void free void *  mem  ) 
 

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.

Parameters:
mem unused


Variable Documentation

pbc_heapAllocCalls = 0 [static]
 

Number of calls to calloc() that have been made, used for statistics.

pbc_heapCurrentSize = 0 [static]
 

Current size in bytes of the heap. Initialized to zero at compile time.

pbc_heapFreeCalls = 0 [static]
 

Number of calls to free() that have been made, used for statistics.

pbc_heapNext = (unsigned char *)PBC_RAM_HEAP_ADRS [static]
 

Next address to be returned by a call to calloc(). Initialized to the heap start address at compile time.

pbc_heapOverflow = 0 [static]
 

Flag to indicate the PBC has run out of heap. Non-zero value indicates out-of-heap condition.


Generated on Fri Jul 22 20:17:37 2005 by doxygen 1.3.3