[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH v1 08/11] qom/cpu: Add Memory Region Property
From: |
Peter Crosthwaite |
Subject: |
[Qemu-devel] [RFC PATCH v1 08/11] qom/cpu: Add Memory Region Property |
Date: |
Mon, 2 Jun 2014 19:10:59 -0700 |
Which is used to construct a per-CPU address space. The Address space
is constructed ASAP from the MemoryRegion property setter itself.
Signed-off-by: Peter Crosthwaite <address@hidden>
---
include/qom/cpu.h | 1 +
qom/cpu.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index df977c8..4f6a4ee 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -237,6 +237,7 @@ struct CPUState {
int64_t icount_extra;
sigjmp_buf jmp_env;
+ MemoryRegion *mr;
AddressSpace *as;
MemoryListener *tcg_as_listener;
diff --git a/qom/cpu.c b/qom/cpu.c
index fada2d4..433e627 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -25,6 +25,8 @@
#include "qemu/log.h"
#include "qemu/error-report.h"
#include "sysemu/sysemu.h"
+#include "exec/memory.h"
+#include "qapi/visitor.h"
bool cpu_exists(int64_t id)
{
@@ -303,12 +305,40 @@ static void cpu_common_realizefn(DeviceState *dev, Error
**errp)
}
}
+static void cpu_set_mr(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ CPUState *cpu = CPU(obj);
+ Error *local_err = NULL;
+ char *path = NULL;
+
+ visit_type_str(v, &path, name, &local_err);
+
+ if (!local_err && strcmp(path, "") != 0) {
+ cpu->mr = MEMORY_REGION(object_resolve_link(obj, name, path,
+ &local_err));
+ }
+
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return;
+ }
+
+ object_ref(OBJECT(cpu->mr));
+ cpu->as = address_space_init_shareable(cpu->mr, NULL);
+}
+
static void cpu_common_initfn(Object *obj)
{
CPUState *cpu = CPU(obj);
CPUClass *cc = CPU_GET_CLASS(obj);
cpu->gdb_num_regs = cpu->gdb_num_g_regs = cc->gdb_num_core_regs;
+ object_property_add(obj, "mr", "link<" TYPE_MEMORY_REGION ">",
+ NULL, /* FIXME: Implement the getter */
+ cpu_set_mr,
+ NULL, /* FIXME: Implement the cleanup */
+ NULL, &error_abort);
}
static int64_t cpu_common_get_arch_id(CPUState *cpu)
--
2.0.0
- [Qemu-devel] [RFC PATCH v1 00/11] Per Master Addressing (PMA), Peter Crosthwaite, 2014/06/02
- [Qemu-devel] [RFC PATCH v1 01/11] microblaze: ml605: Get rid of useless ddr_base variable, Peter Crosthwaite, 2014/06/02
- [Qemu-devel] [RFC PATCH v1 02/11] dma: axidma: Variablise repeated s->streams[i] sub-expr, Peter Crosthwaite, 2014/06/02
- [Qemu-devel] [RFC PATCH v1 03/11] exec: Parent root MRs to the machine, Peter Crosthwaite, 2014/06/02
- [Qemu-devel] [RFC PATCH v1 04/11] exec: dummy_section: Pass address space through., Peter Crosthwaite, 2014/06/02
- [Qemu-devel] [RFC PATCH v1 05/11] memory: Parent Memory Regions to their registered owners, Peter Crosthwaite, 2014/06/02
- [Qemu-devel] [RFC PATCH v1 06/11] memory: address_space_init: do nothing if no root region given, Peter Crosthwaite, 2014/06/02
- [Qemu-devel] [RFC PATCH v1 07/11] memory.c: Add address_space_init_shareable(), Peter Crosthwaite, 2014/06/02
- [Qemu-devel] [RFC PATCH v1 08/11] qom/cpu: Add Memory Region Property,
Peter Crosthwaite <=
- [Qemu-devel] [RFC PATCH v1 09/11] exec: use per-cpu address-spaces for cpuisms, Peter Crosthwaite, 2014/06/02
- [Qemu-devel] [RFC PATCH v1 10/11] microblaze: ml605: Convert to PMA, Peter Crosthwaite, 2014/06/02
- [Qemu-devel] [RFC PATCH v1 11/11] dma: axidma: Convert to PMA, Peter Crosthwaite, 2014/06/02
- Re: [Qemu-devel] [RFC PATCH v1 00/11] Per Master Addressing (PMA), Paolo Bonzini, 2014/06/03
- Re: [Qemu-devel] [RFC PATCH v1 00/11] Per Master Addressing (PMA), Peter Maydell, 2014/06/03