From b14a0b7469fa3e6c26d18438531d26138c55b67e Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Fri, 26 Sep 2014 17:45:21 -0300 Subject: accel: Use QOM classes for accel types Instead of having a static AccelType array, register a class for each accelerator type, and use class name lookup to find accelerator information. Reviewed-by: Paolo Bonzini Signed-off-by: Eduardo Habkost Signed-off-by: Paolo Bonzini --- include/sysemu/accel.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'include') diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h index 5537d74..120ca0e 100644 --- a/include/sysemu/accel.h +++ b/include/sysemu/accel.h @@ -24,6 +24,36 @@ #define HW_ACCEL_H #include "qemu/typedefs.h" +#include "qom/object.h" + +typedef struct AccelState { + /*< private >*/ + Object parent_obj; +} AccelState; + +typedef struct AccelClass { + /*< private >*/ + ObjectClass parent_class; + /*< public >*/ + + const char *opt_name; + const char *name; + int (*available)(void); + int (*init)(MachineClass *mc); + bool *allowed; +} AccelClass; + +#define TYPE_ACCEL "accel" + +#define ACCEL_CLASS_SUFFIX "-" TYPE_ACCEL +#define ACCEL_CLASS_NAME(a) (a ACCEL_CLASS_SUFFIX) + +#define ACCEL_CLASS(klass) \ + OBJECT_CLASS_CHECK(AccelClass, (klass), TYPE_ACCEL) +#define ACCEL(obj) \ + OBJECT_CHECK(AccelState, (obj), TYPE_ACCEL) +#define ACCEL_GET_CLASS(obj) \ + OBJECT_GET_CLASS(AccelClass, (obj), TYPE_ACCEL) extern int tcg_tb_size; -- cgit v1.1