work on moving the uefi into its own subcrate
This commit is contained in:
parent
7785de8fd9
commit
04374aa905
1
ableos/src/arch/uefi_86/init.rs
Normal file
1
ableos/src/arch/uefi_86/init.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
pub fn init() {}
|
|
@ -1 +1,9 @@
|
||||||
|
pub mod init;
|
||||||
|
|
||||||
|
pub fn shutdown() {
|
||||||
|
loop {}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn sloop() -> ! {
|
||||||
|
loop {}
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
pub mod absi;
|
// pub mod absi;
|
||||||
pub mod clip;
|
pub mod clip;
|
||||||
pub mod futex;
|
pub mod futex;
|
||||||
pub mod info;
|
pub mod info;
|
||||||
|
|
|
@ -145,14 +145,20 @@ impl Default for Vterm {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Vterm {
|
impl Vterm {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Vterm::default()
|
||||||
|
}
|
||||||
/// Set the vterm cursor to the given position
|
/// Set the vterm cursor to the given position
|
||||||
pub fn set_cursor_position(&mut self, x: u32, y: u32) {
|
pub fn set_cursor_position(&mut self, x: u32, y: u32) {
|
||||||
if x > VTERM_WIDTH {
|
if x > VTERM_WIDTH {
|
||||||
self.cursor_position.0 = VTERM_WIDTH;
|
self.cursor_position.0 = VTERM_WIDTH;
|
||||||
|
error!("Cursor x position out of bounds");
|
||||||
} else {
|
} else {
|
||||||
self.cursor_position.0 = x;
|
self.cursor_position.0 = x;
|
||||||
}
|
}
|
||||||
if y > VTERM_HEIGHT {
|
if y > VTERM_HEIGHT {
|
||||||
|
error!("Cursor y position out of bounds");
|
||||||
|
|
||||||
self.cursor_position.1 = VTERM_HEIGHT;
|
self.cursor_position.1 = VTERM_HEIGHT;
|
||||||
} else {
|
} else {
|
||||||
self.cursor_position.1 = y;
|
self.cursor_position.1 = y;
|
||||||
|
|
|
@ -15,7 +15,8 @@ use {
|
||||||
file::PathRep,
|
file::PathRep,
|
||||||
relib::network::socket::{SimpleSock, Socket},
|
relib::network::socket::{SimpleSock, Socket},
|
||||||
scheduler::SCHEDULER,
|
scheduler::SCHEDULER,
|
||||||
VgaBuffer, SCREEN_BUFFER,
|
// VgaBuffer,
|
||||||
|
SCREEN_BUFFER,
|
||||||
},
|
},
|
||||||
alloc::{
|
alloc::{
|
||||||
format,
|
format,
|
||||||
|
@ -26,8 +27,6 @@ use {
|
||||||
facepalm::start_facepalm,
|
facepalm::start_facepalm,
|
||||||
lazy_static::lazy_static,
|
lazy_static::lazy_static,
|
||||||
log::*,
|
log::*,
|
||||||
shadeable::pixel_format::from_vga_16,
|
|
||||||
vga::colors::Color16,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
|
@ -39,51 +38,19 @@ lazy_static! {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub fn kernel_main() -> ! {
|
pub fn kernel_main() -> ! {
|
||||||
log::set_max_level(BOOT_CONF.log_level());
|
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();
|
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();
|
let mut vterm0 = Vterm::new();
|
||||||
vterm0.set_cursor_position(123, 123);
|
vterm0.set_cursor_position(60, 40);
|
||||||
start_facepalm();
|
vterm0.characters[0][0].character = 'a';
|
||||||
|
|
||||||
|
// start_facepalm();
|
||||||
sloop()
|
sloop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,10 +101,11 @@ use uefi::{
|
||||||
fs::SimpleFileSystem,
|
fs::SimpleFileSystem,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
CStr16,
|
||||||
};
|
};
|
||||||
use uefi::{proto::console::gop::FrameBuffer, ResultExt};
|
use uefi::{proto::console::gop::FrameBuffer, ResultExt};
|
||||||
|
|
||||||
use crate::{vterm::Vterm, GraphicsReturn, ScreenBuffer};
|
use crate::{file::FileLocations, logger, vterm::Vterm, GraphicsReturn, ScreenBuffer};
|
||||||
|
|
||||||
#[entry]
|
#[entry]
|
||||||
fn main(_handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
|
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");
|
.expect_success("Failed to reset output buffer");
|
||||||
uefi_services::init(&mut system_table).unwrap_success();
|
uefi_services::init(&mut system_table).unwrap_success();
|
||||||
// Print out UEFI revision number
|
// Print out UEFI revision number
|
||||||
|
|
||||||
{
|
{
|
||||||
let rev = system_table.uefi_revision();
|
let rev = system_table.uefi_revision();
|
||||||
let (major, minor) = (rev.major(), rev.minor());
|
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");
|
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
|
if let Ok(gop) = system_table
|
||||||
.boot_services()
|
.boot_services()
|
||||||
.locate_protocol::<GraphicsOutput>()
|
.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");
|
warn!("UEFI Graphics Output Protocol is not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// exit boot services
|
||||||
kernel_main();
|
kernel_main();
|
||||||
|
|
||||||
|
Status::SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw_fb(gop: &mut GraphicsOutput) {
|
pub fn draw_fb(gop: &mut GraphicsOutput) {
|
||||||
|
|
|
@ -22,10 +22,14 @@
|
||||||
pub mod arch;
|
pub mod arch;
|
||||||
|
|
||||||
/// Contains architecture specific code for x86_64.
|
/// 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"]
|
#[path = "arch/x86_64/mod.rs"]
|
||||||
pub mod arch;
|
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.
|
/// Contains architecture specific code for riscv64.
|
||||||
#[cfg(target_arch = "riscv64")]
|
#[cfg(target_arch = "riscv64")]
|
||||||
#[path = "arch/riscv/mod.rs"]
|
#[path = "arch/riscv/mod.rs"]
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
use core::sync::atomic::Ordering;
|
use core::sync::atomic::Ordering;
|
||||||
|
|
||||||
use crate::kmain::TICK;
|
use crate::kmain::TICK;
|
||||||
use crate::serial_println;
|
// use crate::serial_println;
|
||||||
use lliw::{Fg, Reset};
|
use lliw::{Fg, Reset};
|
||||||
pub use log::{debug, info, trace, warn};
|
pub use log::{debug, info, trace, warn};
|
||||||
use log::{Level, Metadata, Record};
|
use log::{Level, Metadata, Record};
|
||||||
|
|
||||||
use crate::arch::drivers::timer::TIMER_INTERRUPT_HERTZ;
|
// use crate::arch::drivers::timer::TIMER_INTERRUPT_HERTZ;
|
||||||
|
|
||||||
struct SimpleLogger;
|
struct SimpleLogger;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ impl log::Log for SimpleLogger {
|
||||||
let color;
|
let color;
|
||||||
let time = TICK.load(Ordering::Relaxed) as f64;
|
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() {
|
match record.level() {
|
||||||
log::Level::Error => color = (Fg::Red, "$RED$"),
|
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::Debug => color = (Fg::Blue, "$BLUE$"),
|
||||||
log::Level::Trace => color = (Fg::Yellow, "$YELLOW$"),
|
log::Level::Trace => color = (Fg::Yellow, "$YELLOW$"),
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
serial_println!(
|
serial_println!(
|
||||||
"[{}{}{}][{}{}{}] {}",
|
"[{}{}{}][{}{}{}] {}",
|
||||||
color.0,
|
color.0,
|
||||||
|
@ -40,6 +40,7 @@ impl log::Log for SimpleLogger {
|
||||||
Reset,
|
Reset,
|
||||||
record.args(),
|
record.args(),
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// Clear the log buffer
|
/// Clear the log buffer
|
||||||
|
|
|
@ -16,8 +16,8 @@ impl core::fmt::Write for Stdout {
|
||||||
}
|
}
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
||||||
use crate::experiments::absi::colorify;
|
// use crate::experiments::absi::colorify;
|
||||||
colorify(s);
|
// colorify(s);
|
||||||
// kprint!("{}", s);
|
// kprint!("{}", s);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue