1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-23 00:16:17 +04:00

Merge remote-tracking branch 'origin/mipsel' into dev

This commit is contained in:
Jiajie Chen 2019-05-06 10:58:27 +08:00
commit b2777032c8
10 changed files with 46 additions and 14 deletions

View File

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

View File

@ -21,6 +21,7 @@ pub fn init_serial_early() {
pub fn init_driver() {
// TODO: add possibly more drivers
// timer::init();
fb::init();
}
pub fn probe_fb_info(width: u32, height: u32, depth: u32) -> FramebufferResult {

View File

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

View File

@ -2,7 +2,7 @@
///
pub use super::board::consts::*;
pub const KERNEL_OFFSET: usize = 0x80100000;
pub const KERNEL_OFFSET: usize = 0x80000000;
pub const MEMORY_OFFSET: usize = 0x8000_0000;

View File

@ -11,4 +11,7 @@ pub mod console;
pub fn init() {
board::init_driver();
console::init();
if let Some(con) = console::CONSOLE.lock().as_mut() {
con.clear();
}
}

View File

@ -29,6 +29,9 @@ pub fn init() {
status.enable_soft_int1();
// Enable clock interrupt
status.enable_hard_int5();
// Enable serial interrupt
#[cfg(feature = "board_thinpad")]
status.enable_hard_int0();
cp0::status::write(status);
}
@ -209,6 +212,11 @@ fn reserved_inst(tf: &mut TrapFrame) -> bool {
let sel = (inst >> 6) & 0b111;
let format = inst & 0b111111;
if inst == 0x42000020 {
// ignore WAIT
return true;
}
if opcode == 0b011111 && format == 0b111011 {
// RDHWR
if rd == 29 && sel == 0 {

View File

@ -1,3 +1,3 @@
#[cfg(any(target_arch = "x86_64", target_arch = "mips"))]
#[cfg(any(target_arch = "x86_64", all(target_arch = "mips", feature = "board_malta")))]
pub mod pci;
pub mod virtio_mmio;

View File

@ -2,6 +2,7 @@
use crate::util::{read, write};
use core::fmt::{Arguments, Result, Write};
use spin::Mutex;
#[derive(Debug, Clone, Copy)]
pub struct SerialPort {
@ -15,6 +16,10 @@ const UART_STATUS_CTS: u8 = 0x1; // clear to send signal
const UART_STATUS_DR: u8 = 0x2; // data ready signal
impl SerialPort {
fn new() -> SerialPort {
SerialPort { base: 0 }
}
pub fn init(&mut self, base: usize) {
self.base = base;
}
@ -49,12 +54,6 @@ impl SerialPort {
pub fn putfmt(&mut self, fmt: Arguments) {
self.write_fmt(fmt).unwrap();
}
pub fn lock(&self) -> SerialPort {
self.clone()
}
pub fn force_unlock(&self) {}
}
impl Write for SerialPort {
@ -72,7 +71,10 @@ impl Write for SerialPort {
}
}
pub static SERIAL_PORT: SerialPort = SerialPort { base: 0 };
// pub static SERIAL_PORT: SerialPort = SerialPort { base: 0xa3000000 };
lazy_static! {
pub static ref SERIAL_PORT: Mutex<SerialPort> = Mutex::new(SerialPort::new());
}
pub fn init(base: usize) {
SERIAL_PORT.lock().init(base);

View File

@ -13,6 +13,7 @@
//! mipssim/malta(MIPS) -- 10MB
use super::HEAP_ALLOCATOR;
use core::mem;
pub use crate::arch::paging::*;
use crate::consts::{KERNEL_OFFSET, MEMORY_OFFSET};
use crate::sync::SpinNoIrqLock;
@ -138,11 +139,13 @@ pub fn handle_page_fault(addr: usize) -> bool {
pub fn init_heap() {
use crate::consts::KERNEL_HEAP_SIZE;
static mut HEAP: [u8; KERNEL_HEAP_SIZE] = [0; KERNEL_HEAP_SIZE];
const machine_align: usize = mem::size_of::<usize>();
const heap_block: usize = KERNEL_HEAP_SIZE / machine_align;
static mut HEAP: [usize; heap_block] = [0; heap_block];
unsafe {
HEAP_ALLOCATOR
.lock()
.init(HEAP.as_ptr() as usize, KERNEL_HEAP_SIZE);
.init(HEAP.as_ptr() as usize, heap_block * machine_align);
}
info!("heap init end");
}

View File

@ -6,7 +6,7 @@ use crate::process::*;
use alloc::string::String;
use alloc::vec::Vec;
#[cfg(not(feature = "run_cmdline"))]
#[cfg(not(any(feature = "run_cmdline", feature = "board_thinpad")))]
pub fn add_user_shell() {
// the busybox of alpine linux can not transfer env vars into child process
// Now we use busybox from
@ -38,6 +38,21 @@ pub fn add_user_shell() {
}
}
#[cfg(feature = "board_thinpad")]
pub fn run_user_shell() {
if let Ok(inode) = ROOT_INODE.lookup("sh") {
let data = inode.read_as_vec().unwrap();
processor().manager().add(Thread::new_user(
data.as_slice(),
"sh",
vec!["sh".into()],
Vec::new(),
));
} else {
processor().manager().add(Thread::new_kernel(shell, 0));
}
}
#[cfg(feature = "run_cmdline")]
pub fn add_user_shell() {
use crate::drivers::CMDLINE;