diff --git a/os/src/boards/qemu.rs b/os/src/boards/qemu.rs index 16dfb40..92d4f37 100644 --- a/os/src/boards/qemu.rs +++ b/os/src/boards/qemu.rs @@ -1,10 +1,10 @@ pub const CLOCK_FREQ: usize = 12500000; pub const MMIO: &[(usize, usize)] = &[ - (0x1000_0000, 0xa000), // VIRT_UART0 in virt machine - // (0x1000_1000, 0x9000), // VIRT_VIRTIO with GPU in virt machine - (0x0C00_0000, 0x40_0000), // VIRT_PLIC in virt machine - (0x0010_0000, 0x00_2000), // VIRT_TEST/RTC in virt machine +// (0x0010_0000, 0x00_2000), // VIRT_TEST/RTC in virt machine + (0x2000000, 0x10000), + (0xc000000, 0x210000), // VIRT_PLIC in virt machine + (0x10000000, 0x9000), // VIRT_UART0 with GPU in virt machine ]; pub type BlockDeviceImpl = crate::drivers::block::VirtIOBlock; diff --git a/os/src/config.rs b/os/src/config.rs index 41fe977..8f8b709 100644 --- a/os/src/config.rs +++ b/os/src/config.rs @@ -2,8 +2,8 @@ pub const USER_STACK_SIZE: usize = 4096 * 2; pub const KERNEL_STACK_SIZE: usize = 4096 * 2; -pub const KERNEL_HEAP_SIZE: usize = 0x20_0000; -pub const MEMORY_END: usize = 0x80800000; +pub const KERNEL_HEAP_SIZE: usize = 0x100_0000; +pub const MEMORY_END: usize = 0x88000000; pub const PAGE_SIZE: usize = 0x1000; pub const PAGE_SIZE_BITS: usize = 0xc; diff --git a/os/src/main.rs b/os/src/main.rs index ff6cf3a..e328e8e 100644 --- a/os/src/main.rs +++ b/os/src/main.rs @@ -32,6 +32,8 @@ mod task; mod timer; mod trap; +use syscall::create_desktop; + core::arch::global_asm!(include_str!("entry.asm")); fn clear_bss() { @@ -69,6 +71,7 @@ pub fn rust_main() -> ! { timer::set_next_trigger(); board::device_init(); fs::list_apps(); + syscall::create_desktop(); task::add_initproc(); *DEV_NON_BLOCKING_ACCESS.exclusive_access() = true; task::run_tasks(); diff --git a/os/src/syscall/gui.rs b/os/src/syscall/gui.rs index b5ac9fb..9ca7f45 100644 --- a/os/src/syscall/gui.rs +++ b/os/src/syscall/gui.rs @@ -1,7 +1,14 @@ -use alloc::{sync::Arc, vec::{Vec, }, string::ToString}; -use embedded_graphics::{prelude::{Point, Size}, primitives::arc}; +use alloc::{string::ToString, sync::Arc, vec::Vec}; +use embedded_graphics::{ + prelude::{Point, Size}, + primitives::arc, +}; -use crate::{gui::{Component, Panel, ImageComp, IconController, Terminal, Button}, fs::ROOT_INODE, sync::UPIntrFreeCell}; +use crate::{ + fs::ROOT_INODE, + gui::{Button, Component, IconController, ImageComp, Panel, Terminal}, + sync::UPIntrFreeCell, +}; static DT: &[u8] = include_bytes!("../assert/desktop.bmp"); @@ -15,8 +22,9 @@ lazy_static::lazy_static!( ); pub fn create_desktop() -> isize { - let mut p:Arc = Arc::new(Panel::new(Size::new(1024, 768), Point::new(0, 0))); - let image = ImageComp::new(Size::new(1024, 768),Point::new(0, 0),DT,Some(p.clone())); + let mut p: Arc = + Arc::new(Panel::new(Size::new(1024, 768), Point::new(0, 0))); + let image = ImageComp::new(Size::new(1024, 768), Point::new(0, 0), DT, Some(p.clone())); let icon = IconController::new(ROOT_INODE.ls(), Some(p.clone())); p.add(Arc::new(image)); p.add(Arc::new(icon)); @@ -30,17 +38,20 @@ pub fn create_desktop() -> isize { pub fn create_terminal() { let desktop = DESKTOP.exclusive_access(); - let arc_t = Arc::new( - Terminal::new( - Size::new(400, 400), - Point::new(200, 100), - Some(desktop.clone()), - Some("demo.txt".to_string()), - "".to_string() - ) - ); + let arc_t = Arc::new(Terminal::new( + Size::new(400, 400), + Point::new(200, 100), + Some(desktop.clone()), + Some("demo.txt".to_string()), + "".to_string(), + )); let text = Panel::new(Size::new(400, 400), Point::new(200, 100)); - let button = Button::new(Size::new(20, 20), Point::new(370, 10), Some(arc_t.clone()), "X".to_string()); + let button = Button::new( + Size::new(20, 20), + Point::new(370, 10), + Some(arc_t.clone()), + "X".to_string(), + ); arc_t.add(Arc::new(text)); arc_t.add(Arc::new(button)); arc_t.paint(); @@ -48,4 +59,3 @@ pub fn create_terminal() { let mut pad = PAD.exclusive_access(); *pad = Some(arc_t); } - diff --git a/os/src/syscall/mod.rs b/os/src/syscall/mod.rs index df2328a..46890ed 100644 --- a/os/src/syscall/mod.rs +++ b/os/src/syscall/mod.rs @@ -25,7 +25,7 @@ const SYSCALL_SEMAPHORE_DOWN: usize = 1022; const SYSCALL_CONDVAR_CREATE: usize = 1030; const SYSCALL_CONDVAR_SIGNAL: usize = 1031; const SYSCALL_CONDVAR_WAIT: usize = 1032; - +const SYSCALL_CREATE_DESKTOP: usize = 2000; mod fs; mod process; mod sync; @@ -37,6 +37,7 @@ use process::*; use sync::*; use thread::*; pub use gui::PAD; +pub use self::gui::create_desktop; pub fn syscall(syscall_id: usize, args: [usize; 3]) -> isize { match syscall_id { @@ -67,6 +68,7 @@ pub fn syscall(syscall_id: usize, args: [usize; 3]) -> isize { SYSCALL_CONDVAR_CREATE => sys_condvar_create(args[0]), SYSCALL_CONDVAR_SIGNAL => sys_condvar_signal(args[0]), SYSCALL_CONDVAR_WAIT => sys_condvar_wait(args[0], args[1]), + SYSCALL_CREATE_DESKTOP => create_desktop(), _ => panic!("Unsupported syscall_id: {}", syscall_id), } }