File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 73
73
//! QEMU device implementations is usually incorrect and can lead to
74
74
//! thread-safety issues.
75
75
//!
76
+ //! ### Example
77
+ //!
78
+ //! ```
79
+ //! # use qemu_api::prelude::*;
80
+ //! # use qemu_api::{c_str, cell::BqlRefCell, irq::InterruptSource, irq::IRQState};
81
+ //! # use qemu_api::{sysbus::SysBusDevice, qom::Owned, qom::ParentField};
82
+ //! # const N_GPIOS: usize = 8;
83
+ //! # struct PL061Registers { /* ... */ }
84
+ //! # unsafe impl ObjectType for PL061State {
85
+ //! # type Class = <SysBusDevice as ObjectType>::Class;
86
+ //! # const TYPE_NAME: &'static std::ffi::CStr = c_str!("pl061");
87
+ //! # }
88
+ //! struct PL061State {
89
+ //! parent_obj: ParentField<SysBusDevice>,
90
+ //!
91
+ //! // Configuration is read-only after initialization
92
+ //! pullups: u32,
93
+ //! pulldowns: u32,
94
+ //!
95
+ //! // Single values shared with C code use BqlCell, in this case via InterruptSource
96
+ //! out: [InterruptSource; N_GPIOS],
97
+ //! interrupt: InterruptSource,
98
+ //!
99
+ //! // Larger state accessed by device methods uses BqlRefCell or Mutex
100
+ //! registers: BqlRefCell<PL061Registers>,
101
+ //! }
102
+ //! ```
103
+ //!
76
104
//! ### `BqlCell<T>`
77
105
//!
78
106
//! [`BqlCell<T>`] implements interior mutability by moving values in and out of
You can’t perform that action at this time.
0 commit comments