diff --git a/kernel/src/fs/vga.rs b/kernel/src/fs/vga.rs index bea4ae6..d5909af 100755 --- a/kernel/src/fs/vga.rs +++ b/kernel/src/fs/vga.rs @@ -31,19 +31,6 @@ impl INode for Vga { } fn write_at(&self, _offset: usize, _buf: &[u8]) -> Result { info!("the _offset is {} {}", _offset, _buf[0]); - //let mut result : usize = 0; - //if let Some(fb) = FRAME_BUFFER.lock().as_mut() { - //for x in 0..1024 { // TODO, should not use CONSTS - //for y in 0..768 { - //let blue = _buf[3 * (x * 768 + y)]; - //let green = _buf[3 * (x * 768 + y) + 1]; - //let red = _buf[3 * (x * 768 + y) + 2]; - //let pixel : u32 = ((blue as u32) << 16) | ((green as u32) << 8) | (red as u32); - //fb.write(x as u32, y as u32, pixel); - //result += 3; - //} - //} - //} use crate::consts::KERNEL_OFFSET; use core::slice; let frame_buffer_data = diff --git a/kernel/src/syscall/mem.rs b/kernel/src/syscall/mem.rs index 3a3d4a8..66817c1 100644 --- a/kernel/src/syscall/mem.rs +++ b/kernel/src/syscall/mem.rs @@ -1,4 +1,4 @@ -use rcore_memory::memory_set::handler::{Delay, File}; +use rcore_memory::memory_set::handler::{Delay, File, Linear}; use rcore_memory::memory_set::MemoryAttr; use rcore_memory::paging::PageTable; use rcore_memory::Page; @@ -53,21 +53,41 @@ impl Syscall<'_> { ); return Ok(addr); } else { - let inode = proc.get_file(fd)?.inode(); - self.vm().push( - addr, - addr + len, - prot.to_attr(), - File { - file: INodeForMap(inode), - mem_start: addr, - file_start: offset, - file_end: offset + len, - allocator: GlobalFrameAlloc, + + let file = proc.get_file(fd)?; + info!("mmap path is {} ", &*file.path); + match &*file.path { + "/dev/fb0" => { + self.vm().push( + addr, + addr + len, + prot.to_attr(), + Linear::new( + ( 0xfd00_0000 - addr ) as isize, + ), + "mmap_file", + ); + info!("mmap for /dev/fb0"); + return Ok(addr); }, - "mmap_file", - ); - return Ok(addr); + _ => { + let inode = file.inode(); + self.vm().push( + addr, + addr + len, + prot.to_attr(), + File { + file: INodeForMap(inode), + mem_start: addr, + file_start: offset, + file_end: offset + len, + allocator: GlobalFrameAlloc, + }, + "mmap_file", + ); + return Ok(addr); + }, + }; } }