blob: 31c6a69ea0c0ac31a2de83971b267e217f8a9e38 [file] [log] [blame]
Manish Pandeyd27b37d2021-03-02 14:41:58 +00001/*
2 * Copyright (c) 2021, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <debug.h>
8
Madhukar Pappireddycd183ef2021-08-05 15:34:07 -05009#include "cactus_message_loop.h"
10#include "cactus_test_cmds.h"
11#include <drivers/arm/sp805.h>
Manish Pandeyd27b37d2021-03-02 14:41:58 +000012#include <ffa_helpers.h>
13#include <sp_helpers.h>
Madhukar Pappireddycd183ef2021-08-05 15:34:07 -050014#include "spm_common.h"
Manish Pandey58971b62020-09-21 21:10:38 +010015#include <spm_helpers.h>
Manish Pandeyd27b37d2021-03-02 14:41:58 +000016
Madhukar Pappireddycd183ef2021-08-05 15:34:07 -050017#include <platform_def.h>
Manish Pandeyf7aafef2021-03-03 11:31:47 +000018
Daniel Boulbye79d2072021-03-03 11:34:53 +000019extern ffa_id_t g_ffa_id;
Manish Pandeyf7aafef2021-03-03 11:31:47 +000020
Madhukar Pappireddycd183ef2021-08-05 15:34:07 -050021void cactus_interrupt_handler(void)
Manish Pandeyf7aafef2021-03-03 11:31:47 +000022{
Madhukar Pappireddycd183ef2021-08-05 15:34:07 -050023 uint32_t intid = spm_interrupt_get();
Manish Pandeyf7aafef2021-03-03 11:31:47 +000024
Madhukar Pappireddycd183ef2021-08-05 15:34:07 -050025 switch (intid) {
26 case MANAGED_EXIT_INTERRUPT_ID:
27 /*
28 * A secure partition performs its housekeeping and sends a
29 * direct response to signal interrupt completion.
30 * This is a pure virtual interrupt, no need for deactivation.
31 */
32 cactus_response(g_ffa_id, HYP_ID, MANAGED_EXIT_INTERRUPT_ID);
33 break;
34 case IRQ_TWDOG_INTID:
35 /*
36 * Interrupt triggered due to Trusted watchdog timer expiry.
37 * Clear the interrupt and stop the timer.
38 */
39 NOTICE("Trusted WatchDog timer stopped\n");
40 sp805_twdog_stop();
Manish Pandeyd27b37d2021-03-02 14:41:58 +000041
Madhukar Pappireddycd183ef2021-08-05 15:34:07 -050042 /* Perform secure interrupt de-activation. */
43 spm_interrupt_deactivate(intid);
Manish Pandeyd27b37d2021-03-02 14:41:58 +000044
Madhukar Pappireddycd183ef2021-08-05 15:34:07 -050045 break;
46 default:
47 /*
48 * Currently the only source of secure interrupt is Trusted
49 * Watchdog timer.
50 */
51 ERROR("%s: Interrupt ID %x not handled!\n", __func__,
52 intid);
53 panic();
Manish Pandeyf7aafef2021-03-03 11:31:47 +000054 }
Manish Pandeyd27b37d2021-03-02 14:41:58 +000055}