\hypertarget{memload_8c}{
\section{memload.c File Reference}
\label{memload_8c}\index{memload.c@{memload.c}}
}
Memory Load functions.  


{\tt \#include $<$string.h$>$}\par
{\tt \#include \char`\"{}CCSDS/CCSDS\_\-pkt.h\char`\"{}}\par
{\tt \#include \char`\"{}MEM/MEM\_\-cmddefs.h\char`\"{}}\par
{\tt \#include \char`\"{}MEM/MEM\_\-load.h\char`\"{}}\par
{\tt \#include \char`\"{}MEM/MEM\_\-msgs.h\char`\"{}}\par
{\tt \#include \char`\"{}MSG/MSG\_\-pubdefs.h\char`\"{}}\par
{\tt \#include \char`\"{}mempriv.h\char`\"{}}\par
{\tt \#include \char`\"{}PBS/MBA.h\char`\"{}}\par


Include dependency graph for memload.c:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=220pt]{memload_8c__incl}
\end{center}
\end{figure}
\subsection*{Data Structures}
\begin{CompactItemize}
\item 
struct \hyperlink{struct__mem__LoadContext}{\_\-mem\_\-Load\-Context}
\begin{CompactList}\small\item\em Memory Load context. \item\end{CompactList}\end{CompactItemize}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\hypertarget{memload_8c_a0}{
\#define \hyperlink{memload_8c_a0}{MEM\_\-LOAD\_\-KEY\_\-VALID}\ (0x124578ab)}
\label{memload_8c_a0}

\begin{CompactList}\small\item\em Load info 'valid' key value. \item\end{CompactList}\item 
\hypertarget{memload_8c_a1}{
\#define \hyperlink{memload_8c_a1}{MEM\_\-LOAD\_\-MEM\_\-WRITE\_\-MAX\_\-WORDS}\ (4096 / 4)}
\label{memload_8c_a1}

\begin{CompactList}\small\item\em Maximum number of words that can be loaded with a Memory Write telecommand. \item\end{CompactList}\item 
\hypertarget{memload_8c_a2}{
\#define \hyperlink{memload_8c_a2}{MEM\_\-LOAD\_\-MAX\_\-STALL}\ (1000)}
\label{memload_8c_a2}

\begin{CompactList}\small\item\em Maximum number of times that a load operation can make no progress before declaring a timeout failure. \item\end{CompactList}\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
typedef \hyperlink{struct__mem__LoadContext}{\_\-mem\_\-Load\-Context} \hyperlink{memload_8c_a3}{mem\_\-Load\-Context}
\begin{CompactList}\small\item\em Typedef for \hyperlink{struct__mem__LoadContext}{\_\-mem\_\-Load\-Context}. \item\end{CompactList}\end{CompactItemize}
\subsection*{Enumerations}
\begin{CompactItemize}
\item 
enum \hyperlink{memload_8c_a18}{mem\_\-Load\-State} \{ \par
\hyperlink{memload_8c_a18a4}{MEM\_\-LOAD\_\-IDLE}, 
\par
\hyperlink{memload_8c_a18a5}{MEM\_\-LOAD\_\-ACTIVE}
 \}
\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
unsigned int \hyperlink{memload_8c_a6}{mem\_\-load\-Check\-Handle} (const \hyperlink{MEM__load_8h_a0}{MEM\_\-Load\-Handle} handle, \hyperlink{struct__mem__LoadContext}{mem\_\-Load\-Context} $\ast$$\ast$context\_\-pp, int check\_\-state, \hyperlink{memload_8c_a18}{mem\_\-Load\-State} exp\_\-state)
\begin{CompactList}\small\item\em Validate a Memory Load context handle. \item\end{CompactList}\item 
unsigned int \hyperlink{memload_8c_a7}{mem\_\-load\-Update\-Status} (\hyperlink{struct__mem__LoadContext}{mem\_\-Load\-Context} $\ast$context\_\-p, const unsigned int status)
\begin{CompactList}\small\item\em Update load context status. \item\end{CompactList}\item 
unsigned int \hyperlink{memload_8c_a8}{mem\_\-load\-Reset\-Context} (\hyperlink{struct__mem__LoadContext}{mem\_\-Load\-Context} $\ast$context\_\-p)
\begin{CompactList}\small\item\em Reset the state of a load context. \item\end{CompactList}\item 
unsigned int \hyperlink{memload_8c_a9}{MEM\_\-load\-Init} (void)
\begin{CompactList}\small\item\em Start the Memory Load system. \item\end{CompactList}\item 
unsigned int \hyperlink{memload_8c_a10}{MEM\_\-load\-Get\-Context} (\hyperlink{MEM__load_8h_a0}{MEM\_\-Load\-Handle} $\ast$handle\_\-p)
\begin{CompactList}\small\item\em Allocate a Memory Load context. \item\end{CompactList}\item 
unsigned int \hyperlink{memload_8c_a11}{MEM\_\-load\-Release\-Context} (\hyperlink{MEM__load_8h_a0}{MEM\_\-Load\-Handle} handle)
\begin{CompactList}\small\item\em Release a Memory Load context. \item\end{CompactList}\item 
unsigned int \hyperlink{memload_8c_a12}{MEM\_\-load\-Get\-Info} (const \hyperlink{MEM__load_8h_a0}{MEM\_\-Load\-Handle} handle, \hyperlink{struct__MEM__LoadInfo}{MEM\_\-Load\-Info} $\ast$info\_\-p)
\begin{CompactList}\small\item\em Get detailed information about a Memory Load context. \item\end{CompactList}\item 
unsigned int \hyperlink{memload_8c_a13}{mem\_\-load\-Start} (\hyperlink{struct__mem__LoadContext}{mem\_\-Load\-Context} $\ast$context\_\-p, const \hyperlink{struct__MEM__Descriptor}{MEM\_\-Descriptor} $\ast$md\_\-p, const unsigned char $\ast$data\_\-p)
\item 
unsigned int \hyperlink{memload_8c_a14}{MEM\_\-load\-Pkt\-Memory} (\hyperlink{MEM__load_8h_a0}{MEM\_\-Load\-Handle} handle, const void $\ast$pkt\_\-p, const unsigned int len)
\begin{CompactList}\small\item\em Handle Memory Write telecommand packets. \item\end{CompactList}\item 
unsigned int \hyperlink{memload_8c_a15}{MEM\_\-load\-Pkt\-Pci} (\hyperlink{MEM__load_8h_a0}{MEM\_\-Load\-Handle} handle, const void $\ast$pkt\_\-p, const unsigned int len)
\begin{CompactList}\small\item\em Handle Memory PCI Device Header Write telecommand packets. \item\end{CompactList}\item 
unsigned int \hyperlink{memload_8c_a16}{MEM\_\-load\-Pkt\-Reg} (\hyperlink{MEM__load_8h_a0}{MEM\_\-Load\-Handle} handle, const void $\ast$pkt\_\-p, const unsigned int len)
\begin{CompactList}\small\item\em Handle Memory Load Register telecommand packets. \item\end{CompactList}\item 
unsigned int \hyperlink{memload_8c_a17}{MEM\_\-load\-Write} (\hyperlink{MEM__load_8h_a0}{MEM\_\-Load\-Handle} handle)
\begin{CompactList}\small\item\em Write data for a Memory Load context. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Memory Load functions. 

These functions handle Memory Write telecommands and the resulting load operations.



\footnotesize\begin{verbatim}
  CVS $Id: memload.c,v 1.15 2005/04/14 21:54:24 dmay Exp $
  \end{verbatim}\normalsize


\subsection{Typedef Documentation}
\hypertarget{memload_8c_a3}{
\index{memload.c@{memload.c}!mem_LoadContext@{mem\_\-LoadContext}}
\index{mem_LoadContext@{mem\_\-LoadContext}!memload.c@{memload.c}}
\subsubsection[mem\_\-LoadContext]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{struct__mem__LoadContext}{mem\_\-Load\-Context}}}
\label{memload_8c_a3}


Typedef for \hyperlink{struct__mem__LoadContext}{\_\-mem\_\-Load\-Context}. 

The typedef for \hyperlink{struct__mem__LoadContext}{\_\-mem\_\-Load\-Context}. 

\subsection{Enumeration Type Documentation}
\hypertarget{memload_8c_a18}{
\index{memload.c@{memload.c}!mem_LoadState@{mem\_\-LoadState}}
\index{mem_LoadState@{mem\_\-LoadState}!memload.c@{memload.c}}
\subsubsection[mem\_\-LoadState]{\setlength{\rightskip}{0pt plus 5cm}enum \hyperlink{memload_8c_a18}{mem\_\-Load\-State}}}
\label{memload_8c_a18}


The typedef for the load state enum, which is a list of all possible states for a load. \begin{Desc}
\item[Enumeration values: ]\par
\begin{description}
\index{MEM_LOAD_IDLE@{MEM\_\-LOAD\_\-IDLE}!memload.c@{memload.c}}\index{memload.c@{memload.c}!MEM_LOAD_IDLE@{MEM\_\-LOAD\_\-IDLE}}\item[{\em 
\hypertarget{memload_8c_a18a4}{
{\em MEM\_\-LOAD\_\-IDLE}}
\label{memload_8c_a18a4}
}]Load is idle, i.e. not active. \index{MEM_LOAD_ACTIVE@{MEM\_\-LOAD\_\-ACTIVE}!memload.c@{memload.c}}\index{memload.c@{memload.c}!MEM_LOAD_ACTIVE@{MEM\_\-LOAD\_\-ACTIVE}}\item[{\em 
\hypertarget{memload_8c_a18a5}{
{\em MEM\_\-LOAD\_\-ACTIVE}}
\label{memload_8c_a18a5}
}]Load is active, i.e. in progress. \end{description}
\end{Desc}



\subsection{Function Documentation}
\hypertarget{memload_8c_a6}{
\index{memload.c@{memload.c}!mem_loadCheckHandle@{mem\_\-loadCheckHandle}}
\index{mem_loadCheckHandle@{mem\_\-loadCheckHandle}!memload.c@{memload.c}}
\subsubsection[mem\_\-loadCheckHandle]{\setlength{\rightskip}{0pt plus 5cm}unsigned int mem\_\-load\-Check\-Handle (const \hyperlink{MEM__load_8h_a0}{MEM\_\-Load\-Handle} {\em handle}, \hyperlink{struct__mem__LoadContext}{mem\_\-Load\-Context} $\ast$$\ast$ {\em context\_\-pp}, int {\em check\_\-state}, \hyperlink{memload_8c_a18}{mem\_\-Load\-State} {\em exp\_\-state})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{memload_8c_a6}


Validate a Memory Load context handle. 

Validate a Memory Load context handle and return a pointer to the corresponding context.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em handle}]Handle for the context. \item[{\em context\_\-pp}]Pointer to location to return context pointer. \item[{\em check\_\-state}]Check context state? nonzero =$>$ yes, 0 =$>$ no. \item[{\em exp\_\-state}]Expected context state.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A MEM MSG code. \end{Desc}
\hypertarget{memload_8c_a10}{
\index{memload.c@{memload.c}!MEM_loadGetContext@{MEM\_\-loadGetContext}}
\index{MEM_loadGetContext@{MEM\_\-loadGetContext}!memload.c@{memload.c}}
\subsubsection[MEM\_\-loadGetContext]{\setlength{\rightskip}{0pt plus 5cm}unsigned int MEM\_\-load\-Get\-Context (\hyperlink{MEM__load_8h_a0}{MEM\_\-Load\-Handle} $\ast$ {\em handle\_\-p})}}
\label{memload_8c_a10}


Allocate a Memory Load context. 

Allocate a Memory Load context. This is analogous to a constructor for a context. This function returns only a handle to a context. The details of the context are hidden from the user. The \hyperlink{MEM__load_8h_a5}{MEM\_\-load\-Get\-Info()} function can be used to get detailed information about the context.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em handle\_\-p}]Pointer to location to return context handle.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A MEM MSG code. \end{Desc}


Here is the call graph for this function:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=170pt]{memload_8c_a10_cgraph}
\end{center}
\end{figure}
\hypertarget{memload_8c_a12}{
\index{memload.c@{memload.c}!MEM_loadGetInfo@{MEM\_\-loadGetInfo}}
\index{MEM_loadGetInfo@{MEM\_\-loadGetInfo}!memload.c@{memload.c}}
\subsubsection[MEM\_\-loadGetInfo]{\setlength{\rightskip}{0pt plus 5cm}unsigned int MEM\_\-load\-Get\-Info (const \hyperlink{MEM__load_8h_a0}{MEM\_\-Load\-Handle} {\em handle}, \hyperlink{struct__MEM__LoadInfo}{MEM\_\-Load\-Info} $\ast$ {\em info\_\-p})}}
\label{memload_8c_a12}


Get detailed information about a Memory Load context. 

Get information about a Memory Load context. The information returned is a subset of the context details that are normally hidden from the user.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em handle}]Handle for context. \item[{\em info\_\-p}]Pointer to location to return context info.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A MEM MSG code. \end{Desc}


Here is the call graph for this function:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=163pt]{memload_8c_a12_cgraph}
\end{center}
\end{figure}
\hypertarget{memload_8c_a9}{
\index{memload.c@{memload.c}!MEM_loadInit@{MEM\_\-loadInit}}
\index{MEM_loadInit@{MEM\_\-loadInit}!memload.c@{memload.c}}
\subsubsection[MEM\_\-loadInit]{\setlength{\rightskip}{0pt plus 5cm}unsigned int MEM\_\-load\-Init (void)}}
\label{memload_8c_a9}


Start the Memory Load system. 

Start the Memory Load system. This function should be called once to initialize the internal state associated with the Memory Load telecommand handler.

\begin{Desc}
\item[Returns:]A MEM MSG code. \end{Desc}
\hypertarget{memload_8c_a14}{
\index{memload.c@{memload.c}!MEM_loadPktMemory@{MEM\_\-loadPktMemory}}
\index{MEM_loadPktMemory@{MEM\_\-loadPktMemory}!memload.c@{memload.c}}
\subsubsection[MEM\_\-loadPktMemory]{\setlength{\rightskip}{0pt plus 5cm}unsigned int MEM\_\-load\-Pkt\-Memory (\hyperlink{MEM__load_8h_a0}{MEM\_\-Load\-Handle} {\em handle}, const void $\ast$ {\em pkt\_\-p}, const unsigned int {\em len})}}
\label{memload_8c_a14}


Handle Memory Write telecommand packets. 

Announces the arrival of a new Memory Write telecommand CCSDS packet.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em handle}]Handle for load context. \item[{\em pkt\_\-p}]Pointer to packet. \item[{\em len}]Length of packet, in bytes.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A MSG code. \end{Desc}


Here is the call graph for this function:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=271pt]{memload_8c_a14_cgraph}
\end{center}
\end{figure}
\hypertarget{memload_8c_a15}{
\index{memload.c@{memload.c}!MEM_loadPktPci@{MEM\_\-loadPktPci}}
\index{MEM_loadPktPci@{MEM\_\-loadPktPci}!memload.c@{memload.c}}
\subsubsection[MEM\_\-loadPktPci]{\setlength{\rightskip}{0pt plus 5cm}unsigned int MEM\_\-load\-Pkt\-Pci (\hyperlink{MEM__load_8h_a0}{MEM\_\-Load\-Handle} {\em handle}, const void $\ast$ {\em pkt\_\-p}, const unsigned int {\em len})}}
\label{memload_8c_a15}


