GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > LCBD / V1-4-4
Constituent: lcbd     Tag: rad750
#include <string.h>
#include "LCBD/LCBD_drv.h"
#include "LCBD/LCBD_pci.h"
#include "LCBD/LCBD_msgs.h"
#include "LCBD/LCB.h"
#include "LCBD/LCB_cr.h"
#include "LCBD/LCBC.h"
#include "LCBD_p.h"
#include "PBI/Attribute.h"
#include "PBS/L.ih"
#include "PBS/FORK.h"
#include "PBS/MBA.h"
#include "PBS/SPIN.h"
#include "PBS/RW.ih"
#include "PBS/RW_protos.h"
#include "PBS/INT.ih"
#include <stdio.h>
Include dependency graph for LCBD_drv.c:
Data Structures | |
struct | _FpgaList |
Structure defining the list of supported Fpgas. More... | |
Defines | |
#define | FABRIC_SELECT_TIMEOUT 10000 |
The timeout period, in nanoseconds, that one is willing to wait for the clock to show up after doing a fabric select. | |
Typedefs | |
typedef _FpgaList | FpgaList |
Typedef for struct _FpgaList. | |
Functions | |
static unsigned int | connect (LCBD lcb, unsigned int options) |
Connects the LCBD to the interrupt source. | |
static unsigned int | disconnect (LCBD lcb) |
Disconnects the LCBD from the interrupt source. | |
static unsigned int | clk_handler (void *unused, LCBD lcb) |
Default clock off -> on and clock on -> off handler. | |
static unsigned int | evt_def_handler (void *unused, unsigned int ed, LCBD_evt *evt) |
Default event handler. | |
static unsigned int | init_pci (LCBD lcb) |
Initializes the LCBD structure -- probes the PCI bus. | |
static unsigned int | init_latp (LCBD lcb, unsigned int options, unsigned int *event_base, LCBD_load_cb notify, void *prm) |
Laundry list of LCBD initializations to do on the LATp side. | |
static unsigned int | init_latp_clk_on (LCBD lcb, unsigned int options, unsigned int *event_base) |
Complete LCBD initializations of LATp side. | |
static unsigned int | init_latp_clk_on_isr (SEM semaphore, LCBD lcb) ATTR_UNUSED_OK |
Clock interrupt callback routine to complete LATp-side initialization. | |
static unsigned int | init_latp_clk_on_entry (LCBD lcb) ATTR_UNUSED_OK |
The asynchronous LATp-side initialization call back handler. | |
static unsigned int | init_circ (LCBD lcb, unsigned int *event_base, int fill) |
Allocates memory for and sets it up to be used as the circular buffer. | |
static unsigned int | init_sw (LCBD lcb) |
Laundry list of LCBD initializations to do on the software side. | |
static unsigned int | destroy_sw (LCBD lcb) |
Laundry list of LCBD shutdowns to do on the software side. | |
static unsigned int | drain_result (LCBD lcb) |
Drains the result FIFOs. | |
static unsigned int | drain_event (LCBD lcb) |
Drains the event FIFOs. | |
static unsigned int | check (unsigned int rd, unsigned int error, const char *name) |
Checks for and reports both IO and ITEM errors. | |
static unsigned int | poll (LCBD lcb, unsigned int nsecs, int iterations) |
Polls the RESULT FIFO every nsecs for @ iterations. | |
static unsigned int | destroy_handler (LCBD_hcb *hcb, unsigned int failure) |
Destroys a FORK processing task, iff it was created by the LCBD driver. | |
static void | select_fabric (unsigned int volatile *fabric, unsigned int select) |
Accesses the fabric select register, writing the fabric select bit and waits for either the clock to show up or a timeout period to expire. | |
static unsigned int | submit (LCBD lcb, unsigned int request) |
Submits the specified request list to the LCB for execution. | |
static unsigned int | poll_reg_access (LCBD lcb, unsigned int value, unsigned int field_select, unsigned short int stall, unsigned int *prv, unsigned int *cur, unsigned int header) |
Performs an access to the LATP register. | |
static unsigned int | poll_csr_access (LCBD lcb, unsigned int value, unsigned int field_select, unsigned short int stall, unsigned int *prv, unsigned int *cur) |
Performs an access to the LATP CSR register. | |
static unsigned int | poll_faults_access (LCBD lcb, unsigned int value, unsigned int field_select, unsigned short int stall, unsigned int *prv, unsigned int *cur) |
Performs an access to the LATP FAULTS register. | |
static unsigned int | clear_faults (LCBD lcb, unsigned short int stall) |
Clears the FIFO faults register. | |
static void | lcbd_isr (LCBD lcb) |
Central ISR that dispatches LCB result descriptors. | |
unsigned int | lcbd_csr_access (LCBD lcb, unsigned int value, unsigned int field_select, unsigned short int stall, unsigned int *prv, unsigned int *cur) |
Utility routine to compose and execute an access command to LCB's CSR register independent of whether the driver is offline or online. | |
unsigned int | lcbd_faults_access (LCBD lcb, unsigned int value, unsigned int field_select, unsigned short int stall, unsigned int *prv, unsigned int *cur) |
Utility routine to compose and execute an access command to LCB's FAULTS register independent of whether the driver is offline or online. | |
unsigned int | LCBD_allow (unsigned char pci_version, unsigned char latp_version) |
Adds the specified PCI and LATP version number combination as being supported by this driver. | |
unsigned int | LCBD_board_id_set (LCBD lcb, int new_board_id, int *org_board_id) |
Sets the LATp board Id, returning the orginal board id. | |
unsigned int | LCBD_clk_edge_set (LCBD lcb, unsigned int new_options, unsigned int *org_options) |
Sets the clock options. | |
LCBD | LCBD_create (LCBD lcb) |
Preinitializes the LCBD device control block. | |
const LCBD_dib * | LCBD_dib_locate (LCBD lcb) |
Returns a readonly pointer to the LCB's device information block. | |
void | LCBD_dib_show (const LCBD_dib *dib) |
Shows (prints to the terminal) the Device Information Block. | |
unsigned int | LCBD_drain (LCBD lcb, int which) |
Drains the specified ques. | |
unsigned int | LCBD_enable (LCBD lcb, unsigned int enables) |
Sets the enable/disable flags controlling the EVENT and RESULT interrupts. | |
unsigned int | LCBD_fabric_read (LCBD lcb) |
Reads the fabric select register. | |
unsigned int | LCBD_fabric_select (LCBD lcb, unsigned int fabric) |
Sets the fabric to specified value. | |
unsigned int | LCBD_faults_read (LCBD lcb, unsigned int clear, unsigned int *prv, unsigned int *cur) |
Reads the LATp faults register and, optionally, clears the specified bits. | |
LCBD | LCBD_get (void) |
Returns a pointer to the driver control structute. | |
unsigned int | LCBD_load (LCBD lcb, unsigned int options, unsigned int *event_base) |
Initializes the LCB hardware and LCBD software. | |
unsigned int | LCBD_load_cancel (LCBD lcb) |
Cancels the Waiting for the LCBD_load_init completion. | |
unsigned int | LCBD_load_init (LCBD lcb, unsigned int options, unsigned int *event_base, LCBD_load_cb notify, void *prm) |
Initializes the LCB hardware and LCBD software. | |
void | LCBD_load_notify (void *semaphore, LCBD lcb, unsigned int status) |
Pre-canned LCBD load notification callback routine. | |
unsigned int | LCBD_load_wait (LCBD lcb) |
Waits for the LCBD_load_init completion. | |
unsigned int | LCBD_pci_cfg_status_clear (LCBD lcb) |
Clears the PCI configuration space status word. | |
LCBD_state | LCBD_state_get (LCBD lcb) |
Returns the current state of the driver. | |
unsigned int | LCBD_unload (LCBD lcb) |
Unloads the LCB driver. | |
unsigned int | LCBD_width_set (LCBD lcb, int new_width, int *org_width) |
Sets the LATp event fabric data path width, returning the original data path width setting. | |
static __inline unsigned int | init_dib (LCBD_dib *dib) |
Initializes the Device Information Block Status. | |
static __inline unsigned int | check_pci_version (const FpgaList *fpga, unsigned char pci_version) |
Checks if the pci version is in the list of acceptable versions. | |
static __inline unsigned int | check_fpgas_version (const FpgaList *fpga, unsigned char pci_version, unsigned char latp_version) |
Checks if the combined PCI/LATP versions is in the list of acceptable versions. | |
static __inline void | init_evt_cbp (LCBD_evt_cbp evt[LCBD_EVT_PROTO_CNT], LCBD_evt_cb defaultHandler, void *defaultParameter) |
Initializes all event fabric protocol handlers to a default callback and parameter. | |
static __inline unsigned int | init_evt_fcb (LCBD_evt_fcb *fcb, unsigned int *event_base) |
Initializes the event free control block. | |
static __inline int | init_ucb (LCBD_ucb *ucb, LCBD lcb) |
Initializes the Unit Control block. | |
static __inline int | destroy_ucb (LCBD_ucb *ucb, LCBD lcb) |
Shutsdown the Unit(s) Control block. | |
static __inline unsigned int | destroy_result_handler (LCBD lcb) |
Destroys the result que service task, iff it was created by the LCBD driver. | |
static __inline unsigned int | destroy_event_handler (LCBD lcb) |
Destroys the event que service task, iff it was created by the LCBD driver. | |
unsigned int | lcbd_create_handler (LCBD_hcb *hcb, const char *name, int priority, LCBD lcb, int que_cnt, const FORK_que_cfg *que_cfg, int que_id, unsigned int failure) |
Creates a FORK processing task. | |
static __inline unsigned int | handle_clks (LCBD_clk_ucb *clk, LCBD_stats_isr *stats, LCBD lcb, unsigned int clock, unsigned int pending, unsigned int enabled) |
Handles the clock interrupts. | |
Variables | |
static FpgaList | Fpga |
List of correlated PCI,LATP FPGA versions that this driver is compatiable with. | |
static struct _LCBD | Lcb |
The actual storage for the driver control block. |
JJRussell -- russell@slac.stanford.edu
CVS $Id
The next step is to drain the FIFOs, but this depends on whether the LCB is a commander or a responder
Problems associated with the draining of each FIFOs must be considered separately.
If the LCB is being used as a responder, then it is very possible that one will find a result item sent by the commander (SIU) that contains the board address to assign to this LCB. This is also a signal that the LCB LATp side clock is now running, so one can now perform operations to the LATp side (ie proceed with the LATp side initialization phase.
|
The timeout period, in nanoseconds, that one is willing to wait for the clock to show up after doing a fabric select.
|
|
Checks for and reports both IO and ITEM errors.
|
|
Checks if the combined PCI/LATP versions is in the list of acceptable versions.
|
|
Checks if the pci version is in the list of acceptable versions.
|
|
Clears the FIFO faults register.
|
|
Default clock off -> on and clock on -> off handler.
|
|
Connects the LCBD to the interrupt source.
|
|
Destroys the event que service task, iff it was created by the LCBD driver.
|
|
Destroys a FORK processing task, iff it was created by the LCBD driver.
|
|
Destroys the result que service task, iff it was created by the LCBD driver.
|
|
Laundry list of LCBD shutdowns to do on the software side.
|
|
Shutsdown the Unit(s) Control block.
|
|
Disconnects the LCBD from the interrupt source.
|
|
Drains the event FIFOs.
|
|
Drains the result FIFOs.
In the last case, an attempt is made to clear an remaining transactions. Could one get into trouble here be taking too long. Don't think so. The request FIFO can only execute 2 commands at a time so the only way there could be a lot of transactions to dispose of is if they are already in the result que. The result FIFO is a maximum of 4Kbytes or 1K transactions in length, Therefore the maximum time will be something like 1K * 2 usecs (the 2 usecs being a generous estimate of the PCI read of the result FIFO.) + the time of complete of the sweeping transaction (something like 10usecs) for a total of about .2msecs.
|
|
Default event handler.
|
|
Handles the clock interrupts.
|
|
Allocates memory for and sets it up to be used as the circular buffer.
|
|
Initializes the Device Information Block Status.
|
|
Initializes all event fabric protocol handlers to a default callback and parameter.
|
|
Initializes the event free control block.
|
|
Laundry list of LCBD initializations to do on the LATp side.
|
|
Complete LCBD initializations of LATp side.
|
|
Initializes the LCBD structure -- probes the PCI bus.
|
|
Laundry list of LCBD initializations to do on the software side.
|
|
Initializes the Unit Control block.
|
|
Adds the specified PCI and LATP version number combination as being supported by this driver.
|
|
Sets the LATp board Id, returning the orginal board id.
|
|
Sets the clock options.
|
|
Preinitializes the LCBD device control block.
|
|
Creates a FORK processing task.
|
|
Utility routine to compose and execute an access command to LCB's CSR register independent of whether the driver is offline or online.
|
|
Returns a readonly pointer to the LCB's device information block.
|
|
Shows (prints to the terminal) the Device Information Block.
|
|
Drains the specified ques.
|
|
Sets the enable/disable flags controlling the EVENT and RESULT interrupts.
|
|
Reads the fabric select register.
|
|
Sets the fabric to specified value.
|
|
Utility routine to compose and execute an access command to LCB's FAULTS register independent of whether the driver is offline or online.
|
|
Reads the LATp faults register and, optionally, clears the specified bits.
// Just read the faults register status = LCBD_faults_read (lcb, 0, &faults, NULL); // Read and clear the faults register status = LCBD_faults_read (lcb, -1, &faults, NULL);
|
|
Returns a pointer to the driver control structute.
|
|
Central ISR that dispatches LCB result descriptors.
|
|
Initializes the LCB hardware and LCBD software.
|
|
Cancels the Waiting for the LCBD_load_init completion.
|
|
Initializes the LCB hardware and LCBD software.
status = LCBD_load_init (lcb, options, event_base, LBCD_load_notify, NULL); // The only errors are catastophic if (status != LCBD_OK) return status; // Now do a bunch of other stuff.... call_a_bunch_of_other_stuff (lots_of_parameters); // Done doing other stuff, now wait till the driver is fully initialized status = LCBD_load_wait (lcb); if (status != LCBD_OK) return status; . |
|
Pre-canned LCBD load notification callback routine.
|
|
Waits for the LCBD_load_init completion.
|
|
Clears the PCI configuration space status word.
|
|
Returns the current state of the driver.
|
|
Unloads the LCB driver.
|
|
Sets the LATp event fabric data path width, returning the original data path width setting.
|
|
Polls the RESULT FIFO every nsecs for @ iterations.
|
|
Performs an access to the LATP CSR register.
|
|
Performs an access to the LATP FAULTS register.
|
|
Performs an access to the LATP register.
|
|
Accesses the fabric select register, writing the fabric select bit and waits for either the clock to show up or a timeout period to expire.
|
|
Submits the specified request list to the LCB for execution.
|
|
Initial value: { 9, 9, { FPGA (0x80, 0x80), FPGA (0x2c, 0x5e), FPGA (0x2c, 0x5d), FPGA (0x2c, 0x5c), FPGA (0x2b, 0x5c), FPGA (0x2a, 0x5c), FPGA (0x2c, 0x5b), FPGA (0x2b, 0x5b), FPGA (0x2a, 0x5b), 0,0, 0,0,0,0 } }
|
|
The actual storage for the driver control block.
|