1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-22 16:16:16 +04:00

Get screen info from bootloader for vga

This commit is contained in:
Jiajie Chen 2019-05-24 16:20:25 +08:00
parent aefbecb127
commit e2bb86aa54
6 changed files with 109 additions and 83 deletions

10
kernel/Cargo.lock generated
View File

@ -16,11 +16,11 @@ dependencies = [
[[package]]
name = "apic"
version = "0.1.0"
source = "git+https://github.com/rcore-os/apic-rs#5ddc5fba952ae7420bcf3b7af3d79004e2b8c12f"
source = "git+https://github.com/rcore-os/apic-rs#3bc93873eaa4d21f09fc4134853d0a1ff917951b"
dependencies = [
"bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"x86 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"x86 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -88,7 +88,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "bootloader"
version = "0.4.0"
source = "git+https://github.com/rcore-os/bootloader?branch=vga#472731f974eb9cddbee030d5bda11fd1ee6959db"
source = "git+https://github.com/rcore-os/bootloader?branch=vga#861e0448eba3085d9af6b5b3c9454d5c8d59f82e"
dependencies = [
"apic 0.1.0 (git+https://github.com/rcore-os/apic-rs)",
"fixedvec 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -622,7 +622,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "x86"
version = "0.12.0"
version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
@ -760,7 +760,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770"
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
"checksum x86 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "841e1ca5a87068718a2a26f2473c6f93cf3b8119f9778fa0ae4b39b664d9e66a"
"checksum x86 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f21eecbd666e3a8edbf0b26d36f270f7a613d8986ca0eafb8205e324f7336dab"
"checksum x86_64 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f9258d7e2dd25008d69e8c9e9ee37865887a5e1e3d06a62f1cb3f6c209e6f177"
"checksum x86_64 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "bb8f09c32a991cc758ebcb9b7984f530095d32578a4e7b85db6ee1f0bbe4c9c6"
"checksum x86_64 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d69bf2d256c74df90fcc68aaf99862dd205310609e9d56247a5c82ead2f28a93"

View File

@ -3,29 +3,55 @@ pub mod fb;
use crate::consts::KERNEL_OFFSET;
use crate::memory::phys_to_virt;
use bootloader::bootinfo::{BootInfo, VbeModeInfo};
use core::mem::zeroed;
use fb::{ColorConfig, FramebufferInfo, FramebufferResult, FRAME_BUFFER};
pub fn init_driver() {
static mut VBE_MODE: VbeModeInfo = VbeModeInfo {
_1: [0; 6],
window_size: 0,
segment_a: 0,
segment_b: 0,
_2: 0,
pitch: 0,
width: 0,
height: 0,
_3: [0; 3],
bpp: 0,
_4: [0; 14],
framebuffer: 0,
};
pub fn init_driver(boot_info: &BootInfo) {
unsafe {
VBE_MODE = boot_info.vbe_info;
}
#[cfg(not(feature = "nographic"))]
fb::init();
}
pub fn probe_fb_info(width: u32, height: u32, depth: u32) -> FramebufferResult {
pub fn probe_fb_info(_width: u32, _height: u32, _depth: u32) -> FramebufferResult {
let width = unsafe { VBE_MODE.width as u32 };
let height = unsafe { VBE_MODE.height as u32 };
let pitch = unsafe { VBE_MODE.pitch as u32 };
let framebuffer = unsafe { VBE_MODE.framebuffer as usize };
let depth = unsafe { VBE_MODE.bpp as u32 };
let fb_info = FramebufferInfo {
xres: 1024,
yres: 768,
xres_virtual: 1024,
yres_virtual: 768,
xres: width,
yres: height,
xres_virtual: width,
yres_virtual: height,
xoffset: 0,
yoffset: 0,
depth: 24,
pitch: 1024, // TOKNOW
bus_addr: 0xfd00_0000,
screen_size: 1024 * 768 * 3,
depth: depth,
pitch: pitch, // TOKNOW
bus_addr: framebuffer as u32,
screen_size: width * height * 3,
};
// assume BGRA8888 for now
Ok((
fb_info,
fb::ColorConfig::BGRA8888,
phys_to_virt(0xfd00_0000),
phys_to_virt(framebuffer),
))
}

View File

@ -6,13 +6,13 @@ pub mod rtc_cmos;
pub mod serial;
pub mod vga;
use super::board;
use super::{board, BootInfo};
pub use self::board::fb;
#[path = "../../../drivers/console/mod.rs"]
pub mod console;
pub fn init() {
pub fn init(boot_info: &BootInfo) {
// Use IOAPIC instead of PIC
pic::disable();
@ -35,7 +35,7 @@ pub fn init() {
enable_irq(consts::PIRQG);
enable_irq(consts::PIRQH);
*/
board::init_driver();
board::init_driver(boot_info);
console::init();
//if let Some(con) = console::CONSOLE.lock().as_mut() {
//con.clear();

View File

@ -55,7 +55,7 @@ pub extern "C" fn _start(boot_info: &'static BootInfo) -> ! {
//get local apic id of cpu
cpu::init();
// Use IOAPIC instead of PIC, use APIC Timer instead of PIT, init serial&keyboard in x86_64
driver::init();
driver::init(boot_info);
// init pci/bus-based devices ,e.g. Intel 10Gb NIC, ...
crate::drivers::init();
// init cpu scheduler and process manager, and add user shell app in process manager

View File

@ -1,11 +1,11 @@
//! Framebuffer
use crate::fs::vga::{fb_bitfield, fb_var_screeninfo};
use alloc::string::String;
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)]

View File

@ -73,14 +73,14 @@ impl INode for Vga {
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)