Browse Source

Successfully read first three bytes of bootloader file from vfs

master
Nick Rirush 6 years ago
parent
commit
efe847d733
Signed by: Rirush GPG Key ID: 8922C7BBF842AFF0
  1. 1
      Cargo.lock
  2. 1
      Cargo.toml
  3. 38
      src/main.rs

1
Cargo.lock

@ -17,6 +17,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
name = "coonboot"
version = "0.1.0"
dependencies = [
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"uefi 0.1.0 (git+https://github.com/GabrielMajeri/uefi-rs)",
"uefi-alloc 0.1.0 (git+https://github.com/GabrielMajeri/uefi-rs)",
"uefi-exts 0.1.0 (git+https://github.com/GabrielMajeri/uefi-rs)",

1
Cargo.toml

@ -9,3 +9,4 @@ uefi-alloc = { git = "https://github.com/GabrielMajeri/uefi-rs" }
uefi-exts = { git = "https://github.com/GabrielMajeri/uefi-rs" }
uefi-logger = { git = "https://github.com/GabrielMajeri/uefi-rs" }
uefi-services = { git = "https://github.com/GabrielMajeri/uefi-rs" }
log = { version = "0.4", default-features = false }

38
src/main.rs

@ -1,18 +1,48 @@
#![no_std]
#![no_main]
#![feature(alloc)]
extern crate uefi;
extern crate uefi_alloc;
extern crate uefi_services;
extern crate uefi_exts;
extern crate uefi_logger;
extern crate uefi_services;
#[macro_use]
extern crate log;
extern crate alloc;
use uefi::prelude::*;
use uefi::proto::media::file::{FileAttribute, FileMode};
use uefi::proto::media::fs::SimpleFileSystem;
use uefi_exts::BootServicesExt;
#[no_mangle]
pub extern "win64" fn uefi_start(image: uefi::Handle, table: SystemTable<Boot>) -> Status {
uefi_services::init(&table).expect_success("Unable to initialize utilities");
table.stdout().reset(false).expect_success("Failed to reset stdout");
pub extern "win64" fn uefi_start(_image: uefi::Handle, table: SystemTable<Boot>) -> Status {
uefi_services::init(&table).expect_success("Failed to initialize utilities");
table
.stdout()
.reset(false)
.expect_success("Failed to reset stdout");
let fs = table
.boot_services()
.find_protocol::<SimpleFileSystem>()
.expect("Failed to resolve filesystem")
.get();
unsafe {
let mut file = (*fs).open_volume().expect("Failed to open root").unwrap();
let mut file = file
.open(
"\\EFI\\coonboot.efi",
FileMode::READ,
FileAttribute::empty(),
)
.unwrap()
.unwrap();
let mut buf: [u8; 3] = [0, 0, 0];
file.read(&mut buf).unwrap().unwrap();
info!("First three bytes of coonboot.efi: {:?}", buf);
}
Status::SUCCESS
}

Loading…
Cancel
Save