fix mmap for framebuffer

master
PanQL 6 years ago
parent f8c88baeea
commit a6f211cef5

@ -19,7 +19,7 @@ pub fn probe_fb_info(width : u32, height : u32, depth : u32) -> FramebufferResul
yoffset: 0, yoffset: 0,
depth: 24, depth: 24,
pitch: 1024, // TOKNOW pitch: 1024, // TOKNOW
bus_addr: 0xf000_0000, bus_addr: 0xfd00_0000,
screen_size: 1024 * 768 * 3, screen_size: 1024 * 768 * 3,
}; };
Ok((fb_info, fb::ColorConfig::BGRA8888, KERNEL_OFFSET + 0xf000_0000)) Ok((fb_info, fb::ColorConfig::BGRA8888, KERNEL_OFFSET + 0xf000_0000))

@ -172,6 +172,11 @@ impl Framebuffer {
unsafe { self.buf.base_addr } unsafe { self.buf.base_addr }
} }
#[inline]
pub fn bus_addr(&self) -> usize {
self.fb_info.bus_addr as usize
}
/// Read pixel at `(x, y)`. /// Read pixel at `(x, y)`.
#[inline] #[inline]
pub fn read(&self, x: u32, y: u32) -> u32 { pub fn read(&self, x: u32, y: u32) -> u32 {

@ -58,16 +58,19 @@ impl Syscall<'_> {
info!("mmap path is {} ", &*file.path); info!("mmap path is {} ", &*file.path);
match &*file.path { match &*file.path {
"/dev/fb0" => { "/dev/fb0" => {
self.vm().push( use crate::arch::board::fb::FRAME_BUFFER;
addr, if let Some(fb) = FRAME_BUFFER.lock().as_mut() {
addr + len, self.vm().push(
prot.to_attr(), addr,
Linear::new( addr + len,
( 0xfd00_0000 - addr ) as isize, prot.to_attr(),
), Linear::new(
"mmap_file", ( fb.bus_addr() - addr ) as isize,
); ),
info!("mmap for /dev/fb0"); "mmap_file",
);
info!("mmap for /dev/fb0");
}
return Ok(addr); return Ok(addr);
}, },
_ => { _ => {

Loading…
Cancel
Save