GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> LEM / V4-8-1 > lem_lists / rhel6-32


Interface   Data Structures   File List   Data Fields   Globals  

list_macros.h File Reference

Macros used with command and result lists. More...

#include <LEM/msg_macros.h>
#include <LEM/list_structs.h>
#include <LEM/encode.h>
#include <PBI/PTR.h>

Defines

#define LEM_ALIGN(_buf, _offset, _alignment)   (((PTR_as_uint)(_buf) + (_offset) + ((_alignment) - 1)) & ~((_alignment) - 1))
 Get the first aligned pointer in the buffer that is at least _offset into the buffer.
#define LEM_ALIGN_REQUEST(_buf, _offset)   LEM_ALIGN(_buf, _offset, LCB_REQUEST_LIST_ALIGN)
 Get the first pointer with the correct aligment for a request list that is at least _offset into the buffer.
#define LEM_ALIGN_RESULT(_buf,_offset)   LEM_ALIGN(_buf, _offset, LCB_RESULT_LIST_ALIGN)
 Get the first pointer with the correct aligment for a result list that is at least _offset into the buffer.
#define LEM_REQUEST_SIZE(N_CI)   ( sizeof(LCB_cl_hdr) + N_CI * sizeof(LEM_ci))
 Size of command list with N_CI command items.
#define LEM_RESPONSE_SIZE(N_CI)   (sizeof(LCBD_xcb) + sizeof(LCB_rl_hdr) + N_CI * sizeof(LEM_rsp_ri))
 Size of a response result list with N_CI items.
#define LEM_RESPONSELESS_SIZE(N_CI)   (sizeof(LCBD_xcb) + sizeof(LCB_rl_hdr) + N_CI * sizeof(LEM_cmd_ri))
 Size of a responsless result list with N_CI items.
#define LEM_DECODE_SIZE(N_CI)   ( N_CI * sizeof(LEM_di))
 Size of a decode list with N_CI items.
#define LEM_SIZE_FOR_CR(N_CI)
 Size of a char array needed to accomodate the lists of a command/response structure with N_CI command items.
#define LEM_INIT_CR(CR, BUF, N_CI)
 Initialise a CR struct using a char array that can accomodate the lists of command/response structure with N_CI command items.
#define LEM_RESET_CR(CRP)
 Reset the counters inside a CR struct.
#define LEM_NEXT_CI(CRP)   (&CRP->cl->ci[CRP->nf++])
 Pointer to the current command item in a command/response structure and increment the read counter.
#define LEM_NEXT_RI(CRP)   (&CRP->rl->ri[CRP->nr++])
 Pointer to the current responseful result item in a command/response structure and increment the read counter.
#define LEM_NEXT_EI(CRP)   (&CRP->el->ri[CRP->nr++])
 Pointer to the current responseless result (error) item in a command/response structure and increment the read counter.
#define LEM_CURR_CI(CRP)   (&CRP->cl->ci[CRP->nf])
 Pointer to the current command item in a command/response structure.
#define LEM_CURR_RI(CRP)   (&CRP->rl->ri[CRP->nr])
 Pointer to the current responseful result item in a command/response structure.
#define LEM_CURR_EI(CRP)   (&CRP->el->ri[CRP->nr])
 Pointer to the current responseless result (error) item in a command/response structure.
#define LEM_Q(CRP, RESULT_HANDLER)
 Queue the list, wait for the list to complete, call the result handling function and reset the C/R structure.
#define LEM_Q_IF_FULL(CRP, RESULT_HANDLER)
 If the number of filled command items equals the total number of items in the command and response lists, queue the list.
#define LEM_READ(CRP, DECODE_FN, DEST, ENCODE_FN, ARGS...)
 Fill the command item to perform the desired read and set the fields of the corresponding decode item; if this is the last item on the list, queue the list.
#define LEM_LOAD(CRP, ENCODE_FN, ARGS...)
 Fill the command item to perform the desired load; if this is the last item on the list, queue the list.
#define LEM_CMD(CRP, ENCODE_FN, ARGS...)
 Fill the command item to perform the dataless command; if this is the last item on the list, queue the list.
#define LEM_RAST(CRP, DECODE_FN, DEST, ENCODE_FN, ARGS...)
 Read-last; Perform a LEM_READ but force the Q.
#define LEM_LAST(CRP, ENCODE_FN, ARGS...)
 Load-last; Perform a LEM_LOAD but force the Q.
#define LEM_CAST(CRP, ENCODE_FN, ARGS...)
 Command-last; Perform a LEM_CMD but force the Q.
#define LEM_ACD_READ(CRP, DECODE_FN, DEST, ENCODE_FN, ARGS...)
 Fill the command item to perform the desired read and set the fields of the corresponding decode item; if this is the last item on the list, queue the list.
#define LEM_ACD_LOAD(CRP, ENCODE_FN, ARGS...)
 Fill the command item to perform the desired load; if this is the last item on the list, queue the list.
#define LEM_ACD_CMD(CRP, ENCODE_FN, ARGS...)
 Fill the command item to perform the dataless command; if this is the last item on the list, queue the list.
#define LEM_ACD_RAST(CRP, DECODE_FN, DEST, ENCODE_FN, ARGS...)
 Read-last; Perform a LEM_ACD_READ but force the Q.
#define LEM_ACD_LAST(CRP, ENCODE_FN, ARGS...)
 Load-last; Perform a LEM_ACD_LOAD but force the Q.
#define LEM_ACD_CAST(CRP, ENCODE_FN, ARGS...)
 Command-last; Perform a LEM_ACD_CMD but force the Q.


Detailed Description

Macros used with command and result lists.

Author:
James Swain & Owen Saxton
$Id: list_macros.h,v 1.8 2011/03/25 18:51:52 apw Exp $

Define Documentation

#define LEM_ACD_CAST ( CRP,
ENCODE_FN,
ARGS...   ) 

Value:

{ \
  ENCODE_FN(LEM_NEXT_CI(CRP), ACD_CMD_DATALESS, ## ARGS, 0); \
  LEM_Q(CRP, LEM_handleLoadErrors);\
}
Command-last; Perform a LEM_ACD_CMD but force the Q.

CRP Pointer to multi-item command/response lists

ENCODE_FN Function to use to fill the command item

ARGS... Arguments to the ENCODE functions, except the first two, which are filled in automatically

#define LEM_ACD_CMD ( CRP,
ENCODE_FN,
ARGS...   ) 

Value:

{ \
  ENCODE_FN(LEM_NEXT_CI(CRP), ACD_CMD_DATALESS, ## ARGS, 0); \
  LEM_Q_IF_FULL(CRP, LEM_handleLoadErrors);\
}
Fill the command item to perform the dataless command; if this is the last item on the list, queue the list.

CRP Pointer to multi-item command/response lists

ENCODE_FN Function to use to fill the command item

ARGS... Arguments to the ENCODE functions, except the first two and the last, which are filled in automatically

#define LEM_ACD_LAST ( CRP,
ENCODE_FN,
ARGS...   ) 

Value:

{\
  ENCODE_FN(LEM_NEXT_CI(CRP), ACD_CMD_LOAD, ## ARGS); \
  LEM_Q(CRP, LEM_handleLoadErrors);\
}
Load-last; Perform a LEM_ACD_LOAD but force the Q.

CRP Pointer to a multi-item command/response lists

ENCODE_FN Function to use to fill the command item

ARGS... Arguments to the ENCODE function, except the first two and the last one, which are filled in automatically

#define LEM_ACD_LOAD ( CRP,
ENCODE_FN,
ARGS...   ) 

Value:

