GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > PBS / V2-10-11

Constituent: pbs     Tag: rad750


Interface   Data Structures   File List   Data Fields   Globals  

MBA.c.vx-ppc-gcc File Reference

Implements the low level memory block allocation routines for the VxWorks platform. More...

#include <stdio.h>
#include <vxWorks.h>
#include <sysLib.h>
#include <memPartLib.h>
#include "PBI/impl/ASM.h.xx-ppc-gcc"

Include dependency graph for MBA.c.vx-ppc-gcc:


Functions

static PART_ID mba_create (const MBA_badBlock *list)
 Creates the memory partition, taking into account a list of bad blocks.
static PART_ID mba_add (PART_ID part_id, unsigned char *beg, unsigned char *end)
 Creates (if part_id is NULL) or adds to the specified memory partition.
int MBA_initialize (MBA_create_cb create, void *prm)
 One time initialization of the MBA facility.
void * MBA_align (unsigned int alignment, unsigned int nBytes)
 Allocates nBytes of aligned memory.
void * MBA_alloc (unsigned int nBytes)
 Allocates nBytes of at least word aligned memory.
int MBA_free (void *pBlock)
 Frees a piece of memory allocated with either MBA_align() or MBA_alloc().
int MBA_statsGet (MBA_stats *stats)
 Gets the memory stats for the MBA partition.

Variables

static PART_ID MemPartId = NULL
 The memory partition id used to allocate user memory requests.

Detailed Description

Implements the low level memory block allocation routines for the VxWorks platform.

Author:
JJRussell - russell@slac.stanford.edu
    CVS $Id: MBA.c.vx-ppc-gcc,v 1.5 2005/05/12 19:42:58 russell Exp $

Overview
The MBA routines on the embedded systems create, allocate and free memory from a pool defined to begin at the end of the system pool and end at the end of physical memory.
Bad Blocking of Memory
A list of bad memory blocks can be specified. The MBA creation routine will construct a VxWorks partition from the pieces not within the list of bad blocks.
Bad Block Specification
The MBA creation routine will guard against certain pathologies a bad block list might possess, but not all. Generally it will take care of pathologies that the user cannot be aware of. These deal with specifying bad blocks that may begin and end outside the MBA pool of memory. This is done on the theory that the user does not possess knowledge of the beginning and ending of the pool, so even with the best intentions, cannot guard against such a specification.
However, the bad block list must be constructed with the following constraints.
  1. The blocks must be ordered
  2. The blocks must be non-overlapping.
  3. The end of the bad block list is defined when a bad block of length 0 is encountered.

Function Documentation

static PART_ID mba_add PART_ID  part_id,
unsigned char *  beg,
unsigned char *  end
[static]
 

Creates (if part_id is NULL) or adds to the specified memory partition.

Returns:
The partition id
Parameters:
part_id The partition id to add to. If NULL, a new partition is created
beg Pointer to the beginning of the memory
end Pointer to the end of the memory (actually, in the usual C sense, one byte past the last byte)
If the partition id, part_id is NULL, a new partition is created. If the partition id is not NULL, it is treated as an existing partition and added to. In both cases the memory region defined by the semi-open interval [beg, end) is added to the partition.

void* MBA_align unsigned int  alignment,
unsigned int  nBytes
 

Allocates nBytes of aligned memory.

Parameters:
alignment The alignment factor. This must be a power of 2
nBytes The number of bytes to allocate
Returns:
If successful, a pointer to the allocated memory, Else NULL
Warning:
Note that the calling sequence to this routine follows the convention of memalign(), not that of the VxWorks routine memPartAlign().

void* MBA_alloc unsigned int  nBytes  ) 
 

Allocates nBytes of at least word aligned memory.

Parameters:
nBytes The number of bytes to allocate
Returns:
If successful, a pointer to the allocated memory, Else NULL

static PART_ID mba_create const MBA_badBlock list  )  [static]
 

Creates the memory partition, taking into account a list of bad blocks.

Returns:
The handle of the created parition ID or NULL on failure
Parameters:
list A list of bad blocks. This may be specified as NULL.

int MBA_free void *  pBlock  ) 
 

Frees a piece of memory allocated with either MBA_align() or MBA_alloc().

Parameters:
pBlock Pointer to the block of memory to be freed.
Return values:
0,if successful
-1,if error
The return error codes are only supported on VxWorks platforms. On generic platforms, success is always returned. This is because free() does not give any indication of success or failure, whereas the VxWorks memPart routines do.

int MBA_initialize MBA_create_cb  create,
void *  prm
 

One time initialization of the MBA facility.

Returns:
Status
Parameters:
create User callback partition creation meant to usurp the default creation routine in an extreme emergency
prm Arbitrary user parameter passed to partition creation routine. If the partition creation routine is specified as NULL, then, if this parameter is treated as a pointer to a list of bad blocks, MBA_badBlock.
This is not meant to be a user callable routine.

int MBA_statsGet MBA_stats stats  ) 
 

Gets the memory stats for the MBA partition.

Parameters:
stats Pointer to the statistics block to fill
Return values:
0,if successful
-1,if error
On VXWORKS platforms, this is just a cover for memInfoGet.

Warning:
These statistics do not exist on generic platforms. The call interface is provided only as a convenience. On generic platforms, the caller should only use the contents for logging or display purposes. It is up to the caller to make his code portable across both a VXWORS and a generic platform.
Additional advise. Even under VXWORKS, unless one can guarantee that the partition is not being used by another thread of execution at the time of call till the time one acts on a decision made as a result of examining the contents of the statistics block, then do not depend on the results of the call for anything more than logging or display purposes. Without the single-threaded constraint, the statistics can certainly change between the time one gathers the statistics and when one acts on them. Bottom line, this call should only ever be used for display or casual diagnostic reasons.


Generated on Wed Dec 20 06:13:20 2006 by  doxygen 1.4.4