hw/arm_gic: Move gic_get_current_cpu into arm_gic.c
Move the gic_get_current_cpu() function into arm_gic.c. There are only two implementations: (1) "get the index of the currently executing CPU", used by all multicore GICs, and (2) "always 0", used by all GICs instantiated with a single CPU interface (the Realview board GIC and the v7M NVIC). So we can move this into the main GIC source file. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Evgeny Voevodin <e.voevodin@samsung.com>
This commit is contained in:
parent
386e29554e
commit
926c4aff6e
@ -20,14 +20,6 @@
|
|||||||
|
|
||||||
#include "sysbus.h"
|
#include "sysbus.h"
|
||||||
|
|
||||||
/* Configuration for arm_gic.c:
|
|
||||||
* how to ID current CPU
|
|
||||||
*/
|
|
||||||
static inline int gic_get_current_cpu(void)
|
|
||||||
{
|
|
||||||
return cpu_single_env->cpu_index;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "arm_gic.c"
|
#include "arm_gic.c"
|
||||||
|
|
||||||
/* A15MP private memory region. */
|
/* A15MP private memory region. */
|
||||||
|
@ -10,15 +10,6 @@
|
|||||||
|
|
||||||
#include "sysbus.h"
|
#include "sysbus.h"
|
||||||
|
|
||||||
/* Configuration for arm_gic.c:
|
|
||||||
* how to ID current CPU
|
|
||||||
*/
|
|
||||||
static inline int
|
|
||||||
gic_get_current_cpu(void)
|
|
||||||
{
|
|
||||||
return cpu_single_env->cpu_index;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "arm_gic.c"
|
#include "arm_gic.c"
|
||||||
|
|
||||||
/* A9MP private memory region. */
|
/* A9MP private memory region. */
|
||||||
|
@ -10,12 +10,6 @@
|
|||||||
#include "sysbus.h"
|
#include "sysbus.h"
|
||||||
#include "qemu-timer.h"
|
#include "qemu-timer.h"
|
||||||
|
|
||||||
static inline int
|
|
||||||
gic_get_current_cpu(void)
|
|
||||||
{
|
|
||||||
return cpu_single_env->cpu_index;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "arm_gic.c"
|
#include "arm_gic.c"
|
||||||
|
|
||||||
/* MPCore private memory region. */
|
/* MPCore private memory region. */
|
||||||
|
20
hw/arm_gic.c
20
hw/arm_gic.c
@ -126,6 +126,16 @@ typedef struct gic_state
|
|||||||
uint32_t num_irq;
|
uint32_t num_irq;
|
||||||
} gic_state;
|
} gic_state;
|
||||||
|
|
||||||
|
static inline int gic_get_current_cpu(gic_state *s)
|
||||||
|
{
|
||||||
|
#if NCPU > 1
|
||||||
|
if (s->num_cpu > 1) {
|
||||||
|
return cpu_single_env->cpu_index;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* TODO: Many places that call this routine could be optimized. */
|
/* TODO: Many places that call this routine could be optimized. */
|
||||||
/* Update interrupt status after enabled or pending bits have been changed. */
|
/* Update interrupt status after enabled or pending bits have been changed. */
|
||||||
static void gic_update(gic_state *s)
|
static void gic_update(gic_state *s)
|
||||||
@ -285,7 +295,7 @@ static uint32_t gic_dist_readb(void *opaque, target_phys_addr_t offset)
|
|||||||
int cm;
|
int cm;
|
||||||
int mask;
|
int mask;
|
||||||
|
|
||||||
cpu = gic_get_current_cpu();
|
cpu = gic_get_current_cpu(s);
|
||||||
cm = 1 << cpu;
|
cm = 1 << cpu;
|
||||||
if (offset < 0x100) {
|
if (offset < 0x100) {
|
||||||
#ifndef NVIC
|
#ifndef NVIC
|
||||||
@ -420,7 +430,7 @@ static void gic_dist_writeb(void *opaque, target_phys_addr_t offset,
|
|||||||
int i;
|
int i;
|
||||||
int cpu;
|
int cpu;
|
||||||
|
|
||||||
cpu = gic_get_current_cpu();
|
cpu = gic_get_current_cpu(s);
|
||||||
if (offset < 0x100) {
|
if (offset < 0x100) {
|
||||||
#ifdef NVIC
|
#ifdef NVIC
|
||||||
goto bad_reg;
|
goto bad_reg;
|
||||||
@ -582,7 +592,7 @@ static void gic_dist_writel(void *opaque, target_phys_addr_t offset,
|
|||||||
int irq;
|
int irq;
|
||||||
int mask;
|
int mask;
|
||||||
|
|
||||||
cpu = gic_get_current_cpu();
|
cpu = gic_get_current_cpu(s);
|
||||||
irq = value & 0x3ff;
|
irq = value & 0x3ff;
|
||||||
switch ((value >> 24) & 3) {
|
switch ((value >> 24) & 3) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -665,14 +675,14 @@ static uint64_t gic_thiscpu_read(void *opaque, target_phys_addr_t addr,
|
|||||||
unsigned size)
|
unsigned size)
|
||||||
{
|
{
|
||||||
gic_state *s = (gic_state *)opaque;
|
gic_state *s = (gic_state *)opaque;
|
||||||
return gic_cpu_read(s, gic_get_current_cpu(), addr);
|
return gic_cpu_read(s, gic_get_current_cpu(s), addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gic_thiscpu_write(void *opaque, target_phys_addr_t addr,
|
static void gic_thiscpu_write(void *opaque, target_phys_addr_t addr,
|
||||||
uint64_t value, unsigned size)
|
uint64_t value, unsigned size)
|
||||||
{
|
{
|
||||||
gic_state *s = (gic_state *)opaque;
|
gic_state *s = (gic_state *)opaque;
|
||||||
gic_cpu_write(s, gic_get_current_cpu(), addr, value);
|
gic_cpu_write(s, gic_get_current_cpu(s), addr, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wrappers to read/write the GIC CPU interface for a specific CPU.
|
/* Wrappers to read/write the GIC CPU interface for a specific CPU.
|
||||||
|
@ -17,13 +17,6 @@
|
|||||||
|
|
||||||
#define NVIC 1
|
#define NVIC 1
|
||||||
|
|
||||||
/* Only a single "CPU" interface is present. */
|
|
||||||
static inline int
|
|
||||||
gic_get_current_cpu(void)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint32_t nvic_readl(void *opaque, uint32_t offset);
|
static uint32_t nvic_readl(void *opaque, uint32_t offset);
|
||||||
static void nvic_writel(void *opaque, uint32_t offset, uint32_t value);
|
static void nvic_writel(void *opaque, uint32_t offset, uint32_t value);
|
||||||
|
|
||||||
|
@ -262,12 +262,6 @@ uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit)
|
|||||||
|
|
||||||
/********* GIC part *********/
|
/********* GIC part *********/
|
||||||
|
|
||||||
static inline int
|
|
||||||
gic_get_current_cpu(void)
|
|
||||||
{
|
|
||||||
return cpu_single_env->cpu_index;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "arm_gic.c"
|
#include "arm_gic.c"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -9,13 +9,6 @@
|
|||||||
|
|
||||||
#include "sysbus.h"
|
#include "sysbus.h"
|
||||||
|
|
||||||
/* Only a single "CPU" interface is present. */
|
|
||||||
static inline int
|
|
||||||
gic_get_current_cpu(void)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "arm_gic.c"
|
#include "arm_gic.c"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user