mirror of
https://github.com/qemu/qemu.git
synced 2025-08-14 11:43:46 +00:00
rust/hpet: convert HPETTimer index to u8 type
The C version of HPET uses the uint8_t type for timer index ("tn"), and usize type in Rust version will break migration between the C and Rust versions. So convert HPETTimer index' type to u8 (consistent with the C version of HPET) to make it friendly for vmstate support. Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Link: https://lore.kernel.org/r/20250414144943.1112885-8-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
8163eeee4e
commit
64e1256b21
@ -184,7 +184,7 @@ fn timer_handler(timer_cell: &BqlRefCell<HPETTimer>) {
|
||||
pub struct HPETTimer {
|
||||
/// timer N index within the timer block (`HPETState`)
|
||||
#[doc(alias = "tn")]
|
||||
index: usize,
|
||||
index: u8,
|
||||
qemu_timer: Timer,
|
||||
/// timer block abstraction containing this timer
|
||||
state: NonNull<HPETState>,
|
||||
@ -210,7 +210,7 @@ pub struct HPETTimer {
|
||||
}
|
||||
|
||||
impl HPETTimer {
|
||||
fn init(&mut self, index: usize, state: &HPETState) {
|
||||
fn init(&mut self, index: u8, state: &HPETState) {
|
||||
*self = HPETTimer {
|
||||
index,
|
||||
// SAFETY: the HPETTimer will only be used after the timer
|
||||
@ -235,7 +235,7 @@ fn init(&mut self, index: usize, state: &HPETState) {
|
||||
Timer::NS,
|
||||
0,
|
||||
timer_handler,
|
||||
&state.timers[self.index],
|
||||
&state.timers[self.index as usize],
|
||||
)
|
||||
}
|
||||
|
||||
@ -246,7 +246,7 @@ fn get_state(&self) -> &HPETState {
|
||||
}
|
||||
|
||||
fn is_int_active(&self) -> bool {
|
||||
self.get_state().is_timer_int_active(self.index)
|
||||
self.get_state().is_timer_int_active(self.index.into())
|
||||
}
|
||||
|
||||
const fn is_fsb_route_enabled(&self) -> bool {
|
||||
@ -611,7 +611,7 @@ fn handle_legacy_irq(&self, irq: u32, level: u32) {
|
||||
|
||||
fn init_timer(&self) {
|
||||
for (index, timer) in self.timers.iter().enumerate() {
|
||||
timer.borrow_mut().init(index, self);
|
||||
timer.borrow_mut().init(index.try_into().unwrap(), self);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user