This commit is contained in:
Able 2021-11-21 02:13:50 -06:00
parent 681dc11b1b
commit aea13d428f
9 changed files with 31 additions and 17 deletions

View file

@ -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 = "*"

View file

@ -1,2 +1,3 @@
pub mod graphics; pub mod graphics;
pub mod nrf52; pub mod nrf52;
pub mod serial;

View file

@ -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)*) => {};

View file

@ -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"));

View file

@ -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)

View file

@ -1,3 +1,5 @@
//! hi
#![no_std] #![no_std]
// #![deny(warnings)] // #![deny(warnings)]
#![feature(asm)] #![feature(asm)]

View file

@ -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 {

0
ableos/src/serial.rs Normal file
View file

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