| 1 | /** |
|---|
| 2 | @file |
|---|
| 3 | DHL_UTL.c |
|---|
| 4 | |
|---|
| 5 | @brief |
|---|
| 6 | PHOENIX HAL library |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | Copyright 2006~2010 Digital STREAM Technology, Inc. |
|---|
| 10 | All Rights Reserved |
|---|
| 11 | */ |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | #include "DHL_OSAL.h" |
|---|
| 15 | #include "DHL_DBG.h" |
|---|
| 16 | |
|---|
| 17 | #include "DHL_UTL.h" |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | /* |
|---|
| 21 | ¸ðµç Çì´õ ÆÄÀÏÀ» Æ÷ÇÔÇÏÁö´Â ¾ÊÀ¸¸ç, compile timeÀ» ÁÙÀ̱â À§ÇØ |
|---|
| 22 | °¢ ¸ðµâÀº ÇÊ¿äÇÑ ¸¸ÅÀÇ Çì´õ¸¦ ¼±¾ðÇϵµ·Ï ÇÔ. |
|---|
| 23 | */ |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | /* |
|---|
| 28 | DHL µð¹ö±× ¸ðµâ À̸§ Á¤ÀÇ ·ê Âü°í: |
|---|
| 29 | |
|---|
| 30 | DHL ¸ðµâµéÀº ¸ðµÎ * ·Î ½ÃÀÛ. |
|---|
| 31 | API´Â ´ë¹®ÀÚ, Platform ¹× ±âŸ´Â ¼Ò¹®ÀÚ »ç¿ë. |
|---|
| 32 | |
|---|
| 33 | µðÆúÆ® ·¹º§Àº 0À¸·Î ¼³Á¤ÇÑ´Ù. (0: ¿¡·¯ ¸Þ½ÃÁö¸¸ Ãâ·Â) |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | */ |
|---|
| 37 | |
|---|
| 38 | //DHL_MODULE("*UTL", 0); |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | #if COMMENT |
|---|
| 43 | ____Config____(){} |
|---|
| 44 | #endif |
|---|
| 45 | |
|---|
| 46 | /* |
|---|
| 47 | ÀÌ ¸ðµâ ³»ºÎ¿¡¼ »ç¿ëµÇ´Â °¢Á¾ configuration Á¤ÀÇ. |
|---|
| 48 | */ |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | /* #define SUPPORT_FAST_SWITCHING_OPTIMIZATION 1 */ |
|---|
| 52 | /* #define FUNC_MONITOR_TIMER_ID TIMER_ID_FUNC_MONITOR */ |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | #if COMMENT |
|---|
| 57 | ____Types____(){} |
|---|
| 58 | #endif |
|---|
| 59 | |
|---|
| 60 | /* |
|---|
| 61 | ÀÌ ¸ðµâ ³»ºÎ¿¡¼ »ç¿ëµÇ´Â structure ¹× enumerations. |
|---|
| 62 | */ |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | #if COMMENT |
|---|
| 67 | ____Variables____(){} |
|---|
| 68 | #endif |
|---|
| 69 | |
|---|
| 70 | /* |
|---|
| 71 | global·Î Àû¿ëµÇ´Â variable Á¤ÀÇ. |
|---|
| 72 | °¢ function º°·Î Ư¼öÇÑ ¿ëµµÀÇ variableÀº °¢ functionX block ¿¡¼ Á¤ÀÇ °¡´É. |
|---|
| 73 | */ |
|---|
| 74 | |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | #if COMMENT |
|---|
| 78 | ____API____(){} |
|---|
| 79 | #endif |
|---|
| 80 | |
|---|
| 81 | static UINT32 dhl_crcTable[256]; |
|---|
| 82 | |
|---|
| 83 | static BOOLEAN dhl_CRCInited; |
|---|
| 84 | |
|---|
| 85 | #define DEMUX_CRC_ADDER_MASK 0x04C11DB7 /* As defined in MPEG-2 CRC */ |
|---|
| 86 | |
|---|
| 87 | |
|---|
| 88 | void dhl_InitCRC(void) |
|---|
| 89 | { |
|---|
| 90 | UINT32 crc; |
|---|
| 91 | INT32 i, j; |
|---|
| 92 | |
|---|
| 93 | if (dhl_CRCInited) return; |
|---|
| 94 | |
|---|
| 95 | // Initialize CRC table |
|---|
| 96 | for (i=0; i<256; i++) { |
|---|
| 97 | crc = 0; |
|---|
| 98 | for (j=7; j>=0; j--) { |
|---|
| 99 | if (((i >> j) ^ (crc >> 31)) & 1) { |
|---|
| 100 | crc=(crc<<1)^DEMUX_CRC_ADDER_MASK; |
|---|
| 101 | } |
|---|
| 102 | else { |
|---|
| 103 | crc<<=1; |
|---|
| 104 | } |
|---|
| 105 | } |
|---|
| 106 | dhl_crcTable[i] = crc; |
|---|
| 107 | } |
|---|
| 108 | dhl_CRCInited = TRUE; |
|---|
| 109 | } |
|---|
| 110 | |
|---|
| 111 | |
|---|
| 112 | UINT32 DHL_UTL_CalcCRC32(UINT32 crc_start, const UINT8 *data, UINT32 len) |
|---|
| 113 | { |
|---|
| 114 | UINT32 crc = crc_start; |
|---|
| 115 | UINT32 i; |
|---|
| 116 | |
|---|
| 117 | if (!dhl_CRCInited) { |
|---|
| 118 | dhl_InitCRC(); |
|---|
| 119 | } |
|---|
| 120 | |
|---|
| 121 | for (i = 0; i < len; ++i) { |
|---|
| 122 | crc = (crc << 8) ^ dhl_crcTable[(crc >> 24) ^ (*data++)]; |
|---|
| 123 | } |
|---|
| 124 | |
|---|
| 125 | return(crc); |
|---|
| 126 | } |
|---|
| 127 | |
|---|
| 128 | |
|---|
| 129 | |
|---|
| 130 | |
|---|
| 131 | #if COMMENT |
|---|
| 132 | ____Debug____(){} |
|---|
| 133 | #endif |
|---|
| 134 | |
|---|
| 135 | |
|---|
| 136 | |
|---|
| 137 | |
|---|
| 138 | #if COMMENT |
|---|
| 139 | ____Symbol____(){} |
|---|
| 140 | #endif |
|---|
| 141 | |
|---|
| 142 | |
|---|
| 143 | #if DHL_REGISTER_DEUBG_SYMBOLS |
|---|
| 144 | |
|---|
| 145 | static DHL_SymbolTable _XxxxSymbols[] = |
|---|
| 146 | { |
|---|
| 147 | /* however, if you want typing short-cut, it is good usage. |
|---|
| 148 | */ |
|---|
| 149 | /* DHL_FNC_SYM_ENTRY2("epg_start", App_EpgUpdateStart), |
|---|
| 150 | DHL_FNC_SYM_ENTRY2("epg_stop", App_EpgUpdateCancel), |
|---|
| 151 | DHL_FNC_SYM_ENTRY2("epg_list", Dmc_EpgPrintAllTables), |
|---|
| 152 | DHL_FNC_SYM_ENTRY2("epg_delete", App_EpgDeleteAll), |
|---|
| 153 | |
|---|
| 154 | DHL_VAR_SYM_ENTRY(g_XX_TestMode),*/ |
|---|
| 155 | 0, |
|---|
| 156 | |
|---|
| 157 | }; |
|---|
| 158 | |
|---|
| 159 | #endif /* DHL_REGISTER_DEUBG_SYMBOLS */ |
|---|
| 160 | |
|---|
| 161 | |
|---|
| 162 | |
|---|
| 163 | #if COMMENT |
|---|
| 164 | ____Init____(){} |
|---|
| 165 | #endif |
|---|
| 166 | |
|---|
| 167 | |
|---|
| 168 | |
|---|
| 169 | /* end of file */ |
|---|
| 170 | |
|---|
| 171 | |
|---|