various changes
This commit is contained in:
parent
27698842da
commit
cb8365abbd
1
ableos/src/arch/uefi_86/mod.rs
Normal file
1
ableos/src/arch/uefi_86/mod.rs
Normal file
|
@ -0,0 +1 @@
|
|||
|
|
@ -10,4 +10,7 @@ pub mod server;
|
|||
pub mod systeminfo;
|
||||
pub mod virtual_memory;
|
||||
pub mod y_compositor;
|
||||
|
||||
pub mod vterm;
|
||||
|
||||
pub const BANNER: &str = include_str!("banner.txt");
|
||||
|
|
39
ableos/src/experiments/vterm.rs
Normal file
39
ableos/src/experiments/vterm.rs
Normal file
|
@ -0,0 +1,39 @@
|
|||
use shadeable::pixel_format::Rgba64;
|
||||
|
||||
pub const VTERM_HEIGHT: u32 = 40;
|
||||
pub const VTERM_WIDTH: u32 = 100;
|
||||
/// Fg and bg colors for vterm
|
||||
pub type ColorCharacter = (Rgba64, Rgba64);
|
||||
|
||||
pub struct VtermCharacter {
|
||||
pub character: char,
|
||||
//
|
||||
pub fg: Rgba64,
|
||||
pub bg: Rgba64,
|
||||
//
|
||||
pub style: Style,
|
||||
}
|
||||
|
||||
pub struct Vterm {
|
||||
pub characters: [[VtermCharacter; VTERM_WIDTH as usize]; VTERM_HEIGHT as usize],
|
||||
pub cursor_x: u32,
|
||||
pub cursor_y: u32,
|
||||
pub cursor_visible: bool,
|
||||
}
|
||||
|
||||
pub struct Style {
|
||||
pub bold: bool,
|
||||
pub underline: bool,
|
||||
pub italic: bool,
|
||||
pub blink: bool,
|
||||
pub reverse: bool,
|
||||
pub strike: bool,
|
||||
}
|
||||
|
||||
pub struct StylePacked(u8);
|
||||
|
||||
impl StylePacked {
|
||||
pub fn new() -> Self {
|
||||
StylePacked(0)
|
||||
}
|
||||
}
|
|
@ -29,6 +29,7 @@ impl ScreenSize {
|
|||
pub enum GraphicsReturn {
|
||||
Ok,
|
||||
ImproperScreenSize,
|
||||
GenericError,
|
||||
}
|
||||
|
||||
pub struct ScreenBuffer {
|
||||
|
|
|
@ -38,8 +38,16 @@ lazy_static! {
|
|||
/// The main entry point of the kernel
|
||||
#[no_mangle]
|
||||
pub fn kernel_main() -> ! {
|
||||
/* init::init();
|
||||
log::set_max_level(BOOT_CONF.log_level());
|
||||
// init::init();
|
||||
|
||||
if (|| true)() || (|| false)() {
|
||||
()
|
||||
} else {
|
||||
((), ());
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
{
|
||||
{
|
||||
|
@ -75,8 +83,8 @@ pub fn kernel_main() -> ! {
|
|||
}
|
||||
}
|
||||
|
||||
start_facepalm();
|
||||
*/
|
||||
start_facepalm();
|
||||
sloop()
|
||||
}
|
||||
|
||||
|
@ -118,16 +126,147 @@ pub fn generate_process_pass() -> u128 {
|
|||
// #![no_main]
|
||||
// #![no_std]
|
||||
|
||||
use uefi::prelude::*;
|
||||
use uefi::ResultExt;
|
||||
use uefi::{
|
||||
prelude::*,
|
||||
proto::{
|
||||
console::gop::{GraphicsOutput, PixelFormat},
|
||||
media::{
|
||||
file::{File, FileAttribute, FileMode},
|
||||
fs::SimpleFileSystem,
|
||||
},
|
||||
},
|
||||
};
|
||||
use uefi::{proto::console::gop::FrameBuffer, ResultExt};
|
||||
|
||||
use crate::{GraphicsReturn, ScreenBuffer};
|
||||
|
||||
#[entry]
|
||||
fn main(_handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
|
||||
system_table
|
||||
.stdout()
|
||||
.reset(false)
|
||||
.expect_success("Failed to reset output buffer");
|
||||
uefi_services::init(&mut system_table).unwrap_success();
|
||||
// Print out UEFI revision number
|
||||
{
|
||||
let rev = system_table.uefi_revision();
|
||||
let (major, minor) = (rev.major(), rev.minor());
|
||||
|
||||
info!("UEFI {}.{}", major, minor);
|
||||
}
|
||||
|
||||
log_version_data();
|
||||
|
||||
kernel_main();
|
||||
info!("Running graphics output protocol test");
|
||||
if let Ok(gop) = system_table
|
||||
.boot_services()
|
||||
.locate_protocol::<GraphicsOutput>()
|
||||
{
|
||||
let gop = gop.expect("Warnings encountered while opening GOP");
|
||||
// Maybe save this
|
||||
let gop = unsafe { &mut *gop.get() };
|
||||
let mode = gop
|
||||
.modes()
|
||||
.map(|mode| mode.expect("Warnings encountered while querying mode"))
|
||||
.find(|mode| {
|
||||
let info = mode.info();
|
||||
info.resolution() == (1440, 900)
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
loop {}
|
||||
// Status::SUCCESS
|
||||
gop.set_mode(&mode)
|
||||
.expect_success("Failed to set graphics mode");
|
||||
|
||||
//crate::check_screenshot(bt, "gop_test");
|
||||
|
||||
draw_fb(gop);
|
||||
} else {
|
||||
// No tests can be run.
|
||||
warn!("UEFI Graphics Output Protocol is not supported");
|
||||
}
|
||||
|
||||
kernel_main();
|
||||
}
|
||||
|
||||
pub fn draw_fb(gop: &mut GraphicsOutput) {
|
||||
let mi = gop.current_mode_info();
|
||||
let stride = mi.stride();
|
||||
let (width, height) = mi.resolution();
|
||||
|
||||
let mut fb = gop.frame_buffer();
|
||||
|
||||
type PixelWriter = unsafe fn(&mut FrameBuffer, usize, [u8; 3]);
|
||||
unsafe fn write_pixel_rgb(fb: &mut FrameBuffer, pixel_base: usize, rgb: [u8; 3]) {
|
||||
fb.write_value(pixel_base, rgb);
|
||||
}
|
||||
unsafe fn write_pixel_bgr(fb: &mut FrameBuffer, pixel_base: usize, rgb: [u8; 3]) {
|
||||
fb.write_value(pixel_base, [rgb[2], rgb[1], rgb[0]]);
|
||||
}
|
||||
|
||||
let write_pixel: PixelWriter = match mi.pixel_format() {
|
||||
PixelFormat::Rgb => write_pixel_rgb,
|
||||
PixelFormat::Bgr => write_pixel_bgr,
|
||||
_ => {
|
||||
info!("This pixel format is not supported by the drawing demo");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let mut fill_rectangle = |(x1, y1), (x2, y2), color| {
|
||||
assert!((x1 < width) && (x2 < width), "Bad X coordinate");
|
||||
assert!((y1 < height) && (y2 < height), "Bad Y coordinate");
|
||||
for row in y1..y2 {
|
||||
for column in x1..x2 {
|
||||
unsafe {
|
||||
let pixel_index = (row * stride) + column;
|
||||
let pixel_base = 4 * pixel_index;
|
||||
write_pixel(&mut fb, pixel_base, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
fill_rectangle((50, 30), (150, 600), [123, 123, 123]);
|
||||
fill_rectangle((400, 120), (750, 450), [16, 0, 255]);
|
||||
fill_rectangle((80, 50), (200, 120), [0, 255, 0]);
|
||||
}
|
||||
|
||||
pub trait GopBuffer {
|
||||
fn copy_to_buffer(&self) -> GraphicsReturn;
|
||||
}
|
||||
|
||||
impl GopBuffer for ScreenBuffer {
|
||||
fn copy_to_buffer(&self) -> GraphicsReturn {
|
||||
GraphicsReturn::GenericError
|
||||
}
|
||||
}
|
||||
/*
|
||||
pub fn file_system() -> Result<SimpleFileSystem, Status> {
|
||||
if let Ok(gop) = system_table
|
||||
.boot_services()
|
||||
.locate_protocol::<SimpleFileSystem>()
|
||||
{
|
||||
let gop = gop.expect("Warnings encountered while opening GOP");
|
||||
// Maybe save this
|
||||
let gop = unsafe { &mut *gop.get() };
|
||||
let mut root = gop.open_volume().unwrap().expect("Failed to open volume");
|
||||
let attr = FileAttribute::all();
|
||||
|
||||
let xyz = root.open("test", FileMode::CreateReadWrite, attr).unwrap();
|
||||
let abcd = xyz.expect("Failed to open file").into_type();
|
||||
|
||||
let abcdef = abcd.unwrap().expect("Failed to open file");
|
||||
let mut buffer = [0u8; 10];
|
||||
match abcdef {
|
||||
uefi::proto::media::file::FileType::Regular(mut file) => {
|
||||
info!("{:?}", file.read(&mut buffer))
|
||||
}
|
||||
uefi::proto::media::file::FileType::Dir(_) => todo!(),
|
||||
}
|
||||
} else {
|
||||
// No tests can be run.
|
||||
warn!("UEFI Simple File System is not supported");
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
|
|
@ -13,9 +13,9 @@ pub const RELEASE_TYPE: &str = "debug";
|
|||
pub const RELEASE_TYPE: &str = "release";
|
||||
|
||||
pub fn start_facepalm() {
|
||||
info!("facepalm 🤦 launched!");
|
||||
info!("facepalm 🤦 version: {}", VERSION);
|
||||
info!("facepalm 🤦 {} mode", RELEASE_TYPE);
|
||||
|
||||
// info!("facepalm 🤦 launched!");
|
||||
// info!("facepalm 🤦 version: {}", VERSION);
|
||||
// info!("facepalm 🤦 {} mode", RELEASE_TYPE);
|
||||
info!("Latin 1 (ISO-8859-1)");
|
||||
// Drop into a debug shell
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue