-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
target-arm: Minimalistic CPU QOM'ification
Introduce only one non-abstract type TYPE_ARM_CPU and do not touch cp15 registers to not interfere with Peter's ongoing remodelling. Embed CPUARMState as first (additional) field of ARMCPU. Let reset call cpu_state_reset() for now. Signed-off-by: Andreas Färber <afaerber@suse.de>
- Loading branch information
Showing
5 changed files
with
134 additions
and
1 deletion.
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,70 @@ | ||
/* | ||
* QEMU ARM CPU | ||
* | ||
* Copyright (c) 2012 SUSE LINUX Products GmbH | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, see | ||
* <http://www.gnu.org/licenses/gpl-2.0.html> | ||
*/ | ||
#ifndef QEMU_ARM_CPU_QOM_H | ||
#define QEMU_ARM_CPU_QOM_H | ||
|
||
#include "qemu/cpu.h" | ||
#include "cpu.h" | ||
|
||
#define TYPE_ARM_CPU "arm-cpu" | ||
|
||
#define ARM_CPU_CLASS(klass) \ | ||
OBJECT_CLASS_CHECK(ARMCPUClass, (klass), TYPE_ARM_CPU) | ||
#define ARM_CPU(obj) \ | ||
OBJECT_CHECK(ARMCPU, (obj), TYPE_ARM_CPU) | ||
#define ARM_CPU_GET_CLASS(obj) \ | ||
OBJECT_GET_CLASS(ARMCPUClass, (obj), TYPE_ARM_CPU) | ||
|
||
/** | ||
* ARMCPUClass: | ||
* | ||
* An ARM CPU model. | ||
*/ | ||
typedef struct ARMCPUClass { | ||
/*< private >*/ | ||
CPUClass parent_class; | ||
/*< public >*/ | ||
|
||
void (*parent_reset)(CPUState *cpu); | ||
} ARMCPUClass; | ||
|
||
/** | ||
* ARMCPU: | ||
* @env: #CPUARMState | ||
* | ||
* An ARM CPU core. | ||
*/ | ||
typedef struct ARMCPU { | ||
/*< private >*/ | ||
CPUState parent_obj; | ||
/*< public >*/ | ||
|
||
CPUARMState env; | ||
} ARMCPU; | ||
|
||
static inline ARMCPU *arm_env_get_cpu(CPUARMState *env) | ||
{ | ||
return ARM_CPU(container_of(env, ARMCPU, env)); | ||
} | ||
|
||
#define ENV_GET_CPU(e) CPU(arm_env_get_cpu(e)) | ||
|
||
|
||
#endif |
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,59 @@ | ||
/* | ||
* QEMU ARM CPU | ||
* | ||
* Copyright (c) 2012 SUSE LINUX Products GmbH | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, see | ||
* <http://www.gnu.org/licenses/gpl-2.0.html> | ||
*/ | ||
|
||
#include "cpu-qom.h" | ||
#include "qemu-common.h" | ||
|
||
static void arm_cpu_reset(CPUState *c) | ||
{ | ||
ARMCPU *cpu = ARM_CPU(c); | ||
ARMCPUClass *class = ARM_CPU_GET_CLASS(cpu); | ||
|
||
class->parent_reset(c); | ||
|
||
/* TODO Drop this in favor of cpu_arm_reset() calling cpu_reset() | ||
* once cpu_reset_model_id() is gone. */ | ||
cpu_state_reset(&cpu->env); | ||
} | ||
|
||
static void arm_cpu_class_init(ObjectClass *c, void *data) | ||
{ | ||
ARMCPUClass *class = ARM_CPU_CLASS(c); | ||
CPUClass *cpu_class = CPU_CLASS(class); | ||
|
||
class->parent_reset = cpu_class->reset; | ||
cpu_class->reset = arm_cpu_reset; | ||
} | ||
|
||
static const TypeInfo arm_cpu_type_info = { | ||
.name = TYPE_ARM_CPU, | ||
.parent = TYPE_CPU, | ||
.instance_size = sizeof(ARMCPU), | ||
.abstract = false, /* TODO Reconsider once cp15 reworked. */ | ||
.class_size = sizeof(ARMCPUClass), | ||
.class_init = arm_cpu_class_init, | ||
}; | ||
|
||
static void arm_cpu_register_types(void) | ||
{ | ||
type_register_static(&arm_cpu_type_info); | ||
} | ||
|
||
type_init(arm_cpu_register_types) |
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