diff --git a/kernel/src/arch/x86_64/driver/mod.rs b/kernel/src/arch/x86_64/driver/mod.rs index e0ca105..85a8fb9 100644 --- a/kernel/src/arch/x86_64/driver/mod.rs +++ b/kernel/src/arch/x86_64/driver/mod.rs @@ -37,7 +37,7 @@ pub fn init() { */ board::init_driver(); console::init(); - if let Some(con) = console::CONSOLE.lock().as_mut() { - con.clear(); - } + //if let Some(con) = console::CONSOLE.lock().as_mut() { + //con.clear(); + //} } diff --git a/kernel/src/drivers/gpu/fb.rs b/kernel/src/drivers/gpu/fb.rs index 136c581..7277b86 100644 --- a/kernel/src/drivers/gpu/fb.rs +++ b/kernel/src/drivers/gpu/fb.rs @@ -5,6 +5,7 @@ use core::fmt; use lazy_static::lazy_static; use log::*; use spin::Mutex; +use crate::fs::vga::{fb_var_screeninfo, fb_bitfield}; /// Framebuffer information #[repr(C)] @@ -237,6 +238,16 @@ impl Framebuffer { pub fn clear(&mut self) { self.fill(0, self.fb_info.screen_size as usize, 0); } + + pub fn fill_var_screeninfo(&self, var_info : &mut fb_var_screeninfo) { + var_info.xres = self.fb_info.xres; + var_info.yres = self.fb_info.yres; + var_info.xres_virtual = self.fb_info.xres_virtual; + var_info.yres_virtual = self.fb_info.yres_virtual; + var_info.xoffset = self.fb_info.xoffset; + var_info.yoffset = self.fb_info.yoffset; + var_info.bits_per_pixel = self.fb_info.depth; + } } lazy_static! { diff --git a/kernel/src/fs/mod.rs b/kernel/src/fs/mod.rs index 240d030..99fe306 100644 --- a/kernel/src/fs/mod.rs +++ b/kernel/src/fs/mod.rs @@ -20,7 +20,7 @@ mod ioctl; mod pipe; mod pseudo; mod stdio; -mod vga; +pub mod vga; // Hard link user programs #[cfg(feature = "link_user")] diff --git a/kernel/src/fs/vga.rs b/kernel/src/fs/vga.rs index 3c40e42..42d4d56 100755 --- a/kernel/src/fs/vga.rs +++ b/kernel/src/fs/vga.rs @@ -20,7 +20,6 @@ macro_rules! impl_inode { fn move_(&self, _old_name: &str, _target: &Arc, _new_name: &str) -> Result<()> { Err(FsError::NotDir) } fn find(&self, _name: &str) -> Result> { Err(FsError::NotDir) } fn get_entry(&self, _id: usize) -> Result { Err(FsError::NotDir) } - fn io_control(&self, cmd: u32, data: usize) -> Result<()> { Err(FsError::NotSupported) } fn fs(&self) -> Arc { unimplemented!() } fn as_any_ref(&self) -> &Any { self } }; @@ -67,5 +66,102 @@ impl INode for Vga { gid: 0, }) } + fn io_control(&self, cmd: u32, data: usize) -> Result<()> { + info!("cmd {:#x} , data {:#x} vga not support ioctl !", cmd, data); + match cmd { + FBIOGET_FSCREENINFO => { + let fb_fix_info = unsafe{ &mut *(data as *mut fb_fix_screeninfo) }; + fb_fix_info.line_length = 100; + Ok(()) + }, + FBIOGET_VSCREENINFO => { + let fb_var_info = unsafe{ &mut *(data as *mut fb_var_screeninfo) }; + if let Some(fb) = FRAME_BUFFER.lock().as_ref() { + fb.fill_var_screeninfo(fb_var_info); + } + Ok(()) + }, + _ => { + warn!("use never support ioctl !"); + Err(FsError::NotSupported) + } + } + //let fb_fix_info = unsafe{ &mut *(data as *mut fb_fix_screeninfo) }; + //Ok(()) + } impl_inode!(); } + +const FBIOGET_FSCREENINFO : u32 = 0x4602; +const FBIOGET_VSCREENINFO : u32 = 0x4600; + +#[repr(C)] +struct fb_fix_screeninfo { + pub id : [u8;16], /* identification string eg "TT Builtin" */ + pub smem_start : u64, /* Start of frame buffer mem */ + /* (physical address) */ + pub smem_len : u32, /* Length of frame buffer mem */ + pub _type : u32, /* see FB_TYPE_* */ + pub type_aux : u32, /* Interleave for interleaved Planes */ + pub visual : u32, /* see FB_VISUAL_* */ + pub xpanstep : u16, /* zero if no hardware panning */ + pub ypanstep : u16, /* zero if no hardware panning */ + pub ywrapstep : u16, /* zero if no hardware ywrap */ + pub line_length : u32, /* length of a line in bytes */ + pub mmio_start : u64, /* Start of Memory Mapped I/O */ + /* (physical address) */ + pub mmio_len : u32, /* Length of Memory Mapped I/O */ + pub accel : u32, /* Indicate to driver which */ + /* specific chip/card we have */ + pub capabilities : u16, /* see FB_CAP_* */ + pub reserved : [u16;2], /* Reserved for future compatibility */ +} + +#[repr(C)] +pub struct fb_var_screeninfo { + pub xres : u32, /* visible resolution */ + pub yres : u32, + pub xres_virtual : u32, /* virtual resolution */ + pub yres_virtual : u32, + pub xoffset : u32, /* offset from virtual to visible */ + pub yoffset : u32, /* resolution */ + + pub bits_per_pixel : u32, /* guess what */ + pub grayscale : u32, /* 0 = color, 1 = grayscale, */ + /* >1 = FOURCC */ + pub red : fb_bitfield , /* bitfield in fb mem if true color, */ + pub green : fb_bitfield , /* else only length is significant */ + pub blue : fb_bitfield , + pub transp : fb_bitfield , /* transparency */ + + pub nonstd : u32, /* != 0 Non standard pixel format */ + + pub activate : u32, /* see FB_ACTIVATE_* */ + + pub height : u32, /* height of picture in mm */ + pub width : u32, /* width of picture in mm */ + + pub accel_flags : u32, /* (OBSOLETE) see fb_info.flags */ + + /* Timing: All values in pixclocks, except pixclock (of course) */ + pub pixclock : u32, /* pixel clock in ps (pico seconds) */ + pub left_margin : u32, /* time from sync to picture */ + pub right_margin : u32, /* time from picture to sync */ + pub upper_margin : u32, /* time from sync to picture */ + pub lower_margin : u32, + pub hsync_len : u32, /* length of horizontal sync */ + pub vsync_len : u32, /* length of vertical sync */ + pub sync : u32, /* see FB_SYNC_* */ + pub vmode : u32, /* see FB_VMODE_* */ + pub rotate : u32, /* angle we rotate counter clockwise */ + pub colorspace : u32, /* colorspace for FOURCC-based modes */ + pub reserved : [u32;4], /* Reserved for future compatibility */ +} + +#[repr(C)] +pub struct fb_bitfield { + pub offset : u32, /* beginning of bitfield */ + pub length : u32, /* length of bitfield */ + pub msb_right : u32, /* != 0 : Most significant bit is */ + /* right */ +}