pull/1/head
Able 2022-12-05 07:27:10 -06:00
parent dfbb9a3bce
commit ffd618cede
Signed by: able
GPG Key ID: 0BD8B45C30DCA887
1 changed files with 27 additions and 1 deletions

View File

@ -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,
}