Manish Pandey | d27b37d | 2021-03-02 14:41:58 +0000 | [diff] [blame] | 1 | /* |
Madhukar Pappireddy | 7caaa4a | 2022-01-28 17:01:35 -0600 | [diff] [blame] | 2 | * Copyright (c) 2021-2022, Arm Limited. All rights reserved. |
Manish Pandey | d27b37d | 2021-03-02 14:41:58 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <debug.h> |
| 8 | |
Madhukar Pappireddy | cd183ef | 2021-08-05 15:34:07 -0500 | [diff] [blame] | 9 | #include "cactus_message_loop.h" |
| 10 | #include "cactus_test_cmds.h" |
| 11 | #include <drivers/arm/sp805.h> |
Manish Pandey | d27b37d | 2021-03-02 14:41:58 +0000 | [diff] [blame] | 12 | #include <ffa_helpers.h> |
| 13 | #include <sp_helpers.h> |
Madhukar Pappireddy | cd183ef | 2021-08-05 15:34:07 -0500 | [diff] [blame] | 14 | #include "spm_common.h" |
Manish Pandey | 58971b6 | 2020-09-21 21:10:38 +0100 | [diff] [blame] | 15 | #include <spm_helpers.h> |
Manish Pandey | d27b37d | 2021-03-02 14:41:58 +0000 | [diff] [blame] | 16 | |
Madhukar Pappireddy | cd183ef | 2021-08-05 15:34:07 -0500 | [diff] [blame] | 17 | #include <platform_def.h> |
Manish Pandey | f7aafef | 2021-03-03 11:31:47 +0000 | [diff] [blame] | 18 | |
J-Alves | a076d4c | 2021-10-19 16:06:15 +0100 | [diff] [blame] | 19 | #define NOTIFICATION_PENDING_INTERRUPT_INTID 5 |
| 20 | |
| 21 | extern void notification_pending_interrupt_handler(void); |
| 22 | |
Daniel Boulby | e79d207 | 2021-03-03 11:34:53 +0000 | [diff] [blame] | 23 | extern ffa_id_t g_ffa_id; |
Manish Pandey | f7aafef | 2021-03-03 11:31:47 +0000 | [diff] [blame] | 24 | |
Madhukar Pappireddy | 7caaa4a | 2022-01-28 17:01:35 -0600 | [diff] [blame] | 25 | extern spinlock_t sp_handler_lock[NUM_VINT_ID]; |
| 26 | |
Madhukar Pappireddy | cd183ef | 2021-08-05 15:34:07 -0500 | [diff] [blame] | 27 | void cactus_interrupt_handler(void) |
Manish Pandey | f7aafef | 2021-03-03 11:31:47 +0000 | [diff] [blame] | 28 | { |
Madhukar Pappireddy | cd183ef | 2021-08-05 15:34:07 -0500 | [diff] [blame] | 29 | uint32_t intid = spm_interrupt_get(); |
Manish Pandey | f7aafef | 2021-03-03 11:31:47 +0000 | [diff] [blame] | 30 | |
Madhukar Pappireddy | cd183ef | 2021-08-05 15:34:07 -0500 | [diff] [blame] | 31 | switch (intid) { |
| 32 | case MANAGED_EXIT_INTERRUPT_ID: |
| 33 | /* |
| 34 | * A secure partition performs its housekeeping and sends a |
| 35 | * direct response to signal interrupt completion. |
| 36 | * This is a pure virtual interrupt, no need for deactivation. |
| 37 | */ |
| 38 | cactus_response(g_ffa_id, HYP_ID, MANAGED_EXIT_INTERRUPT_ID); |
| 39 | break; |
| 40 | case IRQ_TWDOG_INTID: |
| 41 | /* |
| 42 | * Interrupt triggered due to Trusted watchdog timer expiry. |
| 43 | * Clear the interrupt and stop the timer. |
| 44 | */ |
| 45 | NOTICE("Trusted WatchDog timer stopped\n"); |
| 46 | sp805_twdog_stop(); |
Manish Pandey | d27b37d | 2021-03-02 14:41:58 +0000 | [diff] [blame] | 47 | |
Madhukar Pappireddy | cd183ef | 2021-08-05 15:34:07 -0500 | [diff] [blame] | 48 | /* Perform secure interrupt de-activation. */ |
| 49 | spm_interrupt_deactivate(intid); |
Manish Pandey | d27b37d | 2021-03-02 14:41:58 +0000 | [diff] [blame] | 50 | |
Madhukar Pappireddy | cd183ef | 2021-08-05 15:34:07 -0500 | [diff] [blame] | 51 | break; |
J-Alves | a076d4c | 2021-10-19 16:06:15 +0100 | [diff] [blame] | 52 | case NOTIFICATION_PENDING_INTERRUPT_INTID: |
| 53 | notification_pending_interrupt_handler(); |
| 54 | break; |
Madhukar Pappireddy | cd183ef | 2021-08-05 15:34:07 -0500 | [diff] [blame] | 55 | default: |
| 56 | /* |
| 57 | * Currently the only source of secure interrupt is Trusted |
| 58 | * Watchdog timer. |
| 59 | */ |
| 60 | ERROR("%s: Interrupt ID %x not handled!\n", __func__, |
| 61 | intid); |
| 62 | panic(); |
Manish Pandey | f7aafef | 2021-03-03 11:31:47 +0000 | [diff] [blame] | 63 | } |
Madhukar Pappireddy | 7caaa4a | 2022-01-28 17:01:35 -0600 | [diff] [blame] | 64 | |
| 65 | /* Invoke the tail end handler registered by the SP. */ |
| 66 | spin_lock(&sp_handler_lock[intid]); |
| 67 | if (sp_interrupt_tail_end_handler[intid]) { |
| 68 | sp_interrupt_tail_end_handler[intid](); |
| 69 | } |
| 70 | spin_unlock(&sp_handler_lock[intid]); |
Manish Pandey | d27b37d | 2021-03-02 14:41:58 +0000 | [diff] [blame] | 71 | } |