std/os/uefi: add support for getting memory map

This commit is contained in:
Nick Erdmann 2019-09-02 19:04:26 +02:00
parent 03abc6edf4
commit 8db41b7adb
No known key found for this signature in database
GPG Key ID: C174038EAF6578B2
2 changed files with 44 additions and 1 deletions

View File

@ -1,6 +1,7 @@
pub const BootServices = @import("tables/boot_services.zig").BootServices;
pub const ConfigurationTable = @import("tables/configuration_table.zig").ConfigurationTable;
pub const global_variable align(8) = @import("tables/runtime_services.zig").global_variable;
pub const MemoryDescriptor = @import("tables/boot_services.zig").MemoryDescriptor;
pub const ResetType = @import("tables/runtime_services.zig").ResetType;
pub const RuntimeServices = @import("tables/runtime_services.zig").RuntimeServices;
pub const SystemTable = @import("tables/system_table.zig").SystemTable;

View File

@ -20,7 +20,7 @@ pub const BootServices = extern struct {
restoreTpl: usize, // TODO
allocatePages: usize, // TODO
freePages: usize, // TODO
getMemoryMap: usize, // TODO
getMemoryMap: extern fn (*usize, [*]MemoryDescriptor, *usize, *usize, *u32) usize,
allocatePool: usize, // TODO
freePool: usize, // TODO
createEvent: extern fn (u32, usize, ?extern fn (Event, ?*const c_void) void, ?*const c_void, *Event) usize,
@ -81,3 +81,45 @@ pub const TimerDelay = extern enum(u32) {
TimerPeriodic,
TimerRelative,
};
pub const MemoryDescriptor = extern struct {
type: extern enum(u32) {
ReservedMemoryType,
LoaderCode,
LoaderData,
BootServicesCode,
BootServicesData,
RuntimeServicesCode,
RuntimeServicesData,
ConventionalMemory,
UnusableMemory,
ACPIReclaimMemory,
ACPIMemoryNVS,
MemoryMappedIO,
MemoryMappedIOPortSpace,
PalCode,
PersistentMemory,
MaxMemoryType,
},
physical_start: u64,
virtual_start: u64,
number_of_pages: usize,
attribute: packed struct {
uc: bool,
wc: bool,
wt: bool,
wb: bool,
uce: bool,
_pad1: u7,
wp: bool,
rp: bool,
xp: bool,
nv: bool,
more_reliable: bool,
ro: bool,
sp: bool,
cpu_crypto: bool,
_pad2: u43,
memory_runtime: bool,
},
};