Skip to content

Commit

Permalink
Irq modes handling
Browse files Browse the repository at this point in the history
Change-Id: I427af99ad6c561619068155c1e52fe4081282785
  • Loading branch information
ua1arn authored and JonatanAntoni committed Mar 3, 2020
1 parent 33a56d5 commit c1dbf04
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
12 changes: 9 additions & 3 deletions CMSIS/Core_A/Include/irq_ctrl.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**************************************************************************//**
* @file irq_ctrl.h
* @brief Interrupt Controller API header file
* @version V1.0.0
* @date 23. June 2017
* @version V1.1.0
* @date 03. March 2020
******************************************************************************/
/*
* Copyright (c) 2017 ARM Limited. All rights reserved.
* Copyright (c) 2017-2020 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
Expand Down Expand Up @@ -78,6 +78,12 @@ typedef int32_t IRQn_ID_t;
#define IRQ_MODE_CPU_6 (0x40UL << IRQ_MODE_CPU_Pos) ///< CPU: interrupt targets CPU 6
#define IRQ_MODE_CPU_7 (0x80UL << IRQ_MODE_CPU_Pos) ///< CPU: interrupt targets CPU 7

// Encoding in some early GIC implementations
#define IRQ_MODE_MODEL_Pos (13U)
#define IRQ_MODE_MODEL_Msk (0x1UL << IRQ_MODE_MODEL_Pos)
#define IRQ_MODE_MODEL_NN (0x0UL << IRQ_MODE_MODEL_Pos) ///< Corresponding interrupt is handled using the N-N model
#define IRQ_MODE_MODEL_1N (0x1UL << IRQ_MODE_MODEL_Pos) ///< Corresponding interrupt is handled using the 1-N model

#define IRQ_MODE_ERROR (0x80000000UL) ///< Bit indicating mode value error

/* Interrupt priority bit-masks */
Expand Down
14 changes: 11 additions & 3 deletions CMSIS/Core_A/Source/irq_ctrl_gic.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**************************************************************************//**
* @file irq_ctrl_gic.c
* @brief Interrupt controller handling implementation for GIC
* @version V1.0.1
* @date 9. April 2018
* @version V1.1.0
* @date 03. March 2020
******************************************************************************/
/*
* Copyright (c) 2017 ARM Limited. All rights reserved.
* Copyright (c) 2017-2020 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
Expand Down Expand Up @@ -148,6 +148,11 @@ __WEAK int32_t IRQ_SetMode (IRQn_ID_t irqn, uint32_t mode) {
status = -1;
}

val = (mode & IRQ_MODE_MODEL_Msk);
if (val == IRQ_MODE_MODEL_1N) {
cfg |= 1; // 1-N model
}

// Check interrupt type
val = mode & IRQ_MODE_TYPE_Msk;

Expand Down Expand Up @@ -216,6 +221,9 @@ __WEAK uint32_t IRQ_GetMode (IRQn_ID_t irqn) {
mode |= IRQ_MODE_TRIG_LEVEL;
}

if (val & 1U) {
mode |= IRQ_MODE_MODEL_1N;
}
// Get interrupt CPU targets
mode |= GIC_GetTarget ((IRQn_Type)irqn) << IRQ_MODE_CPU_Pos;

Expand Down

0 comments on commit c1dbf04

Please sign in to comment.