GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> MEM / V5-8-2 > mem_base / sun-gcc
#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>
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. |
These functions manipulate memory maps.
CVS $Id: memmap.c,v 1.21 2011/03/29 01:58:53 apw Exp $
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.
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. |
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. |
References _mem_mapEntry::access_flags, _mem_mapEntry::context_p, DIM, MEM_MAP_ACCESS_READ_ANY, MEM_MAP_ACCESS_WRITE_ANY, MEM_MSG, _mem_mapEntry::num_bytes, _mem_mapEntry::read_cb, _mem_mapEntry::start_addr, _mem_mapEntry::valid, and _mem_mapEntry::write_cb.
Referenced by MEM_mapAddPpciEntries().
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.
References DIM, MEM_MAP_ACCESS_32, MEM_mapAddEntry(), MEM_mapRead32Swap(), and MEM_mapWrite32Swap().
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.
References DIM.
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.
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. |
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. |
Referenced by MEM_mapAddPpciEntries().
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.
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. |
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. |
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.
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. |
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. |
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.
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. |
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. |
Referenced by MEM_mapAddPpciEntries().
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.
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. |
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. |
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.
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. |
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. |
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. |
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. |
References _mem_mapEntry::access_flags, _MEM_Descriptor::addr, _MEM_Descriptor::bytes, DIM, MEM_MAP_ACCESS_16, MEM_MAP_ACCESS_8, MEM_MSG, _MEM_Descriptor::memmap, _mem_mapEntry::num_bytes, and _mem_mapEntry::start_addr.
Referenced by mem_loadStart(), and mem_ValidateDumpDescriptor().
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, }
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:
{ { 1, (void *)0x0, 0x10000, MEM_MAP_ACCESS_ANY, MEM_mapReadBuffer, MEM_mapWriteBuffer, mem_mapFakePci }, }
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:
{ { 1, (void *)0x0, MEM_REGISTER_SET_BYTES, MEM_MAP_ACCESS_ANY, MEM_mapReadBuffer, MEM_mapWriteBuffer, mem_mapFakeRegs }, }
Describes the memory map for MEM_MEMMAP_REGISTER loads and dumps.