Handle Memory PCI Device Header Write telecommand packets. 

Announces the arrival of a new Memory PCI Device Header Write telecommand CCSDS packet.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em handle}]Handle for load context. \item[{\em pkt\_\-p}]Pointer to packet. \item[{\em len}]Length of packet, in bytes.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A MSG code. \end{Desc}


Here is the call graph for this function:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=257pt]{memload_8c_a15_cgraph}
\end{center}
\end{figure}
\hypertarget{memload_8c_a16}{
\index{memload.c@{memload.c}!MEM_loadPktReg@{MEM\_\-loadPktReg}}
\index{MEM_loadPktReg@{MEM\_\-loadPktReg}!memload.c@{memload.c}}
\subsubsection[MEM\_\-loadPktReg]{\setlength{\rightskip}{0pt plus 5cm}unsigned int MEM\_\-load\-Pkt\-Reg (\hyperlink{MEM__load_8h_a0}{MEM\_\-Load\-Handle} {\em handle}, const void $\ast$ {\em pkt\_\-p}, const unsigned int {\em len})}}
\label{memload_8c_a16}


Handle Memory Load Register telecommand packets. 

Announces the arrival of a new Memory Processor Register Write telecommand CCSDS packet.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em handle}]Handle for load context. \item[{\em pkt\_\-p}]Pointer to packet. \item[{\em len}]Length of packet, in bytes.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A MSG code. \end{Desc}


Here is the call graph for this function:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=260pt]{memload_8c_a16_cgraph}
\end{center}
\end{figure}
\hypertarget{memload_8c_a11}{
\index{memload.c@{memload.c}!MEM_loadReleaseContext@{MEM\_\-loadReleaseContext}}
\index{MEM_loadReleaseContext@{MEM\_\-loadReleaseContext}!memload.c@{memload.c}}
\subsubsection[MEM\_\-loadReleaseContext]{\setlength{\rightskip}{0pt plus 5cm}unsigned int MEM\_\-load\-Release\-Context (\hyperlink{MEM__load_8h_a0}{MEM\_\-Load\-Handle} {\em handle})}}
\label{memload_8c_a11}


Release a Memory Load context. 

Release a Memory Load context so that the memory associated to it can be re-allocated. This is analogous to a destructor for a context.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em handle}]Handle for context to release.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A MEM MSG code. \end{Desc}


Here is the call graph for this function:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=181pt]{memload_8c_a11_cgraph}
\end{center}
\end{figure}
\hypertarget{memload_8c_a8}{
\index{memload.c@{memload.c}!mem_loadResetContext@{mem\_\-loadResetContext}}
\index{mem_loadResetContext@{mem\_\-loadResetContext}!memload.c@{memload.c}}
\subsubsection[mem\_\-loadResetContext]{\setlength{\rightskip}{0pt plus 5cm}unsigned int mem\_\-load\-Reset\-Context (\hyperlink{struct__mem__LoadContext}{mem\_\-Load\-Context} $\ast$ {\em context\_\-p})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{memload_8c_a8}


Reset the state of a load context. 

Reset the state of a load context.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em context\_\-p}]Pointer to load context.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A MEM MSG code. \end{Desc}
\hypertarget{memload_8c_a13}{
\index{memload.c@{memload.c}!mem_loadStart@{mem\_\-loadStart}}
\index{mem_loadStart@{mem\_\-loadStart}!memload.c@{memload.c}}
\subsubsection[mem\_\-loadStart]{\setlength{\rightskip}{0pt plus 5cm}unsigned int mem\_\-load\-Start (\hyperlink{struct__mem__LoadContext}{mem\_\-Load\-Context} $\ast$ {\em context\_\-p}, const \hyperlink{struct__MEM__Descriptor}{MEM\_\-Descriptor} $\ast$ {\em md\_\-p}, const unsigned char $\ast$ {\em data\_\-p})}}
\label{memload_8c_a13}


