work on moving the uefi into its own subcrate

This commit is contained in:
Able 2022-02-05 01:32:58 -06:00
parent 7785de8fd9
commit 04374aa905
8 changed files with 189 additions and 184 deletions

View file

@ -0,0 +1 @@
pub fn init() {}

View file

@ -1 +1,9 @@
pub mod init;
pub fn shutdown() {
loop {}
}
pub fn sloop() -> ! {
loop {}
}

View file

@ -1,6 +1,6 @@
#![allow(dead_code)]
pub mod absi;
// pub mod absi;
pub mod clip;
pub mod futex;
pub mod info;

View file

@ -145,14 +145,20 @@ impl Default for Vterm {
}
impl Vterm {
pub fn new() -> Self {
Vterm::default()
}
/// Set the vterm cursor to the given position
pub fn set_cursor_position(&mut self, x: u32, y: u32) {
if x > VTERM_WIDTH {
self.cursor_position.0 = VTERM_WIDTH;
error!("Cursor x position out of bounds");
} else {
self.cursor_position.0 = x;
}
if y > VTERM_HEIGHT {
error!("Cursor y position out of bounds");
self.cursor_position.1 = VTERM_HEIGHT;
} else {
self.cursor_position.1 = y;

View file

@ -15,7 +15,8 @@ use {
file::PathRep,
relib::network::socket::{SimpleSock, Socket},
scheduler::SCHEDULER,
VgaBuffer, SCREEN_BUFFER,
// VgaBuffer,
SCREEN_BUFFER,
},
alloc::{
format,
@ -26,8 +27,6 @@ use {
facepalm::start_facepalm,
lazy_static::lazy_static,
log::*,
shadeable::pixel_format::from_vga_16,
vga::colors::Color16,
};
lazy_static! {
@ -39,51 +38,19 @@ lazy_static! {
#[no_mangle]
pub fn kernel_main() -> ! {
log::set_max_level(BOOT_CONF.log_level());
// init::init();
init::init();
let result = logger::init();
match result {
Ok(_) => {}
Err(err) => error!("{}", err),
}
log_version_data();
/*
{
{
let mut scheduler = SCHEDULER.lock();
use crate::scheduler::Priority::*;
let mut process_1 = scheduler.new_process(High);
process_1.capabilities.files = FileAccess::Some(vec![PathRep {
location: FileLocations::Home,
file_name: "test".to_string(),
}]);
scheduler.add_process(process_1);
for ref_process in &scheduler.list {
trace!("{:?}", ref_process);
}
drop(scheduler);
}
use crate::proto_filetable::file::FileLocations;
{
let mut sock_print_id = SimpleSock::new();
sock_print_id.register_protocol("Screen Printer".to_string());
sock_print_id.write(format!("🐑").into());
let mut mode = SCREEN_BUFFER.lock();
mode.force_redraw();
for current in (*String::from_utf8_lossy(&sock_print_id.peek().unwrap())).chars() {
mode.draw_char(0, 0, current, from_vga_16(Color16::Red));
}
mode.copy_to_buffer();
}
}
*/
let mut vterm0 = Vterm::new();
vterm0.set_cursor_position(123, 123);
start_facepalm();
vterm0.set_cursor_position(60, 40);
vterm0.characters[0][0].character = 'a';
// start_facepalm();
sloop()
}
@ -134,10 +101,11 @@ use uefi::{
fs::SimpleFileSystem,
},
},
CStr16,
};
use uefi::{proto::console::gop::FrameBuffer, ResultExt};
use crate::{vterm::Vterm, GraphicsReturn, ScreenBuffer};
use crate::{file::FileLocations, logger, vterm::Vterm, GraphicsReturn, ScreenBuffer};
#[entry]
fn main(_handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
@ -147,6 +115,7 @@ fn main(_handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
.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());
@ -155,6 +124,15 @@ fn main(_handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
}
info!("Running graphics output protocol test");
let stdout = system_table.stdout();
stdout.set_cursor_position(0, 10).unwrap_success();
info!("{:?}", stdout.cursor_position());
// loop {}
/*
if let Ok(gop) = system_table
.boot_services()
.locate_protocol::<GraphicsOutput>()
@ -182,7 +160,14 @@ fn main(_handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
warn!("UEFI Graphics Output Protocol is not supported");
}
*/
// exit boot services
kernel_main();
Status::SUCCESS
}
pub fn draw_fb(gop: &mut GraphicsOutput) {

View file

@ -22,10 +22,14 @@
pub mod arch;
/// Contains architecture specific code for x86_64.
#[cfg(target_arch = "x86_64")]
#[cfg(all(target_arch = "x86_64", not(target_os = "uefi")))]
#[path = "arch/x86_64/mod.rs"]
pub mod arch;
#[cfg(all(target_arch = "x86_64", target_os = "uefi"))]
#[path = "arch/uefi_86/mod.rs"]
pub mod arch;
/// Contains architecture specific code for riscv64.
#[cfg(target_arch = "riscv64")]
#[path = "arch/riscv/mod.rs"]

View file

@ -1,12 +1,12 @@
use core::sync::atomic::Ordering;
use crate::kmain::TICK;
use crate::serial_println;
// use crate::serial_println;
use lliw::{Fg, Reset};
pub use log::{debug, info, trace, warn};
use log::{Level, Metadata, Record};
use crate::arch::drivers::timer::TIMER_INTERRUPT_HERTZ;
// use crate::arch::drivers::timer::TIMER_INTERRUPT_HERTZ;
struct SimpleLogger;
@ -20,7 +20,7 @@ impl log::Log for SimpleLogger {
let color;
let time = TICK.load(Ordering::Relaxed) as f64;
let time_float = time / TIMER_INTERRUPT_HERTZ;
// let time_float = time / TIMER_INTERRUPT_HERTZ;
match record.level() {
log::Level::Error => color = (Fg::Red, "$RED$"),
@ -29,7 +29,7 @@ impl log::Log for SimpleLogger {
log::Level::Debug => color = (Fg::Blue, "$BLUE$"),
log::Level::Trace => color = (Fg::Yellow, "$YELLOW$"),
}
/*
serial_println!(
"[{}{}{}][{}{}{}] {}",
color.0,
@ -40,6 +40,7 @@ impl log::Log for SimpleLogger {
Reset,
record.args(),
);
*/
}
}
/// Clear the log buffer

View file

@ -16,8 +16,8 @@ impl core::fmt::Write for Stdout {
}
#[cfg(target_arch = "x86_64")]
fn write_str(&mut self, s: &str) -> Result<(), Error> {
use crate::experiments::absi::colorify;
colorify(s);
// use crate::experiments::absi::colorify;
// colorify(s);
// kprint!("{}", s);
Ok(())
}