Extract serial driver and add mipssim board for mipsel

Signed-off-by: Harry Chen <i@harrychen.xyz>
master
Harry Chen 6 years ago
parent 3d083eec0c
commit a2e98d73fd

2
kernel/Cargo.lock generated

@ -230,7 +230,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "mips" name = "mips"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/Harry-Chen/rust-mips#e2cea12fc88f1f5a788a155972cd4047e7ad2b4f" source = "git+https://github.com/Harry-Chen/rust-mips#bee9865920bceef12dbb527c1c237de905129c0b"
dependencies = [ dependencies = [
"bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",

@ -26,8 +26,9 @@ board_u540 = ["sv39", "link_user"]
nographic = [] nographic = []
board_raspi3 = ["bcm2837", "link_user"] board_raspi3 = ["bcm2837", "link_user"]
raspi3_use_generic_timer = ["bcm2837/use_generic_timer"] raspi3_use_generic_timer = ["bcm2837/use_generic_timer"]
# for mipsel qemu malta machine # for qemu machine
board_malta = ["link_user"] board_malta = ["link_user"]
board_mipssim = ["link_user"]
# for thinpad # for thinpad
board_thinpad = ["link_user"] board_thinpad = ["link_user"]
# Hard link user program # Hard link user program

@ -68,6 +68,11 @@ ifeq ($(arch), mipsel)
dtb := src/arch/$(arch)/board/$(board)/device.dtb dtb := src/arch/$(arch)/board/$(board)/device.dtb
endif endif
# mipssim does not support SMP
ifeq ($(board), mipssim)
smp := 1
endif
export ARCH = $(arch) export ARCH = $(arch)
export BOARD = $(board) export BOARD = $(board)
export SMP = $(smp) export SMP = $(smp)
@ -129,7 +134,7 @@ qemu_opts += \
-kernel $(kernel_img) -kernel $(kernel_img)
else ifeq ($(arch), mipsel) else ifeq ($(arch), mipsel)
ifeq ($(board), malta) ifeq ($(board), $(filter $(board), malta mipssim))
qemu_opts += \ qemu_opts += \
-machine $(board) \ -machine $(board) \
-serial mon:stdio \ -serial mon:stdio \

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

@ -1,6 +1,7 @@
use once::*; use once::*;
use alloc::string::String; use alloc::string::String;
#[path = "../../../../drivers/serial/16550_reg.rs"]
pub mod serial; pub mod serial;
#[path = "../../../../drivers/gpu/fb.rs"] #[path = "../../../../drivers/gpu/fb.rs"]
pub mod fb; pub mod fb;
@ -21,6 +22,6 @@ pub fn init_driver() {
// timer::init(); // timer::init();
} }
pub fn probe_fb_info(width: u32, height: u32, depth: u32) -> Result<(fb::FramebufferInfo, usize), String> { pub fn probe_fb_info(_width: u32, _height: u32, _depth: u32) -> Result<(fb::FramebufferInfo, usize), String> {
Err(String::from("Framebuffer not usable on malta board")) Err(String::from("Framebuffer not usable on malta board"))
} }

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

@ -0,0 +1,36 @@
/dts-v1/;
/ {
model = "qemu mipssim";
compatible = "qemu,mipssim";
#address-cells = <1>;
#size-cells = <1>;
chosen {
stdio = &uart0;
};
aliases { };
cpu_intc: interrupt-controller {
compatible = "mti,cpu-interrupt-controller";
interrupt-controller;
#interrupt-cells = <1>;
};
main_memory: memory@0 {
device_type = "memory";
reg = <0x00000000 0x10000000>;
};
uart0: serial@bfd003f8 {
compatible = "ns16550a";
reg = <0xbfd003f8 0x8>;
clock-frequency = <1843200>;
/* attached to the MIPS CPU INT2 pin, ie interrupt 4 */
interrupt-parent = <&cpu_intc>;
interrupts = <4>;
};
};

@ -0,0 +1,27 @@
use once::*;
use alloc::string::String;
#[path = "../../../../drivers/serial/16550_reg.rs"]
pub mod serial;
#[path = "../../../../drivers/gpu/fb.rs"]
pub mod fb;
#[path = "../../../../drivers/console/mod.rs"]
pub mod console;
pub mod consts;
/// Initialize serial port first
pub fn init_serial_early() {
assert_has_not_been_called!("board::init must be called only once");
serial::init(0xbfd003f8);
println!("Hello QEMU MIPSSIM!");
}
/// Initialize other board drivers
pub fn init_driver() {
// TODO: add possibly more drivers
// timer::init();
}
pub fn probe_fb_info(_width: u32, _height: u32, _depth: u32) -> Result<(fb::FramebufferInfo, usize), String> {
Err(String::from("Framebuffer not usable on mipssim board"))
}

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

@ -1,6 +1,7 @@
use once::*; use once::*;
use alloc::string::String; use alloc::string::String;
#[path = "../../../../drivers/serial/simple_uart.rs"]
pub mod serial; pub mod serial;
#[path = "../../../../drivers/gpu/fb.rs"] #[path = "../../../../drivers/gpu/fb.rs"]
pub mod fb; pub mod fb;

@ -22,6 +22,11 @@ pub mod board;
#[path = "board/thinpad/mod.rs"] #[path = "board/thinpad/mod.rs"]
pub mod board; pub mod board;
#[cfg(feature = "board_mipssim")]
#[path = "board/mipssim/mod.rs"]
pub mod board;
extern "C" { extern "C" {
fn _dtb_start(); fn _dtb_start();
fn _dtb_end(); fn _dtb_end();

Loading…
Cancel
Save