mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-11 06:16:49 +00:00
Remove the shim kernel crate
This commit is contained in:
parent
d76c7a5b1e
commit
dafd16075f
15
Cargo.lock
generated
15
Cargo.lock
generated
@ -153,6 +153,7 @@ dependencies = [
|
|||||||
"ascii",
|
"ascii",
|
||||||
"aster-block",
|
"aster-block",
|
||||||
"aster-console",
|
"aster-console",
|
||||||
|
"aster-framebuffer",
|
||||||
"aster-input",
|
"aster-input",
|
||||||
"aster-network",
|
"aster-network",
|
||||||
"aster-rights",
|
"aster-rights",
|
||||||
@ -166,6 +167,7 @@ dependencies = [
|
|||||||
"bytemuck",
|
"bytemuck",
|
||||||
"bytemuck_derive",
|
"bytemuck_derive",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
|
"component",
|
||||||
"controlled",
|
"controlled",
|
||||||
"core2",
|
"core2",
|
||||||
"cpio-decoder",
|
"cpio-decoder",
|
||||||
@ -262,19 +264,6 @@ dependencies = [
|
|||||||
"typeflags-util",
|
"typeflags-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "asterinas"
|
|
||||||
version = "0.4.0"
|
|
||||||
dependencies = [
|
|
||||||
"aster-framebuffer",
|
|
||||||
"aster-nix",
|
|
||||||
"aster-time",
|
|
||||||
"component",
|
|
||||||
"id-alloc",
|
|
||||||
"ostd",
|
|
||||||
"x86_64 0.14.11",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "atomic"
|
name = "atomic"
|
||||||
version = "0.6.0"
|
version = "0.6.0"
|
||||||
|
@ -11,7 +11,6 @@ members = [
|
|||||||
"ostd/libs/linux-bzimage/setup",
|
"ostd/libs/linux-bzimage/setup",
|
||||||
"ostd/libs/ostd-test",
|
"ostd/libs/ostd-test",
|
||||||
"kernel",
|
"kernel",
|
||||||
"kernel/aster-nix",
|
|
||||||
"kernel/comps/block",
|
"kernel/comps/block",
|
||||||
"kernel/comps/console",
|
"kernel/comps/console",
|
||||||
"kernel/comps/framebuffer",
|
"kernel/comps/framebuffer",
|
||||||
|
@ -8,8 +8,7 @@ console = { name = "aster-console" }
|
|||||||
time = { name = "aster-time" }
|
time = { name = "aster-time" }
|
||||||
framebuffer = { name = "aster-framebuffer" }
|
framebuffer = { name = "aster-framebuffer" }
|
||||||
network = { name = "aster-network" }
|
network = { name = "aster-network" }
|
||||||
main = { name = "asterinas" }
|
|
||||||
|
|
||||||
[whitelist]
|
[whitelist]
|
||||||
[whitelist.nix.run_first_process]
|
[whitelist.nix.main]
|
||||||
main = true
|
main = true
|
||||||
|
1
Makefile
1
Makefile
@ -114,7 +114,6 @@ OSDK_CRATES := \
|
|||||||
ostd \
|
ostd \
|
||||||
ostd/libs/linux-bzimage/setup \
|
ostd/libs/linux-bzimage/setup \
|
||||||
kernel \
|
kernel \
|
||||||
kernel/aster-nix \
|
|
||||||
kernel/comps/block \
|
kernel/comps/block \
|
||||||
kernel/comps/console \
|
kernel/comps/console \
|
||||||
kernel/comps/framebuffer \
|
kernel/comps/framebuffer \
|
||||||
|
@ -1,18 +1,82 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "asterinas"
|
name = "aster-nix"
|
||||||
version = "0.4.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
id-alloc = { path = "../ostd/libs/id-alloc" }
|
|
||||||
ostd = { path = "../ostd" }
|
|
||||||
aster-nix = { path = "aster-nix" }
|
|
||||||
component = { path = "libs/comp-sys/component" }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dependencies]
|
||||||
x86_64 = "0.14.2"
|
align_ext = { path = "../ostd/libs/align_ext" }
|
||||||
aster-time = { path = "comps/time" }
|
aster-input = { path = "comps/input" }
|
||||||
|
aster-block = { path = "comps/block" }
|
||||||
|
aster-network = { path = "comps/network" }
|
||||||
|
aster-console = { path = "comps/console" }
|
||||||
aster-framebuffer = { path = "comps/framebuffer" }
|
aster-framebuffer = { path = "comps/framebuffer" }
|
||||||
|
aster-time = { path = "comps/time" }
|
||||||
|
aster-virtio = { path = "comps/virtio" }
|
||||||
|
aster-rights = { path = "libs/aster-rights" }
|
||||||
|
component = { path = "libs/comp-sys/component" }
|
||||||
|
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" }
|
||||||
|
aster-util = { path = "libs/aster-util" }
|
||||||
|
id-alloc = { path = "../ostd/libs/id-alloc" }
|
||||||
|
int-to-c-enum = { path = "libs/int-to-c-enum" }
|
||||||
|
cpio-decoder = { path = "libs/cpio-decoder" }
|
||||||
|
ascii = { version = "1.1", default-features = false, features = ["alloc"] }
|
||||||
|
intrusive-collections = "0.9.5"
|
||||||
|
paste = "1.0"
|
||||||
|
time = { version = "0.3", default-features = false, features = ["alloc"] }
|
||||||
|
smoltcp = { git = "https://github.com/smoltcp-rs/smoltcp", rev = "dc08e0b", 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",
|
||||||
|
] }
|
||||||
|
tdx-guest = { version = "0.1.7", optional = true }
|
||||||
|
|
||||||
|
# parse elf file
|
||||||
|
xmas-elf = "0.8.0"
|
||||||
|
# data-structures
|
||||||
|
bitflags = "1.3"
|
||||||
|
ringbuf = { version = "0.3.2", default-features = false, features = ["alloc"] }
|
||||||
|
keyable-arc = { path = "libs/keyable-arc" }
|
||||||
|
# unzip initramfs
|
||||||
|
libflate = { version = "2", default-features = false }
|
||||||
|
core2 = { version = "0.4", default-features = false, features = ["alloc"] }
|
||||||
|
lending-iterator = "0.1.7"
|
||||||
|
spin = "0.9.4"
|
||||||
|
vte = "0.10"
|
||||||
|
lru = "0.12.3"
|
||||||
|
log = "0.4"
|
||||||
|
bitvec = { version = "1.0", default-features = false, features = ["alloc"] }
|
||||||
|
hashbrown = "0.14"
|
||||||
|
rand = { version = "0.8.5", default-features = false, features = [
|
||||||
|
"small_rng",
|
||||||
|
"std_rng",
|
||||||
|
] }
|
||||||
|
static_assertions = "1.1.0"
|
||||||
|
inherit-methods-macro = { git = "https://github.com/asterinas/inherit-methods-macro", rev = "98f7e3e" }
|
||||||
|
getset = "0.1.2"
|
||||||
|
atomic = "0.6"
|
||||||
|
bytemuck = "1.14.3"
|
||||||
|
bytemuck_derive = "1.5.0"
|
||||||
|
takeable = "0.2.2"
|
||||||
|
cfg-if = "1.0"
|
||||||
|
|
||||||
|
[dependencies.lazy_static]
|
||||||
|
version = "1.0"
|
||||||
|
features = ["spin_no_std"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
cvm_guest = ["ostd/cvm_guest", "aster-nix/cvm_guest"]
|
cvm_guest = ["dep:tdx-guest", "ostd/cvm_guest"]
|
||||||
|
@ -1,81 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "aster-nix"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
align_ext = { path = "../../ostd/libs/align_ext" }
|
|
||||||
aster-input = { path = "../comps/input" }
|
|
||||||
aster-block = { path = "../comps/block" }
|
|
||||||
aster-network = { path = "../comps/network" }
|
|
||||||
aster-console = { path = "../comps/console" }
|
|
||||||
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" }
|
|
||||||
aster-util = { path = "../libs/aster-util" }
|
|
||||||
id-alloc = { path = "../../ostd/libs/id-alloc" }
|
|
||||||
int-to-c-enum = { path = "../libs/int-to-c-enum" }
|
|
||||||
cpio-decoder = { path = "../libs/cpio-decoder" }
|
|
||||||
ascii = { version = "1.1", default-features = false, features = ["alloc"] }
|
|
||||||
intrusive-collections = "0.9.5"
|
|
||||||
paste = "1.0"
|
|
||||||
time = { version = "0.3", default-features = false, features = ["alloc"] }
|
|
||||||
smoltcp = { git = "https://github.com/smoltcp-rs/smoltcp", rev = "dc08e0b", 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",
|
|
||||||
] }
|
|
||||||
tdx-guest = { version = "0.1.7", optional = true }
|
|
||||||
|
|
||||||
# parse elf file
|
|
||||||
xmas-elf = "0.8.0"
|
|
||||||
# goblin = {version= "0.5.3", default-features = false, features = ["elf64"]}
|
|
||||||
# data-structures
|
|
||||||
bitflags = "1.3"
|
|
||||||
ringbuf = { version = "0.3.2", default-features = false, features = ["alloc"] }
|
|
||||||
keyable-arc = { path = "../libs/keyable-arc" }
|
|
||||||
# unzip initramfs
|
|
||||||
libflate = { version = "2", default-features = false }
|
|
||||||
core2 = { version = "0.4", default-features = false, features = ["alloc"] }
|
|
||||||
lending-iterator = "0.1.7"
|
|
||||||
spin = "0.9.4"
|
|
||||||
vte = "0.10"
|
|
||||||
lru = "0.12.3"
|
|
||||||
log = "0.4"
|
|
||||||
bitvec = { version = "1.0", default-features = false, features = ["alloc"] }
|
|
||||||
hashbrown = "0.14"
|
|
||||||
rand = { version = "0.8.5", default-features = false, features = [
|
|
||||||
"small_rng",
|
|
||||||
"std_rng",
|
|
||||||
] }
|
|
||||||
static_assertions = "1.1.0"
|
|
||||||
inherit-methods-macro = { git = "https://github.com/asterinas/inherit-methods-macro", rev = "98f7e3e" }
|
|
||||||
getset = "0.1.2"
|
|
||||||
atomic = "0.6"
|
|
||||||
bytemuck = "1.14.3"
|
|
||||||
bytemuck_derive = "1.5.0"
|
|
||||||
takeable = "0.2.2"
|
|
||||||
cfg-if = "1.0"
|
|
||||||
|
|
||||||
[dependencies.lazy_static]
|
|
||||||
version = "1.0"
|
|
||||||
features = ["spin_no_std"]
|
|
||||||
|
|
||||||
[features]
|
|
||||||
cvm_guest = ["dep:tdx-guest"]
|
|
@ -1,155 +0,0 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
|
||||||
|
|
||||||
//! The std library of Asterinas.
|
|
||||||
#![no_std]
|
|
||||||
#![deny(unsafe_code)]
|
|
||||||
#![allow(incomplete_features)]
|
|
||||||
#![feature(btree_cursors)]
|
|
||||||
#![feature(btree_extract_if)]
|
|
||||||
#![feature(const_option)]
|
|
||||||
#![feature(extend_one)]
|
|
||||||
#![feature(fn_traits)]
|
|
||||||
#![feature(format_args_nl)]
|
|
||||||
#![feature(int_roundings)]
|
|
||||||
#![feature(iter_repeat_n)]
|
|
||||||
#![feature(let_chains)]
|
|
||||||
#![feature(linkage)]
|
|
||||||
#![feature(linked_list_remove)]
|
|
||||||
#![feature(negative_impls)]
|
|
||||||
#![feature(register_tool)]
|
|
||||||
// FIXME: This feature is used to support vm capbility now as a work around.
|
|
||||||
// Since this is an incomplete feature, use this feature is unsafe.
|
|
||||||
// We should find a proper method to replace this feature with min_specialization, which is a sound feature.
|
|
||||||
#![feature(specialization)]
|
|
||||||
#![feature(step_trait)]
|
|
||||||
#![feature(trait_alias)]
|
|
||||||
#![feature(trait_upcasting)]
|
|
||||||
#![feature(linked_list_retain)]
|
|
||||||
#![register_tool(component_access_control)]
|
|
||||||
|
|
||||||
use ostd::{
|
|
||||||
arch::qemu::{exit_qemu, QemuExitCode},
|
|
||||||
boot,
|
|
||||||
};
|
|
||||||
use process::Process;
|
|
||||||
|
|
||||||
use crate::{
|
|
||||||
prelude::*,
|
|
||||||
thread::{
|
|
||||||
kernel_thread::{KernelThreadExt, ThreadOptions},
|
|
||||||
Thread,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
extern crate alloc;
|
|
||||||
extern crate lru;
|
|
||||||
#[macro_use]
|
|
||||||
extern crate controlled;
|
|
||||||
#[macro_use]
|
|
||||||
extern crate getset;
|
|
||||||
|
|
||||||
pub mod arch;
|
|
||||||
pub mod console;
|
|
||||||
pub mod context;
|
|
||||||
pub mod cpu;
|
|
||||||
pub mod device;
|
|
||||||
pub mod driver;
|
|
||||||
pub mod error;
|
|
||||||
pub mod events;
|
|
||||||
pub mod fs;
|
|
||||||
pub mod ipc;
|
|
||||||
pub mod net;
|
|
||||||
pub mod prelude;
|
|
||||||
mod process;
|
|
||||||
mod sched;
|
|
||||||
pub mod softirq_id;
|
|
||||||
pub mod syscall;
|
|
||||||
mod taskless;
|
|
||||||
pub mod thread;
|
|
||||||
pub mod time;
|
|
||||||
mod util;
|
|
||||||
pub(crate) mod vdso;
|
|
||||||
pub mod vm;
|
|
||||||
|
|
||||||
pub fn init() {
|
|
||||||
util::random::init();
|
|
||||||
driver::init();
|
|
||||||
time::init();
|
|
||||||
net::init();
|
|
||||||
sched::init();
|
|
||||||
fs::rootfs::init(boot::initramfs()).unwrap();
|
|
||||||
device::init().unwrap();
|
|
||||||
vdso::init();
|
|
||||||
taskless::init();
|
|
||||||
process::init();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn init_thread() {
|
|
||||||
println!(
|
|
||||||
"[kernel] Spawn init thread, tid = {}",
|
|
||||||
current_thread!().tid()
|
|
||||||
);
|
|
||||||
// Work queue should be initialized before interrupt is enabled,
|
|
||||||
// in case any irq handler uses work queue as bottom half
|
|
||||||
thread::work_queue::init();
|
|
||||||
net::lazy_init();
|
|
||||||
fs::lazy_init();
|
|
||||||
ipc::init();
|
|
||||||
// driver::pci::virtio::block::block_device_test();
|
|
||||||
let thread = Thread::spawn_kernel_thread(ThreadOptions::new(|| {
|
|
||||||
println!("[kernel] Hello world from kernel!");
|
|
||||||
let current = current_thread!();
|
|
||||||
let tid = current.tid();
|
|
||||||
debug!("current tid = {}", tid);
|
|
||||||
}));
|
|
||||||
thread.join();
|
|
||||||
info!(
|
|
||||||
"[aster-nix/lib.rs] spawn kernel thread, tid = {}",
|
|
||||||
thread.tid()
|
|
||||||
);
|
|
||||||
|
|
||||||
print_banner();
|
|
||||||
|
|
||||||
let karg = boot::kernel_cmdline();
|
|
||||||
|
|
||||||
let initproc = Process::spawn_user_process(
|
|
||||||
karg.get_initproc_path().unwrap(),
|
|
||||||
karg.get_initproc_argv().to_vec(),
|
|
||||||
karg.get_initproc_envp().to_vec(),
|
|
||||||
)
|
|
||||||
.expect("Run init process failed.");
|
|
||||||
// Wait till initproc become zombie.
|
|
||||||
while !initproc.is_zombie() {
|
|
||||||
// We don't have preemptive scheduler now.
|
|
||||||
// The long running init thread should yield its own execution to allow other tasks to go on.
|
|
||||||
Thread::yield_now();
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: exit via qemu isa debug device should not be the only way.
|
|
||||||
let exit_code = if initproc.exit_code().unwrap() == 0 {
|
|
||||||
QemuExitCode::Success
|
|
||||||
} else {
|
|
||||||
QemuExitCode::Failed
|
|
||||||
};
|
|
||||||
exit_qemu(exit_code);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// first process never return
|
|
||||||
#[controlled]
|
|
||||||
pub fn run_first_process() -> ! {
|
|
||||||
Thread::spawn_kernel_thread(ThreadOptions::new(init_thread));
|
|
||||||
unreachable!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn print_banner() {
|
|
||||||
println!("\x1B[36m");
|
|
||||||
println!(
|
|
||||||
r"
|
|
||||||
_ ___ _____ ___ ___ ___ _ _ _ ___
|
|
||||||
/_\ / __|_ _| __| _ \_ _| \| | /_\ / __|
|
|
||||||
/ _ \\__ \ | | | _|| /| || .` |/ _ \\__ \
|
|
||||||
/_/ \_\___/ |_| |___|_|_\___|_|\_/_/ \_\___/
|
|
||||||
"
|
|
||||||
);
|
|
||||||
println!("\x1B[0m");
|
|
||||||
}
|
|
@ -107,7 +107,7 @@ mod test {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// Exfat disk image
|
/// Exfat disk image
|
||||||
static EXFAT_IMAGE: &[u8] = include_bytes!("../../../../../test/build/exfat.img");
|
static EXFAT_IMAGE: &[u8] = include_bytes!("../../../../test/build/exfat.img");
|
||||||
|
|
||||||
/// Read exfat disk image
|
/// Read exfat disk image
|
||||||
fn new_vm_segment_from_image() -> Segment {
|
fn new_vm_segment_from_image() -> Segment {
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user