{ \
  ENCODE_FN(LEM_NEXT_CI(CRP), ACD_CMD_LOAD, ## ARGS); \
  LEM_Q_IF_FULL(CRP, LEM_handleLoadErrors);\
}
Fill the command item to perform the desired load; if this is the last item on the list, queue the list.

CRP Pointer to multi-item command/response lists

ENCODE_FN Function to use to fill the command item

ARGS... Arguments to the ENCODE function, except the first two, which are filled in automatically

#define LEM_ACD_RAST ( CRP,
DECODE_FN,
DEST,
ENCODE_FN,
ARGS...   ) 

Value:

{\
  CRP->lem_di[CRP->nf].fn  = (pDecode)(DECODE_FN); \
  CRP->lem_di[CRP->nf].des = DEST; \
  ENCODE_FN(LEM_NEXT_CI(CRP), ACD_CMD_READ, ## ARGS, 0); \
  LEM_Q(CRP, LEM_decode);\
}
Read-last; Perform a LEM_ACD_READ but force the Q.

CRP Pointer to a multi-item command/response lists

DECODE_FN Function to use to decode the results

DEST Pointer to location to place the decoded results

ENCODE_FN Function to use to fill the command item

ARGS... Arguments to the ENCODE function, except the first two and the last one, which are filled in automatically

#define LEM_ACD_READ ( CRP,
DECODE_FN,
DEST,
ENCODE_FN,
ARGS...   ) 

Value:

{ \
  CRP->lem_di[CRP->nf].fn  = (pDecode)(DECODE_FN); \
  CRP->lem_di[CRP->nf].des = DEST; \
  ENCODE_FN(LEM_NEXT_CI(CRP), ACD_CMD_READ, ## ARGS, 0); \
  LEM_Q_IF_FULL(CRP, LEM_decode);\
}
Fill the command item to perform the desired read and set the fields of the corresponding decode item; if this is the last item on the list, queue the list.

CRP Pointer to multi-item command/response lists

DECODE_FN Function to use to decode the results

DEST Pointer to location to place the decoded results

ENCODE_FN Function to use to fill the command item

ARGS... Arguments to the ENCODE function, except the first two and the last one, which are filled in automatically

#define LEM_ALIGN ( _buf,
_offset,
_alignment   )     (((PTR_as_uint)(_buf) + (_offset) + ((_alignment) - 1)) & ~((_alignment) - 1))

Get the first aligned pointer in the buffer that is at least _offset into the buffer.

#define LEM_ALIGN_REQUEST ( _buf,
_offset   )     LEM_ALIGN(_buf, _offset, LCB_REQUEST_LIST_ALIGN)

Get the first pointer with the correct aligment for a request list that is at least _offset into the buffer.

#define LEM_ALIGN_RESULT ( _buf,
_offset   )     LEM_ALIGN(_buf, _offset, LCB_RESULT_LIST_ALIGN)

Get the first pointer with the correct aligment for a result list that is at least _offset into the buffer.

#define LEM_CAST ( CRP,
ENCODE_FN,
ARGS...   ) 

Value:

{ \
  ENCODE_FN(LEM_NEXT_CI(CRP), CMD_DATALESS, ## ARGS, 0); \
  LEM_Q(CRP, LEM_handleLoadErrors);\
}
Command-last; Perform a LEM_CMD but force the Q.

CRP Pointer to multi-item command/response lists

ENCODE_FN Function to use to fill the command item

ARGS... Arguments to the ENCODE functions, except the first two, which are filled in automatically

#define LEM_CMD ( CRP,
ENCODE_FN,
ARGS...   ) 

Value:

{ \
  ENCODE_FN(LEM_NEXT_CI(CRP), CMD_DATALESS, ## ARGS, 0); \
  LEM_Q_IF_FULL(CRP, LEM_handleLoadErrors);\
}
Fill the command item to perform the dataless command; if this is the last item on the list, queue the list.

CRP Pointer to multi-item command/response lists

ENCODE_FN Function to use to fill the command item

ARGS... Arguments to the ENCODE functions, except the first two and the last, which are filled in automatically

#define LEM_CURR_CI ( CRP   )     (&CRP->cl->ci[CRP->nf])

Pointer to the current command item in a command/response structure.

#define LEM_CURR_EI ( CRP   )     (&CRP->el->ri[CRP->nr])

Pointer to the current responseless result (error) item in a command/response structure.

Assumes that the command list was a homogeneous list of loads.

Referenced by LEM_handleLoadErrors().

#define LEM_CURR_RI ( CRP   )     (&CRP->rl->ri[CRP->nr])

Pointer to the current responseful result item in a command/response structure.

Assumes that the command list was a homogeneous list of reads

Referenced by LEM_decode(), and LEM_handleReadErrors().

#define LEM_DECODE_SIZE ( N_CI   )     ( N_CI * sizeof(LEM_di))

Size of a decode list with N_CI items.

Referenced by LEM_sizeofDcdList().

#define LEM_INIT_CR ( CR,
BUF,
N_CI   ) 

Value:

{\
  CR.ni      = N_CI; \
  CR.lcbd_cl = (LCBD_cl*)LEM_ALIGN_REQUEST(BUF, 0); \
  CR.lcbd_rl = (LCBD_rl*)LEM_ALIGN_RESULT (CR.lcbd_cl, LEM_REQUEST_SIZE(N_CI)); \
  CR.lem_di  = (LEM_di*)((char*)(CR.lcbd_rl) + LEM_RESPONSE_SIZE(N_CI)); \
  CR.nf      = 0; \
  CR.nr      = 0; \
  CR.cl      = (LEM_micl*    )(CR.lcbd_cl); \
  CR.el      = (LEM_cmd_mirl*)(CR.lcbd_rl); \
  CR.rl      = (LEM_rsp_mirl*)(CR.lcbd_rl); \
}
Initialise a CR struct using a char array that can accomodate the lists of command/response structure with N_CI command items.

#define LEM_LAST ( CRP,
ENCODE_FN,
ARGS...   ) 

Value:

{\
  ENCODE_FN(LEM_NEXT_CI(CRP), CMD_LOAD, ## ARGS); \
  LEM_Q(CRP, LEM_handleLoadErrors);\
}
Load-last; Perform a LEM_LOAD but force the Q.

CRP Pointer to a multi-item command/response lists

ENCODE_FN Function to use to fill the command item

ARGS... Arguments to the ENCODE function, except the first two and the last one, which are filled in automatically

#define LEM_LOAD ( CRP,
ENCODE_FN,
ARGS...   ) 

Value:

{ \
  ENCODE_FN(LEM_NEXT_CI(CRP), CMD_LOAD, ## ARGS); \
  LEM_Q_IF_FULL(CRP, LEM_handleLoadErrors);\
}
Fill the command item to perform the desired load; if this is the last item on the list, queue the list.

CRP Pointer to multi-item command/response lists

ENCODE_FN Function to use to fill the command item

ARGS... Arguments to the ENCODE function, except the first two, which are filled in automatically

#define LEM_NEXT_CI ( CRP   )     (&CRP->cl->ci[CRP->nf++])

Pointer to the current command item in a command/response structure and increment the read counter.

#define LEM_NEXT_EI ( CRP   )     (&CRP->el->ri[CRP->nr++])

Pointer to the current responseless result (error) item in a command/response structure and increment the read counter.

Assumes that the command list was a homogeneous list of loads.

#define LEM_NEXT_RI ( CRP   )     (&CRP->rl->ri[CRP->nr++])

Pointer to the current responseful result item in a command/response structure and increment the read counter.

Assumes that the command list is a homogeneous list of reads

#define LEM_Q ( CRP,
RESULT_HANDLER   ) 

Value:

{ \
  CHECK_CALL(LEM_queueWait (CRP)); \
  CHECK_CALL(RESULT_HANDLER(CRP)); \
  LEM_RESET_CR(CRP); \
}
Queue the list, wait for the list to complete, call the result handling function and reset the C/R structure.

