GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > MEM / V5-6-0

Constituent: mem_base     Tag: mv2304


Interface   Data Structures   File List   Data Fields   Globals  

memmap.c File Reference

Memory Map functions. More...

#include <string.h>
#include "MEM/MEM_cmddefs.h"
#include "MEM/MEM_map.h"
#include "MEM/MEM_msgs.h"
#include "MSG/MSG_pubdefs.h"
#include "mempriv.h"

Include dependency graph for memmap.c:


Defines

#define DIM(a)   (sizeof (a) / sizeof ((a)[0]))
 Dimension of an array.
#define mem_NUM_MEM_MAP_TABLE_ENTRIES   (64)
 Maximum number of mem_mapMemoryTable entries.

Functions

void * MEM_mapRWGeneric (void *dest_p, const void *source_p, const size_t nbytes, void *context_p, size_t *bytes_moved_p)
 Generic memory access callback.
void * MEM_mapRead32Swap (void *dest_p, const void *source_p, const size_t nbytes, void *context_p, size_t *bytes_read_p)
 Byte-swapped 32-bit memory read callback.
void * MEM_mapWrite32Swap (void *dest_p, const void *source_p, const size_t nbytes, void *context_p, size_t *bytes_written_p)
 Byte-swapped 32-bit memory write callback.
void * MEM_mapReadBuffer (void *dest_p, const void *offset, const size_t nbytes, void *buf_p, size_t *bytes_read_p)
 Buffer read access.
void * MEM_mapWriteBuffer (void *offset, const void *src_p, const size_t nbytes, void *buf_p, size_t *bytes_written_p)
 Buffer write access.
unsigned int Mem_ValidateMemoryRange (const MEM_Descriptor *md, const MEM_mapAccessType accessType, const mem_mapEntry **mapEntry)
 Validate memory descriptor against memory map table.
unsigned int MEM_mapInit (void)
 Start the Memory Map system.
unsigned int MEM_mapAddEntry (const caddr_t start_addr, const size_t num_bytes, const MEM_mapAccessType access_flags, MEM_mapAccessCb *read_cb, MEM_mapAccessCb *write_cb, void *context_p)
 Add an entry to the memory map table.
unsigned int MEM_mapAddPpciEntries (void)
 Add memory map table entries for the PPCI bridge chip.

Variables

static mem_mapEntry mem_mapMemoryTable [mem_NUM_MEM_MAP_TABLE_ENTRIES]
 Memory map table for 'memory' accesses.
static unsigned char mem_mapFakeRegs [MEM_REGISTER_SET_BYTES]
 Buffer for simulating CPU register accesses.
static unsigned char mem_mapFakePci [65536]
 Buffer for simulating PCI device header accesses.
static mem_mapEntry mem_mapRegisterTable []
 Memory map table for 'register' accesses.
static mem_mapEntry mem_mapPciConfigTable []
 Memory map table for 'PCI Configuration' accesses.

Detailed Description

Memory Map functions.

These functions manipulate memory maps.

  CVS $Id: memmap.c,v 1.20 2005/11/08 20:43:17 dmay Exp $
  

Function Documentation

unsigned int MEM_mapAddEntry const caddr_t  start_addr,
const size_t  num_bytes,
const MEM_mapAccessType  access_flags,
MEM_mapAccessCb read_cb,
MEM_mapAccessCb write_cb,
void *  context_p
 

Add an entry to the memory map table.

Add an entry to the memory map table, which defines all the valid locations within the memory address space. Each table entry defines a contiguous region of the memory address space, including the types of accesses allowed to the region and pointers to callback functions that can be used to read and write the region.

Parameters:
start_addr Start address of region.
num_bytes Size of region, in bytes.
access_flags Bitmap of allowed accesses to the region.
read_cb Pointer to callback function for reading from region.
write_cb Pointer to callback function for writing to region.
context_p Generic pointer passed to callback functions.
Returns:
A MEM MSG code.

unsigned int MEM_mapAddPpciEntries void   ) 
 

Add memory map table entries for the PPCI bridge chip.

Add memory map table entries for the registers within the powerPCI bridge chip on the RAD750 board.

Returns:
A MEM MSG code.

unsigned int MEM_mapInit void   ) 
 

Start the Memory Map system.

Start the Memory Map system. This function should be called once to initialize the internal state associated with the Memory Map functions.

Returns:
A MEM MSG code.

void * MEM_mapRead32Swap void *  dest_p,
const void *  source_p,
const size_t  nbytes,
void *  context_p,
size_t *  bytes_read_p
 

Byte-swapped 32-bit memory read callback.

This is a callback function for reading 32-bit words that require byte swapping. Accesses must be a multiple of 32-bits and aligned on a 32-bit boundary.

