[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 17/34] mb: cpu: Multi-define guard deep CPU spec
From: |
Peter Crosthwaite |
Subject: |
[Qemu-devel] [RFC PATCH 17/34] mb: cpu: Multi-define guard deep CPU specifics |
Date: |
Sun, 10 May 2015 23:29:20 -0700 |
If MMU_USER_IDX or ENV_OFFSET is already defined, undefine it.
The undef will cause a compile error on the ambiguous case where
multiple cpu.h's are included yet either of these defs
is needed. This shouldn't happen, as the multi-include should only
happen in device-land system level code that need CPU defs from
multiple arches - e.g. a machine model with two different arch CPUs.
Such device code has no bussiness using MMU_USER_IDX or ENV_OFFSET.
ENV_GET_CPU s also multi-guarded to perform no action on second define.
This is for multi-arch where target-multi provides a working
implementation already
Signed-off-by: Peter Crosthwaite <address@hidden>
---
target-microblaze/cpu-qom.h | 7 +++++++
target-microblaze/cpu.h | 6 ++++++
2 files changed, 13 insertions(+)
diff --git a/target-microblaze/cpu-qom.h b/target-microblaze/cpu-qom.h
index e3e0701..f3960ac 100644
--- a/target-microblaze/cpu-qom.h
+++ b/target-microblaze/cpu-qom.h
@@ -67,9 +67,16 @@ static inline MicroBlazeCPU *mb_env_get_cpu(CPUMBState *env)
return container_of(env, MicroBlazeCPU, env);
}
+#ifndef ENV_GET_CPU
#define ENV_GET_CPU(e) CPU(mb_env_get_cpu(e))
+#endif
+#ifndef ENV_OFFSET
#define ENV_OFFSET offsetof(MicroBlazeCPU, env)
+#else
+/* Try and cause a compile bug on any (invalid) users of the multiple def */
+#undef ENV_OFFSET
+#endif
void mb_cpu_do_interrupt(CPUState *cs);
bool mb_cpu_exec_interrupt(CPUState *cs, int int_req);
diff --git a/target-microblaze/cpu.h b/target-microblaze/cpu.h
index da42483..5f15ca9 100644
--- a/target-microblaze/cpu.h
+++ b/target-microblaze/cpu.h
@@ -288,7 +288,13 @@ MicroBlazeCPU *cpu_mb_init(const char *cpu_model);
/* MMU modes definitions */
#define MMU_NOMMU_IDX 0
#define MMU_KERNEL_IDX 1
+
+#ifdef MMU_USER_IDX
+/* Try and cause a compile bug on any (invalid) users of the multiple def */
+#undef MMU_USER_IDX
+#else
#define MMU_USER_IDX 2
+#endif
/* See NB_MMU_MODES further up the file. */
int mb_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int rw,
--
1.9.1
- [Qemu-devel] [RFC PATCH 23/34] arm: cpu.h: Move cpu-all include, (continued)
- [Qemu-devel] [RFC PATCH 23/34] arm: cpu.h: Move cpu-all include, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 20/34] configure: Unify arm and aarch64 disas configury, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 18/34] mb: cpu-qom: Put the ENV first, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 19/34] mb: Enable multi-arch, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 21/34] arm: Rename all exceptions, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 16/34] mb: cpu: Guard cpu_init definition for user mode, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 15/34] hw: mb: Explicitly include cpu.h for consumers, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 13/34] mb: cpu: Change phys and virt address ranges., Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 11/34] mb: cpu: Remove MMUx macros, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 14/34] mb: Use qomified tcg defintions, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 17/34] mb: cpu: Multi-define guard deep CPU specifics,
Peter Crosthwaite <=
- [Qemu-devel] [RFC PATCH 08/34] mb: cpu.h: Move cpu-all include, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 12/34] mb: cpu: Move CPU_COMMON to front of env, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 09/34] mb: delete dummy prototypes, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 06/34] mb: rename EXCP macros, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 10/34] HACK: microblaze: rename clz helper, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 05/34] mb: cpu: Delete MMAP_SHIFT definition, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 07/34] mb: Remove ELF_MACHINE from cpu.h, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 03/34] target-multi: Add, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 01/34] cpu-all: Prototype cpu_exec and cpu_signal_handler, Peter Crosthwaite, 2015/05/11
- [Qemu-devel] [RFC PATCH 02/34] tcg+qom: QOMify core CPU defintions, Peter Crosthwaite, 2015/05/11