diff --git a/kernel/src/arch/x86_64/board/mod.rs b/kernel/src/arch/x86_64/board/mod.rs index ccd85d9..b6da4ce 100755 --- a/kernel/src/arch/x86_64/board/mod.rs +++ b/kernel/src/arch/x86_64/board/mod.rs @@ -19,7 +19,7 @@ pub fn probe_fb_info(width : u32, height : u32, depth : u32) -> FramebufferResul yoffset: 0, depth: 24, pitch: 1024, // TOKNOW - bus_addr: 0xf000_0000, + bus_addr: 0xfd00_0000, screen_size: 1024 * 768 * 3, }; Ok((fb_info, fb::ColorConfig::BGRA8888, KERNEL_OFFSET + 0xf000_0000)) diff --git a/kernel/src/drivers/gpu/fb.rs b/kernel/src/drivers/gpu/fb.rs index 3d3f9df..45b74c0 100644 --- a/kernel/src/drivers/gpu/fb.rs +++ b/kernel/src/drivers/gpu/fb.rs @@ -172,6 +172,11 @@ impl Framebuffer { unsafe { self.buf.base_addr } } + #[inline] + pub fn bus_addr(&self) -> usize { + self.fb_info.bus_addr as usize + } + /// Read pixel at `(x, y)`. #[inline] pub fn read(&self, x: u32, y: u32) -> u32 { diff --git a/kernel/src/syscall/mem.rs b/kernel/src/syscall/mem.rs index 66817c1..44ac35f 100644 --- a/kernel/src/syscall/mem.rs +++ b/kernel/src/syscall/mem.rs @@ -58,16 +58,19 @@ impl Syscall<'_> { 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"); + use crate::arch::board::fb::FRAME_BUFFER; + if let Some(fb) = FRAME_BUFFER.lock().as_mut() { + self.vm().push( + addr, + addr + len, + prot.to_attr(), + Linear::new( + ( fb.bus_addr() - addr ) as isize, + ), + "mmap_file", + ); + info!("mmap for /dev/fb0"); + } return Ok(addr); }, _ => {