basic runner

uefi
Able 2022-02-04 19:09:42 -06:00
parent 4bef64fe43
commit 2ebeb8a753
Signed by untrusted user: able
GPG Key ID: D164AF5F5700BE51
9 changed files with 142 additions and 92 deletions

View File

@ -2,8 +2,8 @@
[build]
# target = "./json_targets/x86_64-ableos.json"
target = "x86_64-unknown-uefi"
target = "./json_targets/x86_64-ableos.json"
# target = "x86_64-unknown-uefi"
[unstable]
build-std = ["core", "compiler_builtins", "alloc"]

12
ableos/Cargo.lock generated
View File

@ -48,6 +48,7 @@ dependencies = [
"spin",
"uart_16550",
"uefi",
"uefi-services",
"unicode-width",
"vga",
"volatile 0.2.7",
@ -653,6 +654,17 @@ dependencies = [
"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]]
name = "unicode-width"
version = "0.1.9"

View File

@ -51,8 +51,8 @@ pretty-hex = "0.2.1"
unicode-width = "0.1.7"
picorand = "*"
# watson = "0.4"
uefi = { version="*", features = ["exts"] }
uefi = { version="*",default-features = false, features = ["exts"] }
uefi-services = "0.11.0"
[dependencies.rdrand]
version = "0.8.1"

View File

@ -17,10 +17,10 @@ static ALLOCATOR: Dummy = Dummy;
*/
use linked_list_allocator::LockedHeap;
#[global_allocator]
// #[global_allocator]
pub static ALLOCATOR: LockedHeap = LockedHeap::empty();
#[alloc_error_handler]
// #[alloc_error_handler]
fn alloc_error_handler(layout: alloc::alloc::Layout) -> ! {
panic!("allocation error: {:?}", layout)
}

Binary file not shown.

View File

@ -1,5 +1,7 @@
#![allow(clippy::empty_loop)]
use x86_64::instructions::random::RdRand;
use {
crate::{
arch::{init, sloop},
@ -36,45 +38,45 @@ lazy_static! {
/// The main entry point of the kernel
#[no_mangle]
pub fn kernel_main() -> ! {
init::init();
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;
/* init::init();
log::set_max_level(BOOT_CONF.log_level());
{
let mut sock_print_id = SimpleSock::new();
sock_print_id.register_protocol("Screen Printer".to_string());
sock_print_id.write(format!("🐑").into());
{
let mut scheduler = SCHEDULER.lock();
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));
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());
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()
}
@ -105,3 +107,27 @@ pub fn log_version_data() {
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
}

View File

@ -14,6 +14,7 @@
naked_functions,
slice_pattern
)]
#![feature(abi_efiapi)]
/// Contains architecture specific code for aarch64.
#[cfg(target_arch = "aarch64")]

View File

@ -9,7 +9,7 @@ use {crate::arch::sloop, core::panic::PanicInfo};
///
/// # Safety
/// This function is unsafe because it does not guarantee that the panic is handled.
#[panic_handler]
// #[panic_handler]
fn panic(info: &PanicInfo) -> ! {
error!("{}", info);
// help me use facepalm::start_facepalm;

View File

@ -4,46 +4,47 @@ use clap::Parser;
#[clap(version = clap::crate_version!(), author = clap::crate_authors!("\n"))]
/// Hello Remember this is a feature
enum Command {
Run {
#[clap(long, short)]
debug: bool,
Run {
#[clap(long, short)]
debug: bool,
#[clap(long, short, arg_enum)]
machine: Option<MachineType>,
},
#[clap(long, short, arg_enum)]
machine: Option<MachineType>,
},
Doc {
#[clap(long, short, arg_enum)]
machine: Option<MachineType>,
},
Doc {
#[clap(long, short, arg_enum)]
machine: Option<MachineType>,
},
}
#[derive(clap::ArgEnum, Debug, Clone)]
enum MachineType {
X86,
RISCV,
ARM,
X86,
RISCV,
ARM,
Uefi86,
}
fn main() -> anyhow::Result<()> {
let args = Command::parse();
let args = Command::parse();
match args {
Command::Run { debug, machine } => {
let _dir = xshell::pushd("./ableos");
match args {
Command::Run { debug, machine } => {
let _dir = xshell::pushd("./ableos");
let _debug_log: &[&str] = match debug {
true => &["-D", "debug.log"],
false => &[],
};
match machine.unwrap_or(MachineType::X86) {
MachineType::X86 => {
xshell::cmd!("cargo run --release").run()?;
}
MachineType::ARM => {
xshell::cmd!("cargo build --release --target=json_targets/aarch64-ableos.json")
.run()?;
#[rustfmt::skip]
let _debug_log: &[&str] = match debug {
true => &["-D", "debug.log"],
false => &[],
};
match machine.unwrap_or(MachineType::X86) {
MachineType::X86 => {
xshell::cmd!("cargo run --release").run()?;
}
MachineType::ARM => {
xshell::cmd!("cargo build --release --target=json_targets/aarch64-ableos.json")
.run()?;
#[rustfmt::skip]
xshell::cmd!(
"qemu-system-aarch64
-machine virt
@ -53,10 +54,11 @@ fn main() -> anyhow::Result<()> {
-device virtio-keyboard
"
).run()?;
}
MachineType::RISCV => {
xshell::cmd!("cargo build --release --target=riscv64gc-unknown-none-elf").run()?;
#[rustfmt::skip]
}
MachineType::RISCV => {
xshell::cmd!("cargo build --release --target=riscv64gc-unknown-none-elf")
.run()?;
#[rustfmt::skip]
xshell::cmd!(
"qemu-system-riscv64
-machine virt
@ -66,26 +68,35 @@ fn main() -> anyhow::Result<()> {
-bios src/arch/riscv/firmwear/opensbi-riscv64-generic-fw_jump.bin
-kernel target/riscv64gc-unknown-none-elf/release/ableos"
).run()?;
}
}
}
}
MachineType::Uefi86 => {
xshell::cmd!("cargo build --release --target=x86_64-unknown-uefi").run()?;
Command::Doc { machine } => {
let _dir = xshell::pushd("./ableos");
xshell::cmd!("uefi-run -b src/arch/uefi_86/firmware/OVMF-pure-efi.fd target/x86_64-unknown-uefi/release/ableos.efi").run()?;
}
}
}
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()?;
}
}
}
}
Command::Doc { machine } => {
let _dir = xshell::pushd("./ableos");
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(())
}