rust: move hwcore::sysbus to system crate
This inverts the dependency from hwcore to system, replacing it with a dependency from system to hwcore. It also matches how hw/core/sysbus.h is part of the system-sys crate, and hw/core/sysbus.c is part of system_ss on the C side. This fixes a linker error in hwcore integration tests on msys2. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
@@ -21,7 +21,6 @@ bql = { path = "../../bql" }
|
||||
qom = { path = "../../qom" }
|
||||
chardev = { path = "../../chardev" }
|
||||
migration = { path = "../../migration" }
|
||||
system = { path = "../../system" }
|
||||
util = { path = "../../util" }
|
||||
|
||||
[lints]
|
||||
|
||||
@@ -3,7 +3,7 @@ _hwcore_rs = static_library(
|
||||
'src/lib.rs',
|
||||
override_options: ['rust_std=2021', 'build.rust_std=2021'],
|
||||
rust_abi: 'rust',
|
||||
link_with: [_bql_rs, _chardev_rs, _migration_rs, _qom_rs, _system_rs, _util_rs],
|
||||
link_with: [_bql_rs, _chardev_rs, _migration_rs, _qom_rs, _util_rs],
|
||||
dependencies: [glib_sys_rs, qemu_macros, common_rs, hwcore_sys_rs],
|
||||
)
|
||||
|
||||
|
||||
@@ -33,10 +33,10 @@
|
||||
///
|
||||
/// Interrupts are implemented as a pointer to the interrupt "sink", which has
|
||||
/// type [`IRQState`]. A device exposes its source as a QOM link property using
|
||||
/// a function such as [`crate::sysbus::SysBusDeviceMethods::init_irq`], and
|
||||
/// a function such as [`crate::DeviceMethods::init_gpio_out`], and
|
||||
/// initially leaves the pointer to a NULL value, representing an unconnected
|
||||
/// interrupt. To connect it, whoever creates the device fills the pointer with
|
||||
/// the sink's `IRQState *`, for example using `sysbus_connect_irq`. Because
|
||||
/// the sink's `IRQState *`, for example using `qdev_connect_gpio_out`. Because
|
||||
/// devices are generally shared objects, interrupt sources are an example of
|
||||
/// the interior mutability pattern.
|
||||
///
|
||||
@@ -87,11 +87,11 @@ pub fn set(&self, level: T) {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) const fn as_ptr(&self) -> *mut *mut bindings::IRQState {
|
||||
pub const fn as_ptr(&self) -> *mut *mut bindings::IRQState {
|
||||
self.cell.as_ptr()
|
||||
}
|
||||
|
||||
pub(crate) const fn slice_as_ptr(slice: &[Self]) -> *mut *mut bindings::IRQState {
|
||||
pub const fn slice_as_ptr(slice: &[Self]) -> *mut *mut bindings::IRQState {
|
||||
assert!(!slice.is_empty());
|
||||
slice[0].as_ptr()
|
||||
}
|
||||
|
||||
@@ -14,6 +14,3 @@
|
||||
|
||||
mod qdev;
|
||||
pub use qdev::*;
|
||||
|
||||
mod sysbus;
|
||||
pub use sysbus::*;
|
||||
|
||||
@@ -9,9 +9,4 @@
|
||||
pub use crate::qdev::ResettablePhasesImpl;
|
||||
pub use crate::qdev::ResetType;
|
||||
|
||||
pub use crate::sysbus::SysBusDevice;
|
||||
pub use crate::sysbus::SysBusDeviceClassExt;
|
||||
pub use crate::sysbus::SysBusDeviceImpl;
|
||||
pub use crate::sysbus::SysBusDeviceMethods;
|
||||
|
||||
pub use crate::irq::InterruptSource;
|
||||
|
||||
@@ -142,7 +142,7 @@ fn test_cast() {
|
||||
let obj_ref: &Object = p_ref.upcast();
|
||||
assert_eq!(addr_of!(*obj_ref), p_ptr.cast());
|
||||
|
||||
let sbd_ref: Option<&SysBusDevice> = obj_ref.dynamic_cast();
|
||||
let sbd_ref: Option<&DummyChildState> = obj_ref.dynamic_cast();
|
||||
assert!(sbd_ref.is_none());
|
||||
|
||||
let dev_ref: Option<&DeviceState> = obj_ref.downcast();
|
||||
@@ -150,7 +150,7 @@ fn test_cast() {
|
||||
|
||||
// SAFETY: the cast is wrong, but the value is only used for comparison
|
||||
unsafe {
|
||||
let sbd_ref: &SysBusDevice = obj_ref.unsafe_cast();
|
||||
let sbd_ref: &DummyChildState = obj_ref.unsafe_cast();
|
||||
assert_eq!(addr_of!(*sbd_ref), p_ptr.cast());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,9 +42,9 @@ subdir('util')
|
||||
subdir('bql')
|
||||
subdir('migration')
|
||||
subdir('qom')
|
||||
subdir('system')
|
||||
subdir('chardev')
|
||||
subdir('hw/core')
|
||||
subdir('system')
|
||||
subdir('tests')
|
||||
subdir('trace')
|
||||
subdir('hw')
|
||||
|
||||
@@ -16,6 +16,7 @@ rust-version.workspace = true
|
||||
common = { path = "../common" }
|
||||
system-sys = { path = "../bindings/system-sys" }
|
||||
bql = { path = "../bql" }
|
||||
hwcore = { path = "../hw/core" }
|
||||
migration = { path = "../migration" }
|
||||
qom = { path = "../qom" }
|
||||
util = { path = "../util" }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
_system_rs = static_library(
|
||||
'system',
|
||||
'src/lib.rs',
|
||||
link_with: [_bql_rs, _migration_rs, _qom_rs, _util_rs],
|
||||
link_with: [_bql_rs, _hwcore_rs, _migration_rs, _qom_rs, _util_rs],
|
||||
dependencies: [glib_sys_rs, common_rs, qemu_macros, system_sys_rs],
|
||||
)
|
||||
|
||||
|
||||
@@ -9,3 +9,6 @@
|
||||
// for prelude-like modules
|
||||
#[rustfmt::skip]
|
||||
pub mod prelude;
|
||||
|
||||
mod sysbus;
|
||||
pub use sysbus::*;
|
||||
|
||||
@@ -6,3 +6,8 @@
|
||||
pub use crate::memory::MemoryRegionOps;
|
||||
pub use crate::memory::MemoryRegionOpsBuilder;
|
||||
pub use crate::memory::MemTxAttrs;
|
||||
|
||||
pub use crate::sysbus::SysBusDevice;
|
||||
pub use crate::sysbus::SysBusDeviceClassExt;
|
||||
pub use crate::sysbus::SysBusDeviceImpl;
|
||||
pub use crate::sysbus::SysBusDeviceMethods;
|
||||
|
||||
@@ -7,15 +7,12 @@
|
||||
use std::ffi::CStr;
|
||||
|
||||
use common::Opaque;
|
||||
use hwcore::{prelude::*, IRQState};
|
||||
use qom::prelude::*;
|
||||
use system::MemoryRegion;
|
||||
pub use system_sys::SysBusDeviceClass;
|
||||
use util::{Error, Result};
|
||||
|
||||
use crate::{
|
||||
irq::{IRQState, InterruptSource},
|
||||
qdev::{DeviceClassExt, DeviceImpl, DeviceState},
|
||||
};
|
||||
use crate::MemoryRegion;
|
||||
|
||||
/// A safe wrapper around [`system_sys::SysBusDevice`].
|
||||
#[repr(transparent)]
|
||||
Reference in New Issue
Block a user