Skip to content

Commit 601906f

Browse files
committed
fix: 重构 Aarch64PerCpu 结构体,移除 cpu_id 字段并调整方法可见性
1 parent d536df8 commit 601906f

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/pcpu.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ use crate::CpuHal;
99
#[repr(C)]
1010
#[repr(align(4096))]
1111
pub struct Aarch64PerCpu {
12-
/// per cpu id
13-
pub cpu_id: usize,
1412
ori_vbar: u64,
1513
}
1614

@@ -19,18 +17,17 @@ unsafe extern "C" {
1917
}
2018

2119
impl Aarch64PerCpu {
22-
fn new(cpu_id: usize) -> AxResult<Self> {
23-
Ok(Self {
24-
cpu_id,
20+
pub fn new() -> Self {
21+
Self {
2522
ori_vbar: VBAR_EL2.get(),
26-
})
23+
}
2724
}
2825

29-
fn is_enabled(&self) -> bool {
26+
pub fn is_enabled(&self) -> bool {
3027
HCR_EL2.is_set(HCR_EL2::VM)
3128
}
3229

33-
fn hardware_enable(&mut self) -> AxResult {
30+
pub fn hardware_enable(&mut self) {
3431
// Set current `VBAR_EL2` to `exception_vector_base_vcpu`
3532
// defined in this crate.
3633
VBAR_EL2.set(exception_vector_base_vcpu as usize as _);
@@ -51,11 +48,9 @@ impl Aarch64PerCpu {
5148
// value = in(reg) 0,
5249
// }
5350
// }
54-
55-
Ok(())
5651
}
5752

58-
fn hardware_disable(&mut self) -> AxResult {
53+
pub fn hardware_disable(&mut self) -> AxResult {
5954
// Reset `VBAR_EL2` into previous value.
6055
// Safety:
6156
// Todo: take care of `preemption`
@@ -65,7 +60,7 @@ impl Aarch64PerCpu {
6560
Ok(())
6661
}
6762

68-
fn max_guest_page_table_levels(&self) -> usize {
63+
pub fn max_guest_page_table_levels(&self) -> usize {
6964
crate::vcpu::max_gpt_level(crate::vcpu::pa_bits())
7065
}
7166
}

0 commit comments

Comments
 (0)