CRP Pointer to a multi-item command/response list

RESULT_HANDLER One of LEM_handleLoadErrors, LEM_handleReadErrors or LEM_decode

#define LEM_Q_IF_FULL ( CRP,
RESULT_HANDLER   ) 

Value:

if(CRP->ni == CRP->nf) { \
    LEM_Q(CRP, RESULT_HANDLER); \
  }
If the number of filled command items equals the total number of items in the command and response lists, queue the list.

CRP Pointer to a multi-item command response list

RESULT_HANDLER One of LEM_handleLoadErrors, LEM_handleReadErrors or LEM_decode

#define LEM_RAST ( CRP,
DECODE_FN,
DEST,
ENCODE_FN,
ARGS...   ) 

Value:

{\
  CRP->lem_di[CRP->nf].fn  = (pDecode)(DECODE_FN); \
  CRP->lem_di[CRP->nf].des = DEST; \
  ENCODE_FN(LEM_NEXT_CI(CRP), CMD_READ, ## ARGS, 0); \
  LEM_Q(CRP, LEM_decode);\
}
Read-last; Perform a LEM_READ but force the Q.

CRP Pointer to a multi-item command/response lists

DECODE_FN Function to use to decode the results

DEST Pointer to location to place the decoded results

ENCODE_FN Function to use to fill the command item

ARGS... Arguments to the ENCODE function, except the first two and the last one, which are filled in automatically

#define LEM_READ ( CRP,
DECODE_FN,
DEST,
ENCODE_FN,
ARGS...   ) 

Value:

{ \
  CRP->lem_di[CRP->nf].fn  = (pDecode)(DECODE_FN); \
  CRP->lem_di[CRP->nf].des = DEST; \
  ENCODE_FN(LEM_NEXT_CI(CRP), CMD_READ, ## ARGS, 0); \
  LEM_Q_IF_FULL(CRP, LEM_decode);\
}
Fill the command item to perform the desired read and set the fields of the corresponding decode item; if this is the last item on the list, queue the list.

CRP Pointer to multi-item command/response lists

DECODE_FN Function to use to decode the results

DEST Pointer to location to place the decoded results

ENCODE_FN Function to use to fill the command item

ARGS... Arguments to the ENCODE function, except the first two and the last one, which are filled in automatically

#define LEM_REQUEST_SIZE ( N_CI   )     ( sizeof(LCB_cl_hdr) + N_CI * sizeof(LEM_ci))

Size of command list with N_CI command items.

Referenced by LEM_queueWait(), and LEM_sizeofCmdList().

#define LEM_RESET_CR ( CRP   ) 

Value:

{\
  CRP->nf = 0; \
  CRP->nr = 0; \
}
Reset the counters inside a CR struct.

#define LEM_RESPONSE_SIZE ( N_CI   )     (sizeof(LCBD_xcb) + sizeof(LCB_rl_hdr) + N_CI * sizeof(LEM_rsp_ri))

Size of a response result list with N_CI items.

Referenced by LEM_sizeofRspList().

#define LEM_RESPONSELESS_SIZE ( N_CI   )     (sizeof(LCBD_xcb) + sizeof(LCB_rl_hdr) + N_CI * sizeof(LEM_cmd_ri))

Size of a responsless result list with N_CI items.

Referenced by LEM_sizeofRsplsList().

#define LEM_SIZE_FOR_CR ( N_CI   ) 

Value:

( LCB_REQUEST_LIST_ALIGN + LEM_REQUEST_SIZE(N_CI) + LCB_RESULT_LIST_ALIGN \
    + LEM_RESPONSE_SIZE(N_CI) + LEM_DECODE_SIZE(N_CI))
Size of a char array needed to accomodate the lists of a command/response structure with N_CI command items.


Generated on Tue Nov 29 16:56:59 2011 by  doxygen 1.5.8