mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-08 12:56:48 +00:00
Make some unsafe
blocks shorter
This commit is contained in:
parent
13287c752e
commit
e06509e380
@ -23,13 +23,11 @@ pub(crate) fn init_cvm_guest() {
|
||||
}
|
||||
|
||||
pub(crate) unsafe fn late_init_on_bsp() {
|
||||
// SAFETY: this function is only called once on BSP.
|
||||
unsafe {
|
||||
trap::init(true);
|
||||
}
|
||||
// SAFETY: This function is only called once on BSP.
|
||||
unsafe { trap::init(true) };
|
||||
irq::init();
|
||||
|
||||
// SAFETY: we're on the BSP and we're ready to boot all APs.
|
||||
// SAFETY: We're on the BSP and we're ready to boot all APs.
|
||||
unsafe { crate::boot::smp::boot_all_aps() };
|
||||
|
||||
timer::init();
|
||||
|
@ -64,10 +64,8 @@ static CPU_FEATURES: Once<FeatureInfo> = Once::new();
|
||||
///
|
||||
/// This function must be called only once on the bootstrapping processor.
|
||||
pub(crate) unsafe fn late_init_on_bsp() {
|
||||
// SAFETY: this function is only called once on BSP.
|
||||
unsafe {
|
||||
trap::init(true);
|
||||
}
|
||||
// SAFETY: This function is only called once on BSP.
|
||||
unsafe { trap::init(true) };
|
||||
irq::init();
|
||||
|
||||
kernel::acpi::init();
|
||||
@ -87,7 +85,7 @@ pub(crate) unsafe fn late_init_on_bsp() {
|
||||
kernel::tsc::init_tsc_freq();
|
||||
timer::init_bsp();
|
||||
|
||||
// SAFETY: we're on the BSP and we're ready to boot all APs.
|
||||
// SAFETY: We're on the BSP and we're ready to boot all APs.
|
||||
unsafe { crate::boot::smp::boot_all_aps() };
|
||||
|
||||
if_tdx_enabled!({
|
||||
@ -105,9 +103,7 @@ pub(crate) unsafe fn late_init_on_bsp() {
|
||||
// 1. All the system device memory have been removed from the builder.
|
||||
// 2. All the port I/O regions belonging to the system device are defined using the macros.
|
||||
// 3. `MAX_IO_PORT` defined in `crate::arch::io` is the maximum value specified by x86-64.
|
||||
unsafe {
|
||||
crate::io::init(io_mem_builder);
|
||||
}
|
||||
unsafe { crate::io::init(io_mem_builder) };
|
||||
}
|
||||
|
||||
/// Architecture-specific initialization on the application processor.
|
||||
|
@ -142,29 +142,21 @@ pub fn register_ap_entry(entry: fn()) {
|
||||
#[no_mangle]
|
||||
fn ap_early_entry(cpu_id: u32) -> ! {
|
||||
// SAFETY: `cpu_id` is the correct value of the CPU ID.
|
||||
unsafe {
|
||||
cpu::init_on_ap(cpu_id);
|
||||
}
|
||||
unsafe { cpu::init_on_ap(cpu_id) };
|
||||
|
||||
crate::arch::enable_cpu_features();
|
||||
|
||||
// SAFETY: this function is only called once on this AP.
|
||||
unsafe {
|
||||
crate::arch::trap::init(false);
|
||||
}
|
||||
// SAFETY: This function is only called once on this AP.
|
||||
unsafe { crate::arch::trap::init(false) };
|
||||
|
||||
// SAFETY: this function is only called once on this AP, after the BSP has
|
||||
// SAFETY: This function is only called once on this AP, after the BSP has
|
||||
// done the architecture-specific initialization.
|
||||
unsafe {
|
||||
crate::arch::init_on_ap();
|
||||
}
|
||||
unsafe { crate::arch::init_on_ap() };
|
||||
|
||||
crate::arch::irq::enable_local();
|
||||
|
||||
// SAFETY: this function is only called once on this AP.
|
||||
unsafe {
|
||||
crate::mm::kspace::activate_kernel_page_table();
|
||||
}
|
||||
// SAFETY: This function is only called once on this AP.
|
||||
unsafe { crate::mm::kspace::activate_kernel_page_table() };
|
||||
|
||||
// Mark the AP as started.
|
||||
let ap_boot_info = AP_BOOT_INFO.get().unwrap();
|
||||
|
@ -78,9 +78,8 @@ unsafe fn init() {
|
||||
|
||||
// SAFETY: This function is called only once, before `allocator::init`
|
||||
// and after memory regions are initialized.
|
||||
unsafe {
|
||||
mm::frame::allocator::init_early_allocator();
|
||||
}
|
||||
unsafe { mm::frame::allocator::init_early_allocator() };
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
arch::if_tdx_enabled!({
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user