Home | History | Annotate | Download | only in qemu
      1 /*
      2  * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved.
      3  *
      4  * SPDX-License-Identifier: BSD-3-Clause
      5  */
      6 
      7 #include <assert.h>
      8 #include <bl_common.h>
      9 #include <gicv2.h>
     10 #include <interrupt_mgmt.h>
     11 
     12 uint32_t plat_ic_get_pending_interrupt_id(void)
     13 {
     14 	return gicv2_get_pending_interrupt_id();
     15 }
     16 
     17 uint32_t plat_ic_get_pending_interrupt_type(void)
     18 {
     19 	return gicv2_get_pending_interrupt_type();
     20 }
     21 
     22 uint32_t plat_ic_acknowledge_interrupt(void)
     23 {
     24 	return gicv2_acknowledge_interrupt();
     25 }
     26 
     27 uint32_t plat_ic_get_interrupt_type(uint32_t id)
     28 {
     29 	uint32_t group;
     30 
     31 	group = gicv2_get_interrupt_group(id);
     32 
     33 	/* Assume that all secure interrupts are S-EL1 interrupts */
     34 	if (!group)
     35 		return INTR_TYPE_S_EL1;
     36 	else
     37 		return INTR_TYPE_NS;
     38 
     39 }
     40 
     41 void plat_ic_end_of_interrupt(uint32_t id)
     42 {
     43 	gicv2_end_of_interrupt(id);
     44 }
     45 
     46 uint32_t plat_interrupt_type_to_line(uint32_t type,
     47 				uint32_t security_state)
     48 {
     49 	assert(type == INTR_TYPE_S_EL1 ||
     50 	       type == INTR_TYPE_EL3 ||
     51 	       type == INTR_TYPE_NS);
     52 
     53 	assert(sec_state_is_valid(security_state));
     54 
     55 	/* Non-secure interrupts are signalled on the IRQ line always */
     56 	if (type == INTR_TYPE_NS)
     57 		return __builtin_ctz(SCR_IRQ_BIT);
     58 
     59 	/*
     60 	 * Secure interrupts are signalled using the IRQ line if the FIQ_EN
     61 	 * bit is not set else they are signalled using the FIQ line.
     62 	 */
     63 	if (gicv2_is_fiq_enabled())
     64 		return __builtin_ctz(SCR_FIQ_BIT);
     65 	else
     66 		return __builtin_ctz(SCR_IRQ_BIT);
     67 }
     68 
     69