| 1 | /** |
|---|
| 2 | @file |
|---|
| 3 | DMW_PsiSdds.c |
|---|
| 4 | |
|---|
| 5 | @brief |
|---|
| 6 | PSI MW SDDS implementation |
|---|
| 7 | |
|---|
| 8 | Copyright 2010 Digital STREAM Technology, Inc. |
|---|
| 9 | All Rights Reserved |
|---|
| 10 | */ |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | #include "DHL_OSAL.h" |
|---|
| 14 | #include "DHL_DBG.h" |
|---|
| 15 | |
|---|
| 16 | #include "DHL_Timer.h" |
|---|
| 17 | |
|---|
| 18 | #include "DLIB_SDDS_Monitor.h" |
|---|
| 19 | #include "DLIB_SDDS_Parser.h" |
|---|
| 20 | |
|---|
| 21 | #include "DMW_Status.h" |
|---|
| 22 | #include "DMW_PsiSdds.h" |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | //#include <string.h> // memcmp |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | /* |
|---|
| 29 | ¸ðµç Çì´õ ÆÄÀÏÀ» Æ÷ÇÔÇÏÁö´Â ¾ÊÀ¸¸ç, compile timeÀ» ÁÙÀ̱â À§ÇØ |
|---|
| 30 | °¢ ¸ðµâÀº ÇÊ¿äÇÑ ¸¸ÅÀÇ Çì´õ¸¦ ¼±¾ðÇϵµ·Ï ÇÔ. |
|---|
| 31 | */ |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | /* |
|---|
| 36 | DHL µð¹ö±× ¸ðµâ À̸§ Á¤ÀÇ ·ê Âü°í: |
|---|
| 37 | |
|---|
| 38 | DHL ¸ðµâµéÀº ¸ðµÎ * ·Î ½ÃÀÛ. |
|---|
| 39 | API´Â ´ë¹®ÀÚ, Platform ¹× ±âŸ´Â ¼Ò¹®ÀÚ »ç¿ë. |
|---|
| 40 | |
|---|
| 41 | µðÆúÆ® ·¹º§Àº 0À¸·Î ¼³Á¤ÇÑ´Ù. (0: ¿¡·¯ ¸Þ½ÃÁö¸¸ Ãâ·Â) |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | */ |
|---|
| 45 | |
|---|
| 46 | DHL_MODULE("$sds", 0); |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | #if COMMENT |
|---|
| 51 | ____Config____(){} |
|---|
| 52 | #endif |
|---|
| 53 | |
|---|
| 54 | /* |
|---|
| 55 | ÀÌ ¸ðµâ ³»ºÎ¿¡¼ »ç¿ëµÇ´Â °¢Á¾ configuration Á¤ÀÇ. |
|---|
| 56 | */ |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | #define DMW_SDDS_TEST 0 |
|---|
| 61 | // Å×½ºÆ® ÄÚµå Æ÷ÇÔ. |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | #define SDDS_ENABLE_SECTION_SYNTAX_CHECK 1 |
|---|
| 66 | // ¼½¼Ç syntax¿¡ ¹®Á¦°¡ ¾ø´Â °ÍÀÎÁö MW ·¹º§¿¡¼ ´Ù½Ã üũ. |
|---|
| 67 | // DLIB ¿¡¼µµ ÀÏ´Ü ±âº»ÀûÀΠüũ´Â ÇØ ÁÖ¾î¾ß °ÚÁö¸¸.. |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | #define SDDS_ENABLE_DDB_RX_INTERLEAVING 1 |
|---|
| 71 | // 1À̸é ddb ¼ö½ÅÀ²À» ³ôÀ̱â À§ÇØ ÀÎÅ͸®ºù ¸ðµå·Î µ¿ÀÛÇÑ´Ù. |
|---|
| 72 | // ´ë½Å ddb ÇÊÅ͸¦ µÎ¹è·Î ¼Ò¸ðÇÏ´Â ´ÜÁ¡ÀÌ ÀÖ´Ù. |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | #define SDDS_ENABLE_GLOBAL_DDB_RX 1 |
|---|
| 76 | // 1 ÀÌ¸é °¢ ¸ðµâº° ddb ÇÊÅ͸¦ »ç¿ëÇÏÁö ¾Ê°í, |
|---|
| 77 | // group ³»ÀÇ ¸ðµç ¸ðµâ blockÀ» ¼ö½Å°¡´ÉÇϵµ·Ï ddb ÇÊÅ͸¦ ¼³Á¤ÇÏ¿© »ç¿ëÇÑ´Ù. |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | #if COMMENT |
|---|
| 82 | ____Types____(){} |
|---|
| 83 | #endif |
|---|
| 84 | |
|---|
| 85 | /* |
|---|
| 86 | ÀÌ ¸ðµâ ³»ºÎ¿¡¼ »ç¿ëµÇ´Â structure ¹× enumerations. |
|---|
| 87 | */ |
|---|
| 88 | |
|---|
| 89 | |
|---|
| 90 | |
|---|
| 91 | typedef struct |
|---|
| 92 | { |
|---|
| 93 | //---- sddsDiiModule_t Á¤º¸ÀÇ copy |
|---|
| 94 | UINT16 moduleId; |
|---|
| 95 | UINT32 moduleSize; // ¸ðµâ ÀüüÀÇ Å©±â. |
|---|
| 96 | |
|---|
| 97 | //---- sddsModuleInfoDesc_t Á¤º¸ÀÇ backup |
|---|
| 98 | UINT8 *moduleName; |
|---|
| 99 | UINT8 *moduleSignature; |
|---|
| 100 | |
|---|
| 101 | BOOL bNeedToDownload; // ´Ù¿î·Îµå ÇÊ¿äÇÔÀ» ÀǹÌ. |
|---|
| 102 | |
|---|
| 103 | // ¹öÆÛ °ü¸®¸¦ app ÂÊÀ¸·Î ³Ñ°åÀ½. |
|---|
| 104 | #if 0 |
|---|
| 105 | // ´Ù¿î·Îµå ¹ÞÀ» ºí·°ÀÌ ÀúÀåµÉ ¹öÆÛ °ø°£. Å©±â´Â moduleSize ¹ÙÀÌÆ®. |
|---|
| 106 | UINT8 *moduleBuffer; |
|---|
| 107 | #endif |
|---|
| 108 | |
|---|
| 109 | // ºí·°ÀÇ °¹¼ö´Â (moduleSize+dii->blockSize-1)/dii->blockSize ÀÌ´Ù. |
|---|
| 110 | // ¸Ç ¸¶Áö¸· blockÀÇ Å©±â´Â blockSize º¸´Ù ÀûÀ» ¼ö ÀÖ´Ù. |
|---|
| 111 | UINT16 numberOfBlocks; |
|---|
| 112 | |
|---|
| 113 | // DDBÀÇ blockNumberÀÇ °ªÀÇ ¹üÀ§´Â 16bit·Î¼ 0 ºÎÅÍ 65535 ÀÌ´Ù. |
|---|
| 114 | // blockSize´Â 16 bitÀÌÁö¸¸, ÃÖ´ë Å©±â´Â 4066 ÀÌ´Ù. |
|---|
| 115 | // µû¶ó¼ ¸ðµâÀÇ ÃÖ´ë Å©±â´Â 4066 * 65536 = 266,469,376 ÀÌ´Ù. ¾à 254MB. |
|---|
| 116 | |
|---|
| 117 | // °¢ DDBÀÇ ¼ö½ÅÀÌ ¿Ï·á µÇ¾ú´ÂÁö¸¦ ±â·ÏÇÏ´Â Ç÷¡±×. |
|---|
| 118 | // |
|---|
| 119 | // DDB°¡ ¼ø¼´ë·Î ¼ö½ÅµÇÁö ¾ÊÀ» ¼ö ÀÖ°í, ¶Ç ½ÅÈ£ »óÅ¿¡ µû¶ó Áß°£¿¡ ºüÁö´Â °æ¿ìµµ ÀÖÀ¸¹Ç·Î |
|---|
| 120 | // °¢ DDB º°·Î ¼ö½Å »óŸ¦ °ü¸®ÇØ¾ß ÇÑ´Ù. |
|---|
| 121 | // |
|---|
| 122 | // ÇØ´ç bit°¡ 1À̸é complete µÇ¾ú´Ù´Â ÀǹÌÀÌ´Ù. |
|---|
| 123 | // flags[blockIndex/8] & (1 << blockIndex%8) ¿Í °°ÀÌ »ç¿ë. |
|---|
| 124 | // |
|---|
| 125 | UINT8 completedFlags[65536/8]; |
|---|
| 126 | // <-- ³Ê¹« Å©´Ù. µ¿Àû ÇÒ´çÀ¸·Î ÇÒ±î? |
|---|
| 127 | // ¸Þ¸ð¸®°¡ ºÎÁ·ÇÏÁö¸¸ ¾Ê´Ù¸é »ó°ü ¾ø´Ù. ÀÌ ModuleInfo ÀÚüµµ µ¿Àû ÇÒ´ç ¹ÞÀº °ÍÀÓ. |
|---|
| 128 | |
|---|
| 129 | // ÀÌ ÆÄÀÏ ´Ù¿î·Îµå°¡ ´Ù ³¡³ª¸é true. |
|---|
| 130 | BOOL bDownloadCompleted; |
|---|
| 131 | |
|---|
| 132 | // ddb¸¦ ¼ö½ÅÇϱâ À§ÇÑ psi control ÇÚµé. |
|---|
| 133 | // ÀÎÅ͸®ºù ¼ö½Å ¿É¼ÇÀÌ enable À̸é 0, 1 ¸ðµÎ »ç¿ëÇϰí |
|---|
| 134 | // ±×·¸Áö ¾Ê´Ù¸é 0 ¸¸ »ç¿ëÇÑ´Ù. |
|---|
| 135 | tDHL_PSI_ControlHandle hDdbCtl0; // even block number |
|---|
| 136 | tDHL_PSI_ControlHandle hDdbCtl1; // odd block number |
|---|
| 137 | |
|---|
| 138 | } S_SDDS_ModuleInfo; |
|---|
| 139 | |
|---|
| 140 | typedef struct |
|---|
| 141 | { |
|---|
| 142 | UINT32 groupId; |
|---|
| 143 | // copy of ctx->dsi->group[ctx->iGroup].groupId; |
|---|
| 144 | |
|---|
| 145 | // compatibility µî ±âŸ Á¤º¸¸¦ Ã¼Å©ÇØ º» °á°ú, ó¸®ÇÒ Çʿ䰡 ¾ø´Â group ÀÎ °æ¿ì |
|---|
| 146 | // ÀÌ flag¸¦ true·Î ÇÏ¿© skip Çϵµ·Ï ÇÑ´Ù. |
|---|
| 147 | //BOOL bNotUsed; |
|---|
| 148 | |
|---|
| 149 | // ¸Ç ¸¶Áö¸· blockÀ» Á¦¿ÜÇÑ ¸ðµç blockÀÇ Å©±â. |
|---|
| 150 | UINT16 blockSize; |
|---|
| 151 | // copy of ctx->dii->blockSize |
|---|
| 152 | |
|---|
| 153 | // dii¸¦ ¼ö½ÅÇϱâ À§ÇÑ psi control ÇÚµé. |
|---|
| 154 | tDHL_PSI_ControlHandle hDiiCtl; |
|---|
| 155 | |
|---|
| 156 | // download µÈ dii ¼½¼Ç. NULL if not downloaded yet. |
|---|
| 157 | // ¸ðµç diiÀÇ transaction id´Â groupId¿Í µ¿ÀÏÇØ¾ß ÇÑ´Ù. |
|---|
| 158 | sddsDiiPtr_t dii; |
|---|
| 159 | |
|---|
| 160 | // ¸ðµâ °¹¼öÀÇ Á¦ÇÑÀº µüÈ÷ ¾øÀ¸¹Ç·Î, µ¿ÀûÀ¸·Î ÇÒ´ç ¹Þ´Â´Ù. |
|---|
| 161 | int numModules; // same as dii->numberOfModules |
|---|
| 162 | S_SDDS_ModuleInfo *mi; // this is moduleinfo array. |
|---|
| 163 | |
|---|
| 164 | } S_SDDS_GroupInfo; |
|---|
| 165 | |
|---|
| 166 | |
|---|
| 167 | |
|---|
| 168 | #if COMMENT |
|---|
| 169 | ____Types____(){} |
|---|
| 170 | #endif |
|---|
| 171 | |
|---|
| 172 | |
|---|
| 173 | |
|---|
| 174 | typedef struct |
|---|
| 175 | { |
|---|
| 176 | tDHL_TSD tsd; |
|---|
| 177 | UINT16 pid; |
|---|
| 178 | |
|---|
| 179 | // dsi¸¦ ¼ö½ÅÇϱâ À§ÇÑ psi control ÇÚµé. |
|---|
| 180 | tDHL_PSI_ControlHandle hDsiCtl; |
|---|
| 181 | |
|---|
| 182 | // download µÈ dsi ¼½¼Ç. NULL if not downloaded yet. |
|---|
| 183 | sddsDsiPtr_t dsi; |
|---|
| 184 | int iGroup; // dsi¿¡¼ ¿ì¸®°¡ ó¸®ÇÒ group index |
|---|
| 185 | |
|---|
| 186 | S_SDDS_GroupInfo *gi; |
|---|
| 187 | |
|---|
| 188 | } S_SDDS_Context; |
|---|
| 189 | |
|---|
| 190 | |
|---|
| 191 | typedef enum |
|---|
| 192 | { |
|---|
| 193 | //--------------------------- |
|---|
| 194 | eSDDS_Cmd_BEGIN = 0x20, |
|---|
| 195 | eSDDS_Cmd_Init, |
|---|
| 196 | // param1: task info.. |
|---|
| 197 | eSDDS_Cmd_Start, |
|---|
| 198 | // param1: tsd |
|---|
| 199 | // param2: pid |
|---|
| 200 | eSDDS_Cmd_Stop, |
|---|
| 201 | // no param |
|---|
| 202 | eSDDS_Cmd_Delete, |
|---|
| 203 | // no param |
|---|
| 204 | eSDDS_Cmd_GetStatus, |
|---|
| 205 | // param1: SddsStatusStructure * |
|---|
| 206 | // param2: Ack semaphore |
|---|
| 207 | eSDDS_Cmd_PrintStatus, |
|---|
| 208 | // param1: detail level |
|---|
| 209 | eSDDS_Cmd_UserAction, |
|---|
| 210 | // param1: user param |
|---|
| 211 | |
|---|
| 212 | eSDDS_Cmd_Shutdown, |
|---|
| 213 | |
|---|
| 214 | //--------------------------- |
|---|
| 215 | eSDDS_Evt_BEGIN = 0x40, |
|---|
| 216 | // À̺¥Æ® °øÅë |
|---|
| 217 | // param1: tDHL_PSI_ControlHandle |
|---|
| 218 | // param2: tDHL_PSI_DataArray * |
|---|
| 219 | eSDDS_Evt_DSI, // DSI ¼ö½Å |
|---|
| 220 | eSDDS_Evt_DII, // DII ¼ö½Å |
|---|
| 221 | eSDDS_Evt_DDB, // DDB ¼ö½Å |
|---|
| 222 | eSDDS_Evt_DC, // DC ¼ö½Å |
|---|
| 223 | |
|---|
| 224 | |
|---|
| 225 | } E_SDDS_Command; |
|---|
| 226 | |
|---|
| 227 | |
|---|
| 228 | typedef struct |
|---|
| 229 | { |
|---|
| 230 | E_SDDS_Command cmd; |
|---|
| 231 | |
|---|
| 232 | UINT32 param[4]; |
|---|
| 233 | |
|---|
| 234 | } S_SDDS_TaskMessage; |
|---|
| 235 | |
|---|
| 236 | |
|---|
| 237 | |
|---|
| 238 | |
|---|
| 239 | |
|---|
| 240 | #if COMMENT |
|---|
| 241 | ____Variables____(){} |
|---|
| 242 | #endif |
|---|
| 243 | |
|---|
| 244 | /* |
|---|
| 245 | global·Î Àû¿ëµÇ´Â variable Á¤ÀÇ. |
|---|
| 246 | °¢ function º°·Î Ư¼öÇÑ ¿ëµµÀÇ variableÀº °¢ functionX block ¿¡¼ Á¤ÀÇ °¡´É. |
|---|
| 247 | */ |
|---|
| 248 | |
|---|
| 249 | static S_SDDS_Context s_sdds_context; |
|---|
| 250 | |
|---|
| 251 | /* |
|---|
| 252 | user callback |
|---|
| 253 | */ |
|---|
| 254 | F_SDDS_CALLBACK s_sdds_user_cb; |
|---|
| 255 | |
|---|
| 256 | |
|---|
| 257 | |
|---|
| 258 | /* |
|---|
| 259 | Å×½ºÆ®¸¦ À§ÇÑ º¯¼öµé.. |
|---|
| 260 | */ |
|---|
| 261 | BOOL s_sdds_force_pidchange; |
|---|
| 262 | |
|---|
| 263 | |
|---|
| 264 | |
|---|
| 265 | #if COMMENT |
|---|
| 266 | ____Function____(){} |
|---|
| 267 | #endif |
|---|
| 268 | |
|---|
| 269 | |
|---|
| 270 | STATUS sdds_task_send_cmd(E_SDDS_Command cmd, UINT32 p0, UINT32 p1, BOOL bWait); |
|---|
| 271 | STATUS sdds_task_send_event(E_SDDS_Command evt, UINT32 p0, UINT32 p1); |
|---|
| 272 | |
|---|
| 273 | |
|---|
| 274 | #if COMMENT |
|---|
| 275 | ____Group1____(){} |
|---|
| 276 | #endif |
|---|
| 277 | |
|---|
| 278 | |
|---|
| 279 | S_SDDS_Context *sdds_get_context(void) |
|---|
| 280 | { |
|---|
| 281 | return &s_sdds_context; |
|---|
| 282 | } |
|---|
| 283 | |
|---|
| 284 | void sdds_check_task(void *handle) |
|---|
| 285 | { |
|---|
| 286 | } |
|---|
| 287 | |
|---|
| 288 | |
|---|
| 289 | /** |
|---|
| 290 | return TRUE if two dsi is same. |
|---|
| 291 | */ |
|---|
| 292 | BOOL sdds_is_same_dsi(sddsDsiPtr_t dsi1, sddsDsiPtr_t dsi2) |
|---|
| 293 | { |
|---|
| 294 | int i; |
|---|
| 295 | sddsDsiGroup_t *g1, *g2; |
|---|
| 296 | |
|---|
| 297 | if (!dsi1 || !dsi2) return FALSE; |
|---|
| 298 | |
|---|
| 299 | if (dsi1->transactionId != dsi2->transactionId) return FALSE; |
|---|
| 300 | // transactionId ¿¡ ¹öÀü Á¤º¸°¡ Æ÷ÇԵǾî ÀÖÀ¸¹Ç·Î |
|---|
| 301 | // À̰͸¸ ºñ±³Çصµ ¹«¹æÇÒ µí ÇÔ. |
|---|
| 302 | #if 0 |
|---|
| 303 | if (memcmp(&dsi1->compat, &dsi2->compat, sizeof(sddsCompatDesc_t))) return FALSE; |
|---|
| 304 | if (dsi1->numberOfGroups != dsi2->numberOfGroups) return FALSE; |
|---|
| 305 | |
|---|
| 306 | for (i=0; i<dsi1->numberOfGroups; i++) { |
|---|
| 307 | g1 = &dsi1->groups[i]; g2 = &dsi2->groups[i]; |
|---|
| 308 | if (g1->groupId != g2->groupId) return FALSE; |
|---|
| 309 | if (g1->groupSize != g2->groupSize) return FALSE; |
|---|
| 310 | if (memcmp(&g1->compat, &g2->compat, sizeof(sddsCompatDesc_t))) return FALSE; |
|---|
| 311 | // ÀÌ ºÎºÐÀº ¹ö±×ÀÓ. compat ¾È¿¡ malloc Æ÷ÀÎÅͰ¡ ÀÖÀ¸¹Ç·Î ±×³É memcmp ÇÏ¸é ¾ÈµÊ. |
|---|
| 312 | |
|---|
| 313 | if (g1->groupInfoLength != g2->groupInfoLength) return FALSE; |
|---|
| 314 | if (memcmp(&g1->groupDescriptors, &g2->groupDescriptors, g1->groupInfoLength)) return FALSE; |
|---|
| 315 | } |
|---|
| 316 | if (dsi1->groupInfoPrivateDataLength != dsi2->groupInfoPrivateDataLength) return FALSE; |
|---|
| 317 | if (memcmp(&dsi1->groupInfoPrivateDataBytes, &dsi2->groupInfoPrivateDataBytes, |
|---|
| 318 | dsi1->groupInfoPrivateDataLength)) return FALSE; |
|---|
| 319 | #endif |
|---|
| 320 | |
|---|
| 321 | if (dsi1->checksum_CRC32 != dsi2->checksum_CRC32) return FALSE; |
|---|
| 322 | |
|---|
| 323 | return TRUE; // all data same.. |
|---|
| 324 | } |
|---|
| 325 | |
|---|
| 326 | BOOL sdds_is_same_dii(sddsDiiPtr_t dii1, sddsDiiPtr_t dii2) |
|---|
| 327 | { |
|---|
| 328 | if (!dii1 || !dii2) return FALSE; |
|---|
| 329 | if (dii1->transactionId != dii2->transactionId) return FALSE; |
|---|
| 330 | |
|---|
| 331 | // todo.. |
|---|
| 332 | |
|---|
| 333 | if (dii1->checksum_CRC32 != dii2->checksum_CRC32) return FALSE; |
|---|
| 334 | |
|---|
| 335 | return TRUE; |
|---|
| 336 | } |
|---|
| 337 | |
|---|
| 338 | void sdds_stop_monitor(tDHL_PSI_ControlHandle *pHandle) |
|---|
| 339 | { |
|---|
| 340 | if (pHandle == NULL || *pHandle == (tDHL_PSI_ControlHandle)0) return; |
|---|
| 341 | DLIB_SDDS_StopMonitor(*pHandle); |
|---|
| 342 | *pHandle = (tDHL_PSI_ControlHandle)0; |
|---|
| 343 | } |
|---|
| 344 | |
|---|
| 345 | void sdds_free_section(void *ppSection) |
|---|
| 346 | { |
|---|
| 347 | void **pp = (void **)ppSection; |
|---|
| 348 | if (pp == NULL || *pp == NULL) return; |
|---|
| 349 | DLIB_SDDS_FreeSection(*pp); |
|---|
| 350 | *pp = (void *)NULL; |
|---|
| 351 | } |
|---|
| 352 | |
|---|
| 353 | void sdds_free_module_info(int index, S_SDDS_ModuleInfo *mi) |
|---|
| 354 | { |
|---|
| 355 | if (!mi) return; |
|---|
| 356 | |
|---|
| 357 | dprint(3, " free module info [%d] 0x%x..\n", index, mi); |
|---|
| 358 | #if 0 |
|---|
| 359 | if (mi->moduleBuffer) { |
|---|
| 360 | dprint(3, " free module buf 0x%x\n", mi->moduleBuffer); |
|---|
| 361 | DHL_OS_Free((void **)&mi->moduleBuffer); |
|---|
| 362 | } |
|---|
| 363 | #endif |
|---|
| 364 | |
|---|
| 365 | sdds_stop_monitor(&mi->hDdbCtl0); |
|---|
| 366 | sdds_stop_monitor(&mi->hDdbCtl1); |
|---|
| 367 | |
|---|
| 368 | memset(mi, 0, sizeof(S_SDDS_ModuleInfo)); |
|---|
| 369 | } |
|---|
| 370 | |
|---|
| 371 | void sdds_free_all_module_info(S_SDDS_GroupInfo *gi) |
|---|
| 372 | { |
|---|
| 373 | int iModule; |
|---|
| 374 | if (!gi) return; |
|---|
| 375 | |
|---|
| 376 | dprint(3, " free all %d module info\n", gi->numModules); |
|---|
| 377 | for (iModule=0; iModule<gi->numModules; iModule++) |
|---|
| 378 | sdds_free_module_info(iModule, &gi->mi[iModule]); |
|---|
| 379 | DHL_OS_Free((void **)&gi->mi); |
|---|
| 380 | |
|---|
| 381 | gi->numModules = 0; |
|---|
| 382 | } |
|---|
| 383 | |
|---|
| 384 | void sdds_free_group_info(S_SDDS_GroupInfo *gi) |
|---|
| 385 | { |
|---|
| 386 | int iModule; |
|---|
| 387 | if (!gi) return; |
|---|
| 388 | |
|---|
| 389 | dprint(3, " free group info %x..\n", gi); |
|---|
| 390 | sdds_stop_monitor(&gi->hDiiCtl); |
|---|
| 391 | sdds_free_section(&gi->dii); |
|---|
| 392 | |
|---|
| 393 | for (iModule=0; iModule<gi->numModules; iModule++) |
|---|
| 394 | sdds_free_module_info(iModule, &gi->mi[iModule]); |
|---|
| 395 | DHL_OS_Free((void **)&gi->mi); |
|---|
| 396 | |
|---|
| 397 | memset(gi, 0, sizeof(S_SDDS_GroupInfo)); |
|---|
| 398 | } |
|---|
| 399 | |
|---|
| 400 | void sdds_free_all_group_info(S_SDDS_Context *ctx) |
|---|
| 401 | { |
|---|
| 402 | if (ctx->gi == NULL) return; |
|---|
| 403 | |
|---|
| 404 | dprint(3, " free all group info..\n"); |
|---|
| 405 | sdds_free_group_info(ctx->gi); |
|---|
| 406 | |
|---|
| 407 | DHL_OS_Free((void **)&ctx->gi); |
|---|
| 408 | |
|---|
| 409 | // ctx->dsi ¹× hDsiCtlÀº °Çµå¸®Áö ¾Ê´Â´Ù. À̰ÍÀº GroupInfo°¡ ¾Æ´Ï´Ù. |
|---|
| 410 | } |
|---|
| 411 | |
|---|
| 412 | void sdds_stop_all_monitor(S_SDDS_Context *ctx) |
|---|
| 413 | { |
|---|
| 414 | int i; |
|---|
| 415 | if (ctx->hDsiCtl) { |
|---|
| 416 | dprint(3, " stop dsi ctl..\n"); |
|---|
| 417 | sdds_stop_monitor(&ctx->hDsiCtl); |
|---|
| 418 | } |
|---|
| 419 | if (ctx->gi && ctx->gi->hDiiCtl) { |
|---|
| 420 | dprint(3, " stop dii ctl..\n"); |
|---|
| 421 | sdds_stop_monitor(&ctx->gi->hDiiCtl); |
|---|
| 422 | } |
|---|
| 423 | for (i=0; ctx->gi && i<ctx->gi->numModules; i++) { |
|---|
| 424 | if (ctx->gi->mi[i].hDdbCtl0) { |
|---|
| 425 | dprint(3, " stop ddb0[%u] ctl..\n", i); |
|---|
| 426 | sdds_stop_monitor(&ctx->gi->mi[i].hDdbCtl0); |
|---|
| 427 | } |
|---|
| 428 | if (ctx->gi->mi[i].hDdbCtl1) { |
|---|
| 429 | dprint(3, " stop ddb1[%u] ctl..\n", i); |
|---|
| 430 | sdds_stop_monitor(&ctx->gi->mi[i].hDdbCtl1); |
|---|
| 431 | } |
|---|
| 432 | } |
|---|
| 433 | } |
|---|
| 434 | |
|---|
| 435 | /* |
|---|
| 436 | user callbackÀ» È£Ãâ. |
|---|
| 437 | */ |
|---|
| 438 | void sdds_user_call(E_SDDS_CB_TYPE cbtype, void *param) |
|---|
| 439 | { |
|---|
| 440 | if (!s_sdds_user_cb) return; |
|---|
| 441 | |
|---|
| 442 | dprint(2, "--> user callback (cbtype %u, param 0x%x)\n", cbtype, param); |
|---|
| 443 | (*s_sdds_user_cb)(cbtype, param); |
|---|
| 444 | } |
|---|
| 445 | |
|---|
| 446 | |
|---|
| 447 | /* |
|---|
| 448 | ¼±ÅÃµÈ group index¸¦ ¸®ÅÏ. |
|---|
| 449 | ¾ø´Ù¸é -1À» ¸®ÅÏÇÑ´Ù. |
|---|
| 450 | */ |
|---|
| 451 | int sdds_choose_group_from_dsi(sddsDsiPtr_t dsi) |
|---|
| 452 | { |
|---|
| 453 | int iGroup; |
|---|
| 454 | |
|---|
| 455 | for (iGroup=0; iGroup<dsi->numberOfGroups; iGroup++) |
|---|
| 456 | { |
|---|
| 457 | // ¿©±â¼ callbackÀ» º¸³»¼ Á¦Á¶»ç°¡ ¸Â´ÂÁö üũ.. |
|---|
| 458 | S_SDDS_CBPARAM_GET_OUI cbp = {0, }; |
|---|
| 459 | sdds_user_call(eSDDS_CB_TYPE_GetOUI, &cbp); |
|---|
| 460 | |
|---|
| 461 | if (cbp.oui == 0) // user°¡ ±¸ÇöÇÏÁö ¾Ê¾ÒÀ½. |
|---|
| 462 | ; // user not specifed oui. |
|---|
| 463 | |
|---|
| 464 | // group descriptor°¡ ¾ø´Ù¸é, manufacturere¸¦ ãÀ» ¼ö ¾øÀ¸¹Ç·Î, |
|---|
| 465 | // ÀÌ dsi ±×·ìÀº »ç¿ë ºÒ°¡. |
|---|
| 466 | if (dsi->groups[iGroup].compat.descriptorCount == 0) continue; |
|---|
| 467 | |
|---|
| 468 | if (cbp.oui == 0x80000000) { |
|---|
| 469 | dprint(2, "test mode: accept any group..\n"); |
|---|
| 470 | break; |
|---|
| 471 | } |
|---|
| 472 | if (cbp.oui) { |
|---|
| 473 | // oui Á¤º¸¸¦ ¾Ë°í ÀÖ´Â °æ¿ì.. µÎ °³ÀÇ desc¸¸ üũÇÑ´Ù. |
|---|
| 474 | sddsCompatDescEntry_t *d; |
|---|
| 475 | |
|---|
| 476 | d = &dsi->groups[iGroup].compat.desc[0]; |
|---|
| 477 | if (d->specifierType == compatSpecifierType_IEEE_OUI && |
|---|
| 478 | (d->specifierData == cbp.oui || 0x80000000 == cbp.oui)) |
|---|
| 479 | dprint(2, "group[%d] desc0 oui matched 0x%x\n", iGroup, cbp.oui); |
|---|
| 480 | else |
|---|
| 481 | continue; // oui not matched. try next group.. |
|---|
| 482 | |
|---|
| 483 | if (d->model == cbp.model || 0xFFFF == cbp.model) |
|---|
| 484 | dprint(2, "group[%d] desc0 model matched 0x%x\n", iGroup, cbp.model); |
|---|
| 485 | else |
|---|
| 486 | continue; |
|---|
| 487 | if (d->version == cbp.version || 0xFFFF == cbp.version) |
|---|
| 488 | dprint(2, "group[%d] desc0 version matched 0x%x\n", iGroup, cbp.version); |
|---|
| 489 | else |
|---|
| 490 | continue; |
|---|
| 491 | #if 0 // ±×³É ¸Ç ¾ÕÀÇ ÇϳªÀÇ compat descriptor¸¸ Á¶»çÇÏÀÚ. |
|---|
| 492 | d = &dsi->groups[iGroup].compat.desc[1]; |
|---|
| 493 | if (dsi->groups[iGroup].compat.descriptorCount > 1 && |
|---|
| 494 | d->specifierType == compatSpecifierType_IEEE_OUI && |
|---|
| 495 | d->specifierData == cbp.oui) { |
|---|
| 496 | dprint(2, "found group[%d] desc1 oui matched 0x%x\n", iGroup, cbp.oui); |
|---|
| 497 | break; |
|---|
| 498 | } |
|---|
| 499 | .. |
|---|
| 500 | #endif |
|---|
| 501 | |
|---|
| 502 | } |
|---|
| 503 | else { |
|---|
| 504 | // oui Á¤º¸¸¦ ¸ð¸£´Â °æ¿ì. user¿¡°Ô callbackÀ¸·Î Çϳª¾¿ query.. |
|---|
| 505 | S_SDDS_CBPARAM_CHECK_DESC cbp2; |
|---|
| 506 | cbp2.desc = &dsi->groups[iGroup].compat; |
|---|
| 507 | cbp2.isOk = FALSE; |
|---|
| 508 | sdds_user_call(eSDDS_CB_TYPE_CheckCompatDesc, &cbp2); |
|---|
| 509 | if (cbp2.isOk) { |
|---|
| 510 | dprint(2, "user choosed group[%d].\n", iGroup); |
|---|
| 511 | break; |
|---|
| 512 | } |
|---|
| 513 | } |
|---|
| 514 | } |
|---|
| 515 | |
|---|
| 516 | if (iGroup >= dsi->numberOfGroups) { |
|---|
| 517 | dprint(0, "!! cannot find group in dsi!!\n"); |
|---|
| 518 | return -1; |
|---|
| 519 | } |
|---|
| 520 | // iGroup ¼±ÅÃÀº ¿Ï·á. |
|---|
| 521 | return iGroup; |
|---|
| 522 | |
|---|
| 523 | } |
|---|
| 524 | |
|---|
| 525 | int sdds_rx_blk_count(S_SDDS_ModuleInfo *mi) |
|---|
| 526 | { |
|---|
| 527 | int count, i; |
|---|
| 528 | for (count=0, i=0; i<mi->numberOfBlocks; i++) { |
|---|
| 529 | if (mi->completedFlags[i/8] & (1<<i%8)) |
|---|
| 530 | count++; |
|---|
| 531 | } |
|---|
| 532 | //dprint(2, " total %d / %u received\n", count, mi->numberOfBlocks); |
|---|
| 533 | return count; |
|---|
| 534 | } |
|---|
| 535 | |
|---|
| 536 | void sdds_prepare_module_info(int index, sddsDiiModule_t *m, |
|---|
| 537 | S_SDDS_CBPARAM_CHECK_FILE *f) |
|---|
| 538 | { |
|---|
| 539 | memset(f, 0, sizeof(*f)); |
|---|
| 540 | |
|---|
| 541 | //f->index = index; |
|---|
| 542 | |
|---|
| 543 | //-------- ¸ðµâ »óÅ º¯¼ö ÃʱâÈ.. |
|---|
| 544 | f->id = m->moduleId; |
|---|
| 545 | f->size = m->moduleSize; // ¸ðµâ ÀüüÀÇ Å©±â. |
|---|
| 546 | |
|---|
| 547 | // module info µð½ºÅ©¸³ÅÍ Á¤º¸ º¹»ç. |
|---|
| 548 | if (m->moduleInfoDesc) |
|---|
| 549 | { |
|---|
| 550 | sddsModuleInfoDesc_t *mid = m->moduleInfoDesc; |
|---|
| 551 | sddsDstModuleInfoDesc_t *di = &mid->dstinfo; |
|---|
| 552 | |
|---|
| 553 | f->name = di->moduleName; |
|---|
| 554 | f->version = di->moduleVer; |
|---|
| 555 | f->type = di->moduleType; |
|---|
| 556 | f->numSupportedHwVersions = di->numSupportedHwVersions; |
|---|
| 557 | f->supportedHwVersions = di->supportedHwVersions; |
|---|
| 558 | f->crc32 = di->fileCRC32; |
|---|
| 559 | } |
|---|
| 560 | |
|---|
| 561 | end: |
|---|
| 562 | return; |
|---|
| 563 | } |
|---|
| 564 | |
|---|
| 565 | #if COMMENT |
|---|
| 566 | ____Group1____(){} |
|---|
| 567 | #endif |
|---|
| 568 | |
|---|
| 569 | |
|---|
| 570 | |
|---|
| 571 | |
|---|
| 572 | void SDDS_PsiRxCallback(tDHL_PSI_Event event, tDHL_PSI_ControlHandle psiCtl, |
|---|
| 573 | E_SDDS_Command cmd, UINT32 userParam) |
|---|
| 574 | { |
|---|
| 575 | DHL_RESULT dhr; |
|---|
| 576 | STATUS err; |
|---|
| 577 | tDHL_PSI_DataArray *desc; |
|---|
| 578 | |
|---|
| 579 | if (event != ePSIEVENT_DATARECEIVED) { |
|---|
| 580 | dprint(0, "!! psicallback err %d\n", event); |
|---|
| 581 | return; |
|---|
| 582 | } |
|---|
| 583 | |
|---|
| 584 | if (cmd == eSDDS_Evt_DSI || cmd == eSDDS_Evt_DII || |
|---|
| 585 | cmd == eSDDS_Evt_DDB || cmd == eSDDS_Evt_DC) |
|---|
| 586 | { |
|---|
| 587 | dprint(2, "sdds psi rx, cmd %d, psictl %x\n", cmd, psiCtl); |
|---|
| 588 | |
|---|
| 589 | // race condition À¸·ÎºÎÅÍÀÇ º¸È£°¡ ¾ÆÁ÷ ¿Ïº®ÇÏÁö ¾ÊÀ¸¹Ç·Î, |
|---|
| 590 | // desc detach ÀÛ¾÷À» ÀÌ callback task¿¡¼ ¼öÇàÇϵµ·Ï ÇÏÀÚ. |
|---|
| 591 | // |
|---|
| 592 | dhr = DHL_PSI_ReadPSIData(psiCtl, &desc); |
|---|
| 593 | if (dhr) { |
|---|
| 594 | dprint(0, "!! %s: DHL_PSI_ReadPSIData err %x\n", __FUNCTION__, dhr); |
|---|
| 595 | return; |
|---|
| 596 | } |
|---|
| 597 | err = sdds_task_send_event(cmd, (UINT32)psiCtl, (UINT32)desc); |
|---|
| 598 | // jump to.. |
|---|
| 599 | // SDDS_HandleEvtProcessDsi |
|---|
| 600 | // SDDS_HandleEvtProcessDii |
|---|
| 601 | // SDDS_HandleEvtProcessDdb |
|---|
| 602 | // SDDS_HandleEvtProcessDc |
|---|
| 603 | if (err) { |
|---|
| 604 | dprint(0, "!! %s: send dpc event err %d\n", __FUNCTION__, err); |
|---|
| 605 | // detach ÇÑ desc¸¦ ÇØÁ¦ ÇØ Áà¾ß ¸Þ¸ð¸® leak°¡ ¾ø´Ù. |
|---|
| 606 | DHL_PSI_FreePSIData(desc); |
|---|
| 607 | } |
|---|
| 608 | } |
|---|
| 609 | else { |
|---|
| 610 | dprint(0, "!! %s: unknown evt msg %d\n", __FUNCTION__, cmd); |
|---|
| 611 | goto errexit; |
|---|
| 612 | } |
|---|
| 613 | |
|---|
| 614 | errexit: |
|---|
| 615 | // psiCtl clean up?? |
|---|
| 616 | return; |
|---|
| 617 | } |
|---|
| 618 | |
|---|
| 619 | void SDDS_DsiCallback(tDHL_PSI_Event event, tDHL_PSI_ControlHandle psiCtl, UINT32 userParam) |
|---|
| 620 | { |
|---|
| 621 | SDDS_PsiRxCallback(event, psiCtl, eSDDS_Evt_DSI, userParam); |
|---|
| 622 | } |
|---|
| 623 | void SDDS_DiiCallback(tDHL_PSI_Event event, tDHL_PSI_ControlHandle psiCtl, UINT32 userParam) |
|---|
| 624 | { |
|---|
| 625 | SDDS_PsiRxCallback(event, psiCtl, eSDDS_Evt_DII, userParam); |
|---|
| 626 | } |
|---|
| 627 | void SDDS_DdbCallback(tDHL_PSI_Event event, tDHL_PSI_ControlHandle psiCtl, UINT32 userParam) |
|---|
| 628 | { |
|---|
| 629 | SDDS_PsiRxCallback(event, psiCtl, eSDDS_Evt_DDB, userParam); |
|---|
| 630 | } |
|---|
| 631 | void SDDS_DcCallback(tDHL_PSI_Event event, tDHL_PSI_ControlHandle psiCtl, UINT32 userParam) |
|---|
| 632 | { |
|---|
| 633 | SDDS_PsiRxCallback(event, psiCtl, eSDDS_Evt_DC, userParam); |
|---|
| 634 | } |
|---|
| 635 | |
|---|
| 636 | |
|---|
| 637 | |
|---|
| 638 | void SDDS_HandleCmdInit(void *handle) |
|---|
| 639 | { |
|---|
| 640 | S_SDDS_Context *ctx; |
|---|
| 641 | |
|---|
| 642 | //-------- get context |
|---|
| 643 | ctx = sdds_get_context(); |
|---|
| 644 | |
|---|
| 645 | //-------- init context |
|---|
| 646 | memset(ctx, 0, sizeof(*ctx)); |
|---|
| 647 | |
|---|
| 648 | dprint(2, "sdds init.. handle %x.. \n", handle); |
|---|
| 649 | |
|---|
| 650 | // iGroupÀº ctx->dsi°¡ ÀÖÀ» ¶§¿¡¸¸ Àǹ̰¡ ÀÖ´Ù. |
|---|
| 651 | ctx->iGroup = -1; |
|---|
| 652 | } |
|---|
| 653 | |
|---|
| 654 | |
|---|
| 655 | /* |
|---|
| 656 | Start APIÀÇ Çڵ鷯 |
|---|
| 657 | */ |
|---|
| 658 | void SDDS_HandleCmdStart(tDHL_TSD tsd, UINT16 pid) |
|---|
| 659 | { |
|---|
| 660 | DHL_RESULT dhr; |
|---|
| 661 | S_SDDS_Context *ctx; |
|---|
| 662 | |
|---|
| 663 | //-------- parameter checking |
|---|
| 664 | // tsd, pid.. |
|---|
| 665 | |
|---|
| 666 | //-------- get context |
|---|
| 667 | ctx = sdds_get_context(); |
|---|
| 668 | |
|---|
| 669 | // check task is valid. |
|---|
| 670 | //sdds_check_task(ctx->task); |
|---|
| 671 | |
|---|
| 672 | //-------- ±âÁ¸¿¡ µ¿ÀÛ ÁßÀÎÁö ¸ÕÀú üũ. |
|---|
| 673 | // |
|---|
| 674 | /* |
|---|
| 675 | tsd³ª pid°¡ ´Þ¶óÁö¸é ÀÏ´Ü ¸ðµÎ resetÇÏ°í ´Ù½Ã ½ÃÀÛÇÏ´Â °ÍÀ¸·Î ÇÑ´Ù. |
|---|
| 676 | ´ÙÀ½°ú °°Àº ½Ã³ª¸®¿À¿¡¼ ÀÌ·± °æ¿ì°¡ ¹ß»ýÇÑ´Ù. |
|---|
| 677 | |
|---|
| 678 | 1. ÇÑ RF ³»¿¡ ¿©·¯ sdds °¡»ó ä³Î ¼ºñ½º°¡ Á¸ÀçÇÏ´Â °æ¿ì. |
|---|
| 679 | 2. ´Ù¸¥ ¹æ¼Û±¹(´Ù¸¥ RF)¿¡¼ sdds ¼ºñ½º¸¦ ½Ç½ÃÇÏ´Â °æ¿ì. |
|---|
| 680 | 3. ±âÁ¸¿¡ µ¿ÀÛ ÁßÀÌ´ø sdds ¼ºñ½º°¡ ¿Ï·áµÇÁö ¾ÊÀº »óÅ¿¡¼, |
|---|
| 681 | ³ªÁß¿¡ ½Ã°£ÀÌ È帥 ÈÄ¿¡ ´Ù¸¥ pid·Î »õ sdds ¼ºñ½º °³½Ã.. |
|---|
| 682 | |
|---|
| 683 | ±¹³» ±Ô°Ý»ó, ÀÌ·± °æ¿ì´Â ¹ß»ýÇÏÁö ¾Ê°ÚÁö¸¸ ½ÇÇè½Ç µî¿¡¼ÀÇ ½Ç¼ö/Àǵµ µîÀ¸·Î |
|---|
| 684 | ÀÌ·± »óȲÀÌ ¹ß»ýµÇ¸é ÃÖ´ëÇÑ ¹®Á¦°¡ ¾ø°Ô ÇØ¾ß ÇÑ´Ù. |
|---|
| 685 | |
|---|
| 686 | 2¹ø °°Àº °æ¿ì´Â ´Ù¸¥ RF¿¡¼ "µ¿ÀÏÇÑ" pid·Î ¼ºñ½º¸¦ ÇÏ´Â °æ¿ì¿¡, |
|---|
| 687 | ÀÌ µÑÀÇ ±¸ºÐÀÌ ºÒ°¡´ÉÇÏ´Ù´Â Á¡Àε¥, º°µµÀÇ rf_id µîÀÌ Ãß°¡µÇ¾î¾ß ÇÒ °Í °°´Ù. |
|---|
| 688 | |
|---|
| 689 | ¹æ¹ý 1) ±âÁ¸ sdds µ¿ÀÛÀÌ ¿Ï·á µÉ ¶§ ±îÁö »õ sdds ¼ºñ½º reject. |
|---|
| 690 | --> 3¹ø °°Àº °æ¿ì´Â ±âÁ¸ sdds´Â ÀÌ¹Ì ¹°°Ç³Ê °£ °æ¿ì. µû¶ó¼ »ç¿ë ºÒ°¡!! |
|---|
| 691 | |
|---|
| 692 | ¹æ¹ý 2) ±âÁ¸ sdds µ¿ÀÛÀ» ÁßÁöÇϰí, »õ·Î ½ÃÀÛ |
|---|
| 693 | --> ÀÌ ¹æ¹ýÀ» »ç¿ëÇÒ ¼ö ¹Û¿¡ ¾øÀ½. |
|---|
| 694 | |
|---|
| 695 | ºó¹øÇÏ°Ô ÀÚ²Ù pid °¡ º¯°æµÇ¾î restart µÇ´õ¶óµµ ¾ÈÁ¤¼º¿¡ ¹®Á¦°¡ ¾ø´ÂÁö |
|---|
| 696 | ÃæºÐÈ÷ Å×½ºÆ® ÇÊ¿äÇÏ´Ù. |
|---|
| 697 | |
|---|
| 698 | Å×½ºÆ® ¹æ¹ý: |
|---|
| 699 | A. pid ´Ù¸¥ µÎ°³ÀÇ ½ºÆ®¸²À» ¸¸µé¾î ½ºÆ®¸² Àåºñ¿¡¼ ¹Ýº¹ Àç»ý. |
|---|
| 700 | B. ½Ã¹Ä·¹À̼Ç. |
|---|
| 701 | */ |
|---|
| 702 | if (s_sdds_force_pidchange || |
|---|
| 703 | (ctx->pid != pid || ctx->tsd != tsd)) { |
|---|
| 704 | if (s_sdds_force_pidchange) |
|---|
| 705 | dprint(0, "-- pid change simul..\n"); |
|---|
| 706 | else if (ctx->pid) |
|---|
| 707 | dprint(2, "!! warning: pid %x tsd %x changed\n", pid, tsd); |
|---|
| 708 | |
|---|
| 709 | dprint(2, "reset all..\n"); |
|---|
| 710 | |
|---|
| 711 | sdds_free_all_group_info(ctx); |
|---|
| 712 | // ÀÌ ¾È¿¡¼ reset ¾ÈµÇ´Â °ÍµéÀº hDsiCtl, dsi »ÓÀÌ´Ù. |
|---|
| 713 | sdds_free_section(&ctx->dsi); |
|---|
| 714 | |
|---|
| 715 | sdds_user_call(eSDDS_CB_TYPE_ResetDownload, NULL); |
|---|
| 716 | } |
|---|
| 717 | |
|---|
| 718 | //-------- ÆÄ¶ó¹ÌÅ͵é ÃʱâÈ |
|---|
| 719 | ctx->tsd = tsd; |
|---|
| 720 | ctx->pid = pid; |
|---|
| 721 | |
|---|
| 722 | dprint(2, "start sdds, tsd %x, pid 0x%x\n", tsd, pid); |
|---|
| 723 | |
|---|
| 724 | //-------- dsi ¸ð´ÏÅÍ ½ÃÀÛ. |
|---|
| 725 | // óÀ½¿¡´Â table_id_extension ÇÊÅÍ ¾øÀÌ ¸ðµÎ ¹Þ´Â´Ù. |
|---|
| 726 | // |
|---|
| 727 | /* |
|---|
| 728 | ÀÌ¹Ì ½ÃÀÛ ÁßÀε¥ ´Ù½Ã Start api°¡ ºÒ¸®´Â °Íµµ Çã¿ëÇÑ´Ù. |
|---|
| 729 | Áï, app ¿¡¼ ä³Î º¯°æ½Ã ¸Å¹ø Stop ÇÔ¼ö¸¦ ºÎ¸£Áö ¾Ê¾Æµµ |
|---|
| 730 | MW µ¿ÀÛÀº µÇµµ·Ï ¼³°è ÇÑ´Ù. ±×·¯³ª ±ÇÀåÇÏ´Â °ÍÀº ¾Æ´Ô. |
|---|
| 731 | |
|---|
| 732 | 1. ±âÁ¸ ¸ð´ÏÅͰ¡ ÀÖÀ¸´Ï ±×³É skip ÇÏ´Â ¹æ¹ý |
|---|
| 733 | Ȥ½Ã ±× µÞ´ÜÀÇ dii, ddb µî¿¡ ¹®Á¦°¡ ÀÖ¾î¼ ´Ù½Ã ½ÃÀÛ½ÃŰ°í ½ÍÀº °æ¿ì¶ó¸é |
|---|
| 734 | ÀÌ ¹æ¹ýÀº È¿°ú°¡ ¾øÀ½.. |
|---|
| 735 | dii, ddb¿¡ ¹®Á¦°¡ ÀÖÀ» °¡´É¼ºÀº?? |
|---|
| 736 | |
|---|
| 737 | 2. filter¸¦ ´Ù½Ã ½ÃÀÛÇÏ´Â ¹æ¹ý |
|---|
| 738 | ¹«Á¶°Ç dsi¸¦ Çѹø ´õ ¹Þ°Ô µÉ °ÍÀÓ.. |
|---|
| 739 | ¾îÂ÷ÇÇ Ã¤³Î º¯°æ ÇÏ´Ù°¡ sdds RF·Î °¡¸é ¹«Á¶°Ç dsi¸¦ ´Ù½Ã ¹Þ°Ô µÇ¹Ç·Î |
|---|
| 740 | º° ºÎ´ãÀº ¾Æ´Ô.. |
|---|
| 741 | --> ÀÌ ¹æ¹ý »ç¿ë. |
|---|
| 742 | */ |
|---|
| 743 | #if 0 // method 1 |
|---|
| 744 | if (ctx->hDsiCtl) { |
|---|
| 745 | dprint(2, "prev dsi ctl %x active. skip dsi monitor..\n", ctx->hDsiCtl); |
|---|
| 746 | } |
|---|
| 747 | else |
|---|
| 748 | #else // method 2 |
|---|
| 749 | if (ctx->hDsiCtl) { |
|---|
| 750 | dprint(2, "prev dsi ctl %x active.. restart..\n", ctx->hDsiCtl); |
|---|
| 751 | sdds_stop_monitor(&ctx->hDsiCtl); |
|---|
| 752 | } |
|---|
| 753 | #endif |
|---|
| 754 | |
|---|
| 755 | { |
|---|
| 756 | dprint(2, "start monitor dsi..\n"); |
|---|
| 757 | dhr = DLIB_SDDS_MonitorDsi(tsd, pid, (UINT32)-1, ePSIUPDATE_CONTINEOUS, |
|---|
| 758 | SDDS_DsiCallback, 0, &ctx->hDsiCtl); |
|---|
| 759 | DHL_ASSERT(dhr == DHL_OK, ""); |
|---|
| 760 | } |
|---|
| 761 | |
|---|
| 762 | /* |
|---|
| 763 | ctxÀÇ groupinfo µî¿¡ ´ëÇØ¼´Â üũÇÏÁö ¸»ÀÚ. |
|---|
| 764 | ÀÏ´Ü dsi ¼ö½Å ÀÌÈÄ¿¡ °í·ÁÇÏÀÚ. |
|---|
| 765 | */ |
|---|
| 766 | |
|---|
| 767 | } |
|---|
| 768 | |
|---|
| 769 | |
|---|
| 770 | /* |
|---|
| 771 | ´ÙÀ½°ú °°Àº °æ¿ì¿¡ È£Ã⠵ȴÙ. |
|---|
| 772 | |
|---|
| 773 | 1. app ¿¡¼ sdds ä³ÎÀ» ¹þ¾î³ª ´Ù¸¥ ä³Î·Î À̵¿ÇÒ ¶§.. |
|---|
| 774 | 2. ´ë±â¸ðµå¿¡¼ sdds ´Ù¿î·Îµå ÁßÀε¥ »ç¿ëÀÚ°¡ Àü¿øÀ» ÄѼ |
|---|
| 775 | ½Ãû ä³Î·Î °¡¾ß ÇÒ ¶§.. (1¹øÀÇ Æ¯¼ö ÄÉÀ̽º) |
|---|
| 776 | |
|---|
| 777 | µ¥ÀÌÅÍ´Â ±×´ë·Î µÎ°í, monitorµé¸¸ ÁßÁö (stop) ÇÑ´Ù. |
|---|
| 778 | */ |
|---|
| 779 | void SDDS_HandleCmdStop(void) |
|---|
| 780 | { |
|---|
| 781 | S_SDDS_Context *ctx; |
|---|
| 782 | int i; |
|---|
| 783 | |
|---|
| 784 | //-------- parameter checking |
|---|
| 785 | // none |
|---|
| 786 | |
|---|
| 787 | //-------- get context |
|---|
| 788 | ctx = sdds_get_context(); |
|---|
| 789 | |
|---|
| 790 | dprint(2, "stop sdds rx\n"); |
|---|
| 791 | |
|---|
| 792 | // check task is valid. |
|---|
| 793 | //sdds_check_task(ctx->task); |
|---|
| 794 | |
|---|
| 795 | sdds_stop_all_monitor(ctx); |
|---|
| 796 | |
|---|
| 797 | sdds_user_call(eSDDS_CB_TYPE_DownloadStopped, NULL); |
|---|
| 798 | |
|---|
| 799 | } |
|---|
| 800 | |
|---|
| 801 | /* |
|---|
| 802 | sdds °ü·Ã µ¥ÀÌÅ͸¦ ¸ðµÎ Áö¿î´Ù. |
|---|
| 803 | Áö¿î ÈÄ¿¡µµ °è¼Ó ¹Þ¾ÆÁö¸é ¾ÈµÇ¹Ç·Î, ³»ºÎ¿¡¼ ´ç¿¬È÷ ¸ÕÀú stop ºÎÅÍ ÇÑ´Ù. |
|---|
| 804 | |
|---|
| 805 | ´ÙÀ½°ú °°Àº °æ¿ì¿¡ È£Ã⠵ȴÙ. |
|---|
| 806 | 1. flash update ±îÁö ¿Ï·á µÈ ÈÄ(??) |
|---|
| 807 | 2. |
|---|
| 808 | |
|---|
| 809 | app ¿¡¼´Â delete ÇÑ ÀÌÈÄ¿¡µµ ä³Î º¯°æ½Ã ¸¶´Ù start¸¦ ´Ù½Ã È£ÃâÇÒ °ÍÀÌ´Ù. |
|---|
| 810 | ¼ÂžÀº update°¡ ³¡³µ´Ù°í ÇÏ´õ¶óµµ ä³Î º¯°æ½Ã ¸¶´Ù sdds ¼ºñ½º¸¦ ´Ù½Ã ¹ß°ßÇÒ °ÍÀ̴ϱî. |
|---|
| 811 | |
|---|
| 812 | ±×·¡¼ sdds RFÀÇ Ã¤³ÎÀ» Æ©´× ÇÒ ¶§ ¸¶´Ù ÃÖ¼ÒÇÑ dsi, dii´Â ¹Þ°Ô µÈ´Ù. |
|---|
| 813 | (dsi ¸¸ ¹Þ¾Æ¼´Â ÀÌ¹Ì updateµÈ sdds ½ºÆ®¸²ÀÎÁö ±¸ºÐ ºÒ°¡À̹ǷΠdiiµµ ¹ÞÀ½. |
|---|
| 814 | ´õºÒ¾î groupinfo ¹öÆÛ, moduleinfo array buffer µîµµ ¸Å¹ø ÇÒ´ç µÈ´Ù.) |
|---|
| 815 | |
|---|
| 816 | µû¶ó¼ flash update ÀÌÈÄ¿¡µµ delete¸¦ ÇÒ Çʿ䰡 º°·Î ¾ø´Ù. |
|---|
| 817 | firmware¿ë ¹öÆÛ´Â app¿¡¼ °ü¸®ÇϹǷÎ, ÀÌ delete api ¾øÀ̵µ ½±°Ô free ÇÒ ¼ö ÀÖÀ» °ÍÀÓ. |
|---|
| 818 | |
|---|
| 819 | ¹°·Ð app¿¡¼ sdds download¸¦ ´ë±â¸ðµå¿¡¼¸¸ ¼öÇàÇÏ°Ô ÇѴٵ簡 ÇÏ´Â |
|---|
| 820 | ¹æ½ÄÀ» ¾²¸é Á» ´úÇÒ °ÍÀÓ. |
|---|
| 821 | |
|---|
| 822 | Ãß°¡: |
|---|
| 823 | flash update°¡ ¿Ï·á µÇ¸é ¾îÂ÷ÇÇ rebootÀ» ÇÑ´Ù. |
|---|
| 824 | ±×·¯¸é ±»ÀÌ delete¸¦ ºÎ¸¦ Çʿ䵵 ¾ø´Ù. |
|---|
| 825 | Áï ÀÌ api´Â Å×½ºÆ® ¿ëµµ À̿ܿ¡´Â º° ÀÇ¹Ì ¾ø´Ù´Â °Í.. |
|---|
| 826 | */ |
|---|
| 827 | void SDDS_HandleCmdDelete(void) |
|---|
| 828 | { |
|---|
| 829 | S_SDDS_Context *ctx; |
|---|
| 830 | |
|---|
| 831 | //-------- parameter checking |
|---|
| 832 | // none |
|---|
| 833 | |
|---|
| 834 | //-------- get context |
|---|
| 835 | ctx = sdds_get_context(); |
|---|
| 836 | |
|---|
| 837 | dprint(2, "delete all sdds data\n"); |
|---|
| 838 | |
|---|
| 839 | // delete ÇÏ·Á¸é ¸ÕÀú stop ºÎÅÍ.. |
|---|
| 840 | sdds_stop_all_monitor(ctx); |
|---|
| 841 | |
|---|
| 842 | // group Á¤º¸¸¦ Áö¿ì°í |
|---|
| 843 | sdds_free_all_group_info(ctx); |
|---|
| 844 | |
|---|
| 845 | sdds_stop_monitor(&ctx->hDsiCtl); |
|---|
| 846 | sdds_free_section(&ctx->dsi); |
|---|
| 847 | ctx->iGroup = -1; |
|---|
| 848 | |
|---|
| 849 | sdds_user_call(eSDDS_CB_TYPE_ResetDownload, NULL); |
|---|
| 850 | |
|---|
| 851 | } |
|---|
| 852 | |
|---|
| 853 | |
|---|
| 854 | void SDDS_HandleCmdPrintStatus(int level) |
|---|
| 855 | { |
|---|
| 856 | S_SDDS_Context *ctx; |
|---|
| 857 | S_SDDS_GroupInfo *gi; |
|---|
| 858 | S_SDDS_ModuleInfo *mi; |
|---|
| 859 | int k; |
|---|
| 860 | |
|---|
| 861 | //-------- parameter checking |
|---|
| 862 | // none |
|---|
| 863 | |
|---|
| 864 | //-------- get context |
|---|
| 865 | ctx = sdds_get_context(); |
|---|
| 866 | |
|---|
| 867 | #define print DHL_OS_Printf |
|---|
| 868 | |
|---|
| 869 | // dsi info |
|---|
| 870 | print("--------------------------------\n"); |
|---|
| 871 | print(" tsd 0x%x, pid 0x%x (%u)\n", ctx->tsd, ctx->pid, ctx->pid); |
|---|
| 872 | print(" dsi 0x%x, selected group idx %d\n", ctx->dsi, ctx->iGroup); |
|---|
| 873 | print(" dsictl 0x%x, groupinfo 0x%x\n", ctx->hDsiCtl, ctx->gi); |
|---|
| 874 | DLIB_SDDS_PrintDsiSection(ctx->dsi, 5); |
|---|
| 875 | |
|---|
| 876 | // group info |
|---|
| 877 | gi = ctx->gi; |
|---|
| 878 | if (gi == NULL) goto label_end; |
|---|
| 879 | print(" group id 0x%x, blksz %d (0x%x)\n", gi->groupId, gi->blockSize, gi->blockSize); |
|---|
| 880 | print(" dii 0x%x, %d modules\n", gi->dii, gi->numModules); |
|---|
| 881 | print(" diictl 0x%x, moduleinfo list 0x%x\n", gi->hDiiCtl, gi->mi); |
|---|
| 882 | DLIB_SDDS_PrintDiiSection(gi->dii, 5); |
|---|
| 883 | |
|---|
| 884 | // module info list |
|---|
| 885 | if (gi->mi == NULL) goto label_end; |
|---|
| 886 | for (k=0; k<gi->numModules; k++) { |
|---|
| 887 | mi = &gi->mi[k]; |
|---|
| 888 | print(" (%d) module id 0x%x, size %d (0x%x)\n", k, mi->moduleId, mi->moduleSize, mi->moduleSize); |
|---|
| 889 | print(" ddbctl0 0x%x, ddbctl1 0x%x, active %d, completed %d\n", |
|---|
| 890 | mi->hDdbCtl0, mi->hDdbCtl1, mi->bNeedToDownload, mi->bDownloadCompleted); |
|---|
| 891 | print(" %d/%u received\n", sdds_rx_blk_count(mi), mi->numberOfBlocks); |
|---|
| 892 | } |
|---|
| 893 | |
|---|
| 894 | label_end: |
|---|
| 895 | print("--------------------------------\n"); |
|---|
| 896 | |
|---|
| 897 | #undef print |
|---|
| 898 | |
|---|
| 899 | } |
|---|
| 900 | |
|---|
| 901 | |
|---|
| 902 | void SDDS_HandleCmdUserAction(UINT32 userparam) |
|---|
| 903 | { |
|---|
| 904 | sdds_user_call(eSDDS_CB_TYPE_UserAction, (void *)userparam); |
|---|
| 905 | } |
|---|
| 906 | |
|---|
| 907 | /* |
|---|
| 908 | |
|---|
| 909 | */ |
|---|
| 910 | void SDDS_HandleEvtProcessDsi(tDHL_PSI_ControlHandle psiCtl, tDHL_PSI_DataArray *desc) |
|---|
| 911 | { |
|---|
| 912 | DHL_RESULT dhr; |
|---|
| 913 | int iGroup; |
|---|
| 914 | S_SDDS_Context *ctx; |
|---|
| 915 | sddsDsiPtr_t dsi = NULL; |
|---|
| 916 | int i, k; |
|---|
| 917 | |
|---|
| 918 | dprint(2, "%s\n", __FUNCTION__); |
|---|
| 919 | //-------- parameter checking |
|---|
| 920 | |
|---|
| 921 | |
|---|
| 922 | //-------- get context |
|---|
| 923 | ctx = sdds_get_context(); |
|---|
| 924 | |
|---|
| 925 | |
|---|
| 926 | //-------- check if we are too late |
|---|
| 927 | // check psictl is valid |
|---|
| 928 | // todo |
|---|
| 929 | /* |
|---|
| 930 | ¾Æ·¡¿Í °°Àº °æ¿ì´Â psi event Àü´ÞÀÌ ³Ê¹« ´Ê°Ô µÇ¾ú°í, |
|---|
| 931 | ±× »çÀÌ¿¡ stop api°¡ ºÒ¸° °æ¿ìÀÌ´Ù. (¶Ç´Â ±× ÀÌÈÄ¿¡ ´Ù½Ã start api È£Ãâ..) |
|---|
| 932 | |
|---|
| 933 | desc´Â ÀÌ¹Ì Çڵ鿡¼ detach µÇ¾ú±â ¶§¹®¿¡ ¿ì¸® ¼Ò°üÀÌ´Ù. free ÇØÁà¾ß ÇÑ´Ù. |
|---|
| 934 | */ |
|---|
| 935 | if (ctx->hDsiCtl != psiCtl) { |
|---|
| 936 | // ÀÌ psictlÀº ÀÌ¹Ì stop µÈ invalid handle ÀÏ °ÍÀÓ. |
|---|
| 937 | dprint(0, "!! dsi received, but psictl mismatch ours %x event %x\n", ctx->hDsiCtl, psiCtl); |
|---|
| 938 | psiCtl = (tDHL_PSI_ControlHandle)0; |
|---|
| 939 | goto label_end; |
|---|
| 940 | } |
|---|
| 941 | |
|---|
| 942 | //-------- ÆÄ½Ì.. |
|---|
| 943 | dprint(2, " parse dsi..\n"); |
|---|
| 944 | if (dprintable(2)) { // dsi dump |
|---|
| 945 | int size = ((desc->sectPtr[0][1] & 0xf)<<8UL) | desc->sectPtr[0][2]; |
|---|
| 946 | memdump(desc->sectPtr[0], size+3, ""); |
|---|
| 947 | } |
|---|
| 948 | dhr = DLIB_SDDS_ParseDsiSection(desc->sectPtr[0], &dsi); |
|---|
| 949 | DHL_ASSERT(dhr == DHL_OK && dsi != NULL, ""); |
|---|
| 950 | |
|---|
| 951 | DHL_PSI_FreePSIData(desc); |
|---|
| 952 | desc = NULL; |
|---|
| 953 | |
|---|
| 954 | //-------- ³»¿ë Ç¥½Ã.. |
|---|
| 955 | if (dprintable(2)) { |
|---|
| 956 | DLIB_SDDS_PrintDsiSection(dsi, 0); |
|---|
| 957 | } |
|---|
| 958 | |
|---|
| 959 | // dsi sanity check. |
|---|
| 960 | // ¸ðµç table consistency´Â MW ·¹º§¿¡¼ ´Ù½Ã üũÇϵµ·Ï ÇÑ´Ù. |
|---|
| 961 | #if SDDS_ENABLE_SECTION_SYNTAX_CHECK |
|---|
| 962 | DHL_ASSERT(dsi->numberOfGroups > 0, ""); |
|---|
| 963 | DHL_ASSERT(dsi->groups != NULL, ""); |
|---|
| 964 | |
|---|
| 965 | if (!dsi->groups || dsi->numberOfGroups <= 0) { |
|---|
| 966 | dprint(0, "!! invalid dsi, num_group %d\n", dsi->numberOfGroups); |
|---|
| 967 | // ´Ù½Ã ¹Þ¾Æµµ ¸¶Âù°¡Áö ÀÏ °ÍÀ̹ǷΠ±×³É Áß´Ü. |
|---|
| 968 | // dsi ¸ð´ÏÅÍ´Â continuous ¸ðµå·Î ¹Þ°í ÀÖÀ¸¹Ç·Î »¡¸® Áß´Ü. |
|---|
| 969 | sdds_stop_monitor(&ctx->hDsiCtl); |
|---|
| 970 | goto label_end; |
|---|
| 971 | } |
|---|
| 972 | #endif // SDDS_ENABLE_SECTION_SYNTAX_CHECK |
|---|
| 973 | |
|---|
| 974 | |
|---|
| 975 | //------- ÀÌ¹Ì ¹ÞÀº dsi¿Í µ¿ÀÏÇÑ °ÍÀ» ¶Ç ¼ö½Å ÇßÀ» ¼öµµ ÀÖÀ¸¹Ç·Î üũ. |
|---|
| 976 | |
|---|
| 977 | if (ctx->dsi) |
|---|
| 978 | { |
|---|
| 979 | do { |
|---|
| 980 | /* |
|---|
| 981 | ¾î´À Á¤µµ ±îÁö ÀÚ¼¼È÷ ºñ±³ÇØ¾ß ÇÒ±î? |
|---|
| 982 | ±×³É ¹öÀü ºñ±³¸¸À¸·Î µÇ´ÂÁö ¾Æ´Ï¸é byte compare°¡ ÇÊ¿äÇÑÁö.. |
|---|
| 983 | todo.. |
|---|
| 984 | */ |
|---|
| 985 | if (!sdds_is_same_dsi(ctx->dsi, dsi)) { |
|---|
| 986 | dprint(2, " dsi changed\n"); |
|---|
| 987 | break; |
|---|
| 988 | } |
|---|
| 989 | dprint(2, " new dsi is same as old one\n"); |
|---|
| 990 | // pause µÇ¾ú´Ù°¡ Àç½ÃÀÛ ÇÑ °æ¿ìÀ̰ųª, |
|---|
| 991 | // ¹º°¡ ÇÊÅͰ¡ À߸ø µÇ¾î µ¿ÀÏÇÑ ¼½¼ÇÀÌ ¼ö½ÅµÈ °æ¿ìÀÌ´Ù. |
|---|
| 992 | |
|---|
| 993 | // ctx->dsi °¡ non-null À̶ó¸é ¹Ýµå½Ã ´ÙÀ½ Á¶°ÇÀÌ ¸¸Á·µÇ¾î¾ß ÇÑ´Ù. |
|---|
| 994 | // 1. ctx->iGroup ÀÌ valid. |
|---|
| 995 | // 2. ctx->groups ¹öÆÛ ÇÒ´ç ¿Ï·á |
|---|
| 996 | // ÀÌ Á¶°ÇÀÌ ¸¸Á·µÇÁö ¾ÊÀ¸¸é ´Ù½Ã ½ÃÀÛÇØ¾ß ÇÔ. |
|---|
| 997 | |
|---|
| 998 | if (ctx->iGroup < 0 || ctx->iGroup >= ctx->dsi->numberOfGroups) { |
|---|
| 999 | dprint(0, "!! iGroup %d invalid!\n", ctx->iGroup); |
|---|
| 1000 | break; |
|---|
| 1001 | } |
|---|
| 1002 | if (ctx->gi == NULL) { |
|---|
| 1003 | dprint(0, "!! ctx groupinfo null!\n"); |
|---|
| 1004 | break; |
|---|
| 1005 | } |
|---|
| 1006 | // dsi ¸¦ ´õ ÀÌ»ó ó¸®ÇÒ Çʿ䰡 ¾ø´Â °æ¿ìÀÌ´Ù. |
|---|
| 1007 | sdds_free_section(&dsi); |
|---|
| 1008 | // »õ·Î ¹ÞÀº dsi´Â ctx->dsi¿Í Áߺ¹µÈ °ÍÀ̹ǷΠfreeÇϰí |
|---|
| 1009 | // dii 󸮺ηΠ°£´Ù. |
|---|
| 1010 | goto monitor_dii; |
|---|
| 1011 | |
|---|
| 1012 | } while (0); |
|---|
| 1013 | |
|---|
| 1014 | /* |
|---|
| 1015 | dsi°¡ º¯°æ µÉ ¼ö ÀÖ´Â »óȲ: |
|---|
| 1016 | 1. ½ºÆ®¸²ÀÌ Áß°£¿¡ º¯°æ. (½ÇÇè½Ç »óȲ) |
|---|
| 1017 | 2. ¿À·¡Àü¿¡ ½Ç½Ã µÇ¾ú´ø sdds°¡ ¿Ï·á µÇÁö ¸øÇÏ°í ³²¾Æ ÀÖ´Ù°¡ |
|---|
| 1018 | ³ªÁßÀÇ »õ sdds ¹ß°ß. (°¡´É¼ºÀº Èñ¹Ú) |
|---|
| 1019 | */ |
|---|
| 1020 | // dsi°¡ º¯°æ µÈ °æ¿ì.. ¶Ç´Â ¹º°¡ ¹®Á¦°¡ »ý°Ü¼ ´Ù½Ã reset ÇØ¾ß ÇÏ´Â °æ¿ì.. |
|---|
| 1021 | // ÀÌ ¸ðµç °æ¿ì°¡ »ç½Ç»ó ºñÁ¤»ó »óȲÀÌ´Ù. |
|---|
| 1022 | dprint(0, "!!!! dsi is changed. clean up first..\n"); |
|---|
| 1023 | |
|---|
| 1024 | // µ¿ÀÛ ÁßÀÎ ¸ðµç ÇÊÅ͸¦ ´Ù stop Çϰí, |
|---|
| 1025 | // ³»ºÎ¸¦ ¿ÏÀüÈ÷ reset ÇÑ´Ù. |
|---|
| 1026 | sdds_free_all_group_info(ctx); |
|---|
| 1027 | // ÀÌ ¾È¿¡¼ reset ¾ÈµÇ´Â °ÍµéÀº hDsiCtl, dsi »ÓÀÌ´Ù. |
|---|
| 1028 | |
|---|
| 1029 | sdds_free_section(&ctx->dsi); |
|---|
| 1030 | //ctx->dsi = dsi; // group Á¤º¸¸¦ ´Ù ó¸®ÇÑ ÈÄ ¸Ç ³ªÁß¿¡ µî·ÏÇØ¾ß ÇÑ´Ù. |
|---|
| 1031 | // µÎ°³ÀÇ Áߺ¹ Æ÷ÀÎÅÍ´Â ÀÚÁ¦ÇÏ´Â °ÍÀÌ ¹Ù¶÷Á÷. |
|---|
| 1032 | |
|---|
| 1033 | sdds_user_call(eSDDS_CB_TYPE_ResetDownload, NULL); |
|---|
| 1034 | |
|---|
| 1035 | } |
|---|
| 1036 | else { |
|---|
| 1037 | // dsi¸¦ óÀ½ ¼ö½Å ÇÑ °æ¿ì.. |
|---|
| 1038 | dprint(2, " first dsi\n"); |
|---|
| 1039 | |
|---|
| 1040 | // Ȥ½Ã ³²¾Æ ÀÖÀ» Áö ¸ð¸£´Â ¸ðµç µ¥ÀÌÅ͸¦ »èÁ¦.. |
|---|
| 1041 | sdds_free_all_group_info(ctx); |
|---|
| 1042 | //ctx->dsi = dsi; // group Á¤º¸¸¦ ´Ù ó¸®ÇÑ ÈÄ ¸Ç ³ªÁß¿¡ µî·ÏÇØ¾ß ÇÑ´Ù. |
|---|
| 1043 | // µÎ°³ÀÇ Áߺ¹ Æ÷ÀÎÅÍ´Â ÀÚÁ¦ÇÏ´Â °ÍÀÌ ¹Ù¶÷Á÷. |
|---|
| 1044 | } |
|---|
| 1045 | |
|---|
| 1046 | //------------- ±×·ì ¼±Åà ---------- |
|---|
| 1047 | DHL_ASSERT(ctx->dsi == NULL && dsi != NULL, ""); |
|---|
| 1048 | |
|---|
| 1049 | /* |
|---|
| 1050 | |
|---|
| 1051 | */ |
|---|
| 1052 | iGroup = sdds_choose_group_from_dsi(dsi); |
|---|
| 1053 | |
|---|
| 1054 | if (iGroup < 0) { |
|---|
| 1055 | // ±×·ìÀÌ ¾ø´Ù¸é ÀÌ dsi´Â ¾µ¸ð ¾ø´Â µ¥ÀÌÅÍÀÌ´Ù. |
|---|
| 1056 | // ±×·¯³ª »èÁ¦¸¦ ÇÏ¸é »õ·Î¿î dsi ¼ö½ÅÀ» ÇÒ ¼ö ¾øÀ¸¹Ç·Î (trid) |
|---|
| 1057 | // ÀÏ´Ü keepÇÑ´Ù. |
|---|
| 1058 | //sdds_free_section(&dsi); |
|---|
| 1059 | ctx->dsi = dsi; |
|---|
| 1060 | dsi = NULL; |
|---|
| 1061 | sdds_free_all_group_info(ctx); |
|---|
| 1062 | |
|---|
| 1063 | goto monitor_dsi_change; |
|---|
| 1064 | } |
|---|
| 1065 | |
|---|
| 1066 | // iGroup ¼±ÅÃÀº ¿Ï·á. |
|---|
| 1067 | DHL_ASSERT(iGroup >= 0 && iGroup < dsi->numberOfGroups, ""); |
|---|
| 1068 | |
|---|
| 1069 | //-------- ±×·ì ±¸Á¶Ã¼ ¸Þ¸ð¸® ÇÒ´ç ¹× ÃʱâÈ.. |
|---|
| 1070 | |
|---|
| 1071 | if (1) { |
|---|
| 1072 | // ¿ì¸®°¡ °ü½ÉÀÖ´Â ±×·ì Çϳª¸¸ ó¸®.. |
|---|
| 1073 | |
|---|
| 1074 | ctx->gi = DHL_OS_Malloc(sizeof(S_SDDS_GroupInfo)); |
|---|
| 1075 | DHL_ASSERT(ctx->gi != NULL, ""); |
|---|
| 1076 | dprint(2, " groupinfo: 0x%x\n", ctx->gi); |
|---|
| 1077 | |
|---|
| 1078 | ctx->gi->groupId = dsi->groups[iGroup].groupId; |
|---|
| 1079 | } |
|---|
| 1080 | |
|---|
| 1081 | //-------- dsi ó¸® ¿Ï·á ------------ |
|---|
| 1082 | ctx->dsi = dsi; |
|---|
| 1083 | dsi = NULL; // °ü¸® ÆíÀǸ¦ À§ÇØ ÇϳªÀÇ Æ÷ÀÎÅ͸¸ »ç¿ë. |
|---|
| 1084 | ctx->iGroup = iGroup; |
|---|
| 1085 | |
|---|
| 1086 | |
|---|
| 1087 | //-------- dsi ±âŸ Á¤º¸ ------------ |
|---|
| 1088 | if (ctx->dsi->groups[iGroup].scheduleDescriptor.numSchedules > 0) |
|---|
| 1089 | { |
|---|
| 1090 | // schedule Á¤º¸ ¾Ë·ÁÁÜ. |
|---|
| 1091 | sdds_user_call(eSDDS_CB_TYPE_NotifySchedules, |
|---|
| 1092 | &ctx->dsi->groups[iGroup].scheduleDescriptor); |
|---|
| 1093 | |
|---|
| 1094 | // schedule Á¤º¸¿Í »ó°ü ¾øÀÌ, Ç×»ó ´ÙÀ½ ´Ü°è·Î ÁøÇàÇÑ´Ù. |
|---|
| 1095 | // schedule Á¤º¸´Â standby »óÅ¿¡¼ app¿¡¼ »ç¿ëÇÒ °ÍÀÓ. |
|---|
| 1096 | } |
|---|
| 1097 | |
|---|
| 1098 | //-------- dii ¸ð´ÏÅÍ ½ÃÀÛ --------- |
|---|
| 1099 | monitor_dii: |
|---|
| 1100 | |
|---|
| 1101 | // ÀÌ ½ÃÁ¡ºÎÅÍ´Â dsi ´Â »ç¿ëÇÏÁö ¾Ê°í, ctx->dsi ¸¸ »ç¿ëÇϵµ·Ï ÇÏÀÚ. (°ü¸® ÆíÀÇ) |
|---|
| 1102 | DHL_ASSERT(dsi == NULL, ""); |
|---|
| 1103 | DHL_ASSERT(ctx->gi != NULL, ""); |
|---|
| 1104 | |
|---|
| 1105 | if (1) { |
|---|
| 1106 | S_SDDS_GroupInfo *gi = ctx->gi; |
|---|
| 1107 | |
|---|
| 1108 | dprint(2, " processing group id 0x%x..\n", gi->groupId); |
|---|
| 1109 | |
|---|
| 1110 | //-------- ±âÁ¸ dii ¸ð´ÏÅÍ stop. |
|---|
| 1111 | /* comment |
|---|
| 1112 | »õ dsi°¡ ¼ö½ÅµÇ¸é ¹«Á¶°Ç ±âÁ¸ monitor´Â restart Çϵµ·Ï ÇÏÀÚ. |
|---|
| 1113 | groupId µîÀÇ º¯°æ ¿©ºÎ¸¦ Ã¼Å©ÇØ¼ ¼±ÅÃÀûÀ¸·Î restart ÇØµµ µÇÁö¸¸, |
|---|
| 1114 | ¸Å¹ø restart ÇØµµ Å©°Ô ¹®Á¦µÇÁö ¾ÊÀ» µí ÇÔ. |
|---|
| 1115 | |
|---|
| 1116 | ³í¸®ÀûÀ¸·Î dii ctlÀÌ ³²¾Æ ÀÖÀ» ¼öµµ ÀÖ´Ù. stop ¾øÀÌ start api¸¦ ¿¬¼Ó ºÎ¸£¸é.. |
|---|
| 1117 | */ |
|---|
| 1118 | if (gi->hDiiCtl) { |
|---|
| 1119 | dprint(0, "!! cancel old dii monitor.. %x\n", gi->hDiiCtl); |
|---|
| 1120 | sdds_stop_monitor(&gi->hDiiCtl); |
|---|
| 1121 | } |
|---|
| 1122 | |
|---|
| 1123 | //-------- dii ¸ð´ÏÅÍ ½ÃÀÛ. |
|---|
| 1124 | // óÀ½¿¡´Â table_id_extension ÇÊÅÍ ¾øÀÌ ¸ðµÎ ¹Þ´Â´Ù. |
|---|
| 1125 | // |
|---|
| 1126 | dprint(2, " monitor dii with groupid 0x%x..\n", gi->groupId); |
|---|
| 1127 | dhr = DLIB_SDDS_MonitorDii(ctx->tsd, ctx->pid, gi->groupId, ePSIUPDATE_ONESHOT, |
|---|
| 1128 | SDDS_DiiCallback, 0, &gi->hDiiCtl); |
|---|
| 1129 | DHL_ASSERT(dhr == DHL_OK, ""); |
|---|
| 1130 | } |
|---|
| 1131 | |
|---|
| 1132 | monitor_dsi_change: |
|---|
| 1133 | |
|---|
| 1134 | /* comment |
|---|
| 1135 | dsi change¸¦ hardwareÀûÀ¸·Î filtering Çϸé ÁÁÀºµ¥ |
|---|
| 1136 | top-level dsi´Â ¸¹Àº bit°¡ 0À¸·Î °íÁ¤À̹ǷΠ|
|---|
| 1137 | table_id_extension ¸¸À» »ç¿ëÇÒ °æ¿ì LSB 1bit ¹Û¿¡ »ç¿ëÇÒ ¼ö ¾ø´Ù. |
|---|
| 1138 | |
|---|
| 1139 | ¸¸¾à dsi1 --> dsi2 --> dsi3 °ú °°ÀÌ ¼¼¹ø º¯°æÀÌ µÇ°í Àִµ¥, |
|---|
| 1140 | dsi2 ºÎºÐ¿¡ ½ÅÈ£ »óÅ µîÀÌ ¾ÊÁÁ¾Æ¼ dsi2¸¦ ¹ÞÁö ¸øÇß´Ù¸é |
|---|
| 1141 | dsi3´Â ¸ø¹ÞÀ» ¼öµµ ÀÖ´Ù. |
|---|
| 1142 | |
|---|
| 1143 | Á¦´ë·Î ÇÏ·Á¸é transaction_id ÀÇ version field(14bit)¸¦ filter·Î °É¸é µÈ´Ù. |
|---|
| 1144 | HAL¿¡¼ Áö¿øµÇ´ÂÁö¿¡ µû¶ó »ç¿ë °¡´É ¿©ºÎ°¡ ´Þ¶óÁø´Ù. |
|---|
| 1145 | |
|---|
| 1146 | ÇÏÁö¸¸ À§ ¿¹¿¡¼¿Í °°ÀÌ dsi3¸¦ ¸ø¹Þ´Â »óȲ¿¡¼µµ stop & start¸¦ Çϸé |
|---|
| 1147 | ´Ù½Ã ¹Þ°Ô µÈ´Ù. (´Ù¸¥ ä³Î¿¡ ´Ù³à¿À¸é ¹Þ´Â ´Ù´Â ÀǹÌ) |
|---|
| 1148 | µû¶ó¼ 1 bit ¸¸ monitorÇØµµ µÉ µí ÇÏ´Ù. |
|---|
| 1149 | */ |
|---|
| 1150 | |
|---|
| 1151 | // ÇöÀçÀÇ dsi¸¦ ±âÁØÀ¸·Î »õ·Î¿î dsi¸¦ monitorÇÑ´Ù. |
|---|
| 1152 | DHL_ASSERT(ctx->dsi != NULL, ""); |
|---|
| 1153 | sdds_stop_monitor(&ctx->hDsiCtl); |
|---|
| 1154 | |
|---|
| 1155 | //-------- »õ·Î¿î dsi ¸ð´ÏÅÍ. |
|---|
| 1156 | |
|---|
| 1157 | // dsi´Â ¹öÀüÀÌ ¿Ã¶ó°¥ ¶§ ¸¶´Ù transactionIdÀÇ ¸¶Áö¸· LSB°¡ toggleµÈ´Ù. |
|---|
| 1158 | dprint(2, " monitor dsi with new trid %x..\n", ctx->dsi->transactionId ^ 1); |
|---|
| 1159 | dhr = DLIB_SDDS_MonitorDsi(ctx->tsd, ctx->pid, |
|---|
| 1160 | ctx->dsi->transactionId ^ 1, ePSIUPDATE_CONTINEOUS, |
|---|
| 1161 | SDDS_DsiCallback, 0, &ctx->hDsiCtl); |
|---|
| 1162 | DHL_ASSERT(dhr == DHL_OK, ""); |
|---|
| 1163 | |
|---|
| 1164 | label_end: |
|---|
| 1165 | if (dsi){ |
|---|
| 1166 | // ¿©±â±îÁö dsi°¡ Èê·¯¿Â °Å¸é Á¤»ó »óȲÀÌ ¾Æ´Ô. |
|---|
| 1167 | sdds_free_section(&dsi); |
|---|
| 1168 | } |
|---|
| 1169 | if (desc) { |
|---|
| 1170 | DHL_PSI_FreePSIData(desc); |
|---|
| 1171 | desc = NULL; |
|---|
| 1172 | } |
|---|
| 1173 | } |
|---|
| 1174 | |
|---|
| 1175 | |
|---|
| 1176 | /* |
|---|
| 1177 | |
|---|
| 1178 | |
|---|
| 1179 | */ |
|---|
| 1180 | void SDDS_HandleEvtProcessDii(tDHL_PSI_ControlHandle psiCtl, tDHL_PSI_DataArray *desc) |
|---|
| 1181 | { |
|---|
| 1182 | DHL_RESULT dhr; |
|---|
| 1183 | int iModule; |
|---|
| 1184 | int nModuleToDownload; |
|---|
| 1185 | int nModuleCompleted; |
|---|
| 1186 | int nBlocksToDownload; |
|---|
| 1187 | S_SDDS_Context *ctx; |
|---|
| 1188 | S_SDDS_GroupInfo *gi = NULL; |
|---|
| 1189 | sddsDiiPtr_t dii = NULL; |
|---|
| 1190 | int i; |
|---|
| 1191 | |
|---|
| 1192 | dprint(2, "%s\n", __FUNCTION__); |
|---|
| 1193 | |
|---|
| 1194 | //-------- parameter checking |
|---|
| 1195 | |
|---|
| 1196 | |
|---|
| 1197 | //-------- get context |
|---|
| 1198 | ctx = sdds_get_context(); |
|---|
| 1199 | gi = ctx->gi; |
|---|
| 1200 | |
|---|
| 1201 | //-------- check if we are too late |
|---|
| 1202 | //if ( ) return; |
|---|
| 1203 | // check psictl is valid |
|---|
| 1204 | |
|---|
| 1205 | /* |
|---|
| 1206 | event󸮰¡ ´Ê¾îÁø »óȲ¿¡¼: |
|---|
| 1207 | reset api°¡ È£ÃâµÇ¾ú´Ù¸é gi°¡ null |
|---|
| 1208 | stop api°¡ È£ÃâµÇ¾ú´Ù¸é psictlÀÌ ´Þ¶óÁü. |
|---|
| 1209 | */ |
|---|
| 1210 | if (gi == NULL) { |
|---|
| 1211 | dprint(0, "!! dii without groupinfo\n"); // app ¿¡¼ ResetÀ» ÇßÀ» ¼öµµ ÀÖÀ½. |
|---|
| 1212 | goto label_end; // ±×³É Á¶¿ëÈ÷ ¹«½Ã.. |
|---|
| 1213 | } |
|---|
| 1214 | |
|---|
| 1215 | if (gi->hDiiCtl != psiCtl) { // app ¿¡¼ Reset ¶Ç´Â Stop À» ÇßÀ» ¼öµµ ÀÖÀ½. |
|---|
| 1216 | // ÀÌ psictlÀº ÀÌ¹Ì stop µÈ invalid handle ÀÏ °ÍÀÓ. |
|---|
| 1217 | dprint(0, "!! dii received, but psictl mismatch %x %x\n", gi->hDiiCtl, psiCtl); |
|---|
| 1218 | psiCtl = (tDHL_PSI_ControlHandle)0; |
|---|
| 1219 | goto label_end; // ±×³É Á¶¿ëÈ÷ ¹«½Ã.. |
|---|
| 1220 | } |
|---|
| 1221 | |
|---|
| 1222 | //-------- ÆÄ½Ì.. |
|---|
| 1223 | dprint(2, " parse dii..\n"); |
|---|
| 1224 | if (dprintable(2)) { |
|---|
| 1225 | int size = ((desc->sectPtr[0][1] & 0xf)<<8UL) | desc->sectPtr[0][2]; |
|---|
| 1226 | memdump(desc->sectPtr[0], size+3, ""); |
|---|
| 1227 | } |
|---|
| 1228 | dhr = DLIB_SDDS_ParseDiiSection(desc->sectPtr[0], &dii); |
|---|
| 1229 | DHL_ASSERT(dhr == DHL_OK && dii != NULL, ""); |
|---|
| 1230 | |
|---|
| 1231 | DHL_PSI_FreePSIData(desc); |
|---|
| 1232 | desc = NULL; |
|---|
| 1233 | |
|---|
| 1234 | //-------- ³»¿ë Ç¥½Ã.. |
|---|
| 1235 | |
|---|
| 1236 | if (dprintable(2)) { |
|---|
| 1237 | DLIB_SDDS_PrintDiiSection(dii, 0); |
|---|
| 1238 | } |
|---|
| 1239 | |
|---|
| 1240 | #if SDDS_ENABLE_SECTION_SYNTAX_CHECK |
|---|
| 1241 | DHL_ASSERT(dii->numberOfModules > 0, ""); |
|---|
| 1242 | DHL_ASSERT(dii->modules != NULL, ""); |
|---|
| 1243 | |
|---|
| 1244 | if (!dii->modules || dii->numberOfModules == 0) { |
|---|
| 1245 | dprint(0, "!! invalid dii, num module %d\n", dii->numberOfModules); |
|---|
| 1246 | // ÀÌ dii´Â invalid ÇϹǷÎ, ´ÙÀ½ ¹öÀü upµÇ±â¸¦ ±â´Ù·Á¾ß ÇÔ. |
|---|
| 1247 | // ¹öÀü º¯°æÀº dsi ºÎÅÍ ´Ù½Ã ½ÃÀÛÇϹǷÎ, ÀÌ dii psictlÀº Áß´Ü. |
|---|
| 1248 | sdds_stop_monitor(&gi->hDiiCtl); |
|---|
| 1249 | goto label_end; |
|---|
| 1250 | } |
|---|
| 1251 | #endif // SDDS_ENABLE_SECTION_SYNTAX_CHECK |
|---|
| 1252 | |
|---|
| 1253 | |
|---|
| 1254 | //-------- ÇöÀçÀÇ context »óȲ üũ. |
|---|
| 1255 | |
|---|
| 1256 | // ¾Æ·¡ °¢Á¾ ¸Þ½ÃÁöµéÀº ÀϹÝÀûÀÎ »óȲ¿¡¼´Â ¹ß»ýµÇÁö ¾Ê¾Æ¾ß ÇÏÁö¸¸, |
|---|
| 1257 | // °úºÎÇÏ »óÅ¿¡¼´Â ÃæºÐÈ÷ ¹ß»ý °¡´ÉÇÑ °ÍµéÀÓ. |
|---|
| 1258 | // |
|---|
| 1259 | // ¿¹·Î continuous ¸ðµå·Î ¼ö½ÅÇÏ¸é¼ (dii callback ÀÌ °è¼Ó ºÒ¸²) |
|---|
| 1260 | // ÀÌ taskÀÇ Ã³¸®°¡ ´Ê¾îÁö¸é (ÀÌ task ¿¡¼ dii psictl stop) |
|---|
| 1261 | // queue ¿¡ ½×¿© ÀÖ´ø dii callbackÀÌ µÚ´Ê°Ô ¿Ã ¼ö ÀÖ´Ù. |
|---|
| 1262 | |
|---|
| 1263 | if (ctx->dsi == NULL) { |
|---|
| 1264 | dprint(0, "!! dii without dsi\n"); // app ¿¡¼ ResetÀ» ÇßÀ» ¼öµµ ÀÖÀ½. |
|---|
| 1265 | goto label_end; // ±×³É Á¶¿ëÈ÷ ¹«½Ã.. |
|---|
| 1266 | } |
|---|
| 1267 | if (gi->groupId != dii->transactionId) { |
|---|
| 1268 | // ÀÌ·± °æ¿ì´Â µå¹°´Ù.. dii´Â ƯÁ¤ trid·Î ÁöÁ¤ ¼ö½ÅÇÔ. |
|---|
| 1269 | dprint(0, "!! new dii's trid %x not matched of group id %x\n", |
|---|
| 1270 | dii->transactionId, gi->groupId); |
|---|
| 1271 | // 󸮰¡ ´Ê¾îÁ®¼ ¹ß»ýÇÑ °æ¿ì¶ó¸é ±×³É Á¶¿ëÈ÷ ¹«½ÃÇÏ¸é µÇ´Âµ¥, ±×·² °¡´É¼º ³·À½. |
|---|
| 1272 | // ±× ÀÌ¿ÜÀÇ °æ¿ì¶ó¸é, ´õ ¹Þ¾Æ ºÃÀÚ ¶È°°À¸´Ï psictl Áß´Ü. |
|---|
| 1273 | sdds_stop_monitor(&gi->hDiiCtl); |
|---|
| 1274 | goto label_end; |
|---|
| 1275 | } |
|---|
| 1276 | |
|---|
| 1277 | //-------- dii filtering |
|---|
| 1278 | |
|---|
| 1279 | // no filtering required. |
|---|
| 1280 | |
|---|
| 1281 | |
|---|
| 1282 | //-------- ±âÁ¸ dii ¿ÍÀÇ ºñ±³. º¯°æ »çÇ× Ã¼Å©. |
|---|
| 1283 | |
|---|
| 1284 | if (gi->dii) |
|---|
| 1285 | { |
|---|
| 1286 | do { |
|---|
| 1287 | if (!sdds_is_same_dii(gi->dii, dii)) break; |
|---|
| 1288 | |
|---|
| 1289 | // Á¤¸»·Î ¸ðµç °ÍÀÌ ´Ù µ¿ÀÏÇÑÁö Çϳª¾¿ ´Ù½Ã üũ.. |
|---|
| 1290 | if (gi->numModules != dii->numberOfModules) { |
|---|
| 1291 | dprint(0, "!! num module changed %u %u\n", gi->numModules, dii->numberOfModules); |
|---|
| 1292 | break; |
|---|
| 1293 | } |
|---|
| 1294 | for (i=0; i<gi->numModules; i++) { |
|---|
| 1295 | //if (gi->mi[i].moduleBuffer == NULL) break; |
|---|
| 1296 | if (gi->mi[i].moduleId != dii->modules[i].moduleId) break; |
|---|
| 1297 | if (gi->mi[i].moduleSize != dii->modules[i].moduleSize) break; |
|---|
| 1298 | } |
|---|
| 1299 | if (i<gi->numModules) { |
|---|
| 1300 | dprint(0, "!! module info [%d] changed\n", i); |
|---|
| 1301 | break; |
|---|
| 1302 | } |
|---|
| 1303 | |
|---|
| 1304 | dprint(2, " new dii is same as old one\n"); |
|---|
| 1305 | // ok. dii ¿Í mi Á¤º¸´Â ¿ÏÀüÈ÷ µ¿ÀÏÇÏ´Ù°í º¼ ¼ö ÀÖÀ½. |
|---|
| 1306 | // dii ´Â gi->dii ¿Í Áߺ¹µÈ´Ù°í º¸°í »èÁ¦ Çϰí ddb ¸ð´ÏÅÍ·Î jump.. |
|---|
| 1307 | sdds_free_section(&dii); |
|---|
| 1308 | goto download_start; |
|---|
| 1309 | |
|---|
| 1310 | } while(0); |
|---|
| 1311 | |
|---|
| 1312 | dprint(0, " module info or dii changed. reset!\n"); |
|---|
| 1313 | |
|---|
| 1314 | sdds_free_all_module_info(gi); |
|---|
| 1315 | sdds_free_section(&gi->dii); |
|---|
| 1316 | |
|---|
| 1317 | // user¿¡°Ôµµ ÀÌ »ç½ÇÀ» ¾Ë·ÁÁÜ. |
|---|
| 1318 | sdds_user_call(eSDDS_CB_TYPE_ResetDownload, NULL); |
|---|
| 1319 | |
|---|
| 1320 | } |
|---|
| 1321 | else { |
|---|
| 1322 | dprint(2, " first dii\n"); |
|---|
| 1323 | sdds_free_all_module_info(gi); |
|---|
| 1324 | } |
|---|
| 1325 | |
|---|
| 1326 | //-------- ¸ðµâ ±¸Á¶Ã¼ ¸Þ¸ð¸® ÇÒ´ç ¹× ÃʱâÈ.. |
|---|
| 1327 | |
|---|
| 1328 | DHL_ASSERT(gi->dii == NULL && dii != NULL, ""); |
|---|
| 1329 | DHL_ASSERT(gi->mi == NULL, ""); |
|---|
| 1330 | |
|---|
| 1331 | dprint(2, " alloc %d module info..\n", dii->numberOfModules); |
|---|
| 1332 | gi->mi = DHL_OS_Malloc(dii->numberOfModules * sizeof(S_SDDS_ModuleInfo)); |
|---|
| 1333 | DHL_ASSERT(gi->mi != NULL, ""); |
|---|
| 1334 | |
|---|
| 1335 | gi->blockSize = dii->blockSize; |
|---|
| 1336 | gi->numModules = dii->numberOfModules; |
|---|
| 1337 | |
|---|
| 1338 | for (iModule=0; iModule<gi->numModules; iModule++) |
|---|
| 1339 | { |
|---|
| 1340 | S_SDDS_CBPARAM_CHECK_FILE fileinfo; |
|---|
| 1341 | S_SDDS_ModuleInfo *mi = &gi->mi[iModule]; |
|---|
| 1342 | |
|---|
| 1343 | dprint(2, " processing module[%d]..\n", iModule); |
|---|
| 1344 | |
|---|
| 1345 | // application query callback |
|---|
| 1346 | sdds_prepare_module_info(iModule, &dii->modules[iModule], &fileinfo); |
|---|
| 1347 | |
|---|
| 1348 | |
|---|
| 1349 | //-------- module Á¤º¸ callback. accept ¿©ºÎ query. |
|---|
| 1350 | fileinfo.isOk = FALSE; |
|---|
| 1351 | sdds_user_call(eSDDS_CB_TYPE_CheckModuleInfo, &fileinfo); |
|---|
| 1352 | |
|---|
| 1353 | if (fileinfo.isOk) { |
|---|
| 1354 | dprint(2, " module accepted\n"); |
|---|
| 1355 | mi->bNeedToDownload = TRUE; |
|---|
| 1356 | } |
|---|
| 1357 | else { |
|---|
| 1358 | dprint(2, " !! user denied this module\n"); |
|---|
| 1359 | mi->bNeedToDownload = FALSE; |
|---|
| 1360 | } |
|---|
| 1361 | |
|---|
| 1362 | //-------- ¸ðµâ »óÅ º¯¼ö |
|---|
| 1363 | mi->moduleId = fileinfo.id; |
|---|
| 1364 | mi->moduleSize = fileinfo.size; |
|---|
| 1365 | mi->moduleName = fileinfo.name; |
|---|
| 1366 | mi->moduleSignature = fileinfo.version; |
|---|
| 1367 | |
|---|
| 1368 | // ºí·°ÀÇ °¹¼ö´Â (moduleSize+dii->blockSize-1)/dii->blockSize ÀÌ´Ù. |
|---|
| 1369 | // ¸Ç ¸¶Áö¸· blockÀÇ Å©±â´Â blockSize º¸´Ù ÀûÀ» ¼ö ÀÖ´Ù. |
|---|
| 1370 | mi->numberOfBlocks = (mi->moduleSize + dii->blockSize-1)/dii->blockSize; |
|---|
| 1371 | mi->bDownloadCompleted = FALSE; |
|---|
| 1372 | |
|---|
| 1373 | /* |
|---|
| 1374 | ¹öÆÛ °ü¸®´Â app ¿¡¼ Çϵµ·Ï Á¤Ã¥ º¯°æ. |
|---|
| 1375 | ¹öÆÛ¸¦ MW¿¡¼ ÇÏ°Ô µÇ¸é ³ªÁß¿¡ buffer free¸¦ À§ÇÑ º°µµÀÇ api°¡ ÇÊ¿äÇÏ°Ô µÊ. |
|---|
| 1376 | */ |
|---|
| 1377 | #if 0 |
|---|
| 1378 | //-------- ¸ðµâ ¹öÆÛ ¸Þ¸ð¸® ÇÒ´ç.. |
|---|
| 1379 | // ´Ù¿î·Îµå ¹ÞÀ» ºí·°ÀÌ ÀúÀåµÉ ¹öÆÛ °ø°£. Å©±â´Â moduleSize ¹ÙÀÌÆ®. |
|---|
| 1380 | dprint(2, " alloc module buffers.. %u bytes..\n", mi->moduleSize); |
|---|
| 1381 | // todo.. |
|---|
| 1382 | // ¿ä±¸ ÇÏ´Â ¸Þ¸ð¸® Å©±â°¡ ¾öû Ŭ ¼öµµ ÀÖÀ½.. üũ ¿ä¸Á.. |
|---|
| 1383 | |
|---|
| 1384 | if (mi->moduleSize > SDDS_MAX_MODULE_SIZE) { |
|---|
| 1385 | dprint(2, "!! module size exceed max\n"); |
|---|
| 1386 | } |
|---|
| 1387 | else { |
|---|
| 1388 | mi->moduleBuffer = DHL_OS_Malloc(mi->moduleSize); |
|---|
| 1389 | DHL_ASSERT(mi->moduleBuffer != NULL, ""); |
|---|
| 1390 | } |
|---|
| 1391 | #endif |
|---|
| 1392 | |
|---|
| 1393 | //mi->completedFlags[65536/8]; |
|---|
| 1394 | memset(mi->completedFlags, 0, sizeof(mi->completedFlags)); |
|---|
| 1395 | |
|---|
| 1396 | } |
|---|
| 1397 | |
|---|
| 1398 | //-------- dii ó¸® ¿Ï·á ------------ |
|---|
| 1399 | gi->dii = dii; |
|---|
| 1400 | dii = NULL; |
|---|
| 1401 | |
|---|
| 1402 | download_start: |
|---|
| 1403 | |
|---|
| 1404 | DHL_ASSERT(gi->dii != NULL && dii == NULL, ""); |
|---|
| 1405 | |
|---|
| 1406 | //-------- ddb ¸ð´ÏÅÍ Áغñ.. |
|---|
| 1407 | for (iModule=0, nModuleToDownload=0, nBlocksToDownload=0; iModule<gi->numModules; iModule++) |
|---|
| 1408 | { |
|---|
| 1409 | S_SDDS_ModuleInfo *mi = &gi->mi[iModule]; |
|---|
| 1410 | |
|---|
| 1411 | //-------- ±âÁ¸ ddb ¸ð´ÏÅÍ ÁßÁö. |
|---|
| 1412 | // »õ dii°¡ ¼ö½ÅµÇ¸é ¹«Á¶°Ç ±âÁ¸ monitor´Â restart Çϵµ·Ï ÇÏÀÚ. |
|---|
| 1413 | if (mi->hDdbCtl0) { |
|---|
| 1414 | dprint(2, " cancel old ddb0 monitor[%d] 0x%x..\n", iModule, mi->hDdbCtl0); |
|---|
| 1415 | sdds_stop_monitor(&mi->hDdbCtl0); |
|---|
| 1416 | } |
|---|
| 1417 | if (mi->hDdbCtl1) { |
|---|
| 1418 | dprint(2, " cancel old ddb1 monitor[%d] 0x%x..\n", iModule, mi->hDdbCtl1); |
|---|
| 1419 | sdds_stop_monitor(&mi->hDdbCtl1); |
|---|
| 1420 | } |
|---|
| 1421 | /* ¹öÀü µîÀ» È®ÀÎÇÏ¿© download°¡ ÇÊ¿ä ¾ø´Â ÆÄÀϵéÀº º°µµ·Î check¸¦ ÇØ µÎ¾úÀ½. |
|---|
| 1422 | */ |
|---|
| 1423 | if (!mi->bNeedToDownload) continue; |
|---|
| 1424 | |
|---|
| 1425 | if (mi->bDownloadCompleted) { |
|---|
| 1426 | nModuleCompleted++; |
|---|
| 1427 | continue; |
|---|
| 1428 | } |
|---|
| 1429 | |
|---|
| 1430 | nModuleToDownload ++; |
|---|
| 1431 | nBlocksToDownload += mi->numberOfBlocks; |
|---|
| 1432 | } |
|---|
| 1433 | |
|---|
| 1434 | if (nModuleToDownload > 0) { |
|---|
| 1435 | // ÀÌÁ¦ ddb monitor¸¦ ½ÃÀÛÇÏ¸é ¹Ù·Î blonk ¼ö½ÅÀÌ ½ÃÀ۵ȴÙ. |
|---|
| 1436 | // ÀÌ ½ÃÁ¡¿¡¼ download start callback ¾Ë¸². |
|---|
| 1437 | S_SDDS_CBPARAM_DOWNLOAD_START param; |
|---|
| 1438 | param.total_blocks = nBlocksToDownload; |
|---|
| 1439 | sdds_user_call(eSDDS_CB_TYPE_DownloadStarted, ¶m); |
|---|
| 1440 | } |
|---|
| 1441 | else if (nModuleCompleted > 0) { |
|---|
| 1442 | dprint(2, " all modules downloaded already\n"); |
|---|
| 1443 | sdds_user_call(eSDDS_CB_TYPE_DownloadCompleted, (void *)(-1)); |
|---|
| 1444 | goto monitor_dii_change; |
|---|
| 1445 | } |
|---|
| 1446 | else { |
|---|
| 1447 | dprint(2, " no modules to download\n"); |
|---|
| 1448 | sdds_user_call(eSDDS_CB_TYPE_DownloadNotRequired, NULL); |
|---|
| 1449 | goto monitor_dii_change; |
|---|
| 1450 | } |
|---|
| 1451 | |
|---|
| 1452 | //-------- ddb ¸ð´ÏÅÍ ½ÃÀÛ. |
|---|
| 1453 | for (iModule=0; iModule<gi->numModules; iModule++) |
|---|
| 1454 | { |
|---|
| 1455 | S_SDDS_ModuleInfo *mi = &gi->mi[iModule]; |
|---|
| 1456 | |
|---|
| 1457 | //-------- ±âÁ¸ ddb ¸ð´ÏÅÍ ÁßÁö. |
|---|
| 1458 | // »õ dii°¡ ¼ö½ÅµÇ¸é ¹«Á¶°Ç ±âÁ¸ monitor´Â restart Çϵµ·Ï ÇÏÀÚ. |
|---|
| 1459 | if (mi->hDdbCtl0) |
|---|
| 1460 | sdds_stop_monitor(&mi->hDdbCtl0); |
|---|
| 1461 | if (mi->hDdbCtl1) |
|---|
| 1462 | sdds_stop_monitor(&mi->hDdbCtl1); |
|---|
| 1463 | |
|---|
| 1464 | if (!mi->bNeedToDownload) { |
|---|
| 1465 | dprint(2, " module[%d] download skipped\n", iModule); |
|---|
| 1466 | continue; |
|---|
| 1467 | } |
|---|
| 1468 | |
|---|
| 1469 | #if SDDS_ENABLE_DDB_RX_INTERLEAVING |
|---|
| 1470 | dprint(2, " start monitor ddb_0 [%d]..\n", iModule); |
|---|
| 1471 | dhr = DLIB_SDDS_MonitorDdb(ctx->tsd, ctx->pid, mi->moduleId, |
|---|
| 1472 | eDDB_RIM_Even, ePSIUPDATE_CONTINEOUS, |
|---|
| 1473 | SDDS_DdbCallback, 0, &mi->hDdbCtl0); |
|---|
| 1474 | DHL_ASSERT(dhr == DHL_OK, ""); |
|---|
| 1475 | dprint(2, " start monitor ddb_1 [%d]..\n", iModule); |
|---|
| 1476 | dhr = DLIB_SDDS_MonitorDdb(ctx->tsd, ctx->pid, mi->moduleId, |
|---|
| 1477 | eDDB_RIM_Odd, ePSIUPDATE_CONTINEOUS, |
|---|
| 1478 | SDDS_DdbCallback, 0, &mi->hDdbCtl1); |
|---|
| 1479 | DHL_ASSERT(dhr == DHL_OK, ""); |
|---|
| 1480 | #else |
|---|
| 1481 | dprint(2, " start monitor ddb[%d]..\n", iModule); |
|---|
| 1482 | dhr = DLIB_SDDS_MonitorDdb(ctx->tsd, ctx->pid, mi->moduleId, |
|---|
| 1483 | eDDB_RIM_All, ePSIUPDATE_CONTINEOUS, |
|---|
| 1484 | SDDS_DdbCallback, 0, &mi->hDdbCtl0); |
|---|
| 1485 | DHL_ASSERT(dhr == DHL_OK, ""); |
|---|
| 1486 | // ÀÎÅ͸®ºù ¼ö½ÅÀ» ÇÏÁö ¾Ê´Â´Ù¸é hDdbCtl1 Àº »ç¿ëÇÏÁö ¾Ê´Â´Ù. |
|---|
| 1487 | #endif |
|---|
| 1488 | |
|---|
| 1489 | } |
|---|
| 1490 | |
|---|
| 1491 | monitor_dii_change: |
|---|
| 1492 | |
|---|
| 1493 | DHL_ASSERT(gi->dii != NULL, ""); |
|---|
| 1494 | sdds_stop_monitor(&gi->hDiiCtl); |
|---|
| 1495 | |
|---|
| 1496 | // dii°¡ ¹Ù²î¸é dsiµµ °°ÀÌ ¹Ù²î´Ï±î ±»ÀÌ ¸ð´ÏÅ͸¦ °ÉÁö ¾Ê¾Æµµ µÉ µí ÇÔ.. |
|---|
| 1497 | |
|---|
| 1498 | label_end: |
|---|
| 1499 | |
|---|
| 1500 | if (dii) { |
|---|
| 1501 | // ctx¿¡ µî·ÏµÇÁö ¾Ê°í ¿©±â±îÁö Èê·¯¿Â dii´Â ¹ö·Á¾ß ÇÔ. |
|---|
| 1502 | sdds_free_section(&dii); |
|---|
| 1503 | } |
|---|
| 1504 | if (desc) { // ¿¡·¯ ¹ß»ý½Ã ¿©±â¼ desc°¡ free µÊ. |
|---|
| 1505 | DHL_PSI_FreePSIData(desc); |
|---|
| 1506 | desc = NULL; |
|---|
| 1507 | } |
|---|
| 1508 | |
|---|
| 1509 | } |
|---|
| 1510 | |
|---|
| 1511 | |
|---|
| 1512 | /* |
|---|
| 1513 | |
|---|
| 1514 | |
|---|
| 1515 | */ |
|---|
| 1516 | void SDDS_HandleEvtProcessDdb(tDHL_PSI_ControlHandle psiCtl, tDHL_PSI_DataArray *desc) |
|---|
| 1517 | { |
|---|
| 1518 | DHL_RESULT dhr; |
|---|
| 1519 | S_SDDS_Context *ctx; |
|---|
| 1520 | S_SDDS_GroupInfo *gi = NULL; |
|---|
| 1521 | S_SDDS_ModuleInfo *mi = NULL; |
|---|
| 1522 | sddsDdbPtr_t ddb = NULL; |
|---|
| 1523 | int i, iModule; |
|---|
| 1524 | UINT32 received_blocks; |
|---|
| 1525 | |
|---|
| 1526 | dprint(2, "%s\n", __FUNCTION__); |
|---|
| 1527 | |
|---|
| 1528 | //-------- parameter checking |
|---|
| 1529 | |
|---|
| 1530 | |
|---|
| 1531 | //-------- get context |
|---|
| 1532 | ctx = sdds_get_context(); |
|---|
| 1533 | |
|---|
| 1534 | //-------- check if we are too late |
|---|
| 1535 | //if ( ) return; |
|---|
| 1536 | // check psictl is valid |
|---|
| 1537 | |
|---|
| 1538 | gi = ctx->gi; |
|---|
| 1539 | if (gi == NULL) { |
|---|
| 1540 | dprint(0, "!! ddb without groupinfo\n"); |
|---|
| 1541 | goto label_end; |
|---|
| 1542 | } |
|---|
| 1543 | if (gi->mi == NULL || gi->numModules <= 0) { |
|---|
| 1544 | dprint(0, "!! ddb without moduleinfo\n"); |
|---|
| 1545 | goto label_end; |
|---|
| 1546 | } |
|---|
| 1547 | |
|---|
| 1548 | /* |
|---|
| 1549 | psictlÀÌ À¯È¿ÇÑ °ÍÀÎÁö¸¦ °Ë»çÇØ¾ß Çϴµ¥, mi->hDdbCtl ¿¡ ÀúÀµÇ¾?ÀÖ´Ù. |
|---|
| 1550 | ±×·¯³ª ÀÌ ½ÃÁ¡¿¡¼ mi¸¦ ãÀ» ¼ö´Â ¾ø´Ù. |
|---|
| 1551 | ¾î´À module ÀÇ µ¥ÀÌÅÍÀÎÁö¸¦ ¾Ë·Á¸é ddb¸¦ parsing ÇØ¼ |
|---|
| 1552 | ddb->moduleId ¿Í ÀÏÄ¡ÇÏ´Â moduleÀ» ã¾Æ¾ß ÇÑ´Ù. |
|---|
| 1553 | ±×·¡¼ ¼ø¼°¡ ´Ù¸¥ handler¿Í Á» ´Ù¸£´Ù. ÀÏ´Ü parsing ºÎÅÍ ÇØ ºÁ¾ß ÇÑ´Ù. |
|---|
| 1554 | |
|---|
| 1555 | ÀÌ¹Ì À߸øµÈ psictlÀ̶ó¸é ¾û¶×ÇÑ µ¥ÀÌÅÍÀÏ ¼ö ÀÖ´Ù. (ddb°¡ ¾Æ´Ï¶ó pat ¶óµç°¡..) |
|---|
| 1556 | HAL¿¡¼ handleÀ» validate check ÇÏ´Â api¸¦ Á¦°øÇØ ÁÖ¸é ÁÁ´Ù. |
|---|
| 1557 | */ |
|---|
| 1558 | //-------- ÆÄ½Ì.. |
|---|
| 1559 | dprint(2, " parse ddb..\n"); |
|---|
| 1560 | dhr = DLIB_SDDS_ParseDdbSection(desc->sectPtr[0], &ddb); |
|---|
| 1561 | // ¿¡·¯°¡ ¹ß»ýÇÒ ¼öµµ ÀÖÀ½.. ´ëÃ¥ ÇÊ¿ä.. |
|---|
| 1562 | DHL_ASSERT(dhr == DHL_OK && ddb != NULL, ""); |
|---|
| 1563 | |
|---|
| 1564 | |
|---|
| 1565 | //-------- ³»¿ë Ç¥½Ã.. |
|---|
| 1566 | |
|---|
| 1567 | if (dprintable(2)) { |
|---|
| 1568 | DLIB_SDDS_PrintDdbSection(ddb, 0); |
|---|
| 1569 | } |
|---|
| 1570 | |
|---|
| 1571 | |
|---|
| 1572 | //-------- ÇöÀçÀÇ context »óȲ üũ. |
|---|
| 1573 | |
|---|
| 1574 | // ¾î´À ¸ðµâ¿¡ ¼ÓÇÑ ºí·°ÀÎÁö ã´Â´Ù. |
|---|
| 1575 | for (mi=NULL, iModule=0; iModule<gi->numModules; iModule++) { |
|---|
| 1576 | if (gi->mi[iModule].moduleId == ddb->moduleId) { |
|---|
| 1577 | mi = &gi->mi[iModule]; |
|---|
| 1578 | break; |
|---|
| 1579 | } |
|---|
| 1580 | } |
|---|
| 1581 | if (mi == NULL) { |
|---|
| 1582 | dprint(0, "!! cannot find related module\n"); |
|---|
| 1583 | goto label_end; |
|---|
| 1584 | } |
|---|
| 1585 | if (mi->hDdbCtl0 != psiCtl && mi->hDdbCtl1 != psiCtl) { |
|---|
| 1586 | dprint(0, "!! ddb received, but psictl mismatch 0:%x 1:%x this:%x\n", |
|---|
| 1587 | mi->hDdbCtl0, mi->hDdbCtl1, psiCtl); |
|---|
| 1588 | psiCtl = (tDHL_PSI_ControlHandle)0; // ÀÌ¹Ì stop µÈ ÇÚµéÀÓ. |
|---|
| 1589 | goto label_end; // ±×³É Á¶¿ëÈ÷ ¹«½Ã.. |
|---|
| 1590 | } |
|---|
| 1591 | |
|---|
| 1592 | dprint(2, " this block is from module[%d], moduleId 0x%x, ddbctl %d\n", |
|---|
| 1593 | iModule, mi->moduleId, psiCtl==mi->hDdbCtl0 ? 0 : 1); |
|---|
| 1594 | |
|---|
| 1595 | //------- block °Ë»ç ¹× ó¸®.. |
|---|
| 1596 | |
|---|
| 1597 | // ¾î¶² °æ¿ì? |
|---|
| 1598 | // ÀÌ¹Ì reset µÈ °æ¿ì ¹Û¿¡ ¾øÀ» µí ÇÔ.. resetÀº À§¿¡¼ °É·¯Áö´Âµ¥. ÀÏ´Ü Ã¼Å©ÇÏÀÚ. |
|---|
| 1599 | if (mi->bNeedToDownload == FALSE) { |
|---|
| 1600 | dprint(0, "!! ddb with non-necessary module?\n"); |
|---|
| 1601 | //DHL_ASSERT(FALSE, ""); |
|---|
| 1602 | goto label_end; |
|---|
| 1603 | } |
|---|
| 1604 | |
|---|
| 1605 | // block number ¹üÀ§ üũ. |
|---|
| 1606 | if (ddb->blockNumber >= mi->numberOfBlocks) { |
|---|
| 1607 | dprint(0, "!! ddb block# %u exceed max %u. moduleSize %u\n", |
|---|
| 1608 | ddb->blockNumber, mi->numberOfBlocks, mi->moduleSize); |
|---|
| 1609 | goto label_end; |
|---|
| 1610 | } |
|---|
| 1611 | // block data size üũ. ¸ðµâÀÇ ¸¶Áö¸· blockÀ» Á¦¿ÜÇϰí´Â ¸ðµÎ ¹Ì¸® ¾Ë·ÁÁø Á¤º¸¿Í ÀÏÄ¡ÇØ¾ß ÇÔ. |
|---|
| 1612 | if ((ddb->blockNumber < mi->numberOfBlocks-1 && ddb->blockDataLength != gi->blockSize) || |
|---|
| 1613 | (ddb->blockNumber == mi->numberOfBlocks-1 && ddb->blockDataLength > 4066)) { |
|---|
| 1614 | dprint(0, "!! ddb block (blk# %u) data len %u invalid\n", |
|---|
| 1615 | ddb->blockNumber, ddb->blockDataLength); |
|---|
| 1616 | goto label_end; |
|---|
| 1617 | } |
|---|
| 1618 | |
|---|
| 1619 | // ±â ¼ö½Å ¿©ºÎ üũ. |
|---|
| 1620 | if (mi->completedFlags[ddb->blockNumber/8] & (1 << ddb->blockNumber%8)) { |
|---|
| 1621 | dprint(1, " block #%u (moduleId %u) already received, %d/%u\n", |
|---|
| 1622 | ddb->blockNumber, mi->moduleId, sdds_rx_blk_count(mi), mi->numberOfBlocks); |
|---|
| 1623 | // cafrii 100819 fix |
|---|
| 1624 | // ÀÌ¹Ì ¼ö½Å ¿Ï·á »óÅ¿¡¼ caller°¡ ´Ù½Ã start ÇßÀ» ¼öµµ ÀÖÀ¸¹Ç·Î |
|---|
| 1625 | // ¸Å block ¼ö½Å ¸¶´Ù complete üũ¸¦ Çϵµ·Ï ÇÏÀÚ. |
|---|
| 1626 | |
|---|
| 1627 | received_blocks = sdds_rx_blk_count(mi); |
|---|
| 1628 | goto label_check_complete; |
|---|
| 1629 | } |
|---|
| 1630 | |
|---|
| 1631 | mi->completedFlags[ddb->blockNumber/8] |= (1 << ddb->blockNumber%8); |
|---|
| 1632 | |
|---|
| 1633 | // ¼ö½Å Á¤µµ Ç¥½Ã.. |
|---|
| 1634 | received_blocks = sdds_rx_blk_count(mi); |
|---|
| 1635 | dprint(1, " %d/%u ddb blks received\n", received_blocks, mi->numberOfBlocks); |
|---|
| 1636 | |
|---|
| 1637 | //------- application callback |
|---|
| 1638 | |
|---|
| 1639 | if (1) { |
|---|
| 1640 | S_SDDS_CBPARAM_BLOCK_RECEIVED cbp; |
|---|
| 1641 | |
|---|
| 1642 | memset(&cbp, 0, sizeof(cbp)); |
|---|
| 1643 | cbp.ddb = ddb; |
|---|
| 1644 | cbp.idxblk = ddb->blockNumber; |
|---|
| 1645 | cbp.offset = ddb->blockNumber*gi->blockSize; |
|---|
| 1646 | cbp.received_blocks = received_blocks; |
|---|
| 1647 | cbp.total_blocks = mi->numberOfBlocks; |
|---|
| 1648 | |
|---|
| 1649 | sdds_user_call(eSDDS_CB_TYPE_BlockReceived, &cbp); |
|---|
| 1650 | } |
|---|
| 1651 | |
|---|
| 1652 | label_check_complete: |
|---|
| 1653 | |
|---|
| 1654 | // ´Ù ¼ö½Å µÈ °Å¶ó¸é ¿Ï·á. |
|---|
| 1655 | |
|---|
| 1656 | if (received_blocks == mi->numberOfBlocks) { |
|---|
| 1657 | dprint(2, " module[%d] download completed\n", iModule); |
|---|
| 1658 | sdds_stop_monitor(&mi->hDdbCtl0); |
|---|
| 1659 | sdds_stop_monitor(&mi->hDdbCtl1); |
|---|
| 1660 | mi->bDownloadCompleted = TRUE; |
|---|
| 1661 | |
|---|
| 1662 | sdds_user_call(eSDDS_CB_TYPE_DownloadCompleted, (void *)(UINT32)mi->moduleId); |
|---|
| 1663 | } |
|---|
| 1664 | |
|---|
| 1665 | // ¸ðµç module ÀÌ ´Ù¿î·Îµå ¿Ï·á µÇ¸é callback. |
|---|
| 1666 | if (1) |
|---|
| 1667 | { |
|---|
| 1668 | BOOL bAllCompleted = TRUE; |
|---|
| 1669 | for (i=0; i<gi->numModules; i++) { |
|---|
| 1670 | // Çϳª¶óµµ ´Ù ¾È¹ÞÀº ¸ðµâÀÌ ÀÖ´Ù¸é ¾Æ´Ô.. |
|---|
| 1671 | if (gi->mi[i].bNeedToDownload && !gi->mi[i].bDownloadCompleted) { |
|---|
| 1672 | bAllCompleted = FALSE; |
|---|
| 1673 | break; |
|---|
| 1674 | } |
|---|
| 1675 | } |
|---|
| 1676 | if (bAllCompleted) { |
|---|
| 1677 | dprint(2, " all modules are completed\n"); |
|---|
| 1678 | sdds_user_call(eSDDS_CB_TYPE_DownloadCompleted, (void *)-1); |
|---|
| 1679 | } |
|---|
| 1680 | } |
|---|
| 1681 | |
|---|
| 1682 | label_end: |
|---|
| 1683 | |
|---|
| 1684 | //-------- ¸¶¹«¸®.. |
|---|
| 1685 | |
|---|
| 1686 | // ddb ¼½¼ÇÀÇ Æ÷ÀÎÅÍ´Â ½ÇÁ¦·Î´Â ÀÌ desc ¾ÈÀÇ µ¥ÀÌÅ͸¦ ±×³É pointing ¸¸ ÇÑ °ÍÀÌ´Ù. |
|---|
| 1687 | // µû¶ó¼ ddb ¼½¼ÇÀ» ´Ù Ȱ¿ëÇϱâ Àü±îÁö´Â ÀÌ desc¸¦ free ÇÏ¸é ¾ÈµÈ´Ù. |
|---|
| 1688 | |
|---|
| 1689 | // ²À ÇÊ¿äÇÏ´Ù¸é memcpy¸¦ ÇØ µÎ¾î¾ß Çϴµ¥, ±ÇÀåÇÏÁö ¾ÊÀ½.. |
|---|
| 1690 | if (desc) |
|---|
| 1691 | DHL_PSI_FreePSIData(desc); |
|---|
| 1692 | |
|---|
| 1693 | sdds_free_section(&ddb); |
|---|
| 1694 | |
|---|
| 1695 | } |
|---|
| 1696 | |
|---|
| 1697 | |
|---|
| 1698 | void SDDS_HandleEvtProcessDc(tDHL_PSI_ControlHandle psiCtl, tDHL_PSI_DataArray *desc) |
|---|
| 1699 | { |
|---|
| 1700 | dprint(2, "%s\n", __FUNCTION__); |
|---|
| 1701 | |
|---|
| 1702 | DHL_PSI_FreePSIData(desc); |
|---|
| 1703 | } |
|---|
| 1704 | |
|---|
| 1705 | |
|---|
| 1706 | |
|---|
| 1707 | |
|---|
| 1708 | #if COMMENT |
|---|
| 1709 | ____TaskWrapper____(){} |
|---|
| 1710 | #endif |
|---|
| 1711 | |
|---|
| 1712 | |
|---|
| 1713 | DHL_TMHANDLE g_sdds_task; |
|---|
| 1714 | |
|---|
| 1715 | #define DMW_SDDS_TASK_PRIO TASK_PRI_DMW_PSI |
|---|
| 1716 | #define DMW_SDDS_TASK_STACK 16384 |
|---|
| 1717 | |
|---|
| 1718 | |
|---|
| 1719 | /* |
|---|
| 1720 | proxy´Â timer stubµéÀ» º¸ÀÌÁö ¾Ê°Ô ÇØ ÁÖ´Â thin layer. |
|---|
| 1721 | |
|---|
| 1722 | command ¿Í event¸¦ ºÐ¸®Çϴ Ưº°ÇÑ ÀÌÀ¯´Â ¾øÀ½. |
|---|
| 1723 | |
|---|
| 1724 | ¸ðµç command/event¸¦ ´Ù ºÐ¸®ÇÒ ¼öµµ ÀÖ°í, (°¢°¢ÀÇ timer callback »ç¿ë) |
|---|
| 1725 | (--> Äڵ尡 ÁöÀúºÐ..) |
|---|
| 1726 | ¸ðµç command/event¸¦ ÇϳªÀÇ callback¿¡¼ ó¸®ÇÒ ¼öµµ ÀÖ´Ù. |
|---|
| 1727 | (--> ¼º´É »óÀÇ ¼ÕÇØ..) |
|---|
| 1728 | |
|---|
| 1729 | ±×³É µÎ ±Ø´Ü ¿É¼ÇÀÇ Áß°£ Á¤µµ¸¦ »ç¿ëÇÔ.. |
|---|
| 1730 | */ |
|---|
| 1731 | void _sdds_task_proxy_cmd(UINT32 idTimer, UINT32 *param) |
|---|
| 1732 | { |
|---|
| 1733 | if (0); |
|---|
| 1734 | else if (idTimer == eSDDS_Cmd_Init) { |
|---|
| 1735 | dprint(2, "cmd init\n"); |
|---|
| 1736 | SDDS_HandleCmdInit((void *)param[0]); |
|---|
| 1737 | } |
|---|
| 1738 | else if (idTimer == eSDDS_Cmd_Start) { |
|---|
| 1739 | dprint(2, "cmd start\n"); |
|---|
| 1740 | SDDS_HandleCmdStart((tDHL_TSD)param[0], param[1]); |
|---|
| 1741 | } |
|---|
| 1742 | else if (idTimer == eSDDS_Cmd_Stop) { |
|---|
| 1743 | dprint(2, "cmd stop\n"); |
|---|
| 1744 | SDDS_HandleCmdStop(); |
|---|
| 1745 | } |
|---|
| 1746 | else if (idTimer == eSDDS_Cmd_Delete) { |
|---|
| 1747 | //dprint(2, "cmd delete\n"); |
|---|
| 1748 | SDDS_HandleCmdDelete(); |
|---|
| 1749 | } |
|---|
| 1750 | else if (idTimer == eSDDS_Cmd_GetStatus) { |
|---|
| 1751 | //dprint(2, "cmd get status\n"); |
|---|
| 1752 | //SDDS_HandleCmdGetStatus(param[0], param[1]); |
|---|
| 1753 | } |
|---|
| 1754 | else if (idTimer == eSDDS_Cmd_PrintStatus) { |
|---|
| 1755 | //dprint(2, "cmd print status\n"); |
|---|
| 1756 | SDDS_HandleCmdPrintStatus(param[0]); |
|---|
| 1757 | } |
|---|
| 1758 | else if (idTimer == eSDDS_Cmd_UserAction) { |
|---|
| 1759 | SDDS_HandleCmdUserAction(param[0]); |
|---|
| 1760 | } |
|---|
| 1761 | else if (idTimer == eSDDS_Cmd_Shutdown) { |
|---|
| 1762 | //dprint(2, "cmd shutdown\n"); |
|---|
| 1763 | //SDDS_HandleCmdShutdown(param[0], param[1]); |
|---|
| 1764 | } |
|---|
| 1765 | else |
|---|
| 1766 | dprint(0, "!! unknown cmd 0x%x\n", idTimer); |
|---|
| 1767 | } |
|---|
| 1768 | |
|---|
| 1769 | void _sdds_task_proxy_event(UINT32 idTimer, UINT32 *param) |
|---|
| 1770 | { |
|---|
| 1771 | if (0); |
|---|
| 1772 | else if (idTimer == eSDDS_Evt_DSI) { |
|---|
| 1773 | dprint(2, "dsi msg\n"); |
|---|
| 1774 | SDDS_HandleEvtProcessDsi((tDHL_PSI_ControlHandle)param[0], (tDHL_PSI_DataArray *)param[1]); |
|---|
| 1775 | } |
|---|
| 1776 | else if (idTimer == eSDDS_Evt_DII) { |
|---|
| 1777 | dprint(2, "dii msg\n"); |
|---|
| 1778 | SDDS_HandleEvtProcessDii((tDHL_PSI_ControlHandle)param[0], (tDHL_PSI_DataArray *)param[1]); |
|---|
| 1779 | } |
|---|
| 1780 | else if (idTimer == eSDDS_Evt_DDB) { |
|---|
| 1781 | dprint(2, "ddb msg\n"); |
|---|
| 1782 | SDDS_HandleEvtProcessDdb((tDHL_PSI_ControlHandle)param[0], (tDHL_PSI_DataArray *)param[1]); |
|---|
| 1783 | } |
|---|
| 1784 | else if (idTimer == eSDDS_Evt_DC) { |
|---|
| 1785 | dprint(2, "dc msg\n"); |
|---|
| 1786 | SDDS_HandleEvtProcessDc((tDHL_PSI_ControlHandle)param[0], (tDHL_PSI_DataArray *)param[1]); |
|---|
| 1787 | } |
|---|
| 1788 | else |
|---|
| 1789 | dprint(0, "!! unknown evt 0x%x\n", idTimer); |
|---|
| 1790 | } |
|---|
| 1791 | |
|---|
| 1792 | STATUS sdds_task_send_cmd(E_SDDS_Command cmd, UINT32 p0, UINT32 p1, BOOL bWait) |
|---|
| 1793 | { |
|---|
| 1794 | DHL_RESULT dhr; |
|---|
| 1795 | UINT32 params[4]; |
|---|
| 1796 | |
|---|
| 1797 | params[0] = p0; params[1] = p1; |
|---|
| 1798 | |
|---|
| 1799 | dhr = DHL_TIMER_StartEx( |
|---|
| 1800 | g_sdds_task, cmd, 0, /* zero period ==> dpc */ |
|---|
| 1801 | _sdds_task_proxy_cmd, 2, params, eTIMER_FLAG_OneShot); |
|---|
| 1802 | |
|---|
| 1803 | if (bWait) |
|---|
| 1804 | DHL_TIMER_Sync(g_sdds_task); |
|---|
| 1805 | |
|---|
| 1806 | return dhr ? statusError : statusOK; |
|---|
| 1807 | } |
|---|
| 1808 | |
|---|
| 1809 | STATUS sdds_task_send_event(E_SDDS_Command evt, UINT32 p0, UINT32 p1) |
|---|
| 1810 | { |
|---|
| 1811 | DHL_RESULT dhr; |
|---|
| 1812 | UINT32 params[4]; |
|---|
| 1813 | |
|---|
| 1814 | params[0] = p0; params[1] = p1; |
|---|
| 1815 | |
|---|
| 1816 | dhr = DHL_TIMER_StartEx( |
|---|
| 1817 | g_sdds_task, evt, 0, /* zero period ==> dpc */ |
|---|
| 1818 | _sdds_task_proxy_event, 2, params, eTIMER_FLAG_OneShot); |
|---|
| 1819 | return dhr ? statusError : statusOK; |
|---|
| 1820 | } |
|---|
| 1821 | |
|---|
| 1822 | void sdds_task_init(void) |
|---|
| 1823 | { |
|---|
| 1824 | DHL_RESULT dhr; |
|---|
| 1825 | DHL_TIMER_INIT_PARAM param; |
|---|
| 1826 | |
|---|
| 1827 | //dhl_timer_module_init(); // DHL_SYS_Timer ´Â ¹Ì¸® ÃʱâÈ µÇ¾ú´Ù°í °¡Á¤. |
|---|
| 1828 | |
|---|
| 1829 | if (g_sdds_task) |
|---|
| 1830 | return; // dhl timer already initialized. |
|---|
| 1831 | |
|---|
| 1832 | memset(¶m, 0, sizeof(DHL_TIMER_INIT_PARAM)); |
|---|
| 1833 | |
|---|
| 1834 | param.max_timer_entry = 2; // ÇöÀç´Â ¸ðµÎ dpc ·Î¸¸ »ç¿ëÇϹǷÎ, ¸¹ÀÌ ÇÊ¿ä ¾øÀ½. |
|---|
| 1835 | param.name = "sdds"; |
|---|
| 1836 | param.task_priority = DMW_SDDS_TASK_PRIO; |
|---|
| 1837 | param.stack_size = DMW_SDDS_TASK_STACK; |
|---|
| 1838 | param.use_mutex_lock = 0; // we should support ISR!! |
|---|
| 1839 | param.num_user_param = 2; |
|---|
| 1840 | param.msg_que_size = 32; |
|---|
| 1841 | |
|---|
| 1842 | dhr = DHL_TIMER_Initialize(¶m, &g_sdds_task); |
|---|
| 1843 | DHL_ASSERT(dhr == DHL_OK, ""); |
|---|
| 1844 | |
|---|
| 1845 | dprint(2, "sdds task init..\n"); |
|---|
| 1846 | |
|---|
| 1847 | } |
|---|
| 1848 | |
|---|
| 1849 | |
|---|
| 1850 | |
|---|
| 1851 | #if COMMENT |
|---|
| 1852 | ____Debug____(){} |
|---|
| 1853 | #endif |
|---|
| 1854 | |
|---|
| 1855 | |
|---|
| 1856 | |
|---|
| 1857 | |
|---|
| 1858 | #if COMMENT |
|---|
| 1859 | ____Symbol____(){} |
|---|
| 1860 | #endif |
|---|
| 1861 | |
|---|
| 1862 | |
|---|
| 1863 | #if DHL_REGISTER_DEUBG_SYMBOLS |
|---|
| 1864 | |
|---|
| 1865 | static DHL_SymbolTable _symbols[] = |
|---|
| 1866 | { |
|---|
| 1867 | /* however, if you want typing short-cut, it is good usage. |
|---|
| 1868 | DHL_FNC_SYM_ENTRY2("epg_start", App_EpgUpdateStart), |
|---|
| 1869 | DHL_FNC_SYM_ENTRY2("epg_stop", App_EpgUpdateCancel), |
|---|
| 1870 | DHL_FNC_SYM_ENTRY2("epg_list", Dmc_EpgPrintAllTables), |
|---|
| 1871 | DHL_FNC_SYM_ENTRY2("epg_delete", App_EpgDeleteAll), |
|---|
| 1872 | |
|---|
| 1873 | DHL_VAR_SYM_ENTRY(g_XX_TestMode), |
|---|
| 1874 | */ |
|---|
| 1875 | 0, |
|---|
| 1876 | }; |
|---|
| 1877 | |
|---|
| 1878 | #endif /* DHL_REGISTER_DEUBG_SYMBOLS */ |
|---|
| 1879 | |
|---|
| 1880 | |
|---|
| 1881 | |
|---|
| 1882 | #if COMMENT |
|---|
| 1883 | ____Init____(){} |
|---|
| 1884 | #endif |
|---|
| 1885 | |
|---|
| 1886 | |
|---|
| 1887 | void DMW_SDDS_Init(void) |
|---|
| 1888 | { |
|---|
| 1889 | //STATUS status; |
|---|
| 1890 | |
|---|
| 1891 | #if DHL_REGISTER_DEUBG_SYMBOLS |
|---|
| 1892 | DHL_DBG_RegisterSymbols(_symbols, DHL_NUMSYMBOLS(_symbols)); |
|---|
| 1893 | #endif |
|---|
| 1894 | |
|---|
| 1895 | /* °¢Á¾ init code.. */ |
|---|
| 1896 | |
|---|
| 1897 | sdds_task_init(); |
|---|
| 1898 | |
|---|
| 1899 | // bwait ¸ðµå »ç¿ë½Ã ÁÖÀÇ. user action command (flashing) ÀÛ¾÷Àº ¿À·¡ °É¸± ¼ö ÀÖÀ¸¹Ç·Î.. |
|---|
| 1900 | // sdds init Àº óÀ½ init task ¿¡¼ 1ȸ¸¸ ºÒ¸®¹Ç·Î ±¦ÂúÀ½. |
|---|
| 1901 | sdds_task_send_cmd(eSDDS_Cmd_Init, 0, 0, TRUE); |
|---|
| 1902 | // jump to SDDS_HandleCmdInit |
|---|
| 1903 | } |
|---|
| 1904 | |
|---|
| 1905 | void DMW_SDDS_RegisterCallback(F_SDDS_CALLBACK cb) |
|---|
| 1906 | { |
|---|
| 1907 | s_sdds_user_cb = cb; |
|---|
| 1908 | } |
|---|
| 1909 | |
|---|
| 1910 | void DMW_SDDS_Start(int pid) |
|---|
| 1911 | { |
|---|
| 1912 | sdds_task_send_cmd(eSDDS_Cmd_Start, (UINT32)DHL_DMX_GetTsd(), pid, FALSE); |
|---|
| 1913 | // jump to SDDS_HandleCmdStart |
|---|
| 1914 | } |
|---|
| 1915 | |
|---|
| 1916 | void DMW_SDDS_Stop(void) |
|---|
| 1917 | { |
|---|
| 1918 | sdds_task_send_cmd(eSDDS_Cmd_Stop, 0, 0, FALSE); |
|---|
| 1919 | // jump to SDDS_HandleCmdStop |
|---|
| 1920 | } |
|---|
| 1921 | |
|---|
| 1922 | void DMW_SDDS_Reset(void) |
|---|
| 1923 | { |
|---|
| 1924 | sdds_task_send_cmd(eSDDS_Cmd_Delete, 0, 0, FALSE); |
|---|
| 1925 | // jump to SDDS_HandleCmdDelete |
|---|
| 1926 | } |
|---|
| 1927 | |
|---|
| 1928 | void DMW_SDDS_PrintStatus(int level) |
|---|
| 1929 | { |
|---|
| 1930 | sdds_task_send_cmd(eSDDS_Cmd_PrintStatus, level, 0, FALSE); |
|---|
| 1931 | // jump to SDDS_HandleCmdPrintStatus |
|---|
| 1932 | } |
|---|
| 1933 | |
|---|
| 1934 | void DMW_SDDS_UserAction(UINT32 userparam) |
|---|
| 1935 | { |
|---|
| 1936 | sdds_task_send_cmd(eSDDS_Cmd_UserAction, 0, 0, FALSE); |
|---|
| 1937 | } |
|---|
| 1938 | |
|---|
| 1939 | |
|---|
| 1940 | #if COMMENT |
|---|
| 1941 | ____Test____(){} |
|---|
| 1942 | #endif |
|---|
| 1943 | |
|---|
| 1944 | #if DMW_SDDS_TEST |
|---|
| 1945 | |
|---|
| 1946 | /* |
|---|
| 1947 | test procedure |
|---|
| 1948 | |
|---|
| 1949 | m2_init |
|---|
| 1950 | m2_chtype 0 |
|---|
| 1951 | m2_scan 18 18 |
|---|
| 1952 | // ¶Ç´Â KBS-2 live.. sdds ¼ºñ½º°¡ Æ÷ÇԵǾî ÀÖ¾î¾ß ÇÔ. |
|---|
| 1953 | //m2_tune 7 |
|---|
| 1954 | sml $sds 4 |
|---|
| 1955 | |
|---|
| 1956 | DMW_SDDS_Init |
|---|
| 1957 | DWM_SDDS_Start 0x1200 |
|---|
| 1958 | // vct/pmt ¿¡¼ pid´Â ã¾Æ¾ß Çϴµ¥, |
|---|
| 1959 | // ±¹³» KBS sdds´Â Áö±Ý 0x1200 À¸·Î °íÁ¤ µÈ µí ÇÔ.. |
|---|
| 1960 | // ³ªÁß¿¡ ¹Ù²ð ¼ö ÀÖÀ½. |
|---|
| 1961 | */ |
|---|
| 1962 | |
|---|
| 1963 | void sdt_callback(E_SDDS_CB_TYPE cbtype, void *param) |
|---|
| 1964 | { |
|---|
| 1965 | dprint(0, "------- callback, type %d, param %x\n", cbtype, param); |
|---|
| 1966 | |
|---|
| 1967 | if (0); |
|---|
| 1968 | #if 0 |
|---|
| 1969 | else if (cbtype == eSDDS_CB_TYPE_GetOUI) { |
|---|
| 1970 | S_SDDS_CBPARAM_GET_OUI *cbp = (S_SDDS_CBPARAM_GET_OUI *)param; |
|---|
| 1971 | cbp->oui = IEEE_OUI_DST; |
|---|
| 1972 | //cbp->oui = 0x80000000; // special marker.. meaning accept anyone. |
|---|
| 1973 | /* ÁÖÀÇ !!!!!!!! |
|---|
| 1974 | ÀÌ ½ºÆä¼È ¸¶Ä¿´Â °³¹ß¿ëÀ¸·Î¸¸ »ç¿ëµÇ¾î¾ß ÇÔ!!!! |
|---|
| 1975 | OUI´Â 24ºñÆ® À̹ǷÎ, À§ °ªÀº ½ÇÁ¦·Î´Â »ç¿ëµÇÁö ¾Ê´Â ¹üÀ§ÀÓ. |
|---|
| 1976 | */ |
|---|
| 1977 | cbp->model = 0x01; // NEWBY |
|---|
| 1978 | cbp->version = 0xFFFF; // any version. |
|---|
| 1979 | } |
|---|
| 1980 | #else |
|---|
| 1981 | else if (cbtype == eSDDS_CB_TYPE_CheckCompatDesc) { |
|---|
| 1982 | S_SDDS_CBPARAM_CHECK_DESC *cbp = (S_SDDS_CBPARAM_CHECK_DESC *)param; |
|---|
| 1983 | int i; |
|---|
| 1984 | for (i=0; i<cbp->desc->descriptorCount; i++) { |
|---|
| 1985 | sddsCompatDescEntry_t *desc = &cbp->desc->desc[i]; |
|---|
| 1986 | if (desc->descriptorType != eSystemHardwareDescriptor && |
|---|
| 1987 | desc->descriptorType != eSystemSoftwareDescriptor) |
|---|
| 1988 | continue; |
|---|
| 1989 | if (desc->specifierType != compatSpecifierType_IEEE_OUI) |
|---|
| 1990 | continue; |
|---|
| 1991 | if (desc->specifierData != IEEE_OUI_DST) |
|---|
| 1992 | continue; |
|---|
| 1993 | if (desc->model != 0x01) // NEWBY |
|---|
| 1994 | continue; |
|---|
| 1995 | // DST ±Ô°Ý, NEWBY ±ÔÁ¤¿¡¼´Â versionÀº ¹Ì»ç¿ë. |
|---|
| 1996 | |
|---|
| 1997 | // desc->subDescriptorCount ¿¡´Â urgency mode °¡ µé¾î ÀÖÀ»ÅÙµ¥, |
|---|
| 1998 | // ÀÏ´Ü »ç¿ëÇÏÁö ¾Ê´Â´Ù. |
|---|
| 1999 | cbp->isOk = TRUE; |
|---|
| 2000 | break; |
|---|
| 2001 | } |
|---|
| 2002 | } |
|---|
| 2003 | #endif |
|---|
| 2004 | |
|---|
| 2005 | else if (cbtype == eSDDS_CB_TYPE_NotifySchedules) { |
|---|
| 2006 | int i; |
|---|
| 2007 | sddsScheduleDesc_t *sch = (sddsScheduleDesc_t *)param; |
|---|
| 2008 | for (i=0; sch && sch->schedules && i<sch->numSchedules; i++) { |
|---|
| 2009 | dprint(2, " sched[%d] %x, %d seconds\n", |
|---|
| 2010 | sch->schedules[i].startTime, |
|---|
| 2011 | sch->schedules[i].lengthInSeconds); |
|---|
| 2012 | } |
|---|
| 2013 | } |
|---|
| 2014 | |
|---|
| 2015 | else if (cbtype == eSDDS_CB_TYPE_CheckModuleInfo) { |
|---|
| 2016 | S_SDDS_CBPARAM_CHECK_FILE *cbp = (S_SDDS_CBPARAM_CHECK_FILE *)param; |
|---|
| 2017 | |
|---|
| 2018 | dprint(2, " [%d] check file: mid %u, '%s'", cbp->id, cbp->name); |
|---|
| 2019 | cbp->isOk = TRUE; |
|---|
| 2020 | } |
|---|
| 2021 | |
|---|
| 2022 | else if (cbtype == eSDDS_CB_TYPE_BlockReceived) { |
|---|
| 2023 | S_SDDS_CBPARAM_BLOCK_RECEIVED *cbp = (S_SDDS_CBPARAM_BLOCK_RECEIVED *)param; |
|---|
| 2024 | dprint(2, " %u/%u blocks received\n", cbp->received_blocks, cbp->total_blocks); |
|---|
| 2025 | } |
|---|
| 2026 | |
|---|
| 2027 | } |
|---|
| 2028 | |
|---|
| 2029 | void sdt_init(void) |
|---|
| 2030 | { |
|---|
| 2031 | void m2_init(void); |
|---|
| 2032 | void m2_chtype(int); |
|---|
| 2033 | void m2_scan(int,int); |
|---|
| 2034 | |
|---|
| 2035 | DHL_DBG_SetModuleLevel("$sds", 4); |
|---|
| 2036 | m2_init(); |
|---|
| 2037 | m2_chtype(0); |
|---|
| 2038 | m2_scan(18, 18); // ¶Ç´Â KBS-2 live.. sdds ¼ºñ½º°¡ Æ÷ÇԵǾî ÀÖ¾î¾ß ÇÔ. |
|---|
| 2039 | |
|---|
| 2040 | DMW_SDDS_Init(); |
|---|
| 2041 | DMW_SDDS_RegisterCallback(sdt_callback); |
|---|
| 2042 | } |
|---|
| 2043 | |
|---|
| 2044 | void sdt_start(UINT16 pid) |
|---|
| 2045 | { |
|---|
| 2046 | DMW_SDDS_Start(pid); |
|---|
| 2047 | } |
|---|
| 2048 | |
|---|
| 2049 | #endif // DMW_SDDS_TEST |
|---|
| 2050 | |
|---|
| 2051 | |
|---|
| 2052 | /* end of file */ |
|---|
| 2053 | |
|---|