source: svn/trunk/zas_dstar/hal/include/dsthalPsiDsmcc.h @ 2

Last change on this file since 2 was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
File size: 17.4 KB
Line 
1/*************************************************************************
2 * 
3 * DsmccCommon.h - Contains the structures and includes DSMCC module
4 *   
5 * Copyright 2006 Digital Stream Technology
6 * All Rights Reserved
7 *       
8 **************************************************************************/
9#ifndef DSMCC_COMMON_H
10#define DSMCC_COMMON_H
11
12//#include "dstddPsiBitBuffer.h"
13#include "dsthalPsiMemChain.h"
14
15//#include "DsmccAPI.h"
16/**************************************************************************
17DSM-CC DDB Structure Defines
18**************************************************************************/
19
20typedef enum
21{
22    eDDBMemData,                            // DDB buffer contains module image
23    eDDBFileData                            // DDB buffer contains filename string
24
25} eDDBDataType_t;
26
27// DDB message processing return values
28typedef enum
29{
30    eDsmccDDBTableIsComplete,
31    eDsmccDDBInitContextFail,
32    eDsmccDDBOutOfCPUMemory,
33    eDsmccDDBParseError,
34    eDsmccDDBWrongDownloadId,
35    eDsmccDDBWrongModuleId,
36    eDsmccDDBWrongVersion,
37    eDsmccDDBInvalidBlockNum,
38    eDsmccDDBBlockRecvd,
39    eDsmccDDBMemOutOfBound
40
41} eDSMCCRetval_t;
42
43// Event message enumerates
44typedef enum
45{
46        eDsmccDeactivate,
47        eDsmccActivate,
48    eDsmccDIIDataReceived,
49    eDsmccDDBDataReceived
50
51} eDSMCCEvent_t;
52
53
54typedef void (*DsmccEventProc_t)( DHL_PSI_HANDLE *psiHandle, void *pDsmccData );
55typedef void (*DsmccStatusProc_t)( DHL_PSI_HANDLE *psiHandle, eDSMCCRetval_t DsmccMsg, DS_U32 param);
56
57// This data structure is returned to DSMCC DDB client as the callback function's parameter
58// Client needs to destroy this data structure using FreeDsmccMemChain( DDBModulePtr_t )
59typedef struct                             
60{                                           
61    //*** Copies of DDB monitoring parameters ***//
62    DS_U16              moduleId;           // DDB module ID
63    DS_U8               moduleVersion;      // DDB module version
64    DS_U32              moduleSize;         // DDB total module size
65
66    //*** DDB module info and data ***//
67    eDDBDataType_t      dataType;           // Type of information in the buffer
68    DS_U8               *pDDBBuffer;        // Buffer to store the module data or path/filename string
69    DS_U8               *pDDBIndex;         // The path/filename string of block directory (contains block number and index)
70    DS_U32              blockTotal;         // Total number of blocks
71    DS_U16              blockSize;          // Size of each block
72
73} DDBModule_t, *DDBModulePtr_t;
74
75
76typedef struct
77{
78    DS_U16              blockNumber;        // The block's sequence number
79    DS_U16              blockIndex;         // The data block index in the DDB module data file
80
81} DDBFileDir_t, *DDBFileDirPtr_t;
82
83/**************************************************************************
84DSM-CC DII Structure Defines
85**************************************************************************/
86
87typedef struct
88{
89    DS_U8                   adaptationType;
90    DS_U8                   DIIMsgNumber;
91
92} *dsmccDIIAdaptHeaderPtr_t;
93   
94typedef struct
95{
96    DS_U8                   protocolDiscriminator;
97    DS_U8                   dsmccType;
98    DS_U16                  messageId;
99    DS_U32                  transaction_id;
100    DS_U8                   adaptationLength;
101    DS_U16                  messageLength;
102    dsmccDIIAdaptHeaderPtr_t ptrDsmccAdaptationHeader;
103
104} DsmccMsgHeader_t, *DsmccMsgHeaderPtr_t;
105
106typedef struct
107{
108    DS_U8                   subDescType;
109    DS_U8                   subDescLength;
110    DS_U8                   subDescInfoByte;
111
112} CompatblSubDesc_t, *CompatblSubDescPtr_t;
113
114typedef struct
115{
116    DS_U8                   descType;
117    DS_U8                   descLength;
118    DS_U8                   specifierType;
119    DS_U32                  specifierData;
120    DS_U16                  model;
121    DS_U16                  version;
122
123    DS_BOOL                 bValid;
124    DS_U8                   subDescCount;
125    ////CompatblSubDesc_t   subDescInfo;
126
127} CompatblDescInfo_t, *CompatblDescInfoPtr_t;
128
129typedef struct
130{
131    DS_U16                  descLength;
132    DS_U16                  descCount;
133    DS_U8                  *descriptors;
134    CompatblDescInfo_t      compatblDescInfo;
135
136} CompatblDesc_t;
137
138typedef struct
139{
140    DS_U16                  moduleId;
141    DS_U32                  moduleSize;
142    DS_U8                   moduleVersion;
143
144    DS_U8                   moduleInfoLength;
145    DS_U8*                  ptrModuleInfoByte;
146
147    DS_U16                  module_name_length;
148    DS_U8*                  ptrModuleName;          /* Retrieved from ModuleInfo_descriptor. Refer A/97 5.3.1 */
149    DS_BOOL                 bCrcFieldValid;
150    DS_U32                  Crc32_descriptor;       /* Retrieved from CRC32_descriptor. Refer A/90 7.2.3.6.2 */
151
152} ModuleInfo_t, *ModuleInfoPtr_t;
153
154typedef struct
155{
156    DsmccMsgHeaderPtr_t     ptrDsmccMsgHeader;
157
158    DS_U32                  downloadId;
159    DS_U16                  blockSize;
160    DS_U8                   windowSize;
161    DS_U8                   ackPeriod;
162    DS_U32                  tCDownloadWindow;
163    DS_U32                  tCDownloadScenario;
164
165    CompatblDesc_t          compatblDesc;
166
167    DS_U16                  numberOfModules;
168    ModuleInfoPtr_t         ptrDIIModuleInfo;
169
170    DS_U16                  privateDataLength;
171    DS_U8*                  ptrPrivateDataByte;
172
173} DIIMsg_t, *DIIMsgPtr_t;
174
175
176// This data structure is returned to DSMCC DII client as the callback function's parameter
177// Client needs to destroy this data structure using FreeDsmccMemChain()
178typedef struct
179{
180    //*** Optional information obtained from the 1st section of DSMCC-DII table ***//
181        DS_U8                       table_id;                   /* Table ID */
182    DS_U16                  dsmcc_section_length;   /* Length of 1st section */
183    DS_U16                  table_id_extension;     /* Contains DII transaction number */
184        DS_U8                       version_number;                 /* Version number. When the table is updated, this value is changed. */
185        DS_U8                       current_next_indicator;     /* If table id is 0x3B this must be 1 */                                                       
186        DS_U8                       section_number;                 /* Section number */
187        DS_U8                       last_section_number;        /* Last section number in multi section */
188    DS_U32                  transaction_id;         /* Transaction ID indicated in 1st section dsmccMessageHeader */
189    DS_U32                  downloadId;             /* Data carousel ID indicated in 1st section */
190    DS_U16                  blockSize;              /* Size of DDB message block indicated in 1st section */
191   
192    //*** DII message section array ***//
193    DS_U8                   numSections;            /* Number of DII msg sections */
194    DIIMsgPtr_t             ptrDIIMsgSections;      /* Ptr to DII msg sections (DIIMsg_t structures) */
195
196} DsmccDIIMsg_t, *DsmccDIIMsgPtr_t;
197
198
199/**************************************************************************
200DSM-CC APIs
201**************************************************************************/
202DHL_RESULT DHL_PSI_ActivateDDBTask( int *pAppTaskPriority );             /* Must be called once before start monitoring DII/DDB */
203
204DHL_RESULT DHL_PSI_DeactivateDDBTask( void );                            /* Terminate DSMCC task and all active DII/DDB monitors */
205
206DHL_RESULT FreeDsmccMemChain( void* pDsmccMem );
207
208#if 0
209DHL_RESULT DHL_PSI_MonitorDsmccDII( DHL_PSI_HANDLE sysInfo,                          /* Transport unit */
210                         DS_U16 Pid,                        /* DII Pid to monitor */
211                         DS_U16 transactionId,              /* The transaction ID (from SDTT?) */
212                         DsmccEventProc_t pfCallbackProc,   /* Client callback func ptr */
213                         DHL_TBL_HANDLE *returnPsiCtl          /* PSI Ctl structure */
214                       );
215#else
216DHL_RESULT DHL_PSI_MonitorDsmccDII( DHL_PSI_HANDLE sysInfo, 
217                                                                        DS_U16 Pid, 
218                                                                        DS_U16 transactionId, 
219                                                                        DsmccEventProc_t pfCallbackProc, 
220                                                                        DS_U32 userParam,
221                                                                        DHL_PSI_HANDLE *returnPsiCtl );
222#endif
223DHL_RESULT DHL_PSI_CancelDsmccDII( DHL_TBL_HANDLE *psiCtl );
224
225DHL_RESULT DHL_PSI_MonitorDsmccDDB( DHL_PSI_HANDLE sysInfo,                          /* Transport unit */
226                         DS_U16 Pid,                        /* DDB Pid to monitor */
227                         DS_U32 downloadId,                 /* Identifies the carousel ID */
228                         DS_U16 moduleId,                   /* Module ID from DII module info */
229                         DS_U8  moduleVersion,              /* Module version from DII module info */
230                         DS_U32 moduleSize,                 /* Total module size in bytes from DII module info */
231                         DS_U16 blockSize,                  /* DDB block size from DII module info */
232                         DsmccEventProc_t pfCallbackProc,
233                         DsmccStatusProc_t pfStatusProc, 
234                         DHL_PSI_HANDLE *returnPsiCtl
235                       );
236
237DHL_RESULT DHL_PSI_CancelDsmccDDB( DHL_PSI_HANDLE *psiCtl );
238void *DHL_PSI_GetDsmccDDBBuffer(DHL_PSI_HANDLE psiCtl);
239void DHL_PSI_SetDsmccAllocFreeFunc(void *AllocFunc, void *FreeFunc);
240int DHL_PSI_GetDsmccDDBProgress(DHL_PSI_HANDLE psiCtl);
241void DHL_PSI_FreeDDBBuffer(void *addr);
242
243#define DSMCC_DEBUG                     0       // Set to 0 for non debug
244#define DSMCC_DISKFILE                  0       // Diskfile buffering support
245
246
247#define DSMCCDDB_TASK_PRIO                  0           // Priority of DSM-CC task
248
249// DSM-CC Table IDs
250#define DSMCC_DII_TABLE_ID                  0x3B
251#define DSMCC_DDB_TABLE_ID                  0x3C
252
253#define MAX_DSMCC_SECTION_LENGTH        4096    // Maximum DSMCC message section length
254#define MAX_DSMCC_SECTIONS                              256             
255#define MIN_DSMCC_SECTIONS                              1               
256
257#define NUM_DII_MON_CONTEXTS            16      // Maximum numbers of simultaneous DII monitors
258#define NUM_DDB_MON_CONTEXTS            16      // Maximum numbers of simultaneous DDB monitors
259
260#define DSMCC_FILE_BUFSECTIONS          16      // Number of DDB sections buffered in diskfile mode
261
262#define DDB_PATH_FILENAME               "/udma/dsmcc/Mod"
263
264// DSMCC thread event message data structure
265typedef struct
266{
267        eDSMCCEvent_t           event;
268
269        DS_U32                      userParam;
270        DHL_PSI_HANDLE              *psiCtl;
271        void                        *param;
272        PSIDataArray_t      *desc;
273
274} DsmccMsg_t;
275
276// DII monitor context data structure
277typedef struct
278{
279    DS_BOOL                isUsed;             // This DII context use flag
280
281    DsmccEventProc_t    pfCallbackProc;     // Client callback function ptr
282
283    DHL_PSI_HANDLE                  *psiCtl;            // PSI Ctl of the DII context
284
285} DIIMsgMonContext_t, *DIIMsgMonContextPtr_t;
286
287// DDB monitor context data structure
288typedef struct
289{
290    DS_BOOL                isUsed;             // This DDB context use flag
291
292    DsmccEventProc_t    pfCallbackProc;     // Client callback function ptr
293    DsmccStatusProc_t   pfStatusProc;       // Status callbck function ptr
294
295    //*** DDB monitoring parameters ***//
296    DS_BOOL                isInitialized;      // Buffers are allocated
297    DS_U32              downloadId;         // DDB download ID identifies the data carousel
298    DS_U16              moduleId;           // DDB module ID
299    DS_U8               moduleVersion;      // DDB module version
300    DS_U32              moduleSize;         // DDB total module size
301    DS_U16              blockSize;          // DDB block size
302    DS_U16              lastBlockSize;      // DDB last block size
303    DS_U32              blockRecvd;         // Number of blocks received
304    DS_U32              blockTotal;         // Total number of blocks
305
306        memId_t                         memId;              // MemChain ID for allocating data structure for DSMCC-DDB client
307    DDBModulePtr_t      pDDBModule;         // Ptr to data structure returned to DDB client
308
309    DS_U8               *pBlockRecvBitFlags;// Bit flags to indicate the blocks received
310
311    DHL_PSI_HANDLE                  *psiCtl;            // PSI Ctl of the DDB context
312       
313        OS_MESSAGEQUEUE_ID      dsmccQ;
314        OS_TASK_ID                      dsmccTaskID;
315        OS_SEMAPHORE_ID         syncSema4;          // Used to synchronize with DSMCC thread
316
317} DDBMsgMonContext_t, *DDBMsgMonContextPtr_t;
318
319
320// DSMCC thread global variable structure
321typedef struct
322{
323    DS_BOOL                isActive;
324
325        OS_SEMAPHORE_ID         mutexSema4;         // Used to access DSMCC database variables
326        OS_SEMAPHORE_ID         controlSema4;
327
328    DIIMsgMonContext_t  DIIMonContexts[ NUM_DII_MON_CONTEXTS ]; // DII monitoring contexts
329    DDBMsgMonContext_t  DDBMonContexts[ NUM_DDB_MON_CONTEXTS ]; // DDB monitoring contexts
330
331} DSMCCDatabase_t;
332
333
334/**************************************************************************
335DSM-CC DDB Table Parsing Structure Defines
336The following data structures are used to parse the contents of DDB msgs
337**************************************************************************/
338
339#define DSMCC_DDB_MEM_LIMIT      (64*1024)   // 64Kb max    (4096)              // 4Kb max
340
341typedef struct
342{
343    DS_U8                   adaptationType;
344    DS_U8                   adaptationDataByte;
345
346} *dsmccDDBAdaptHeaderPtr_t;
347   
348typedef struct
349{
350    DS_U8                   protocolDiscriminator;
351    DS_U8                   dsmccType;
352    DS_U16                  messageId;
353    DS_U32                  downloadId;
354    DS_U8                   adaptationLength;
355    DS_U16                  messageLength;
356
357    dsmccDDBAdaptHeaderPtr_t ptrDsmccAdaptationHeader;
358
359} DsmccDnldDataHdr_t, *DsmccDnldDataHdrPtr_t;
360
361typedef struct
362{
363    DsmccDnldDataHdrPtr_t   ptrDsmccDnldDataHdr;
364   
365    DS_U16                  moduleId;               /* Module ID */
366    DS_U8                   moduleVersion;          /* Version */
367    DS_U16                  blockNumber;            /* Block number */
368
369    DS_U8                   *pBlockDataByte;        /* DDB payload */
370
371} DDBMsg_t, *DDBMsgPtr_t;
372
373// Structure used to parse DSMCC DDB message
374typedef struct
375{
376        DS_U8                       table_id;                   /* Table ID */
377    DS_U16                  dsmcc_section_length;   /* Length of section */
378    DS_U16                  table_id_extension;     /* Contains module ID */
379        DS_U8                       version_number;                 /* Version number. When the table is updated, this value is changed. */
380        DS_U8                       current_next_indicator;     /* If table id is 0x3C this must be 1 */                                                       
381        DS_U8                       section_number;                 /* Section number */
382        DS_U8                       last_section_number;        /* Last section number in multi section */
383   
384    DDBMsgPtr_t             ptrDDBMsgSection;       /* Ptr to DDB msg section (DDBMsg_t structures) */
385
386} DsmccDDBMsg_t, *DsmccDDBMsgPtr_t;
387
388
389/**************************************************************************
390DSM-CC DII Table Parsing Structure Defines
391The following data structures are used to parse the contents of DII msgs
392**************************************************************************/
393
394#define DSMCC_DII_MEM_LIMIT         (64*1024)   // 64Kb max
395
396// This DSMCC encapsulator structure is used in DSMCC DII section parsing and returned to
397// ParseDsmccDII()
398typedef struct 
399{
400        DS_U8                       table_id;                   /* Table ID */
401    DS_U16                  dsmcc_section_length;   /* Length of this section */
402    DS_U16                  table_id_extension;     /* Contains DII transaction number */
403        DS_U8                       version_number;                 /* Version number. When the table is updated, this value is changed. */
404        DS_U8                       current_next_indicator;     /* If table id is 0x3B this must be 1 */
405                                                               
406        DS_U8                       section_number;                 /* Section number */
407        DS_U8                       last_section_number;        /* Last section number in multi section */
408
409        DIIMsgPtr_t                 ptrDIIMsgSection;       /* DII msg section */
410
411} dsmccDIISection_t, *dsmccDIISectionPtr_t;
412
413/*==============================================================================
414         DSMCC Type definitions
415==============================================================================*/
416#define DSMCC_MESSAGE_HEADER_PREFIX     0x11    /* DSMCC_Section.protocolDiscriminator = 0x11 */
417#define DSMCC_MESSAGE_HEADER_TYPE       0x03    /* DSMCC_Section.dsmccType = 0x03 */
418
419#define COMPATBL_DESC_SYSTEM_HW     0x01
420#define COMPATBL_DESC_SYSTEM_SW     0x02
421
422typedef enum {
423        DSMCC_MESSAGE_DIREQ=((DSMCC_MESSAGE_HEADER_PREFIX<<24)+(DSMCC_MESSAGE_HEADER_TYPE<<16)+0x1001), // DownloadInfoRequest
424        DSMCC_MESSAGE_DIRSP=((DSMCC_MESSAGE_HEADER_PREFIX<<24)+(DSMCC_MESSAGE_HEADER_TYPE<<16)+0x1002), // DownloadInfoResponse
425        DSMCC_MESSAGE_DII=((DSMCC_MESSAGE_HEADER_PREFIX<<24)+(DSMCC_MESSAGE_HEADER_TYPE<<16)+0x1002),   // DownloadInfoIndication
426        DSMCC_MESSAGE_DDB=((DSMCC_MESSAGE_HEADER_PREFIX<<24)+(DSMCC_MESSAGE_HEADER_TYPE<<16)+0x1003),   // DownloadDataBlock
427        DSMCC_MESSAGE_DDR=((DSMCC_MESSAGE_HEADER_PREFIX<<24)+(DSMCC_MESSAGE_HEADER_TYPE<<16)+0x1004),   // DownloadDataRequest
428        DSMCC_MESSAGE_DC =((DSMCC_MESSAGE_HEADER_PREFIX<<24)+(DSMCC_MESSAGE_HEADER_TYPE<<16)+0x1005),   // DownloadCancel
429        DSMCC_MESSAGE_DSI=((DSMCC_MESSAGE_HEADER_PREFIX<<24)+(DSMCC_MESSAGE_HEADER_TYPE<<16)+0x1006),   // DownloadSeverInitiate
430} dsmcc_message_type;
431
432/**************************************************************************
433DSM-CC DII and DDB private function prototypes
434**************************************************************************/
435void PrintDsmccDII( const DsmccDIIMsgPtr_t pDsmccDIIMsg );
436DHL_RESULT ParseDsmccDII( PSIDataArray_t *desc, DsmccDIIMsgPtr_t *ppDsmccDIIMsg );
437
438eDSMCCRetval_t ProcessDsmccDDB( PSIDataArray_t *desc, 
439                                DDBMsgMonContextPtr_t pDDBMsgMonContext, 
440                                DDBModulePtr_t *ppDDBModule );
441
442#if DSMCC_DISKFILE                          // Diskfile support
443void CloseDDBCaptureFiles( DDBMsgMonContextPtr_t pDDBMsgMonContext );
444#endif
445
446
447#endif
Note: See TracBrowser for help on using the repository browser.