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

@ -1,36 +0,0 @@
name: Publish OSDK
on:
pull_request:
paths:
- VERSION
- osdk/Cargo.toml
push:
branches:
- main
paths:
- VERSION
jobs:
osdk-publish:
runs-on: ubuntu-latest
timeout-minutes: 10
container: asterinas/asterinas:0.6.2
steps:
- uses: actions/checkout@v4
- name: Check Publish
# On pull request, set `--dry-run` to check whether OSDK can publish
if: github.event_name == 'pull_request'
run: |
cd osdk
cargo publish --dry-run
- name: Publish
# On push, OSDK will be published
if: github.event_name == 'push'
env:
REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
cd osdk
cargo publish --token ${REGISTRY_TOKEN}

View File

@ -0,0 +1,69 @@
name: Publish OSDK and OSTD
on:
pull_request:
paths:
- VERSION
- ostd/**
- osdk/**
push:
branches:
- main
paths:
- VERSION
jobs:
osdk-publish:
runs-on: ubuntu-latest
timeout-minutes: 10
container: asterinas/asterinas:0.6.2
steps:
- uses: actions/checkout@v4
- name: Check Publish OSDK
# On pull request, set `--dry-run` to check whether OSDK can publish
if: github.event_name == 'pull_request'
run: |
cd osdk
cargo publish --dry-run
- name: Publish OSDK
# On push, OSDK will be published
if: github.event_name == 'push'
env:
REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
cd osdk
cargo publish --token ${REGISTRY_TOKEN}
ostd-publish:
runs-on: ubuntu-latest
timeout-minutes: 10
container: asterinas/asterinas:0.6.2
strategy:
matrix:
# All supported targets, this array should keep consistent with
# `package.metadata.docs.rs.targets` in `ostd/Cargo.toml`
target: ['x86_64-unknown-none']
steps:
- uses: actions/checkout@v4
- name: Check Publish OSTD
# On pull request, set `--dry-run` to check whether OSDK can publish
if: github.event_name == 'pull_request'
run: |
cd ostd
cargo publish --target ${{ matrix.target }} --dry-run
cargo doc --target ${{ matrix.target }}
- name: Publish OSTD
if: github.event_name == 'push'
env:
REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
# Using any target that OSTD supports for publishing is ok.
# Here we use the same target as
# `package.metadata.docs.rs.default-target` in `ostd/Cargo.toml`.
run: |
cd ostd
cargo publish --target x86_64-unknown-none --token ${REGISTRY_TOKEN}

117
Cargo.lock generated
View File

@ -84,7 +84,6 @@ dependencies = [
"lazy_static",
"log",
"ostd",
"pod",
"spin 0.9.8",
"static_assertions",
]
@ -141,7 +140,6 @@ dependencies = [
"int-to-c-enum",
"log",
"ostd",
"pod",
"ringbuf",
"smoltcp",
"spin 0.9.8",
@ -185,7 +183,6 @@ dependencies = [
"lru",
"ostd",
"paste",
"pod",
"rand",
"ringbuf",
"smoltcp",
@ -238,7 +235,6 @@ dependencies = [
"aster-rights-proc",
"inherit-methods-macro",
"ostd",
"pod",
"typeflags-util",
]
@ -261,7 +257,6 @@ dependencies = [
"int-to-c-enum",
"log",
"ostd",
"pod",
"smoltcp",
"spin 0.9.8",
"typeflags-util",
@ -277,7 +272,7 @@ dependencies = [
"component",
"id-alloc",
"ostd",
"x86_64",
"x86_64 0.14.11",
]
[[package]]
@ -760,9 +755,9 @@ dependencies = [
[[package]]
name = "intrusive-collections"
version = "0.9.5"
version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f4f90afb01281fdeffb0f8e082d230cbe4f888f837cc90759696b858db1a700"
checksum = "b694dc9f70c3bda874626d2aed13b780f137aab435f4e9814121955cf706122e"
dependencies = [
"memoffset",
]
@ -795,13 +790,6 @@ checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd"
name = "keyable-arc"
version = "0.1.0"
[[package]]
name = "ktest"
version = "0.1.0"
dependencies = [
"owo-colors",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
@ -891,7 +879,7 @@ dependencies = [
"uart_16550",
"uefi",
"uefi-services",
"x86_64",
"x86_64 0.14.11",
"xmas-elf 0.8.0",
]
@ -950,9 +938,9 @@ checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
[[package]]
name = "memoffset"
version = "0.8.0"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1"
checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
dependencies = [
"autocfg",
]
@ -1094,7 +1082,6 @@ dependencies = [
"inherit-methods-macro",
"int-to-c-enum",
"intrusive-collections",
"ktest",
"lazy_static",
"linux-boot-params",
"log",
@ -1103,8 +1090,9 @@ dependencies = [
"num-derive",
"num-traits",
"ostd-macros",
"ostd-pod",
"ostd-test",
"owo-colors",
"pod",
"rsdp",
"spin 0.9.8",
"static_assertions",
@ -1113,13 +1101,13 @@ dependencies = [
"unwinding",
"volatile",
"x86",
"x86_64",
"x86_64 0.14.11",
"xarray",
]
[[package]]
name = "ostd-macros"
version = "0.1.0"
version = "0.1.4"
dependencies = [
"proc-macro2",
"quote",
@ -1127,6 +1115,31 @@ dependencies = [
"syn 2.0.49",
]
[[package]]
name = "ostd-pod"
version = "0.1.1"
source = "git+https://github.com/asterinas/ostd-pod?rev=c4644be#c4644be401cae1e046a810574078b64e35924f5f"
dependencies = [
"ostd-pod-derive",
]
[[package]]
name = "ostd-pod-derive"
version = "0.1.1"
source = "git+https://github.com/asterinas/ostd-pod?rev=c4644be#c4644be401cae1e046a810574078b64e35924f5f"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "ostd-test"
version = "0.1.0"
dependencies = [
"owo-colors",
]
[[package]]
name = "owo-colors"
version = "3.5.0"
@ -1139,24 +1152,6 @@ version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c"
[[package]]
name = "pod"
version = "0.1.0"
source = "git+https://github.com/asterinas/pod?rev=d7dba56#d7dba56cc202a10d483b60aba4f734b1f49cb37b"
dependencies = [
"pod-derive",
]
[[package]]
name = "pod-derive"
version = "0.1.0"
source = "git+https://github.com/asterinas/pod?rev=d7dba56#d7dba56cc202a10d483b60aba4f734b1f49cb37b"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "polonius-the-crab"
version = "0.2.1"
@ -1276,6 +1271,15 @@ dependencies = [
"bitflags 1.3.2",
]
[[package]]
name = "raw-cpuid"
version = "11.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e29830cbb1290e404f24c73af91c5d8d631ce7e128691e9477556b540cd01ecd"
dependencies = [
"bitflags 2.4.1",
]
[[package]]
name = "ringbuf"
version = "0.3.3"
@ -1358,9 +1362,9 @@ dependencies = [
[[package]]
name = "smallvec"
version = "1.13.1"
version = "1.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7"
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
[[package]]
name = "smoltcp"
@ -1462,8 +1466,8 @@ dependencies = [
"bitflags 1.3.2",
"iced-x86",
"lazy_static",
"raw-cpuid",
"x86_64",
"raw-cpuid 10.7.0",
"x86_64 0.14.11",
]
[[package]]
@ -1539,13 +1543,12 @@ dependencies = [
[[package]]
name = "trapframe"
version = "0.9.0"
source = "git+https://github.com/asterinas/trapframe-rs?rev=4739428#4739428fd51685c74e6e88e73e5f04cb89f465ee"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "105000258ba41c463b63403c9341c55a298f35f6137b1cca08c10f0409ef8d3a"
dependencies = [
"log",
"pod",
"raw-cpuid",
"x86_64",
"raw-cpuid 11.0.2",
"x86_64 0.15.1",
]
[[package]]
@ -1723,7 +1726,7 @@ checksum = "2781db97787217ad2a2845c396a5efe286f87467a5810836db6d74926e94a385"
dependencies = [
"bit_field",
"bitflags 1.3.2",
"raw-cpuid",
"raw-cpuid 10.7.0",
]
[[package]]
@ -1738,6 +1741,18 @@ dependencies = [
"volatile",
]
[[package]]
name = "x86_64"
version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bc79523af8abf92fb1a970c3e086c5a343f6bcc1a0eb890f575cbb3b45743df"
dependencies = [
"bit_field",
"bitflags 2.4.1",
"rustversion",
"volatile",
]
[[package]]
name = "xarray"
version = "0.1.0"

View File

@ -8,7 +8,7 @@ members = [
"ostd/libs/linux-bzimage/builder",
"ostd/libs/linux-bzimage/boot-params",
"ostd/libs/linux-bzimage/setup",
"ostd/libs/ktest",
"ostd/libs/ostd-test",
"kernel",
"kernel/aster-nix",
"kernel/comps/block",

View File

@ -91,8 +91,8 @@ NON_OSDK_CRATES := \
ostd/libs/id-alloc \
ostd/libs/linux-bzimage/builder \
ostd/libs/linux-bzimage/boot-params \
ostd/libs/ktest \
ostd/libs/ostd-macros \
ostd/libs/ostd-test \
kernel/libs/cpio-decoder \
kernel/libs/int-to-c-enum \
kernel/libs/int-to-c-enum/derive \

View File

@ -6,9 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
ostd = { path = "../../ostd" }
align_ext = { path = "../../ostd/libs/align_ext" }
pod = { git = "https://github.com/asterinas/pod", rev = "d7dba56" }
aster-input = { path = "../comps/input" }
aster-block = { path = "../comps/block" }
aster-network = { path = "../comps/network" }
@ -17,6 +15,7 @@ aster-time = { path = "../comps/time" }
aster-virtio = { path = "../comps/virtio" }
aster-rights = { path = "../libs/aster-rights" }
controlled = { path = "../libs/comp-sys/controlled" }
ostd = { path = "../../ostd" }
typeflags = { path = "../libs/typeflags" }
typeflags-util = { path = "../libs/typeflags-util" }
aster-rights-proc = { path = "../libs/aster-rights-proc" }

View File

@ -1,6 +1,9 @@
// SPDX-License-Identifier: MPL-2.0
use ostd::cpu::UserContext;
use ostd::{
cpu::{RawGeneralRegs, UserContext},
Pod,
};
use crate::cpu::LinuxAbi;
@ -36,3 +39,64 @@ impl LinuxAbi for UserContext {
self.fsbase()
}
}
/// General-purpose registers.
#[derive(Debug, Clone, Copy, Pod, Default)]
#[repr(C)]
pub struct GpRegs {
pub rax: usize,
pub rbx: usize,
pub rcx: usize,
pub rdx: usize,
pub rsi: usize,
pub rdi: usize,
pub rbp: usize,
pub rsp: usize,
pub r8: usize,
pub r9: usize,
pub r10: usize,
pub r11: usize,
pub r12: usize,
pub r13: usize,
pub r14: usize,
pub r15: usize,
pub rip: usize,
pub rflags: usize,
pub fsbase: usize,
pub gsbase: usize,
}
macro_rules! copy_gp_regs {
($src: ident, $dst: ident) => {
$dst.rax = $src.rax;
$dst.rbx = $src.rax;
$dst.rcx = $src.rcx;
$dst.rdx = $src.rdx;
$dst.rsi = $src.rsi;
$dst.rdi = $src.rdi;
$dst.rbp = $src.rbp;
$dst.rsp = $src.rsp;
$dst.r8 = $src.r8;
$dst.r9 = $src.r9;
$dst.r10 = $src.r10;
$dst.r11 = $src.r11;
$dst.r12 = $src.r12;
$dst.r13 = $src.r13;
$dst.r14 = $src.r14;
$dst.r15 = $src.r15;
$dst.rip = $src.rip;
$dst.rflags = $src.rflags;
$dst.fsbase = $src.fsbase;
$dst.gsbase = $src.gsbase;
};
}
impl GpRegs {
pub fn copy_to_raw(&self, dst: &mut RawGeneralRegs) {
copy_gp_regs!(self, dst);
}
pub fn copy_from_raw(&mut self, src: &RawGeneralRegs) {
copy_gp_regs!(src, self);
}
}

View File

@ -1,6 +1,6 @@
// SPDX-License-Identifier: MPL-2.0
use pod::Pod;
use ostd::Pod;
use super::constants::{EXFAT_FIRST_CLUSTER, EXFAT_RESERVED_CLUSTERS, MEDIA_FAILURE, VOLUME_DIRTY};
use crate::prelude::*;

View File

@ -19,8 +19,8 @@ pub(crate) use log::{debug, error, info, log_enabled, trace, warn};
pub(crate) use ostd::{
mm::{Vaddr, VmReader, VmWriter, PAGE_SIZE},
sync::{Mutex, MutexGuard, RwLock, RwMutex, SpinLock, SpinLockGuard},
Pod,
};
pub(crate) use pod::Pod;
/// return current process
#[macro_export]

View File

@ -6,10 +6,10 @@
use core::mem::{self, size_of};
use aster_util::{read_union_fields, union_read_ptr::UnionReadPtr};
use ostd::cpu::GeneralRegs;
use super::sig_num::SigNum;
use crate::{
arch::cpu::GpRegs,
prelude::*,
process::{Pid, Uid},
};
@ -206,7 +206,7 @@ pub struct mcontext_t {
#[derive(Debug, Clone, Copy, Pod, Default)]
#[repr(C)]
pub struct SignalCpuContext {
pub gp_regs: GeneralRegs,
pub gp_regs: GpRegs,
pub fpregs_on_heap: u64,
pub fpregs: Vaddr, // *mut FpRegs,
}

View File

@ -166,7 +166,11 @@ pub fn handle_user_signal(
uc_sigmask: mask.as_u64(),
..Default::default()
};
ucontext.uc_mcontext.inner.gp_regs = *context.general_regs();
ucontext
.uc_mcontext
.inner
.gp_regs
.copy_from_raw(context.general_regs());
let mut sig_context = posix_thread.sig_context().lock();
if let Some(sig_context_addr) = *sig_context {
ucontext.uc_link = sig_context_addr;

View File

@ -38,7 +38,11 @@ pub fn sys_rt_sigreturn(context: &mut UserContext) -> Result<SyscallReturn> {
} else {
*sig_context = Some(ucontext.uc_link);
};
*context.general_regs_mut() = ucontext.uc_mcontext.inner.gp_regs;
ucontext
.uc_mcontext
.inner
.gp_regs
.copy_to_raw(context.general_regs_mut());
// unblock sig mask
let sig_mask = ucontext.uc_sigmask;
posix_thread.sig_mask().lock().unblock(sig_mask);

View File

@ -23,8 +23,8 @@ use aster_util::coeff::Coeff;
use ostd::{
mm::{Frame, VmIo, PAGE_SIZE},
sync::SpinLock,
Pod,
};
use pod::Pod;
use spin::Once;
use crate::{

View File

@ -8,7 +8,6 @@ edition = "2021"
[dependencies]
bitflags = "1.3"
spin = "0.9.4"
pod = { git = "https://github.com/asterinas/pod", rev = "d7dba56" }
ostd = { path = "../../../ostd" }
align_ext = { path = "../../../ostd/libs/align_ext" }
aster-util = { path = "../../libs/aster-util" }

View File

@ -5,7 +5,7 @@ use core::{
ops::{Add, Sub},
};
use pod::Pod;
use ostd::Pod;
use static_assertions::const_assert;
/// The block index used in the filesystem.

View File

@ -15,7 +15,6 @@ component = { path = "../../libs/comp-sys/component" }
int-to-c-enum = { path = "../../libs/int-to-c-enum" }
log = "0.4"
ostd = { path = "../../../ostd" }
pod = { git = "https://github.com/asterinas/pod", rev = "d7dba56" }
ringbuf = { version = "0.3.2", default-features = false, features = ["alloc"] }
smoltcp = { version = "0.9.1", default-features = false, features = ["alloc", "log", "medium-ethernet", "medium-ip", "proto-dhcpv4", "proto-ipv4", "proto-igmp", "socket-icmp", "socket-udp", "socket-tcp", "socket-raw", "socket-dhcpv4"] }
spin = "0.9.4"

View File

@ -8,8 +8,8 @@ use ostd::{
Daddr, DmaDirection, DmaStream, FrameAllocOptions, HasDaddr, VmReader, VmWriter, PAGE_SIZE,
},
sync::SpinLock,
Pod,
};
use pod::Pod;
use spin::Once;
use crate::dma_pool::{DmaPool, DmaSegment};

View File

@ -15,11 +15,10 @@ extern crate alloc;
use alloc::{collections::BTreeMap, string::String, sync::Arc, vec::Vec};
use core::{any::Any, fmt::Debug};
use aster_util::safe_ptr::Pod;
pub use buffer::{RxBuffer, TxBuffer, RX_BUFFER_POOL, TX_BUFFER_POOL};
use component::{init_component, ComponentInitError};
pub use dma_pool::DmaSegment;
use ostd::sync::SpinLock;
use ostd::{sync::SpinLock, Pod};
use smoltcp::phy;
use spin::Once;

View File

@ -19,7 +19,6 @@ aster-rights = { path = "../../libs/aster-rights" }
id-alloc = { path = "../../../ostd/libs/id-alloc" }
typeflags-util = { path = "../../libs/typeflags-util" }
ostd = { path = "../../../ostd" }
pod = { git = "https://github.com/asterinas/pod", rev = "d7dba56" }
component = { path = "../../libs/comp-sys/component" }
log = "0.4"
bit_field = "0.10.1"

View File

@ -15,8 +15,8 @@ use ostd::{
mm::{DmaDirection, DmaStream, DmaStreamSlice, FrameAllocOptions, VmIo},
sync::SpinLock,
trap::TrapFrame,
Pod,
};
use pod::Pod;
use super::{BlockFeatures, VirtioBlockConfig};
use crate::{

View File

@ -5,8 +5,7 @@ pub mod device;
use aster_util::safe_ptr::SafePtr;
use bitflags::bitflags;
use int_to_c_enum::TryFromInt;
use ostd::io_mem::IoMem;
use pod::Pod;
use ostd::{io_mem::IoMem, Pod};
use crate::transport::VirtioTransport;

View File

@ -1,8 +1,7 @@
// SPDX-License-Identifier: MPL-2.0
use aster_util::safe_ptr::SafePtr;
use ostd::io_mem::IoMem;
use pod::Pod;
use ostd::{io_mem::IoMem, Pod};
use crate::transport::VirtioTransport;

View File

@ -28,8 +28,7 @@
pub mod device;
use aster_util::safe_ptr::SafePtr;
use ostd::io_mem::IoMem;
use pod::Pod;
use ostd::{io_mem::IoMem, Pod};
use crate::transport::VirtioTransport;

View File

@ -3,8 +3,7 @@
use aster_network::EthernetAddr;
use aster_util::safe_ptr::SafePtr;
use bitflags::bitflags;
use ostd::io_mem::IoMem;
use pod::Pod;
use ostd::{io_mem::IoMem, Pod};
use crate::transport::VirtioTransport;

View File

@ -2,7 +2,7 @@
use bitflags::bitflags;
use int_to_c_enum::TryFromInt;
use pod::Pod;
use ostd::Pod;
pub const VIRTIO_NET_HDR_LEN: usize = core::mem::size_of::<VirtioNetHdr>();

View File

@ -2,8 +2,7 @@
use aster_util::safe_ptr::SafePtr;
use bitflags::bitflags;
use ostd::io_mem::IoMem;
use pod::Pod;
use ostd::{io_mem::IoMem, Pod};
use crate::transport::VirtioTransport;

View File

@ -6,8 +6,7 @@ use core::{fmt::Debug, hint::spin_loop, mem::size_of};
use aster_network::{RxBuffer, TxBuffer};
use aster_util::{field_ptr, slot_vec::SlotVec};
use log::debug;
use ostd::{mm::VmWriter, offset_of, sync::SpinLock, trap::TrapFrame};
use pod::Pod;
use ostd::{mm::VmWriter, offset_of, sync::SpinLock, trap::TrapFrame, Pod};
use super::{
config::{VirtioVsockConfig, VsockFeatures},

View File

@ -27,7 +27,7 @@
//
use bitflags::bitflags;
use int_to_c_enum::TryFromInt;
use pod::Pod;
use ostd::Pod;
use super::error::{self, SocketError};

View File

@ -15,9 +15,8 @@ use log::debug;
use ostd::{
io_mem::IoMem,
mm::{DmaCoherent, FrameAllocOptions},
offset_of,
offset_of, Pod,
};
use pod::Pod;
use crate::{dma_buf::DmaBuf, transport::VirtioTransport};

View File

@ -2,7 +2,7 @@
use core::fmt::Debug;
use pod::Pod;
use ostd::Pod;
#[derive(Clone, Copy, Pod)]
#[repr(C)]

View File

@ -1,8 +1,7 @@
// SPDX-License-Identifier: MPL-2.0
use aster_util::safe_ptr::SafePtr;
use ostd::io_mem::IoMem;
use pod::Pod;
use ostd::{io_mem::IoMem, Pod};
use super::capability::VirtioPciCapabilityData;
use crate::transport::pci::capability::VirtioPciCpabilityType;

View File

@ -7,7 +7,6 @@ edition = "2021"
[dependencies]
ostd = { path = "../../../ostd" }
pod = { git = "https://github.com/asterinas/pod", rev = "d7dba56" }
typeflags-util = { path = "../typeflags-util" }
aster-rights-proc = { path = "../aster-rights-proc" }
aster-rights = { path = "../aster-rights" }

View File

@ -5,11 +5,11 @@ use core::{fmt::Debug, marker::PhantomData};
use aster_rights::{Dup, Exec, Full, Read, Signal, TRightSet, TRights, Write};
use aster_rights_proc::require;
use inherit_methods_macro::inherit_methods;
pub use ostd::Pod;
use ostd::{
mm::{Daddr, DmaStream, HasDaddr, HasPaddr, Paddr, VmIo},
Result,
};
pub use pod::Pod;
pub use typeflags_util::SetContain;
/// Safe pointers.

View File

@ -2,7 +2,7 @@
use core::marker::PhantomData;
use pod::Pod;
use ostd::Pod;
/// This ptr is designed to read union field safely.
/// Write to union field is safe operation. While reading union field is UB.

View File

@ -2,11 +2,15 @@
name = "int-to-c-enum"
version = "0.1.0"
edition = "2021"
license = "MPL-2.0"
readme = "README.md"
description = "TryFromInt - A convenient derive macro for converting an integer to an enum"
repository = "https://github.com/asterinas/asterinas"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
int-to-c-enum-derive = { path = "derive", optional = true }
int-to-c-enum-derive = { path = "derive", optional = true, version = "0.1.0"}
[features]
default = ["derive"]

View File

@ -2,6 +2,9 @@
name = "int-to-c-enum-derive"
version = "0.1.0"
edition = "2021"
license = "MPL-2.0"
description = "int-to-c-enum's proc macros"
repository = "https://github.com/asterinas/asterinas"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -157,10 +157,9 @@ fn install_setup_with_arch(
cmd.arg("install").arg("linux-bzimage-setup");
cmd.arg("--force");
cmd.arg("--root").arg(install_dir.as_ref());
cmd.arg("--git").arg(crate::util::ASTER_GIT_LINK);
// FIXME: Uses a fixed tag instaed of relies on remote branch
cmd.arg("--tag").arg("v0.5.1");
// cmd.arg("--tag").arg(crate::util::ASTER_GIT_TAG);
// Remember to upgrade this version if new version of linux-bzimage-setup is released.
const LINUX_BZIMAGE_SETUP_VERSION: &str = "0.1.0";
cmd.arg("--version").arg(LINUX_BZIMAGE_SETUP_VERSION);
cmd.arg("--target").arg(match arch {
SetupInstallArch::X86_64 => "x86_64-unknown-none",
SetupInstallArch::Other(path) => path.to_str().unwrap(),

View File

@ -7,7 +7,7 @@ use crate::{
config::manifest::ProjectType,
error::Errno,
error_msg,
util::{aster_crate_dep, cargo_new_lib, get_cargo_metadata},
util::{cargo_new_lib, get_cargo_metadata, ostd_dep},
};
pub fn execute_new_command(args: &NewArgs) {
@ -40,7 +40,7 @@ fn add_manifest_dependencies(cargo_metadata: &serde_json::Value, crate_name: &st
let dependencies = manifest.get_mut("dependencies").unwrap();
let ostd_dep = toml::Table::from_str(&aster_crate_dep("ostd")).unwrap();
let ostd_dep = toml::Table::from_str(&ostd_dep()).unwrap();
dependencies.as_table_mut().unwrap().extend(ostd_dep);
let content = toml::to_string(&manifest).unwrap();

View File

@ -12,18 +12,12 @@ use crate::{error::Errno, error_msg};
use quote::ToTokens;
/// FIXME: We should publish the asterinas crates to a public registry
/// and use the published version in the generated Cargo.toml.
pub const ASTER_GIT_LINK: &str = "https://github.com/asterinas/asterinas";
/// Make sure it syncs with the builder dependency in Cargo.toml.
/// We cannot use `include_str!("../../VERSION")` here
/// because `cargo publish` does not allow using files outside of the crate directory.
pub const ASTER_GIT_TAG: &str = concat!("v", env!("CARGO_PKG_VERSION"));
pub fn aster_crate_dep(crate_name: &str) -> String {
format!(
"{} = {{ git = \"{}\", tag = \"{}\" }}",
crate_name, ASTER_GIT_LINK, ASTER_GIT_TAG
)
/// The version of OSTD on crates.io.
///
/// OSTD shares the same version with OSDK, so just use the version of OSDK here.
pub const OSTD_VERSION: &str = env!("CARGO_PKG_VERSION");
pub fn ostd_dep() -> String {
format!("ostd = {{ version = \"{}\" }}", OSTD_VERSION)
}
fn cargo() -> Command {

View File

@ -88,7 +88,7 @@ pub fn add_member_to_workspace(workspace: impl AsRef<Path>, new_member: &str) {
}
/// Makes crates created by `cargo ostd new` depends on ostd locally,
/// instead of ostd from local branch.
/// instead of ostd from remote source(git repo/crates.io).
///
/// Each crate created by `cargo ostd new` should add this patch.
pub fn depends_on_local_ostd(manifest_path: impl AsRef<Path>) {

View File

@ -2,41 +2,48 @@
name = "ostd"
version = "0.6.2"
edition = "2021"
description = "Rust OS framework that facilitates the development of and innovation in OS kernels"
license = "MPL-2.0"
readme = "README.md"
repository = "https://github.com/asterinas/asterinas"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
# Settings for publishing docs in docs.rs
[package.metadata.docs.rs]
default-target = "x86_64-unknown-none"
targets = ["x86_64-unknown-none"]
[dependencies]
align_ext = { path = "libs/align_ext" }
ostd-macros = { path = "libs/ostd-macros" }
align_ext = { path = "libs/align_ext", version = "0.1.0" }
array-init = "2.0"
bit_field = "0.10.1"
buddy_system_allocator = "0.9.0"
bitflags = "1.3"
bitvec = { version = "1.0", default-features = false, features = ["alloc"] }
linux-boot-params = { path = "libs/linux-bzimage/boot-params" }
buddy_system_allocator = "0.9.0"
cfg-if = "1.0"
gimli = { version = "0.28", default-features = false, features = ["read-core"] }
inherit-methods-macro = { git = "https://github.com/asterinas/inherit-methods-macro", rev = "98f7e3e" }
xarray = { git = "https://github.com/asterinas/xarray", rev = "72a4067" }
int-to-c-enum = { path = "../kernel/libs/int-to-c-enum" }
# instrusive-collections of version 0.9.6 fails to compile with current rust toolchain,
# So we set a fixed version 0.9.5 for this crate
intrusive-collections = { version = "=0.9.5", features = ["nightly"] }
array-init = "2.0"
ktest = { path = "libs/ktest" }
id-alloc = { path = "libs/id-alloc" }
id-alloc = { path = "libs/id-alloc", version = "0.1.0" }
inherit-methods-macro = { git = "https://github.com/asterinas/inherit-methods-macro", rev = "98f7e3e", version = "0.1.0" }
int-to-c-enum = { path = "../kernel/libs/int-to-c-enum", version = "0.1.0" }
intrusive-collections = { version = "0.9.6", features = ["nightly"] }
lazy_static = { version = "1.0", features = ["spin_no_std"] }
linux-boot-params = { path = "libs/linux-bzimage/boot-params", version = "0.1.0" }
log = "0.4"
num = { version = "0.4", default-features = false }
num-derive = { version = "0.4", default-features = false }
num-traits = { version = "0.2", default-features = false }
pod = { git = "https://github.com/asterinas/pod", rev = "d7dba56" }
ostd-macros = { path = "libs/ostd-macros", version = "0.1.4" }
ostd-test = { path = "libs/ostd-test", version = "0.1.0" }
owo-colors = { version = "3", optional = true }
ostd-pod = { git = "https://github.com/asterinas/ostd-pod", rev = "c4644be", version = "0.1.1" }
spin = "0.9.4"
static_assertions = "1.1.0"
tdx-guest = { version = "0.1.5", optional = true }
trapframe = { git = "https://github.com/asterinas/trapframe-rs", rev = "4739428" }
trapframe = "0.10.0"
unwinding = { version = "0.2.2", default-features = false, features = ["fde-gnu-eh-frame-hdr", "hide-trace", "panic", "personality", "unwinder"] }
volatile = { version = "0.4.5", features = ["unstable"] }
owo-colors = { version = "3", optional = true }
xarray = { git = "https://github.com/asterinas/xarray", rev = "72a4067", version = "0.1.0" }
[target.x86_64-unknown-none.dependencies]
x86_64 = "0.14.2"

View File

@ -18,12 +18,4 @@ Asterinas OSTD offers the following key values.
## OSTD APIs
TODO
## Implementation status
TODO
## Roadmap and plan
TODO
See [API docs](https://docs.rs/ostd/latest/ostd).

View File

@ -2,6 +2,9 @@
name = "id-alloc"
version = "0.1.0"
edition = "2021"
license = "MPL-2.0"
description = "An id allocator implemented by the bitmap"
repository = "https://github.com/asterinas/asterinas"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -2,6 +2,9 @@
name = "linux-boot-params"
version = "0.1.0"
edition = "2021"
description = "The Boot Parameters for Linux Boot Protocol"
license = "MPL-2.0"
repository = "https://github.com/asterinas/asterinas"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -2,6 +2,9 @@
name = "linux-bzimage-setup"
version = "0.1.0"
edition = "2021"
description = "The linux bzImage setup binary"
license = "MPL-2.0"
repository = "https://github.com/asterinas/asterinas"
[[bin]]
name = "linux-bzimage-setup"
@ -11,7 +14,7 @@ path = "src/main.rs"
[dependencies]
cfg-if = "1.0.0"
linux-boot-params = { path = "../boot-params" }
linux-boot-params = { path = "../boot-params", version = "0.1.0" }
uart_16550 = "0.3.0"
xmas-elf = "0.8.0"

View File

@ -1,7 +1,10 @@
[package]
name = "ostd-macros"
version = "0.1.0"
version = "0.1.4"
edition = "2021"
description = "OSTD's proc macros"
license = "MPL-2.0"
repository ="https://github.com/asterinas/asterinas"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -11,7 +11,9 @@ use syn::{parse_macro_input, Expr, Ident, ItemFn};
///
/// # Example
///
/// ```norun
/// ```ignore
/// #![no_std]
///
/// use ostd::prelude::*;
///
/// #[ostd::main]
@ -44,7 +46,7 @@ pub fn main(_attr: TokenStream, item: TokenStream) -> TokenStream {
/// For crates other than ostd,
/// this macro can be used in the following form.
///
/// ```norun
/// ```ignore
/// use ostd::prelude::*;
///
/// #[ktest]
@ -56,7 +58,7 @@ pub fn main(_attr: TokenStream, item: TokenStream) -> TokenStream {
/// For ostd crate itself,
/// this macro can be used in the form
///
/// ```norun
/// ```ignore
/// use crate::prelude::*;
///
/// #[ktest]
@ -144,10 +146,10 @@ pub fn ktest(_attr: TokenStream, item: TokenStream) -> TokenStream {
#[cfg(ktest)]
#[used]
#[link_section = ".ktest_array"]
static #fn_ktest_item_name: ktest::KtestItem = ktest::KtestItem::new(
static #fn_ktest_item_name: ostd_test::KtestItem = ostd_test::KtestItem::new(
#fn_name,
(#should_panic, #expectation_tokens),
ktest::KtestItemInfo {
ostd_test::KtestItemInfo {
module_path: module_path!(),
fn_name: stringify!(#fn_name),
package: #package_name,

View File

@ -1,7 +1,10 @@
[package]
name = "ktest"
name = "ostd-test"
version = "0.1.0"
edition = "2021"
description = "The kernel mode testing framework of OSTD"
license = "MPL-2.0"
repository ="https://github.com/asterinas/asterinas"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -1,20 +1,20 @@
// SPDX-License-Identifier: MPL-2.0
//! # The kernel mode testing framework of Asterinas.
//! # The kernel mode testing framework of OSTD.
//!
//! `ktest` stands for kernel-mode testing framework. Its goal is to provide a
//! `ostd-test` stands for kernel-mode testing framework for OSTD. Its goal is to provide a
//! `cargo test`-like experience for any `#![no_std]` bare metal crates.
//!
//! In Asterinas, all the tests written in the source tree of the crates will be run
//! In OSTD, all the tests written in the source tree of the crates will be run
//! immediately after the initialization of `ostd`. Thus you can use any
//! feature provided by the frame including the heap allocator, etc.
//!
//! By all means, ktest is an individule crate that only requires:
//! By all means, ostd-test is an individule crate that only requires:
//! - a custom linker script section `.ktest_array`,
//! - and an alloc implementation.
//!
//! And the frame happens to provide both of them. Thus, any crates depending
//! on the frame can use ktest without any extra dependency.
//! And the OSTD happens to provide both of them. Thus, any crates depending
//! on the OSTD can use ostd-test without any extra dependency.
//!
//! ## Usage
//!
@ -43,7 +43,7 @@
//! }
//! ```
//!
//! Any crates using the ktest framework should be linked with ostd.
//! Any crates using the ostd-test framework should be linked with ostd.
//!
//! ```toml
//! # Cargo.toml

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() {