simple file system
This commit is contained in:
5
nel_os_bootloader/.cargo/config.toml
Normal file
5
nel_os_bootloader/.cargo/config.toml
Normal file
@ -0,0 +1,5 @@
|
||||
[build]
|
||||
target = "x86_64-unknown-uefi"
|
||||
|
||||
[target.x86_64-unknown-uefi]
|
||||
runner = "./run-qemu.sh"
|
@ -5,4 +5,4 @@ edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
log = "0.4.27"
|
||||
uefi = { version = "0.35.0", features = ["logger", "panic_handler"] }
|
||||
uefi = { version = "0.35.0", features = ["logger", "panic_handler", "alloc"] }
|
||||
|
Binary file not shown.
@ -1,11 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
cargo build --release --target x86_64-unknown-uefi
|
||||
EFI_BINARY="$1"
|
||||
|
||||
cp target/x86_64-unknown-uefi/release/nel_os_bootloader.efi esp/efi/boot/bootx64.efi
|
||||
cp "$EFI_BINARY" esp/efi/boot/bootx64.efi
|
||||
|
||||
qemu-system-x86_64 -enable-kvm \
|
||||
-m 4G \
|
||||
-m 4G \
|
||||
-nographic \
|
||||
-serial mon:stdio \
|
||||
-no-reboot \
|
||||
-drive if=pflash,format=raw,readonly=on,file=OVMF_CODE.fd \
|
||||
-drive if=pflash,format=raw,readonly=on,file=OVMF_VARS.fd \
|
||||
-drive format=raw,file=fat:rw:esp
|
@ -1,8 +1,20 @@
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
use core::arch::asm;
|
||||
use uefi::{boot::MemoryType, mem::memory_map::MemoryMap, prelude::*, println};
|
||||
use uefi::{
|
||||
allocator::Allocator,
|
||||
boot::{MemoryType, ScopedProtocol},
|
||||
mem::memory_map::MemoryMap,
|
||||
prelude::*,
|
||||
println,
|
||||
proto::media::{file::Directory, fs::SimpleFileSystem},
|
||||
};
|
||||
|
||||
#[global_allocator]
|
||||
static ALLOCATOR: Allocator = Allocator;
|
||||
|
||||
fn hlt_loop() -> ! {
|
||||
loop {
|
||||
@ -12,11 +24,18 @@ fn hlt_loop() -> ! {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_fs() -> Directory {
|
||||
let mut fs: ScopedProtocol<SimpleFileSystem> =
|
||||
uefi::boot::get_image_file_system(uefi::boot::image_handle()).unwrap();
|
||||
|
||||
fs.open_volume().unwrap()
|
||||
}
|
||||
|
||||
#[entry]
|
||||
fn main() -> Status {
|
||||
uefi::helpers::init().unwrap();
|
||||
|
||||
uefi::system::with_stdout(|stdout| stdout.clear()).unwrap();
|
||||
println!("\nnel_os bootloader");
|
||||
|
||||
let memory_map = uefi::boot::memory_map(MemoryType::LOADER_DATA).unwrap();
|
||||
println!("memory_map len: {}", memory_map.len());
|
||||
@ -30,5 +49,16 @@ fn main() -> Status {
|
||||
println!(" PhysStart: {:?}", entry.phys_start);
|
||||
}
|
||||
|
||||
let mut root = get_fs();
|
||||
|
||||
println!("Root directory entries:");
|
||||
while let Ok(Some(file_info)) = root.read_entry_boxed() {
|
||||
if file_info.is_directory() {
|
||||
println!("Directory: {}", file_info.file_name());
|
||||
} else {
|
||||
println!("File: {}", file_info.file_name());
|
||||
}
|
||||
}
|
||||
|
||||
hlt_loop();
|
||||
}
|
||||
|
Reference in New Issue
Block a user