Make essential changes for publishing OSTD

This commit is contained in:
Jianfeng Jiang
2024-07-01 08:00:09 +00:00
committed by Tate, Hongliang Tian
parent 77b823edc0
commit f86583dbce
64 changed files with 341 additions and 218 deletions

View File

@ -16,7 +16,8 @@ use bitvec::{
use log::debug;
#[cfg(feature = "intel_tdx")]
use tdx_guest::tdcall;
use trapframe::{GeneralRegs, UserContext as RawUserContext};
pub use trapframe::GeneralRegs as RawGeneralRegs;
use trapframe::UserContext as RawUserContext;
use x86_64::registers::{
rflags::RFlags,
segmentation::{Segment64, FS},
@ -131,7 +132,7 @@ pub struct CpuExceptionInfo {
}
#[cfg(feature = "intel_tdx")]
impl TdxTrapFrame for GeneralRegs {
impl TdxTrapFrame for RawGeneralRegs {
fn rax(&self) -> usize {
self.rax
}
@ -258,12 +259,12 @@ impl UserPreemption {
impl UserContext {
/// Returns a reference to the general registers.
pub fn general_regs(&self) -> &GeneralRegs {
pub fn general_regs(&self) -> &RawGeneralRegs {
&self.user_context.general
}
/// Returns a mutable reference to the general registers
pub fn general_regs_mut(&mut self) -> &mut GeneralRegs {
pub fn general_regs_mut(&mut self) -> &mut RawGeneralRegs {
&mut self.user_context.general
}

View File

@ -6,7 +6,6 @@ use alloc::collections::BTreeMap;
use core::mem::size_of;
use log::warn;
use pod::Pod;
use super::second_stage::{DeviceMode, PageTableEntry, PagingConsts};
use crate::{
@ -17,6 +16,7 @@ use crate::{
page_table::PageTableError,
Frame, FrameAllocOptions, Paddr, PageFlags, PageTable, VmIo, PAGE_SIZE,
},
Pod,
};
/// Bit 0 is `Present` bit, indicating whether this entry is present.

View File

@ -4,12 +4,13 @@
use core::ops::Range;
use pod::Pod;
use crate::mm::{
page_prop::{CachePolicy, PageFlags, PrivilegedPageFlags as PrivFlags},
page_table::{PageTableEntryTrait, PageTableMode},
Paddr, PageProperty, PagingConstsTrait, PagingLevel, Vaddr,
use crate::{
mm::{
page_prop::{CachePolicy, PageFlags, PrivilegedPageFlags as PrivFlags},
page_table::{PageTableEntryTrait, PageTableMode},
Paddr, PageProperty, PagingConstsTrait, PagingLevel, Vaddr,
},
Pod,
};
/// The page table used by iommu maps the device address

View File

@ -5,14 +5,16 @@
use alloc::fmt;
use core::ops::Range;
use pod::Pod;
pub(crate) use util::__memcpy_fallible;
use x86_64::{instructions::tlb, structures::paging::PhysFrame, VirtAddr};
use crate::mm::{
page_prop::{CachePolicy, PageFlags, PageProperty, PrivilegedPageFlags as PrivFlags},
page_table::PageTableEntryTrait,
Paddr, PagingConstsTrait, PagingLevel, Vaddr, PAGE_SIZE,
use crate::{
mm::{
page_prop::{CachePolicy, PageFlags, PageProperty, PrivilegedPageFlags as PrivFlags},
page_table::PageTableEntryTrait,
Paddr, PagingConstsTrait, PagingLevel, Vaddr, PAGE_SIZE,
},
Pod,
};
mod util;

View File

@ -156,7 +156,7 @@ fn run_ktests(test_whitelist: Option<&[&str]>, crate_whitelist: Option<&[&str]>)
let fn_catch_unwind = &(unwinding::panic::catch_unwind::<(), fn()>
as fn(fn()) -> Result<(), Box<(dyn Any + Send + 'static)>>);
use ktest::runner::{run_ktests, KtestResult};
use ostd_test::runner::{run_ktests, KtestResult};
match run_ktests(
&crate::console::early_print,
fn_catch_unwind,

View File

@ -6,7 +6,6 @@ pub mod cpu_local;
cfg_if::cfg_if! {
if #[cfg(target_arch = "x86_64")]{
pub use trapframe::GeneralRegs;
pub use crate::arch::x86::cpu::*;
}
}

View File

@ -4,11 +4,9 @@
use core::{mem::size_of, ops::Range};
use pod::Pod;
use crate::{
mm::{kspace::LINEAR_MAPPING_BASE_VADDR, paddr_to_vaddr, HasPaddr, Paddr, Vaddr, VmIo},
Error, Result,
Error, Pod, Result,
};
/// I/O memory.

View File

@ -44,6 +44,7 @@ pub mod trap;
pub mod user;
pub use ostd_macros::main;
pub use ostd_pod::Pod;
pub use self::{cpu::cpu_local::CpuLocal, error::Error, prelude::Result};
@ -123,5 +124,5 @@ mod test {
/// The module re-exports everything from the ktest crate
#[cfg(ktest)]
pub mod ktest {
pub use ktest::*;
pub use ostd_test::*;
}

View File

@ -6,7 +6,6 @@ use core::marker::PhantomData;
use align_ext::AlignExt;
use inherit_methods_macro::inherit_methods;
use pod::Pod;
use crate::{
arch::mm::__memcpy_fallible,
@ -15,7 +14,7 @@ use crate::{
MAX_USERSPACE_VADDR,
},
prelude::*,
Error,
Error, Pod,
};
/// A trait that enables reading/writing data from/to a VM object,

View File

@ -2,14 +2,15 @@
use core::{fmt::Debug, marker::PhantomData, ops::Range};
use pod::Pod;
use super::{
nr_subpage_per_huge, paddr_to_vaddr,
page_prop::{PageFlags, PageProperty},
page_size, Paddr, PagingConstsTrait, PagingLevel, Vaddr,
};
use crate::arch::mm::{PageTableEntry, PagingConsts};
use crate::{
arch::mm::{PageTableEntry, PagingConsts},
Pod,
};
mod node;
use node::*;

View File

@ -29,7 +29,7 @@ use unwinding::{
/// panic handler in the binary crate.
#[export_name = "__aster_panic_handler"]
pub fn panic_handler(info: &core::panic::PanicInfo) -> ! {
let throw_info = ktest::PanicInfo {
let throw_info = ostd_test::PanicInfo {
message: info.message().to_string(),
file: info.location().unwrap().file().to_string(),
line: info.location().unwrap().line() as usize,

View File

@ -293,7 +293,6 @@ impl fmt::Debug for AtomicBits {
#[cfg(ktest)]
mod test {
use super::*;
use crate::prelude::*;
#[ktest]
fn new() {