GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> LCBD / V1-5-0 > lcbd / rad750
#include "LCBD/LCB_cr.h"
#include "LCBD/LCBD_cr.h"
#include "PBI/Attribute.h"
#include "PBI/Inline.h"
Defines | |
#define | LCBC_MAP_TYPE_BY_OPCODE |
Defines a 32-bit integer that functions as a map of the command type indexed by opcode. | |
#define | LCBC_TYPE_BY_OPCODE_FULL(_map, _opcode) |
Maps an opcode to a command item type. | |
#define | LCBC_TYPE_BY_OPCODE(_opcode) LCBC_TYPE_BY_OPCODE_FULL(LCBC_MAP_TYPE_BY_OPCODE, _opcode) |
Maps an opcode to a result item type. | |
Typedefs | |
typedef enum _LCBC_TYPE | LCBC_TYPE |
Typedef for enum _LCBC_TYPE. | |
typedef unsigned int | LCBC_processor (void *prm, const LCB_ci *ci) |
Callback routine for LCBC_process. | |
Enumerations | |
enum | _LCBC_TYPE { LCBC_TYPE_UNDEFINED = 0, LCBC_TYPE_SIMPLE = 1, LCBC_TYPE_REGISTER = 2, LCBC_TYPE_COMMAND = 3, LCBC_TYPE_EVENT = 4 } |
Enumerates the four defined command item types + one undefined type. More... | |
Functions | |
LCBC__EXP_PROTO const void * | LCBC__advance (const LCB_ci *ci, int nbytes) ATTR_UNUSED_OK |
Advances the pointer ci by the specified number of bytes. | |
LCBC__EXP_PROTO const LCB_ci * | LCBC__next (const LCB_ci *ci) ATTR_UNUSED_OK |
Advances the pointer ci to the next command item. | |
LCBC__EXP_PROTO LCB_ci * | LCBC__mark_time_fill (LCB_ci_mark_time *ci, unsigned short int stall) ATTR_UNUSED_OK |
Constructs a mark time LCB command. | |
LCBC__EXP_PROTO LCB_ci * | LCBC__event_fill (LCB_ci_event *ci, unsigned int latp_adr, unsigned int proto, unsigned int len32, unsigned short int stall) ATTR_UNUSED_OK |
Constructs event transmit command, without a response. | |
LCBC__EXP_PROTO LCB_ci * | LCBC__cmd_xmit_fill (LCB_ci_cmd *ci, const LCB_ci_cmd_payload *payload, unsigned short int stall) ATTR_UNUSED_OK |
Constructs transmit command, without a response. | |
LCBC__EXP_PROTO LCB_ci * | LCBC__lat_reset_fill (LCB_ci_lat_reset *ci, unsigned short int stall) ATTR_UNUSED_OK |
Constructs a LAT reset LCB command. | |
LCBC__EXP_PROTO LCB_ci * | LCBC__cmdr_xmit_fill (LCB_ci_cmdr *ci, const LCB_ci_cmd_payload *payload, unsigned short int timeout) ATTR_UNUSED_OK |
Constructs transmit command, with a response. | |
LCBC__EXP_PROTO LCB_ci * | LCBC__csr_access_fill (LCB_ci_csr *ci, unsigned int value, unsigned int field_select, unsigned short int stall) ATTR_UNUSED_OK |
Constructs a LCB CSR register access command. | |
LCBC__EXP_PROTO LCB_ci * | LCBC__faults_access_fill (LCB_ci_faults *ci, unsigned int value, unsigned int field_select, unsigned short int stall) ATTR_UNUSED_OK |
Constructs a LCB FIFO FAULTS register access command. | |
LCBC__EXP_PROTO LCB_ci * | LCBC__rxstats_access_fill (LCB_ci_rxstats *ci, unsigned int value, unsigned int field_select, unsigned short int stall) ATTR_UNUSED_OK |
Constructs a LCB Receive Statistics/Status register access command. | |
LCB_ci * | LCBC_mark_time_fill (LCB_ci_mark_time *ci, unsigned short int stall) |
Constructs a mark time LCB command. | |
LCB_ci * | LCBC_event_fill (LCB_ci_event *ci, unsigned int latp_adr, unsigned int proto, unsigned int len32, unsigned short int stall) |
Constructs event transmit command. | |
LCB_ci * | LCBC_lat_reset_fill (LCB_ci_lat_reset *ci, unsigned short int stall) |
Constructs a LAT reset LCB command. | |
LCB_ci * | LCBC_csr_access_fill (LCB_ci_csr *ci, unsigned int value, unsigned int field_select, unsigned short int stall) |
Constructs a LCB CSR register access command. | |
LCB_ci * | LCBC_faults_access_fill (LCB_ci_faults *ci, unsigned int value, unsigned int field_select, unsigned short int stall) |
Constructs a LCB FIFO FAULTS register access command. | |
LCB_ci * | LCBC_rxstats_access_fill (LCB_ci_rxstats *ci, unsigned int value, unsigned int field_select, unsigned short int stall) |
Constructs a LCB RECEIVE STATISTICS/STATUS register access command. | |
unsigned int | LCBC_process (const LCB_ci *ci, const LCB_ci *end, LCBC_processor rtn, void *prm) |
Executes the user specified handler for each command item in the range ci to end. | |
void | LCBC_show (unsigned int options, const LCB_ci *beg, const LCB_ci *end) |
Dumps the result items to stdout. | |
unsigned int | LCBC_cmd_xmit (LCBD lcb, const LCB_ci_cmd_payload *payload, unsigned short int stall) |
Utility routine to compose and submit a command with no response command (department of redundancy department?). | |
unsigned int | LCBC_mark_time (LCBD lcb, unsigned short int stall) |
Utility routine to compose and execute an LCB mark time command. | |
unsigned int | LCBC_lat_reset (LCBD lcb, unsigned short int stall) |
Utility routine to compose and execute an LCB LAT reset command. | |
unsigned int | LCBC_cmdr_xmit (LCBD lcb, const LCB_ci_cmd_payload *ci_payload, unsigned short int timeout, LCB_ri_cmd_payload *ri_payload) |
Utility routine to compose and submit a command with response command (department of redundancy department?). | |
unsigned int | LCBC_csr_access (LCBD lcb, unsigned int value, unsigned int field_select, unsigned short int stall, unsigned int *old_val, unsigned int *cur_val) |
Utility routine to compose and execute an access command to LCB's CSR register. | |
unsigned int | LCBC_faults_access (LCBD lcb, unsigned int value, unsigned int field_select, unsigned short int stall, unsigned int *old_val, unsigned int *cur_val) |
Utility routine to compose and execute an access command to LCB's FIFO FAULTS register. | |
unsigned int | LCBC_rxstats_access (LCBD lcb, unsigned int value, unsigned int field_select, unsigned short int stall, unsigned int *old_val, unsigned int *cur_val) |
Utility routine to compose and execute an access command to LCB's RECEIVE STATISTICS/STATS register. |
CVS $Id
These map out the data structure of command items. See chapter 3 & 4 of Mike Huffer's "LAT Communications Board -- Design Specification" for more details.
#define LCBC_MAP_TYPE_BY_OPCODE |
Value:
( \ (LCBC_TYPE_COMMAND << (3 * LCB_OPCODE_CMD )) | \ (LCBC_TYPE_SIMPLE << (3 * LCB_OPCODE_MARK_TIME )) | \ (LCBC_TYPE_EVENT << (3 * LCB_OPCODE_EVENT )) | \ (LCBC_TYPE_SIMPLE << (3 * LCB_OPCODE_LAT_RESET )) | \ (LCBC_TYPE_COMMAND << (3 * LCB_OPCODE_CMDR )) | \ (LCBC_TYPE_REGISTER << (3 * LCB_OPCODE_CSR )) | \ (LCBC_TYPE_UNDEFINED << (3 * LCB_OPCODE_6 )) | \ (LCBC_TYPE_REGISTER << (3 * LCB_OPCODE_FAULTS )) | \ (LCBC_TYPE_UNDEFINED << (3 * LCB_OPCODE_8 )) | \ (LCBC_TYPE_REGISTER << (3 * LCB_OPCODE_RXSTATS )) \ )
The 32-bit integer functions as a map of the command type indexed by opcode. Each command type consumes 3 bits. Given that there are 16 potential opcodes, it takes 48 bits to define the map. This means the map cannot be contained in a 32 bit integer. Ah, but wait, only the first ten opcodes are actually defined. So we can cheat, and only define the first ten. Indexing by greater than 32 will produce a 0.
type = opcode <= 10 ? ((LCBC_MAP_TYPE_BY_OPCODE >> (3 * opcode)) & 0x3) : LCBC_TYPE_UNDEFINED;
There are 16 opcodes, that map to 5 descriptor types
0 LCB_OPCODE_CMD = LCBC_TYPE_COMMAND 1 LCB_OPCODE_MARK_TIME = LCBC_TYPE_SIMPLE 2 LCB_OPCODE_EVENT = LCBC_TYPE_EVENT 3 LCB_OPCODE_LAT_RESET = LCBC_TYPE_SIMPLE 4 LCB_OPCODE_CMDR = LCBC_TYPE_COMMAND 5 LCB_OPCODE_CSR = LCBC_TYPE_REGISTER 6 LCB_OPCODE_6 = LCBC_TYPE_UNDEFINED 7 LCB_OPCODE_FAULTS = LCBC_TYPE_REGISTER 8 LCB_OPCODE_8 = LCBC_TYPE_UNDEFINED 9 LCB_OPCODE_RXSTATS = LCBC_TYPE_REGISTER A LCB_OPCODE_A = LCBC_TYPE_UNDEFINED B LCB_OPCODE_B = LCBC_TYPE_UNDEFINED C LCB_OPCODE_C = LCBC_TYPE_UNDEFINED D LCB_OPCODE_D = LCBC_TYPE_UNDEFINED E LCB_OPCODE_E = LCBC_TYPE_UNDEFINED F LCB_OPCODE_F = LCBC_TYPE_UNDEFINED
#define LCBC_TYPE_BY_OPCODE | ( | _opcode | ) | LCBC_TYPE_BY_OPCODE_FULL(LCBC_MAP_TYPE_BY_OPCODE, _opcode) |
Maps an opcode to a result item type.
_opcode | The opcode to map |
#define LCBC_TYPE_BY_OPCODE_FULL | ( | _map, | |||
_opcode | ) |
Maps an opcode to a command item type.
_map | The mapping word. | |
_opcode | The opcode to map |
unsigned int LCBC_processor |
Callback routine for LCBC_process.
prm | Arbitrary user parameter passed to this routine | |
ci | The command item to process |
enum _LCBC_TYPE |
Enumerates the four defined command item types + one undefined type.
LCBC__EXP_FNC const void * LCBC__advance | ( | const LCB_ci * | ci, | |
int | nbytes | |||
) |
Advances the pointer ci by the specified number of bytes.
ci | Thehe command item pointer to advance | |
nbytes | The number of bytes to advance the pointer |
LCBC__EXP_FNC LCB_ci * LCBC__cmd_xmit_fill | ( | LCB_ci_cmd * | ci, | |
const LCB_ci_cmd_payload * | payload, | |||
unsigned short int | stall | |||
) |
Constructs transmit command, without a response.
ci | The command item to be filled. | |
payload | The transmit command's payload. This consists of a LATp header plus a highly encoded bit pattern which determines further routing and the action to be taken at the destination | |
stall | The stall period, in units of 20MHz clock ticks |
LCBC__EXP_FNC LCB_ci * LCBC__cmdr_xmit_fill | ( | LCB_ci_cmdr * | ci, | |
const LCB_ci_cmd_payload * | payload, | |||
unsigned short int | timeout | |||
) |
Constructs transmit command, with a response.
ci | The command item to be filled. | |
payload | The transmit command's payload. This consists of a LATp header plus a highly encoded bit pattern which determines further routing and the action to be taken at the destination | |
timeout | The timeout perion, in units of 20MHz clock ticks |
LCBC__EXP_FNC LCB_ci * LCBC__csr_access_fill | ( | LCB_ci_csr * | ci, | |
unsigned int | field_select, | |||
unsigned int | value, | |||
unsigned short int | stall | |||
) |
Constructs a LCB CSR register access command.
ci | The command item to be filled | |
field_select | A word indicating the bits from value that will be written. For example, if 0, then no bits will be written, if -1, then all bits will be written. | |
value | The value to be written | |
stall | The stall time, in units of 20MHz clock ticks |
LCBC__EXP_FNC LCB_ci * LCBC__event_fill | ( | LCB_ci_event * | ci, | |
unsigned int | latp_adr, | |||
unsigned int | proto, | |||
unsigned int | len32, | |||
unsigned short int | stall | |||
) |
Constructs event transmit command, without a response.
ci | The event transmit command item to be filled. | |
latp_adr | The destination LATp address | |
proto | The protocol | |
len32 | The length of the data to be transformed in 32 bit words. This must be a multiple of 4, since the LCB transfer engine works in units of 16-byte cells. This length must include the LATP packet header word. | |
stall | The stall period, in units of 20MHz clock ticks |
#define LATP_ADR 22 #define PROTO 2 #define STALL 10 fill (LCB_ci_event *ci, unsigned int *dst, int len32) { unsigned short *dst = ci->data; memcpy (dst, src, len32 * sizeof (int)); len32 += 1; // Add on the length of the LATP_pckt_hdr len32 = (len32 + 3) & ~03; // Round to a multiple of 4 integers return LCBC__event_fill (ci, 22, LATP_ADR, PROTO, len32, STALL); }
LCBC__EXP_FNC LCB_ci * LCBC__faults_access_fill | ( | LCB_ci_faults * | ci, | |
unsigned int | field_select, | |||
unsigned int | value, | |||
unsigned short int | stall | |||
) |
Constructs a LCB FIFO FAULTS register access command.
ci | The command item to be filled | |
field_select | A word indicating the bits from value that will be written. For example, if 0, then no bits will be written, if -1, then all bits will be written. | |
value | The value to be written | |
stall | The stall time, in units of 20MHz clock ticks |
LCBC__EXP_FNC LCB_ci * LCBC__lat_reset_fill | ( | LCB_ci_lat_reset * | ci, | |
unsigned short int | stall | |||
) |
Constructs a LAT reset LCB command.
ci | The command item to be filled. | |
stall | The stall time, in units of 20MHz clock ticks |
LCBC__EXP_FNC LCB_ci * LCBC__mark_time_fill | ( | LCB_ci_mark_time * | ci, | |
unsigned short int | stall | |||
) |
Constructs a mark time LCB command.
ci | The command item to be filled. | |
stall | The stall time, in units of 20MHz clock ticks |
Advances the pointer ci to the next command item.
ci | The command item |
LCBC__EXP_FNC LCB_ci * LCBC__rxstats_access_fill | ( | LCB_ci_rxstats * | ci, | |
unsigned int | field_select, | |||
unsigned int | value, | |||
unsigned short int | stall | |||
) |
Constructs a LCB Receive Statistics/Status register access command.
ci | The command item to be filled | |
field_select | A word indicating the bits from value that will be written. For example, if 0, then no bits will be written, if -1, then all bits will be written. | |
value | The value to be written | |
stall | The stall time, in units of 20MHz clock ticks |
unsigned int LCBC_cmd_xmit | ( | LCBD | lcb, | |
const LCB_ci_cmd_payload * | payload, | |||
unsigned short int | stall | |||
) |
Utility routine to compose and submit a command with no response command (department of redundancy department?).
lcb | The LCB driver handle | |
payload | The payload of the command access command. The format of this beast is dependent on the target (PDU, TEM, GTFE) and is non-trivial. However, this routine does not concern itself with the formatting, deferring that as someone else's problem. | |
stall | The stall time, in units of 20Mhz clock ticks |
unsigned int LCBC_cmdr_xmit | ( | LCBD | lcb, | |
const LCB_ci_cmd_payload * | ci_payload, | |||
unsigned short int | timeout, | |||
LCB_ri_cmd_payload * | ri_payload | |||
) |
Utility routine to compose and submit a command with response command (department of redundancy department?).
lcb | The LCB driver handle | |
ci_payload | The payload of the command access command. The format of this beast is dependent on the target (PDU, TEM, GTFE) and is non-trivial. However, this routine does not concern itself with the formatting, deferring that as someone else's problem. | |
timeout | The LCB timeout period, in units of 20MHz clock ticks to wait for a response to be returned. | |
ri_payload | The resulting (returned) payload. As is in the case of the command item payload, ci_payload, the format of this payload is highly dependent on the target. However, this routine merely returns the payload results to the user, again adopting the philosopy of not my problem, |
unsigned int LCBC_csr_access | ( | LCBD | lcb, | |
unsigned int | value, | |||
unsigned int | field_select, | |||
unsigned short int | stall, | |||
unsigned int * | old_val, | |||
unsigned int * | cur_val | |||
) |
Utility routine to compose and execute an access command to LCB's CSR register.
lcb | The LCB driver handle | |
value | The value to write. Only bits matching those in the field_select parameter will actually be written. | |
field_select | Pattern of those bits in value to write | |
stall | The stall time, in units of 20MHz clock ticks, for the LCB to wait for completion. | |
old_val | Pointer to receive the value of the register before modification. This may be NULL. | |
cur_val | Pointer to receive the value of the register after modification. This may be NULL. |
LCB_ci* LCBC_csr_access_fill | ( | LCB_ci_csr * | ci, | |
unsigned int | value, | |||
unsigned int | field_select, | |||
unsigned short int | stall | |||
) |
Constructs a LCB CSR register access command.
ci | The command item to be filled | |
field_select | A word indicating the bits from value that will be written. For example, if 0, then no bits will be written, if -1, then all bits will be written. | |
value | The value to be written | |
stall | The stall time, in units of 20MHz clock ticks |
LCB_ci * LCBC_event_fill | ( | LCB_ci_event * | ci, | |
unsigned int | latp_adr, | |||
unsigned int | proto, | |||
unsigned int | len32, | |||
unsigned short int | stall | |||
) |
Constructs event transmit command.
ci | The event transmit command item to be filled. | |
latp_adr | The destination LATp address | |
proto | The protocol | |
len32 | The length of the data to be transformed in 32 bit words. This must be a multiple of 4, since the LCB transfer engine works in units of 16-byte cells | |
stall | The stall period, in units of 20MHz clock ticks |
#define LATP_ADR 22 #define PROTO 2 #define STALL 10 fill (LCB_ci_event *ci, unsigned int *dst, int len32) { unsigned short *dst = ci->data; memcpy (dst, src, len32 * sizeof (int)); return LCBC_event_fill (ci, 22, LATP_ADR, PROTO, len32, STALL); }
unsigned int LCBC_faults_access | ( | LCBD | lcb, | |
unsigned int | value, | |||
unsigned int | field_select, | |||
unsigned short int | stall, | |||
unsigned int * | old_val, | |||
unsigned int * | cur_val | |||
) |
Utility routine to compose and execute an access command to LCB's FIFO FAULTS register.
lcb | The LCB driver handle | |
value | The value to write. Only bits matching those in the field_select parameter will actually be written. | |
field_select | Pattern of those bits in value to write | |
stall | The stall time, in units of 20MHz clock ticks, for the LCB to wait for completion. | |
old_val | Pointer to receive the value of the register before modification. This may be NULL. | |
cur_val | Pointer to receive the value of the register after modification. This may be NULL. |
LCB_ci* LCBC_faults_access_fill | ( | LCB_ci_faults * | ci, | |
unsigned int | value, | |||
unsigned int | field_select, | |||
unsigned short int | stall | |||
) |
Constructs a LCB FIFO FAULTS register access command.
ci | The command item to be filled | |
field_select | A word indicating the bits from value that will be written. For example, if 0, then no bits will be written, if -1, then all bits will be written. | |
value | The value to be written | |
stall | The stall time in units of 20MHz clock ticks |
unsigned int LCBC_lat_reset | ( | LCBD | lcb, | |
unsigned short int | stall | |||
) |
Utility routine to compose and execute an LCB LAT reset command.
lcb | The LCB driver handle | |
stall | The stall time, in units of 20Mhz clock ticks |
LCB_ci* LCBC_lat_reset_fill | ( | LCB_ci_lat_reset * | ci, | |
unsigned short int | stall | |||
) |
Constructs a LAT reset LCB command.
ci | The command item to be filled. | |
stall | The stall time, in units of 20MHz clock ticks |
unsigned int LCBC_mark_time | ( | LCBD | lcb, | |
unsigned short int | stall | |||
) |
Utility routine to compose and execute an LCB mark time command.
lcb | The LCB driver handle | |
stall | The stall time, in units of 20Mhz clock ticks |
LCB_ci* LCBC_mark_time_fill | ( | LCB_ci_mark_time * | ci, | |
unsigned short int | stall | |||
) |
Constructs a mark time LCB command.
ci | The command item to be filled. | |
stall | The stall time, in units of 20MHz clock ticks |
unsigned int LCBC_process | ( | const LCB_ci * | ci, | |
const LCB_ci * | end, | |||
LCBC_processor | rtn, | |||
void * | prm | |||
) |
Executes the user specified handler for each command item in the range ci to end.
ci | The first command item to process | |
end | One past the last command item to process | |
rtn | User provided callback routine to process one item | |
prm | User provided parameter passed to rtn |
unsigned int LCBC_rxstats_access | ( | LCBD | lcb, | |
unsigned int | value, | |||
unsigned int | field_select, | |||
unsigned short int | stall, | |||
unsigned int * | old_val, | |||
unsigned int * | cur_val | |||
) |
Utility routine to compose and execute an access command to LCB's RECEIVE STATISTICS/STATS register.
lcb | The LCB driver handle | |
value | The value to write. Only bits matching those in the field_select parameter will actually be written. | |
field_select | Pattern of those bits in value to write | |
stall | The stall time, in units of 20MHz clock ticks, for the LCB to wait for completion. | |
old_val | Pointer to receive the value of the register before modification. This may be NULL. | |
cur_val | Pointer to receive the value of the register after modification. This may be NULL. |
LCB_ci* LCBC_rxstats_access_fill | ( | LCB_ci_rxstats * | ci, | |
unsigned int | value, | |||
unsigned int | field_select, | |||
unsigned short int | stall | |||
) |
Constructs a LCB RECEIVE STATISTICS/STATUS register access command.
ci | The command item to be filled | |
field_select | A word indicating the bits from value that will be written. For example, if 0, then no bits will be written, if -1, then all bits will be written. | |
value | The value to be written | |
stall | The stall time, in units of 20MHz clock ticks |
Dumps the result items to stdout.
options | Show options | |
beg | Pointer to the first result descriptor to show | |
end | Pointer to one past the lst result descriptor to show |