1use crate::drivers::GPU_DEVICE;
2use crate::mm::{MapArea, MapPermission, MapType, PhysAddr, VirtAddr};
3use crate::task::current_process;
4
5const FB_VADDR: usize = 0x10000000;
6
7pub fn sys_framebuffer() -> isize {
8 let fb = GPU_DEVICE.get_framebuffer();
9 let len = fb.len();
10 let fb_start_pa = PhysAddr::from(fb.as_ptr() as usize);
12 assert!(fb_start_pa.aligned());
13 let fb_start_ppn = fb_start_pa.floor();
14 let fb_start_vpn = VirtAddr::from(FB_VADDR).floor();
15 let pn_offset = fb_start_ppn.0 as isize - fb_start_vpn.0 as isize;
16
17 let current_process = current_process();
18 let mut inner = current_process.inner_exclusive_access();
19 inner.memory_set.push(
20 MapArea::new(
21 (FB_VADDR as usize).into(),
22 (FB_VADDR + len as usize).into(),
23 MapType::Linear(pn_offset),
24 MapPermission::R | MapPermission::W | MapPermission::U,
25 ),
26 None,
27 );
28 FB_VADDR as isize
29}
30
31pub fn sys_framebuffer_flush() -> isize {
32 GPU_DEVICE.flush();
33 0
34}