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 | * isrentry.c |
| 41 | * |
| 42 | * Project: |
| 43 | * -------- |
| 44 | * Maui_Software |
| 45 | * |
| 46 | * Description: |
| 47 | * ------------ |
| 48 | * This Module defines the IRQ service routines for all IRQ sources |
| 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 | * removed! |
| 74 | * removed! |
| 75 | * |
| 76 | * removed! |
| 77 | * removed! |
| 78 | * removed! |
| 79 | * removed! |
| 80 | * |
| 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 | * removed! |
| 126 | * removed! |
| 127 | * |
| 128 | * removed! |
| 129 | * removed! |
| 130 | * removed! |
| 131 | * |
| 132 | * removed! |
| 133 | * removed! |
| 134 | * removed! |
| 135 | * removed! |
| 136 | * |
| 137 | * removed! |
| 138 | * removed! |
| 139 | * removed! |
| 140 | * |
| 141 | * removed! |
| 142 | * removed! |
| 143 | * removed! |
| 144 | * |
| 145 | * removed! |
| 146 | * removed! |
| 147 | * removed! |
| 148 | * |
| 149 | * removed! |
| 150 | * removed! |
| 151 | * removed! |
| 152 | * removed! |
| 153 | * removed! |
| 154 | * removed! |
| 155 | * removed! |
| 156 | * removed! |
| 157 | * removed! |
| 158 | * removed! |
| 159 | * removed! |
| 160 | * removed! |
| 161 | * removed! |
| 162 | * |
| 163 | * removed! |
| 164 | * removed! |
| 165 | * removed! |
| 166 | * removed! |
| 167 | * |
| 168 | * removed! |
| 169 | * removed! |
| 170 | * removed! |
| 171 | * removed! |
| 172 | * removed! |
| 173 | * removed! |
| 174 | * |
| 175 | * removed! |
| 176 | * removed! |
| 177 | * removed! |
| 178 | * |
| 179 | * removed! |
| 180 | * removed! |
| 181 | * removed! |
| 182 | * |
| 183 | * removed! |
| 184 | * removed! |
| 185 | * removed! |
| 186 | * |
| 187 | * removed! |
| 188 | * removed! |
| 189 | * removed! |
| 190 | * |
| 191 | * removed! |
| 192 | * removed! |
| 193 | * removed! |
| 194 | * |
| 195 | * removed! |
| 196 | * removed! |
| 197 | * removed! |
| 198 | * |
| 199 | * removed! |
| 200 | * removed! |
| 201 | * removed! |
| 202 | * |
| 203 | * removed! |
| 204 | * removed! |
| 205 | * removed! |
| 206 | * |
| 207 | * removed! |
| 208 | * removed! |
| 209 | * removed! |
| 210 | * |
| 211 | * removed! |
| 212 | * removed! |
| 213 | * removed! |
| 214 | * |
| 215 | * removed! |
| 216 | * removed! |
| 217 | * removed! |
| 218 | * |
| 219 | * removed! |
| 220 | * removed! |
| 221 | * removed! |
| 222 | * |
| 223 | * removed! |
| 224 | * removed! |
| 225 | * removed! |
| 226 | * |
| 227 | *------------------------------------------------------------------------------ |
| 228 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 229 | *============================================================================ |
| 230 | ****************************************************************************/ |
| 231 | /******************************************************************************* |
| 232 | * Include header files. |
| 233 | *******************************************************************************/ |
| 234 | #ifdef __MTK_TARGET__ |
| 235 | #include <mips/mt.h> |
| 236 | #endif |
| 237 | #include "reg_base.h" |
| 238 | #include "isrentry.h" |
| 239 | #include "intrCtrl.h" |
| 240 | |
| 241 | #if defined __MIPS_I7200__ |
| 242 | #include "md97/idle_service.h" |
| 243 | #include "drv_rstctl.h" |
| 244 | #endif |
| 245 | |
| 246 | #include "kal_hrt_api.h" |
| 247 | #include "sync_data.h" |
| 248 | #include "kal_general_types.h" |
| 249 | #include "kal_public_api.h" |
| 250 | #include "kal_public_defs.h" |
| 251 | #include "us_timer.h" |
| 252 | #include "drv_mdcirq.h" |
| 253 | #include "drv_mdcirq_reg.h" |
| 254 | #include "kal_iram_section_defs.h" |
| 255 | #include "drv_vpe_irq.h" |
| 256 | #include "kal_cpuinfo.h" |
| 257 | #include "mips_ia_utils.h" |
| 258 | #include "drv_vpe_irq.h" |
| 259 | #include "ex_public.h" |
| 260 | #include "SST_sla.h" |
| 261 | #include "swtr.h" |
| 262 | #include "kal_internal_api.h" |
| 263 | #include "mddbg_public.h" |
| 264 | #include "kal_wp_hook.h" |
| 265 | |
| 266 | #if defined(__ESL_DBG_UTIL__) |
| 267 | #include "esl_debug.h" |
| 268 | #else /* __ESL_DBG_UTIL__ */ |
| 269 | #define esl_printf(donothing...) do {;}while(0) |
| 270 | #endif /* __ESL_DBG_UTIL__ */ |
| 271 | |
| 272 | /************************************************************************* |
| 273 | * Define function prototypes and data structures. |
| 274 | *************************************************************************/ |
| 275 | |
| 276 | extern void kal_hrt_mt_save(kal_uint32 irqvector, kal_mt_stack_ptr *stack_ptr); |
| 277 | extern void kal_hrt_mt_restore(kal_uint32 irqvector, kal_mt_stack_ptr *stack_ptr); |
| 278 | |
| 279 | #if defined(__DUMMY_L1_ON_TARGET_4G5G__) |
| 280 | extern void xl1r_vpe_idle_setup_False(void); |
| 281 | #endif |
| 282 | |
| 283 | /************************************************************************* |
| 284 | * Define imported global data. |
| 285 | *************************************************************************/ |
| 286 | extern kal_uint16 HWIRQCode2SWIRQCode[]; |
| 287 | extern kal_uint16 SWIRQCode2HWIRQCode[]; |
| 288 | |
| 289 | #if defined(__MDCIRQ_B2B_IRQ_SPEEDUP_FLOW__) |
| 290 | extern kal_uint32 ECT_VPE_Trigger_Status[]; |
| 291 | #endif |
| 292 | |
| 293 | /************************************************************************* |
| 294 | * Define global data. |
| 295 | *************************************************************************/ |
| 296 | irqlisr_entry lisr_dispatch_tbl[NUM_IRQ_SOURCES]; |
| 297 | |
| 298 | __MCURW_HWRW_C_ALIGNED_L2CACHE_LOCK_ZI(4) void *processing_lisr[MDCIRQ_TOTAL_VPE_NUM]; |
| 299 | #if defined(__MD97_IS_2CORES__) |
| 300 | __MCURW_HWRW_C_ALIGNED_L2CACHE_LOCK_RW(4) kal_uint32 processing_irqx[MDCIRQ_TOTAL_VPE_NUM] = {IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT}; |
| 301 | #else |
| 302 | __MCURW_HWRW_C_ALIGNED_L2CACHE_LOCK_RW(4) kal_uint32 processing_irqx[MDCIRQ_TOTAL_VPE_NUM] = {IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT}; |
| 303 | #endif |
| 304 | |
| 305 | #if defined(__MDCIRQ_MPB_PROFILE__) |
| 306 | __MCURW_HWRO_C_ALIGNED_ZI_WB(32) kal_uint32 processing_hrt_irq_count[8]; |
| 307 | kal_uint32 max_concur_hrt_irq_count = 0; // Include both Running HRT ISRs & Preempted HRT ISRs |
| 308 | kal_uint32 max_concur_processing_hrt_irqx[MDCIRQ_TOTAL_VPE_NUM] = {IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT, IRQ_NOT_LISR_CONTEXT}; |
| 309 | kal_uint32 max_concur_hrt_irq_frc = 0; |
| 310 | #endif |
| 311 | |
| 312 | __MCURW_HWRW_C_ALIGNED_L2CACHE_LOCK_ZI(4) kal_uint32 processing_irqCnt[MDCIRQ_TOTAL_VPE_NUM]; |
| 313 | __MCURW_HWRW_C_ALIGNED_L2CACHE_LOCK_ZI(4) kal_uint32 max_processing_irqCnt[MDCIRQ_TOTAL_VPE_NUM]; |
| 314 | |
| 315 | /* spurious interrupt log */ |
| 316 | #define SPURIOUS_IRQ_LOG_SIZE 20 |
| 317 | kal_uint32 spurious_count[MDCIRQ_TOTAL_VPE_NUM] = {0}; |
| 318 | kal_uint32 spurious_id[MDCIRQ_TOTAL_VPE_NUM][SPURIOUS_IRQ_LOG_SIZE]; |
| 319 | |
| 320 | /************************************************************************* |
| 321 | * Macro Definitions for "CIRQ Dispatch Misbehaviour" SW Workaround * |
| 322 | *************************************************************************/ |
| 323 | #define MDCIRQ_DUMMY_DI() \ |
| 324 | do{ \ |
| 325 | __asm__ __volatile__( \ |
| 326 | "di\n\t" \ |
| 327 | "ehb\n\t" \ |
| 328 | ); \ |
| 329 | } while(0) |
| 330 | |
| 331 | #define MDCIRQ_DUMMY_EI() \ |
| 332 | do{ \ |
| 333 | __asm__ __volatile__( \ |
| 334 | "ei\n\t" \ |
| 335 | "ehb\n\t" \ |
| 336 | ); \ |
| 337 | } while(0) |
| 338 | |
| 339 | |
| 340 | /* Delay cirq_cycle T * 6(Shaolin to CIRQ clock ratio) * 2(dual issue) */ |
| 341 | /* 6T per round => 5 nop + 1 addiu from for loop */ |
| 342 | #define MDCIRQ_DELAY_LOOP(cirq_cycle) \ |
| 343 | do{ \ |
| 344 | register kal_uint32 _delay_loop; \ |
| 345 | for(_delay_loop = 0; _delay_loop < cirq_cycle * 2; _delay_loop++) { \ |
| 346 | __asm__ __volatile__( \ |
| 347 | "nop\n\t" \ |
| 348 | "nop\n\t" \ |
| 349 | "nop\n\t" \ |
| 350 | "nop\n\t" \ |
| 351 | "nop\n\t" \ |
| 352 | ); \ |
| 353 | } \ |
| 354 | }while(0) |
| 355 | |
| 356 | /************************************************************************* |
| 357 | * Macro Definitions for "CIRQ Dispatch Misbehaviour" SW Workaround End * |
| 358 | *************************************************************************/ |
| 359 | |
| 360 | /************************************************************************* |
| 361 | * FUNCTION |
| 362 | * MDCIRQ_IRQ_Register_LISR |
| 363 | * |
| 364 | * DESCRIPTION |
| 365 | * This function implement method to register IRQ's LISR. |
| 366 | * |
| 367 | * CALLS |
| 368 | * |
| 369 | * CALL BY |
| 370 | * |
| 371 | * PARAMETERS |
| 372 | * HWIRQID - vector number to register |
| 373 | * reg_lisr - register LISR's handler |
| 374 | * description - LISR's description pointer to be saved. |
| 375 | * Remember, the routine won't duplicate the description, |
| 376 | * therefore, caller shouldn't free the description. |
| 377 | * |
| 378 | * RETURNS |
| 379 | * |
| 380 | *************************************************************************/ |
| 381 | void MDCIRQ_IRQ_Register_LISR(kal_uint16 HWIRQCode, void (*reg_lisr)(kal_uint32), char* description) |
| 382 | { |
| 383 | kal_uint32 savedMask, SWIRQCode; |
| 384 | |
| 385 | savedMask = kal_hrt_SaveAndSetIRQMask(); |
| 386 | SWIRQCode = (kal_uint32)HWIRQCode2SWIRQCode[HWIRQCode]; |
| 387 | lisr_dispatch_tbl[HWIRQCode].vector = SWIRQCode; |
| 388 | lisr_dispatch_tbl[HWIRQCode].lisr_handler = reg_lisr; |
| 389 | lisr_dispatch_tbl[HWIRQCode].description = description; |
| 390 | kal_hrt_RestoreIRQMask(savedMask); |
| 391 | } |
| 392 | |
| 393 | /************************************************************************* |
| 394 | * FUNCTION |
| 395 | * MDCIRQ_IRQ_LISR_Init |
| 396 | * |
| 397 | * DESCRIPTION |
| 398 | * This function implement IRQ's LISR (Low-level Interrupt Service Routine) |
| 399 | * Table initialization. |
| 400 | * |
| 401 | * CALLS |
| 402 | * |
| 403 | * CALL BY |
| 404 | * |
| 405 | * PARAMETERS |
| 406 | * |
| 407 | * RETURNS |
| 408 | * |
| 409 | *************************************************************************/ |
| 410 | void MDCIRQ_IRQ_LISR_Init() |
| 411 | { |
| 412 | kal_uint32 i; |
| 413 | for (i = NUM_IRQ_SOURCES; i != 0; i--) |
| 414 | { |
| 415 | MDCIRQ_IRQ_Register_LISR(i - 1, MDCIRQ_IRQ_Default_LISR, "NULL handler"); |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | /************************************************************************* |
| 420 | * FUNCTION |
| 421 | * MDCIRQ_IRQ_Retrieve_LISR |
| 422 | * |
| 423 | * DESCRIPTION |
| 424 | * This function implement to retrieve register LISR handler |
| 425 | * |
| 426 | * CALLS |
| 427 | * |
| 428 | * CALL BY |
| 429 | * |
| 430 | * PARAMETERS |
| 431 | * |
| 432 | * RETURNS |
| 433 | * |
| 434 | *************************************************************************/ |
| 435 | void* MDCIRQ_IRQ_Retrieve_LISR(kal_uint16 HWIRQCode) |
| 436 | { |
| 437 | return(void*)(lisr_dispatch_tbl[HWIRQCode].lisr_handler); |
| 438 | } |
| 439 | |
| 440 | /************************************************************************* |
| 441 | * FUNCTION |
| 442 | * IRQ_Default_LISR |
| 443 | * |
| 444 | * DESCRIPTION |
| 445 | * This function implement default IRQ' LISR |
| 446 | * |
| 447 | * CALLS |
| 448 | * |
| 449 | * CALL BY |
| 450 | * IRQ_LISR_Init() |
| 451 | * |
| 452 | * PARAMETERS |
| 453 | * |
| 454 | * RETURNS |
| 455 | * |
| 456 | *************************************************************************/ |
| 457 | void MDCIRQ_IRQ_Default_LISR(kal_uint32 irq_id) |
| 458 | { |
| 459 | kal_fatal_error_handler(KAL_ERROR_NON_REGISTERED_LISR, irq_id); |
| 460 | } |
| 461 | |
| 462 | void INT_Timer_Interrupt(void) |
| 463 | { |
| 464 | kal_timer_interrupt(); |
| 465 | } |
| 466 | |
| 467 | void isrC_Main(kal_uint32 vector) |
| 468 | { |
| 469 | |
| 470 | kal_uint32 vpe_num; |
| 471 | kal_uint32 irqx_swcode, irqx_swcode_non_spurious; |
| 472 | kal_uint32 irqx_hwcode, irqx_hwcode_non_spurious; |
| 473 | void *processing_lisr_backup; |
| 474 | kal_uint32 processing_irqx_backup; |
| 475 | kal_uint32 ori_vpe_state; |
| 476 | kal_mt_stack_ptr mt_stack_ptr_backup = {{NULL}}; |
| 477 | |
| 478 | ASSERT_EXL_SAFE(vector == VPE_IRQID_MDCIRQ); |
| 479 | |
| 480 | vpe_num = kal_get_current_vpe_id(); |
| 481 | processing_lisr_backup = processing_lisr[vpe_num]; |
| 482 | processing_irqx_backup = processing_irqx[vpe_num]; |
| 483 | |
| 484 | #if defined(__MDCIRQ_B2B_IRQ_SPEEDUP_FLOW__) |
| 485 | do { |
| 486 | #endif |
| 487 | |
| 488 | #if defined(__MDCIRQ_GCR_SIGNAL_DISABLE__) |
| 489 | irqx_swcode = DRV_Reg32(MDCIRQ_VPE_IRQ_ID_BASE + (vpe_num<<2)); |
| 490 | #else |
| 491 | irqx_swcode = DRV_Reg32(MDCIRQ_GCR_VPE_IRQ_ID_BASE + (vpe_num<<2)); |
| 492 | #endif |
| 493 | |
| 494 | irqx_swcode_non_spurious = irqx_swcode & 0x1ff; |
| 495 | |
| 496 | /* Set&backup VPE IRQ state */ |
| 497 | ori_vpe_state = drv_mdcirq_SaveAndSet_VPE_state(vpe_num, irqx_swcode_non_spurious); |
| 498 | |
| 499 | #if defined __MIPS_I7200__ |
| 500 | /* Reset TC's priority according IRQ's Priority */ |
| 501 | register miu_reg32_t tc_priority; |
| 502 | if (irqx_swcode < IRQ_HRT_PRIORITY_THRESHOLD) { |
| 503 | // HRT IRQs |
| 504 | tc_priority = HRT_CONTEXT_GRP; |
| 505 | #if defined(__MDCIRQ_MPB_PROFILE__) |
| 506 | kal_atomic_inc(&processing_hrt_irq_count[0]); |
| 507 | #endif |
| 508 | } else { |
| 509 | // Non-HRT IRQs and Spurious IRQs |
| 510 | tc_priority = kal_get_current_domain(); |
| 511 | } |
| 512 | miu_mtc0(MIU_C0_TCSCHEDULE, tc_priority << MIU_C0_TCSCHEDULE_PRIO_BITFIELD_BEG); |
| 513 | |
| 514 | #else /* MT6297_IA */ |
| 515 | /* Not set when spurious interrput, so take original read ID result as parameter */ |
| 516 | if( !kal_if_hrt_domain(vpe_num) ) |
| 517 | { |
| 518 | LISR_RAISE_TC_PRIO(irqx_swcode); |
| 519 | } |
| 520 | #endif |
| 521 | |
| 522 | #if defined(__DUMMY_L1_ON_TARGET_4G5G__) |
| 523 | /* Record current VPE is not in Idletask for KS IODT FPGA */ |
| 524 | xl1r_vpe_idle_setup_False(); |
| 525 | #endif |
| 526 | |
| 527 | irqx_hwcode_non_spurious = (kal_uint32)SWIRQCode2HWIRQCode[irqx_swcode_non_spurious]; |
| 528 | irqx_hwcode = irqx_hwcode_non_spurious | (irqx_swcode&0x200); |
| 529 | |
| 530 | /* Use HW code to do IRQ logging */ |
| 531 | esl_printf(ESL_SIM_TIME_FLAG|ESL_WALL_TIME_FLAG, "[ISR-%d S]\n", irqx_hwcode); |
| 532 | |
| 533 | /* These global variable will be used by others. The meaning should keep the same as 93*/ |
| 534 | processing_irqx[vpe_num] = irqx_hwcode_non_spurious; |
| 535 | processing_lisr[vpe_num] = (void*)lisr_dispatch_tbl[irqx_hwcode_non_spurious].lisr_handler; |
| 536 | processing_irqCnt[vpe_num]++; |
| 537 | if(processing_irqCnt[vpe_num]>max_processing_irqCnt[vpe_num]) |
| 538 | { |
| 539 | max_processing_irqCnt[vpe_num] = processing_irqCnt[vpe_num]; |
| 540 | } |
| 541 | |
| 542 | SLA_LoggingLISR(0xaaaa0000 | ((kal_uint32)irqx_hwcode), vpe_num); |
| 543 | |
| 544 | /************************************************************************************ |
| 545 | * SW workaround for "CIRQ Dispatch Misbehaviour" * |
| 546 | * When low priority IRQ is enterting IRQ handler flow (readID ~ set vpe state), and * |
| 547 | * high priority IRQ is choosing best vpe according to vpe state, the high priority * |
| 548 | * IRQ will dispatch to the same VPE and preempt low priority IRQ since vpe state * |
| 549 | * of the low priority IRQ has not yet been updated to CIRQ. This may cause two * |
| 550 | * critical LISRS to run on the same VPE while other VPEs are in IDLE. Therefore, we * |
| 551 | * trigger a dummy DI/EI below to force high priority IRQ to be resent to other VPEs.* |
| 552 | *************************************************************************************/ |
| 553 | |
| 554 | #if defined(__MDCIRQ_GCR_SIGNAL_DISABLE__) |
| 555 | /* Dummy read APB_VPE_IRQ_STATE to guarantee value has been written to CIRQ */ |
| 556 | ASSERT_EXL_SAFE(MDCIRQ_READ_REG_INDEX(MDCIRQ_VPE_IRQ_STATE_BASE, vpe_num) == irqx_swcode_non_spurious); |
| 557 | #else |
| 558 | /* Dummy read GCR_VPE_IRQ_STATE to guarantee value has been written to GCR, |
| 559 | then wait for 3T CIRQ clock so that the GCR value is synced to CIRQ */ |
| 560 | ASSERT_EXL_SAFE(MDCIRQ_READ_REG_INDEX(MDCIRQ_GCR_VPE_IRQ_STATE_BASE, vpe_num) == irqx_swcode_non_spurious); |
| 561 | MDCIRQ_DELAY_LOOP(3); |
| 562 | #endif |
| 563 | |
| 564 | /* Dummy DI/EI to force pending IRQs to be resent */ |
| 565 | MDCIRQ_DUMMY_DI(); |
| 566 | MDCIRQ_DELAY_LOOP(3); |
| 567 | MDCIRQ_DUMMY_EI(); |
| 568 | |
| 569 | /************************************************************************************ |
| 570 | * SW workaround for "CIRQ Dispatch Misbehaviour" End * |
| 571 | *************************************************************************************/ |
| 572 | |
| 573 | /* Non-Spurious IRQ */ |
| 574 | if(!(irqx_hwcode&0x200)) |
| 575 | { |
| 576 | kal_hrt_mt_save(irqx_hwcode_non_spurious, &mt_stack_ptr_backup); |
| 577 | #if defined(__MDCIRQ_OSIPI_SPECIAL_FLOW__) |
| 578 | /* Mask OSIPI in the first IRQ LISR (because OSIPI is the lowest priority) */ |
| 579 | if( processing_irqCnt[vpe_num] == 1 ) |
| 580 | { |
| 581 | VPE_IRQ_MASK(VPE_IRQID_OSIPI); |
| 582 | } |
| 583 | #endif |
| 584 | #if defined __MIPS_I7200__ |
| 585 | if((kal_get_current_domain() == KAL_DOMAIN_CHRT) && (processing_irqCnt[vpe_num] == 1)) |
| 586 | { |
| 587 | // enable and kick WDT |
| 588 | drv_rstctl_set_check_bit((vpeid_e)vpe_num); |
| 589 | drv_rstctl_set_kick_bit((vpeid_e)vpe_num); |
| 590 | } |
| 591 | #endif |
| 592 | #if !defined(DISABLE_MDDBG_FUNCTION) |
| 593 | wp_hook_dispatchLISR_start(vpe_num,irqx_hwcode_non_spurious); |
| 594 | #endif |
| 595 | Clear_EXL(); |
| 596 | |
| 597 | lisr_dispatch_tbl[irqx_hwcode_non_spurious].lisr_handler(irqx_hwcode_non_spurious); |
| 598 | |
| 599 | if(Ibit_Status()!=1) //Ibit cannot be disabled after LISR! |
| 600 | { |
| 601 | kal_fatal_error_handler(KAL_ERROR_INTERRUPT_DISABLED_AFTER_LISR_FAILED, (kal_uint32)processing_lisr[vpe_num]); |
| 602 | } |
| 603 | |
| 604 | Set_EXL(); |
| 605 | #if !defined(DISABLE_MDDBG_FUNCTION) |
| 606 | wp_hook_dispatchLISR_end(vpe_num,irqx_hwcode_non_spurious); |
| 607 | #endif |
| 608 | |
| 609 | #if defined(__MDCIRQ_B2B_IRQ_SPEEDUP_FLOW__) |
| 610 | /* CIRQ timing limitation: "After clearing IRQ source, need to wait for |
| 611 | 105T CPU clock before doing priority ACK." |
| 612 | => SWLA need to be placed before priority ACK */ |
| 613 | kal_hrt_mt_restore(irqx_hwcode_non_spurious, &mt_stack_ptr_backup); |
| 614 | SLA_LoggingLISR(0xaaaaaaaa, vpe_num); |
| 615 | drv_mdcirq_Restore_VPE_state(vpe_num, ori_vpe_state); |
| 616 | |
| 617 | /* In B2B flow, do priority ACK earlier so that next IRQ can be |
| 618 | triggered to CPU earlier. */ |
| 619 | if( processing_irqx_backup == IRQ_NOT_LISR_CONTEXT) |
| 620 | MDCIRQ_SYS_endIsr(vpe_num, processing_irqx_backup); |
| 621 | else |
| 622 | MDCIRQ_SYS_endIsr(vpe_num, (kal_uint32)HWIRQCode2SWIRQCode[processing_irqx_backup]); |
| 623 | #endif |
| 624 | |
| 625 | #if defined(__MDCIRQ_OSIPI_SPECIAL_FLOW__) |
| 626 | /* Unmask OSIPI after the first IRQ LISR */ |
| 627 | if( processing_irqCnt[vpe_num] == 1 ) |
| 628 | { |
| 629 | VPE_IRQ_UNMASK(VPE_IRQID_OSIPI); |
| 630 | } |
| 631 | #endif |
| 632 | |
| 633 | #if defined __MIPS_I7200__ |
| 634 | if((kal_get_current_domain() == KAL_DOMAIN_CHRT) && (processing_irqCnt[vpe_num] == 1)) |
| 635 | { |
| 636 | // disable WDT |
| 637 | drv_rstctl_clr_check_bit((vpeid_e)vpe_num); |
| 638 | // set wait variable |
| 639 | Idle_Service_Prepare_WAIT(); |
| 640 | } |
| 641 | #endif |
| 642 | |
| 643 | #if !defined(__MDCIRQ_B2B_IRQ_SPEEDUP_FLOW__) |
| 644 | kal_hrt_mt_restore(irqx_hwcode_non_spurious, &mt_stack_ptr_backup); |
| 645 | #endif |
| 646 | } |
| 647 | else // spurious IRQ |
| 648 | { |
| 649 | spurious_id[vpe_num][spurious_count[vpe_num]%SPURIOUS_IRQ_LOG_SIZE] = irqx_hwcode; |
| 650 | spurious_count[vpe_num]++; |
| 651 | |
| 652 | #if defined(__MDCIRQ_B2B_IRQ_SPEEDUP_FLOW__) |
| 653 | SLA_LoggingLISR(0xaaaaaaaa, vpe_num); |
| 654 | drv_mdcirq_Restore_VPE_state(vpe_num, ori_vpe_state); |
| 655 | #endif |
| 656 | } |
| 657 | |
| 658 | #if defined(__MDCIRQ_MPB_PROFILE__) |
| 659 | if (processing_hrt_irq_count[0] >= max_concur_hrt_irq_count) { |
| 660 | max_concur_hrt_irq_count = processing_hrt_irq_count[0]; |
| 661 | max_concur_hrt_irq_frc = ust_get_current_time(); |
| 662 | memcpy(max_concur_processing_hrt_irqx, processing_irqx, sizeof(processing_irqx)); |
| 663 | } |
| 664 | if (irqx_swcode < IRQ_HRT_PRIORITY_THRESHOLD) { |
| 665 | kal_atomic_dec(&processing_hrt_irq_count[0]); |
| 666 | } |
| 667 | #endif |
| 668 | |
| 669 | processing_irqx[vpe_num] = processing_irqx_backup; |
| 670 | processing_lisr[vpe_num] = processing_lisr_backup; |
| 671 | processing_irqCnt[vpe_num]--; |
| 672 | |
| 673 | /* Use HW code to do IRQ logging */ |
| 674 | esl_printf(ESL_SIM_TIME_FLAG|ESL_WALL_TIME_FLAG, "[ISR-%d E]\n", irqx_hwcode); |
| 675 | |
| 676 | #if defined(__MDCIRQ_B2B_IRQ_SPEEDUP_FLOW__) |
| 677 | /* CTI interrupt is level-trigger and the source would not be cleared. |
| 678 | Therefore, ignore the pending IRQ, let it back to OS and enter exception. */ |
| 679 | if (ECT_VPE_Trigger_Status[vpe_num] != 0) { |
| 680 | break; |
| 681 | } |
| 682 | |
| 683 | /* Check if next IRQ is pending */ |
| 684 | /* IRQ_B <-> SI_INT[4] => IP6 => C0_CAUSE[14] */ |
| 685 | if (((miu_mfc0(MIU_C0_CAUSE) >> (8 + VPE_IRQID_MDCIRQ)) & 0x1) == 1) { |
| 686 | /* Delay 1T CIRQ clock to ensure IRQ ID has been synced to GCR */ |
| 687 | MDCIRQ_DELAY_LOOP(1); |
| 688 | |
| 689 | /* CIRQ timing limitation: "SW should not DI or set min priority within |
| 690 | 50T CPU clock before read ID." |
| 691 | => Should not DI or set SPL within 50T before this point */ |
| 692 | } else { |
| 693 | /* No pending IRQ => exit ISR handler loop */ |
| 694 | break; |
| 695 | } |
| 696 | |
| 697 | } while (1); |
| 698 | #else |
| 699 | SLA_LoggingLISR(0xaaaaaaaa, vpe_num); |
| 700 | drv_mdcirq_Restore_VPE_state(vpe_num, ori_vpe_state); |
| 701 | |
| 702 | /* Non-Spurious IRQ */ |
| 703 | if(!(irqx_hwcode&0x200)) |
| 704 | { |
| 705 | /* IRQ idx in SW code view */ |
| 706 | if( processing_irqx_backup == IRQ_NOT_LISR_CONTEXT) |
| 707 | MDCIRQ_SYS_endIsr(vpe_num, processing_irqx_backup); |
| 708 | else |
| 709 | MDCIRQ_SYS_endIsr(vpe_num, (kal_uint32)HWIRQCode2SWIRQCode[processing_irqx_backup]); |
| 710 | } |
| 711 | #endif |
| 712 | } |
| 713 | |
| 714 | |
| 715 | #if 0 |
| 716 | /* under construction !*/ |
| 717 | /* under construction !*/ |
| 718 | /* under construction !*/ |
| 719 | /* under construction !*/ |
| 720 | /* under construction !*/ |
| 721 | /* under construction !*/ |
| 722 | /* under construction !*/ |
| 723 | /* under construction !*/ |
| 724 | /* under construction !*/ |
| 725 | /* under construction !*/ |
| 726 | /* under construction !*/ |
| 727 | /* under construction !*/ |
| 728 | /* under construction !*/ |
| 729 | /* under construction !*/ |
| 730 | /* under construction !*/ |
| 731 | /* under construction !*/ |
| 732 | /* under construction !*/ |
| 733 | /* under construction !*/ |
| 734 | /* under construction !*/ |
| 735 | /* under construction !*/ |
| 736 | /* under construction !*/ |
| 737 | /* under construction !*/ |
| 738 | /* under construction !*/ |
| 739 | /* under construction !*/ |
| 740 | /* under construction !*/ |
| 741 | /* under construction !*/ |
| 742 | /* under construction !*/ |
| 743 | /* under construction !*/ |
| 744 | /* under construction !*/ |
| 745 | /* under construction !*/ |
| 746 | /* under construction !*/ |
| 747 | /* under construction !*/ |
| 748 | /* under construction !*/ |
| 749 | /* under construction !*/ |
| 750 | /* under construction !*/ |
| 751 | /* under construction !*/ |
| 752 | #endif |
| 753 | |