mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge remote-tracking branch 'afaerber/qom-cpu' into staging
# By Andreas Färber
# Via Andreas Färber
* afaerber/qom-cpu: (47 commits)
target-i386: Split command line parsing out of cpu_x86_register()
target-i386: Move cpu_x86_init()
target-lm32: Drop unused cpu_lm32_close() prototype
target-s390x: Drop unused cpu_s390x_close() prototype
spapr_hcall: Replace open-coded CPU loop with qemu_get_cpu()
ppce500_spin: Replace open-coded CPU loop with qemu_get_cpu()
e500: Replace open-coded loop with qemu_get_cpu()
cpu: Add CPUArchState pointer to CPUState
cputlb: Pass CPUState to cpu_unlink_tb()
cpu: Move current_tb field to CPUState
cpu: Move exit_request field to CPUState
cpu: Move running field to CPUState
cpu: Move host_tid field to CPUState
target-cris: Introduce CRISCPU subclasses
target-m68k: Pass M68kCPU to m68k_set_irq_level()
mcf_intc: Pass M68kCPU to mcf_intc_init()
mcf5206: Pass M68kCPU to mcf5206_init()
target-m68k: Return M68kCPU from cpu_m68k_init()
ppc405_uc: Pass PowerPCCPU to ppc40x_{core,chip,system}_reset()
target-xtensa: Move TCG initialization to XtensaCPU initfn
...
This commit is contained in:
+12
-9
@@ -32,7 +32,9 @@ bool qemu_cpu_has_work(CPUState *cpu)
|
||||
|
||||
void cpu_loop_exit(CPUArchState *env)
|
||||
{
|
||||
env->current_tb = NULL;
|
||||
CPUState *cpu = ENV_GET_CPU(env);
|
||||
|
||||
cpu->current_tb = NULL;
|
||||
longjmp(env->jmp_env, 1);
|
||||
}
|
||||
|
||||
@@ -54,6 +56,7 @@ void cpu_resume_from_signal(CPUArchState *env, void *puc)
|
||||
static void cpu_exec_nocache(CPUArchState *env, int max_cycles,
|
||||
TranslationBlock *orig_tb)
|
||||
{
|
||||
CPUState *cpu = ENV_GET_CPU(env);
|
||||
tcg_target_ulong next_tb;
|
||||
TranslationBlock *tb;
|
||||
|
||||
@@ -64,10 +67,10 @@ static void cpu_exec_nocache(CPUArchState *env, int max_cycles,
|
||||
|
||||
tb = tb_gen_code(env, orig_tb->pc, orig_tb->cs_base, orig_tb->flags,
|
||||
max_cycles);
|
||||
env->current_tb = tb;
|
||||
cpu->current_tb = tb;
|
||||
/* execute the generated code */
|
||||
next_tb = tcg_qemu_tb_exec(env, tb->tc_ptr);
|
||||
env->current_tb = NULL;
|
||||
cpu->current_tb = NULL;
|
||||
|
||||
if ((next_tb & 3) == 2) {
|
||||
/* Restore PC. This may happen if async event occurs before
|
||||
@@ -196,7 +199,7 @@ int cpu_exec(CPUArchState *env)
|
||||
cpu_single_env = env;
|
||||
|
||||
if (unlikely(exit_request)) {
|
||||
env->exit_request = 1;
|
||||
cpu->exit_request = 1;
|
||||
}
|
||||
|
||||
#if defined(TARGET_I386)
|
||||
@@ -537,8 +540,8 @@ int cpu_exec(CPUArchState *env)
|
||||
next_tb = 0;
|
||||
}
|
||||
}
|
||||
if (unlikely(env->exit_request)) {
|
||||
env->exit_request = 0;
|
||||
if (unlikely(cpu->exit_request)) {
|
||||
cpu->exit_request = 0;
|
||||
env->exception_index = EXCP_INTERRUPT;
|
||||
cpu_loop_exit(env);
|
||||
}
|
||||
@@ -589,9 +592,9 @@ int cpu_exec(CPUArchState *env)
|
||||
TB, but before it is linked into a potentially
|
||||
infinite loop and becomes env->current_tb. Avoid
|
||||
starting execution if there is a pending interrupt. */
|
||||
env->current_tb = tb;
|
||||
cpu->current_tb = tb;
|
||||
barrier();
|
||||
if (likely(!env->exit_request)) {
|
||||
if (likely(!cpu->exit_request)) {
|
||||
tc_ptr = tb->tc_ptr;
|
||||
/* execute the generated code */
|
||||
next_tb = tcg_qemu_tb_exec(env, tc_ptr);
|
||||
@@ -623,7 +626,7 @@ int cpu_exec(CPUArchState *env)
|
||||
}
|
||||
}
|
||||
}
|
||||
env->current_tb = NULL;
|
||||
cpu->current_tb = NULL;
|
||||
/* reset soft MMU for next block (it can currently
|
||||
only be set by a memory fault) */
|
||||
} /* for(;;) */
|
||||
|
||||
@@ -54,6 +54,7 @@ static const CPUTLBEntry s_cputlb_empty_entry = {
|
||||
*/
|
||||
void tlb_flush(CPUArchState *env, int flush_global)
|
||||
{
|
||||
CPUState *cpu = ENV_GET_CPU(env);
|
||||
int i;
|
||||
|
||||
#if defined(DEBUG_TLB)
|
||||
@@ -61,7 +62,7 @@ void tlb_flush(CPUArchState *env, int flush_global)
|
||||
#endif
|
||||
/* must reset current TB so that interrupts cannot modify the
|
||||
links while we are modifying them */
|
||||
env->current_tb = NULL;
|
||||
cpu->current_tb = NULL;
|
||||
|
||||
for (i = 0; i < CPU_TLB_SIZE; i++) {
|
||||
int mmu_idx;
|
||||
@@ -92,6 +93,7 @@ static inline void tlb_flush_entry(CPUTLBEntry *tlb_entry, target_ulong addr)
|
||||
|
||||
void tlb_flush_page(CPUArchState *env, target_ulong addr)
|
||||
{
|
||||
CPUState *cpu = ENV_GET_CPU(env);
|
||||
int i;
|
||||
int mmu_idx;
|
||||
|
||||
@@ -110,7 +112,7 @@ void tlb_flush_page(CPUArchState *env, target_ulong addr)
|
||||
}
|
||||
/* must reset current TB so that interrupts cannot modify the
|
||||
links while we are modifying them */
|
||||
env->current_tb = NULL;
|
||||
cpu->current_tb = NULL;
|
||||
|
||||
addr &= TARGET_PAGE_MASK;
|
||||
i = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
|
||||
|
||||
@@ -271,11 +271,13 @@ static int write_elf64_note(DumpState *s)
|
||||
static int write_elf64_notes(DumpState *s)
|
||||
{
|
||||
CPUArchState *env;
|
||||
CPUState *cpu;
|
||||
int ret;
|
||||
int id;
|
||||
|
||||
for (env = first_cpu; env != NULL; env = env->next_cpu) {
|
||||
id = cpu_index(env);
|
||||
cpu = ENV_GET_CPU(env);
|
||||
id = cpu_index(cpu);
|
||||
ret = cpu_write_elf64_note(fd_write_vmcore, env, id, s);
|
||||
if (ret < 0) {
|
||||
dump_error(s, "dump: failed to write elf notes.\n");
|
||||
@@ -321,11 +323,13 @@ static int write_elf32_note(DumpState *s)
|
||||
static int write_elf32_notes(DumpState *s)
|
||||
{
|
||||
CPUArchState *env;
|
||||
CPUState *cpu;
|
||||
int ret;
|
||||
int id;
|
||||
|
||||
for (env = first_cpu; env != NULL; env = env->next_cpu) {
|
||||
id = cpu_index(env);
|
||||
cpu = ENV_GET_CPU(env);
|
||||
id = cpu_index(cpu);
|
||||
ret = cpu_write_elf32_note(fd_write_vmcore, env, id, s);
|
||||
if (ret < 0) {
|
||||
dump_error(s, "dump: failed to write elf notes.\n");
|
||||
|
||||
@@ -492,8 +492,10 @@ void cpu_reset_interrupt(CPUArchState *env, int mask)
|
||||
|
||||
void cpu_exit(CPUArchState *env)
|
||||
{
|
||||
env->exit_request = 1;
|
||||
cpu_unlink_tb(env);
|
||||
CPUState *cpu = ENV_GET_CPU(env);
|
||||
|
||||
cpu->exit_request = 1;
|
||||
cpu_unlink_tb(cpu);
|
||||
}
|
||||
|
||||
void cpu_abort(CPUArchState *env, const char *fmt, ...)
|
||||
|
||||
@@ -2066,9 +2066,11 @@ static void gdb_set_cpu_pc(GDBState *s, target_ulong pc)
|
||||
static CPUArchState *find_cpu(uint32_t thread_id)
|
||||
{
|
||||
CPUArchState *env;
|
||||
CPUState *cpu;
|
||||
|
||||
for (env = first_cpu; env != NULL; env = env->next_cpu) {
|
||||
if (cpu_index(env) == thread_id) {
|
||||
cpu = ENV_GET_CPU(env);
|
||||
if (cpu_index(cpu) == thread_id) {
|
||||
return env;
|
||||
}
|
||||
}
|
||||
@@ -2096,7 +2098,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
|
||||
case '?':
|
||||
/* TODO: Make this return the correct value for user-mode. */
|
||||
snprintf(buf, sizeof(buf), "T%02xthread:%02x;", GDB_SIGNAL_TRAP,
|
||||
cpu_index(s->c_cpu));
|
||||
cpu_index(ENV_GET_CPU(s->c_cpu)));
|
||||
put_packet(s, buf);
|
||||
/* Remove all the breakpoints when this query is issued,
|
||||
* because gdb is doing and initial connect and the state
|
||||
@@ -2391,7 +2393,8 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
|
||||
} else if (strcmp(p,"sThreadInfo") == 0) {
|
||||
report_cpuinfo:
|
||||
if (s->query_cpu) {
|
||||
snprintf(buf, sizeof(buf), "m%x", cpu_index(s->query_cpu));
|
||||
snprintf(buf, sizeof(buf), "m%x",
|
||||
cpu_index(ENV_GET_CPU(s->query_cpu)));
|
||||
put_packet(s, buf);
|
||||
s->query_cpu = s->query_cpu->next_cpu;
|
||||
} else
|
||||
@@ -2512,6 +2515,7 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state)
|
||||
{
|
||||
GDBState *s = gdbserver_state;
|
||||
CPUArchState *env = s->c_cpu;
|
||||
CPUState *cpu = ENV_GET_CPU(env);
|
||||
char buf[256];
|
||||
const char *type;
|
||||
int ret;
|
||||
@@ -2540,7 +2544,7 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state)
|
||||
}
|
||||
snprintf(buf, sizeof(buf),
|
||||
"T%02xthread:%02x;%swatch:" TARGET_FMT_lx ";",
|
||||
GDB_SIGNAL_TRAP, cpu_index(env), type,
|
||||
GDB_SIGNAL_TRAP, cpu_index(cpu), type,
|
||||
env->watchpoint_hit->vaddr);
|
||||
env->watchpoint_hit = NULL;
|
||||
goto send_packet;
|
||||
@@ -2573,7 +2577,7 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state)
|
||||
ret = GDB_SIGNAL_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
snprintf(buf, sizeof(buf), "T%02xthread:%02x;", ret, cpu_index(env));
|
||||
snprintf(buf, sizeof(buf), "T%02xthread:%02x;", ret, cpu_index(cpu));
|
||||
|
||||
send_packet:
|
||||
put_packet(s, buf);
|
||||
|
||||
+7
-4
@@ -24,6 +24,7 @@ static void an5206_init(QEMUMachineInitArgs *args)
|
||||
ram_addr_t ram_size = args->ram_size;
|
||||
const char *cpu_model = args->cpu_model;
|
||||
const char *kernel_filename = args->kernel_filename;
|
||||
M68kCPU *cpu;
|
||||
CPUM68KState *env;
|
||||
int kernel_size;
|
||||
uint64_t elf_entry;
|
||||
@@ -32,12 +33,14 @@ static void an5206_init(QEMUMachineInitArgs *args)
|
||||
MemoryRegion *ram = g_new(MemoryRegion, 1);
|
||||
MemoryRegion *sram = g_new(MemoryRegion, 1);
|
||||
|
||||
if (!cpu_model)
|
||||
if (!cpu_model) {
|
||||
cpu_model = "m5206";
|
||||
env = cpu_init(cpu_model);
|
||||
if (!env) {
|
||||
}
|
||||
cpu = cpu_m68k_init(cpu_model);
|
||||
if (!cpu) {
|
||||
hw_error("Unable to find m68k CPU definition\n");
|
||||
}
|
||||
env = &cpu->env;
|
||||
|
||||
/* Initialize CPU registers. */
|
||||
env->vbr = 0;
|
||||
@@ -55,7 +58,7 @@ static void an5206_init(QEMUMachineInitArgs *args)
|
||||
vmstate_register_ram_global(sram);
|
||||
memory_region_add_subregion(address_space_mem, AN5206_RAMBAR_ADDR, sram);
|
||||
|
||||
mcf5206_init(address_space_mem, AN5206_MBAR_ADDR, env);
|
||||
mcf5206_init(address_space_mem, AN5206_MBAR_ADDR, cpu);
|
||||
|
||||
/* Load kernel. */
|
||||
if (!kernel_filename) {
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ void apic_handle_tpr_access_report(DeviceState *d, target_ulong ip,
|
||||
{
|
||||
APICCommonState *s = DO_UPCAST(APICCommonState, busdev.qdev, d);
|
||||
|
||||
vapic_report_tpr_access(s->vapic, &s->cpu->env, ip, access);
|
||||
vapic_report_tpr_access(s->vapic, CPU(s->cpu), ip, access);
|
||||
}
|
||||
|
||||
void apic_report_irq_delivered(int delivered)
|
||||
|
||||
+1
-1
@@ -143,7 +143,7 @@ bool apic_next_timer(APICCommonState *s, int64_t current_time);
|
||||
void apic_enable_tpr_access_reporting(DeviceState *d, bool enable);
|
||||
void apic_enable_vapic(DeviceState *d, hwaddr paddr);
|
||||
|
||||
void vapic_report_tpr_access(DeviceState *dev, void *cpu, target_ulong ip,
|
||||
void vapic_report_tpr_access(DeviceState *dev, CPUState *cpu, target_ulong ip,
|
||||
TPRAccess access);
|
||||
|
||||
#endif /* !QEMU_APIC_INTERNAL_H */
|
||||
|
||||
+8
-5
@@ -382,8 +382,10 @@ static void patch_call(VAPICROMState *s, CPUX86State *env, target_ulong ip,
|
||||
cpu_memory_rw_debug(env, ip + 1, (void *)&offset, sizeof(offset), 1);
|
||||
}
|
||||
|
||||
static void patch_instruction(VAPICROMState *s, CPUX86State *env, target_ulong ip)
|
||||
static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
|
||||
{
|
||||
CPUState *cs = CPU(cpu);
|
||||
CPUX86State *env = &cpu->env;
|
||||
VAPICHandlers *handlers;
|
||||
uint8_t opcode[2];
|
||||
uint32_t imm32;
|
||||
@@ -439,17 +441,18 @@ static void patch_instruction(VAPICROMState *s, CPUX86State *env, target_ulong i
|
||||
resume_all_vcpus();
|
||||
|
||||
if (!kvm_enabled()) {
|
||||
env->current_tb = NULL;
|
||||
cs->current_tb = NULL;
|
||||
tb_gen_code(env, current_pc, current_cs_base, current_flags, 1);
|
||||
cpu_resume_from_signal(env, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void vapic_report_tpr_access(DeviceState *dev, void *cpu, target_ulong ip,
|
||||
void vapic_report_tpr_access(DeviceState *dev, CPUState *cs, target_ulong ip,
|
||||
TPRAccess access)
|
||||
{
|
||||
VAPICROMState *s = DO_UPCAST(VAPICROMState, busdev.qdev, dev);
|
||||
CPUX86State *env = cpu;
|
||||
X86CPU *cpu = X86_CPU(cs);
|
||||
CPUX86State *env = &cpu->env;
|
||||
|
||||
cpu_synchronize_state(env);
|
||||
|
||||
@@ -465,7 +468,7 @@ void vapic_report_tpr_access(DeviceState *dev, void *cpu, target_ulong ip,
|
||||
if (vapic_enable(s, env) < 0) {
|
||||
return;
|
||||
}
|
||||
patch_instruction(s, env, ip);
|
||||
patch_instruction(s, cpu, ip);
|
||||
}
|
||||
|
||||
typedef struct VAPICEnableTPRReporting {
|
||||
|
||||
@@ -17,7 +17,7 @@ void mcf_uart_mm_init(struct MemoryRegion *sysmem,
|
||||
/* mcf_intc.c */
|
||||
qemu_irq *mcf_intc_init(struct MemoryRegion *sysmem,
|
||||
hwaddr base,
|
||||
CPUM68KState *env);
|
||||
M68kCPU *cpu);
|
||||
|
||||
/* mcf_fec.c */
|
||||
void mcf_fec_init(struct MemoryRegion *sysmem, NICInfo *nd,
|
||||
@@ -25,6 +25,6 @@ void mcf_fec_init(struct MemoryRegion *sysmem, NICInfo *nd,
|
||||
|
||||
/* mcf5206.c */
|
||||
qemu_irq *mcf5206_init(struct MemoryRegion *sysmem,
|
||||
uint32_t base, CPUM68KState *env);
|
||||
uint32_t base, M68kCPU *cpu);
|
||||
|
||||
#endif
|
||||
|
||||
+4
-4
@@ -145,7 +145,7 @@ static m5206_timer_state *m5206_timer_init(qemu_irq irq)
|
||||
/* System Integration Module. */
|
||||
|
||||
typedef struct {
|
||||
CPUM68KState *env;
|
||||
M68kCPU *cpu;
|
||||
MemoryRegion iomem;
|
||||
m5206_timer_state *timer[2];
|
||||
void *uart[2];
|
||||
@@ -226,7 +226,7 @@ static void m5206_mbar_update(m5206_mbar_state *s)
|
||||
level = 0;
|
||||
vector = 0;
|
||||
}
|
||||
m68k_set_irq_level(s->env, level, vector);
|
||||
m68k_set_irq_level(s->cpu, level, vector);
|
||||
}
|
||||
|
||||
static void m5206_mbar_set_irq(void *opaque, int irq, int level)
|
||||
@@ -525,7 +525,7 @@ static const MemoryRegionOps m5206_mbar_ops = {
|
||||
.endianness = DEVICE_NATIVE_ENDIAN,
|
||||
};
|
||||
|
||||
qemu_irq *mcf5206_init(MemoryRegion *sysmem, uint32_t base, CPUM68KState *env)
|
||||
qemu_irq *mcf5206_init(MemoryRegion *sysmem, uint32_t base, M68kCPU *cpu)
|
||||
{
|
||||
m5206_mbar_state *s;
|
||||
qemu_irq *pic;
|
||||
@@ -541,7 +541,7 @@ qemu_irq *mcf5206_init(MemoryRegion *sysmem, uint32_t base, CPUM68KState *env)
|
||||
s->timer[1] = m5206_timer_init(pic[10]);
|
||||
s->uart[0] = mcf_uart_init(pic[12], serial_hds[0]);
|
||||
s->uart[1] = mcf_uart_init(pic[13], serial_hds[1]);
|
||||
s->env = env;
|
||||
s->cpu = cpu;
|
||||
|
||||
m5206_mbar_reset(s);
|
||||
return pic;
|
||||
|
||||
+7
-4
@@ -192,6 +192,7 @@ static void mcf5208evb_init(QEMUMachineInitArgs *args)
|
||||
ram_addr_t ram_size = args->ram_size;
|
||||
const char *cpu_model = args->cpu_model;
|
||||
const char *kernel_filename = args->kernel_filename;
|
||||
M68kCPU *cpu;
|
||||
CPUM68KState *env;
|
||||
int kernel_size;
|
||||
uint64_t elf_entry;
|
||||
@@ -201,13 +202,15 @@ static void mcf5208evb_init(QEMUMachineInitArgs *args)
|
||||
MemoryRegion *ram = g_new(MemoryRegion, 1);
|
||||
MemoryRegion *sram = g_new(MemoryRegion, 1);
|
||||
|
||||
if (!cpu_model)
|
||||
if (!cpu_model) {
|
||||
cpu_model = "m5208";
|
||||
env = cpu_init(cpu_model);
|
||||
if (!env) {
|
||||
}
|
||||
cpu = cpu_m68k_init(cpu_model);
|
||||
if (!cpu) {
|
||||
fprintf(stderr, "Unable to find m68k CPU definition\n");
|
||||
exit(1);
|
||||
}
|
||||
env = &cpu->env;
|
||||
|
||||
/* Initialize CPU registers. */
|
||||
env->vbr = 0;
|
||||
@@ -224,7 +227,7 @@ static void mcf5208evb_init(QEMUMachineInitArgs *args)
|
||||
memory_region_add_subregion(address_space_mem, 0x80000000, sram);
|
||||
|
||||
/* Internal peripherals. */
|
||||
pic = mcf_intc_init(address_space_mem, 0xfc048000, env);
|
||||
pic = mcf_intc_init(address_space_mem, 0xfc048000, cpu);
|
||||
|
||||
mcf_uart_mm_init(address_space_mem, 0xfc060000, pic[26], serial_hds[0]);
|
||||
mcf_uart_mm_init(address_space_mem, 0xfc064000, pic[27], serial_hds[1]);
|
||||
|
||||
+4
-4
@@ -16,7 +16,7 @@ typedef struct {
|
||||
uint64_t ifr;
|
||||
uint64_t enabled;
|
||||
uint8_t icr[64];
|
||||
CPUM68KState *env;
|
||||
M68kCPU *cpu;
|
||||
int active_vector;
|
||||
} mcf_intc_state;
|
||||
|
||||
@@ -40,7 +40,7 @@ static void mcf_intc_update(mcf_intc_state *s)
|
||||
}
|
||||
}
|
||||
s->active_vector = ((best == 64) ? 24 : (best + 64));
|
||||
m68k_set_irq_level(s->env, best_level, s->active_vector);
|
||||
m68k_set_irq_level(s->cpu, best_level, s->active_vector);
|
||||
}
|
||||
|
||||
static uint64_t mcf_intc_read(void *opaque, hwaddr addr,
|
||||
@@ -139,12 +139,12 @@ static const MemoryRegionOps mcf_intc_ops = {
|
||||
|
||||
qemu_irq *mcf_intc_init(MemoryRegion *sysmem,
|
||||
hwaddr base,
|
||||
CPUM68KState *env)
|
||||
M68kCPU *cpu)
|
||||
{
|
||||
mcf_intc_state *s;
|
||||
|
||||
s = g_malloc0(sizeof(mcf_intc_state));
|
||||
s->env = env;
|
||||
s->cpu = cpu;
|
||||
mcf_intc_reset(s);
|
||||
|
||||
memory_region_init_io(&s->iomem, &mcf_intc_ops, s, "mcf", 0x100);
|
||||
|
||||
@@ -876,7 +876,6 @@ void pc_cpus_init(const char *cpu_model)
|
||||
|
||||
for (i = 0; i < smp_cpus; i++) {
|
||||
if (!cpu_x86_init(cpu_model)) {
|
||||
fprintf(stderr, "Unable to find x86 CPU definition\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,20 +300,20 @@ static void ppc40x_set_irq(void *opaque, int pin, int level)
|
||||
if (level) {
|
||||
LOG_IRQ("%s: reset the PowerPC system\n",
|
||||
__func__);
|
||||
ppc40x_system_reset(env);
|
||||
ppc40x_system_reset(cpu);
|
||||
}
|
||||
break;
|
||||
case PPC40x_INPUT_RESET_CHIP:
|
||||
if (level) {
|
||||
LOG_IRQ("%s: reset the PowerPC chip\n", __func__);
|
||||
ppc40x_chip_reset(env);
|
||||
ppc40x_chip_reset(cpu);
|
||||
}
|
||||
break;
|
||||
case PPC40x_INPUT_RESET_CORE:
|
||||
/* XXX: TODO: update DBSR[MRR] */
|
||||
if (level) {
|
||||
LOG_IRQ("%s: reset the PowerPC core\n", __func__);
|
||||
ppc40x_core_reset(env);
|
||||
ppc40x_core_reset(cpu);
|
||||
}
|
||||
break;
|
||||
case PPC40x_INPUT_CINT:
|
||||
@@ -1011,13 +1011,13 @@ static void cpu_4xx_wdt_cb (void *opaque)
|
||||
/* No reset */
|
||||
break;
|
||||
case 0x1: /* Core reset */
|
||||
ppc40x_core_reset(env);
|
||||
ppc40x_core_reset(cpu);
|
||||
break;
|
||||
case 0x2: /* Chip reset */
|
||||
ppc40x_chip_reset(env);
|
||||
ppc40x_chip_reset(cpu);
|
||||
break;
|
||||
case 0x3: /* System reset */
|
||||
ppc40x_system_reset(env);
|
||||
ppc40x_system_reset(cpu);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,9 +58,9 @@ clk_setup_cb ppc_40x_timers_init (CPUPPCState *env, uint32_t freq,
|
||||
unsigned int decr_excp);
|
||||
|
||||
/* Embedded PowerPC reset */
|
||||
void ppc40x_core_reset (CPUPPCState *env);
|
||||
void ppc40x_chip_reset (CPUPPCState *env);
|
||||
void ppc40x_system_reset (CPUPPCState *env);
|
||||
void ppc40x_core_reset(PowerPCCPU *cpu);
|
||||
void ppc40x_chip_reset(PowerPCCPU *cpu);
|
||||
void ppc40x_system_reset(PowerPCCPU *cpu);
|
||||
void PREP_debug_write (void *opaque, uint32_t addr, uint32_t val);
|
||||
|
||||
extern CPUWriteMemoryFunc * const PPC_io_write[];
|
||||
|
||||
+3
-8
@@ -240,20 +240,15 @@ static int ppce500_load_device_tree(CPUPPCState *env,
|
||||
/* We need to generate the cpu nodes in reverse order, so Linux can pick
|
||||
the first node as boot node and be happy */
|
||||
for (i = smp_cpus - 1; i >= 0; i--) {
|
||||
CPUState *cpu = NULL;
|
||||
CPUState *cpu;
|
||||
char cpu_name[128];
|
||||
uint64_t cpu_release_addr = MPC8544_SPIN_BASE + (i * 0x20);
|
||||
|
||||
for (env = first_cpu; env != NULL; env = env->next_cpu) {
|
||||
cpu = ENV_GET_CPU(env);
|
||||
if (cpu->cpu_index == i) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cpu = qemu_get_cpu(i);
|
||||
if (cpu == NULL) {
|
||||
continue;
|
||||
}
|
||||
env = cpu->env_ptr;
|
||||
|
||||
snprintf(cpu_name, sizeof(cpu_name), "/cpus/PowerPC,8544@%x",
|
||||
cpu->cpu_index);
|
||||
|
||||
+10
-6
@@ -1770,8 +1770,9 @@ static void ppc405_mal_init(CPUPPCState *env, qemu_irq irqs[4])
|
||||
|
||||
/*****************************************************************************/
|
||||
/* SPR */
|
||||
void ppc40x_core_reset (CPUPPCState *env)
|
||||
void ppc40x_core_reset(PowerPCCPU *cpu)
|
||||
{
|
||||
CPUPPCState *env = &cpu->env;
|
||||
target_ulong dbsr;
|
||||
|
||||
printf("Reset PowerPC core\n");
|
||||
@@ -1782,8 +1783,9 @@ void ppc40x_core_reset (CPUPPCState *env)
|
||||
env->spr[SPR_40x_DBSR] = dbsr;
|
||||
}
|
||||
|
||||
void ppc40x_chip_reset (CPUPPCState *env)
|
||||
void ppc40x_chip_reset(PowerPCCPU *cpu)
|
||||
{
|
||||
CPUPPCState *env = &cpu->env;
|
||||
target_ulong dbsr;
|
||||
|
||||
printf("Reset PowerPC chip\n");
|
||||
@@ -1795,7 +1797,7 @@ void ppc40x_chip_reset (CPUPPCState *env)
|
||||
env->spr[SPR_40x_DBSR] = dbsr;
|
||||
}
|
||||
|
||||
void ppc40x_system_reset (CPUPPCState *env)
|
||||
void ppc40x_system_reset(PowerPCCPU *cpu)
|
||||
{
|
||||
printf("Reset PowerPC system\n");
|
||||
qemu_system_reset_request();
|
||||
@@ -1803,21 +1805,23 @@ void ppc40x_system_reset (CPUPPCState *env)
|
||||
|
||||
void store_40x_dbcr0 (CPUPPCState *env, uint32_t val)
|
||||
{
|
||||
PowerPCCPU *cpu = ppc_env_get_cpu(env);
|
||||
|
||||
switch ((val >> 28) & 0x3) {
|
||||
case 0x0:
|
||||
/* No action */
|
||||
break;
|
||||
case 0x1:
|
||||
/* Core reset */
|
||||
ppc40x_core_reset(env);
|
||||
ppc40x_core_reset(cpu);
|
||||
break;
|
||||
case 0x2:
|
||||
/* Chip reset */
|
||||
ppc40x_chip_reset(env);
|
||||
ppc40x_chip_reset(cpu);
|
||||
break;
|
||||
case 0x3:
|
||||
/* System reset */
|
||||
ppc40x_system_reset(env);
|
||||
ppc40x_system_reset(cpu);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-11
@@ -123,18 +123,11 @@ static void spin_write(void *opaque, hwaddr addr, uint64_t value,
|
||||
{
|
||||
SpinState *s = opaque;
|
||||
int env_idx = addr / sizeof(SpinInfo);
|
||||
CPUPPCState *env;
|
||||
CPUState *cpu = NULL;
|
||||
CPUState *cpu;
|
||||
SpinInfo *curspin = &s->spin[env_idx];
|
||||
uint8_t *curspin_p = (uint8_t*)curspin;
|
||||
|
||||
for (env = first_cpu; env != NULL; env = env->next_cpu) {
|
||||
cpu = CPU(ppc_env_get_cpu(env));
|
||||
if (cpu->cpu_index == env_idx) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cpu = qemu_get_cpu(env_idx);
|
||||
if (cpu == NULL) {
|
||||
/* Unknown CPU */
|
||||
return;
|
||||
@@ -161,11 +154,11 @@ static void spin_write(void *opaque, hwaddr addr, uint64_t value,
|
||||
if (!(ldq_p(&curspin->addr) & 1)) {
|
||||
/* run CPU */
|
||||
SpinKick kick = {
|
||||
.cpu = ppc_env_get_cpu(env),
|
||||
.cpu = POWERPC_CPU(cpu),
|
||||
.spin = curspin,
|
||||
};
|
||||
|
||||
run_on_cpu(CPU(kick.cpu), spin_kick, &kick);
|
||||
run_on_cpu(cpu, spin_kick, &kick);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-10
@@ -469,16 +469,11 @@ static target_ulong h_register_vpa(PowerPCCPU *cpu, sPAPREnvironment *spapr,
|
||||
CPUPPCState *tenv;
|
||||
CPUState *tcpu;
|
||||
|
||||
for (tenv = first_cpu; tenv; tenv = tenv->next_cpu) {
|
||||
tcpu = CPU(ppc_env_get_cpu(tenv));
|
||||
if (tcpu->cpu_index == procno) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!tenv) {
|
||||
tcpu = qemu_get_cpu(procno);
|
||||
if (!tcpu) {
|
||||
return H_PARAMETER;
|
||||
}
|
||||
tenv = tcpu->env_ptr;
|
||||
|
||||
switch (flags) {
|
||||
case FLAGS_REGISTER_VPA:
|
||||
@@ -513,13 +508,14 @@ static target_ulong h_cede(PowerPCCPU *cpu, sPAPREnvironment *spapr,
|
||||
target_ulong opcode, target_ulong *args)
|
||||
{
|
||||
CPUPPCState *env = &cpu->env;
|
||||
CPUState *cs = CPU(cpu);
|
||||
|
||||
env->msr |= (1ULL << MSR_EE);
|
||||
hreg_compute_hflags(env);
|
||||
if (!cpu_has_work(CPU(cpu))) {
|
||||
if (!cpu_has_work(cs)) {
|
||||
env->halted = 1;
|
||||
env->exception_index = EXCP_HLT;
|
||||
env->exit_request = 1;
|
||||
cs->exit_request = 1;
|
||||
}
|
||||
return H_SUCCESS;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user