This commit is contained in:
Able 2022-02-17 03:26:05 -06:00
parent b7c9feff26
commit 77e6f29568
4 changed files with 20 additions and 83 deletions

View file

@ -7,10 +7,16 @@ pub fn shutdown() {
pub fn sloop() -> ! {
loop {}
}
use core::{ffi::c_void, sync::atomic::AtomicUsize, time::Duration};
use crate::kmain::kernel_main;
use uefi::{
prelude::*,
proto::console::gop::{GraphicsOutput, PixelFormat},
proto::{
console::gop::{GraphicsOutput, PixelFormat},
pi::mp::MpServices,
},
};
use uefi::{proto::console::gop::FrameBuffer, ResultExt};
@ -56,10 +62,9 @@ fn main(_handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
.expect_success("Failed to set graphics mode");
let mut fb_1 = FrameBuffWrap::new(gop);
loop {
for x in 0..100 {
fb_1.draw_pixel(x, 400, [123, 123, 123]);
}
for x in 0..100 {
fb_1.draw_pixel(x, 400, [123, 123, 123]);
}
} else {
// No tests can be run.
@ -67,87 +72,23 @@ fn main(_handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
}
use uefi::proto::pi::mp::MpServices;
if let Ok(mp) = system_table.boot_services().locate_protocol::<MpServices>() {
let mp = mp.expect("Warnings encountered while opening GOP");
let mp = unsafe { &mut *mp.get() };
info!("Found MP Services");
// info!("{:?}", mp.get_number_of_processors().unwrap_success());
// info!("{:?}", mp.get_processor_info(0).unwrap_success());
if let Ok(mp_support) = system_table.boot_services().locate_protocol::<MpServices>() {
let mp_support = mp_support
.expect("Warnings encountered while opening multi-processor services protocol");
let mp = unsafe { &mut *mp_support.get() };
let proc_count = mp.get_number_of_processors().unwrap().unwrap();
info!("Number of processors: {:?}", proc_count);
}
// */
// exit boot services
kernel_main();
Status::SUCCESS
}
/*
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");
}
extern "efiapi" fn hi(_: *mut c_void) {
info!("Hello, world!");
}
*/
pub fn mp_handle() {}
/*
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), [250, 128, 64]);
fill_rectangle((400, 120), (750, 450), [16, 128, 255]);
*/
use uefi::proto::console::gop::ModeInfo;
pub type PixelWriter = unsafe fn(&mut FrameBuffer, usize, [u8; 3]);

View file

@ -3,7 +3,3 @@ pub mod pixel_format;
pub mod positions;
pub mod text;
pub mod window;
pub trait API {
fn init();
}

View file

@ -39,7 +39,7 @@ lazy_static! {
pub fn kernel_main() -> ! {
// log::set_max_level(BOOT_CONF.log_level());
init::init();
info!("AbleOS {} {}", KERNEL_VERSION, RELEASE_TYPE);
// info!("AbleOS {} {}", KERNEL_VERSION, RELEASE_TYPE);
let result = logger::init();
match result {
Ok(_) => {}

View file

@ -73,7 +73,7 @@ fn main() -> anyhow::Result<()> {
xshell::cmd!("cargo build --release --target=x86_64-unknown-uefi").run()?;
xshell::cmd!(
"uefi-run -b src/arch/uefi_86/firmware/OVMF-pure-efi.fd target/x86_64-unknown-uefi/release/ableos.efi"
"uefi-run -b src/arch/uefi_86/firmware/OVMF-pure-efi.fd target/x86_64-unknown-uefi/release/ableos.efi -- -machine q35 -smp 4"
)
.run()?;
}