aboutsummaryrefslogtreecommitdiff
path: root/target/mips/cpu.c
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <f4bug@amsat.org>2020-10-12 11:57:55 +0200
committerPhilippe Mathieu-Daudé <f4bug@amsat.org>2020-10-17 13:59:40 +0200
commit7aaab96a9b1c37f473f73363ff815eb059a2f823 (patch)
treef9f9f2c2fd64269a996f0991e8a701ba11d42a40 /target/mips/cpu.c
parenta0713e85bfaec4d787b978640096322716938a56 (diff)
downloadqemu-7aaab96a9b1c37f473f73363ff815eb059a2f823.zip
qemu-7aaab96a9b1c37f473f73363ff815eb059a2f823.tar.gz
qemu-7aaab96a9b1c37f473f73363ff815eb059a2f823.tar.bz2
target/mips/cpu: Introduce mips_cpu_create_with_clock() helper
Introduce an helper to create a MIPS CPU and connect it to a reference clock. This helper is not MIPS specific, but so far only MIPS CPUs need it. Suggested-by: Huacai Chen <zltjiangshi@gmail.com> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20201012095804.3335117-13-f4bug@amsat.org>
Diffstat (limited to 'target/mips/cpu.c')
-rw-r--r--target/mips/cpu.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/target/mips/cpu.c b/target/mips/cpu.c
index 2a6f484..33a9ed5 100644
--- a/target/mips/cpu.c
+++ b/target/mips/cpu.c
@@ -288,3 +288,15 @@ static void mips_cpu_register_types(void)
}
type_init(mips_cpu_register_types)
+
+/* Could be used by generic CPU object */
+MIPSCPU *mips_cpu_create_with_clock(const char *cpu_type, Clock *cpu_refclk)
+{
+ DeviceState *cpu;
+
+ cpu = DEVICE(object_new(cpu_type));
+ qdev_connect_clock_in(cpu, "clk-in", cpu_refclk);
+ qdev_realize(cpu, NULL, &error_abort);
+
+ return MIPS_CPU(cpu);
+}