GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> LCBD / V1-5-0 > lcbb / rad750
#include <string.h>
#include "PBS/SPIN.h"
#include "PBS/SPIN.ih"
#include "PBS/BSWP.ih"
#include "LCBD/LCBB.h"
#include "LCBD/LATP.h"
#include "LCBD/LCBB_msgs.h"
#include "LCBD/LCB_cr.h"
Classes | |
| struct | _LCBB_err_rst_maps |
| Maps to take a result transfer/receive error/status value, into a standard message code. More... | |
| struct | _LCBB_err_evt_maps |
| Maps to take an event transfer/receive error/status value, into a standard message code. More... | |
| struct | _LCBB_err_maps |
| Provides mapping arrays to take an LCB hardware error code into a LCB message code. More... | |
Defines | |
| #define | CHECK_EQ(n, a, b) struct Check_ ## n { int x[1 / (a == b) ]; } |
| Checks is a = b, and if not the compiler will issue an error. | |
| #define | LCBB_XTIME_REGISTER 10000 |
| Estimate of a register access time, in nanoseconds. | |
| #define | LCBB_XTIME_FUNCTION 10000 |
| Estimate of a function execution time, in nanoseconds. | |
| #define | LCBB_XTIME_EVENT_TRANSFER 10000 |
| Estimate of a event transfer overhead, in nanoseconds. | |
| #define | LCBB_XTIME_TIMEOUT 60000000 |
| Estimate of LCB event transfer timeout period. | |
| #define | LCBB_CLK_FREQ 20000000 |
| The default LCB LATp clock frequency (nominally 20MHz). | |
| #define | LCBB_NSECS_PER_TICK 50 |
| The default LCB LATp clock speed (nominally 20MHz = 50nsec/tick). | |
| #define | LCBB_BITS_PER_TICK 1 |
| The default LCB DMA output transfer speed. This is always 1 bit/tick (20Mbits/sec) independent of the bit/byte of the input interface. | |
| #define | LCBB_RST_DRAIN_TIMEOUT ((unsigned int)(3 * LCBB_CLK_FREQ)) |
| The result drain timeout period, in units of LCBB clock ticks. This is the maximum time that the function will wait for the sweeping transaction to be returned. | |
| #define | LCBB_XTIME_EVENT_TRANSFER_BY_INTS(_nints) |
| Estimates the time to get submit and get the result descriptor back for an event transfer of _nints. | |
Typedefs | |
|
typedef struct _LCBB_err_rst_maps | LCBB_err_rst_maps |
| Typedef for struct _LCBB_err_rst_maps. | |
|
typedef struct _LCBB_err_evt_maps | LCBB_err_evt_maps |
| Typedef for struct _LCBB_err_evt_maps. | |
| typedef struct _LCBB_err_maps | LCBB_err_maps |
| Typedef for struct _LCBB_err_maps. | |
Functions | |
| static __inline void | pciStore32 (volatile unsigned int *dst, unsigned int w) |
| Write a 32-bit integer to PCI Memory. | |
| static __inline unsigned int | pciLoad32 (volatile unsigned int *src) |
| Read a 32-bit integer from PCI Memory. | |
| static __inline unsigned int | clear_faults (LCBB lcb, unsigned short timeout) |
| Clears the FIFO faults register. | |
| static unsigned int | access_function (LCBB lcb, unsigned short stall, unsigned int header, unsigned int poll_timeout) |
| Performs an access to the specified LCB slave-side LATP function. | |
| static unsigned int | access_reg (LCBB lcb, unsigned int value, unsigned int field_select, unsigned short int stall, unsigned int *prv, unsigned int *cur, unsigned int header, unsigned int poll_timeout) |
| Performs an access to the specified LCB slave-side LATP register. | |
| static unsigned int | poll (LCBB lcb, unsigned int poll_period, unsigned int timeout, unsigned short int op_len, const void *result, const LCB_ri_err *ri_err) |
| Polls the RESULT FIFO every nsecs for @ iterations. | |
| static __inline unsigned int | submit (LCBB lcb, unsigned int request) |
| Submits the specified request list to the LCB for execution. | |
| static unsigned int | execute (LCBB lcb, unsigned int request, unsigned int xtime, unsigned int timeout, unsigned short int op_len, void *result, LCB_ri_err *ri_err) |
| Has the LCB's command execution routine execute the specified single item request. The result list and result item is checked for successful completion. | |
| static unsigned int | init_pci (LCBB lcb) |
| Initializes the LCB structure -- probes the PCI bus. | |
| static unsigned int | init_latp (LCBB lcb) |
| Laundry list of LCB initializations to do on the LATp side. | |
| static void | init_circ (LCBB lcb) |
| Allocates memory for and sets it up to be used as the circular buffer. | |
| static unsigned int | drain_result (LCBB lcb) |
| Drains the result FIFOs. | |
| static unsigned int | drain_event (LCBB lcb) |
| Drains the event FIFOs. | |
| static __inline unsigned int | mapXfrErr (const LCBB_err_rst_maps *maps, unsigned int err) |
| Maps a result descriptor status into an error code. | |
| static __inline unsigned int | mapRcvErr (const LCBB_err_rst_maps *maps, unsigned int err) |
| Maps a result item status into an error code. | |
| LCBB | LCBB_configure (unsigned int latp, void *requestList, void *resultList, void *circBuffer) |
| Returns a pointer to the LCB control structure, with the specified configuration parameters. | |
| unsigned int | LCBB_init (LCBB lcb) |
| Initializes the LCB structure for polled mode. | |
| unsigned int | LCBB_check (LCBB lcb, LCBB_msg *msg) |
| Maps the LCB error codes to a LCB message code. | |
| unsigned int | LCBB_free (LCBB lcb, LCBB_msg *msg) |
| unsigned char * | LCBB_locate (LCBB lcb) |
| Returns a pointer to payload. | |
| LCBB_msg * | LCBB_receive (LCBB lcb) |
| Reads the event FIFO for descriptors. | |
| unsigned int | LCBB_send (LCBB lcb, unsigned int dst, unsigned int proto, int nbytes) |
| Sends the data. | |
| unsigned int | LCBB_start (LCBB lcb) |
| Enables the LCB for taking event data. | |
| unsigned int | LCBB_mark_time (LCBB lcb, unsigned short int stall) |
| Issues a Mark Time command to the LCB. | |
| unsigned int | LCBB_lat_reset (LCBB lcb, unsigned short int stall) |
| Issues a LAT reset. | |
| unsigned int | LCBB_csr_access (LCBB lcb, unsigned int value, unsigned int field_select, unsigned short int timeout, unsigned int *prv, unsigned int *cur) |
| Does an access of the LATp CSR register. | |
| unsigned int | LCBB_faults_access (LCBB lcb, unsigned int value, unsigned int field_select, unsigned short int timeout, unsigned int *prv, unsigned int *cur) |
| Does an access of the LATp CSR register. | |
| unsigned int | LCBB_rxstats_access (LCBB lcb, unsigned int value, unsigned int field_select, unsigned short int timeout, unsigned int *prv, unsigned int *cur) |
| Does an access of the LATp Receive Statistics/Status register. | |
Variables | |
|
static const LCBB_err_maps | LcbbErrMaps |
| Realization of the LCB error to message code mapping arrays. | |
| struct _LCBB | Lcbb |
| The LCB driver control block. | |
CVS $Id
| #define CHECK_EQ | ( | n, | |||
| a, | |||||
| b | ) | struct Check_ ## n { int x[1 / (a == b) ]; } |
Checks is a = b, and if not the compiler will issue an error.
| n | Unique identifying string (helps isolate the error) | |
| a | The value to check | |
| b | The value to check |
| #define LCBB_XTIME_EVENT_TRANSFER_BY_INTS | ( | _nints | ) |
Value:
(LCBB_XTIME_EVENT_TRANSFER \ + (((_nints) * 32) * LCBB_NSECS_PER_TICK) / LCBB_BITS_PER_TICK);
time = Submit_Time + Pci_Dma_Time + Lat_Dma_Time + Lcb_timeout
+ Lat_Result_Dsc_Write + Pci_Result_Dsc_Write
Fixed_Time = Submit_Time + Lat_Result_Dsc_Write + Pci_Result_Dsc_Write
Dma_Time = Pci_Dma_Time + Lat_Dma_Time
Typedef for struct _LCBB_err_maps.
Combines the Result and Event mapping data structures
| static unsigned int access_function | ( | LCBB | lcb, | |
| unsigned short | stall, | |||
| unsigned int | header, | |||
| unsigned int | poll_timeout | |||
| ) | [static] |
Performs an access to the specified LCB slave-side LATP function.
| lcb | The LCB driver handle | |
| stall | The stall time, in units of LATp clocks | |
| header | The header word, giving the length and opcode | |
| poll_timeout | The poll loop timeout value, in units of nanoseconds |
| static unsigned int access_reg | ( | LCBB | lcb, | |
| unsigned int | value, | |||
| unsigned int | field_select, | |||
| unsigned short int | stall, | |||
| unsigned int * | prv, | |||
| unsigned int * | cur, | |||
| unsigned int | header, | |||
| unsigned int | poll_timeout | |||
| ) | [static] |
Performs an access to the specified LCB slave-side LATP register.
| lcb | The LCB driver handle | |
| value | The 32-bit value to write | |
| field_select | A bit mask indicating which fields should be written | |
| stall | A stall or timeout value (in units of LATp clocks) | |
| prv | Pointer to return the previous value of the register | |
| cur | Pointer to return the current value of the register | |
| header | The header word | |
| poll_timeout | The poll loop timeout value, in units of nanoseconds |
| unsigned int clear_faults | ( | LCBB | lcb, | |
| unsigned short | timeout | |||
| ) | [static] |
Clears the FIFO faults register.
| lcb | The LCB driver handle | |
| timeout | A timeout value (in units of LATp clocks) |
| static unsigned int drain_event | ( | LCBB | lcb | ) | [static] |
Drains the event FIFOs.
| 0,if | successfully drained | |
| LCB | message code it had errors |
| lcb | Initialized LCBB handle |
| static unsigned int drain_result | ( | LCBB | lcb | ) | [static] |
Drains the result FIFOs.
| 0,if | successfully drained | |
| LCB | message code it had errors |
| lcb | Initialized LCBB handle |
| static unsigned int execute | ( | LCBB | lcb, | |
| unsigned int | request, | |||
| unsigned int | xtime, | |||
| unsigned int | timeout, | |||
| unsigned short int | op_len, | |||
| void * | result, | |||
| LCB_ri_err * | ri_err | |||
| ) | [static] |
Has the LCB's command execution routine execute the specified single item request. The result list and result item is checked for successful completion.
| LCBB_OK,if | okay | |
| LCBB_REQFULL,if | the transaction could not submitted to the LCB because the request queue is full | |
| LCBB_NULLDSC,if,when | polling for the result, the NULL descriptor was the only transaction found | |
| LCBB_ROGUE,if,when | polling for the result, a ROGUE transaction was the only transaction found. |
| lcb | The LCBB driver handle | |
| request | A pointer to a properly built (address | length) request. The transformation for local to PCI space is done in this routine. | |
| xtime | The estimate time to do the transaction, in nanoseconds | |
| timeout | An additional timeout period to be added to the transaction time, in nanoseconds | |
| op_len | Opcode and length piece of the ols field | |
| result | Address of the expected result list. | |
| ri_err | Pointer to the result item's error field. |
| static void init_circ | ( | LCBB | lcb | ) | [static] |
Allocates memory for and sets it up to be used as the circular buffer.
| lcb | The lcb handle |
| static unsigned int init_latp | ( | LCBB | lcb | ) | [static] |
Laundry list of LCB initializations to do on the LATp side.
| lcb | A previously PCI initialized LCBB handle |
| static unsigned int init_pci | ( | LCBB | lcb | ) | [static] |
Initializes the LCB structure -- probes the PCI bus.
| lcb | Pointer to the private LCBB structure |
| LCBB_OK | for success, | |
| LCBB_PCIFAIL,if | the board cannot be found. | |
| LCBB_PCIMAPPL,if | the translation of local address to PCI address fails | |
| LCBB_PCIMAPLP,if | the address mapping fails |
Maps the LCB error codes to a LCB message code.
| LCBB_OK | if message is okay | |
| LCB | message code if not |
| lcb | Pointer to private LCB structure | |
| msg | The LCB message |
| LCB LCBB_configure | ( | unsigned int | latp, | |
| void * | requestList, | |||
| void * | resultList, | |||
| void * | circBuffer | |||
| ) |
Returns a pointer to the LCB control structure, with the specified configuration parameters.
| latp | The LATp configuration information presented as 16 select bits and 16 value bits. Only those bits with their corresponding select bits set will be altered. | |
| requestList | An array of 4096 bytes aligned on a 512 byte boundary. This memory will be used to construct request lists. It is from this memory that space for LCB-to-LCB traffic, |
| resultList | As array of 4096 bytes aligned on a 16 byte boundary. This memory will be used to hold result lists. | |
| circBuffer | An array of LCB_CIRC_BUFFER_TOTAL (640Kbytes) align on a LCB_CIRC_BUFFER_ALIGN (1Mbyte) boundary. This memory will be used to hold incoming 'event' traffic. |
SIU EPU
commander 1 -
evt_path - -
cmd_path - -
hdr_parity - -
payload_parity - -
pause_test - -
pause_stick - -
board_id v -
byte_wide v -
LCBB_latp_cfg latp; latp.ui = 0; latp.sv.value.command = 1; latp.sv.value.board_id = board_id; latp.sv.value.byte_wide = 1; latp.sv.select.command = LCBB_LATP_SELECT; latp.sv.select.board_id = LCBB_LATP_SELECT; latp.sv.select.byte_wide = LCBB_LATP_SELECT; LCBB_configure (latp.ui, requestList, resultList, circBuffer);
| unsigned int LCBB_csr_access | ( | LCBB | lcb, | |
| unsigned int | value, | |||
| unsigned int | field_select, | |||
| unsigned short int | timeout, | |||
| unsigned int * | prv, | |||
| unsigned int * | cur | |||
| ) |
Does an access of the LATp CSR register.
| lcb | Pointer to the LCBB control structure | |
| value | The value to write to the register | |
| field_select | A bit map indicating which fields of value should be written to the register. | |
| timeout | The number of 20MHz ticks that the LCB should wait for a response before timing out. | |
| prv | A pointer to receive the previous value | |
| cur | A pointer to receive the current value |
| unsigned int LCBB_faults_access | ( | LCBB | lcb, | |
| unsigned int | value, | |||
| unsigned int | field_select, | |||
| unsigned short int | timeout, | |||
| unsigned int * | prv, | |||
| unsigned int * | cur | |||
| ) |
Does an access of the LATp CSR register.
| lcb | Pointer to the LCBB control structure | |
| value | The value to write to the register | |
| field_select | A bit map indicating which fields of value should be written to the register. | |
| timeout | The number of 20MHz ticks that the LCB should wait for a response before timing out. | |
| prv | A pointer to receive the previous value | |
| cur | A pointer to receive the current value |
| lcb | Pointer to private LCB structure | |
| msg | Pointer to a pointer to a message |
| unsigned int LCBB_init | ( | LCBB | lcb | ) |
Initializes the LCB structure for polled mode.
| lcb | Pointer to private LCB structure |
| unsigned int LCBB_lat_reset | ( | LCBB | lcb, | |
| unsigned short int | stall | |||
| ) |
Issues a LAT reset.
| lcb | Pointer to the LCBB control structure | |
| stall | The stall time, in units of 20MHz ticks until the next command can be issued. |
| unsigned char * LCBB_locate | ( | LCBB | lcb | ) |
Returns a pointer to payload.
| lcb | Pointer to private LCB structure |
| unsigned int LCBB_mark_time | ( | LCBB | lcb, | |
| unsigned short int | stall | |||
| ) |
Issues a Mark Time command to the LCB.
| lcb | Pointer to the LCBB control structure | |
| stall | The amount of time to stall, in units of 20MHz ticks |
Reads the event FIFO for descriptors.
| lcb | Pointer to private LCBB structure |
| If | there is a message, a pointer to the received message | |
| If | these is no message, NUL, |
| unsigned int LCBB_rxstats_access | ( | LCBB | lcb, | |
| unsigned int | value, | |||
| unsigned int | field_select, | |||
| unsigned short int | timeout, | |||
| unsigned int * | prv, | |||
| unsigned int * | cur | |||
| ) |
Does an access of the LATp Receive Statistics/Status register.
| lcb | Pointer to the LCBB control structure | |
| value | The value to write to the register | |
| field_select | A bit map indicating which fields of value should be written to the register. | |
| timeout | The number of 20MHz ticks that the LCB should wait for a response before timing out. | |
| prv | A pointer to receive the previous value | |
| cur | A pointer to receive the current value |
| unsigned int LCBB_send | ( | LCBB | lcb, | |
| unsigned int | dst, | |||
| unsigned int | proto, | |||
| int | nbytes | |||
| ) |
Sends the data.
| lcb | Pointer to private LCBB structure | |
| dst | LATp destination fabric address, physical | |
| proto | 2-bit LATp protocol to use when sending bulk data | |
| nbytes | The number of bytes to send. Note that this length must include the 4 bytes of the LATP packet header |
| unsigned int LCBB_start | ( | LCBB | lcb | ) |
Enables the LCB for taking event data.
| lcb | Pointer to private LCBB structure |
| static __inline unsigned int mapRcvErr | ( | const LCBB_err_rst_maps * | maps, | |
| unsigned int | err | |||
| ) | [static] |
Maps a result item status into an error code.
| maps | The error maps for result codes | |
| err | The error (status) code to map |
| static __inline unsigned int mapXfrErr | ( | const LCBB_err_rst_maps * | maps, | |
| unsigned int | err | |||
| ) | [static] |
Maps a result descriptor status into an error code.
| maps | The error maps for result codes | |
| err | The error (status) code to map |
| unsigned int pciLoad32 | ( | volatile unsigned int * | src | ) | [static] |
Read a 32-bit integer from PCI Memory.
| src | Pointer source memory location |
| void pciStore32 | ( | volatile unsigned int * | dst, | |
| unsigned int | w | |||
| ) | [static] |
Write a 32-bit integer to PCI Memory.
| dst | Pointer destination memory | |
| w | 32-bit value to store |
| static unsigned int poll | ( | LCBB | lcb, | |
| unsigned int | poll_period, | |||
| unsigned int | timeout, | |||
| unsigned short int | op_len, | |||
| const void * | result, | |||
| const LCB_ri_err * | ri_err | |||
| ) | [static] |
Polls the RESULT FIFO every nsecs for @ iterations.
| lcb | The LCBB driver handle | |
| poll_period | The polling period, in nanoseconds | |
| timeout | The timeout period, in nanoseconds | |
| op_len | The opcode and length of the transaction | |
| result | Address of the expected result list. | |
| ri_err | Pointer to the result item's error field. s |
Even a list of up to 3 seconds is possible (pretty bizarre), can be covered by the range of the SPIN counter. The smallest range is
MV2304, MCP750: 2**32 * 60 nsecs ~= 240 seconds
RAD750 : 2**32 * 120 nsecs ~= 480 seconds
| static unsigned int submit | ( | LCBB | lcb, | |
| unsigned int | request | |||
| ) | [static] |
Submits the specified request list to the LCB for execution.
| LCBB_OK,if | the transaction was successfully submitted | |
| LCBB_REQFULL,if | the transaction could not be submitted because the request queue was full. |
| lcb | The LCBB driver handle | |
| request | A pointer to a properly built (address | length) request. The transformation for local to PCI space is done in this routine. |
1.5.3