\hypertarget{BFI_8c}{
\section{BFI.c File Reference}
\label{BFI_8c}\index{BFI.c@{BFI.c}}
}
Balloon Flight Interrupt Handling, Implementation. 


{\tt \#include $<$sem\-Lib.h$>$}\par
{\tt \#include $<$int\-Lib.h$>$}\par
{\tt \#include $<$errno.h$>$}\par
{\tt \#include $<$obj\-Lib.h$>$}\par
{\tt \#include $<$iv.h$>$}\par
{\tt \#include \char`\"{}BBC/BUG.h\char`\"{}}\par
{\tt \#include \char`\"{}BBC/INT.ih\char`\"{}}\par
{\tt \#include \char`\"{}BTU/TEM\_\-ids.h\char`\"{}}\par
{\tt \#include \char`\"{}BTU/TEM\_\-tem\-Int.h\char`\"{}}\par
{\tt \#include \char`\"{}BFU/BFM.h\char`\"{}}\par
{\tt \#include \char`\"{}BFU/BFI.h\char`\"{}}\par
\subsection*{Data Structures}
\begin{CompactItemize}
\item 
struct \hyperlink{struct__BFI__gsc}{\_\-BFI\_\-gsc}
\begin{CompactList}\small\item\em Group service context.\item\end{CompactList}\item 
struct \hyperlink{struct__BFI__gscList}{\_\-BFI\_\-gsc\-List}
\begin{CompactList}\small\item\em Collection of all group service contexts.\item\end{CompactList}\item 
struct \hyperlink{struct__BFI__ssc}{\_\-BFI\_\-ssc}
\begin{CompactList}\small\item\em System Service Context.\item\end{CompactList}\end{CompactItemize}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\hypertarget{BFI_8c_a0}{
\index{BFI_M_TEM_INT_ALLOC_MSK@{BFI\_\-M\_\-TEM\_\-INT\_\-ALLOC\_\-MSK}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_M_TEM_INT_ALLOC_MSK@{BFI\_\-M\_\-TEM\_\-INT\_\-ALLOC\_\-MSK}}
\#define \hyperlink{BFI_8c_a0}{BFI\_\-M\_\-TEM\_\-INT\_\-ALLOC\_\-MSK}\ (BFI\_\-M\_\-INT\_\-SRC\_\-TEMS $<$$<$ (32 - BFI\_\-K\_\-INT\_\-SRC\_\-TEMS))}
\label{BFI_8c_a0}

\begin{CompactList}\small\item\em A left justified global interrupt mask is defined which contains a value representing interrupts from all the tems, arranged a nibble / TEM.\item\end{CompactList}\item 
\hypertarget{BFI_8c_a1}{
\index{BIT@{BIT}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BIT@{BIT}}
\#define \hyperlink{BFI_8c_a1}{BIT}(\_\-l32, \_\-n)\ ((\_\-l32 $>$$>$ \_\-n) \& 1)}
\label{BFI_8c_a1}

\begin{CompactList}\small\item\em Returns the value of {\em n} th bit of 32 bit word {\em \_\-l}.\item\end{CompactList}\item 
\hypertarget{BFI_8c_a2}{
\index{BITC@{BITC}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BITC@{BITC}}
\#define \hyperlink{BFI_8c_a2}{BITC}(\_\-l32, \_\-n)\ (((\_\-l32 $>$$>$ \_\-n) \& 1) $^\wedge$ 1)}
\label{BFI_8c_a2}

\begin{CompactList}\small\item\em Returns the value of the complement {\em n} th bit of 32 bit word {\em \_\-l}.\item\end{CompactList}\item 
\#define \hyperlink{BFI_8c_a3}{BITS}(\_\-l32, \_\-r, \_\-w)\ ((\_\-l32 $>$$>$ \_\-r) \& \_\-w)
\begin{CompactList}\small\item\em Returns the right justified value of bit field.\item\end{CompactList}\item 
\hypertarget{BFI_8c_a4}{
\index{BFI_S_ICW_TEMID@{BFI\_\-S\_\-ICW\_\-TEMID}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_S_ICW_TEMID@{BFI\_\-S\_\-ICW\_\-TEMID}}
\#define \hyperlink{BFI_8c_a4}{BFI\_\-S\_\-ICW\_\-TEMID}\ 4}
\label{BFI_8c_a4}

\begin{CompactList}\small\item\em Size of the TEM id field.\item\end{CompactList}\item 
\hypertarget{BFI_8c_a5}{
\index{BFI_S_ICW_IRPTS@{BFI\_\-S\_\-ICW\_\-IRPTS}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_S_ICW_IRPTS@{BFI\_\-S\_\-ICW\_\-IRPTS}}
\#define \hyperlink{BFI_8c_a5}{BFI\_\-S\_\-ICW\_\-IRPTS}\ 4}
\label{BFI_8c_a5}

\begin{CompactList}\small\item\em Size of the interrupt source mask field.\item\end{CompactList}\item 
\hypertarget{BFI_8c_a6}{
\index{BFI_S_ICW_GRPS@{BFI\_\-S\_\-ICW\_\-GRPS}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_S_ICW_GRPS@{BFI\_\-S\_\-ICW\_\-GRPS}}
\#define \hyperlink{BFI_8c_a6}{BFI\_\-S\_\-ICW\_\-GRPS}\ 24}
\label{BFI_8c_a6}

\begin{CompactList}\small\item\em Size of the service group mask field.\item\end{CompactList}\item 
\hypertarget{BFI_8c_a7}{
\index{BFI_V_ICW_TEMID@{BFI\_\-V\_\-ICW\_\-TEMID}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_V_ICW_TEMID@{BFI\_\-V\_\-ICW\_\-TEMID}}
\#define \hyperlink{BFI_8c_a7}{BFI\_\-V\_\-ICW\_\-TEMID}\ 0}
\label{BFI_8c_a7}

\begin{CompactList}\small\item\em Right shift needed to extract tem id.\item\end{CompactList}\item 
\hypertarget{BFI_8c_a8}{
\index{BFI_V_ICW_IRPTS@{BFI\_\-V\_\-ICW\_\-IRPTS}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_V_ICW_IRPTS@{BFI\_\-V\_\-ICW\_\-IRPTS}}
\#define \hyperlink{BFI_8c_a8}{BFI\_\-V\_\-ICW\_\-IRPTS}\ (BFI\_\-V\_\-ICW\_\-TEMID + BFI\_\-S\_\-ICW\_\-TEMID)}
\label{BFI_8c_a8}

\begin{CompactList}\small\item\em Right shift needed to extract source mask.\item\end{CompactList}\item 
\hypertarget{BFI_8c_a9}{
\index{BFI_V_ICW_GRPS@{BFI\_\-V\_\-ICW\_\-GRPS}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_V_ICW_GRPS@{BFI\_\-V\_\-ICW\_\-GRPS}}
\#define \hyperlink{BFI_8c_a9}{BFI\_\-V\_\-ICW\_\-GRPS}\ (BFI\_\-V\_\-ICW\_\-IRPTS + BFI\_\-S\_\-ICW\_\-IRPTS)}
\label{BFI_8c_a9}

\begin{CompactList}\small\item\em Right shift needed to extract group mask.\item\end{CompactList}\item 
\hypertarget{BFI_8c_a10}{
\index{BFI_N_ICW_TEMID@{BFI\_\-N\_\-ICW\_\-TEMID}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_N_ICW_TEMID@{BFI\_\-N\_\-ICW\_\-TEMID}}
\#define \hyperlink{BFI_8c_a10}{BFI\_\-N\_\-ICW\_\-TEMID}\ ((1$<$$<$BFI\_\-S\_\-ICW\_\-TEMID)-1)}
\label{BFI_8c_a10}

\begin{CompactList}\small\item\em Left justified mask to extract tem id.\item\end{CompactList}\item 
\hypertarget{BFI_8c_a11}{
\index{BFI_N_ICW_IRPTS@{BFI\_\-N\_\-ICW\_\-IRPTS}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_N_ICW_IRPTS@{BFI\_\-N\_\-ICW\_\-IRPTS}}
\#define \hyperlink{BFI_8c_a11}{BFI\_\-N\_\-ICW\_\-IRPTS}\ ((1$<$$<$BFI\_\-S\_\-ICW\_\-IRPTS)-1)}
\label{BFI_8c_a11}

\begin{CompactList}\small\item\em Left justified mask to extract source mask.\item\end{CompactList}\item 
\hypertarget{BFI_8c_a12}{
\index{BFI_N_ICW_GRPS@{BFI\_\-N\_\-ICW\_\-GRPS}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_N_ICW_GRPS@{BFI\_\-N\_\-ICW\_\-GRPS}}
\#define \hyperlink{BFI_8c_a12}{BFI\_\-N\_\-ICW\_\-GRPS}\ ((1$<$$<$BFI\_\-S\_\-ICW\_\-GRPS )-1)}
\label{BFI_8c_a12}

\begin{CompactList}\small\item\em Left justified mask to extract group mask.\item\end{CompactList}\item 
\hypertarget{BFI_8c_a13}{
\index{BFI_M_ICW_TEMID@{BFI\_\-M\_\-ICW\_\-TEMID}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_M_ICW_TEMID@{BFI\_\-M\_\-ICW\_\-TEMID}}
\#define \hyperlink{BFI_8c_a13}{BFI\_\-M\_\-ICW\_\-TEMID}\ (BFI\_\-N\_\-ICW\_\-TEMID $<$$<$ BFI\_\-V\_\-ICW\_\-TEMID)}
\label{BFI_8c_a13}

\begin{CompactList}\small\item\em In place mask to extract tem id.\item\end{CompactList}\item 
\hypertarget{BFI_8c_a14}{
\index{BFI_M_ICW_IRPTS@{BFI\_\-M\_\-ICW\_\-IRPTS}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_M_ICW_IRPTS@{BFI\_\-M\_\-ICW\_\-IRPTS}}
\#define \hyperlink{BFI_8c_a14}{BFI\_\-M\_\-ICW\_\-IRPTS}\ (BFI\_\-N\_\-ICW\_\-IRPTS $<$$<$ BFI\_\-V\_\-ICW\_\-IRPTS)}
\label{BFI_8c_a14}

\begin{CompactList}\small\item\em In place mask to extract source mask.\item\end{CompactList}\item 
\hypertarget{BFI_8c_a15}{
\index{BFI_M_ICW_GRPS@{BFI\_\-M\_\-ICW\_\-GRPS}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_M_ICW_GRPS@{BFI\_\-M\_\-ICW\_\-GRPS}}
\#define \hyperlink{BFI_8c_a15}{BFI\_\-M\_\-ICW\_\-GRPS}\ (BFI\_\-N\_\-ICW\_\-GRPS  $<$$<$ BFI\_\-V\_\-ICW\_\-GRPS)}
\label{BFI_8c_a15}

\begin{CompactList}\small\item\em In place mask to extract group mask.\item\end{CompactList}\item 
\hypertarget{BFI_8c_a16}{
\index{extractGrps@{extractGrps}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!extractGrps@{extract\-Grps}}
\#define \hyperlink{BFI_8c_a16}{extract\-Grps}(\_\-icw)\ ((\_\-icw $>$$>$ BFI\_\-V\_\-ICW\_\-GRPS ) \& BFI\_\-N\_\-ICW\_\-GRPS)}
\label{BFI_8c_a16}

\begin{CompactList}\small\item\em Macro to extract the group mask field.\item\end{CompactList}\item 
\hypertarget{BFI_8c_a17}{
\index{extractIrpts@{extractIrpts}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!extractIrpts@{extract\-Irpts}}
\#define \hyperlink{BFI_8c_a17}{extract\-Irpts}(\_\-icw)\ ((\_\-icw $>$$>$ BFI\_\-V\_\-ICW\_\-IRPTS) \& BFI\_\-N\_\-ICW\_\-IRPTS)}
\label{BFI_8c_a17}

\begin{CompactList}\small\item\em Macro to extract the source mask field.\item\end{CompactList}\item 
\hypertarget{BFI_8c_a18}{
\index{extractTemid@{extractTemid}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!extractTemid@{extract\-Temid}}
\#define \hyperlink{BFI_8c_a18}{extract\-Temid}(\_\-icw)\ ((\_\-icw $>$$>$ BFI\_\-V\_\-ICW\_\-TEMID) \& BFI\_\-N\_\-ICW\_\-TEMID)}
\label{BFI_8c_a18}

\begin{CompactList}\small\item\em Macro to extract the tem id field.\item\end{CompactList}\item 
\hypertarget{BFI_8c_a19}{
\index{insertGrps@{insertGrps}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!insertGrps@{insert\-Grps}}
\#define \hyperlink{BFI_8c_a19}{insert\-Grps}(\_\-grps)\ ((\_\-grps  \& BFI\_\-N\_\-ICW\_\-GRPS )$<$$<$BFI\_\-V\_\-ICW\_\-GRPS )}
\label{BFI_8c_a19}

\begin{CompactList}\small\item\em Macro to insert the group mask field.\item\end{CompactList}\item 
\hypertarget{BFI_8c_a20}{
\index{insertIrpts@{insertIrpts}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!insertIrpts@{insert\-Irpts}}
\#define \hyperlink{BFI_8c_a20}{insert\-Irpts}(\_\-irpts)\ ((\_\-irpts \& BFI\_\-N\_\-ICW\_\-IRPTS)$<$$<$BFI\_\-V\_\-ICW\_\-IRPTS)}
\label{BFI_8c_a20}

\begin{CompactList}\small\item\em Macro to insert the source mask field.\item\end{CompactList}\item 
\hypertarget{BFI_8c_a21}{
\index{insertTemid@{insertTemid}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!insertTemid@{insert\-Temid}}
\#define \hyperlink{BFI_8c_a21}{insert\-Temid}(\_\-temid)\ ((\_\-temid \& BFI\_\-N\_\-ICW\_\-TEMID)$<$$<$BFI\_\-V\_\-ICW\_\-TEMID)}
\label{BFI_8c_a21}

\begin{CompactList}\small\item\em Macro to insert the tem id field.\item\end{CompactList}\item 
\#define \hyperlink{BFI_8c_a22}{BFI\_\-K\_\-INT\_\-MAX}\ (BFI\_\-K\_\-INT\_\-SRC\_\-TEMS)
\begin{CompactList}\small\item\em Maximum number of interrupt sources.\item\end{CompactList}\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
typedef \hyperlink{struct__BFI__gsc}{\_\-BFI\_\-gsc} \hyperlink{BFI_8c_a23}{BFI\_\-gsc}
\begin{CompactList}\small\item\em Typedef for struct \hyperlink{struct__BFI__gsc}{\_\-BFI\_\-gsc}.\item\end{CompactList}\item 
typedef \hyperlink{struct__BFI__gscList}{\_\-BFI\_\-gsc\-List} \hyperlink{BFI_8c_a24}{BFI\_\-gsc\-List}
\begin{CompactList}\small\item\em Typedef for struct \hyperlink{struct__BFI__gscList}{\_\-BFI\_\-gsc\-List}.\item\end{CompactList}\item 
typedef \hyperlink{struct__BFI__ssc}{\_\-BFI\_\-ssc} \hyperlink{BFI_8c_a25}{BFI\_\-ssc}
\begin{CompactList}\small\item\em Typedef for struct \hyperlink{struct__BFI__ssc}{\_\-BFI\_\-ssc}.\item\end{CompactList}\item 
\hypertarget{BFI_8c_a26}{
\index{BFI_icw@{BFI\_\-icw}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_icw@{BFI\_\-icw}}
typedef unsigned int \hyperlink{BFI_8c_a26}{BFI\_\-icw}}
\label{BFI_8c_a26}

\begin{CompactList}\small\item\em Interrrupt context word.\item\end{CompactList}\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void \hyperlink{BFI_8c_a28}{BFI\_\-service} (\hyperlink{BFI_8c_a26}{BFI\_\-icw} icw)
\begin{CompactList}\small\item\em The VME interrupt service routine.\item\end{CompactList}\item 
int \hyperlink{BFI_8c_a29}{FFS} (unsigned int mask)
\begin{CompactList}\small\item\em Provides a straightforward interface to the CNTLZW machine instruction.\item\end{CompactList}\item 
int \hyperlink{BFI_8c_a30}{allocate} (unsigned int $\ast$mask)
\begin{CompactList}\small\item\em Allocates the first available group service context block.\item\end{CompactList}\item 
unsigned int \hyperlink{BFI_8c_a31}{connect} (const struct \_\-TEM\_\-tem $\ast$tems, enum \_\-TEM\_\-tem\-Id tem\-Id, const \hyperlink{BFI_8c_a23}{BFI\_\-gsc} $\ast$gsc, int groups)
\begin{CompactList}\small\item\em Connects all interrupts associated with the specified TEM.\item\end{CompactList}\item 
\hypertarget{BFI_8c_a32}{
\index{BFI_connect@{BFI\_\-connect}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_connect@{BFI\_\-connect}}
int {\bf BFI\_\-connect} (void)}
\label{BFI_8c_a32}

\item 
\hypertarget{BFI_8c_a33}{
\index{BFI_evtThresholdsSet@{BFI\_\-evtThresholdsSet}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_evtThresholdsSet@{BFI\_\-evt\-Thresholds\-Set}}
unsigned int {\bf BFI\_\-evt\-Thresholds\-Set} (unsigned int tem\-List, const unsigned int $\ast$thresholds)}
\label{BFI_8c_a33}

\item 
\hypertarget{BFI_8c_a34}{
\index{BFI_groupAdd@{BFI\_\-groupAdd}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_groupAdd@{BFI\_\-group\-Add}}
int {\bf BFI\_\-group\-Add} (unsigned int irpts)}
\label{BFI_8c_a34}

\item 
\hypertarget{BFI_8c_a35}{
\index{BFI_groupDisable@{BFI\_\-groupDisable}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_groupDisable@{BFI\_\-group\-Disable}}
unsigned int {\bf BFI\_\-group\-Disable} (\hyperlink{BFI_8h_a11}{BFI\_\-group} grp\-Id, unsigned int disable)}
\label{BFI_8c_a35}

\item 
\hypertarget{BFI_8c_a36}{
\index{BFI_groupEnable@{BFI\_\-groupEnable}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_groupEnable@{BFI\_\-group\-Enable}}
unsigned int {\bf BFI\_\-group\-Enable} (\hyperlink{BFI_8h_a11}{BFI\_\-group} gsc\-Id, unsigned int enable)}
\label{BFI_8c_a36}

\item 
\hypertarget{BFI_8c_a37}{
\index{BFI_groupPend@{BFI\_\-groupPend}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_groupPend@{BFI\_\-group\-Pend}}
unsigned int {\bf BFI\_\-group\-Pend} (\hyperlink{BFI_8h_a11}{BFI\_\-group} group\-Id, int timeout)}
\label{BFI_8c_a37}

\item 
\hypertarget{BFI_8c_a38}{
\index{BFI_groupSignal@{BFI\_\-groupSignal}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_groupSignal@{BFI\_\-group\-Signal}}
int {\bf BFI\_\-group\-Signal} (\hyperlink{BFI_8h_a11}{BFI\_\-group} group\-Id, unsigned int irpts)}
\label{BFI_8c_a38}

\item 
\hypertarget{BFI_8c_a39}{
\index{BFI_init@{BFI\_\-init}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_init@{BFI\_\-init}}
unsigned int {\bf BFI\_\-init} (const struct \hyperlink{struct__BFM__dsc}{\_\-BFM\_\-dsc} $\ast$bfm, unsigned int tem\-List, const unsigned int $\ast$levels, const unsigned int $\ast$base)}
\label{BFI_8c_a39}

\item 
\hypertarget{BFI_8c_a40}{
\index{BFI_errorsGather@{BFI\_\-errorsGather}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_errorsGather@{BFI\_\-errors\-Gather}}
unsigned int {\bf BFI\_\-errors\-Gather} (unsigned int irpts)}
\label{BFI_8c_a40}

\item 
\hypertarget{BFI_8c_a41}{
\index{BFI_masterDisable@{BFI\_\-masterDisable}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_masterDisable@{BFI\_\-master\-Disable}}
unsigned int {\bf BFI\_\-master\-Disable} (unsigned int tem\-List)}
\label{BFI_8c_a41}

\item 
\hypertarget{BFI_8c_a42}{
\index{BFI_masterEnable@{BFI\_\-masterEnable}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_masterEnable@{BFI\_\-master\-Enable}}
unsigned int {\bf BFI\_\-master\-Enable} (unsigned int tem\-List)}
\label{BFI_8c_a42}

\item 
\hypertarget{BFI_8c_a43}{
\index{BFI_masterReset@{BFI\_\-masterReset}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_masterReset@{BFI\_\-master\-Reset}}
unsigned int {\bf BFI\_\-master\-Reset} (unsigned int tem\-List)}
\label{BFI_8c_a43}

\item 
\hypertarget{BFI_8c_a44}{
\index{BFI_minEventsGet@{BFI\_\-minEventsGet}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_minEventsGet@{BFI\_\-min\-Events\-Get}}
int {\bf BFI\_\-min\-Events\-Get} (unsigned int tem\-List, unsigned int $\ast$nevts)}
\label{BFI_8c_a44}

\item 
\hypertarget{BFI_8c_a45}{
\index{BFI_trim@{BFI\_\-trim}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_trim@{BFI\_\-trim}}
unsigned int {\bf BFI\_\-trim} (unsigned int tem\-List, unsigned int int\-List)}
\label{BFI_8c_a45}

\item 
\hypertarget{BFI_8c_a46}{
\index{BFI_vmeDisable@{BFI\_\-vmeDisable}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_vmeDisable@{BFI\_\-vme\-Disable}}
unsigned int {\bf BFI\_\-vme\-Disable} (unsigned int tem\-List)}
\label{BFI_8c_a46}

\item 
\hypertarget{BFI_8c_a47}{
\index{BFI_vmeEnable@{BFI\_\-vmeEnable}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!BFI_vmeEnable@{BFI\_\-vme\-Enable}}
unsigned int {\bf BFI\_\-vme\-Enable} (unsigned int tem\-List)}
\label{BFI_8c_a47}

\end{CompactItemize}
\subsection*{Variables}
\begin{CompactItemize}
\item 
\hypertarget{BFI_8c_a27}{
\index{Bfi_Ssc@{Bfi\_\-Ssc}!BFI.c@{BFI.c}}\index{BFI.c@{BFI.c}!Bfi_Ssc@{Bfi\_\-Ssc}}
\hyperlink{BFI_8c_a25}{BFI\_\-ssc} \hyperlink{BFI_8c_a27}{Bfi\_\-Ssc}}
\label{BFI_8c_a27}

\begin{CompactList}\small\item\em Global to an instance of this system servicing context block.\item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Balloon Flight Interrupt Handling, Implementation.



\begin{Desc}
\item[Author: ]\par
JJRussell - \href{mailto:russell@slac.stanford.edu}{\tt russell@slac.stanford.edu}\end{Desc}


\subsection{Define Documentation}
\hypertarget{BFI_8c_a22}{
\index{BFI.c@{BFI.c}!BFI_K_INT_MAX@{BFI\_\-K\_\-INT\_\-MAX}}
\index{BFI_K_INT_MAX@{BFI\_\-K\_\-INT\_\-MAX}!BFI.c@{BFI.c}}
\subsubsection[BFI\_\-K\_\-INT\_\-MAX]{\setlength{\rightskip}{0pt plus 5cm}\#define BFI\_\-K\_\-INT\_\-MAX\ (BFI\_\-K\_\-INT\_\-SRC\_\-TEMS)}}
\label{BFI_8c_a22}


Maximum number of interrupt sources.



 Since an interrrupt can be associated with only one group, this number determines the maximum number of possible groups. Because a group may service more than one interrupt, the number of groups actually used may be smaller than this number, even in a system with all interrupts active. \hypertarget{BFI_8c_a3}{
\index{BFI.c@{BFI.c}!BITS@{BITS}}
\index{BITS@{BITS}!BFI.c@{BFI.c}}
\subsubsection[BITS]{\setlength{\rightskip}{0pt plus 5cm}\#define BITS(\_\-l32, \_\-r, \_\-w)\ ((\_\-l32 $>$$>$ \_\-r) \& \_\-w)}}
\label{BFI_8c_a3}


Returns the right justified value of bit field.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
\_\-l}]The 32 bit word to extract the bit field from. \item[{\em 
\_\-r}]The bit number of least significant bit of the bit field. \item[{\em 
\_\-w}]The width of the bit field. \end{description}
\end{Desc}


\subsection{Typedef Documentation}
\hypertarget{BFI_8c_a23}{
\index{BFI.c@{BFI.c}!BFI_gsc@{BFI\_\-gsc}}
\index{BFI_gsc@{BFI\_\-gsc}!BFI.c@{BFI.c}}
\subsubsection[BFI\_\-gsc]{\setlength{\rightskip}{0pt plus 5cm}BFI\_\-gsc}}
\label{BFI_8c_a23}


Typedef for struct \hyperlink{struct__BFI__gsc}{\_\-BFI\_\-gsc}.



 Contains all the information needed to define and control an interrupt group. An interrupt group can be associated with multiple interrupt sources, but it always delivers its response to one listener. This allows multiple interrupts to be handle within a single context. For example, all L1T interrupts from each TEM could be enabled and associated with a single group. If any L1T interrupt becomes active, then the context responsible for handling this group will be notified with a wake up call and a parameter indicating which sources are active. \hypertarget{BFI_8c_a24}{
\index{BFI.c@{BFI.c}!BFI_gscList@{BFI\_\-gscList}}
\index{BFI_gscList@{BFI\_\-gscList}!BFI.c@{BFI.c}}
\subsubsection[BFI\_\-gscList]{\setlength{\rightskip}{0pt plus 5cm}BFI\_\-gsc\-List}}
\label{BFI_8c_a24}


Typedef for struct \hyperlink{struct__BFI__gscList}{\_\-BFI\_\-gsc\-List}.



 The current implementation supports 24 distinct groups. This data structure services as a pool for BFI\_\-gsc context blocks needed to define a group service context. Blocks are allocated for this pool.

The {\tt free} field is a list of the free, unallocated, group service context blocks, expressed as a bit mask. It is initialized to have its most significant 24 bits set, indicating that all blocks are free. (The left justification is because the allocator uses a CNLZ, count leading zeros instruction to find the first free block. \hypertarget{BFI_8c_a25}{
\index{BFI.c@{BFI.c}!BFI_ssc@{BFI\_\-ssc}}
\index{BFI_ssc@{BFI\_\-ssc}!BFI.c@{BFI.c}}
\subsubsection[BFI\_\-ssc]{\setlength{\rightskip}{0pt plus 5cm}BFI\_\-ssc}}
\label{BFI_8c_a25}


Typedef for struct \hyperlink{struct__BFI__ssc}{\_\-BFI\_\-ssc}.



 Gathers together all the information needed to define and control the interrupts. 

\subsection{Function Documentation}
\hypertarget{BFI_8c_a30}{
\index{BFI.c@{BFI.c}!allocate@{allocate}}
\index{allocate@{allocate}!BFI.c@{BFI.c}}
\subsubsection[allocate]{\setlength{\rightskip}{0pt plus 5cm}int allocate (unsigned int $\ast$ {\em mask})\hspace{0.3cm}{\tt  \mbox{[}inline, static\mbox{]}}}}
\label{BFI_8c_a30}


Allocates the first available group service context block.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
mask}]The free list, expressed as a left justified bit mask. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns: ]\par
An index between 0 - 23 if the allocation is successful. Returns -1 if the allocation fails.\end{Desc}
This allocator is multithread safe. If the allocation is successful, the allocated block is marked as no longer free. \hypertarget{BFI_8c_a28}{
\index{BFI.c@{BFI.c}!BFI_service@{BFI\_\-service}}
\index{BFI_service@{BFI\_\-service}!BFI.c@{BFI.c}}
\subsubsection[BFI\_\-service]{\setlength{\rightskip}{0pt plus 5cm}void BFI\_\-service (\hyperlink{BFI_8c_a26}{BFI\_\-icw} {\em icw})}}
\label{BFI_8c_a28}


The VME interrupt service routine.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
icw}]The interrupt context word. Since this routine is connected to multiple interrupts, this parameter is used to distinguish which interrupt(s) is/are being serviced.\end{description}
\end{Desc}
Service the specified interrupts. The list of groups serviced by this interrupt are woke up. This routine is called back when a particular set of interrupts occurs for a particular VME interrupt level. Because the TEM delivers all its interrupts at the same VME interrupt level, the association of interrupt level with a specific TEM can be made.

This routine is meant to service all interrupts possibilities that a single TEM may produce. When multiple interrupts are present, it may be that more than one group needs to be tickled (ie have its semaphore given).

\begin{Desc}
\item[Warning: ]\par
This is not a user callable routine.\end{Desc}
{\bf PROGRAMMING} NOTE \par
 {\bf ----------------} \par
 Perhaps a good optimization would be to isolate the set of interrupt vectors that service one and only one group to a specific routine. That would save the looping structure and the code that goes with it. \hypertarget{BFI_8c_a31}{
\index{BFI.c@{BFI.c}!connect@{connect}}
\index{connect@{connect}!BFI.c@{BFI.c}}
\subsubsection[connect]{\setlength{\rightskip}{0pt plus 5cm}unsigned int connect (const struct \_\-TEM\_\-tem $\ast$ {\em tems}, enum \_\-TEM\_\-tem\-Id {\em tem\-Id}, const \hyperlink{BFI_8c_a23}{BFI\_\-gsc} $\ast$ {\em gsc}, int {\em groups})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BFI_8c_a31}


Connects all interrupts associated with the specified TEM.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
tems}]The TEM database. \item[{\em 
tem\-Id}]The id of the TEM to connect, ie ACD, TKR, CAL \item[{\em 
gsc}]The array of group service context blocks. \item[{\em 
groups}]The list of groups to connect. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns: ]\par
0 if succesfully, else a list of interrupts that failed to connect. \end{Desc}
\hypertarget{BFI_8c_a29}{
\index{BFI.c@{BFI.c}!FFS@{FFS}}
\index{FFS@{FFS}!BFI.c@{BFI.c}}
\subsubsection[FFS]{\setlength{\rightskip}{0pt plus 5cm}int FFS (unsigned int {\em mask})\hspace{0.3cm}{\tt  \mbox{[}inline, static\mbox{]}}}}
\label{BFI_8c_a29}


Provides a straightforward interface to the CNTLZW machine instruction.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
mask}]The word to find the first set bit in \end{description}
\end{Desc}
\begin{Desc}
\item[Returns: ]\par
0-32 indicating the first set bit. Returning 32 indicates that there are no bits set.\end{Desc}
This is an internal utility routine used by the group service context block allocator. 