Skip to content

Commit 9dbdfe9

Browse files
medhefgonicholasbishop
authored andcommitted
loaded_image: Provide getters for memory types
1 parent 816d39c commit 9dbdfe9

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
- Added `LoadedImageDevicePath` protocol.
2828
- Added `FileAttribute::is_directory(&self)` and
2929
`FileAttribute::is_regular_file(&self)`
30+
- Added `LoadedImage::code_type()` and `LoadedImage::data_type()`
3031

3132
### Changed
3233

uefi/src/proto/loaded_image.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,26 @@ impl LoadedImage {
170170
pub const fn info(&self) -> (*const c_void, u64) {
171171
(self.image_base, self.image_size)
172172
}
173+
174+
/// Get the memory type of the image's code sections.
175+
///
176+
/// Normally the returned value is one of:
177+
/// - `MemoryType::LOADER_CODE` for UEFI applications
178+
/// - `MemoryType::BOOT_SERVICES_CODE` for UEFI boot drivers
179+
/// - `MemoryType::RUNTIME_SERVICES_CODE` for UEFI runtime drivers
180+
#[must_use]
181+
pub fn code_type(&self) -> MemoryType {
182+
self.image_code_type
183+
}
184+
185+
/// Get the memory type of the image's data sections.
186+
///
187+
/// Normally the returned value is one of:
188+
/// - `MemoryType::LOADER_DATA` for UEFI applications
189+
/// - `MemoryType::BOOT_SERVICES_DATA` for UEFI boot drivers
190+
/// - `MemoryType::RUNTIME_SERVICES_DATA` for UEFI runtime drivers
191+
#[must_use]
192+
pub fn data_type(&self) -> MemoryType {
193+
self.image_data_type
194+
}
173195
}

0 commit comments

Comments
 (0)