Extract some board-specfic constants

Signed-off-by: Harry Chen <i@harrychen.xyz>
master
Harry Chen 6 years ago
parent 26a5847a0a
commit 96caa80914

@ -0,0 +1,3 @@
/// board specific constants for malta
pub const MEMORY_END: usize = 0x8800_0000;
pub const KERNEL_HEAP_SIZE: usize = 0x00a0_0000;

@ -6,6 +6,7 @@ pub mod serial;
pub mod fb; pub mod fb;
#[path = "../../../../drivers/console/mod.rs"] #[path = "../../../../drivers/console/mod.rs"]
pub mod console; pub mod console;
pub mod consts;
/// Initialize serial port first /// Initialize serial port first
pub fn init_serial_early() { pub fn init_serial_early() {

@ -83,7 +83,7 @@ impl Write for SerialPort {
fn write<T>(addr: usize, content: T) { fn write<T>(addr: usize, content: T) {
let cell = (addr) as *mut T; let cell = (addr) as *mut T;
unsafe { write_volatile(cell, content) } unsafe { write_volatile(cell, content); }
} }
fn read<T>(addr: usize) -> T { fn read<T>(addr: usize) -> T {

@ -0,0 +1,3 @@
/// board specific constants for thinpad
pub const MEMORY_END: usize = 0x8080_0000;
pub const KERNEL_HEAP_SIZE: usize = 0x0020_0000;

@ -1,10 +1,14 @@
use once::*; use once::*;
use alloc::string::String;
pub mod serial; pub mod serial;
#[path = "../../../../drivers/gpu/fb.rs"] #[path = "../../../../drivers/gpu/fb.rs"]
pub mod fb; pub mod fb;
#[path = "../../../../drivers/console/mod.rs"] #[path = "../../../../drivers/console/mod.rs"]
pub mod console; pub mod console;
pub mod consts;
use fb::FramebufferInfo;
/// Initialize serial port first /// Initialize serial port first
pub fn init_serial_early() { pub fn init_serial_early() {
@ -31,6 +35,6 @@ pub fn probe_fb_info(width: u32, height: u32, depth: u32) -> Result<(Framebuffer
pitch: 800, pitch: 800,
bus_addr: 0xa2000000, bus_addr: 0xa2000000,
screen_size: 800 * 600, screen_size: 800 * 600,
} };
Ok((fb_info, 0xa2000000)) Ok((fb_info, 0xa2000000))
} }

@ -4,7 +4,7 @@ use core::fmt::{Write, Result, Arguments};
use core::ptr::{read_volatile, write_volatile}; use core::ptr::{read_volatile, write_volatile};
use spin::Mutex; use spin::Mutex;
struct SerialPort { pub struct SerialPort {
base: usize base: usize
} }
@ -27,7 +27,7 @@ impl SerialPort {
} }
/// non-blocking version of putchar() /// non-blocking version of putchar()
fn putchar(&mut self, c: u8) { pub fn putchar(&mut self, c: u8) {
write(self.base + UART_DATA, c); write(self.base + UART_DATA, c);
} }
@ -76,12 +76,12 @@ impl Write for SerialPort {
fn write<T>(addr: usize, content: T) { fn write<T>(addr: usize, content: T) {
let cell = (addr) as *mut T; let cell = (addr) as *mut T;
write_volatile(cell, content); unsafe { write_volatile(cell, content); }
} }
fn read<T>(addr: usize) -> T { fn read<T>(addr: usize) -> T {
let cell = (addr) as *const T; let cell = (addr) as *const T;
read_volatile(cell); unsafe { read_volatile(cell) }
} }

@ -4,7 +4,7 @@
OUTPUT_ARCH(riscv) OUTPUT_ARCH(riscv)
ENTRY(_start) ENTRY(_start)
BASE_ADDRESS = 0x80100000; BASE_ADDRESS = 0x80000000;
SECTIONS SECTIONS
{ {

@ -1,11 +1,11 @@
/// Platform specific constants /// Platform specific constants
///
pub const KERNEL_OFFSET: usize = 0x80100000; pub use super::board::consts::*;
pub const KERNEL_HEAP_SIZE: usize = 0x00a0_0000; pub const KERNEL_OFFSET: usize = 0x80000000;
pub const MEMORY_OFFSET: usize = 0x8000_0000; pub const MEMORY_OFFSET: usize = 0x8000_0000;
pub const MEMORY_END: usize = 0x8800_0000;
pub const USER_STACK_OFFSET: usize = 0x80000000 - USER_STACK_SIZE; pub const USER_STACK_OFFSET: usize = 0x80000000 - USER_STACK_SIZE;
pub const USER_STACK_SIZE: usize = 0x10000; pub const USER_STACK_SIZE: usize = 0x10000;

Loading…
Cancel
Save