mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-11 03:24:58 -06:00
rust: pl011: switch vmstate to new-style macros
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
9a2ba4882d
commit
b800a31321
3 changed files with 26 additions and 19 deletions
|
@ -15,7 +15,7 @@ use qemu_api::{
|
||||||
qemu_irq, sysbus_connect_irq, sysbus_mmio_map, sysbus_realize_and_unref, CharBackend,
|
qemu_irq, sysbus_connect_irq, sysbus_mmio_map, sysbus_realize_and_unref, CharBackend,
|
||||||
Chardev, Clock, ClockEvent, MemoryRegion, QEMUChrEvent, CHR_IOCTL_SERIAL_SET_BREAK,
|
Chardev, Clock, ClockEvent, MemoryRegion, QEMUChrEvent, CHR_IOCTL_SERIAL_SET_BREAK,
|
||||||
},
|
},
|
||||||
c_str,
|
c_str, impl_vmstate_forward,
|
||||||
irq::InterruptSource,
|
irq::InterruptSource,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
qdev::{DeviceImpl, DeviceState, Property},
|
qdev::{DeviceImpl, DeviceState, Property},
|
||||||
|
@ -61,6 +61,7 @@ impl DeviceId {
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct Fifo([registers::Data; PL011_FIFO_DEPTH as usize]);
|
pub struct Fifo([registers::Data; PL011_FIFO_DEPTH as usize]);
|
||||||
|
impl_vmstate_forward!(Fifo);
|
||||||
|
|
||||||
impl Fifo {
|
impl Fifo {
|
||||||
const fn len(&self) -> u32 {
|
const fn len(&self) -> u32 {
|
||||||
|
|
|
@ -6,11 +6,11 @@ use core::ptr::NonNull;
|
||||||
use std::os::raw::{c_int, c_void};
|
use std::os::raw::{c_int, c_void};
|
||||||
|
|
||||||
use qemu_api::{
|
use qemu_api::{
|
||||||
bindings::*, c_str, vmstate_clock, vmstate_fields, vmstate_subsections, vmstate_uint32,
|
bindings::*, c_str, vmstate_clock, vmstate_fields, vmstate_of, vmstate_subsections,
|
||||||
vmstate_uint32_array, vmstate_unused, zeroable::Zeroable,
|
vmstate_unused, zeroable::Zeroable,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::device::{PL011State, PL011_FIFO_DEPTH};
|
use crate::device::PL011State;
|
||||||
|
|
||||||
extern "C" fn pl011_clock_needed(opaque: *mut c_void) -> bool {
|
extern "C" fn pl011_clock_needed(opaque: *mut c_void) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -52,21 +52,21 @@ pub static VMSTATE_PL011: VMStateDescription = VMStateDescription {
|
||||||
post_load: Some(pl011_post_load),
|
post_load: Some(pl011_post_load),
|
||||||
fields: vmstate_fields! {
|
fields: vmstate_fields! {
|
||||||
vmstate_unused!(core::mem::size_of::<u32>()),
|
vmstate_unused!(core::mem::size_of::<u32>()),
|
||||||
vmstate_uint32!(flags, PL011State),
|
vmstate_of!(PL011State, flags),
|
||||||
vmstate_uint32!(line_control, PL011State),
|
vmstate_of!(PL011State, line_control),
|
||||||
vmstate_uint32!(receive_status_error_clear, PL011State),
|
vmstate_of!(PL011State, receive_status_error_clear),
|
||||||
vmstate_uint32!(control, PL011State),
|
vmstate_of!(PL011State, control),
|
||||||
vmstate_uint32!(dmacr, PL011State),
|
vmstate_of!(PL011State, dmacr),
|
||||||
vmstate_uint32!(int_enabled, PL011State),
|
vmstate_of!(PL011State, int_enabled),
|
||||||
vmstate_uint32!(int_level, PL011State),
|
vmstate_of!(PL011State, int_level),
|
||||||
vmstate_uint32_array!(read_fifo, PL011State, PL011_FIFO_DEPTH),
|
vmstate_of!(PL011State, read_fifo),
|
||||||
vmstate_uint32!(ilpr, PL011State),
|
vmstate_of!(PL011State, ilpr),
|
||||||
vmstate_uint32!(ibrd, PL011State),
|
vmstate_of!(PL011State, ibrd),
|
||||||
vmstate_uint32!(fbrd, PL011State),
|
vmstate_of!(PL011State, fbrd),
|
||||||
vmstate_uint32!(ifl, PL011State),
|
vmstate_of!(PL011State, ifl),
|
||||||
vmstate_uint32!(read_pos, PL011State),
|
vmstate_of!(PL011State, read_pos),
|
||||||
vmstate_uint32!(read_count, PL011State),
|
vmstate_of!(PL011State, read_count),
|
||||||
vmstate_uint32!(read_trigger, PL011State),
|
vmstate_of!(PL011State, read_trigger),
|
||||||
},
|
},
|
||||||
subsections: vmstate_subsections! {
|
subsections: vmstate_subsections! {
|
||||||
VMSTATE_PL011_CLOCK
|
VMSTATE_PL011_CLOCK
|
||||||
|
|
|
@ -106,6 +106,7 @@ pub mod registers {
|
||||||
//! Device registers exposed as typed structs which are backed by arbitrary
|
//! Device registers exposed as typed structs which are backed by arbitrary
|
||||||
//! integer bitmaps. [`Data`], [`Control`], [`LineControl`], etc.
|
//! integer bitmaps. [`Data`], [`Control`], [`LineControl`], etc.
|
||||||
use bilge::prelude::*;
|
use bilge::prelude::*;
|
||||||
|
use qemu_api::impl_vmstate_bitsized;
|
||||||
|
|
||||||
/// Receive Status Register / Data Register common error bits
|
/// Receive Status Register / Data Register common error bits
|
||||||
///
|
///
|
||||||
|
@ -172,6 +173,7 @@ pub mod registers {
|
||||||
pub errors: Errors,
|
pub errors: Errors,
|
||||||
_reserved: u16,
|
_reserved: u16,
|
||||||
}
|
}
|
||||||
|
impl_vmstate_bitsized!(Data);
|
||||||
|
|
||||||
impl Data {
|
impl Data {
|
||||||
// bilge is not very const-friendly, unfortunately
|
// bilge is not very const-friendly, unfortunately
|
||||||
|
@ -208,6 +210,7 @@ pub mod registers {
|
||||||
pub errors: Errors,
|
pub errors: Errors,
|
||||||
_reserved_unpredictable: u24,
|
_reserved_unpredictable: u24,
|
||||||
}
|
}
|
||||||
|
impl_vmstate_bitsized!(ReceiveStatusErrorClear);
|
||||||
|
|
||||||
impl ReceiveStatusErrorClear {
|
impl ReceiveStatusErrorClear {
|
||||||
pub fn set_from_data(&mut self, data: Data) {
|
pub fn set_from_data(&mut self, data: Data) {
|
||||||
|
@ -280,6 +283,7 @@ pub mod registers {
|
||||||
pub ring_indicator: bool,
|
pub ring_indicator: bool,
|
||||||
_reserved_zero_no_modify: u23,
|
_reserved_zero_no_modify: u23,
|
||||||
}
|
}
|
||||||
|
impl_vmstate_bitsized!(Flags);
|
||||||
|
|
||||||
impl Flags {
|
impl Flags {
|
||||||
pub fn reset(&mut self) {
|
pub fn reset(&mut self) {
|
||||||
|
@ -354,6 +358,7 @@ pub mod registers {
|
||||||
/// 31:8 - Reserved, do not modify, read as zero.
|
/// 31:8 - Reserved, do not modify, read as zero.
|
||||||
_reserved_zero_no_modify: u24,
|
_reserved_zero_no_modify: u24,
|
||||||
}
|
}
|
||||||
|
impl_vmstate_bitsized!(LineControl);
|
||||||
|
|
||||||
impl LineControl {
|
impl LineControl {
|
||||||
pub fn reset(&mut self) {
|
pub fn reset(&mut self) {
|
||||||
|
@ -498,6 +503,7 @@ pub mod registers {
|
||||||
/// 31:16 - Reserved, do not modify, read as zero.
|
/// 31:16 - Reserved, do not modify, read as zero.
|
||||||
_reserved_zero_no_modify2: u16,
|
_reserved_zero_no_modify2: u16,
|
||||||
}
|
}
|
||||||
|
impl_vmstate_bitsized!(Control);
|
||||||
|
|
||||||
impl Control {
|
impl Control {
|
||||||
pub fn reset(&mut self) {
|
pub fn reset(&mut self) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue