Merge pull request 'ARM: Add serial console logging' (#9) from microtau/ableos:master into master
Reviewed-on: https://git.ablecorp.us/AbleOS/ableos/pulls/9
This commit is contained in:
commit
239ee43064
1154
Cargo.lock
generated
1154
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
23
kernel/src/arch/aarch64/logging.rs
Normal file
23
kernel/src/arch/aarch64/logging.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
use {core::fmt::Write, spin::Mutex};
|
||||
|
||||
const SERIAL_CONSOLE: Mutex<SerialConsole> = Mutex::new(SerialConsole {
|
||||
uart: 0x09000000 as *mut u8,
|
||||
});
|
||||
|
||||
struct SerialConsole {
|
||||
uart: *mut u8,
|
||||
}
|
||||
|
||||
impl core::fmt::Write for SerialConsole {
|
||||
fn write_str(&mut self, s: &str) -> core::fmt::Result {
|
||||
for c in s.chars() {
|
||||
unsafe { *self.uart = c as u8 }
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn log(args: core::fmt::Arguments<'_>) -> core::fmt::Result {
|
||||
SERIAL_CONSOLE.lock().write_fmt(args)
|
||||
}
|
|
@ -1,9 +1,15 @@
|
|||
use {core::arch::asm, limine::FramebufferRequest};
|
||||
|
||||
pub mod logging;
|
||||
pub use logging::log;
|
||||
|
||||
pub const PAGE_SIZE: usize = 4096;
|
||||
|
||||
#[no_mangle]
|
||||
unsafe extern "C" fn _kernel_start() -> ! {
|
||||
crate::logger::init().expect("failed to set logger");
|
||||
log::info!("Initialising AKern {}", crate::VERSION);
|
||||
|
||||
static FB_REQ: FramebufferRequest = FramebufferRequest::new(0);
|
||||
let fb1 = &FB_REQ.get_response().get().unwrap().framebuffers()[0];
|
||||
|
||||
|
@ -26,7 +32,3 @@ pub fn spin_loop() -> ! {
|
|||
pub fn hardware_random_u64() -> u64 {
|
||||
0
|
||||
}
|
||||
|
||||
pub fn log(_args: core::fmt::Arguments<'_>) -> core::fmt::Result {
|
||||
panic!()
|
||||
}
|
||||
|
|
|
@ -19,9 +19,7 @@ pub fn init() {
|
|||
pub fn log(args: core::fmt::Arguments<'_>) -> core::fmt::Result {
|
||||
x86_64::instructions::interrupts::without_interrupts(|| {
|
||||
// TERMINAL_LOGGER.lock().write_fmt(args)?;
|
||||
let mut sc = SERIAL_CONSOLE.lock();
|
||||
sc.write_fmt(args)?;
|
||||
Ok(())
|
||||
SERIAL_CONSOLE.lock().write_fmt(args)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -4,14 +4,9 @@ version = "0.2.0"
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
cpio_reader = "0.1" # remove me
|
||||
derive_more = "0.99"
|
||||
env_logger = "0.10"
|
||||
error-stack = "0.2"
|
||||
fatfs = "0.3"
|
||||
log = "0.4" # remove me
|
||||
rpm = "0.11" # remove me
|
||||
zstd = "0.12" # remove me
|
||||
|
||||
[dependencies.reqwest]
|
||||
version = "0.11"
|
||||
|
|
|
@ -71,25 +71,11 @@ fn main() -> Result<(), Error> {
|
|||
}
|
||||
|
||||
fn get_fs() -> Result<FileSystem<impl ReadWriteSeek>, io::Error> {
|
||||
let path = Path::new("target/disk.img");
|
||||
|
||||
match std::fs::metadata(path) {
|
||||
Err(e) if e.kind() == io::ErrorKind::NotFound => (),
|
||||
Err(e) => bail!(e),
|
||||
Ok(_) => {
|
||||
return FileSystem::new(
|
||||
File::options().read(true).write(true).open(path)?,
|
||||
FsOptions::new(),
|
||||
)
|
||||
.into_report()
|
||||
}
|
||||
}
|
||||
|
||||
let mut img = File::options()
|
||||
.read(true)
|
||||
.write(true)
|
||||
.create(true)
|
||||
.open(path)?;
|
||||
.open(Path::new("target/disk.img"))?;
|
||||
|
||||
img.set_len(1024 * 1024 * 64)?;
|
||||
|
||||
|
|
Loading…
Reference in a new issue