#ifndef __PUBFUNCS_H__ #define __PUBFUNCS_H__ //----- Global functions defined in this module ------------------------------------------------------------------ extern int get_block (K_BLOCK * block, K_POOL poolid, int size); extern void init_block (K_BLOCK *p_block, int length); extern unsigned int andmask (unsigned int * dst, unsigned int len, unsigned int mask); extern void prepare_TM_packet (K_BLOCK *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int); extern int release_block (K_BLOCK *); extern void compute_and_add_LCU_CRC (unsigned int * lcu_macro); //----- Global variables defined in this module ------------------------------------------------------------------ extern unsigned int Memory_Pool_Occupation[5]; extern unsigned int Observation_ID; extern unsigned int Meas_BuildingBlock_ID; extern unsigned int Cur_BuildingBlock_ID; //----- Global defines in this module ------------------------------------------------------------------ // PACKING CODES #define PACKING_8 0 #define PACKING_16 1 #define PACKING_24 2 #define PACKING_32 3 /* ----------- Packing and unpacking macros --------------------------------------------*/ #define PACK(macro_var_a,macro_var_b) ( (macro_var_a<<16) + (macro_var_b) ) #define UNPACK(macro_var_a,macro_var_b) { (macro_var_a)[0] = (macro_var_b) >> 16; (macro_var_a)[1] = (macro_var_b) & 0xFFFF;} #define PACK8(macro_var_a,macro_var_b) ( (macro_var_a<<8) | (macro_var_b & 0xFF) ) // DATA PACKETS CODES #define HKP 0 #define SCIP 1 #define MEMP 2 /*******************************************************************************************************/ /*******************************************************************************************************/ // STRUCTURE OF ALL QUEUES' MESSAGE /*******************************************************************************************************/ /*******************************************************************************************************/ typedef struct { K_BLOCK block; // structure to manage the block (used also to free it) int offset; // this is the displacement (from the beginning of the block) that points to the current packet int length; // number of 16-bit data words int count; // packet downcounter - if 0 free the block int first_ch; // first channel of the packet int packing; // bit packing flag: 0->8 bit, 1->16 bit, 2->24 bit, 3->32 bit // 0xff0000 data packet code: 1=sci 2=memdump // 0x00ff00 non esa header length in 16bits word // 0x0000ff packing 12/6/02 } TM_MSG, SD_TM_MSG, // Science Data TeleMetry MeSsaGe HK_TM_MSG, // HouseKeeping TeleMetry MeSsaGe EVNT_TM_MSG, TC_MSG; typedef struct { unsigned int subsysID; // HRS or WBS unsigned int measID; // tuning procs K_BLOCK block; // structure to manage the block (used also to free it) int int_scan_cnt; // wbs integrated scan count int phase; // modulation phase unsigned int transfer_cnt; // frame counter for the fifo identified by field subsysID int time_position; // a reference to get the TS of the frame } SD_PKT_MSG; typedef struct { unsigned int command_number; // progressive number of the command to which the msg is relative unsigned int operation_id; // ID to be used to decide what to do int block_loaded; // if 0 no block is allocated, if 1 yes (and needs to be freed) K_BLOCK block; // block to possibly store the TC packet in (4 ints) unsigned int exec_attempts; // counter of the number of times that the packet was tried for execution unsigned int data[2]; // array used to pass possible parameters } HS_HDL_MSG, LS_HDL_MSG; #endif