Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
buhe committed Oct 28, 2021
1 parent d2edc48 commit b5d7e80
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion os/src/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use core::fmt::{self, Write};

use crate::{driver::print_with_lcd, scall_sbi::put_char};

struct STDOUT;
pub struct STDOUT;

impl Write for STDOUT {
fn write_str(&mut self, s: &str) -> core::fmt::Result {
Expand Down
5 changes: 3 additions & 2 deletions os/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ fn clear_bss() {

#[no_mangle]
extern "C" fn rust_main(_hartid: usize, device_tree_paddr: usize) -> ! {
println!("{}", logo::LOGO);
// println!("hart id is {}", hartid);
// println!("dtb addr is 0x{:x}", device_tree_paddr);
#[repr(C)]
Expand All @@ -63,9 +62,11 @@ extern "C" fn rust_main(_hartid: usize, device_tree_paddr: usize) -> ! {

clear_bss();
heap::init();
driver::init();
mmu::init();
trap::init();
driver::init();

println!("{}", logo::LOGO);
#[cfg(test)]
test_main();

Expand Down
20 changes: 11 additions & 9 deletions os/src/mmu/memory_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use super::{PTEFlags, PageTable, PageTableEntry};
use super::{PhysAddr, PhysPageNum, VirtAddr, VirtPageNum};
use super::{StepByOne, VPNRange};
use crate::config::{MEMORY_END, MMIO, PAGE_SIZE, TRAMPOLINE, TRAP_CONTEXT, USER_STACK_SIZE};
use core::fmt::{self, Write};
use crate::console::STDOUT;
use alloc::collections::BTreeMap;
use alloc::sync::Arc;
use alloc::vec::Vec;
Expand Down Expand Up @@ -76,14 +78,14 @@ impl MemorySet {
// map trampoline
memory_set.map_trampoline();
// map kernel sections
println!(".text [{:#x}, {:#x})", stext as usize, etext as usize);
println!(".rodata [{:#x}, {:#x})", srodata as usize, erodata as usize);
println!(".data [{:#x}, {:#x})", sdata as usize, edata as usize);
println!(
writeln!(STDOUT, ".text [{:#x}, {:#x})", stext as usize, etext as usize);
writeln!(STDOUT, ".rodata [{:#x}, {:#x})", srodata as usize, erodata as usize);
writeln!(STDOUT, ".data [{:#x}, {:#x})", sdata as usize, edata as usize);
writeln!(STDOUT,
".bss [{:#x}, {:#x})",
sbss_with_stack as usize, ebss as usize
);
println!("mapping .text section");
writeln!(STDOUT, "mapping .text section");
memory_set.push(
MapArea::new(
(stext as usize).into(),
Expand All @@ -93,7 +95,7 @@ impl MemorySet {
),
None,
);
println!("mapping .rodata section");
writeln!(STDOUT, "mapping .rodata section");
memory_set.push(
MapArea::new(
(srodata as usize).into(),
Expand All @@ -103,7 +105,7 @@ impl MemorySet {
),
None,
);
println!("mapping .data section");
writeln!(STDOUT, "mapping .data section");
memory_set.push(
MapArea::new(
(sdata as usize).into(),
Expand All @@ -113,7 +115,7 @@ impl MemorySet {
),
None,
);
println!("mapping .bss section");
writeln!(STDOUT, "mapping .bss section");
memory_set.push(
MapArea::new(
(sbss_with_stack as usize).into(),
Expand All @@ -123,7 +125,7 @@ impl MemorySet {
),
None,
);
println!("mapping physical memory");
writeln!(STDOUT, "mapping physical memory");
memory_set.push(
MapArea::new(
(ekernel as usize).into(),
Expand Down

0 comments on commit b5d7e80

Please sign in to comment.