new file mode 100644
@@ -0,0 +1,2 @@
+/target
+/.git-old
new file mode 100644
@@ -0,0 +1,3 @@
+[workspace]
+members = ["qemu"]
+resolver = "2"
new file mode 100644
@@ -0,0 +1,6 @@
+[package]
+name = "qemu-hw"
+version = "0.1.0"
+edition = "2021"
+
+[dependencies]
new file mode 100644
new file mode 100644
@@ -0,0 +1,3 @@
+fn main() {
+ println!("Hello, world!");
+}
new file mode 100644
@@ -0,0 +1,7 @@
+[package]
+name = "qemu"
+version = "0.1.0"
+edition = "2021"
+
+[dependencies]
+const-default = { version = "~1", features = ["derive"] }
new file mode 100644
@@ -0,0 +1,88 @@
+use std::ffi::{c_char, c_void};
+
+#[repr(C)]
+pub struct Object {
+ pub klass: *mut c_void,
+ pub free: extern "C" fn(c: *mut c_void),
+ pub properties: *mut c_void,
+ pub r#ref: u32,
+ pub parent: *mut Object,
+}
+
+#[repr(C)]
+pub struct ObjectClass {
+ pub unparent: Option<unsafe extern "C" fn(*mut Object)>,
+}
+
+#[repr(C)]
+pub struct DeviceState {
+ pub base: Object,
+}
+
+#[repr(C)]
+#[allow(non_camel_case_types)]
+pub struct PropertyInfo {
+ pub name: *const c_char,
+ pub description: *const c_char,
+ // ...
+}
+#[repr(C)]
+pub struct Property {
+ pub name: *const c_char,
+ pub offset: usize,
+ pub default: u64,
+ pub info: *const PropertyInfo,
+}
+
+pub struct DeviceClass {
+ pub oc: ObjectClass,
+
+ pub realize: Option<unsafe extern "C" fn(*mut DeviceState, *mut *mut Error)>,
+ pub unrealize: Option<unsafe extern "C" fn(*mut DeviceState)>,
+ pub cold_reset: Option<unsafe extern "C" fn(*mut DeviceState)>,
+ pub properties: *const Property,
+}
+
+#[repr(C)]
+pub struct TypeInfo {
+ pub name: *const c_char,
+ pub parent: *const c_char,
+ pub instance_mem_init: Option<unsafe extern "C" fn(*mut c_void)>,
+ pub instance_init: Option<unsafe extern "C" fn(*mut c_void)>,
+ pub instance_finalize: Option<unsafe extern "C" fn(*mut c_void)>,
+ pub class_init: Option<unsafe extern "C" fn(*mut c_void, *mut c_void)>,
+ pub instance_size: usize,
+}
+
+#[repr(C)]
+pub struct Error {
+ _unused: c_char,
+}
+
+extern "C" {
+ pub fn error_setg_internal(
+ errp: *mut *mut Error,
+ src: *mut c_char,
+ line: u32,
+ func: *mut c_char,
+ fmt: *const c_char,
+ ...
+ );
+ pub fn error_get_pretty(errp: *const Error) -> *mut c_char;
+ pub fn error_free(errp: *mut Error);
+
+ pub fn object_dynamic_cast(obj: *mut Object, typ: *const c_char) -> *mut c_void;
+ pub fn object_property_add_child(obj: *mut Object, typ: *const c_char,
+ child: *mut Object);
+ pub fn object_get_typename(obj: *const Object) -> *const c_char;
+ pub fn object_ref(obj: *mut Object);
+ pub fn object_new(typ: *const c_char) -> *const Object;
+ pub fn object_unref(obj: *mut Object);
+ pub fn object_unparent(obj: *mut Object);
+
+ pub fn device_cold_reset(obj: *mut DeviceState);
+ pub fn device_realize(obj: *mut DeviceState, err: *mut *mut Error) -> bool;
+ pub fn type_register(obj: *const TypeInfo);
+
+ pub static qdev_prop_bool: PropertyInfo;
+}
new file mode 100644
@@ -0,0 +1,4 @@
+#![allow(unused_macros)]
+#![allow(dead_code)]
+
+pub mod bindings;
qemu/ is where target-independent code goes. This code should not use constructors and will be brought in as needed. qemu-hw/ is where the target-dependent code goes, which is going to be built depending on Kconfig symbols. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> --- .gitignore | 2 + Cargo.toml | 3 + qemu-hw/Cargo.toml | 6 ++ qemu-hw/src/lib.rs | 0 qemu-hw/src/main.rs | 3 + qemu/Cargo.toml | 7 ++ qemu/src/bindings/mod.rs | 88 +++++++++++++++++++++++++ qemu/src/lib.rs | 4 ++ 9 files changed, 249 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.toml create mode 100644 qemu-hw/Cargo.toml create mode 100644 qemu-hw/src/lib.rs create mode 100644 qemu-hw/src/main.rs create mode 100644 qemu/Cargo.toml create mode 100644 qemu/src/bindings/mod.rs create mode 100644 qemu/src/lib.rs