-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09671fa
commit a32ebfc
Showing
15 changed files
with
99 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use crate::kernel::syscalls::*; | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn syscall(sys_num: i32, sys_arg: u8) { | ||
match sys_num { | ||
64 => sys_write(sys_arg), | ||
_ => return, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,6 @@ pub trait Device { | |
fn name(&mut self) -> &'static str { | ||
return "None"; | ||
} | ||
|
||
const UART0: usize = 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use super::board::Board; | ||
use super::uart::Uart; | ||
use crate::kernel::device::Device; | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn sys_write(write: u8) { | ||
let mut uart = Uart::new(Board::UART0); | ||
|
||
uart.write_byte(write); | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn sys_read() -> u8 { | ||
let mut uart = Uart::new(Board::UART0); | ||
|
||
return uart.read(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use core::alloc::{GlobalAlloc, Layout}; | ||
use core::ptr::null_mut; | ||
use crate::riscv_printk; | ||
|
||
pub struct Allocator; | ||
|
||
#[global_allocator] | ||
pub static GLOBAL_ALLOCATOR: Allocator = Allocator; | ||
|
||
unsafe impl GlobalAlloc for Allocator { | ||
unsafe fn alloc(&self, _layout: Layout) -> *mut u8 { | ||
null_mut() | ||
} | ||
|
||
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) { | ||
loop { } | ||
} | ||
} | ||
|
||
#[alloc_error_handler] | ||
unsafe fn alloc_error(_layout: Layout) -> ! { | ||
riscv_printk!("Alloc memory layout:"); | ||
riscv_printk!(" {:?}", _layout); | ||
panic!("Alloc memory error"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod alloc; | ||
pub mod bss; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters