Skip to content
Closed
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
6 changes: 6 additions & 0 deletions uefi/src/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ use uefi_raw::table::boot::InterfaceType;
#[cfg(feature = "alloc")]
use {alloc::vec::Vec, uefi::ResultExt};

/// Size in bytes of a UEFI page.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we move this to uefi-raw or reexport it from there?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, opened #1383

///
/// Note that this is not necessarily the processor's page size. The UEFI page
/// size is always 4 KiB.
pub const PAGE_SIZE: usize = 4096;

/// Global image handle. This is only set by [`set_image_handle`], and it is
/// only read by [`image_handle`].
static IMAGE_HANDLE: AtomicPtr<c_void> = AtomicPtr::new(ptr::null_mut());
Expand Down
6 changes: 3 additions & 3 deletions uefi/src/proto/security/memory_protection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl MemoryProtection {
/// [`EXECUTE_PROTECT`]: MemoryAttribute::EXECUTE_PROTECT
/// [`READ_ONLY`]: MemoryAttribute::READ_ONLY
/// [`Status::NO_MAPPING`]: crate::Status::NO_MAPPING
/// [UEFI page size]: uefi::table::boot::PAGE_SIZE
/// [UEFI page size]: crate::boot::PAGE_SIZE
pub fn get_memory_attributes(
&self,
byte_region: Range<PhysicalAddress>,
Expand All @@ -53,7 +53,7 @@ impl MemoryProtection {
/// [`READ_PROTECT`]: MemoryAttribute::READ_PROTECT
/// [`EXECUTE_PROTECT`]: MemoryAttribute::EXECUTE_PROTECT
/// [`READ_ONLY`]: MemoryAttribute::READ_ONLY
/// [UEFI page size]: uefi::table::boot::PAGE_SIZE
/// [UEFI page size]: crate::boot::PAGE_SIZE
pub fn set_memory_attributes(
&self,
byte_region: Range<PhysicalAddress>,
Expand All @@ -76,7 +76,7 @@ impl MemoryProtection {
/// [`READ_PROTECT`]: MemoryAttribute::READ_PROTECT
/// [`EXECUTE_PROTECT`]: MemoryAttribute::EXECUTE_PROTECT
/// [`READ_ONLY`]: MemoryAttribute::READ_ONLY
/// [UEFI page size]: uefi::table::boot::PAGE_SIZE
/// [UEFI page size]: crate::boot::PAGE_SIZE
pub fn clear_memory_attributes(
&self,
byte_region: Range<PhysicalAddress>,
Expand Down
8 changes: 1 addition & 7 deletions uefi/src/table/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

pub use crate::boot::{
AllocateType, EventNotifyFn, LoadImageSource, OpenProtocolAttributes, OpenProtocolParams,
ProtocolSearchKey, SearchType, TimerTrigger,
ProtocolSearchKey, SearchType, TimerTrigger, PAGE_SIZE,
};
pub use uefi_raw::table::boot::{
EventType, InterfaceType, MemoryAttribute, MemoryDescriptor, MemoryType, Tpl,
Expand All @@ -29,12 +29,6 @@ use core::ops::{Deref, DerefMut};
use core::ptr::NonNull;
use core::{ptr, slice};

/// Size in bytes of a UEFI page.
///
/// Note that this is not necessarily the processor's page size. The UEFI page
/// size is always 4 KiB.
pub const PAGE_SIZE: usize = 4096;

/// Contains pointers to all of the boot services.
///
/// # Accessing `BootServices`
Expand Down