mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-22 00:43:24 +00:00
Adjust the format of imports in Asterinas
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
92e488e727
commit
cfcef6965a
@ -3,20 +3,22 @@
|
||||
//! The Linux 64-bit Boot Protocol supporting module.
|
||||
//!
|
||||
|
||||
use linux_boot_params::{BootParams, E820Type, LINUX_BOOT_HEADER_MAGIC};
|
||||
|
||||
use crate::boot::{
|
||||
kcmdline::KCmdlineArg,
|
||||
memory_region::{non_overlapping_regions_from, MemoryRegion, MemoryRegionType},
|
||||
BootloaderAcpiArg, BootloaderFramebufferArg,
|
||||
};
|
||||
use crate::{config::PHYS_OFFSET, vm::paddr_to_vaddr};
|
||||
|
||||
use alloc::{borrow::ToOwned, format, string::String, vec::Vec};
|
||||
use core::ffi::CStr;
|
||||
|
||||
use linux_boot_params::{BootParams, E820Type, LINUX_BOOT_HEADER_MAGIC};
|
||||
use spin::Once;
|
||||
|
||||
use crate::{
|
||||
boot::{
|
||||
kcmdline::KCmdlineArg,
|
||||
memory_region::{non_overlapping_regions_from, MemoryRegion, MemoryRegionType},
|
||||
BootloaderAcpiArg, BootloaderFramebufferArg,
|
||||
},
|
||||
config::PHYS_OFFSET,
|
||||
vm::paddr_to_vaddr,
|
||||
};
|
||||
|
||||
static BOOT_PARAMS: Once<BootParams> = Once::new();
|
||||
|
||||
fn init_bootloader_name(bootloader_name: &'static Once<String>) {
|
||||
|
@ -1,6 +1,8 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::{string::String, vec::Vec};
|
||||
use core::arch::global_asm;
|
||||
|
||||
use multiboot2::MemoryAreaType;
|
||||
use spin::Once;
|
||||
|
||||
@ -14,8 +16,6 @@ use crate::{
|
||||
vm::paddr_to_vaddr,
|
||||
};
|
||||
|
||||
use core::arch::global_asm;
|
||||
|
||||
global_asm!(include_str!("header.S"));
|
||||
|
||||
pub(super) const MULTIBOOT_ENTRY_MAGIC: u32 = 0x2BADB002;
|
||||
|
@ -4,16 +4,16 @@ use alloc::{
|
||||
string::{String, ToString},
|
||||
vec::Vec,
|
||||
};
|
||||
use core::arch::global_asm;
|
||||
|
||||
use multiboot2::{BootInformation, BootInformationHeader, MemoryAreaType};
|
||||
use spin::Once;
|
||||
|
||||
use crate::boot::{
|
||||
kcmdline::KCmdlineArg,
|
||||
memory_region::{non_overlapping_regions_from, MemoryRegion, MemoryRegionType},
|
||||
BootloaderAcpiArg, BootloaderFramebufferArg,
|
||||
};
|
||||
use spin::Once;
|
||||
|
||||
use core::arch::global_asm;
|
||||
|
||||
global_asm!(include_str!("header.S"));
|
||||
|
||||
|
@ -1,17 +1,14 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::{fmt, sync::Arc, vec::Vec};
|
||||
use core::fmt::Write;
|
||||
|
||||
use crate::sync::SpinLock;
|
||||
use crate::trap::IrqLine;
|
||||
use alloc::fmt;
|
||||
use alloc::{sync::Arc, vec::Vec};
|
||||
use log::debug;
|
||||
use spin::Once;
|
||||
use trapframe::TrapFrame;
|
||||
|
||||
use super::device::serial::SerialPort;
|
||||
use super::kernel::IO_APIC;
|
||||
use super::{device::serial::SerialPort, kernel::IO_APIC};
|
||||
use crate::{sync::SpinLock, trap::IrqLine};
|
||||
|
||||
#[inline]
|
||||
pub fn print(args: fmt::Arguments) {
|
||||
|
@ -2,23 +2,28 @@
|
||||
|
||||
//! CPU.
|
||||
|
||||
use core::arch::x86_64::{_fxrstor, _fxsave};
|
||||
use core::fmt::Debug;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use bitvec::{prelude::Lsb0, slice::IterOnes};
|
||||
use trapframe::{GeneralRegs, UserContext as RawUserContext};
|
||||
use core::{
|
||||
arch::x86_64::{_fxrstor, _fxsave},
|
||||
fmt::Debug,
|
||||
};
|
||||
|
||||
#[cfg(feature = "intel_tdx")]
|
||||
use crate::arch::tdx_guest::{handle_virtual_exception, TdxTrapFrame};
|
||||
use bitvec::prelude::BitVec;
|
||||
use bitvec::{
|
||||
prelude::{BitVec, Lsb0},
|
||||
slice::IterOnes,
|
||||
};
|
||||
use log::debug;
|
||||
#[cfg(feature = "intel_tdx")]
|
||||
use tdx_guest::tdcall;
|
||||
use trapframe::{GeneralRegs, UserContext as RawUserContext};
|
||||
use x86_64::registers::rflags::RFlags;
|
||||
|
||||
use crate::trap::call_irq_callback_functions;
|
||||
use crate::user::{UserContextApi, UserContextApiInternal, UserEvent};
|
||||
#[cfg(feature = "intel_tdx")]
|
||||
use crate::arch::tdx_guest::{handle_virtual_exception, TdxTrapFrame};
|
||||
use crate::{
|
||||
trap::call_irq_callback_functions,
|
||||
user::{UserContextApi, UserContextApiInternal, UserEvent},
|
||||
};
|
||||
|
||||
/// Returns the number of CPUs.
|
||||
pub fn num_cpus() -> u32 {
|
||||
|
@ -3,9 +3,8 @@
|
||||
use acpi::{fadt::Fadt, sdt::Signature};
|
||||
use x86_64::instructions::port::{ReadOnlyAccess, WriteOnlyAccess};
|
||||
|
||||
use crate::arch::x86::kernel::acpi::ACPI_TABLES;
|
||||
|
||||
use super::io_port::IoPort;
|
||||
use crate::arch::x86::kernel::acpi::ACPI_TABLES;
|
||||
|
||||
pub static CMOS_ADDRESS: IoPort<u8, WriteOnlyAccess> = unsafe { IoPort::new(0x70) };
|
||||
pub static CMOS_DATA: IoPort<u8, ReadOnlyAccess> = unsafe { IoPort::new(0x71) };
|
||||
|
@ -2,11 +2,13 @@
|
||||
|
||||
use core::marker::PhantomData;
|
||||
|
||||
pub use x86_64::instructions::port::{
|
||||
PortReadAccess as IoPortReadAccess, PortWriteAccess as IoPortWriteAccess, ReadOnlyAccess,
|
||||
ReadWriteAccess, WriteOnlyAccess,
|
||||
pub use x86_64::{
|
||||
instructions::port::{
|
||||
PortReadAccess as IoPortReadAccess, PortWriteAccess as IoPortWriteAccess, ReadOnlyAccess,
|
||||
ReadWriteAccess, WriteOnlyAccess,
|
||||
},
|
||||
structures::port::{PortRead, PortWrite},
|
||||
};
|
||||
pub use x86_64::structures::port::{PortRead, PortWrite};
|
||||
|
||||
/// An I/O port, representing a specific address in the I/O address of x86.
|
||||
///
|
||||
|
@ -1,11 +1,12 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::collections::BTreeMap;
|
||||
use core::mem::size_of;
|
||||
|
||||
use alloc::collections::BTreeMap;
|
||||
use log::warn;
|
||||
use pod::Pod;
|
||||
|
||||
use super::second_stage::{PageTableEntry, PageTableFlags};
|
||||
use crate::{
|
||||
bus::pci::PciDeviceLocation,
|
||||
vm::{
|
||||
@ -15,8 +16,6 @@ use crate::{
|
||||
},
|
||||
};
|
||||
|
||||
use super::second_stage::{PageTableEntry, PageTableFlags};
|
||||
|
||||
/// Bit 0 is `Present` bit, indicating whether this entry is present.
|
||||
/// Bit 63:12 is the context-table pointer pointing to this bus's context-table.
|
||||
#[derive(Pod, Clone, Copy)]
|
||||
|
@ -1,17 +1,16 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use core::fmt::Debug;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use bitflags::bitflags;
|
||||
use log::info;
|
||||
use spin::Once;
|
||||
use trapframe::TrapFrame;
|
||||
use volatile::{access::ReadWrite, Volatile};
|
||||
|
||||
use crate::{trap::IrqLine, vm::Vaddr};
|
||||
|
||||
use super::remapping::Capability;
|
||||
use crate::{trap::IrqLine, vm::Vaddr};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct FaultEventRegisters {
|
||||
|
@ -8,6 +8,7 @@ use volatile::{
|
||||
Volatile,
|
||||
};
|
||||
|
||||
use super::{context_table::RootTable, IommuError};
|
||||
use crate::{
|
||||
arch::{
|
||||
iommu::fault,
|
||||
@ -19,8 +20,6 @@ use crate::{
|
||||
vm::paddr_to_vaddr,
|
||||
};
|
||||
|
||||
use super::{context_table::RootTable, IommuError};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct RemappingRegisters {
|
||||
version: Volatile<&'static u32, ReadOnly>,
|
||||
|
@ -1,12 +1,12 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::sync::Mutex;
|
||||
use alloc::{boxed::Box, fmt::Debug, sync::Arc, vec::Vec};
|
||||
|
||||
use spin::Once;
|
||||
use trapframe::TrapFrame;
|
||||
|
||||
use crate::{
|
||||
sync::{SpinLock, SpinLockGuard},
|
||||
sync::{Mutex, SpinLock, SpinLockGuard},
|
||||
util::recycle_allocator::RecycleAllocator,
|
||||
};
|
||||
|
||||
|
@ -1,16 +1,15 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use core::{fmt::Debug, mem::size_of, slice::Iter};
|
||||
|
||||
use acpi::{sdt::Signature, AcpiTable};
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use crate::vm::paddr_to_vaddr;
|
||||
|
||||
use super::{
|
||||
remapping::{Andd, Atsr, Drhd, Rhsa, Rmrr, Satc, Sidp},
|
||||
SdtHeaderWrapper,
|
||||
};
|
||||
use crate::vm::paddr_to_vaddr;
|
||||
|
||||
/// DMA Remapping structure. When IOMMU is enabled, the structure should be present in the ACPI table,
|
||||
/// and the user can use the DRHD table in this structure to obtain the register base addresses used to configure functions such as IOMMU.
|
||||
|
@ -3,20 +3,21 @@
|
||||
pub mod dmar;
|
||||
pub mod remapping;
|
||||
|
||||
use alloc::borrow::ToOwned;
|
||||
use core::{
|
||||
ops::{Deref, DerefMut},
|
||||
ptr::NonNull,
|
||||
};
|
||||
|
||||
use crate::vm::paddr_to_vaddr;
|
||||
use acpi::{sdt::SdtHeader, AcpiHandler, AcpiTable, AcpiTables};
|
||||
use log::{info, warn};
|
||||
use spin::Once;
|
||||
|
||||
use crate::{
|
||||
boot::{self, BootloaderAcpiArg},
|
||||
sync::SpinLock,
|
||||
vm::paddr_to_vaddr,
|
||||
};
|
||||
use acpi::{sdt::SdtHeader, AcpiHandler, AcpiTable, AcpiTables};
|
||||
use alloc::borrow::ToOwned;
|
||||
use log::{info, warn};
|
||||
use spin::Once;
|
||||
|
||||
/// RSDP information, key is the signature, value is the virtual address of the signature
|
||||
pub static ACPI_TABLES: Once<SpinLock<AcpiTables<AcpiMemoryHandler>>> = Once::new();
|
||||
|
@ -4,9 +4,8 @@
|
||||
//! This file defines these structures and provides a "Debug" implementation to see the value inside these structures.
|
||||
//! Most of the introduction are copied from Intel vt-directed-io-specification.
|
||||
|
||||
use core::{fmt::Debug, mem::size_of};
|
||||
|
||||
use alloc::{string::String, vec::Vec};
|
||||
use core::{fmt::Debug, mem::size_of};
|
||||
|
||||
/// DMA-remapping hardware unit definition (DRHD).
|
||||
///
|
||||
|
@ -1,8 +1,8 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::{vec, vec::Vec};
|
||||
|
||||
use acpi::PlatformInfo;
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use bit_field::BitField;
|
||||
use log::info;
|
||||
use spin::Once;
|
||||
|
@ -1,11 +1,12 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::sync::Mutex;
|
||||
use alloc::boxed::Box;
|
||||
use alloc::sync::Arc;
|
||||
use alloc::{boxed::Box, sync::Arc};
|
||||
|
||||
use log::info;
|
||||
use spin::Once;
|
||||
|
||||
use crate::sync::Mutex;
|
||||
|
||||
pub mod ioapic;
|
||||
pub mod x2apic;
|
||||
pub mod xapic;
|
||||
|
@ -1,11 +1,10 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::sync::Mutex;
|
||||
use crate::vm;
|
||||
use spin::Once;
|
||||
use x86::apic::xapic;
|
||||
|
||||
use super::ApicTimer;
|
||||
use crate::{sync::Mutex, vm};
|
||||
|
||||
const IA32_APIC_BASE_MSR: u32 = 0x1B;
|
||||
const IA32_APIC_BASE_MSR_BSP: u32 = 0x100; // Processor is a BSP
|
||||
|
@ -1,12 +1,14 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::arch::x86::device::io_port::{IoPort, WriteOnlyAccess};
|
||||
use crate::trap::IrqLine;
|
||||
use core::sync::atomic::Ordering::Relaxed;
|
||||
use core::sync::atomic::{AtomicBool, AtomicU8};
|
||||
use core::sync::atomic::{AtomicBool, AtomicU8, Ordering::Relaxed};
|
||||
|
||||
use log::info;
|
||||
|
||||
use crate::{
|
||||
arch::x86::device::io_port::{IoPort, WriteOnlyAccess},
|
||||
trap::IrqLine,
|
||||
};
|
||||
|
||||
static MASTER_CMD: IoPort<u8, WriteOnlyAccess> = unsafe { IoPort::new(0x20) };
|
||||
static MASTER_DATA: IoPort<u8, WriteOnlyAccess> = unsafe { IoPort::new(0x21) };
|
||||
static SLAVE_CMD: IoPort<u8, WriteOnlyAccess> = unsafe { IoPort::new(0xA0) };
|
||||
|
@ -4,6 +4,7 @@ use core::{
|
||||
arch::x86_64::_rdtsc,
|
||||
sync::atomic::{AtomicBool, AtomicU64, Ordering},
|
||||
};
|
||||
|
||||
use log::info;
|
||||
use trapframe::TrapFrame;
|
||||
use x86::cpuid::cpuid;
|
||||
|
@ -1,12 +1,13 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::sync::Mutex;
|
||||
use alloc::{collections::BTreeMap, fmt};
|
||||
|
||||
use pod::Pod;
|
||||
use x86_64::{instructions::tlb, structures::paging::PhysFrame, VirtAddr};
|
||||
|
||||
use crate::{
|
||||
config::ENTRY_COUNT,
|
||||
sync::Mutex,
|
||||
vm::{
|
||||
page_table::{table_of, PageTableEntryTrait, PageTableFlagsTrait},
|
||||
Paddr, Vaddr,
|
||||
|
@ -1,9 +1,11 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use tdx_guest::{
|
||||
serial_println, tdcall,
|
||||
tdcall::TdgVeInfo,
|
||||
tdvmcall,
|
||||
tdvmcall::{cpuid, hlt, rdmsr, wrmsr, IoSize},
|
||||
{serial_println, tdcall, tdvmcall, TdxVirtualExceptionType},
|
||||
TdxVirtualExceptionType,
|
||||
};
|
||||
|
||||
pub trait TdxTrapFrame {
|
||||
|
@ -1,22 +1,31 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::sync::Arc;
|
||||
use core::arch::x86_64::_rdtsc;
|
||||
use core::sync::atomic::{AtomicBool, AtomicU64, Ordering};
|
||||
use x86::cpuid::cpuid;
|
||||
use core::{
|
||||
arch::x86_64::_rdtsc,
|
||||
sync::atomic::{AtomicBool, AtomicU64, Ordering},
|
||||
};
|
||||
|
||||
use log::info;
|
||||
use spin::Once;
|
||||
use trapframe::TrapFrame;
|
||||
use x86::msr::{wrmsr, IA32_TSC_DEADLINE};
|
||||
|
||||
use crate::arch::kernel::tsc::init_tsc_freq;
|
||||
use crate::arch::timer::pit::OperatingMode;
|
||||
use crate::arch::x86::kernel::apic::{DivideConfig, APIC_INSTANCE};
|
||||
use crate::arch::x86::kernel::tsc::TSC_FREQ;
|
||||
use crate::trap::IrqLine;
|
||||
use x86::{
|
||||
cpuid::cpuid,
|
||||
msr::{wrmsr, IA32_TSC_DEADLINE},
|
||||
};
|
||||
|
||||
use super::TIMER_FREQ;
|
||||
use crate::{
|
||||
arch::{
|
||||
kernel::tsc::init_tsc_freq,
|
||||
timer::pit::OperatingMode,
|
||||
x86::kernel::{
|
||||
apic::{DivideConfig, APIC_INSTANCE},
|
||||
tsc::TSC_FREQ,
|
||||
},
|
||||
},
|
||||
trap::IrqLine,
|
||||
};
|
||||
|
||||
pub fn init() {
|
||||
init_tsc_freq();
|
||||
|
@ -1,15 +1,19 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::{trap::IrqLine, vm::paddr_to_vaddr};
|
||||
use acpi::{AcpiError, HpetInfo};
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use acpi::{AcpiError, HpetInfo};
|
||||
use spin::Once;
|
||||
use volatile::{
|
||||
access::{ReadOnly, ReadWrite},
|
||||
Volatile,
|
||||
};
|
||||
|
||||
use crate::arch::x86::kernel::{acpi::ACPI_TABLES, apic::ioapic};
|
||||
use crate::{
|
||||
arch::x86::kernel::{acpi::ACPI_TABLES, apic::ioapic},
|
||||
trap::IrqLine,
|
||||
vm::paddr_to_vaddr,
|
||||
};
|
||||
static HPET_INSTANCE: Once<Hpet> = Once::new();
|
||||
|
||||
const OFFSET_ID_REGISTER: usize = 0x000;
|
||||
|
@ -4,18 +4,17 @@ pub mod apic;
|
||||
pub mod hpet;
|
||||
pub mod pit;
|
||||
|
||||
use core::any::Any;
|
||||
use core::sync::atomic::{AtomicBool, AtomicU64, AtomicU8, Ordering};
|
||||
|
||||
use alloc::{boxed::Box, collections::BinaryHeap, sync::Arc, vec::Vec};
|
||||
use core::{
|
||||
any::Any,
|
||||
sync::atomic::{AtomicBool, AtomicU64, AtomicU8, Ordering},
|
||||
};
|
||||
|
||||
use spin::Once;
|
||||
use trapframe::TrapFrame;
|
||||
|
||||
use crate::arch::x86::kernel;
|
||||
use crate::sync::SpinLock;
|
||||
use crate::trap::IrqLine;
|
||||
|
||||
use self::apic::APIC_TIMER_CALLBACK;
|
||||
use crate::{arch::x86::kernel, sync::SpinLock, trap::IrqLine};
|
||||
|
||||
/// The timer frequency (Hz). Here we choose 1000Hz since 1000Hz is easier for unit conversion and
|
||||
/// convenient for timer. What's more, the frequency cannot be set too high or too low, 1000Hz is
|
||||
|
@ -15,6 +15,7 @@ use alloc::{
|
||||
vec,
|
||||
vec::Vec,
|
||||
};
|
||||
|
||||
use log::warn;
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
|
@ -7,13 +7,13 @@
|
||||
pub mod kcmdline;
|
||||
pub mod memory_region;
|
||||
|
||||
use alloc::{string::String, vec::Vec};
|
||||
|
||||
use kcmdline::KCmdlineArg;
|
||||
use spin::Once;
|
||||
|
||||
use self::memory_region::MemoryRegion;
|
||||
|
||||
use alloc::{string::String, vec::Vec};
|
||||
use spin::Once;
|
||||
|
||||
/// ACPI information from the bootloader.
|
||||
///
|
||||
/// The boot crate can choose either providing the raw RSDP physical address or
|
||||
@ -119,9 +119,10 @@ pub fn call_aster_main() -> ! {
|
||||
}
|
||||
#[cfg(ktest)]
|
||||
{
|
||||
use crate::arch::qemu::{exit_qemu, QemuExitCode};
|
||||
use alloc::{boxed::Box, string::ToString};
|
||||
use core::any::Any;
|
||||
|
||||
use crate::arch::qemu::{exit_qemu, QemuExitCode};
|
||||
crate::init();
|
||||
let fn_catch_unwind = &(unwinding::panic::catch_unwind::<(), fn()>
|
||||
as fn(fn()) -> Result<(), Box<(dyn Any + Send + 'static)>>);
|
||||
|
@ -1,11 +1,11 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::{collections::VecDeque, fmt::Debug, sync::Arc, vec::Vec};
|
||||
|
||||
use log::{debug, error};
|
||||
|
||||
use crate::bus::BusProbeError;
|
||||
|
||||
use super::device::MmioCommonDevice;
|
||||
use crate::bus::BusProbeError;
|
||||
|
||||
pub trait MmioDevice: Sync + Send + Debug {
|
||||
fn device_id(&self) -> u32;
|
||||
|
@ -3,14 +3,13 @@
|
||||
use int_to_c_enum::TryFromInt;
|
||||
use log::info;
|
||||
|
||||
use super::VIRTIO_MMIO_MAGIC;
|
||||
use crate::{
|
||||
io_mem::IoMem,
|
||||
trap::IrqLine,
|
||||
vm::{paddr_to_vaddr, Paddr, VmIo},
|
||||
};
|
||||
|
||||
use super::VIRTIO_MMIO_MAGIC;
|
||||
|
||||
/// MMIO Common device.
|
||||
/// TODO: Implement universal access to MMIO devices since we are temporarily
|
||||
/// using specific virtio device as implementation of CommonDevice.
|
||||
|
@ -5,18 +5,17 @@
|
||||
pub mod bus;
|
||||
pub mod device;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use core::ops::Range;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use log::debug;
|
||||
|
||||
use self::bus::MmioBus;
|
||||
use crate::{
|
||||
arch::kernel::IO_APIC, bus::mmio::device::MmioCommonDevice, sync::SpinLock, trap::IrqLine,
|
||||
vm::paddr_to_vaddr,
|
||||
};
|
||||
|
||||
use self::bus::MmioBus;
|
||||
|
||||
const VIRTIO_MMIO_MAGIC: u32 = 0x74726976;
|
||||
|
||||
pub static MMIO_BUS: SpinLock<MmioBus> = SpinLock::new(MmioBus::new());
|
||||
|
@ -1,13 +1,12 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::{collections::VecDeque, sync::Arc, vec::Vec};
|
||||
use core::fmt::Debug;
|
||||
|
||||
use alloc::{collections::VecDeque, sync::Arc, vec::Vec};
|
||||
use log::{debug, error};
|
||||
|
||||
use crate::bus::BusProbeError;
|
||||
|
||||
use super::{device_info::PciDeviceId, PciCommonDevice};
|
||||
use crate::bus::BusProbeError;
|
||||
|
||||
pub trait PciDevice: Sync + Send + Debug {
|
||||
fn device_id(&self) -> PciDeviceId;
|
||||
|
@ -3,7 +3,6 @@
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use self::{msix::CapabilityMsixData, vendor::CapabilityVndrData};
|
||||
|
||||
use super::{
|
||||
cfg_space::{PciDeviceCommonCfgOffset, Status},
|
||||
common_device::PciCommonDevice,
|
||||
|
@ -1,7 +1,9 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::bus::pci::{common_device::PciCommonDevice, device_info::PciDeviceLocation};
|
||||
use crate::{Error, Result};
|
||||
use crate::{
|
||||
bus::pci::{common_device::PciCommonDevice, device_info::PciDeviceLocation},
|
||||
Error, Result,
|
||||
};
|
||||
|
||||
/// Vendor specific capability. Users can access this capability area at will,
|
||||
/// except for the PCI configuration space which cannot be accessed at will through this structure.
|
||||
|
@ -1,11 +1,11 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::sync::Arc;
|
||||
|
||||
use bitflags::bitflags;
|
||||
|
||||
use crate::{io_mem::IoMem, Error, Result};
|
||||
|
||||
use super::PciDeviceLocation;
|
||||
use crate::{io_mem::IoMem, Error, Result};
|
||||
|
||||
#[repr(u16)]
|
||||
pub enum PciDeviceCommonCfgOffset {
|
||||
|
@ -2,9 +2,8 @@
|
||||
|
||||
use core::iter;
|
||||
|
||||
use crate::arch::pci::{PCI_ADDRESS_PORT, PCI_DATA_PORT};
|
||||
|
||||
use super::cfg_space::PciDeviceCommonCfgOffset;
|
||||
use crate::arch::pci::{PCI_ADDRESS_PORT, PCI_DATA_PORT};
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
pub struct PciDeviceId {
|
||||
|
@ -56,10 +56,10 @@ pub mod cfg_space;
|
||||
pub mod common_device;
|
||||
mod device_info;
|
||||
|
||||
use crate::sync::Mutex;
|
||||
pub use device_info::{PciDeviceId, PciDeviceLocation};
|
||||
|
||||
use self::{bus::PciBus, common_device::PciCommonDevice};
|
||||
use crate::sync::Mutex;
|
||||
|
||||
pub static PCI_BUS: Mutex<PciBus> = Mutex::new(PciBus::new());
|
||||
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
//! CPU.
|
||||
|
||||
use core::{cell::UnsafeCell, ops::Deref};
|
||||
|
||||
use crate::trap::disable_local;
|
||||
use core::cell::UnsafeCell;
|
||||
use core::ops::Deref;
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(target_arch = "x86_64")]{
|
||||
|
@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use core::{mem::size_of, ops::Range};
|
||||
|
||||
use pod::Pod;
|
||||
|
||||
use crate::{
|
||||
|
@ -43,12 +43,11 @@ pub mod user;
|
||||
mod util;
|
||||
pub mod vm;
|
||||
|
||||
pub use self::cpu::CpuLocal;
|
||||
pub use self::error::Error;
|
||||
pub use self::prelude::Result;
|
||||
#[cfg(feature = "intel_tdx")]
|
||||
use tdx_guest::init_tdx;
|
||||
|
||||
pub use self::{cpu::CpuLocal, error::Error, prelude::Result};
|
||||
|
||||
pub fn init() {
|
||||
arch::before_all_init();
|
||||
logger::init();
|
||||
|
@ -1,9 +1,9 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::{config::DEFAULT_LOG_LEVEL, early_println};
|
||||
|
||||
use log::{Metadata, Record};
|
||||
|
||||
use crate::{config::DEFAULT_LOG_LEVEL, early_println};
|
||||
|
||||
const LOGGER: Logger = Logger {};
|
||||
|
||||
struct Logger {}
|
||||
|
@ -5,14 +5,16 @@
|
||||
use alloc::{boxed::Box, string::ToString};
|
||||
use core::ffi::c_void;
|
||||
|
||||
use crate::arch::qemu::{exit_qemu, QemuExitCode};
|
||||
use crate::{early_print, early_println};
|
||||
use log::error;
|
||||
|
||||
use crate::{
|
||||
arch::qemu::{exit_qemu, QemuExitCode},
|
||||
early_print, early_println,
|
||||
};
|
||||
|
||||
extern crate cfg_if;
|
||||
extern crate gimli;
|
||||
use gimli::Register;
|
||||
|
||||
use unwinding::{
|
||||
abi::{
|
||||
UnwindContext, UnwindReasonCode, _Unwind_Backtrace, _Unwind_FindEnclosingFunction,
|
||||
|
@ -4,9 +4,7 @@
|
||||
|
||||
pub type Result<T> = core::result::Result<T, crate::error::Error>;
|
||||
|
||||
pub(crate) use alloc::boxed::Box;
|
||||
pub(crate) use alloc::sync::Arc;
|
||||
pub(crate) use alloc::vec::Vec;
|
||||
pub(crate) use alloc::{boxed::Box, sync::Arc, vec::Vec};
|
||||
pub(crate) use core::any::Any;
|
||||
|
||||
pub use crate::vm::{Paddr, Vaddr};
|
||||
|
@ -1,7 +1,9 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use core::fmt::{self};
|
||||
use core::sync::atomic::{AtomicU64, Ordering::Relaxed};
|
||||
use core::{
|
||||
fmt::{self},
|
||||
sync::atomic::{AtomicU64, Ordering::Relaxed},
|
||||
};
|
||||
|
||||
use align_ext::AlignExt;
|
||||
|
||||
|
@ -10,10 +10,12 @@ mod rwmutex;
|
||||
mod spin;
|
||||
mod wait;
|
||||
|
||||
pub use self::atomic_bits::AtomicBits;
|
||||
pub use self::mutex::{Mutex, MutexGuard};
|
||||
// pub use self::rcu::{pass_quiescent_state, OwnerPtr, Rcu, RcuReadGuard, RcuReclaimer};
|
||||
pub use self::rwlock::{RwLock, RwLockReadGuard, RwLockUpgradeableGuard, RwLockWriteGuard};
|
||||
pub use self::rwmutex::{RwMutex, RwMutexReadGuard, RwMutexUpgradeableGuard, RwMutexWriteGuard};
|
||||
pub use self::spin::{SpinLock, SpinLockGuard};
|
||||
pub use self::wait::WaitQueue;
|
||||
pub use self::{
|
||||
atomic_bits::AtomicBits,
|
||||
mutex::{Mutex, MutexGuard},
|
||||
rwlock::{RwLock, RwLockReadGuard, RwLockUpgradeableGuard, RwLockWriteGuard},
|
||||
rwmutex::{RwMutex, RwMutexReadGuard, RwMutexUpgradeableGuard, RwMutexWriteGuard},
|
||||
spin::{SpinLock, SpinLockGuard},
|
||||
wait::WaitQueue,
|
||||
};
|
||||
|
@ -1,11 +1,13 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use super::WaitQueue;
|
||||
use core::cell::UnsafeCell;
|
||||
use core::ops::{Deref, DerefMut};
|
||||
use core::{
|
||||
cell::UnsafeCell,
|
||||
fmt,
|
||||
ops::{Deref, DerefMut},
|
||||
sync::atomic::{AtomicBool, Ordering},
|
||||
};
|
||||
|
||||
use core::fmt;
|
||||
use core::sync::atomic::{AtomicBool, Ordering};
|
||||
use super::WaitQueue;
|
||||
|
||||
/// A mutex with waitqueue.
|
||||
pub struct Mutex<T> {
|
||||
|
@ -1,14 +1,19 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use core::cell::UnsafeCell;
|
||||
use core::fmt;
|
||||
use core::ops::{Deref, DerefMut};
|
||||
use core::sync::atomic::AtomicUsize;
|
||||
use core::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed, Release};
|
||||
use core::{
|
||||
cell::UnsafeCell,
|
||||
fmt,
|
||||
ops::{Deref, DerefMut},
|
||||
sync::atomic::{
|
||||
AtomicUsize,
|
||||
Ordering::{AcqRel, Acquire, Relaxed, Release},
|
||||
},
|
||||
};
|
||||
|
||||
use crate::task::{disable_preempt, DisablePreemptGuard};
|
||||
use crate::trap::disable_local;
|
||||
use crate::trap::DisabledLocalIrqGuard;
|
||||
use crate::{
|
||||
task::{disable_preempt, DisablePreemptGuard},
|
||||
trap::{disable_local, DisabledLocalIrqGuard},
|
||||
};
|
||||
|
||||
/// Spin-based Read-write Lock
|
||||
///
|
||||
|
@ -1,10 +1,14 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use core::cell::UnsafeCell;
|
||||
use core::fmt;
|
||||
use core::ops::{Deref, DerefMut};
|
||||
use core::sync::atomic::AtomicUsize;
|
||||
use core::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed, Release};
|
||||
use core::{
|
||||
cell::UnsafeCell,
|
||||
fmt,
|
||||
ops::{Deref, DerefMut},
|
||||
sync::atomic::{
|
||||
AtomicUsize,
|
||||
Ordering::{AcqRel, Acquire, Relaxed, Release},
|
||||
},
|
||||
};
|
||||
|
||||
use super::WaitQueue;
|
||||
|
||||
|
@ -1,13 +1,16 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use core::cell::UnsafeCell;
|
||||
use core::fmt;
|
||||
use core::ops::{Deref, DerefMut};
|
||||
use core::sync::atomic::{AtomicBool, Ordering};
|
||||
use core::{
|
||||
cell::UnsafeCell,
|
||||
fmt,
|
||||
ops::{Deref, DerefMut},
|
||||
sync::atomic::{AtomicBool, Ordering},
|
||||
};
|
||||
|
||||
use crate::task::{disable_preempt, DisablePreemptGuard};
|
||||
use crate::trap::disable_local;
|
||||
use crate::trap::DisabledLocalIrqGuard;
|
||||
use crate::{
|
||||
task::{disable_preempt, DisablePreemptGuard},
|
||||
trap::{disable_local, DisabledLocalIrqGuard},
|
||||
};
|
||||
|
||||
/// A spin lock.
|
||||
pub struct SpinLock<T> {
|
||||
|
@ -1,13 +1,18 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use super::SpinLock;
|
||||
use crate::arch::timer::{add_timeout_list, TIMER_FREQ};
|
||||
use alloc::{collections::VecDeque, sync::Arc};
|
||||
use bitflags::bitflags;
|
||||
use core::sync::atomic::{AtomicBool, Ordering};
|
||||
use core::time::Duration;
|
||||
use core::{
|
||||
sync::atomic::{AtomicBool, Ordering},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use crate::task::{add_task, current_task, schedule, Task, TaskStatus};
|
||||
use bitflags::bitflags;
|
||||
|
||||
use super::SpinLock;
|
||||
use crate::{
|
||||
arch::timer::{add_timeout_list, TIMER_FREQ},
|
||||
task::{add_task, current_task, schedule, Task, TaskStatus},
|
||||
};
|
||||
|
||||
/// A wait queue.
|
||||
///
|
||||
|
@ -8,7 +8,9 @@ mod scheduler;
|
||||
#[allow(clippy::module_inception)]
|
||||
mod task;
|
||||
|
||||
pub use self::priority::Priority;
|
||||
pub use self::processor::{current_task, disable_preempt, preempt, schedule, DisablePreemptGuard};
|
||||
pub use self::scheduler::{add_task, set_scheduler, Scheduler};
|
||||
pub use self::task::{Task, TaskAdapter, TaskOptions, TaskStatus};
|
||||
pub use self::{
|
||||
priority::Priority,
|
||||
processor::{current_task, disable_preempt, preempt, schedule, DisablePreemptGuard},
|
||||
scheduler::{add_task, set_scheduler, Scheduler},
|
||||
task::{Task, TaskAdapter, TaskOptions, TaskStatus},
|
||||
};
|
||||
|
@ -1,20 +1,16 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use core::sync::atomic::AtomicUsize;
|
||||
use alloc::sync::Arc;
|
||||
use core::sync::atomic::{AtomicUsize, Ordering::Relaxed};
|
||||
|
||||
use crate::cpu_local;
|
||||
use crate::sync::Mutex;
|
||||
use crate::trap::disable_local;
|
||||
|
||||
use core::sync::atomic::Ordering::Relaxed;
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
use super::{
|
||||
scheduler::{fetch_task, GLOBAL_SCHEDULER},
|
||||
task::{context_switch, TaskContext},
|
||||
Task, TaskStatus,
|
||||
};
|
||||
use alloc::sync::Arc;
|
||||
use lazy_static::lazy_static;
|
||||
use crate::{cpu_local, sync::Mutex, trap::disable_local};
|
||||
|
||||
pub struct Processor {
|
||||
current: Option<Arc<Task>>,
|
||||
|
@ -1,11 +1,9 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::sync::SpinLock;
|
||||
use crate::task::Task;
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
use crate::{prelude::*, sync::SpinLock, task::Task};
|
||||
|
||||
lazy_static! {
|
||||
pub(crate) static ref GLOBAL_SCHEDULER: SpinLock<GlobalScheduler> =
|
||||
SpinLock::new(GlobalScheduler { scheduler: None });
|
||||
|
@ -1,20 +1,21 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::arch::mm::PageTableFlags;
|
||||
use crate::config::{KERNEL_STACK_SIZE, PAGE_SIZE};
|
||||
use crate::cpu::CpuSet;
|
||||
use crate::prelude::*;
|
||||
use crate::sync::{Mutex, MutexGuard};
|
||||
use crate::user::UserSpace;
|
||||
use crate::vm::page_table::KERNEL_PAGE_TABLE;
|
||||
use crate::vm::{VmAllocOptions, VmSegment};
|
||||
use intrusive_collections::{intrusive_adapter, LinkedListAtomicLink};
|
||||
|
||||
use intrusive_collections::intrusive_adapter;
|
||||
use intrusive_collections::LinkedListAtomicLink;
|
||||
|
||||
use super::add_task;
|
||||
use super::priority::Priority;
|
||||
use super::processor::{current_task, schedule};
|
||||
use super::{
|
||||
add_task,
|
||||
priority::Priority,
|
||||
processor::{current_task, schedule},
|
||||
};
|
||||
use crate::{
|
||||
arch::mm::PageTableFlags,
|
||||
config::{KERNEL_STACK_SIZE, PAGE_SIZE},
|
||||
cpu::CpuSet,
|
||||
prelude::*,
|
||||
sync::{Mutex, MutexGuard},
|
||||
user::UserSpace,
|
||||
vm::{page_table::KERNEL_PAGE_TABLE, VmAllocOptions, VmSegment},
|
||||
};
|
||||
|
||||
core::arch::global_asm!(include_str!("switch.S"));
|
||||
|
||||
|
@ -2,12 +2,14 @@
|
||||
|
||||
//! Timer.
|
||||
|
||||
use crate::arch::timer::{add_timeout_list, TimerCallback, TICK};
|
||||
use crate::prelude::*;
|
||||
use crate::{arch::timer::TIMER_FREQ, sync::SpinLock};
|
||||
use core::{sync::atomic::Ordering, time::Duration};
|
||||
|
||||
pub use crate::arch::timer::read_monotonic_milli_seconds;
|
||||
use crate::{
|
||||
arch::timer::{add_timeout_list, TimerCallback, TICK, TIMER_FREQ},
|
||||
prelude::*,
|
||||
sync::SpinLock,
|
||||
};
|
||||
|
||||
/// A timer invokes a callback function after a specified span of time elapsed.
|
||||
///
|
||||
|
@ -2,14 +2,14 @@
|
||||
|
||||
use core::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
use crate::{arch::irq::IRQ_LIST, cpu::CpuException, cpu_local};
|
||||
|
||||
#[cfg(feature = "intel_tdx")]
|
||||
use crate::arch::tdx_guest::{handle_virtual_exception, TdxTrapFrame};
|
||||
#[cfg(feature = "intel_tdx")]
|
||||
use tdx_guest::tdcall;
|
||||
use trapframe::TrapFrame;
|
||||
|
||||
#[cfg(feature = "intel_tdx")]
|
||||
use crate::arch::tdx_guest::{handle_virtual_exception, TdxTrapFrame};
|
||||
use crate::{arch::irq::IRQ_LIST, cpu::CpuException, cpu_local};
|
||||
|
||||
#[cfg(feature = "intel_tdx")]
|
||||
impl TdxTrapFrame for TrapFrame {
|
||||
fn rax(&self) -> usize {
|
||||
|
@ -1,12 +1,16 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::arch::irq::{self, IrqCallbackHandle, NOT_USING_IRQ};
|
||||
use crate::task::{disable_preempt, DisablePreemptGuard};
|
||||
use crate::{prelude::*, Error};
|
||||
|
||||
use core::fmt::Debug;
|
||||
|
||||
use trapframe::TrapFrame;
|
||||
|
||||
use crate::{
|
||||
arch::irq::{self, IrqCallbackHandle, NOT_USING_IRQ},
|
||||
prelude::*,
|
||||
task::{disable_preempt, DisablePreemptGuard},
|
||||
Error,
|
||||
};
|
||||
|
||||
pub type IrqCallbackFunction = dyn Fn(&TrapFrame) + Sync + Send + 'static;
|
||||
|
||||
/// An Interrupt ReQuest(IRQ) line. User can use `alloc` or `alloc_specific` to get specific IRQ line.
|
||||
|
@ -3,11 +3,12 @@
|
||||
mod handler;
|
||||
mod irq;
|
||||
|
||||
pub(crate) use self::handler::call_irq_callback_functions;
|
||||
pub use self::irq::{disable_local, DisabledLocalIrqGuard, IrqCallbackFunction, IrqLine};
|
||||
pub use handler::in_interrupt_context;
|
||||
pub use trapframe::TrapFrame;
|
||||
|
||||
pub(crate) use self::handler::call_irq_callback_functions;
|
||||
pub use self::irq::{disable_local, DisabledLocalIrqGuard, IrqCallbackFunction, IrqLine};
|
||||
|
||||
pub(crate) fn init() {
|
||||
unsafe {
|
||||
trapframe::init();
|
||||
|
@ -2,12 +2,10 @@
|
||||
|
||||
//! User space.
|
||||
|
||||
use crate::cpu::UserContext;
|
||||
use crate::prelude::*;
|
||||
use crate::task::Task;
|
||||
use crate::vm::VmSpace;
|
||||
use trapframe::TrapFrame;
|
||||
|
||||
use crate::{cpu::UserContext, prelude::*, task::Task, vm::VmSpace};
|
||||
|
||||
/// A user space.
|
||||
///
|
||||
/// Each user space has a VM address space and allows a task to execute in
|
||||
|
@ -3,15 +3,16 @@
|
||||
use alloc::sync::Arc;
|
||||
use core::ops::Deref;
|
||||
|
||||
use crate::arch::{iommu, mm::PageTableFlags};
|
||||
use crate::vm::{
|
||||
dma::{dma_type, Daddr, DmaType},
|
||||
paddr_to_vaddr,
|
||||
page_table::KERNEL_PAGE_TABLE,
|
||||
HasPaddr, Paddr, VmIo, VmReader, VmSegment, VmWriter, PAGE_SIZE,
|
||||
};
|
||||
|
||||
use super::{check_and_insert_dma_mapping, remove_dma_mapping, DmaError, HasDaddr};
|
||||
use crate::{
|
||||
arch::{iommu, mm::PageTableFlags},
|
||||
vm::{
|
||||
dma::{dma_type, Daddr, DmaType},
|
||||
paddr_to_vaddr,
|
||||
page_table::KERNEL_PAGE_TABLE,
|
||||
HasPaddr, Paddr, VmIo, VmReader, VmSegment, VmWriter, PAGE_SIZE,
|
||||
},
|
||||
};
|
||||
|
||||
/// A coherent (or consistent) DMA mapping,
|
||||
/// which guarantees that the device and the CPU can
|
||||
@ -163,9 +164,10 @@ impl HasPaddr for DmaCoherent {
|
||||
|
||||
#[if_cfg_ktest]
|
||||
mod test {
|
||||
use alloc::vec;
|
||||
|
||||
use super::*;
|
||||
use crate::vm::VmAllocOptions;
|
||||
use alloc::vec;
|
||||
|
||||
#[ktest]
|
||||
fn map_with_coherent_device() {
|
||||
|
@ -1,18 +1,17 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::sync::Arc;
|
||||
use core::arch::x86_64::_mm_clflush;
|
||||
use core::ops::Range;
|
||||
|
||||
use crate::arch::iommu;
|
||||
use crate::error::Error;
|
||||
use crate::vm::{
|
||||
dma::{dma_type, Daddr, DmaType},
|
||||
HasPaddr, Paddr, VmSegment, PAGE_SIZE,
|
||||
};
|
||||
use crate::vm::{VmIo, VmReader, VmWriter};
|
||||
use core::{arch::x86_64::_mm_clflush, ops::Range};
|
||||
|
||||
use super::{check_and_insert_dma_mapping, remove_dma_mapping, DmaError, HasDaddr};
|
||||
use crate::{
|
||||
arch::iommu,
|
||||
error::Error,
|
||||
vm::{
|
||||
dma::{dma_type, Daddr, DmaType},
|
||||
HasPaddr, Paddr, VmIo, VmReader, VmSegment, VmWriter, PAGE_SIZE,
|
||||
},
|
||||
};
|
||||
|
||||
/// A streaming DMA mapping. Users must synchronize data
|
||||
/// before reading or after writing to ensure consistency.
|
||||
@ -198,9 +197,10 @@ impl HasPaddr for DmaStream {
|
||||
|
||||
#[if_cfg_ktest]
|
||||
mod test {
|
||||
use alloc::vec;
|
||||
|
||||
use super::*;
|
||||
use crate::vm::VmAllocOptions;
|
||||
use alloc::vec;
|
||||
|
||||
#[ktest]
|
||||
fn streaming_map() {
|
||||
|
@ -4,14 +4,13 @@ mod dma_coherent;
|
||||
mod dma_stream;
|
||||
|
||||
use alloc::collections::BTreeSet;
|
||||
use spin::Once;
|
||||
|
||||
use crate::{arch::iommu::has_iommu, config::PAGE_SIZE, sync::SpinLock};
|
||||
|
||||
use super::Paddr;
|
||||
|
||||
pub use dma_coherent::DmaCoherent;
|
||||
pub use dma_stream::{DmaDirection, DmaStream};
|
||||
use spin::Once;
|
||||
|
||||
use super::Paddr;
|
||||
use crate::{arch::iommu::has_iommu, config::PAGE_SIZE, sync::SpinLock};
|
||||
|
||||
/// If a device performs DMA to read or write system
|
||||
/// memory, the addresses used by the device are device addresses.
|
||||
|
@ -6,13 +6,12 @@ use core::{
|
||||
marker::PhantomData,
|
||||
ops::{BitAnd, BitOr, Not, Range},
|
||||
};
|
||||
|
||||
use pod::Pod;
|
||||
|
||||
use super::{frame_allocator, HasPaddr, Paddr, VmIo};
|
||||
use crate::{config::PAGE_SIZE, prelude::*, Error};
|
||||
|
||||
use super::{frame_allocator, HasPaddr};
|
||||
use super::{Paddr, VmIo};
|
||||
|
||||
/// A collection of page frames (physical memory pages).
|
||||
///
|
||||
/// For the most parts, `VmFrameVec` is like `Vec<VmFrame>`. But the
|
||||
|
@ -1,15 +1,18 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use align_ext::AlignExt;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use align_ext::AlignExt;
|
||||
use buddy_system_allocator::FrameAllocator;
|
||||
use log::info;
|
||||
use spin::Once;
|
||||
|
||||
use crate::boot::memory_region::{MemoryRegion, MemoryRegionType};
|
||||
use crate::{config::PAGE_SIZE, sync::SpinLock};
|
||||
|
||||
use super::{frame::VmFrameFlags, VmFrame, VmFrameVec, VmSegment};
|
||||
use crate::{
|
||||
boot::memory_region::{MemoryRegion, MemoryRegionType},
|
||||
config::PAGE_SIZE,
|
||||
sync::SpinLock,
|
||||
};
|
||||
|
||||
pub(super) static FRAME_ALLOCATOR: Once<SpinLock<FrameAllocator>> = Once::new();
|
||||
|
||||
|
@ -1,20 +1,23 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::config::{KERNEL_HEAP_SIZE, PAGE_SIZE};
|
||||
use crate::prelude::*;
|
||||
use crate::sync::SpinLock;
|
||||
use crate::trap::disable_local;
|
||||
use crate::vm::frame_allocator::FRAME_ALLOCATOR;
|
||||
use crate::Error;
|
||||
use align_ext::AlignExt;
|
||||
use buddy_system_allocator::Heap;
|
||||
use core::{
|
||||
alloc::{GlobalAlloc, Layout},
|
||||
ptr::NonNull,
|
||||
};
|
||||
|
||||
use align_ext::AlignExt;
|
||||
use buddy_system_allocator::Heap;
|
||||
use log::debug;
|
||||
|
||||
use super::paddr_to_vaddr;
|
||||
use crate::{
|
||||
config::{KERNEL_HEAP_SIZE, PAGE_SIZE},
|
||||
prelude::*,
|
||||
sync::SpinLock,
|
||||
trap::disable_local,
|
||||
vm::frame_allocator::FRAME_ALLOCATOR,
|
||||
Error,
|
||||
};
|
||||
|
||||
#[global_allocator]
|
||||
static HEAP_ALLOCATOR: LockedHeapWithRescue<32> = LockedHeapWithRescue::new(rescue);
|
||||
|
@ -1,9 +1,9 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::prelude::*;
|
||||
use inherit_methods_macro::inherit_methods;
|
||||
use pod::Pod;
|
||||
|
||||
use inherit_methods_macro::inherit_methods;
|
||||
use crate::prelude::*;
|
||||
|
||||
/// A trait that enables reading/writing data from/to a VM object,
|
||||
/// e.g., `VmSpace`, `VmFrameVec`, and `VmFrame`.
|
||||
|
@ -1,15 +1,16 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::collections::{btree_map::Entry, BTreeMap};
|
||||
use core::fmt;
|
||||
|
||||
use super::page_table::{PageTable, PageTableConfig, UserMode};
|
||||
use crate::{
|
||||
arch::mm::{PageTableEntry, PageTableFlags},
|
||||
config::{PAGE_SIZE, PHYS_OFFSET},
|
||||
vm::is_page_aligned,
|
||||
vm::{VmAllocOptions, VmFrame, VmFrameVec, VmReader, VmWriter},
|
||||
prelude::*,
|
||||
vm::{is_page_aligned, VmAllocOptions, VmFrame, VmFrameVec, VmReader, VmWriter},
|
||||
Error,
|
||||
};
|
||||
use crate::{prelude::*, Error};
|
||||
use alloc::collections::{btree_map::Entry, BTreeMap};
|
||||
use core::fmt;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct MapArea {
|
||||
|
@ -19,24 +19,23 @@ mod options;
|
||||
pub(crate) mod page_table;
|
||||
mod space;
|
||||
|
||||
use crate::config::{KERNEL_OFFSET, PAGE_SIZE, PHYS_OFFSET};
|
||||
use alloc::{borrow::ToOwned, vec::Vec};
|
||||
|
||||
pub use self::dma::{DmaCoherent, DmaDirection, DmaStream, HasDaddr};
|
||||
pub use self::frame::{VmFrame, VmFrameVec, VmFrameVecIter, VmReader, VmSegment, VmWriter};
|
||||
pub use self::io::VmIo;
|
||||
pub use self::options::VmAllocOptions;
|
||||
pub use self::space::{VmMapOptions, VmPerm, VmSpace};
|
||||
|
||||
pub use self::{
|
||||
memory_set::{MapArea, MemorySet},
|
||||
page_table::PageTable,
|
||||
};
|
||||
|
||||
use alloc::borrow::ToOwned;
|
||||
use alloc::vec::Vec;
|
||||
use spin::Once;
|
||||
|
||||
use crate::boot::memory_region::{MemoryRegion, MemoryRegionType};
|
||||
pub use self::{
|
||||
dma::{DmaCoherent, DmaDirection, DmaStream, HasDaddr},
|
||||
frame::{VmFrame, VmFrameVec, VmFrameVecIter, VmReader, VmSegment, VmWriter},
|
||||
io::VmIo,
|
||||
memory_set::{MapArea, MemorySet},
|
||||
options::VmAllocOptions,
|
||||
page_table::PageTable,
|
||||
space::{VmMapOptions, VmPerm, VmSpace},
|
||||
};
|
||||
use crate::{
|
||||
boot::memory_region::{MemoryRegion, MemoryRegionType},
|
||||
config::{KERNEL_OFFSET, PAGE_SIZE, PHYS_OFFSET},
|
||||
};
|
||||
|
||||
/// Get physical address trait
|
||||
pub trait HasPaddr {
|
||||
|
@ -1,8 +1,7 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::{prelude::*, Error};
|
||||
|
||||
use super::{frame::VmFrameFlags, frame_allocator, VmFrame, VmFrameVec, VmSegment};
|
||||
use crate::{prelude::*, Error};
|
||||
|
||||
/// Options for allocating physical memory pages (or frames).
|
||||
///
|
||||
|
@ -1,5 +1,12 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::{vec, vec::Vec};
|
||||
use core::{fmt::Debug, marker::PhantomData, mem::size_of};
|
||||
|
||||
use log::trace;
|
||||
use pod::Pod;
|
||||
use spin::Once;
|
||||
|
||||
use super::{paddr_to_vaddr, Paddr, Vaddr, VmAllocOptions};
|
||||
use crate::{
|
||||
arch::mm::{is_kernel_vaddr, is_user_vaddr, tlb_flush, PageTableEntry},
|
||||
@ -7,11 +14,6 @@ use crate::{
|
||||
sync::SpinLock,
|
||||
vm::VmFrame,
|
||||
};
|
||||
use alloc::{vec, vec::Vec};
|
||||
use core::{fmt::Debug, marker::PhantomData, mem::size_of};
|
||||
use log::trace;
|
||||
use pod::Pod;
|
||||
use spin::Once;
|
||||
|
||||
pub trait PageTableFlagsTrait: Clone + Copy + Sized + Pod + Debug {
|
||||
fn new() -> Self;
|
||||
|
@ -1,17 +1,11 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::arch::mm::PageTableFlags;
|
||||
use crate::config::PAGE_SIZE;
|
||||
use crate::sync::Mutex;
|
||||
use bitflags::bitflags;
|
||||
use core::ops::Range;
|
||||
|
||||
use super::VmFrameVec;
|
||||
use super::{is_page_aligned, Vaddr};
|
||||
use super::{MapArea, MemorySet};
|
||||
use crate::{prelude::*, Error};
|
||||
use bitflags::bitflags;
|
||||
|
||||
use super::VmIo;
|
||||
use super::{is_page_aligned, MapArea, MemorySet, Vaddr, VmFrameVec, VmIo};
|
||||
use crate::{arch::mm::PageTableFlags, config::PAGE_SIZE, prelude::*, sync::Mutex, Error};
|
||||
|
||||
/// Virtual memory space.
|
||||
///
|
||||
|
@ -3,17 +3,17 @@
|
||||
//! Test runner enabling control over the tests.
|
||||
//!
|
||||
|
||||
use alloc::{string::String, vec::Vec};
|
||||
use core::format_args;
|
||||
|
||||
use owo_colors::OwoColorize;
|
||||
|
||||
use crate::{
|
||||
path::{KtestPath, SuffixTrie},
|
||||
tree::{KtestCrate, KtestTree},
|
||||
CatchUnwindImpl, KtestError, KtestItem, KtestIter,
|
||||
};
|
||||
|
||||
use alloc::{string::String, vec::Vec};
|
||||
use core::format_args;
|
||||
|
||||
use owo_colors::OwoColorize;
|
||||
|
||||
pub enum KtestResult {
|
||||
Ok,
|
||||
Failed,
|
||||
|
@ -262,10 +262,10 @@ const EDDMAXNR: usize = 6;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
use core::mem::offset_of;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_screen_info_offsets() {
|
||||
assert_eq!(offset_of!(ScreenInfo, orig_x), 0x00);
|
||||
|
@ -22,9 +22,8 @@ use std::{
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use xmas_elf::program::SegmentData;
|
||||
|
||||
use mapping::{SetupFileOffset, SetupVA};
|
||||
use xmas_elf::program::SegmentData;
|
||||
|
||||
/// The type of the bzImage that we are building through `make_bzimage`.
|
||||
///
|
||||
|
@ -8,11 +8,11 @@
|
||||
//! The reference to the Linux PE header definition:
|
||||
//! https://github.com/torvalds/linux/blob/master/include/linux/pe.h
|
||||
|
||||
use std::{mem::size_of, ops::Range};
|
||||
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use serde::Serialize;
|
||||
|
||||
use std::{mem::size_of, ops::Range};
|
||||
|
||||
use crate::mapping::{SetupFileOffset, SetupVA, LEGACY_SETUP_SEC_SIZE, SETUP32_LMA};
|
||||
|
||||
// The MS-DOS header.
|
||||
|
@ -1,15 +1,16 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use linux_boot_params::BootParams;
|
||||
use uefi::{
|
||||
data_types::Handle,
|
||||
proto::loaded_image::LoadedImage,
|
||||
table::{boot::MemoryMap, Boot, Runtime, SystemTable},
|
||||
};
|
||||
|
||||
use linux_boot_params::BootParams;
|
||||
|
||||
use super::paging::{Ia32eFlags, PageNumber, PageTableCreator};
|
||||
use super::relocation::apply_rela_dyn_relocations;
|
||||
use super::{
|
||||
paging::{Ia32eFlags, PageNumber, PageTableCreator},
|
||||
relocation::apply_rela_dyn_relocations,
|
||||
};
|
||||
|
||||
#[export_name = "efi_stub_entry"]
|
||||
extern "sysv64" fn efi_stub_entry(handle: Handle, mut system_table: SystemTable<Boot>) -> ! {
|
||||
|
@ -1,9 +1,9 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use linux_boot_params::BootParams;
|
||||
|
||||
use core::arch::{asm, global_asm};
|
||||
|
||||
use linux_boot_params::BootParams;
|
||||
|
||||
global_asm!(include_str!("header.S"));
|
||||
|
||||
global_asm!(include_str!("setup.S"));
|
||||
|
@ -1,9 +1,10 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
// Copyright(c) 2023-2024 Intel Corporation.
|
||||
|
||||
use crate::{tdcall::TdcallArgs, tdvmcall::TdVmcallArgs};
|
||||
use core::arch::global_asm;
|
||||
|
||||
use crate::{tdcall::TdcallArgs, tdvmcall::TdVmcallArgs};
|
||||
|
||||
global_asm!(include_str!("tdcall.asm"));
|
||||
global_asm!(include_str!("tdvmcall.asm"));
|
||||
|
||||
|
@ -11,12 +11,14 @@ mod asm;
|
||||
pub mod tdcall;
|
||||
pub mod tdvmcall;
|
||||
|
||||
pub use self::tdcall::{get_veinfo, TdxVirtualExceptionType};
|
||||
pub use self::tdvmcall::print;
|
||||
|
||||
use raw_cpuid::{native_cpuid::cpuid_count, CpuIdResult};
|
||||
use tdcall::{InitError, TdgVpInfo};
|
||||
|
||||
pub use self::{
|
||||
tdcall::{get_veinfo, TdxVirtualExceptionType},
|
||||
tdvmcall::print,
|
||||
};
|
||||
|
||||
pub fn init_tdx() -> Result<TdgVpInfo, InitError> {
|
||||
check_tdx_guest()?;
|
||||
Ok(tdcall::get_tdinfo()?)
|
||||
|
@ -5,10 +5,12 @@
|
||||
//! It is used to call guest-side Intel TDX functions. For more information about
|
||||
//! TDCALL, please refer to the [Intel® TDX Module v1.5 ABI Specification](https://cdrdv2.intel.com/v1/dl/getContent/733579)
|
||||
|
||||
use crate::asm::asm_td_call;
|
||||
use bitflags::bitflags;
|
||||
use core::fmt;
|
||||
|
||||
use bitflags::bitflags;
|
||||
|
||||
use crate::asm::asm_td_call;
|
||||
|
||||
/// TDCALL Instruction Leaf Numbers Definition.
|
||||
#[repr(u64)]
|
||||
pub enum TdcallNum {
|
||||
|
@ -8,15 +8,17 @@
|
||||
//! resumes the TD via a SEAMCALL [TDH.VP.ENTER] invocation.
|
||||
extern crate alloc;
|
||||
|
||||
use crate::asm::asm_td_vmcall;
|
||||
use alloc::fmt;
|
||||
use bitflags::bitflags;
|
||||
use core::fmt::Write;
|
||||
|
||||
use bitflags::bitflags;
|
||||
use x86_64::{
|
||||
registers::rflags::{self, RFlags},
|
||||
structures::port::PortRead,
|
||||
};
|
||||
|
||||
use crate::asm::asm_td_vmcall;
|
||||
|
||||
/// TDVMCALL Instruction Leaf Numbers Definition.
|
||||
#[repr(u64)]
|
||||
pub enum TdVmcallNum {
|
||||
|
@ -4,10 +4,14 @@ use std::path::PathBuf;
|
||||
|
||||
use clap::{crate_version, Args, Parser};
|
||||
|
||||
use crate::commands::{execute_check_command, execute_clippy_command, execute_new_command};
|
||||
use crate::config_manager::boot::{BootLoader, BootProtocol};
|
||||
use crate::config_manager::qemu::QemuMachine;
|
||||
use crate::config_manager::{BuildConfig, RunConfig, TestConfig};
|
||||
use crate::{
|
||||
commands::{execute_check_command, execute_clippy_command, execute_new_command},
|
||||
config_manager::{
|
||||
boot::{BootLoader, BootProtocol},
|
||||
qemu::QemuMachine,
|
||||
BuildConfig, RunConfig, TestConfig,
|
||||
},
|
||||
};
|
||||
|
||||
pub fn main() {
|
||||
let osdk_subcommand = match Cli::parse() {
|
||||
|
@ -2,12 +2,10 @@
|
||||
|
||||
use std::process;
|
||||
|
||||
use crate::commands::utils::create_target_json;
|
||||
use crate::error::Errno;
|
||||
use crate::error_msg;
|
||||
use crate::utils::get_cargo_metadata;
|
||||
|
||||
use super::utils::{cargo, COMMON_CARGO_ARGS};
|
||||
use crate::{
|
||||
commands::utils::create_target_json, error::Errno, error_msg, utils::get_cargo_metadata,
|
||||
};
|
||||
|
||||
pub fn execute_check_command() {
|
||||
let target_json_path = {
|
||||
|
@ -2,11 +2,10 @@
|
||||
|
||||
use std::process;
|
||||
|
||||
use crate::error_msg;
|
||||
use crate::utils::get_cargo_metadata;
|
||||
use crate::{commands::utils::create_target_json, error::Errno};
|
||||
|
||||
use super::utils::{cargo, COMMON_CARGO_ARGS};
|
||||
use crate::{
|
||||
commands::utils::create_target_json, error::Errno, error_msg, utils::get_cargo_metadata,
|
||||
};
|
||||
|
||||
pub fn execute_clippy_command() {
|
||||
let target_json_path = {
|
||||
|
@ -7,6 +7,6 @@ mod clippy;
|
||||
mod new;
|
||||
mod utils;
|
||||
|
||||
pub use self::check::execute_check_command;
|
||||
pub use self::clippy::execute_clippy_command;
|
||||
pub use self::new::execute_new_command;
|
||||
pub use self::{
|
||||
check::execute_check_command, clippy::execute_clippy_command, new::execute_new_command,
|
||||
};
|
||||
|
@ -1,13 +1,13 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::str::FromStr;
|
||||
use std::{fs, process};
|
||||
use std::{fs, path::PathBuf, process, str::FromStr};
|
||||
|
||||
use crate::cli::NewArgs;
|
||||
use crate::error::Errno;
|
||||
use crate::error_msg;
|
||||
use crate::utils::{cargo_new_lib, get_cargo_metadata, ASTER_FRAME_DEP};
|
||||
use crate::{
|
||||
cli::NewArgs,
|
||||
error::Errno,
|
||||
error_msg,
|
||||
utils::{cargo_new_lib, get_cargo_metadata, ASTER_FRAME_DEP},
|
||||
};
|
||||
|
||||
pub fn execute_new_command(args: &NewArgs) {
|
||||
cargo_new_lib(&args.crate_name);
|
||||
|
@ -1,8 +1,10 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
use std::{
|
||||
fs,
|
||||
path::{Path, PathBuf},
|
||||
process::Command,
|
||||
};
|
||||
|
||||
pub const COMMON_CARGO_ARGS: &[&str] = &[
|
||||
"-Zbuild-std=core,alloc,compiler_builtins",
|
||||
|
@ -1,10 +1,8 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::process;
|
||||
use std::{path::PathBuf, process};
|
||||
|
||||
use crate::error::Errno;
|
||||
use crate::error_msg;
|
||||
use crate::{error::Errno, error_msg};
|
||||
|
||||
/// Arguments for creating bootdev image and how to boot with vmm.
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
|
@ -1,16 +1,15 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::process;
|
||||
use std::{path::PathBuf, process};
|
||||
|
||||
use regex::Regex;
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::error::Errno;
|
||||
use crate::error_msg;
|
||||
|
||||
use super::boot::Boot;
|
||||
use super::qemu::{CfgQemu, Qemu};
|
||||
use super::{
|
||||
boot::Boot,
|
||||
qemu::{CfgQemu, Qemu},
|
||||
};
|
||||
use crate::{error::Errno, error_msg};
|
||||
|
||||
/// The osdk manifest from configuration file and command line arguments.
|
||||
#[derive(Debug)]
|
||||
|
@ -9,18 +9,22 @@ pub mod boot;
|
||||
pub mod manifest;
|
||||
pub mod qemu;
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::{fs, process};
|
||||
use std::{fs, path::PathBuf, process};
|
||||
|
||||
use indexmap::{IndexMap, IndexSet};
|
||||
use which::which;
|
||||
|
||||
use self::boot::BootLoader;
|
||||
use self::manifest::{OsdkManifest, TomlManifest};
|
||||
use crate::cli::{BuildArgs, CargoArgs, OsdkArgs, RunArgs, TestArgs};
|
||||
use crate::error::Errno;
|
||||
use crate::utils::get_cargo_metadata;
|
||||
use crate::{error_msg, warn_msg};
|
||||
use self::{
|
||||
boot::BootLoader,
|
||||
manifest::{OsdkManifest, TomlManifest},
|
||||
};
|
||||
use crate::{
|
||||
cli::{BuildArgs, CargoArgs, OsdkArgs, RunArgs, TestArgs},
|
||||
error::Errno,
|
||||
error_msg,
|
||||
utils::get_cargo_metadata,
|
||||
warn_msg,
|
||||
};
|
||||
|
||||
/// Configurations for build subcommand
|
||||
#[derive(Debug)]
|
||||
|
@ -1,16 +1,14 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::path::PathBuf;
|
||||
use std::{fmt, process};
|
||||
use std::{collections::BTreeMap, fmt, path::PathBuf, process};
|
||||
|
||||
use serde::de::{self, Visitor};
|
||||
use serde::{Deserialize, Deserializer};
|
||||
|
||||
use crate::error::Errno;
|
||||
use crate::error_msg;
|
||||
use serde::{
|
||||
de::{self, Visitor},
|
||||
Deserialize, Deserializer,
|
||||
};
|
||||
|
||||
use super::get_key;
|
||||
use crate::{error::Errno, error_msg};
|
||||
|
||||
/// Arguments for creating bootdev image and how to boot with vmm.
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
|
@ -1,13 +1,18 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::{
|
||||
fs,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use crate::config_manager::manifest::{OsdkManifest, TomlManifest, FEATURE_REGEX};
|
||||
|
||||
use crate::cli::CargoArgs;
|
||||
use crate::config_manager::get_feature_strings;
|
||||
use crate::test::utils::{assert_success, cargo_osdk, create_workspace};
|
||||
use crate::{
|
||||
cli::CargoArgs,
|
||||
config_manager::{
|
||||
get_feature_strings,
|
||||
manifest::{OsdkManifest, TomlManifest, FEATURE_REGEX},
|
||||
},
|
||||
test::utils::{assert_success, cargo_osdk, create_workspace},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn deserialize_osdk_manifest() {
|
||||
|
@ -2,11 +2,14 @@
|
||||
|
||||
//! The common utils for crate unit test
|
||||
|
||||
use std::{
|
||||
ffi::OsStr,
|
||||
fs::{self, create_dir_all},
|
||||
path::{Path, PathBuf},
|
||||
process::Output,
|
||||
};
|
||||
|
||||
use assert_cmd::Command;
|
||||
use std::ffi::OsStr;
|
||||
use std::fs::{self, create_dir_all};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Output;
|
||||
|
||||
pub fn cargo_osdk<T: AsRef<OsStr>, I: IntoIterator<Item = T>>(args: I) -> Command {
|
||||
let mut command = Command::cargo_bin("cargo-osdk").unwrap();
|
||||
|
@ -1,11 +1,8 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use std::ffi::OsStr;
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
use std::{ffi::OsStr, path::Path, process::Command};
|
||||
|
||||
use crate::error::Errno;
|
||||
use crate::error_msg;
|
||||
use crate::{error::Errno, error_msg};
|
||||
|
||||
// FIXME: Crates belonging to Asterinas require a different dependency format. The dependency
|
||||
// should be specified using a relative path instead of a URL.
|
||||
|
@ -2,9 +2,10 @@
|
||||
|
||||
//! Providing the utility to run the GDB scripts for the runner.
|
||||
|
||||
use crate::qemu_grub_efi;
|
||||
use std::{fs::OpenOptions, io::Write, path::PathBuf, process::Command};
|
||||
|
||||
use crate::qemu_grub_efi;
|
||||
|
||||
/// Run a GDB client.
|
||||
///
|
||||
/// If argument `gdb_grub` is set true, it will run GRUB's gdb script.
|
||||
|
@ -1,13 +1,13 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use linux_bzimage_builder::{make_bzimage, BzImageType};
|
||||
|
||||
use std::{
|
||||
fs,
|
||||
io::Read,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use linux_bzimage_builder::{make_bzimage, BzImageType};
|
||||
|
||||
use crate::BootProtocol;
|
||||
|
||||
macro_rules! ovmf_prefix {
|
||||
|
@ -9,16 +9,17 @@ pub mod tty;
|
||||
mod urandom;
|
||||
mod zero;
|
||||
|
||||
use crate::fs::device::{add_node, Device, DeviceId, DeviceType};
|
||||
use crate::prelude::*;
|
||||
pub use pty::new_pty_pair;
|
||||
pub use pty::{PtyMaster, PtySlave};
|
||||
pub use pty::{new_pty_pair, PtyMaster, PtySlave};
|
||||
pub use random::Random;
|
||||
#[cfg(feature = "intel_tdx")]
|
||||
pub use tdxguest::TdxGuest;
|
||||
pub use urandom::Urandom;
|
||||
|
||||
use self::tty::get_n_tty;
|
||||
use crate::{
|
||||
fs::device::{add_node, Device, DeviceId, DeviceType},
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
/// Init the device node in fs, must be called after mounting rootfs.
|
||||
pub fn init() -> Result<()> {
|
||||
|
@ -1,10 +1,7 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use super::*;
|
||||
use crate::events::IoEvents;
|
||||
use crate::fs::inode_handle::FileIo;
|
||||
use crate::prelude::*;
|
||||
use crate::process::signal::Poller;
|
||||
use crate::{events::IoEvents, fs::inode_handle::FileIo, prelude::*, process::signal::Poller};
|
||||
|
||||
pub struct Null;
|
||||
|
||||
|
@ -1,9 +1,13 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::fs::devpts::DevPts;
|
||||
use crate::fs::fs_resolver::{FsPath, FsResolver};
|
||||
use crate::fs::utils::{Dentry, Inode, InodeMode, InodeType};
|
||||
use crate::prelude::*;
|
||||
use crate::{
|
||||
fs::{
|
||||
devpts::DevPts,
|
||||
fs_resolver::{FsPath, FsResolver},
|
||||
utils::{Dentry, Inode, InodeMode, InodeType},
|
||||
},
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
#[allow(clippy::module_inception)]
|
||||
mod pty;
|
||||
|
@ -1,20 +1,26 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use alloc::format;
|
||||
|
||||
use ringbuf::{ring_buffer::RbBase, HeapRb, Rb};
|
||||
|
||||
use crate::device::tty::line_discipline::LineDiscipline;
|
||||
use crate::device::tty::new_job_control_and_ldisc;
|
||||
use crate::events::IoEvents;
|
||||
use crate::fs::device::{Device, DeviceId, DeviceType};
|
||||
use crate::fs::devpts::DevPts;
|
||||
use crate::fs::fs_resolver::FsPath;
|
||||
use crate::fs::inode_handle::FileIo;
|
||||
use crate::fs::utils::{AccessMode, Inode, InodeMode, IoctlCmd};
|
||||
use crate::prelude::*;
|
||||
use crate::process::signal::{Pollee, Poller};
|
||||
use crate::process::{JobControl, Terminal};
|
||||
use crate::util::{read_val_from_user, write_val_to_user};
|
||||
use crate::{
|
||||
device::tty::{line_discipline::LineDiscipline, new_job_control_and_ldisc},
|
||||
events::IoEvents,
|
||||
fs::{
|
||||
device::{Device, DeviceId, DeviceType},
|
||||
devpts::DevPts,
|
||||
fs_resolver::FsPath,
|
||||
inode_handle::FileIo,
|
||||
utils::{AccessMode, Inode, InodeMode, IoctlCmd},
|
||||
},
|
||||
prelude::*,
|
||||
process::{
|
||||
signal::{Pollee, Poller},
|
||||
JobControl, Terminal,
|
||||
},
|
||||
util::{read_val_from_user, write_val_to_user},
|
||||
};
|
||||
|
||||
const BUFFER_CAPACITY: usize = 4096;
|
||||
|
||||
|
@ -1,10 +1,14 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::events::IoEvents;
|
||||
use crate::fs::device::{Device, DeviceId, DeviceType};
|
||||
use crate::fs::inode_handle::FileIo;
|
||||
use crate::prelude::*;
|
||||
use crate::process::signal::Poller;
|
||||
use crate::{
|
||||
events::IoEvents,
|
||||
fs::{
|
||||
device::{Device, DeviceId, DeviceType},
|
||||
inode_handle::FileIo,
|
||||
},
|
||||
prelude::*,
|
||||
process::signal::Poller,
|
||||
};
|
||||
|
||||
pub struct Random;
|
||||
|
||||
|
@ -1,14 +1,16 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use super::*;
|
||||
use crate::error::Error;
|
||||
use crate::events::IoEvents;
|
||||
use crate::fs::inode_handle::FileIo;
|
||||
use crate::fs::utils::IoctlCmd;
|
||||
use crate::process::signal::Poller;
|
||||
use crate::util::{read_val_from_user, write_val_to_user};
|
||||
use tdx_guest::tdcall::{get_report, TdCallError};
|
||||
|
||||
use super::*;
|
||||
use crate::{
|
||||
error::Error,
|
||||
events::IoEvents,
|
||||
fs::{inode_handle::FileIo, utils::IoctlCmd},
|
||||
process::signal::Poller,
|
||||
util::{read_val_from_user, write_val_to_user},
|
||||
};
|
||||
|
||||
const TDX_REPORTDATA_LEN: usize = 64;
|
||||
const TDX_REPORT_LEN: usize = 1024;
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user