Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
armv7m: Move NVICState struct definition into header
Move the NVICState struct definition into a header, so we can embed it into other QOM objects like SoCs. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Message-id: 1487604965-23220-3-git-send-email-peter.maydell@linaro.org
- Loading branch information
Showing
2 changed files
with
67 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* ARMv7M NVIC object | ||
* | ||
* Copyright (c) 2017 Linaro Ltd | ||
* Written by Peter Maydell <peter.maydell@linaro.org> | ||
* | ||
* This code is licensed under the GPL version 2 or later. | ||
*/ | ||
|
||
#ifndef HW_ARM_ARMV7M_NVIC_H | ||
#define HW_ARM_ARMV7M_NVIC_H | ||
|
||
#include "target/arm/cpu.h" | ||
#include "hw/sysbus.h" | ||
|
||
#define TYPE_NVIC "armv7m_nvic" | ||
|
||
#define NVIC(obj) \ | ||
OBJECT_CHECK(NVICState, (obj), TYPE_NVIC) | ||
|
||
/* Highest permitted number of exceptions (architectural limit) */ | ||
#define NVIC_MAX_VECTORS 512 | ||
|
||
typedef struct VecInfo { | ||
/* Exception priorities can range from -3 to 255; only the unmodifiable | ||
* priority values for RESET, NMI and HardFault can be negative. | ||
*/ | ||
int16_t prio; | ||
uint8_t enabled; | ||
uint8_t pending; | ||
uint8_t active; | ||
uint8_t level; /* exceptions <=15 never set level */ | ||
} VecInfo; | ||
|
||
typedef struct NVICState { | ||
/*< private >*/ | ||
SysBusDevice parent_obj; | ||
/*< public >*/ | ||
|
||
ARMCPU *cpu; | ||
|
||
VecInfo vectors[NVIC_MAX_VECTORS]; | ||
uint32_t prigroup; | ||
|
||
/* vectpending and exception_prio are both cached state that can | ||
* be recalculated from the vectors[] array and the prigroup field. | ||
*/ | ||
unsigned int vectpending; /* highest prio pending enabled exception */ | ||
int exception_prio; /* group prio of the highest prio active exception */ | ||
|
||
struct { | ||
uint32_t control; | ||
uint32_t reload; | ||
int64_t tick; | ||
QEMUTimer *timer; | ||
} systick; | ||
|
||
MemoryRegion sysregmem; | ||
MemoryRegion container; | ||
|
||
uint32_t num_irq; | ||
qemu_irq excpout; | ||
qemu_irq sysresetreq; | ||
} NVICState; | ||
|
||
#endif |