Parameters:
dest_p Pointer to destination of the read.
source_p Pointer to source of the read.
nbytes Number of bytes to read.
context_p Pointer to generic context (unused).
bytes_read_p Pointer to location to return number of bytes read.
Returns:
dest_p if no error occurred, NULL if an error occurred.

void * MEM_mapReadBuffer void *  dest_p,
const void *  offset,
const size_t  nbytes,
void *  buf_p,
size_t *  bytes_read_p
 

Buffer read access.

This is a callback function for reading values from a buffer. This would be used, for example, to read a snapshot of the CPU register values or the PCI configuration space values which have been captured in a buffer. A pointer to the beginning of this snapshot buffer must be provided as the buf_p parameter.

Parameters:
dest_p Pointer to destination of the buffer read.
offset Offset from buf_p to begin reading.
nbytes Number of bytes to read.
buf_p Pointer to start of buffer.
bytes_read_p Pointer to location to return number of bytes read.
Returns:
dest_p if no error occurred, NULL if an error occurred.

void * MEM_mapRWGeneric void *  dest_p,
const void *  source_p,
const size_t  nbytes,
void *  context_p,
size_t *  bytes_moved_p
 

Generic memory access callback.

This is a callback function for reading and writing generic memory. It is suitable for RAM or other memory that has no alignment or access restrictions.

Parameters:
dest_p Pointer to destination of the memory read or write.
source_p Pointer to source of the memory read or write.
nbytes Number of bytes to read or write.
context_p Pointer to generic context (unused).
bytes_moved_p Pointer to location to return number of bytes moved.
Returns:
dest_p if no error occurred, NULL if an error occurred.

void * MEM_mapWrite32Swap void *  dest_p,
const void *  source_p,
const size_t  nbytes,
void *  context_p,
size_t *  bytes_written_p
 

Byte-swapped 32-bit memory write callback.

This is a callback function for writing 32-bit words that require byte swapping. Accesses must be a multiple of 32-bits and aligned on a 32-bit boundary.

Parameters:
dest_p Pointer to destination of the write.
source_p Pointer to source of the write.
nbytes Number of bytes to write.
context_p Pointer to generic context (unused).
bytes_written_p Pointer to location to return num bytes written.
Returns:
dest_p if no error occurred, NULL if an error occurred.

void * MEM_mapWriteBuffer void *  offset,
const void *  src_p,
const size_t  nbytes,
void *  buf_p,
size_t *  bytes_written_p
 

Buffer write access.

This is a callback function for writing values to a buffer. A pointer to the beginning of the buffer must be provided as the buf_p parameter.

Parameters:
offset Offset from buf_p to begin writing.
src_p Pointer to source of the buffer write.
nbytes Number of bytes to write.
buf_p Pointer to start of buffer.
bytes_written_p Pointer to location to return num bytes written.
Returns:
offset if no error occurred, NULL if an error occurred.

unsigned int Mem_ValidateMemoryRange const MEM_Descriptor md,
const MEM_mapAccessType  accessType,
const mem_mapEntry **  mapEntry
 

Validate memory descriptor against memory map table.

This function verifies that a memory descriptor is valid for a given set of access types. Potential access types are specified in accessType as a bitfield. If at least one of the access types specified is legal for the memory descriptor, a handle to the appropriate memory map entry is passed back for future use. If, instead, the caller wants to know if *all* specified access types are valid, then this function must be called once for each type.

Parameters:
md Pointer to memory descriptor to be validated.
accessType Bitfield of types of accesses to validate.
mapEntry Pointer to location to return map table entry handle.
Return values:
MEM_SUCCESS md is OK for accessType.
MEM_OUTOFRNG md does not fit in any memory map.
MEM_BADMAP md does not contain a legal memory map type.
MEM_BADACC accessType is not legal for md.


Variable Documentation

mem_mapFakePci [static]
 

Initial value:

    {
        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
    }
Buffer for simulating PCI device header accesses.

mem_mapMemoryTable [static]
 

Memory map table for 'memory' accesses.

Describes the memory map for MEM_MEMMAP_MEMORY loads and dumps.

mem_mapPciConfigTable [static]
 

Initial value:

Memory map table for 'PCI Configuration' accesses.

Describes the memory map for MEM_MEMMAP_PCI_CFG loads and dumps. The PCI configuration space is a 256-byte address space for each device on the PCI bus.

mem_mapRegisterTable [static]
 

Initial value:

Memory map table for 'register' accesses.

Describes the memory map for MEM_MEMMAP_REGISTER loads and dumps.


Generated on Tue Nov 8 22:36:29 2005 by  doxygen 1.4.4