forked from AbleOS/ableos
Merge branch 'master' into paging
This commit is contained in:
commit
e42b424b1a
|
@ -6,8 +6,10 @@ build-std-features = ["compiler-builtins-mem"]
|
||||||
build-std = ["core", "compiler_builtins", "alloc"]
|
build-std = ["core", "compiler_builtins", "alloc"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[target.'cfg(target_arch = "x86_64")']
|
[target.'cfg(target_arch = "x86_64")']
|
||||||
# --quiet suppresses warning messages from the bootimage crate
|
# --quiet suppresses warning messages from the bootimage crate
|
||||||
runner = "bootimage runner --quiet"
|
runner = "bootimage runner --quiet"
|
||||||
|
|
||||||
[target.riscv64gc-unknown-none-elf]
|
[target.riscv64gc-unknown-none-elf]
|
||||||
rustflags = "-C link-arg=-T../ableos/src/arch/riscv/virt.lds"
|
rustflags = "-C link-arg=-T../ableos/src/arch/riscv/virt.lds"
|
||||||
|
|
|
@ -15,12 +15,15 @@ run-args=["-serial", "stdio"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
spin = "0.5.2"
|
spin = "0.5.2"
|
||||||
# linked_list_allocator = "0.9.0"
|
|
||||||
|
|
||||||
[dependencies.lazy_static]
|
[dependencies.lazy_static]
|
||||||
features = ["spin_no_std"]
|
features = ["spin_no_std"]
|
||||||
version = "1.0"
|
version = "1.0"
|
||||||
|
|
||||||
|
# [dependencies.rhai]
|
||||||
|
# version = "*"
|
||||||
|
# features = ["no_std"]
|
||||||
|
|
||||||
# alloc required
|
# alloc required
|
||||||
# [dependencies.wasmi]
|
# [dependencies.wasmi]
|
||||||
# version = "*"
|
# version = "*"
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
pub mod graphics;
|
pub mod graphics;
|
||||||
pub mod nrf52;
|
pub mod nrf52;
|
||||||
|
pub mod serial;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/// Prints to the host through the serial interface.
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! serial_print {
|
macro_rules! serial_print {
|
||||||
($($arg:tt)*) => {};
|
($($arg:tt)*) => {};
|
|
@ -4,7 +4,6 @@ use core::ptr;
|
||||||
pub mod drivers;
|
pub mod drivers;
|
||||||
pub mod init;
|
pub mod init;
|
||||||
|
|
||||||
pub mod serial;
|
|
||||||
use crate::arch::drivers::nrf52::{Level, Pins};
|
use crate::arch::drivers::nrf52::{Level, Pins};
|
||||||
use core::ptr::write_volatile;
|
use core::ptr::write_volatile;
|
||||||
global_asm!(include_str!("boot.s"));
|
global_asm!(include_str!("boot.s"));
|
||||||
|
|
|
@ -33,6 +33,7 @@ use lazy_static::lazy_static;
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref SERIAL: Mutex<Serial123> = {
|
pub static ref SERIAL: Mutex<Serial123> = {
|
||||||
let serial_port = Serial123 {
|
let serial_port = Serial123 {
|
||||||
|
/// UART port for the serial bus
|
||||||
uart_data: 0x10000000,
|
uart_data: 0x10000000,
|
||||||
};
|
};
|
||||||
Mutex::new(serial_port)
|
Mutex::new(serial_port)
|
||||||
|
|
|
@ -31,3 +31,10 @@ Memory: {}
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
pub const KERNEL_VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
/// A constant to check if the kernel is in debug mode
|
||||||
|
pub const RELEASE_TYPE: &str = "debug";
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
/// A constant to check if the kernel is in release mode
|
||||||
|
pub const RELEASE_TYPE: &str = "release";
|
||||||
|
|
|
@ -9,10 +9,16 @@ use crate::{
|
||||||
driver_traits::{graphics::Graphics, serial::Serial},
|
driver_traits::{graphics::Graphics, serial::Serial},
|
||||||
relib::math::rand::{linearshift::LinearShiftRegister, prand::PRand, RAND_HANDLE, RNG},
|
relib::math::rand::{linearshift::LinearShiftRegister, prand::PRand, RAND_HANDLE, RNG},
|
||||||
serial_print, serial_println,
|
serial_print, serial_println,
|
||||||
|
|
||||||
|
experiments::systeminfo::{KERNEL_VERSION, RELEASE_TYPE},
|
||||||
|
keyboard::DecodedKey,
|
||||||
};
|
};
|
||||||
use bootloader::{entry_point, BootInfo};
|
use bootloader::{entry_point, BootInfo};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
|
||||||
|
|
||||||
use x86_64::{VirtAddr, structures::paging::Page};
|
use x86_64::{VirtAddr, structures::paging::Page};
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
#[allow(unconditional_recursion)]
|
#[allow(unconditional_recursion)]
|
||||||
pub extern "C" fn stack_overflow() -> u8 {
|
pub extern "C" fn stack_overflow() -> u8 {
|
||||||
|
@ -21,8 +27,6 @@ pub extern "C" fn stack_overflow() -> u8 {
|
||||||
69 // NOTE: Any specific reason for this number asside from memes?
|
69 // NOTE: Any specific reason for this number asside from memes?
|
||||||
}
|
}
|
||||||
|
|
||||||
use crate::keyboard::DecodedKey;
|
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref KEY_BUFFER: [DecodedKey; 256] = [DecodedKey::RawKey(123); 256];
|
pub static ref KEY_BUFFER: [DecodedKey; 256] = [DecodedKey::RawKey(123); 256];
|
||||||
pub static ref KEY_BUFFER_POINTER: u8 = 0;
|
pub static ref KEY_BUFFER_POINTER: u8 = 0;
|
||||||
|
@ -41,10 +45,11 @@ pub fn kernel_main(boot_info: &'static BootInfo) -> ! {
|
||||||
/* If AES is present then AES init rng as well
|
/* If AES is present then AES init rng as well
|
||||||
// Maybe via a cfg
|
// Maybe via a cfg
|
||||||
AES::init_rng();
|
AES::init_rng();
|
||||||
|
*/
|
||||||
|
|
||||||
*/
|
|
||||||
#[cfg(not(target_arch = "riscv64"))]
|
|
||||||
println!("init");
|
println!("{} v{}", RELEASE_TYPE, KERNEL_VERSION);
|
||||||
|
|
||||||
{
|
{
|
||||||
use crate::experiments::mail::MailBoxes;
|
use crate::experiments::mail::MailBoxes;
|
||||||
|
|
|
@ -1,48 +1,39 @@
|
||||||
|
//! hi
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
// #![deny(warnings)]
|
#![feature(
|
||||||
#![feature(asm)]
|
abi_x86_interrupt,
|
||||||
#![feature(global_asm)]
|
asm,
|
||||||
#![feature(abi_x86_interrupt)]
|
core_intrinsics,
|
||||||
#![feature(core_intrinsics, lang_items, llvm_asm)]
|
global_asm,
|
||||||
// #![feature(alloc_error_handler)] // at the top of the file
|
lang_items,
|
||||||
#![reexport_test_harness_main = "test_main"]
|
llvm_asm,
|
||||||
#![feature(custom_test_frameworks)]
|
naked_functions
|
||||||
#![test_runner(crate::arch::test_runner)]
|
)]
|
||||||
#![feature(naked_functions)]
|
|
||||||
#[cfg(target_arch = "arm")]
|
|
||||||
#[path = "arch/aarch32/mod.rs"]
|
|
||||||
mod arch;
|
|
||||||
|
|
||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
#[path = "arch/aarch64/mod.rs"]
|
#[path = "arch/aarch64/mod.rs"]
|
||||||
mod arch;
|
pub mod arch;
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
#[path = "arch/x86_64/mod.rs"]
|
#[path = "arch/x86_64/mod.rs"]
|
||||||
mod arch;
|
pub mod arch;
|
||||||
|
|
||||||
#[cfg(target_arch = "riscv64")]
|
#[cfg(target_arch = "riscv64")]
|
||||||
#[path = "arch/riscv/mod.rs"]
|
#[path = "arch/riscv/mod.rs"]
|
||||||
mod arch;
|
pub mod arch;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod print;
|
pub mod print;
|
||||||
|
|
||||||
use arch::drivers::serial;
|
use arch::drivers::serial;
|
||||||
|
|
||||||
mod driver_traits;
|
pub mod driver_traits;
|
||||||
mod experiments;
|
pub mod experiments;
|
||||||
#[cfg(not(target_arch = "mips"))]
|
|
||||||
// pub mod allocator;
|
|
||||||
mod kmain;
|
|
||||||
#[cfg(not(target_arch = "mips"))]
|
|
||||||
mod panic;
|
|
||||||
pub use experiments::server;
|
|
||||||
pub mod keyboard;
|
pub mod keyboard;
|
||||||
|
pub mod kmain;
|
||||||
|
pub mod panic;
|
||||||
pub mod relib;
|
pub mod relib;
|
||||||
pub const KERNEL_VERSION: &str = env!("CARGO_PKG_VERSION");
|
|
||||||
#[cfg(debug_assertions)]
|
use experiments::server;
|
||||||
/// A constant to check if the kernel is in debug mode
|
|
||||||
pub const RELEASE_TYPE: &str = "debug";
|
|
||||||
#[cfg(not(debug_assertions))]
|
|
||||||
/// A constant to check if the kernel is in release mode
|
|
||||||
pub const RELEASE_TYPE: &str = "release";
|
|
||||||
extern crate alloc;
|
|
||||||
|
|
|
@ -9,20 +9,12 @@ impl Stdout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl core::fmt::Write for Stdout {
|
impl core::fmt::Write for Stdout {
|
||||||
#[cfg(target_arch = "arm")]
|
|
||||||
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
|
||||||
use crate::arch::write;
|
|
||||||
write(s);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
||||||
// Don't actually print anything yet lmao
|
// Don't actually print anything yet lmao
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
||||||
use crate::kprint;
|
use crate::kprint;
|
||||||
|
@ -34,12 +26,6 @@ impl core::fmt::Write for Stdout {
|
||||||
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
#[cfg(target_arch = "mips")]
|
|
||||||
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
|
||||||
use psp::dprint;
|
|
||||||
dprint!("{}", s);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! print {
|
macro_rules! print {
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
pub mod linearshift;
|
pub mod linearshift;
|
||||||
pub mod prand;
|
pub mod prand;
|
||||||
pub mod wichmanhillrand; // FIXEME: Reimplement
|
pub mod wichmanhillrand; // FIXEME: Reimplement
|
||||||
use crate::serial_println;
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use linearshift::LinearShiftRegister;
|
use linearshift::LinearShiftRegister;
|
||||||
use prand::PRand;
|
use prand::PRand;
|
||||||
|
|
0
ableos/src/serial.rs
Normal file
0
ableos/src/serial.rs
Normal file
0
ableos/src/wasm/mod.rs
Normal file
0
ableos/src/wasm/mod.rs
Normal file
|
@ -11,6 +11,11 @@ enum Command {
|
||||||
#[clap(long, short, arg_enum)]
|
#[clap(long, short, arg_enum)]
|
||||||
machine: Option<MachineType>,
|
machine: Option<MachineType>,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Doc {
|
||||||
|
#[clap(long, short, arg_enum)]
|
||||||
|
machine: Option<MachineType>,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(clap::ArgEnum, Debug, Clone)]
|
#[derive(clap::ArgEnum, Debug, Clone)]
|
||||||
|
@ -34,7 +39,6 @@ fn main() -> anyhow::Result<()> {
|
||||||
};
|
};
|
||||||
match machine.unwrap_or(MachineType::X86) {
|
match machine.unwrap_or(MachineType::X86) {
|
||||||
MachineType::X86 => {
|
MachineType::X86 => {
|
||||||
// Used for the x86-64 variant only
|
|
||||||
xshell::cmd!("cargo run --release").run()?;
|
xshell::cmd!("cargo run --release").run()?;
|
||||||
}
|
}
|
||||||
MachineType::ARM => {
|
MachineType::ARM => {
|
||||||
|
@ -67,6 +71,23 @@ fn main() -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Command::Doc { machine } => {
|
||||||
|
let _dir = xshell::pushd("./ableos");
|
||||||
|
|
||||||
|
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()?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue