Import QEMU upstream snapshot d2e570c
Upstream: https://gitlab.com/qemu-project/qemu.git Upstream-Commit: d2e570cc0f97b936902a5b1b86b73c0f5998b475
This commit is contained in:
commit
cf256aa081
11315 files changed
+3598369
No files matched your search
@@ -0,0 +1,2 @@
|
||||
config X_HPET_RUST
|
||||
bool
|
||||
@@ -0,0 +1,24 @@
|
||||
[package]
|
||||
name = "hpet"
|
||||
version = "0.1.0"
|
||||
authors = ["Zhao Liu <[email protected]>"]
|
||||
description = "IA-PC High Precision Event Timer emulation in Rust"
|
||||
|
||||
edition.workspace = true
|
||||
homepage.workspace = true
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
||||
rust-version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
common = { path = "../../../common" }
|
||||
util = { path = "../../../util" }
|
||||
migration = { path = "../../../migration" }
|
||||
bql = { path = "../../../bql" }
|
||||
qom = { path = "../../../qom" }
|
||||
system = { path = "../../../system" }
|
||||
hwcore = { path = "../../../hw/core" }
|
||||
trace = { path = "../../../trace" }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
@@ -0,0 +1,6 @@
|
||||
_libhpet_rs = cargo_ws.package('hpet').library()
|
||||
|
||||
rust_devices_ss.add(when: 'CONFIG_X_HPET_RUST', if_true: [declare_dependency(
|
||||
link_whole: [_libhpet_rs],
|
||||
variables: {'crate': 'hpet'},
|
||||
)])
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,67 @@
|
||||
// Copyright (C) 2024 Intel Corporation.
|
||||
// Author(s): Zhao Liu <[email protected]>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
use std::ptr::addr_of_mut;
|
||||
|
||||
use common::Zeroable;
|
||||
use util::{self, prelude::*};
|
||||
|
||||
/// Each `HPETState` represents a Event Timer Block. The v1 spec supports
|
||||
/// up to 8 blocks. QEMU only uses 1 block (in PC machine).
|
||||
const HPET_MAX_NUM_EVENT_TIMER_BLOCK: usize = 8;
|
||||
|
||||
#[repr(C, packed)]
|
||||
#[derive(Copy, Clone, Default)]
|
||||
pub struct HPETFwEntry {
|
||||
pub event_timer_block_id: u32,
|
||||
pub address: u64,
|
||||
pub min_tick: u16,
|
||||
pub page_prot: u8,
|
||||
}
|
||||
unsafe impl Zeroable for HPETFwEntry {}
|
||||
|
||||
#[repr(C, packed)]
|
||||
#[derive(Copy, Clone, Default)]
|
||||
pub struct HPETFwConfig {
|
||||
pub count: u8,
|
||||
pub hpet: [HPETFwEntry; HPET_MAX_NUM_EVENT_TIMER_BLOCK],
|
||||
}
|
||||
unsafe impl Zeroable for HPETFwConfig {}
|
||||
|
||||
#[allow(non_upper_case_globals)]
|
||||
#[no_mangle]
|
||||
pub static mut hpet_fw_cfg: HPETFwConfig = HPETFwConfig {
|
||||
count: u8::MAX,
|
||||
..Zeroable::ZERO
|
||||
};
|
||||
|
||||
impl HPETFwConfig {
|
||||
pub(crate) fn assign_hpet_id() -> util::Result<usize> {
|
||||
assert!(bql::is_locked());
|
||||
// SAFETY: all accesses go through these methods, which guarantee
|
||||
// that the accesses are protected by the BQL.
|
||||
let fw_cfg = unsafe { &mut *addr_of_mut!(hpet_fw_cfg) };
|
||||
|
||||
if fw_cfg.count == u8::MAX {
|
||||
// first instance
|
||||
fw_cfg.count = 0;
|
||||
}
|
||||
|
||||
ensure!(fw_cfg.count != 8, "Only 8 instances of HPET are allowed");
|
||||
|
||||
let id: usize = fw_cfg.count.into();
|
||||
fw_cfg.count += 1;
|
||||
Ok(id)
|
||||
}
|
||||
|
||||
pub(crate) fn update_hpet_cfg(hpet_id: usize, timer_block_id: u32, address: u64) {
|
||||
assert!(bql::is_locked());
|
||||
// SAFETY: all accesses go through these methods, which guarantee
|
||||
// that the accesses are protected by the BQL.
|
||||
let fw_cfg = unsafe { &mut *addr_of_mut!(hpet_fw_cfg) };
|
||||
|
||||
fw_cfg.hpet[hpet_id].event_timer_block_id = timer_block_id;
|
||||
fw_cfg.hpet[hpet_id].address = address;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright (C) 2024 Intel Corporation.
|
||||
// Author(s): Zhao Liu <[email protected]>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
//! # HPET QEMU Device Model
|
||||
//!
|
||||
//! This library implements a device model for the IA-PC HPET (High
|
||||
//! Precision Event Timers) device in QEMU.
|
||||
|
||||
pub mod device;
|
||||
pub mod fw_cfg;
|
||||
|
||||
pub const TYPE_HPET: &::std::ffi::CStr = c"hpet";
|
||||
@@ -0,0 +1 @@
|
||||
subdir('hpet')
|
||||
Reference in new issue
Block a user