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)]
|
||||
|
||||
pub mod absi;
|
||||
// pub mod absi;
|
||||
pub mod clip;
|
||||
pub mod futex;
|
||||
pub mod info;
|
||||
|
|
|
@ -10,157 +10,163 @@ pub type ColorCharacter = (Rgba64, Rgba64);
|
|||
/// A vterm representation of a character
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct VtermCharacter {
|
||||
pub character: char,
|
||||
//
|
||||
pub style: Style,
|
||||
//
|
||||
pub char_color: ColorCharacter,
|
||||
pub character: char,
|
||||
//
|
||||
pub style: Style,
|
||||
//
|
||||
pub char_color: ColorCharacter,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Style {
|
||||
pub bold: bool,
|
||||
pub underline: bool,
|
||||
pub italic: bool,
|
||||
pub blink: bool,
|
||||
pub reverse: bool,
|
||||
pub strike: bool,
|
||||
pub bold: bool,
|
||||
pub underline: bool,
|
||||
pub italic: bool,
|
||||
pub blink: bool,
|
||||
pub reverse: bool,
|
||||
pub strike: bool,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct StylePacked(pub u8);
|
||||
|
||||
impl StylePacked {
|
||||
pub fn bold(&self) -> bool {
|
||||
(self.0 & 0x01) > 0
|
||||
}
|
||||
pub fn underlined(&self) -> bool {
|
||||
(self.0 & 0x02) > 0
|
||||
}
|
||||
pub fn italic(&self) -> bool {
|
||||
(self.0 & 0x04) > 0
|
||||
}
|
||||
pub fn blinking(&self) -> bool {
|
||||
(self.0 & 0x08) > 0
|
||||
}
|
||||
pub fn reversed(&self) -> bool {
|
||||
(self.0 & 0x10) > 0
|
||||
}
|
||||
pub fn struck(&self) -> bool {
|
||||
(self.0 & 0x20) > 0
|
||||
}
|
||||
#[must_use]
|
||||
pub fn set_bold(mut self, v: bool) -> Self {
|
||||
if v {
|
||||
self.0 |= 0x01;
|
||||
} else {
|
||||
self.0 &= 0x01u8.not();
|
||||
}
|
||||
self
|
||||
}
|
||||
#[must_use]
|
||||
pub fn set_underlined(mut self, v: bool) -> Self {
|
||||
if v {
|
||||
self.0 |= 0x02;
|
||||
} else {
|
||||
self.0 &= 0x02u8.not();
|
||||
}
|
||||
self
|
||||
}
|
||||
#[must_use]
|
||||
pub fn set_italic(mut self, v: bool) -> Self {
|
||||
if v {
|
||||
self.0 |= 0x04;
|
||||
} else {
|
||||
self.0 &= 0x04u8.not();
|
||||
}
|
||||
self
|
||||
}
|
||||
#[must_use]
|
||||
pub fn set_blinking(mut self, v: bool) -> Self {
|
||||
if v {
|
||||
self.0 |= 0x08;
|
||||
} else {
|
||||
self.0 &= 0x08u8.not();
|
||||
}
|
||||
self
|
||||
}
|
||||
#[must_use]
|
||||
pub fn set_reversed(mut self, v: bool) -> Self {
|
||||
if v {
|
||||
self.0 |= 0x10;
|
||||
} else {
|
||||
self.0 &= 0x10u8.not();
|
||||
}
|
||||
self
|
||||
}
|
||||
#[must_use]
|
||||
pub fn set_struck(mut self, v: bool) -> Self {
|
||||
if v {
|
||||
self.0 |= 0x20;
|
||||
} else {
|
||||
self.0 &= 0x20u8.not();
|
||||
}
|
||||
self
|
||||
}
|
||||
pub fn bold(&self) -> bool {
|
||||
(self.0 & 0x01) > 0
|
||||
}
|
||||
pub fn underlined(&self) -> bool {
|
||||
(self.0 & 0x02) > 0
|
||||
}
|
||||
pub fn italic(&self) -> bool {
|
||||
(self.0 & 0x04) > 0
|
||||
}
|
||||
pub fn blinking(&self) -> bool {
|
||||
(self.0 & 0x08) > 0
|
||||
}
|
||||
pub fn reversed(&self) -> bool {
|
||||
(self.0 & 0x10) > 0
|
||||
}
|
||||
pub fn struck(&self) -> bool {
|
||||
(self.0 & 0x20) > 0
|
||||
}
|
||||
#[must_use]
|
||||
pub fn set_bold(mut self, v: bool) -> Self {
|
||||
if v {
|
||||
self.0 |= 0x01;
|
||||
} else {
|
||||
self.0 &= 0x01u8.not();
|
||||
}
|
||||
self
|
||||
}
|
||||
#[must_use]
|
||||
pub fn set_underlined(mut self, v: bool) -> Self {
|
||||
if v {
|
||||
self.0 |= 0x02;
|
||||
} else {
|
||||
self.0 &= 0x02u8.not();
|
||||
}
|
||||
self
|
||||
}
|
||||
#[must_use]
|
||||
pub fn set_italic(mut self, v: bool) -> Self {
|
||||
if v {
|
||||
self.0 |= 0x04;
|
||||
} else {
|
||||
self.0 &= 0x04u8.not();
|
||||
}
|
||||
self
|
||||
}
|
||||
#[must_use]
|
||||
pub fn set_blinking(mut self, v: bool) -> Self {
|
||||
if v {
|
||||
self.0 |= 0x08;
|
||||
} else {
|
||||
self.0 &= 0x08u8.not();
|
||||
}
|
||||
self
|
||||
}
|
||||
#[must_use]
|
||||
pub fn set_reversed(mut self, v: bool) -> Self {
|
||||
if v {
|
||||
self.0 |= 0x10;
|
||||
} else {
|
||||
self.0 &= 0x10u8.not();
|
||||
}
|
||||
self
|
||||
}
|
||||
#[must_use]
|
||||
pub fn set_struck(mut self, v: bool) -> Self {
|
||||
if v {
|
||||
self.0 |= 0x20;
|
||||
} else {
|
||||
self.0 &= 0x20u8.not();
|
||||
}
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Vterm {
|
||||
pub characters: [[VtermCharacter; VTERM_WIDTH as usize]; VTERM_HEIGHT as usize],
|
||||
/// The internal representation of the vterm
|
||||
style: Style,
|
||||
/// The cursor position in layout x,y
|
||||
cursor_position: (u32, u32),
|
||||
pub characters: [[VtermCharacter; VTERM_WIDTH as usize]; VTERM_HEIGHT as usize],
|
||||
/// The internal representation of the vterm
|
||||
style: Style,
|
||||
/// The cursor position in layout x,y
|
||||
cursor_position: (u32, u32),
|
||||
|
||||
pub cursor_visible: bool,
|
||||
pub cursor_visible: bool,
|
||||
}
|
||||
|
||||
impl Default for Vterm {
|
||||
fn default() -> Self {
|
||||
Vterm {
|
||||
characters: [[VtermCharacter {
|
||||
character: ' ',
|
||||
char_color: (0xff_ff_ff_ff, 0x00_00_00_00),
|
||||
fn default() -> Self {
|
||||
Vterm {
|
||||
characters: [[VtermCharacter {
|
||||
character: ' ',
|
||||
char_color: (0xff_ff_ff_ff, 0x00_00_00_00),
|
||||
style: Style {
|
||||
bold: false,
|
||||
underline: false,
|
||||
italic: false,
|
||||
blink: false,
|
||||
reverse: false,
|
||||
strike: false,
|
||||
},
|
||||
}; VTERM_WIDTH as usize]; VTERM_HEIGHT as usize],
|
||||
cursor_position: (0, 0),
|
||||
cursor_visible: true,
|
||||
style: Style {
|
||||
bold: false,
|
||||
underline: false,
|
||||
italic: false,
|
||||
blink: false,
|
||||
reverse: false,
|
||||
strike: false,
|
||||
bold: false,
|
||||
underline: false,
|
||||
italic: false,
|
||||
blink: false,
|
||||
reverse: false,
|
||||
strike: false,
|
||||
},
|
||||
}; VTERM_WIDTH as usize]; VTERM_HEIGHT as usize],
|
||||
cursor_position: (0, 0),
|
||||
cursor_visible: true,
|
||||
style: Style {
|
||||
bold: false,
|
||||
underline: false,
|
||||
italic: false,
|
||||
blink: false,
|
||||
reverse: false,
|
||||
strike: false,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Vterm {
|
||||
/// 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;
|
||||
} else {
|
||||
self.cursor_position.0 = x;
|
||||
}
|
||||
if y > VTERM_HEIGHT {
|
||||
self.cursor_position.1 = VTERM_HEIGHT;
|
||||
} else {
|
||||
self.cursor_position.1 = y;
|
||||
}
|
||||
}
|
||||
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");
|
||||
|
||||
/// Set the vterm style
|
||||
pub fn set_vterm_style(&mut self, style: Style) {
|
||||
self.style = style;
|
||||
}
|
||||
self.cursor_position.1 = VTERM_HEIGHT;
|
||||
} else {
|
||||
self.cursor_position.1 = y;
|
||||
}
|
||||
}
|
||||
|
||||
/// Set the vterm style
|
||||
pub fn set_vterm_style(&mut self, style: Style) {
|
||||
self.style = style;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue