GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> MEM / V5-8-2 > mem / sun-gcc
#include <string.h>
#include <CDM/CDM_pubdefs.h>
#include <ITC/ITC_pubdefs.h>
#include <LCBD/LCBD.h>
#include <MSG/MSG_pubdefs.h>
#include <PBS/FPA.h>
#include <PBS/INT.ih>
#include <PBS/MBA.h>
#include <PBS/MTX.h>
#include <PBS/WUT.h>
#include <MEM/MEM_cmdxtrn.h>
#include <MEM/MEM_dump.h>
#include <MEM/MEM_load.h>
#include <MEM/MEM_map.h>
#include <MEM/MEM_msgs.h>
#include <MEM/MEM_pubdefs.h>
#include <MEM_DB/MEM_DB_schema.h>
#include <MEM_control.h>
#include <Memmap.h>
Defines | |
#define | INT_FAKE_OK |
Acknowledges that we realize interrupts can't be disabled on host machines. | |
Functions | |
static void * | mem_surom_read (void *dest_p, const void *source_p, const size_t nbytes, void *context_p, size_t *bytes_read_p) |
RAD750 SUROM read callback function. | |
void * | MEM_readSurom (void *dst_p, const void *src_p, const unsigned int num_bytes) |
Read RAD750 SUROM. | |
static unsigned int | mem_map_init (MEM_Control *ctl_p) |
Init the memory map for dumps and loads. | |
static unsigned int | mem_pool_init (FPA_fcb **fcb_pp, void **buf_pp, int *in_use_p, unsigned int num_pkt, unsigned int pkt_bytes) |
Initialize an FPA pool. | |
static unsigned int | mem_pool_free (FPA_fcb **fcb_pp, void **buf_pp, int *in_use_p) |
Free an FPA pool. | |
static unsigned int | mem_create_control_block (void) |
Allocate and adopt a MEM control information block. | |
static unsigned int | mem_lock_access (MEM_Control *ctl_p) |
Lock access to a MEM control block. | |
static unsigned int | mem_unlock_access (MEM_Control *ctl_p, unsigned int status) |
Unlock access to a MEM control block. | |
static unsigned int | mem_change_state (MEM_Control *ctl_p, unsigned int valid_states, MEM_Control_State new_state) |
Change the state of the MEM functions. | |
unsigned int | MEM_initialize (ITC_Task *task_p, ITC_TaskID tid) |
Initialize the MEM application-level functions. | |
unsigned int | MEM_init (void) |
Initialize the MEM application-level functions using CDM. | |
unsigned int | MEM_shutdown (void) |
Shutdown the MEM functions. | |
unsigned int | MEM_updateStats (MEM_Control *ctl_p, unsigned int msg_status, unsigned int fcode) |
Common routine to update MEM command statistics. | |
unsigned int | MEM_getInfo (MEM_Info *info_p) |
Get current state of the MEM application-level functions. | |
Variables | |
MEM_Control * | Mem_control_p = NULL |
Pointer to the MEM control information block. | |
unsigned char | mem_sim_ram_buf [1024] |
Buffer of simulated RAM for memory dumps and loads. |
** CVS $Id: MEM_control.c,v 1.25 2011/03/29 01:58:52 apw Exp $ **
Control functions for the application-level portion of the MEM package. These functions are used within the context of another task, so they do not actually start and configure a task of their own.
unsigned int mem_change_state | ( | MEM_Control * | ctl_p, | |
unsigned int | valid_states, | |||
MEM_Control_State | new_state | |||
) | [static] |
Change the state of the MEM functions.
ctl_p | Pointer to MEM control block. | |
valid_states | Bitmask of valid current states. | |
new_state | New state. |
References mem_lock_access(), mem_unlock_access(), and _MEM_Control::state.
Referenced by MEM_initialize(), and MEM_shutdown().
unsigned int mem_create_control_block | ( | void | ) | [static] |
Allocate and adopt a MEM control information block.
References MEM_STATE_UNINITIALIZED, _MEM_Control::mtx, and _MEM_Control::state.
Referenced by MEM_initialize().
unsigned int MEM_getInfo | ( | MEM_Info * | info_p | ) |
Get current state of the MEM application-level functions.
info_p | Pointer to location to return state information. |
References _MEM_Control::info, mem_lock_access(), MEM_STATE_INITIALIZED, mem_unlock_access(), and _MEM_Control::state.
unsigned int MEM_init | ( | void | ) |
Initialize the MEM application-level functions using CDM.
This function is a wrapper for MEM_initialize() that uses CDM to determine its parameters.
A MSG code if an error occurs.
References MEM_initialize().
unsigned int MEM_initialize | ( | ITC_Task * | task_p, | |
ITC_TaskID | tid | |||
) |
Initialize the MEM application-level functions.
This function initializes the application-level portion of the MEM package and transitions it to the INITIALIZED state. It should be the first MEM function called when using the MEM package.
At the application level, there is no MEM task. Instead, the handlers for the MEM telecommands are attached to another task. If a valid value is provided for either the task_p or the tid parameter, then this function will attach the MEM command handlers to the corresponding task. If neither parameter is specified (by setting task_p to NULL and tid to -1), then it is assumed that the controlling task will attach the MEM command handlers.
task_p | Pointer to controlling task's description block. | |
tid | ID of the controlling task. |
An error MSG code if the MEM package has already been initialized or an error occurs.
References _MEM_Control::dump_active, _MEM_Control::dump_dest_nid, _MEM_Control::dump_fcode, _MEM_Control::dump_handle, _MEM_Control::dump_tran_id, _MEM_Control::load_handle, _MEM_Control::max_dump_pkts, MEM_Apid644, mem_change_state(), mem_create_control_block(), MEM_dumpGetContext(), MEM_dumpInit(), MEM_loadGetContext(), MEM_loadInit(), mem_map_init(), mem_pool_init(), MEM_STATE_INIT_FAIL, MEM_STATE_INITIALIZED, MEM_STATE_INITIALIZING, MEM_STATE_UNINITIALIZED, MEM_updateStats(), _MEM_Control::my_nid, _MEM_Control::my_tid, _MEM_Control::num_dump_pkts, _MEM_Control::pkt_buf_p, _MEM_Control::pkt_fcb_p, _MEM_Control::pkt_in_use, _MEM_Control::poll_enabled, _MEM_Control::poll_usecs, _MEM_Control::retries, _MEM_Control::retry_qitem_p, _MEM_Control::state, _MEM_Control::task_p, and _MEM_Control::wut_handle.
Referenced by MEM_init().
unsigned int mem_lock_access | ( | MEM_Control * | ctl_p | ) | [static] |
Lock access to a MEM control block.
ctl_p | Pointer to MEM control block. |
References _MEM_Control::mtx.
Referenced by mem_change_state(), MEM_getInfo(), and MEM_updateStats().
unsigned int mem_map_init | ( | MEM_Control * | ctl_p | ) | [static] |
Init the memory map for dumps and loads.
ctl_p | Pointer to memory control block. |
References MEM_MAP_ACCESS_32, MEM_MAP_ACCESS_ANY, MEM_MAP_ACCESS_READ_32, MEM_MAP_ACCESS_READ_ANY, MEM_mapAddEntry(), MEM_mapAddPpciEntries(), MEM_mapInit(), MEM_mapRead32Swap(), MEM_mapReadBuffer(), MEM_mapRWGeneric(), MEM_mapWrite32Swap(), MEM_mapWriteBuffer(), and mem_surom_read().
Referenced by MEM_initialize().
unsigned int mem_pool_free | ( | FPA_fcb ** | fcb_pp, | |
void ** | buf_pp, | |||
int * | in_use_p | |||
) | [static] |
Free an FPA pool.
fcb_pp | Pointer to FPA control block pointer. | |
buf_pp | Pointer to pool data buffer pointer. | |
in_use_p | Pointer to count of packets in use. |
Referenced by MEM_shutdown().
unsigned int mem_pool_init | ( | FPA_fcb ** | fcb_pp, | |
void ** | buf_pp, | |||
int * | in_use_p, | |||
unsigned int | num_pkt, | |||
unsigned int | pkt_bytes | |||
) | [static] |
Initialize an FPA pool.
fcb_pp | Pointer to location to store FPA control block pointer. | |
buf_pp | Pointer to location to store pool data buffer pointer. | |
in_use_p | Pointer to count of packets in use. | |
num_pkt | Number of packets to include in the pool. | |
pkt_bytes | Size of each packet, in bytes. |
Referenced by MEM_initialize().
void * MEM_readSurom | ( | void * | dst_p, | |
const void * | src_p, | |||
const unsigned int | num_bytes | |||
) |
Read RAD750 SUROM.
dst_p | Pointer to destination of the memory read. | |
src_p | Pointer to source of the memory read. | |
num_bytes | Number of bytes to read. |
References mem_surom_read().
unsigned int MEM_shutdown | ( | void | ) |
Shutdown the MEM functions.
This function shuts down the MEM package and transitions it back to the UNINITIALIZED state. It can be called only if the current MEM state is INITIALIZED, INIT_FAIL, or SHUTDOWN_FAIL.
An error MSG code if the MEM package is in an invalid state or an error occurs.
References _MEM_Control::dump_handle, _MEM_Control::load_handle, MEM_Apid644, mem_change_state(), MEM_dumpReleaseContext(), MEM_loadReleaseContext(), mem_pool_free(), MEM_STATE_INIT_FAIL, MEM_STATE_INITIALIZED, MEM_STATE_SHUTDOWN, MEM_STATE_SHUTDOWN_FAIL, MEM_STATE_UNINITIALIZED, MEM_updateStats(), _MEM_Control::pkt_buf_p, _MEM_Control::pkt_fcb_p, _MEM_Control::pkt_in_use, _MEM_Control::state, _MEM_Control::task_p, and _MEM_Control::wut_handle.
void * mem_surom_read | ( | void * | dest_p, | |
const void * | source_p, | |||
const size_t | nbytes, | |||
void * | context_p, | |||
size_t * | bytes_read_p | |||
) | [static] |
RAD750 SUROM read callback function.
RAD750 SUROM read function that is suitable for use as a memory map table entry callback function.
dest_p | Pointer to destination of the memory read. | |
source_p | Pointer to source of the memory read. | |
nbytes | Number of bytes to read. | |
context_p | Generic context pointer (unused). | |
bytes_read_p | Pointer to location to return number of bytes read. |
Referenced by mem_map_init(), and MEM_readSurom().
unsigned int mem_unlock_access | ( | MEM_Control * | ctl_p, | |
unsigned int | status | |||
) | [static] |
Unlock access to a MEM control block.
ctl_p | Pointer to MEM control block. | |
status | Previous status code. |
References _MEM_Control::mtx.
Referenced by mem_change_state(), MEM_getInfo(), and MEM_updateStats().
unsigned int MEM_updateStats | ( | MEM_Control * | ctl_p, | |
unsigned int | msg_status, | |||
unsigned int | fcode | |||
) |
Common routine to update MEM command statistics.
ctl_p | Pointer to MEM control block. | |
msg_status | Status MSG code for the command. | |
fcode | Function code for the command. |
References _MEM_Descriptor::addr, _MEM_Descriptor::bytes, _MEM_DumpInfo::current_addr, _MEM_Control::dump_active, _MEM_Info::dump_active, _MEM_Info::dump_addr, _MEM_Info::dump_bytes, _MEM_Control::dump_dest_nid, _MEM_Control::dump_fcode, _MEM_Info::dump_fcode, _MEM_Control::dump_handle, _MEM_Info::dump_start, _MEM_Info::dump_status, _MEM_Control::dump_tran_id, _MEM_Info::dump_tran_id, _MEM_Control::info, _MEM_LoadInfo::is_active, _MEM_Info::last_fcode, _MEM_Info::last_status, _MEM_Info::load_active, _MEM_Info::load_bytes, _MEM_Control::load_handle, _MEM_Info::load_offset, _MEM_Info::load_start, _MEM_Info::load_status, _MEM_DumpInfo::md, MEM_dumpGetInfo(), MEM_loadGetInfo(), mem_lock_access(), mem_unlock_access(), _MEM_LoadInfo::offset, _MEM_LoadInfo::start_addr, _MEM_DumpInfo::status, _MEM_LoadInfo::status, and _MEM_LoadInfo::total_bytes.
Referenced by mem_handle_dump(), MEM_initialize(), MEM_LMEMDUMPCANCEL(), MEM_LMEMDUMPNEXT(), MEM_LMEMDUMPPOOL(), MEM_LMEMDUMPSYMREL(), MEM_LMEMDUMPSYMVAL(), MEM_LMEMLOADMEM(), MEM_LMEMLOADPCI(), MEM_LMEMLOADREG(), MEM_LMEMNOOP(), and MEM_shutdown().
MEM_Control* Mem_control_p = NULL |
Pointer to the MEM control information block.
Control block for MEM.
Pointer to the control block (state) for the MEM application-level functions.
Referenced by MEM_LMEMDUMPCANCEL(), MEM_LMEMDUMPMEM(), MEM_LMEMDUMPNEXT(), MEM_LMEMDUMPPCI(), MEM_LMEMDUMPPOOL(), MEM_LMEMDUMPREG(), MEM_LMEMDUMPSYMREL(), MEM_LMEMDUMPSYMVAL(), MEM_LMEMLOADMEM(), MEM_LMEMLOADPCI(), MEM_LMEMLOADREG(), and MEM_LMEMNOOP().
unsigned char mem_sim_ram_buf |
Initial value:
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }
This buffer simulates the RAD750 RAM in a host environment.