rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | /***************************************************************************** |
| 2 | * Copyright Statement: |
| 3 | * -------------------- |
| 4 | * This software is protected by Copyright and the information contained |
| 5 | * herein is confidential. The software may not be copied and the information |
| 6 | * contained herein may not be used or disclosed except with the written |
| 7 | * permission of MediaTek Inc. (C) 2005 |
| 8 | * |
| 9 | * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 10 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 11 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| 12 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 13 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 14 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 15 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 16 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 17 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| 18 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| 19 | * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| 20 | * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| 21 | * |
| 22 | * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| 23 | * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 24 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 25 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| 26 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 27 | * |
| 28 | * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| 29 | * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| 30 | * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| 31 | * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| 32 | * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| 33 | * |
| 34 | *****************************************************************************/ |
| 35 | |
| 36 | /***************************************************************************** |
| 37 | * |
| 38 | * Filename: |
| 39 | * --------- |
| 40 | * tst_file_transfer.c |
| 41 | * |
| 42 | * Project: |
| 43 | * -------- |
| 44 | * Maui_Software |
| 45 | * |
| 46 | * Description: |
| 47 | * ------------ |
| 48 | * This file implements the tasks to transfer TST logs to File |
| 49 | * |
| 50 | * Author: |
| 51 | * ------- |
| 52 | * ------- |
| 53 | * |
| 54 | *============================================================================== |
| 55 | * HISTORY |
| 56 | * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 57 | *------------------------------------------------------------------------------ |
| 58 | * removed! |
| 59 | * removed! |
| 60 | * removed! |
| 61 | * removed! |
| 62 | * removed! |
| 63 | * removed! |
| 64 | * removed! |
| 65 | * removed! |
| 66 | * removed! |
| 67 | * removed! |
| 68 | * removed! |
| 69 | * removed! |
| 70 | * removed! |
| 71 | * removed! |
| 72 | * removed! |
| 73 | * removed! |
| 74 | * removed! |
| 75 | * removed! |
| 76 | * removed! |
| 77 | * removed! |
| 78 | * removed! |
| 79 | * removed! |
| 80 | * removed! |
| 81 | * removed! |
| 82 | * removed! |
| 83 | * removed! |
| 84 | * removed! |
| 85 | * |
| 86 | * removed! |
| 87 | * removed! |
| 88 | * removed! |
| 89 | * |
| 90 | * removed! |
| 91 | * removed! |
| 92 | * removed! |
| 93 | * |
| 94 | * removed! |
| 95 | * removed! |
| 96 | * removed! |
| 97 | * |
| 98 | * removed! |
| 99 | * removed! |
| 100 | * removed! |
| 101 | * |
| 102 | * removed! |
| 103 | * removed! |
| 104 | * removed! |
| 105 | * |
| 106 | * removed! |
| 107 | * removed! |
| 108 | * removed! |
| 109 | * |
| 110 | * removed! |
| 111 | * removed! |
| 112 | * removed! |
| 113 | * |
| 114 | * removed! |
| 115 | * removed! |
| 116 | * removed! |
| 117 | * |
| 118 | * removed! |
| 119 | * removed! |
| 120 | * removed! |
| 121 | * |
| 122 | * removed! |
| 123 | * removed! |
| 124 | * removed! |
| 125 | * |
| 126 | * removed! |
| 127 | * removed! |
| 128 | * removed! |
| 129 | * |
| 130 | * removed! |
| 131 | * removed! |
| 132 | * removed! |
| 133 | * |
| 134 | * removed! |
| 135 | * removed! |
| 136 | * removed! |
| 137 | * |
| 138 | * removed! |
| 139 | * removed! |
| 140 | * removed! |
| 141 | * |
| 142 | * removed! |
| 143 | * removed! |
| 144 | * removed! |
| 145 | * |
| 146 | * removed! |
| 147 | * removed! |
| 148 | * removed! |
| 149 | * |
| 150 | * removed! |
| 151 | * removed! |
| 152 | * removed! |
| 153 | * |
| 154 | * removed! |
| 155 | * removed! |
| 156 | * removed! |
| 157 | * removed! |
| 158 | * removed! |
| 159 | * |
| 160 | * removed! |
| 161 | * removed! |
| 162 | * removed! |
| 163 | * |
| 164 | * removed! |
| 165 | * removed! |
| 166 | * removed! |
| 167 | * |
| 168 | * removed! |
| 169 | * removed! |
| 170 | * removed! |
| 171 | * |
| 172 | * removed! |
| 173 | * removed! |
| 174 | * removed! |
| 175 | * |
| 176 | * removed! |
| 177 | * removed! |
| 178 | * removed! |
| 179 | * |
| 180 | * removed! |
| 181 | * removed! |
| 182 | * removed! |
| 183 | * |
| 184 | * removed! |
| 185 | * removed! |
| 186 | * removed! |
| 187 | * |
| 188 | * |
| 189 | *------------------------------------------------------------------------------ |
| 190 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 191 | *============================================================================ |
| 192 | ****************************************************************************/ |
| 193 | |
| 194 | #include "kal_public_api.h" //MSBB change #include "kal_release.h" /* Basic data type */ |
| 195 | |
| 196 | #include "kal_public_defs.h" //MSBB change #include "stack_common.h" |
| 197 | #include "kal_public_defs.h" //MSBB change #include "stack_msgs.h" |
| 198 | |
| 199 | #include "syscomp_config.h" |
| 200 | #include "task_config.h" /* Task creation */ |
| 201 | |
| 202 | #include "kal_public_api.h" /* Buffer management */ |
| 203 | |
| 204 | #include "GV.h" |
| 205 | #include "tst_def.h" |
| 206 | #include "tst_ext.h" /* Dump info*/ |
| 207 | #include "fat_fs.h" |
| 208 | #include "dcl.h" // For HAL RTC Interface |
| 209 | #include "tst_file_def.h" |
| 210 | |
| 211 | //#pragma arm section code= "PRIMARY_ROCODE" rwdata = "PRIMARY_RW" , rodata = "PRIMARY_RODATA" , zidata = "PRIMARY_ZI" |
| 212 | /************************************************************************* |
| 213 | * Definitions |
| 214 | *************************************************************************/ |
| 215 | #ifdef __TST_WRITE_TO_FILE__ |
| 216 | #if defined(__TST_WRITE_EX_MEM_ONLY__) |
| 217 | __tstfilezidata kal_uint8 write2file_temp_buf[ASSERT_MEM_DISK_DUMP_BUF_LEN]; |
| 218 | #define ASSERT_MEM_DISK_DUMP_BUF_LEN (1024) |
| 219 | #else |
| 220 | #define write2file_temp_buf (tst_dump_info.buffer) |
| 221 | #define ASSERT_MEM_DISK_DUMP_BUF_LEN (TST_FSWRITE_BUFFER_SIZE) |
| 222 | #endif |
| 223 | #endif //#ifdef __TST_WRITE_TO_FILE__ |
| 224 | |
| 225 | #define BIN_FILE_HEADER (0x2454ABCD) |
| 226 | #define BIN_FILE_VERSION (0x00000001) |
| 227 | #define TST_FILE_DISK_CHECK_PERIOD (128) |
| 228 | |
| 229 | /************************************************************************* |
| 230 | * Global variable declaration |
| 231 | *************************************************************************/ |
| 232 | |
| 233 | #ifdef __TST_WRITE_TO_FILE__ |
| 234 | __tstfilezidata tst_dump_info_struct tst_dump_info; |
| 235 | |
| 236 | #ifdef __SMART_PHONE_MODEM__ |
| 237 | __tstfilezidata kal_uint32 tst_check_sd_avail_tick=0; |
| 238 | #endif //#ifdef __SMART_PHONE_MODEM__ |
| 239 | |
| 240 | #if defined(__TST_WRITE_EX_MEM_ONLY__) |
| 241 | __tstfilezidata kal_uint8 write2file_temp_buf[ASSERT_MEM_DISK_DUMP_BUF_LEN]; |
| 242 | #else |
| 243 | #define write2file_temp_buf (tst_dump_info.buffer) |
| 244 | #define ASSERT_MEM_DISK_DUMP_BUF_LEN (TST_FSWRITE_BUFFER_SIZE) |
| 245 | #endif |
| 246 | #elif defined(__AT_ETSTLP_SUPPORT__) || !defined(__MMI_FMI__) |
| 247 | #define ASSERT_MEM_DISK_DUMP_BUF_LEN (1024) // for dual talk logging memory dump |
| 248 | __tstfilezidata kal_uint8 write2file_temp_buf[ASSERT_MEM_DISK_DUMP_BUF_LEN]; |
| 249 | #else |
| 250 | #define write2file_temp_buf NULL |
| 251 | #define ASSERT_MEM_DISK_DUMP_BUF_LEN (0) |
| 252 | #endif //#ifdef __TST_WRITE_TO_FILE__ |
| 253 | |
| 254 | __tstfilerwdata tst_log_to_file_err_enum tst_err_log_to_file = NO_LOG_ERROR; //the error code |
| 255 | __tstfilerwdata kal_uint8* tst_file_ex_tmp_buf = write2file_temp_buf; |
| 256 | __tstfilerwdata kal_uint32 tst_file_ex_tmp_buf_size = ASSERT_MEM_DISK_DUMP_BUF_LEN; |
| 257 | __tstfilezidata kal_eventgrpid tft_event_group; |
| 258 | |
| 259 | |
| 260 | /************************************************************************* |
| 261 | * Extern variable declaration |
| 262 | *************************************************************************/ |
| 263 | #if defined(__SMART_PHONE_MODEM__) |
| 264 | extern kal_bool tst_ft_mode; |
| 265 | #endif //#if defined(__SMART_PHONE_MODEM__) |
| 266 | extern kal_bool tst_is_PsTrc_open; |
| 267 | extern kal_bool tst_ft_mode; |
| 268 | extern kal_uint8 TST_OUTPUT_MODE; |
| 269 | extern char base_release_hw_ver[]; |
| 270 | extern char base_release_sw_ver[]; |
| 271 | extern unsigned char tst_module_filter_g[]; |
| 272 | extern unsigned char tst_sap_filter_g[]; |
| 273 | extern unsigned char tst_trace_filter_g[]; |
| 274 | extern kal_bool tst_l1trace_flag; |
| 275 | extern kal_bool tst_pstrace_flag; |
| 276 | extern kal_bool bLoadMiniLogFilter; |
| 277 | |
| 278 | /************************************************************************* |
| 279 | * Function declaration |
| 280 | *************************************************************************/ |
| 281 | kal_bool tst_file_transferrer_create(comptask_handler_struct **handle); |
| 282 | kal_bool tst_file_transferrer_init(void); |
| 283 | void tst_file_transferrer_main( task_entry_struct * task_entry_ptr ); |
| 284 | kal_bool tst_file_transferrer_reset(void); |
| 285 | void tst_file_open_file_to_write(void); |
| 286 | void tst_file_dump_create_file(void); |
| 287 | FS_HANDLE tst_file_create_file(void); |
| 288 | void tst_file_dump_file(void); |
| 289 | kal_bool tst_file_write_file(kal_uint8 *buffer, kal_uint32 length); |
| 290 | extern kal_bool tst_check_filter_enabled(void); |
| 291 | extern void trc_setfilter(unsigned char *setting, unsigned int len); |
| 292 | extern kal_bool if_buffer_all_zero(kal_uint8 *ptr, kal_uint16 length); |
| 293 | extern void tst_file_update_predefined_filters(void); |
| 294 | extern kal_uint32 tst_get_ring_buffer_usage(void); |
| 295 | extern void tst_file_write_logacc_logs(void); |
| 296 | extern void tst_nvram_statistic_handler(nvram_actions act); |
| 297 | kal_uint32 tst_file_wait_data_card_for_ready(void); |
| 298 | kal_bool tst_file_get_disk_phy_space(kal_char driveLetter); |
| 299 | |
| 300 | /************************************************************************* |
| 301 | * Function body |
| 302 | *************************************************************************/ |
| 303 | |
| 304 | #ifdef __TST_WRITE_TO_FILE__ //this function is only avaialable when __TST_WRITE_TO_FILE__ is enabled |
| 305 | |
| 306 | __tstfileFunc void tst_file_write_verno_to_file(void) |
| 307 | { |
| 308 | FS_HANDLE fHandle; |
| 309 | WCHAR strFSName[54];//i.e. X:\PSLog\00000.dmp |
| 310 | kal_uint32 written_bytes; |
| 311 | |
| 312 | #if !defined(__SMART_PHONE_MODEM__) |
| 313 | { |
| 314 | RTC_CTRL_GET_TIME_T rtc_time; |
| 315 | DCL_HANDLE rtc_handler; |
| 316 | kal_uint32 tick; |
| 317 | |
| 318 | rtc_handler = DclRTC_Open(DCL_RTC,FLAGS_NONE); |
| 319 | if(STATUS_FAIL == DclRTC_Control(rtc_handler, RTC_CMD_GET_TIME, (DCL_CTRL_DATA_T *)&rtc_time)) // New API with CMD & DATA |
| 320 | { |
| 321 | tick = kal_get_systicks(); |
| 322 | kal_wsprintf(strFSName, "%c:\\PSLog\\%d_version.txt", tst_dump_info.cDriveLetter,tick); |
| 323 | } |
| 324 | else |
| 325 | { |
| 326 | kal_wsprintf(strFSName, "%c:\\PSLog\\%04d_%02d%02d_%02d%02d_%d_version.txt", tst_dump_info.cDriveLetter, |
| 327 | rtc_time.u1Year + 2000, |
| 328 | rtc_time.u1Mon, |
| 329 | rtc_time.u1Day, |
| 330 | rtc_time.u1Hour, |
| 331 | rtc_time.u1Min, |
| 332 | rtc_time.u1Sec |
| 333 | ); |
| 334 | } |
| 335 | } |
| 336 | #else //#if !define(__SMART_PHONE_MODEM__) |
| 337 | { |
| 338 | kal_uint32 tick; |
| 339 | |
| 340 | tick = kal_get_systicks(); |
| 341 | //create/open the file |
| 342 | kal_wsprintf(strFSName, "%c:\\PSLog\\%d_version.txt", tst_dump_info.cDriveLetter,tick); |
| 343 | } |
| 344 | #endif //#if !define(__SMART_PHONE_MODEM__) |
| 345 | |
| 346 | fHandle = FS_Open(strFSName, FS_CREATE_ALWAYS); //overwrite it if if has existed |
| 347 | |
| 348 | if (fHandle < 0) |
| 349 | return; |
| 350 | |
| 351 | FS_Write(fHandle, "MTK HW Version = ", 17, &written_bytes); |
| 352 | FS_Write(fHandle, base_release_hw_ver, strlen(base_release_hw_ver), &written_bytes); |
| 353 | FS_Write(fHandle, "\n", 1, &written_bytes); |
| 354 | FS_Write(fHandle, "MTK SW Version = ", 17, &written_bytes); |
| 355 | FS_Write(fHandle, base_release_sw_ver, strlen(base_release_sw_ver), &written_bytes); |
| 356 | FS_Write(fHandle, "\n", 1, &written_bytes); |
| 357 | FS_Close(fHandle); |
| 358 | } |
| 359 | |
| 360 | //Load the filter settings from SD:\\PSLog\\catcher_filter.bin |
| 361 | __tstfileFunc int tst_file_load_Catcher_filter_from_files(void) |
| 362 | { |
| 363 | FS_HANDLE fHandle; |
| 364 | WCHAR strFSName[36];//i.e. X:\PSLog\00000.dmp |
| 365 | kal_uint32 read_data; |
| 366 | kal_uint32 read_len; |
| 367 | int res = 0; |
| 368 | |
| 369 | kal_wsprintf(strFSName, "%c:\\PSLog\\catcher_filter.bin", tst_dump_info.cDriveLetter); |
| 370 | fHandle = FS_Open(strFSName, FS_READ_ONLY); //overwrite it if if has existed |
| 371 | |
| 372 | if (fHandle < 0) |
| 373 | { |
| 374 | tst_sys_trace("[TST] Can't find catcher_filter.bin from SD."); |
| 375 | res = -1; |
| 376 | goto LOAD_FILTER_EXIT; |
| 377 | } |
| 378 | |
| 379 | //bin file content layout |
| 380 | // header (4 bytes) |
| 381 | // version (4 bytes) |
| 382 | // l1 data length(4 bytes) |
| 383 | // l1 data ( (l1_n+3)/4*4 bytes ) |
| 384 | // ps module length (4 bytes) |
| 385 | // ps module data ( ps_m_n bytes ) |
| 386 | // ps trace length (4 bytes) |
| 387 | // ps trace data ( ps_t_n bytes ) |
| 388 | // ps sap length (4 bytes) |
| 389 | // ps sap data ( ps_s_n bytes ) |
| 390 | |
| 391 | //read header |
| 392 | res = FS_Read(fHandle, &read_data, 4, &read_len); |
| 393 | if (read_data != BIN_FILE_HEADER) |
| 394 | { |
| 395 | res = -2; |
| 396 | goto LOAD_FILTER_EXIT; |
| 397 | } |
| 398 | |
| 399 | //read version |
| 400 | res = FS_Read(fHandle, &read_data, 4, &read_len); |
| 401 | if (read_data == 0x00000001) |
| 402 | { |
| 403 | kal_uint32 i; |
| 404 | unsigned char* data_ptr; |
| 405 | |
| 406 | for (i=0;i<4;++i) |
| 407 | { |
| 408 | //read length |
| 409 | res = FS_Read(fHandle, &read_data, 4, &read_len); |
| 410 | data_ptr = (unsigned char*)get_ctrl_buffer(read_data); |
| 411 | |
| 412 | //read data |
| 413 | res = FS_Read(fHandle, data_ptr, read_data, &read_len); |
| 414 | |
| 415 | switch (i) |
| 416 | { |
| 417 | case 0: //l1 |
| 418 | if(if_buffer_all_zero( data_ptr, read_data)) |
| 419 | { |
| 420 | tst_l1trace_flag = KAL_FALSE; |
| 421 | } |
| 422 | else |
| 423 | { |
| 424 | tst_l1trace_flag = KAL_TRUE; |
| 425 | } |
| 426 | trc_setfilter(data_ptr, read_data); |
| 427 | break; |
| 428 | case 1: //tst module |
| 429 | memcpy(tst_module_filter_g, data_ptr, read_data); |
| 430 | break; |
| 431 | case 2: //tst trace |
| 432 | memcpy(tst_trace_filter_g, data_ptr, read_data); |
| 433 | break; |
| 434 | case 3: //tst sap |
| 435 | memcpy(tst_sap_filter_g, data_ptr, read_data); |
| 436 | break; |
| 437 | default: |
| 438 | break; |
| 439 | } |
| 440 | |
| 441 | free_ctrl_buffer(data_ptr); |
| 442 | } //for (i=0;i<4;++i) |
| 443 | |
| 444 | res = 0; |
| 445 | } |
| 446 | else |
| 447 | { |
| 448 | FS_Close(fHandle); |
| 449 | res = -3; |
| 450 | goto LOAD_FILTER_EXIT; |
| 451 | } |
| 452 | |
| 453 | LOAD_FILTER_EXIT: |
| 454 | FS_Close(fHandle); |
| 455 | return res; |
| 456 | } |
| 457 | |
| 458 | __tstfileFunc void tst_file_set_log2SD_option(void) |
| 459 | { |
| 460 | // decide the tst output mode |
| 461 | if ( (TST_OUTPUT_MODE == 0) || (tst_ft_mode == KAL_TRUE)) //UART only |
| 462 | { |
| 463 | tst_dump_info.tst_write2_sd_option = TST_Write2File_None; |
| 464 | } |
| 465 | else if (TST_OUTPUT_MODE == 1) //FILE only |
| 466 | { |
| 467 | tst_dump_info.tst_write2_sd_option = TST_Write2File_Only; |
| 468 | } |
| 469 | else //Both UART and File |
| 470 | { |
| 471 | tst_dump_info.tst_write2_sd_option = TST_Write2File_Both; |
| 472 | } |
| 473 | |
| 474 | |
| 475 | if (tst_dump_info.tst_write2_sd_option != TST_Write2File_None) |
| 476 | { |
| 477 | //tst_open_file_to_write(); |
| 478 | tst_file_open_file_to_write(); |
| 479 | tst_is_PsTrc_open = KAL_TRUE; |
| 480 | tst_dump_info.bAlreadyAssertDump = KAL_FALSE; |
| 481 | |
| 482 | //check the pre-defined filter files |
| 483 | if (tst_file_load_Catcher_filter_from_files() != 0) |
| 484 | { |
| 485 | //Use the default filters if no filters are set |
| 486 | if (bLoadMiniLogFilter == KAL_TRUE || tst_check_filter_enabled() == KAL_FALSE) |
| 487 | { |
| 488 | tst_sys_trace("[TST] Use the pre-defined filters for logging"); |
| 489 | tst_file_update_predefined_filters(); |
| 490 | } |
| 491 | else |
| 492 | { |
| 493 | tst_sys_trace("[TST] Use the pre-defined filters from NVRAM for logging"); |
| 494 | } |
| 495 | } |
| 496 | else |
| 497 | { |
| 498 | tst_sys_trace("[TST] Use the pre-defined filters from SD for logging"); |
| 499 | } |
| 500 | if (if_buffer_all_zero(tst_module_filter_g, TST_MODULE_FILTER_LEN)) |
| 501 | tst_pstrace_flag = KAL_FALSE; |
| 502 | else |
| 503 | tst_pstrace_flag = KAL_TRUE; |
| 504 | |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | __tstfileFunc void tst_file_sp_check_sd_ready(void) |
| 509 | { |
| 510 | #ifdef __SMART_PHONE_MODEM__ |
| 511 | if (tst_err_log_to_file == NO_CARD) |
| 512 | { |
| 513 | kal_uint32 cur_time; |
| 514 | extern kal_uint32 tst_check_sd_avail_tick; |
| 515 | |
| 516 | cur_time = kal_get_systicks(); |
| 517 | |
| 518 | //check it every two second |
| 519 | if (kal_ticks_to_secs(cur_time-tst_check_sd_avail_tick) > 2) |
| 520 | { |
| 521 | //tst_set_log2SD_option(); |
| 522 | tst_check_sd_avail_tick = cur_time; |
| 523 | } |
| 524 | } |
| 525 | #endif //#ifdef __SMART_PHONE_MODEM__ |
| 526 | } |
| 527 | |
| 528 | //Return |
| 529 | //0: nothing happen, |
| 530 | //1: to start only log to file, |
| 531 | //2: to stop only log to file |
| 532 | __tstfileFunc kal_uint32 tst_file_check_if_output2uart(void) |
| 533 | { |
| 534 | kal_uint32 cWriteToFileInd=0; |
| 535 | |
| 536 | if (TST_OUTPUT_MODE == 2) //output to both UART and File |
| 537 | { |
| 538 | kal_uint32 ratio; |
| 539 | cWriteToFileInd = 0; |
| 540 | ratio = tst_get_ring_buffer_usage() * 100 / TST_RING_BUFFER_SIZE; |
| 541 | |
| 542 | if (tst_dump_info.tst_write2_sd_option == TST_Write2File_Both) |
| 543 | { |
| 544 | if (ratio > 70 ) // > 70% |
| 545 | { |
| 546 | tst_dump_info.tst_write2_sd_option = TST_Write2File_Only; |
| 547 | |
| 548 | cWriteToFileInd = 1; //1: to start logging to file, |
| 549 | |
| 550 | //reset the counter |
| 551 | tst_dump_info.nOmitPacketCount = 1; //this will be reset at tst_indicate_write_to_file_status() |
| 552 | } |
| 553 | } |
| 554 | else |
| 555 | { |
| 556 | if (ratio < 10 ) // <10% |
| 557 | { |
| 558 | tst_dump_info.tst_write2_sd_option = TST_Write2File_Both; |
| 559 | cWriteToFileInd = 2; |
| 560 | }else |
| 561 | { |
| 562 | tst_dump_info.nOmitPacketCount++; //this will be reset at tst_indicate_write_to_file_status() |
| 563 | } |
| 564 | } |
| 565 | } |
| 566 | |
| 567 | return cWriteToFileInd; |
| 568 | } |
| 569 | |
| 570 | /************************************************************************* |
| 571 | * FUNCTION |
| 572 | * tst_create |
| 573 | * |
| 574 | * DESCRIPTION |
| 575 | * This function implements tst entity's create handler. |
| 576 | * |
| 577 | * PARAMETERS |
| 578 | * |
| 579 | * RETURNS |
| 580 | * None |
| 581 | * |
| 582 | * GLOBALS AFFECTED |
| 583 | * |
| 584 | *************************************************************************/ |
| 585 | __tstfileFunc kal_bool |
| 586 | tst_file_transferrer_create(comptask_handler_struct **handle) |
| 587 | { |
| 588 | static const comptask_handler_struct tst_file_transferrer_handler_info = |
| 589 | { |
| 590 | tst_file_transferrer_main, /* task entry function */ |
| 591 | tst_file_transferrer_init, /* task initialization function */ |
| 592 | tst_file_transferrer_reset /* task reset handler */ |
| 593 | }; |
| 594 | |
| 595 | *handle = (comptask_handler_struct *)&tst_file_transferrer_handler_info; |
| 596 | return KAL_TRUE; |
| 597 | } |
| 598 | |
| 599 | |
| 600 | /************************************************************************* |
| 601 | * FUNCTION |
| 602 | * tst_file_transferrer_init |
| 603 | * |
| 604 | * DESCRIPTION |
| 605 | * This function calls component task's initialization handler |
| 606 | * |
| 607 | * PARAMETERS |
| 608 | * task_index - task's index |
| 609 | * |
| 610 | * RETURNS |
| 611 | * |
| 612 | * GLOBALS AFFECTED |
| 613 | * |
| 614 | *************************************************************************/ |
| 615 | __tstfileFunc kal_bool tst_file_transferrer_init(void) |
| 616 | { |
| 617 | tst_dump_info.cDriveLetter = 0xFF; // init it as a impossible char |
| 618 | tft_event_group = kal_create_event_group("TFTEVT"); |
| 619 | return KAL_TRUE; |
| 620 | } |
| 621 | |
| 622 | |
| 623 | /************************************************************************* |
| 624 | * FUNCTION |
| 625 | * tst_file_transferrer_reset |
| 626 | * |
| 627 | * DESCRIPTION |
| 628 | * This function implements xyz's reset handler |
| 629 | * |
| 630 | * PARAMETERS |
| 631 | * task_index - task's index |
| 632 | * |
| 633 | * RETURNS |
| 634 | * |
| 635 | * GLOBALS AFFECTED |
| 636 | * |
| 637 | *************************************************************************/ |
| 638 | __tstfileFunc kal_bool |
| 639 | tst_file_transferrer_reset(void) |
| 640 | { |
| 641 | return KAL_TRUE; |
| 642 | } |
| 643 | |
| 644 | |
| 645 | |
| 646 | /************************************************************************* |
| 647 | * FUNCTION |
| 648 | * tst_file_transferrer_main |
| 649 | * |
| 650 | * DESCRIPTION |
| 651 | * This function implements tst task's entry function |
| 652 | * |
| 653 | * PARAMETERS |
| 654 | * |
| 655 | * RETURNS |
| 656 | * None |
| 657 | * |
| 658 | * GLOBALS AFFECTED |
| 659 | * |
| 660 | *************************************************************************/ |
| 661 | |
| 662 | __tstfileFunc void tst_file_transferrer_main( task_entry_struct * task_entry_ptr ) |
| 663 | { |
| 664 | kal_uint32 event_group; |
| 665 | kal_uint32 b_write_version = 0; |
| 666 | |
| 667 | tst_file_set_log2SD_option(); |
| 668 | tst_nvram_statistic_handler(NVRAM_READ); //read statistic |
| 669 | |
| 670 | while (1){ |
| 671 | //wait for event to indicate if Transferrer needs to take the action |
| 672 | kal_retrieve_eg_events( tst_event_group, |
| 673 | TST_EVENT_OPEN_FILE | TST_EVENT_WRITE_CREATE_TO_FILE | TST_EVENT_WRITE_TO_FILE | TST_EVENT_LGA_LOG2FILE_REQ, |
| 674 | KAL_OR_CONSUME, |
| 675 | &event_group, |
| 676 | KAL_SUSPEND); |
| 677 | |
| 678 | //switch the event cases |
| 679 | if (TST_EVENT_OPEN_FILE & event_group) |
| 680 | { //open file to write |
| 681 | tst_file_open_file_to_write(); |
| 682 | |
| 683 | //indicate the file has created and opened |
| 684 | kal_set_eg_events(tst_event_group, TST_EVENT_OPEN_FILE_OK, KAL_OR); |
| 685 | } |
| 686 | else if (TST_EVENT_WRITE_CREATE_TO_FILE & event_group){ |
| 687 | //write to file and create a new file |
| 688 | tst_file_dump_create_file(); |
| 689 | |
| 690 | //indicate the actions complete |
| 691 | kal_set_eg_events(tst_event_group, TST_EVENT_WRITE_CREATE_TO_FILE_OK, KAL_OR); |
| 692 | } |
| 693 | else if (TST_EVENT_WRITE_TO_FILE & event_group){ |
| 694 | //write to file |
| 695 | tst_file_dump_file(); |
| 696 | |
| 697 | //indicate the action completes |
| 698 | kal_set_eg_events(tst_event_group, TST_EVENT_WRITE_TO_FILE_OK, KAL_OR); |
| 699 | } |
| 700 | #if defined(__LOGACC_ENABLE__) && !defined(UNIT_TEST) |
| 701 | else if (TST_EVENT_LGA_LOG2FILE_REQ & event_group) |
| 702 | { |
| 703 | tst_file_write_logacc_logs(); |
| 704 | } |
| 705 | #endif //#if defined(__LOGACC_ENABLE__) && !defined(UNIT_TEST) |
| 706 | |
| 707 | //output the version info |
| 708 | if (!b_write_version) |
| 709 | { |
| 710 | tst_file_write_verno_to_file(); |
| 711 | b_write_version = 1; |
| 712 | } |
| 713 | |
| 714 | //Clean Up |
| 715 | { |
| 716 | //Update the disk size |
| 717 | { |
| 718 | static kal_uint32 tst_file_disk_check_interval = 0; |
| 719 | if (tst_file_disk_check_interval>TST_FILE_DISK_CHECK_PERIOD) |
| 720 | { |
| 721 | tst_file_get_disk_phy_space(tst_dump_info.cDriveLetter); |
| 722 | tst_file_disk_check_interval = 0; |
| 723 | } |
| 724 | else |
| 725 | ++tst_file_disk_check_interval; |
| 726 | } |
| 727 | } |
| 728 | } //end of while(1) |
| 729 | } |
| 730 | |
| 731 | |
| 732 | /************************************************************************* |
| 733 | * FUNCTION |
| 734 | * tst_file_open_file_to_write |
| 735 | * |
| 736 | * DESCRIPTION |
| 737 | * open a file and prepare for writing |
| 738 | * |
| 739 | * PARAMETERS |
| 740 | * None |
| 741 | * |
| 742 | * |
| 743 | * RETURNS |
| 744 | * None |
| 745 | * |
| 746 | * |
| 747 | *****************************************************************************/ |
| 748 | #ifdef __SMART_PHONE_MODEM__ |
| 749 | __tstfilezidata kal_char error_msg_str[32]; //debug |
| 750 | #endif //#ifdef __SMART_PHONE_MODEM__ |
| 751 | __tstfileFunc void tst_file_open_file_to_write(void) |
| 752 | { |
| 753 | kal_char driveLetter; |
| 754 | FS_HANDLE fHandle; |
| 755 | |
| 756 | if (tst_dump_info.tst_write2_sd_option == TST_Write2File_None) return; |
| 757 | |
| 758 | tst_dump_info.bHeadOfOnePacket = KAL_FALSE; |
| 759 | tst_dump_info.bAssertForFull = KAL_FALSE; |
| 760 | tst_dump_info.nOmitPacketCount = 0; |
| 761 | |
| 762 | //if(stack_query_boot_mode() != NORMAL_BOOT) |
| 763 | #if defined(__SMART_PHONE_MODEM__) |
| 764 | if (tst_ft_mode == KAL_TRUE) |
| 765 | #else //#if defined(__SMART_PHONE_MODEM__) |
| 766 | if(kal_query_boot_mode() != NORMAL_BOOT) |
| 767 | #endif //#if defined(__SMART_PHONE_MODEM__) |
| 768 | { |
| 769 | #if defined(__SMART_PHONE_MODEM__) |
| 770 | //There is some unknow state while booting |
| 771 | sprintf(error_msg_str, "Boot mode:%d", (kal_uint32)kal_query_boot_mode()); |
| 772 | tst_sys_trace(error_msg_str); |
| 773 | #endif //#if defined(__SMART_PHONE_MODEM__) |
| 774 | |
| 775 | return; |
| 776 | } |
| 777 | |
| 778 | if (tst_dump_info.buffer == NULL || tst_dump_info.L1Buffer == NULL) |
| 779 | { |
| 780 | tst_err_log_to_file = ERR_ALLOC_MEM; |
| 781 | goto FAIL_EXIT; |
| 782 | } |
| 783 | |
| 784 | //1. check if removable dis exits |
| 785 | driveLetter = FS_GetDrive(FS_DRIVE_V_REMOVABLE, 1, 0); |
| 786 | if (driveLetter <67 || driveLetter > 72) |
| 787 | { |
| 788 | #ifdef __SMART_PHONE_MODEM__ |
| 789 | sprintf(error_msg_str, "Boot mode:%d", (kal_uint32)driveLetter); |
| 790 | tst_sys_trace(error_msg_str); |
| 791 | #endif //#ifdef __SMART_PHONE_MODEM__ |
| 792 | return; |
| 793 | } |
| 794 | tst_dump_info.cDriveLetter = driveLetter; |
| 795 | |
| 796 | {//2. query the vacancy |
| 797 | kal_bool res = tst_file_get_disk_phy_space(driveLetter); |
| 798 | if (!res){goto FAIL_EXIT;} |
| 799 | }//2. end of querying the vacancy |
| 800 | |
| 801 | //3. create the file X:\pslog\log??.dmp |
| 802 | fHandle = tst_file_create_file(); //create a new file |
| 803 | |
| 804 | if (fHandle < 0) { |
| 805 | goto FAIL_EXIT; |
| 806 | }//failed to open or create the file |
| 807 | |
| 808 | tst_dump_info.nDiskFreeSpace -= TST_MAX_LOG_SIZE_FOR_SINGLE_FILE; |
| 809 | tst_dump_info.nFileFreeSpace = TST_MAX_LOG_SIZE_FOR_SINGLE_FILE - (1<<12); //4k for buffer |
| 810 | tst_dump_info.nCommitCountDown = TST_COMMIT_BATCH; |
| 811 | tst_err_log_to_file = NO_LOG_ERROR; |
| 812 | return; |
| 813 | |
| 814 | FAIL_EXIT: |
| 815 | tst_dump_info.tst_write2_sd_option = TST_Write2File_None; |
| 816 | return; |
| 817 | } |
| 818 | |
| 819 | |
| 820 | /************************************************************************* |
| 821 | * FUNCTION |
| 822 | * tst_file_write_to_file |
| 823 | * |
| 824 | * DESCRIPTION |
| 825 | * write data to the log file |
| 826 | * |
| 827 | * PARAMETERS |
| 828 | * None |
| 829 | * |
| 830 | * |
| 831 | * RETURNS |
| 832 | * None |
| 833 | * |
| 834 | * |
| 835 | *****************************************************************************/ |
| 836 | __tstfileFunc kal_bool tst_file_write_file(kal_uint8 *buffer, kal_uint32 length) |
| 837 | { |
| 838 | kal_int32 res; |
| 839 | kal_uint32 written_bytes; |
| 840 | //write and commit |
| 841 | |
| 842 | if (length == 0) return KAL_TRUE; |
| 843 | |
| 844 | #if !defined(__SMART_PHONE_MODEM__) |
| 845 | res = FS_Extend(tst_dump_info.fHandle, length); |
| 846 | |
| 847 | if (FS_NO_ERROR != res) |
| 848 | { |
| 849 | tst_err_log_to_file = ERR_EXTEND; |
| 850 | goto FAIL_EXIT; |
| 851 | } |
| 852 | #endif //#if !defined(__SMART_PHONE_MODEM__) |
| 853 | |
| 854 | res = FS_Write(tst_dump_info.fHandle, tst_dump_info.buffer, length, &written_bytes); |
| 855 | |
| 856 | if (FS_NO_ERROR != res) |
| 857 | { |
| 858 | tst_err_log_to_file = ERR_WRITE; |
| 859 | goto FAIL_EXIT; |
| 860 | } |
| 861 | |
| 862 | tst_dump_info.nCommitCountDown--; |
| 863 | if (tst_dump_info.nCommitCountDown == 0) |
| 864 | { |
| 865 | tst_dump_info.nCommitCountDown = TST_COMMIT_BATCH; |
| 866 | |
| 867 | #if !defined(__SMART_PHONE_MODEM__) |
| 868 | // flush the FS buffer every nCommitCountDown times |
| 869 | res = FS_Commit(tst_dump_info.fHandle); |
| 870 | |
| 871 | if (FS_NO_ERROR != res) |
| 872 | { |
| 873 | tst_err_log_to_file = ERR_COMMIT; |
| 874 | goto FAIL_EXIT; |
| 875 | } |
| 876 | #endif //#if !defined(__SMART_PHONE_MODEM__) |
| 877 | } |
| 878 | |
| 879 | return KAL_TRUE; |
| 880 | |
| 881 | FAIL_EXIT: |
| 882 | tst_dump_info.tst_write2_sd_option = TST_Write2File_None; |
| 883 | return KAL_FALSE; |
| 884 | } |
| 885 | |
| 886 | /************************************************************************* |
| 887 | * FUNCTION |
| 888 | * tst_file_dump_create_file |
| 889 | * |
| 890 | * DESCRIPTION |
| 891 | * write logs to the file. After the file is full, create a new file |
| 892 | * |
| 893 | * PARAMETERS |
| 894 | * None |
| 895 | * |
| 896 | * |
| 897 | * RETURNS |
| 898 | * |
| 899 | * |
| 900 | * |
| 901 | *****************************************************************************/ |
| 902 | |
| 903 | __tstfileFunc void tst_file_dump_create_file(void) |
| 904 | { |
| 905 | FS_HANDLE fHandle; |
| 906 | kal_int32 res; |
| 907 | kal_bool bRet; |
| 908 | |
| 909 | //move logs from the buffer to the file |
| 910 | bRet = tst_file_write_file(tst_dump_info.buffer, tst_dump_info.nBufferPtr); |
| 911 | if (!bRet) goto FAIL_EXIT; |
| 912 | |
| 913 | tst_dump_info.nBufferPtr = 0; |
| 914 | |
| 915 | res = FS_Close(tst_dump_info.fHandle); |
| 916 | if (res < 0) |
| 917 | { |
| 918 | tst_err_log_to_file = ERR_CLOSE; |
| 919 | goto FAIL_EXIT; |
| 920 | } |
| 921 | |
| 922 | if (tst_dump_info.nDiskFreeSpace < TST_FILE_MIN_DISK_SIZE ) //128kBytes as minimal size |
| 923 | { |
| 924 | tst_err_log_to_file = DISK_FULL; |
| 925 | goto FAIL_EXIT; |
| 926 | } |
| 927 | tst_dump_info.fHandle = 0; |
| 928 | |
| 929 | fHandle = tst_file_create_file(); //create a new file |
| 930 | if (fHandle < 0) //failed to open or create the file |
| 931 | { |
| 932 | goto FAIL_EXIT; |
| 933 | } |
| 934 | |
| 935 | return; |
| 936 | |
| 937 | FAIL_EXIT: |
| 938 | |
| 939 | return; |
| 940 | } |
| 941 | |
| 942 | /************************************************************************* |
| 943 | * FUNCTION |
| 944 | * tst_file_dump_file |
| 945 | * |
| 946 | * DESCRIPTION |
| 947 | * write logs to the file. |
| 948 | * |
| 949 | * PARAMETERS |
| 950 | * None |
| 951 | * |
| 952 | * |
| 953 | * RETURNS |
| 954 | * |
| 955 | * |
| 956 | * |
| 957 | *****************************************************************************/ |
| 958 | |
| 959 | __tstfileFunc void tst_file_dump_file(void) |
| 960 | { |
| 961 | kal_bool bRet = tst_file_write_file(tst_dump_info.buffer, TST_FSWRITE_BUFFER_SIZE); |
| 962 | |
| 963 | if (!bRet) |
| 964 | { |
| 965 | tst_err_log_to_file = ERR_WRITE; |
| 966 | } |
| 967 | |
| 968 | } |
| 969 | |
| 970 | /************************************************************************* |
| 971 | * FUNCTION |
| 972 | * tst_file_create_file |
| 973 | * |
| 974 | * DESCRIPTION |
| 975 | * create and open the new file according to the current time |
| 976 | * |
| 977 | * PARAMETERS |
| 978 | * None |
| 979 | * |
| 980 | * |
| 981 | * RETURNS |
| 982 | * FS_HANDLE: the file handle of the created file |
| 983 | * |
| 984 | * |
| 985 | *****************************************************************************/ |
| 986 | |
| 987 | __tstfileFunc FS_HANDLE tst_file_create_file(void) |
| 988 | { |
| 989 | WCHAR strFSName[36];//i.e. X:\PSLog\00000.dmp |
| 990 | FS_HANDLE fHandle; |
| 991 | |
| 992 | //create/open the folder "X:\PSLog\" |
| 993 | kal_wsprintf(strFSName, "%c:\\PSLog\\", tst_dump_info.cDriveLetter); |
| 994 | FS_CreateDir(strFSName); |
| 995 | |
| 996 | #if !defined(__SMART_PHONE_MODEM__) |
| 997 | { |
| 998 | RTC_CTRL_GET_TIME_T rtc_time; |
| 999 | DCL_HANDLE rtc_handler; |
| 1000 | |
| 1001 | rtc_handler = DclRTC_Open(DCL_RTC,FLAGS_NONE); |
| 1002 | DclRTC_Control(rtc_handler, RTC_CMD_GET_TIME, (DCL_CTRL_DATA_T *)&rtc_time); // New API with CMD & DATA |
| 1003 | |
| 1004 | //create/open the file |
| 1005 | kal_wsprintf(strFSName, "%c:\\PSLog\\%04d_%02d%02d_%02d%02d_%d.dmp", tst_dump_info.cDriveLetter, |
| 1006 | rtc_time.u1Year + 2000, |
| 1007 | rtc_time.u1Mon, |
| 1008 | rtc_time.u1Day, |
| 1009 | rtc_time.u1Hour, |
| 1010 | rtc_time.u1Min, |
| 1011 | rtc_time.u1Sec |
| 1012 | ); |
| 1013 | kal_wsprintf(tst_dump_info.strAssertFolderName, |
| 1014 | "%c:\\PSLog\\%04d_%02d%02d_%02d%02d_%d\\", tst_dump_info.cDriveLetter, |
| 1015 | rtc_time.u1Year + 2000, |
| 1016 | rtc_time.u1Mon, |
| 1017 | rtc_time.u1Day, |
| 1018 | rtc_time.u1Hour, |
| 1019 | rtc_time.u1Min, |
| 1020 | rtc_time.u1Sec |
| 1021 | ); |
| 1022 | } |
| 1023 | #else //#if !define(__SMART_PHONE_MODEM__) |
| 1024 | { |
| 1025 | kal_uint32 tick; |
| 1026 | |
| 1027 | tick = kal_get_systicks(); |
| 1028 | //create/open the file |
| 1029 | kal_wsprintf(strFSName, "%c:\\PSLog\\%d.dmp", tst_dump_info.cDriveLetter,tick); |
| 1030 | kal_wsprintf(tst_dump_info.strAssertFolderName, |
| 1031 | "%c:\\PSLog\\%d.files\\", tst_dump_info.cDriveLetter,tick); |
| 1032 | } |
| 1033 | #endif //#if !define(__SMART_PHONE_MODEM__) |
| 1034 | |
| 1035 | fHandle = FS_Open(strFSName, FS_CREATE_ALWAYS); //overwrite it if if has existed |
| 1036 | |
| 1037 | if (fHandle < 0) |
| 1038 | { //error openning the file |
| 1039 | goto FAIL_EXIT; |
| 1040 | } |
| 1041 | { |
| 1042 | //write the header |
| 1043 | kal_uint32 version = 0x02; |
| 1044 | kal_mem_cpy(tst_dump_info.buffer, (kal_uint8*)&version, 4); |
| 1045 | tst_dump_info.nBufferPtr = 4; |
| 1046 | |
| 1047 | tst_dump_info.fHandle = fHandle; |
| 1048 | } |
| 1049 | return fHandle; |
| 1050 | |
| 1051 | FAIL_EXIT: |
| 1052 | tst_err_log_to_file = ERR_OPEN; |
| 1053 | tst_dump_info.tst_write2_sd_option = TST_Write2File_None; |
| 1054 | return -1; |
| 1055 | } |
| 1056 | |
| 1057 | //0: Not ready, 1:ok |
| 1058 | __tstfileFunc kal_uint32 tst_file_wait_data_card_for_ready(void) |
| 1059 | { |
| 1060 | |
| 1061 | return 1; |
| 1062 | } |
| 1063 | |
| 1064 | |
| 1065 | __tstfileFunc kal_bool tst_file_get_disk_phy_space(kal_char driveLetter) |
| 1066 | { |
| 1067 | FS_DiskInfo diskInfo; |
| 1068 | WCHAR strFSName[8]; |
| 1069 | kal_uint32 totalFreeSpace; |
| 1070 | |
| 1071 | kal_wsprintf(strFSName, "%c:\\", driveLetter); |
| 1072 | //FAT document: only the first time calling for a drive is time-consuming. |
| 1073 | if (0 > FS_GetDiskInfo(strFSName, &diskInfo, FS_DI_BASIC_INFO|FS_DI_FREE_SPACE)) |
| 1074 | {//Failed for this drive, take it not exist |
| 1075 | tst_err_log_to_file = NO_CARD; |
| 1076 | return KAL_FALSE; |
| 1077 | } |
| 1078 | |
| 1079 | //calculate for the free space |
| 1080 | /*total disk size could be bigger than 2G (kal_int32) or 4G (kal_uint32)*/ |
| 1081 | totalFreeSpace = (diskInfo.BytesPerSector * |
| 1082 | diskInfo.SectorsPerCluster / 1024) * |
| 1083 | diskInfo.FreeClusters; //in unit of KBytes, to prevent it exceed kal_int32 |
| 1084 | |
| 1085 | if (totalFreeSpace > (1<<20)) |
| 1086 | {//if the free size > 1GBytes, just bookkeep it as 1G |
| 1087 | totalFreeSpace = (1<<30); |
| 1088 | } |
| 1089 | else |
| 1090 | { |
| 1091 | totalFreeSpace *= 1024; |
| 1092 | } |
| 1093 | |
| 1094 | if (totalFreeSpace < TST_MAX_LOG_SIZE_FOR_SINGLE_FILE) |
| 1095 | { |
| 1096 | tst_err_log_to_file = DISK_FULL; |
| 1097 | return KAL_FALSE; |
| 1098 | } |
| 1099 | |
| 1100 | tst_dump_info.nDiskFreeSpace = totalFreeSpace; |
| 1101 | |
| 1102 | return KAL_TRUE; |
| 1103 | } |
| 1104 | |
| 1105 | |
| 1106 | #else //__TST_WRITE_TO_FILE__ |
| 1107 | |
| 1108 | //#pragma arm section code= "PRIMARY_ROCODE" rwdata = "PRIMARY_RW" , rodata = "PRIMARY_RODATA" , zidata = "PRIMARY_ZI" |
| 1109 | __tstfileFunc kal_bool tst_file_transferrer_create(comptask_handler_struct **handle) |
| 1110 | { |
| 1111 | return KAL_FALSE; |
| 1112 | } |
| 1113 | |
| 1114 | #endif //__TST_WRITE_TO_FILE__ |
| 1115 | |