Start a Memory Write operation. Updates the Memory Load context to reflect the start of a load operation.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em context\_\-p}]Pointer to load context. \item[{\em md\_\-p}]Pointer to target memory descriptor. \item[{\em data\_\-p}]Pointer to buffer containing the data to write.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A MSG code. \end{Desc}


Here is the call graph for this function:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=167pt]{memload_8c_a13_cgraph}
\end{center}
\end{figure}
\hypertarget{memload_8c_a7}{
\index{memload.c@{memload.c}!mem_loadUpdateStatus@{mem\_\-loadUpdateStatus}}
\index{mem_loadUpdateStatus@{mem\_\-loadUpdateStatus}!memload.c@{memload.c}}
\subsubsection[mem\_\-loadUpdateStatus]{\setlength{\rightskip}{0pt plus 5cm}unsigned int mem\_\-load\-Update\-Status (\hyperlink{struct__mem__LoadContext}{mem\_\-Load\-Context} $\ast$ {\em context\_\-p}, const unsigned int {\em status})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{memload_8c_a7}


Update load context status. 

Update a load context with the specified status.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em context\_\-p}]Pointer to load context. \item[{\em status}]Most recent function status.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A MEM MSG code. \end{Desc}
\hypertarget{memload_8c_a17}{
\index{memload.c@{memload.c}!MEM_loadWrite@{MEM\_\-loadWrite}}
\index{MEM_loadWrite@{MEM\_\-loadWrite}!memload.c@{memload.c}}
\subsubsection[MEM\_\-loadWrite]{\setlength{\rightskip}{0pt plus 5cm}unsigned int MEM\_\-load\-Write (\hyperlink{MEM__load_8h_a0}{MEM\_\-Load\-Handle} {\em handle})}}
\label{memload_8c_a17}


Write data for a Memory Load context. 

Write another chunk of data for the specified Memory Load context. This function should be called repeatedly until all the data associated with the context has been written to memory. The status of the Memory Load operation can be obtained with the \hyperlink{MEM__load_8h_a5}{MEM\_\-load\-Get\-Info()} function.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em handle}]Handle for context in which to write the data.\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A MEM MSG code. \end{Desc}


Here is the call graph for this function:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=157pt]{memload_8c_a17_cgraph}
\end{center}
\end{figure}
