qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC v0 2/4] hw: Introduce Linux Device API


From: Peter Crosthwaite
Subject: [Qemu-devel] [RFC v0 2/4] hw: Introduce Linux Device API
Date: Tue, 30 Jun 2015 12:21:34 -0700

Introduce an interface for a device with some basic linux awareness.
Allows devices to implement setup routines to emulate the device as
when Linux handoff happens. Some devices needs this to emulate
firmware or bootloader behaviour.

This allows use of -kernel -dtb -initrd style boots on platforms that
have non-trivial firmware setup requirements.

Signed-off-by: Peter Crosthwaite <address@hidden>
---
 hw/Makefile.objs         |  1 +
 hw/guest/Makefile.objs   |  1 +
 hw/guest/linux.c         | 14 ++++++++++++++
 include/hw/guest/linux.h | 32 ++++++++++++++++++++++++++++++++
 4 files changed, 48 insertions(+)
 create mode 100644 hw/guest/Makefile.objs
 create mode 100644 hw/guest/linux.c
 create mode 100644 include/hw/guest/linux.h

diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 73afa41..3b03d90 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -7,6 +7,7 @@ devices-dirs-$(CONFIG_SOFTMMU) += char/
 devices-dirs-$(CONFIG_SOFTMMU) += cpu/
 devices-dirs-$(CONFIG_SOFTMMU) += display/
 devices-dirs-$(CONFIG_SOFTMMU) += dma/
+devices-dirs-$(CONFIG_SOFTMMU) += guest/
 devices-dirs-$(CONFIG_SOFTMMU) += gpio/
 devices-dirs-$(CONFIG_SOFTMMU) += i2c/
 devices-dirs-$(CONFIG_SOFTMMU) += ide/
diff --git a/hw/guest/Makefile.objs b/hw/guest/Makefile.objs
new file mode 100644
index 0000000..a413c89
--- /dev/null
+++ b/hw/guest/Makefile.objs
@@ -0,0 +1 @@
+common-obj-y += linux.o
diff --git a/hw/guest/linux.c b/hw/guest/linux.c
new file mode 100644
index 0000000..70d9652
--- /dev/null
+++ b/hw/guest/linux.c
@@ -0,0 +1,14 @@
+#include "hw/guest/linux.h"
+
+static const TypeInfo linux_device_info = {
+    .name          = TYPE_LINUX_DEVICE,
+    .parent        = TYPE_INTERFACE,
+    .class_size = sizeof(LinuxDeviceClass),
+};
+
+static void linux_register_types(void)
+{
+    type_register_static(&linux_device_info);
+}
+
+type_init(linux_register_types)
diff --git a/include/hw/guest/linux.h b/include/hw/guest/linux.h
new file mode 100644
index 0000000..b481a33
--- /dev/null
+++ b/include/hw/guest/linux.h
@@ -0,0 +1,32 @@
+#ifndef GUEST_LINUX_H
+
+#include "qemu-common.h"
+#include "qom/object.h"
+
+#define TYPE_LINUX_DEVICE "linux,device"
+
+#define LINUX_DEVICE_CLASS(klass) \
+    OBJECT_CLASS_CHECK(LinuxDeviceClass, (klass), TYPE_LINUX_DEVICE)
+#define LINUX_DEVICE_GET_CLASS(obj) \
+    OBJECT_GET_CLASS(LinuxDeviceClass, (obj), TYPE_LINUX_DEVICE)
+#define LINUX_DEVICE(obj) \
+    INTERFACE_CHECK(LinuxDevice, (obj), TYPE_LINUX_DEVICE)
+
+typedef struct LinuxDevice {
+    /*< private >*/
+    Object parent_obj;
+} LinuxDevice;
+
+typedef struct LinuxDeviceClass {
+    /*< private > */
+    InterfaceClass parent_class;
+
+    /*< public >*/
+    /** linux_init - Init the device for a Linux boot. Setup the device in the
+     * correct post-firmware state for a Linux boot.
+     */
+    void (*linux_init)(LinuxDevice *obj);
+} LinuxDeviceClass;
+
+#define GUEST_LINUX_H
+#endif
-- 
2.4.5.3.g6a5966f




reply via email to

[Prev in Thread] Current Thread [Next in Thread]