Hacky debug output
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
.macro ADR_REL reg, sym
|
||||
adrp \reg, \sym
|
||||
add \reg, \reg, #:lo12:\sym
|
||||
.endm
|
||||
|
||||
.section .text._entry
|
||||
.global _entry
|
||||
_entry:
|
||||
mrs x1, mpidr_el1
|
||||
and x1, x1, #3
|
||||
beq 2f
|
||||
1:
|
||||
wfe
|
||||
b 1b
|
||||
|
||||
2:
|
||||
|
||||
// Zero .bss
|
||||
ADR_REL x0, __bss_start
|
||||
ADR_REL x1, __bss_end
|
||||
1:
|
||||
cmp x0, x1
|
||||
beq 2f
|
||||
stp xzr, xzr, [x0], #16
|
||||
b 1b
|
||||
2:
|
||||
|
||||
ADR_REL x0, bsp_stack_top
|
||||
mov sp, x0
|
||||
|
||||
b __aa64_bsp_main
|
||||
|
||||
.section .bss
|
||||
.p2align 4
|
||||
bsp_stack_bottom:
|
||||
.skip 16384
|
||||
bsp_stack_top:
|
||||
@@ -0,0 +1,11 @@
|
||||
use cortex_a::asm;
|
||||
|
||||
#[no_mangle]
|
||||
fn __aa64_bsp_main() {
|
||||
debugln!("Test");
|
||||
loop {
|
||||
asm::wfe();
|
||||
}
|
||||
}
|
||||
|
||||
global_asm!(include_str!("entry.S"));
|
||||
@@ -0,0 +1 @@
|
||||
pub mod boot;
|
||||
@@ -0,0 +1,7 @@
|
||||
cfg_if! {
|
||||
if #[cfg(target_arch = "aarch64")] {
|
||||
pub mod aarch64;
|
||||
|
||||
pub use aarch64 as platform;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
use core::fmt;
|
||||
|
||||
struct Output;
|
||||
|
||||
impl fmt::Write for Output {
|
||||
fn write_str(&mut self, s: &str) -> fmt::Result {
|
||||
for &byte in s.as_bytes() {
|
||||
// XXX
|
||||
unsafe {
|
||||
core::ptr::write_volatile(0x09000000 as *mut u32, byte as u32);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! debug {
|
||||
($($it:tt)+) => ($crate::debug::_debug(format_args!($($it)+)))
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! debugln {
|
||||
($($it:tt)+) => (debug!("{}\n", format_args!($($it)+)))
|
||||
}
|
||||
|
||||
pub fn _debug(args: fmt::Arguments) {
|
||||
use fmt::Write;
|
||||
drop(Output {}.write_fmt(args));
|
||||
}
|
||||
+8
-17
@@ -3,24 +3,15 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
#[macro_use]
|
||||
extern crate cfg_if;
|
||||
|
||||
#[macro_use]
|
||||
pub mod debug;
|
||||
pub mod arch;
|
||||
pub mod mem;
|
||||
|
||||
#[panic_handler]
|
||||
fn panic_handler(_pi: &PanicInfo) -> ! {
|
||||
fn panic_handler(_pi: &core::panic::PanicInfo) -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
global_asm!(r#"
|
||||
.section .text._entry
|
||||
.global _entry
|
||||
_entry:
|
||||
mrs x1, mpidr_el1
|
||||
and x1, x1, #3
|
||||
beq 2f
|
||||
1:
|
||||
wfe
|
||||
b 1b
|
||||
|
||||
2:
|
||||
b .
|
||||
"#);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn memcpy(dst: *mut u8, src: *mut u8, mut len: usize) -> *mut u8 {
|
||||
while len != 0 {
|
||||
len -= 1;
|
||||
*dst.add(len) = *src.add(len);
|
||||
}
|
||||
dst
|
||||
}
|
||||
Reference in New Issue
Block a user