forked from AbleOS/ableos_userland
update
This commit is contained in:
parent
f5835bab57
commit
693d861a4e
|
@ -1,6 +1,8 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use core::ptr;
|
||||
|
||||
use able_graphics_library::display::parse_display_string;
|
||||
|
||||
const VGA_ADDRESS: *mut u8 = 0xB8000 as *mut u8;
|
||||
|
@ -10,7 +12,7 @@ fn start() {
|
|||
// TODO: Initialize the VGA hardware and configure it to the desired video mode
|
||||
// (e.g. 640x480, 800x600, etc.).
|
||||
|
||||
let result = parse_display_string("680x480x32@60");
|
||||
let result = parse_display_string("680x480x16@60");
|
||||
use able_graphics_library::display::DisplayError::*;
|
||||
match result {
|
||||
Ok(display) => {
|
||||
|
@ -90,4 +92,28 @@ impl<'a> VGAState<'a> {
|
|||
self.set_vga_mode(self.mode)
|
||||
// initalize the graphics lib to be usable
|
||||
}
|
||||
unsafe fn set_register(address: u16, value: u8) -> Result<(), VGAError> {
|
||||
let address_ptr = address as *mut u8;
|
||||
let value_ptr = value as u8;
|
||||
|
||||
// TODO: check if this works
|
||||
ptr::write_volatile(address_ptr, value_ptr);
|
||||
let read_value = Self::read_register(address);
|
||||
if read_value != value {
|
||||
return Err(VGAError::WrittenValueNotReadValue);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
unsafe fn read_register(address: u16) -> u8 {
|
||||
let address_ptr = address as *mut u8;
|
||||
|
||||
ptr::read_volatile(address_ptr)
|
||||
}
|
||||
}
|
||||
|
||||
pub enum VgaRegister {}
|
||||
|
||||
pub enum VGAError {
|
||||
/// The value written is not the same as the value read
|
||||
WrittenValueNotReadValue,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue