basic runner
This commit is contained in:
parent
2d5e8d24eb
commit
27698842da
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
# target = "./json_targets/x86_64-ableos.json"
|
target = "./json_targets/x86_64-ableos.json"
|
||||||
target = "x86_64-unknown-uefi"
|
# target = "x86_64-unknown-uefi"
|
||||||
|
|
||||||
[unstable]
|
[unstable]
|
||||||
build-std = ["core", "compiler_builtins", "alloc"]
|
build-std = ["core", "compiler_builtins", "alloc"]
|
||||||
|
|
12
ableos/Cargo.lock
generated
12
ableos/Cargo.lock
generated
|
@ -48,6 +48,7 @@ dependencies = [
|
||||||
"spin",
|
"spin",
|
||||||
"uart_16550",
|
"uart_16550",
|
||||||
"uefi",
|
"uefi",
|
||||||
|
"uefi-services",
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
"vga",
|
"vga",
|
||||||
"volatile 0.2.7",
|
"volatile 0.2.7",
|
||||||
|
@ -653,6 +654,17 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "uefi-services"
|
||||||
|
version = "0.11.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7840bddc6477dc443cc5652ca9683de9f10bd173691151c3160d734521bef3bd"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"log",
|
||||||
|
"uefi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-width"
|
name = "unicode-width"
|
||||||
version = "0.1.9"
|
version = "0.1.9"
|
||||||
|
|
|
@ -51,8 +51,8 @@ pretty-hex = "0.2.1"
|
||||||
unicode-width = "0.1.7"
|
unicode-width = "0.1.7"
|
||||||
picorand = "*"
|
picorand = "*"
|
||||||
# watson = "0.4"
|
# watson = "0.4"
|
||||||
uefi = { version="*", features = ["exts"] }
|
uefi = { version="*",default-features = false, features = ["exts"] }
|
||||||
|
uefi-services = "0.11.0"
|
||||||
|
|
||||||
[dependencies.rdrand]
|
[dependencies.rdrand]
|
||||||
version = "0.8.1"
|
version = "0.8.1"
|
||||||
|
|
|
@ -17,10 +17,10 @@ static ALLOCATOR: Dummy = Dummy;
|
||||||
*/
|
*/
|
||||||
use linked_list_allocator::LockedHeap;
|
use linked_list_allocator::LockedHeap;
|
||||||
|
|
||||||
#[global_allocator]
|
// #[global_allocator]
|
||||||
pub static ALLOCATOR: LockedHeap = LockedHeap::empty();
|
pub static ALLOCATOR: LockedHeap = LockedHeap::empty();
|
||||||
|
|
||||||
#[alloc_error_handler]
|
// #[alloc_error_handler]
|
||||||
fn alloc_error_handler(layout: alloc::alloc::Layout) -> ! {
|
fn alloc_error_handler(layout: alloc::alloc::Layout) -> ! {
|
||||||
panic!("allocation error: {:?}", layout)
|
panic!("allocation error: {:?}", layout)
|
||||||
}
|
}
|
||||||
|
|
BIN
ableos/src/arch/uefi_86/firmware/OVMF-pure-efi.fd
Normal file
BIN
ableos/src/arch/uefi_86/firmware/OVMF-pure-efi.fd
Normal file
Binary file not shown.
|
@ -1,5 +1,7 @@
|
||||||
#![allow(clippy::empty_loop)]
|
#![allow(clippy::empty_loop)]
|
||||||
|
|
||||||
|
use x86_64::instructions::random::RdRand;
|
||||||
|
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
arch::{init, sloop},
|
arch::{init, sloop},
|
||||||
|
@ -36,45 +38,45 @@ lazy_static! {
|
||||||
/// The main entry point of the kernel
|
/// The main entry point of the kernel
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub fn kernel_main() -> ! {
|
pub fn kernel_main() -> ! {
|
||||||
init::init();
|
/* init::init();
|
||||||
log::set_max_level(BOOT_CONF.log_level());
|
log::set_max_level(BOOT_CONF.log_level());
|
||||||
|
|
||||||
{
|
|
||||||
{
|
|
||||||
let mut scheduler = SCHEDULER.lock();
|
|
||||||
|
|
||||||
use crate::scheduler::Priority::*;
|
|
||||||
let mut process_1 = scheduler.new_process(High);
|
|
||||||
process_1.capabilities.files = FileAccess::Some(vec![PathRep {
|
|
||||||
location: FileLocations::Home,
|
|
||||||
file_name: "test".to_string(),
|
|
||||||
}]);
|
|
||||||
scheduler.add_process(process_1);
|
|
||||||
for ref_process in &scheduler.list {
|
|
||||||
trace!("{:?}", ref_process);
|
|
||||||
}
|
|
||||||
drop(scheduler);
|
|
||||||
}
|
|
||||||
|
|
||||||
use crate::proto_filetable::file::FileLocations;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut sock_print_id = SimpleSock::new();
|
{
|
||||||
sock_print_id.register_protocol("Screen Printer".to_string());
|
let mut scheduler = SCHEDULER.lock();
|
||||||
sock_print_id.write(format!("🐑").into());
|
|
||||||
|
|
||||||
let mut mode = SCREEN_BUFFER.lock();
|
use crate::scheduler::Priority::*;
|
||||||
|
let mut process_1 = scheduler.new_process(High);
|
||||||
mode.force_redraw();
|
process_1.capabilities.files = FileAccess::Some(vec![PathRep {
|
||||||
for current in (*String::from_utf8_lossy(&sock_print_id.peek().unwrap())).chars() {
|
location: FileLocations::Home,
|
||||||
mode.draw_char(0, 0, current, from_vga_16(Color16::Red));
|
file_name: "test".to_string(),
|
||||||
|
}]);
|
||||||
|
scheduler.add_process(process_1);
|
||||||
|
for ref_process in &scheduler.list {
|
||||||
|
trace!("{:?}", ref_process);
|
||||||
|
}
|
||||||
|
drop(scheduler);
|
||||||
|
}
|
||||||
|
|
||||||
|
use crate::proto_filetable::file::FileLocations;
|
||||||
|
|
||||||
|
{
|
||||||
|
let mut sock_print_id = SimpleSock::new();
|
||||||
|
sock_print_id.register_protocol("Screen Printer".to_string());
|
||||||
|
sock_print_id.write(format!("🐑").into());
|
||||||
|
|
||||||
|
let mut mode = SCREEN_BUFFER.lock();
|
||||||
|
|
||||||
|
mode.force_redraw();
|
||||||
|
for current in (*String::from_utf8_lossy(&sock_print_id.peek().unwrap())).chars() {
|
||||||
|
mode.draw_char(0, 0, current, from_vga_16(Color16::Red));
|
||||||
|
}
|
||||||
|
mode.copy_to_buffer();
|
||||||
}
|
}
|
||||||
mode.copy_to_buffer();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
start_facepalm();
|
|
||||||
|
|
||||||
|
start_facepalm();
|
||||||
|
*/
|
||||||
sloop()
|
sloop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,3 +107,27 @@ pub fn log_version_data() {
|
||||||
master().unwrap().brand_string().unwrap()
|
master().unwrap().brand_string().unwrap()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn generate_process_pass() -> u128 {
|
||||||
|
use rdrand::RdRand;
|
||||||
|
let gen = RdRand::new().unwrap();
|
||||||
|
let ret = (gen.try_next_u64().unwrap() as u128) << 64 | (gen.try_next_u64().unwrap() as u128);
|
||||||
|
ret
|
||||||
|
}
|
||||||
|
|
||||||
|
// #![no_main]
|
||||||
|
// #![no_std]
|
||||||
|
|
||||||
|
use uefi::prelude::*;
|
||||||
|
use uefi::ResultExt;
|
||||||
|
|
||||||
|
#[entry]
|
||||||
|
fn main(_handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
|
||||||
|
uefi_services::init(&mut system_table).unwrap_success();
|
||||||
|
log_version_data();
|
||||||
|
|
||||||
|
kernel_main();
|
||||||
|
|
||||||
|
loop {}
|
||||||
|
// Status::SUCCESS
|
||||||
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
naked_functions,
|
naked_functions,
|
||||||
slice_pattern
|
slice_pattern
|
||||||
)]
|
)]
|
||||||
|
#![feature(abi_efiapi)]
|
||||||
|
|
||||||
/// Contains architecture specific code for aarch64.
|
/// Contains architecture specific code for aarch64.
|
||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
|
|
|
@ -9,7 +9,7 @@ use {crate::arch::sloop, core::panic::PanicInfo};
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// This function is unsafe because it does not guarantee that the panic is handled.
|
/// This function is unsafe because it does not guarantee that the panic is handled.
|
||||||
#[panic_handler]
|
// #[panic_handler]
|
||||||
fn panic(info: &PanicInfo) -> ! {
|
fn panic(info: &PanicInfo) -> ! {
|
||||||
error!("{}", info);
|
error!("{}", info);
|
||||||
// help me use facepalm::start_facepalm;
|
// help me use facepalm::start_facepalm;
|
||||||
|
|
|
@ -4,46 +4,47 @@ use clap::Parser;
|
||||||
#[clap(version = clap::crate_version!(), author = clap::crate_authors!("\n"))]
|
#[clap(version = clap::crate_version!(), author = clap::crate_authors!("\n"))]
|
||||||
/// Hello Remember this is a feature
|
/// Hello Remember this is a feature
|
||||||
enum Command {
|
enum Command {
|
||||||
Run {
|
Run {
|
||||||
#[clap(long, short)]
|
#[clap(long, short)]
|
||||||
debug: bool,
|
debug: bool,
|
||||||
|
|
||||||
#[clap(long, short, arg_enum)]
|
#[clap(long, short, arg_enum)]
|
||||||
machine: Option<MachineType>,
|
machine: Option<MachineType>,
|
||||||
},
|
},
|
||||||
|
|
||||||
Doc {
|
Doc {
|
||||||
#[clap(long, short, arg_enum)]
|
#[clap(long, short, arg_enum)]
|
||||||
machine: Option<MachineType>,
|
machine: Option<MachineType>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(clap::ArgEnum, Debug, Clone)]
|
#[derive(clap::ArgEnum, Debug, Clone)]
|
||||||
enum MachineType {
|
enum MachineType {
|
||||||
X86,
|
X86,
|
||||||
RISCV,
|
RISCV,
|
||||||
ARM,
|
ARM,
|
||||||
|
Uefi86,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> anyhow::Result<()> {
|
fn main() -> anyhow::Result<()> {
|
||||||
let args = Command::parse();
|
let args = Command::parse();
|
||||||
|
|
||||||
match args {
|
match args {
|
||||||
Command::Run { debug, machine } => {
|
Command::Run { debug, machine } => {
|
||||||
let _dir = xshell::pushd("./ableos");
|
let _dir = xshell::pushd("./ableos");
|
||||||
|
|
||||||
let _debug_log: &[&str] = match debug {
|
let _debug_log: &[&str] = match debug {
|
||||||
true => &["-D", "debug.log"],
|
true => &["-D", "debug.log"],
|
||||||
false => &[],
|
false => &[],
|
||||||
};
|
};
|
||||||
match machine.unwrap_or(MachineType::X86) {
|
match machine.unwrap_or(MachineType::X86) {
|
||||||
MachineType::X86 => {
|
MachineType::X86 => {
|
||||||
xshell::cmd!("cargo run --release").run()?;
|
xshell::cmd!("cargo run --release").run()?;
|
||||||
}
|
}
|
||||||
MachineType::ARM => {
|
MachineType::ARM => {
|
||||||
xshell::cmd!("cargo build --release --target=json_targets/aarch64-ableos.json")
|
xshell::cmd!("cargo build --release --target=json_targets/aarch64-ableos.json")
|
||||||
.run()?;
|
.run()?;
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
xshell::cmd!(
|
xshell::cmd!(
|
||||||
"qemu-system-aarch64
|
"qemu-system-aarch64
|
||||||
-machine virt
|
-machine virt
|
||||||
|
@ -53,10 +54,11 @@ fn main() -> anyhow::Result<()> {
|
||||||
-device virtio-keyboard
|
-device virtio-keyboard
|
||||||
"
|
"
|
||||||
).run()?;
|
).run()?;
|
||||||
}
|
}
|
||||||
MachineType::RISCV => {
|
MachineType::RISCV => {
|
||||||
xshell::cmd!("cargo build --release --target=riscv64gc-unknown-none-elf").run()?;
|
xshell::cmd!("cargo build --release --target=riscv64gc-unknown-none-elf")
|
||||||
#[rustfmt::skip]
|
.run()?;
|
||||||
|
#[rustfmt::skip]
|
||||||
xshell::cmd!(
|
xshell::cmd!(
|
||||||
"qemu-system-riscv64
|
"qemu-system-riscv64
|
||||||
-machine virt
|
-machine virt
|
||||||
|
@ -66,26 +68,35 @@ fn main() -> anyhow::Result<()> {
|
||||||
-bios src/arch/riscv/firmwear/opensbi-riscv64-generic-fw_jump.bin
|
-bios src/arch/riscv/firmwear/opensbi-riscv64-generic-fw_jump.bin
|
||||||
-kernel target/riscv64gc-unknown-none-elf/release/ableos"
|
-kernel target/riscv64gc-unknown-none-elf/release/ableos"
|
||||||
).run()?;
|
).run()?;
|
||||||
}
|
}
|
||||||
}
|
MachineType::Uefi86 => {
|
||||||
}
|
xshell::cmd!("cargo build --release --target=x86_64-unknown-uefi").run()?;
|
||||||
|
|
||||||
Command::Doc { machine } => {
|
xshell::cmd!("uefi-run -b src/arch/uefi_86/firmware/OVMF-pure-efi.fd target/x86_64-unknown-uefi/release/ableos.efi").run()?;
|
||||||
let _dir = xshell::pushd("./ableos");
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
match machine.unwrap_or(MachineType::X86) {
|
Command::Doc { machine } => {
|
||||||
MachineType::X86 => {
|
let _dir = xshell::pushd("./ableos");
|
||||||
xshell::cmd!("cargo doc --open").run()?;
|
|
||||||
}
|
|
||||||
MachineType::ARM => {
|
|
||||||
xshell::cmd!("cargo doc --open --target=json_targets/aarch64-ableos.json").run()?;
|
|
||||||
}
|
|
||||||
MachineType::RISCV => {
|
|
||||||
xshell::cmd!("cargo doc --open --target=riscv64gc-unknown-none-elf").run()?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
match machine.unwrap_or(MachineType::X86) {
|
||||||
|
MachineType::X86 => {
|
||||||
|
xshell::cmd!("cargo doc --open").run()?;
|
||||||
|
}
|
||||||
|
MachineType::ARM => {
|
||||||
|
xshell::cmd!("cargo doc --open --target=json_targets/aarch64-ableos.json")
|
||||||
|
.run()?;
|
||||||
|
}
|
||||||
|
MachineType::RISCV => {
|
||||||
|
xshell::cmd!("cargo doc --open --target=riscv64gc-unknown-none-elf").run()?;
|
||||||
|
}
|
||||||
|
MachineType::Uefi86 => {
|
||||||
|
xshell::cmd!("cargo doc --open --target=x86_64-unknown-uefi").run()?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue