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 | * system_profiler.h |
| 41 | * |
| 42 | * Project: |
| 43 | * -------- |
| 44 | * |
| 45 | * |
| 46 | * Description: |
| 47 | * ------------ |
| 48 | * |
| 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 | * |
| 62 | * removed! |
| 63 | * removed! |
| 64 | * removed! |
| 65 | * |
| 66 | * removed! |
| 67 | * removed! |
| 68 | * removed! |
| 69 | * |
| 70 | * removed! |
| 71 | * removed! |
| 72 | * removed! |
| 73 | * |
| 74 | * removed! |
| 75 | * removed! |
| 76 | * removed! |
| 77 | * |
| 78 | * removed! |
| 79 | * removed! |
| 80 | * removed! |
| 81 | * |
| 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 | * removed! |
| 110 | * |
| 111 | * removed! |
| 112 | * removed! |
| 113 | * removed! |
| 114 | * |
| 115 | * removed! |
| 116 | * removed! |
| 117 | * removed! |
| 118 | * |
| 119 | * removed! |
| 120 | * removed! |
| 121 | * removed! |
| 122 | * |
| 123 | * removed! |
| 124 | * removed! |
| 125 | * removed! |
| 126 | * |
| 127 | * removed! |
| 128 | * removed! |
| 129 | * removed! |
| 130 | * |
| 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 | * |
| 149 | * removed! |
| 150 | * removed! |
| 151 | * removed! |
| 152 | * |
| 153 | * removed! |
| 154 | * removed! |
| 155 | * |
| 156 | * removed! |
| 157 | * removed! |
| 158 | * |
| 159 | * removed! |
| 160 | * removed! |
| 161 | * removed! |
| 162 | * |
| 163 | * removed! |
| 164 | * removed! |
| 165 | * |
| 166 | * removed! |
| 167 | * removed! |
| 168 | * |
| 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 | * removed! |
| 189 | * removed! |
| 190 | * removed! |
| 191 | * |
| 192 | * removed! |
| 193 | * removed! |
| 194 | * removed! |
| 195 | * |
| 196 | *------------------------------------------------------------------------------ |
| 197 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 198 | *============================================================================ |
| 199 | ****************************************************************************/ |
| 200 | |
| 201 | #ifndef SYSPROFILER_PUBLIC_H |
| 202 | #define SYSPROFILER_PUBLIC_H |
| 203 | |
| 204 | #include "swla_public.h" |
| 205 | #include "mcu_pmu_montr_public.h" |
| 206 | #include "kal_public_defs.h" |
| 207 | #include "cpu_info.h" |
| 208 | #include "ex_public.h" |
| 209 | |
| 210 | |
| 211 | typedef enum { |
| 212 | SYSPRO_SW_SWLA_MODE = 0, |
| 213 | SYSPRO_SW_SWTR_MODE, |
| 214 | SYSPRO_MODE_END |
| 215 | }SYSPRO_MODE; |
| 216 | |
| 217 | typedef enum |
| 218 | { |
| 219 | SYSPRO_CORE0 = 0, |
| 220 | SYSPRO_CORE1, |
| 221 | #if defined(__MD95__) |
| 222 | #ifndef __MD95_IS_2CORES__ |
| 223 | SYSPRO_CORE2, |
| 224 | #endif // ifndef(__MD95_IS_2CORES__) |
| 225 | |
| 226 | #elif defined(__MD97__) || defined(__MD97P__) |
| 227 | SYSPRO_CORE2, |
| 228 | SYSPRO_CORE3, |
| 229 | #endif |
| 230 | SYSPRO_NUM |
| 231 | }SYSPRO_MCU_CORE; |
| 232 | |
| 233 | |
| 234 | #if defined(__MTK_TARGET__) && !defined(__MAUI_BASIC__) && !defined(__ESL_HRT__) |
| 235 | |
| 236 | #if defined(__MD95__) |
| 237 | |
| 238 | #define __SYSTEM_PROFILER_ON__ |
| 239 | #define __SWLA_SNAPSHOT_FEATURE__ |
| 240 | #define __SWLA_SNAPSHOT_FEATURE_DEBUG__ |
| 241 | |
| 242 | #elif defined(__MD97__) || defined(__MD97P__) |
| 243 | |
| 244 | #define __SYSTEM_PROFILER_ON__ |
| 245 | #define __SYSPRO_DEFAULT_MIN_BUFF_SIZE__ |
| 246 | //#define __SWLA_SNAPSHOT_FEATURE__ |
| 247 | //#define __SWLA_SNAPSHOT_FEATURE_DEBUG__ |
| 248 | |
| 249 | #else |
| 250 | #error "Unsupported chip" |
| 251 | #endif |
| 252 | #endif |
| 253 | |
| 254 | /* DHL will call PMU API. So APIs should be exported to be linked.*/ |
| 255 | #if defined(__MTK_TARGET__) |
| 256 | #define __SWLA_MIPS_PMU_EXIST__ |
| 257 | #endif |
| 258 | |
| 259 | #define MAX_SYSPRO_NUMBER (SYS_MCU_NUM_CORE) |
| 260 | #define MAX_SWLA_NUMBER (SYS_MCU_NUM_CORE) |
| 261 | #define MAX_SWTR_NUMBER (SYS_MCU_NUM_CORE) |
| 262 | #define MAX_SW_SWTR_NUMBER (SYS_MCU_NUM_CORE) |
| 263 | #define BASIC_INFO_SIZE (8) |
| 264 | #define SYSPROFILER_INITCORE (0) |
| 265 | #define SYSPRO_HW_SWTR_DEFAULT_SAMPLE_RATE (4096) |
| 266 | |
| 267 | #if defined(__MD95__) |
| 268 | #define MAX_TC_NUMBER (4) |
| 269 | #elif defined(__MD97__) || defined(__MD97P__) |
| 270 | #define MAX_TC_NUMBER (6) |
| 271 | #else |
| 272 | #error "Unsupported chip" |
| 273 | #endif |
| 274 | |
| 275 | #if defined(__MD95__) |
| 276 | #define SYS_PRO_HEADER_MINOR_VER (3) |
| 277 | #define SYS_PRO_HEADER_MAJOR_VER (1) |
| 278 | #elif defined(__MD97__) || defined(__MD97P__) |
| 279 | #define SYS_PRO_HEADER_MINOR_VER (0) |
| 280 | #define SYS_PRO_HEADER_MAJOR_VER (4) |
| 281 | #else |
| 282 | #error "Unsupported chip" |
| 283 | #endif |
| 284 | #define SYS_PRO_HEADER_PADDING (0) |
| 285 | #define SYS_PRO_HEADER_MAGIC (0xEE) |
| 286 | |
| 287 | /* |
| 288 | * IF extra add-on parts are required, please modify this following number |
| 289 | */ |
| 290 | // 14 is the number of ASM add-on (6 built-in and 8 extra data) --> but current is no ASM, can change |
| 291 | #define MAX_ADDON_INFO_NUM 14 |
| 292 | #define MAX_PLATFORM_NAME_LEN 16 |
| 293 | #define MAX_FLAVOR_NAME_LEN 32 |
| 294 | #define MAX_SW_LABEL_LEN 64 |
| 295 | #define HEADER_SCRATCHPAD_LEN 128 |
| 296 | |
| 297 | typedef struct SysProfiler_SummayHeader_T |
| 298 | { |
| 299 | // version Info: since ver 1.03 |
| 300 | kal_uint8 minor_ver; |
| 301 | kal_uint8 major_ver; |
| 302 | kal_uint8 padding; |
| 303 | kal_uint8 magic; // should always be 0xEE |
| 304 | |
| 305 | #if defined(__MD95__) // version Info: since ver1.03(For Gen93/95) |
| 306 | kal_uint32 header_sz; |
| 307 | kal_uint32 main_desc_sz; |
| 308 | #elif defined(__MD97__) || defined(__MD97P__) // version Info: since ver4.0 (For Gen97) |
| 309 | kal_uint8 vpe0_ic_info; |
| 310 | kal_uint8 vpe1_ic_info; |
| 311 | kal_uint8 vpe2_ic_info; |
| 312 | kal_uint8 vpe3_ic_info; |
| 313 | kal_uint32 platform_info; |
| 314 | #else |
| 315 | #error "Unsupported chip" |
| 316 | #endif |
| 317 | kal_uint32 addon_desc_sz; |
| 318 | } SysProfiler_SummaryHeader; |
| 319 | |
| 320 | typedef struct SysProfiler_MainDescHeader_T |
| 321 | { |
| 322 | kal_char mode_name[4]; |
| 323 | kal_uint32 core_id; |
| 324 | kal_uint32 mdsys_timebase; |
| 325 | kal_uint32 modemsys_timebase_low; |
| 326 | kal_uint32 modemsys_timebase_high; |
| 327 | kal_uint32 log_sz; |
| 328 | kal_uint32 raw_begin_pos; |
| 329 | #if defined(__MD97__) || defined(__MD97P__) |
| 330 | kal_uint32 cpu_clock_mhz; |
| 331 | #else |
| 332 | kal_uint32 padding; |
| 333 | #endif |
| 334 | kal_char platformName[MAX_PLATFORM_NAME_LEN]; |
| 335 | kal_char flavorName[MAX_FLAVOR_NAME_LEN]; |
| 336 | kal_char SWLabel[MAX_SW_LABEL_LEN]; |
| 337 | } SysProfiler_MainDescHeader; |
| 338 | |
| 339 | typedef struct SysProfiler_AddonDescHeader_T |
| 340 | { |
| 341 | kal_uint32 log_sz; |
| 342 | kal_char ext_name[12]; |
| 343 | } SysProfiler_AddonDescHeader; |
| 344 | |
| 345 | typedef struct SysProfiler_LoggingHeader_T |
| 346 | { |
| 347 | SysProfiler_SummaryHeader summary; |
| 348 | SysProfiler_MainDescHeader main_desc; |
| 349 | SysProfiler_AddonDescHeader addon_info[MAX_ADDON_INFO_NUM]; |
| 350 | kal_char header_padding[HEADER_SCRATCHPAD_LEN]; /* SPV scratchpad, content will be output to header region of sla.bins */ |
| 351 | } SysProfiler_LoggingHeader; |
| 352 | |
| 353 | typedef struct SysProfiler_DumpMemoryInfo_T |
| 354 | { |
| 355 | kal_uint32 base_addr1; |
| 356 | kal_uint32 length1; |
| 357 | kal_uint32 base_addr2; |
| 358 | kal_uint32 length2; |
| 359 | } SysProfiler_DumpMemInfo; |
| 360 | |
| 361 | #if defined(__MD95__) |
| 362 | #if defined(__SWLA_MIPS_PMU_EXIST__) |
| 363 | typedef struct SysProfiler_PMCSettingParameter_T |
| 364 | { |
| 365 | SYSPRO_MODE mode; |
| 366 | SYSPRO_MCU_CORE coreID; |
| 367 | kal_uint8 TCID; |
| 368 | IAPMU_MONITOR_EVENT_TYPE PMC0Event; |
| 369 | IAPMU_MONITOR_TARGET_TYPE PMC0Type; |
| 370 | IAPMU_MONITOR_EVENT_TYPE PMC1Event; |
| 371 | IAPMU_MONITOR_TARGET_TYPE PMC1Type; |
| 372 | } SysProfiler_PMCSettingParameter; |
| 373 | |
| 374 | typedef struct SysProfiler_DHLPMCParameter_T |
| 375 | { |
| 376 | SysProfiler_PMCSettingParameter parameter[MAX_SWLA_NUMBER * MAX_TC_NUMBER]; |
| 377 | } SysProfiler_DHLPMCParameter; |
| 378 | |
| 379 | typedef struct SysProfiler_PMCSettingLocalParameterForILM_T |
| 380 | { |
| 381 | LOCAL_PARA_HDR |
| 382 | SysProfiler_PMCSettingParameter parameter[MAX_TC_NUMBER]; |
| 383 | } SysProfiler_PMCSettingLocalParameterForILM; |
| 384 | |
| 385 | #endif |
| 386 | #elif defined(__MD97__) || defined(__MD97P__) |
| 387 | |
| 388 | #define SYSPROFILER_CM2_NUM 4 |
| 389 | typedef struct CM2ConfigParameter_T |
| 390 | { |
| 391 | kal_uint32 Event; |
| 392 | kal_uint32 Qualifier; |
| 393 | kal_uint32 BegAddr; |
| 394 | kal_uint32 EndAddr; |
| 395 | kal_uint32 VPEMask; |
| 396 | }CM2ConfigParameter; |
| 397 | |
| 398 | #define SYSPROFILER_PMC_NUM 4 |
| 399 | typedef struct PMCConfigParameter_T |
| 400 | { |
| 401 | kal_uint32 Event; |
| 402 | kal_uint32 Type; |
| 403 | }PMCConfigParameter; |
| 404 | |
| 405 | typedef struct SysProfiler_CM2SettingParameter_T |
| 406 | { |
| 407 | SYSPRO_MODE mode; |
| 408 | SYSPRO_MCU_CORE coreID; |
| 409 | CM2ConfigParameter CM2_parameter[SYSPROFILER_CM2_NUM]; |
| 410 | }SysProfiler_CM2SettingParameter; |
| 411 | |
| 412 | typedef struct SysProfiler_PMCSettingParameter_T |
| 413 | { |
| 414 | SYSPRO_MODE mode; |
| 415 | SYSPRO_MCU_CORE coreID; |
| 416 | PMCConfigParameter PMC_parameter[SYSPROFILER_PMC_NUM]; |
| 417 | } SysProfiler_PMCSettingParameter; |
| 418 | |
| 419 | typedef struct SysProfiler_DHLPMCParameter_T |
| 420 | { |
| 421 | SysProfiler_PMCSettingParameter parameter[MAX_SWLA_NUMBER * MAX_TC_NUMBER]; |
| 422 | } SysProfiler_DHLPMCParameter; |
| 423 | |
| 424 | typedef struct SysProfiler_PMCSettingLocalParameterForILM_T |
| 425 | { |
| 426 | LOCAL_PARA_HDR |
| 427 | SysProfiler_PMCSettingParameter parameter; |
| 428 | } SysProfiler_PMCSettingLocalParameterForILM; |
| 429 | |
| 430 | #else |
| 431 | #error "Unsupported chip" |
| 432 | #endif |
| 433 | |
| 434 | |
| 435 | typedef enum |
| 436 | { |
| 437 | SYSPRO_SW_ADDON, |
| 438 | SYSPRO_ADDON_TYPE_END, |
| 439 | } SYSPROFILER_ADDON_TYPE; |
| 440 | |
| 441 | typedef enum |
| 442 | { |
| 443 | SYSPRO_SWLA_ADDON, |
| 444 | SYSPRO_SWTR_ADDON, |
| 445 | SYSPRO_ADDON_PROFILER_TYPE_END, |
| 446 | } SYSPROFILER_ADDON_PROFILER_TYPE; |
| 447 | |
| 448 | typedef enum{ |
| 449 | SYSPRO_ERROR_CODE_SUCCESS = 0, |
| 450 | SYSPRO_ERROR_CODE_START = 0x10, |
| 451 | SYSPRO_ERROR_CODE_BUFFER_TOO_SMALL, |
| 452 | SYSPRO_ERROR_CODE_BUFFER_TOO_LARGE, |
| 453 | SYSPRO_ERROR_CODE_WRONG_MODE, |
| 454 | SYSPRO_ERROR_CODE_WAIT_IDLE_FAIL, |
| 455 | SYSPRO_ERROR_CODE_OVER_ADDON_INDEX, |
| 456 | SYSPRO_ERROR_CODE_OVER_ADDON_SIZE, |
| 457 | SYSPRO_ERROR_CODE_INVALID_SAMPLE_RATE, |
| 458 | SYSPRO_ERROR_CODE_SW_START = 0x20, |
| 459 | SYSPRO_ERROR_CODE_SWLA_ALREADY_ENABLE, |
| 460 | SYSPRO_ERROR_CODE_SWLA_RAM_BUFFER_IN_USED, |
| 461 | SYSPRO_ERROR_CODE_SWTR_ALREADY_ENABLE, |
| 462 | SYSPRO_ERROR_CODE_SWTR_RAM_BUFFER_IN_USED, |
| 463 | SYSPRO_ERROR_CODE_OUT_OF_SUPPORT_COREID, |
| 464 | SYSPRO_ERROR_CODE_INVALID_MODE, |
| 465 | SYSPRO_ERROR_CODE_BUFFER_ADDRESS_SIZE, |
| 466 | SYSPRO_ERROR_CODE_PROFILER_NOT_ENABLE, |
| 467 | SYSPRO_ERROR_CODE_INVALID_PROFILER_ADDON, |
| 468 | SYSPRO_ERROR_CODE_INVALID_ADDON_OPTION, |
| 469 | SYSPRO_ERROR_CODE_NO_ADDON_AVAILABLE, |
| 470 | SYSPRO_ERROR_CODE_NO_EXTRA_ADDON_AVAILABLE, |
| 471 | SYSPRO_ERROR_CODE_DUPLICATED_ADDON, |
| 472 | SYSPRO_ERROR_CODE_NULL_FUNCTION_PTR, |
| 473 | SYSPRO_ERROR_CODE_PMC_PARAMETER_INVALID, |
| 474 | SYSPRO_ERROR_CODE_DEPRECATED_FUNCTION, |
| 475 | SYSPRO_ERROR_CODE_NO_AVAILABLE_SNAPSHOT_BUFFER, |
| 476 | SYSPRO_ERROR_CODE_SNAPSHOT_AGAIN_IN_SHORT_TIME, |
| 477 | SYSPRO_ERROR_CODE_NO_SUPPORT_DUMP_LEVEL, |
| 478 | SYSPRO_ERROR_CODE_INIT_FAIL, |
| 479 | |
| 480 | |
| 481 | SYSPRO_ERROR_CODE_CORE_0 = 0x0000, |
| 482 | SYSPRO_ERROR_CODE_CORE_1 = 0x0100, |
| 483 | SYSPRO_ERROR_CODE_CORE_2 = 0x0200, |
| 484 | SYSPRO_ERROR_CODE_CORE_3 = 0x0300, |
| 485 | //SYSPRO_ERROR_CODE_MCU_ASM = 0x0400, |
| 486 | //SYSPRO_ERROR_CODE_INFRA_ASM = 0x0500, |
| 487 | |
| 488 | SYSPRO_ERROR_CODE_END, |
| 489 | } SYSPROFILER_ERROR_CODE; |
| 490 | |
| 491 | |
| 492 | #if defined(__SWLA_SNAPSHOT_FEATURE__) |
| 493 | |
| 494 | typedef enum |
| 495 | { |
| 496 | SYSPRO_SNAPSHOT_CORE_IDLE, |
| 497 | SYSPRO_SNAPSHOT_CORE_START, |
| 498 | SYSPRO_SNAPSHOT_CORE_DONE |
| 499 | } SYSPROFILER_SNAPSHOT_CORE_STATUS_TYPE ; |
| 500 | |
| 501 | |
| 502 | typedef enum |
| 503 | { |
| 504 | SYSPRO_SNAPSHOT_BUFF_INDEX_0, |
| 505 | /* |
| 506 | SYSPRO_SNAPSHOT_BUFF_INDEX_1, |
| 507 | SYSPRO_SNAPSHOT_BUFF_INDEX_2, |
| 508 | SYSPRO_SNAPSHOT_BUFF_INDEX_3, |
| 509 | SYSPRO_SNAPSHOT_BUFF_INDEX_4, |
| 510 | SYSPRO_SNAPSHOT_BUFF_INDEX_5, |
| 511 | SYSPRO_SNAPSHOT_BUFF_INDEX_19=19, |
| 512 | */ |
| 513 | SYSPRO_SNAPSHOT_BUFF_NUM, |
| 514 | SYSPRO_SNAPSHOT_BUFF_COMMON, /* Reserved for common case */ |
| 515 | SYSPRO_SNAPSHOT_BUFF_HRT_FAIL, /* For Hard-Read-Time fail case */ |
| 516 | SYSPRO_SNAPSHOT_BUFF_END = 0xFFFFFFFF /* Force this enum 32bit */ |
| 517 | } SYSPROFILER_SNAPSHOT_BUFF_ID_ENUM ; |
| 518 | |
| 519 | /* if this structure change, should also modify tool */ |
| 520 | typedef struct SysProifler_Snapshot_Core_t |
| 521 | { |
| 522 | kal_uint32 seg1_src_addr; |
| 523 | kal_uint32 seg1_dst_addr; |
| 524 | kal_uint32 seg1_size; |
| 525 | kal_uint32 seg1_gdma_result; |
| 526 | kal_uint32 seg2_src_addr; |
| 527 | kal_uint32 seg2_dst_addr; |
| 528 | kal_uint32 seg2_size; |
| 529 | kal_uint32 seg2_gdma_result; |
| 530 | kal_uint32 lisr_used; |
| 531 | kal_uint32 lisr_in_time; |
| 532 | kal_uint32 lisr_out_time; |
| 533 | SysProfiler_LoggingHeader header; |
| 534 | SYSPROFILER_ERROR_CODE err_code; |
| 535 | SYSPROFILER_SNAPSHOT_CORE_STATUS_TYPE status; |
| 536 | SYSPRO_MODE mode; |
| 537 | |
| 538 | } SysProfiler_Snapshot_Core; |
| 539 | |
| 540 | /* if this structure change, should also modify tool */ |
| 541 | typedef struct SysProfiler_Snapshot_Info_t |
| 542 | { |
| 543 | kal_uint32 has_snapshot; |
| 544 | kal_uint32 trigger_time_us; |
| 545 | kal_uint32 trigger_time_tick; |
| 546 | kal_uint32 trigger_vpe; |
| 547 | kal_uint32 caller; |
| 548 | SysProfiler_Snapshot_Core core[MAX_SYSPRO_NUMBER]; |
| 549 | }SysProfiler_Snapshot_Info; |
| 550 | |
| 551 | #endif |
| 552 | |
| 553 | typedef enum |
| 554 | { |
| 555 | SYSPRO_MIN_BUFF_SIZE, |
| 556 | SYSPRO_MAX_BUFF_SIZE, |
| 557 | SYSPRO_CUSTOM_BUFF_SIZE, |
| 558 | }SYSPROFILER_ADJUST_BUFF_TYPE; |
| 559 | |
| 560 | #define IS_SWLA_MODE(MODE) ( MODE == SYSPRO_SW_SWLA_MODE ) |
| 561 | #define IS_SWTR_MODE(MODE) ( MODE == SYSPRO_SW_SWTR_MODE ) |
| 562 | |
| 563 | void SysProfiler_Init(void); |
| 564 | kal_uint32 SysProfiler_Start(void); |
| 565 | kal_uint32 SysProfiler_StartCoreProfilerByMode( SYSPRO_MODE mode, kal_uint32 samplingRate); |
| 566 | kal_uint32 SysProfiler_StartPlatformProfilerByMode( SYSPRO_MODE mode, kal_uint32 sysSamplingRate, kal_uint32 infraSamplingRate); |
| 567 | kal_uint32 SysProfiler_Stop(void); |
| 568 | kal_uint32 SysProfiler_StopCoreProfiler(void); |
| 569 | kal_uint32 SysProfiler_StopPlatformProfiler(void); |
| 570 | void SysProfiler_ASMStop(void); |
| 571 | SYSPROFILER_ERROR_CODE SysProfiler_SetMode(SYSPRO_MODE mode); |
| 572 | SYSPROFILER_ERROR_CODE SysProfiler_SetSampleRate(kal_uint32 sampleRate); |
| 573 | kal_uint32 SysProfiler_RetriveHeader( kal_uint8** headerStartAddress, kal_uint32* headerSize, kal_uint8 coreID); |
| 574 | kal_uint32 SysProfiler_RetriveLoggingBuffer(kal_uint32 **info, kal_uint16 *count, kal_uint8* region_config, kal_uint8 coreID); |
| 575 | kal_bool SysProfiler_CheckRAMAvailability(kal_uint32 idx, kal_uint8 coreID); |
| 576 | SYSPROFILER_ERROR_CODE SysProfiler_RegisterAddon( SYSPROFILER_ADDON_TYPE addonType, kal_uint32 addonSize, kal_char addonName[], void (*SYSPRO_AddonInfoInitFunc)(void), void *SA_AddonInfoLoggingFunc, kal_bool SA_SwapOutLogging, SYSPROFILER_ADDON_PROFILER_TYPE profilerType, SYSPRO_MCU_CORE coreID); |
| 577 | kal_bool SysProfiler_QueryCoreProfilerModeAndRunningStatus( SYSPRO_MODE* returnMode, kal_bool* returnRunningStatus); |
| 578 | kal_bool SysProfiler_QueryPlatformProfilerModeAndRunningStatus( SYSPRO_MODE* returnMode, kal_bool* returnRunningStatus); |
| 579 | kal_bool SysProfiler_QueryAddonExist(char *addonPrefix, SYSPRO_MODE mode, kal_uint32 coreID); |
| 580 | kal_bool SysProfiler_QueryHeaderScratchpad(kal_uint8 coreID, kal_uint8** addr, kal_uint32* size, kal_uint32* header_offset); |
| 581 | |
| 582 | #if defined(__SWLA_MIPS_PMU_EXIST__) |
| 583 | SYSPROFILER_ERROR_CODE SysProfiler_PassPMCParameterFromDHL(SysProfiler_DHLPMCParameter* DHLParameter); |
| 584 | #if defined(__MD95__) |
| 585 | kal_bool SysProfiler_PassPMCParameterFromMDDBG(SysProfiler_PMCSettingParameter PMCParameter[], ilm_struct ilm); |
| 586 | #elif defined(__MD97__) || defined(__MD97P__) |
| 587 | kal_bool SysProfiler_PassPMCParameterFromMDDBG(SysProfiler_PMCSettingParameter PMCParameter, ilm_struct ilm); |
| 588 | #else |
| 589 | #error "Unsupported chip" |
| 590 | #endif |
| 591 | #endif |
| 592 | SYSPROFILER_ERROR_CODE SysProfiler_PassPMCParameterByATCMD(kal_uint8* data_str); |
| 593 | SYSPROFILER_ERROR_CODE SysProfiler_TurnOnELMAddon(kal_uint32 coreID); |
| 594 | SYSPROFILER_ERROR_CODE SysProfiler_TurnOnEBMAddon(kal_uint32 coreID); |
| 595 | #if defined(__MD95__) |
| 596 | SYSPROFILER_ERROR_CODE SysProfiler_TurnOnCM2Addon(kal_uint32 coreID, kal_uint32 counter); |
| 597 | SYSPROFILER_ERROR_CODE SysProfiler_TurnOnICM2Addon(kal_uint32 coreID, kal_uint32 counter); |
| 598 | #elif defined(__MD97__) || defined(__MD97P__) |
| 599 | SYSPROFILER_ERROR_CODE SysProfiler_ConfigCM2fromATCMD(kal_uint32 coreID, kal_uint8* data_str, SysProfiler_CM2SettingParameter* config); |
| 600 | SYSPROFILER_ERROR_CODE SysProfiler_TurnOnCM2Addon(kal_uint32 coreID, SysProfiler_CM2SettingParameter *config); |
| 601 | #else |
| 602 | #error "Unsupported chip" |
| 603 | #endif |
| 604 | void SysProfiler_Adjust_buffer(SYSPROFILER_ADJUST_BUFF_TYPE type, kal_uint32 buffersize); |
| 605 | SYSPROFILER_ERROR_CODE SysProfiler_TriggerInitAddonByATCMD(kal_uint8 *data_str); |
| 606 | kal_bool SysProfiler_RegisterDefaultAddonFromMDDBG(void); |
| 607 | #if defined(__SWLA_SNAPSHOT_FEATURE__) |
| 608 | SYSPROFILER_ERROR_CODE SysProfiler_BufferSnapshot(SYSPROFILER_SNAPSHOT_BUFF_ID_ENUM* buffer_id); |
| 609 | #endif |
| 610 | |
| 611 | #endif |