memory map
This commit is contained in:
Binary file not shown.
@@ -1,5 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
cargo build --release --target x86_64-unknown-uefi
|
||||
|
||||
cp target/x86_64-unknown-uefi/release/nel_os_bootloader.efi esp/efi/boot/bootx64.efi
|
||||
|
||||
qemu-system-x86_64 -enable-kvm \
|
||||
-m 4G \
|
||||
-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,16 +1,34 @@
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
use log::info;
|
||||
use uefi::prelude::*;
|
||||
use core::arch::asm;
|
||||
use uefi::{boot::MemoryType, mem::memory_map::MemoryMap, prelude::*, println};
|
||||
|
||||
fn hlt_loop() -> ! {
|
||||
loop {
|
||||
unsafe {
|
||||
asm!("hlt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[entry]
|
||||
fn main() -> Status {
|
||||
uefi::helpers::init().unwrap();
|
||||
|
||||
let boot_services = uefi::env::boot_services();
|
||||
uefi::system::with_stdout(|stdout| stdout.clear()).unwrap();
|
||||
|
||||
info!("Hello world!");
|
||||
boot::stall(10_000_000);
|
||||
Status::SUCCESS
|
||||
let memory_map = uefi::boot::memory_map(MemoryType::LOADER_DATA).unwrap();
|
||||
println!("memory_map len: {}", memory_map.len());
|
||||
|
||||
println!("Conventional memory:");
|
||||
for entry in memory_map.entries() {
|
||||
if entry.ty != MemoryType::CONVENTIONAL {
|
||||
continue;
|
||||
}
|
||||
println!(" Size: {:?}MiB", entry.page_count * 4 / 1024);
|
||||
println!(" PhysStart: {:?}", entry.phys_start);
|
||||
}
|
||||
|
||||
hlt_loop();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user