Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ edition = "2021"

[dependencies]
log = "0.4.20"
uefi = { version = "0.26.0", features = ["alloc"], optional = true }
uefi-services = { version = "0.23.0", optional = true }
uefi = { version = "0.27.0", features = ["alloc"], optional = true }
uefi-services = { version = "0.24.0", optional = true }
ttf_renderer = { git = "https://github.com/codyd51/axle", branch="paging-demo" }
agx_definitions = { git = "https://github.com/codyd51/axle", branch="paging-demo" }
libgui = { git = "https://github.com/codyd51/axle", branch="paging-demo" }
Expand Down
1 change: 1 addition & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[toolchain]
channel = "nightly-2024-04-09" # rustc 1.79
targets = ["x86_64-unknown-uefi"]

19 changes: 5 additions & 14 deletions src/fs.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
use alloc::format;
use alloc::vec::Vec;
use uefi::{CStr16, cstr16};
use uefi::fs::FileSystem;
use uefi::{CString16};
use uefi::fs::{FileSystem};
use uefi::prelude::BootServices;

pub fn read_file(boot_services: &BootServices, path: &str) -> Vec<u8> {
let mut input_as_u16s = path
.chars()
.map(|c| u16::try_from(c as u32))
.collect::<Result<Vec<u16>, _>>().expect("Failed to convert path characters to u16s");
// Add a null byte at the end, as CStr16 needs one
input_as_u16s.push(0);
let path_as_cstr16 = unsafe {
CStr16::from_u16_with_nul_unchecked(&input_as_u16s)
};

let mut sfs = boot_services.get_image_file_system(boot_services.image_handle()).unwrap();
let path_as_cstr16 = CString16::try_from(path).expect("Path should only contain UCS2-compatible characters.");
let sfs = boot_services.get_image_file_system(boot_services.image_handle()).unwrap();
let mut fs = FileSystem::new(sfs);
fs.read(path_as_cstr16).expect(&format!("Failed to read file \"{path}\""))
fs.read(path_as_cstr16.as_ref()).expect(&format!("Should be able to read file \"{path}\""))
}