mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-31 23:35:38 +00:00
cpu: cpu_by_arch_id() helper
The helper can be used for CPU object lookup using the CPU's arch-specific ID (the one returned by CPUClass::get_arch_id()). Backports commit 5ce46cb34eecec0bc94a4b1394763f9a1bbe20c3 from qemu
This commit is contained in:
parent
75afdffa45
commit
382022929e
|
@ -606,6 +606,16 @@ CPUState *qemu_get_cpu(struct uc_struct *uc, int index);
|
|||
*/
|
||||
bool cpu_exists(struct uc_struct* uc, int64_t id);
|
||||
|
||||
/**
|
||||
* cpu_by_arch_id:
|
||||
* @id: Guest-exposed CPU ID of the CPU to obtain.
|
||||
*
|
||||
* Get a CPU with matching @id.
|
||||
*
|
||||
* Returns: The CPU or %NULL if there is no matching CPU.
|
||||
*/
|
||||
CPUState *cpu_by_arch_id(struct uc_struct *uc, int64_t id);
|
||||
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
|
||||
typedef void (*CPUInterruptHandler)(CPUState *, int);
|
||||
|
|
|
@ -24,15 +24,20 @@
|
|||
#include "qemu/log.h"
|
||||
#include "uc_priv.h"
|
||||
|
||||
bool cpu_exists(struct uc_struct* uc, int64_t id)
|
||||
CPUState *cpu_by_arch_id(struct uc_struct *uc, int64_t id)
|
||||
{
|
||||
CPUState *cpu = uc->cpu;
|
||||
CPUClass *cc = CPU_GET_CLASS(uc, cpu);
|
||||
|
||||
if (cc->get_arch_id(cpu) == id) {
|
||||
return true;
|
||||
return cpu;
|
||||
}
|
||||
return false;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool cpu_exists(struct uc_struct *uc, int64_t id)
|
||||
{
|
||||
return !!cpu_by_arch_id(uc, id);
|
||||
}
|
||||
|
||||
CPUState *cpu_generic_init(struct uc_struct *uc, const char *typename, const char *cpu_model)
|
||||
|
|
Loading…
Reference in a new issue