-
Notifications
You must be signed in to change notification settings - Fork 50
[patina_mm] refactor current folder structure to allow external consumption #1413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+932
−332
Merged
Changes from 9 commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
f8d0b24
Patina MM related changes
kuqin12 34093d1
Use new GUID format
kuqin12 9585d37
some cleanup
kuqin12 8addd46
some more cleanup?
kuqin12 bf79f0f
misspell
kuqin12 e1a7297
fmt
kuqin12 21aae10
fixing some build breaks
kuqin12 09f66d2
fmt 2
kuqin12 2522226
build break again?
kuqin12 167133d
Merge remote-tracking branch 'origin/main' into bu2
kuqin12 cd72bca
remove mm_services for now
kuqin12 8ca6f86
revert some comments
kuqin12 5e0b77b
fixing the docx
kuqin12 f2463ce
simplify syntax
kuqin12 423c801
simplify content
kuqin12 928afe7
fix clippy
kuqin12 46732df
fmt
kuqin12 3b80b78
removed response type into u64 because it is actually from this into …
kuqin12 c4d6e4a
fix the size
kuqin12 0176f54
signature fix
kuqin12 2f1591d
do not need known layout
kuqin12 e15682f
fmt...
kuqin12 a8cc627
Merge remote-tracking branch 'origin/main' into bu2
kuqin12 a866711
fmt again
kuqin12 aba5443
moved definitions into patina
kuqin12 d11bee8
Merge remote-tracking branch 'origin/main' into bu2
kuqin12 b279163
remove some junk
kuqin12 dcc0415
fmt?
kuqin12 bca160e
fmt?
kuqin12 b7afeee
Merge remote-tracking branch 'origin/main' into bu2
kuqin12 c930f4c
Merge remote-tracking branch 'origin/main' into bu2
kuqin12 592ea6e
Merge branch 'main' into bu2
kuqin12 5861e31
Merge branch 'main' into bu2
kuqin12 5209e41
Merge branch 'main' into bu2
kuqin12 83411c0
Merge branch 'main' into bu2
kuqin12 e198494
Merge remote-tracking branch 'origin/main' into bu2
kuqin12 67b26fd
adding padding field
kuqin12 e102406
Merge branch 'bu2' of https://github.com/kuqin12/patina into bu2
kuqin12 583f4bd
signature and revision
kuqin12 a5b4793
fmt
kuqin12 f3e8eae
move pi defintiions to its own location
kuqin12 a610b7f
updated to make pi definitions into pi folder
kuqin12 c10457f
misspell
kuqin12 98d5b1a
fmt
kuqin12 e7de083
drop to_vec
kuqin12 9b5011d
Merge remote-tracking branch 'origin/main' into bu2
kuqin12 bc6984a
fixing doc
kuqin12 ff123f3
fmt
kuqin12 72a0b60
fmt
kuqin12 28a3a75
pr feedback
kuqin12 fdb0a69
Merge remote-tracking branch 'origin/main' into bu2
kuqin12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,171 @@ | ||
| //! Management Mode (MM) Header and Buffer HOB Definitions | ||
| //! | ||
| //! Defines the header and buffer HOB structures necessary for the MM environment to be initialized and used by components | ||
| //! dependent on MM details. | ||
| //! | ||
| //! ## MM HOB Usage | ||
| //! | ||
| //! It is expected that the MM HOB buffer will be initialized by the environment that registers services for the | ||
| //! platform. The HOBs can have platform-fixed values assigned during their initialization. It should be common | ||
| //! for at least the communication buffers to be populated as a mutable HOB during boot time. It is | ||
| //! recommended for a "MM HOB" component to handle all MM HOB details with minimal other MM related | ||
| //! dependencies and lock the HOBs so they are available for components that depend on the immutable HOB | ||
| //! to perform MM operations. | ||
| //! | ||
| //! ## License | ||
| //! | ||
| //! Copyright (C) Microsoft Corporation. | ||
| //! | ||
| //! SPDX-License-Identifier: Apache-2.0 | ||
| //! | ||
|
|
||
| use patina::{BinaryGuid, Guid}; | ||
| use zerocopy_derive::{FromBytes, Immutable, KnownLayout}; | ||
|
|
||
| /// GUID for the MM communication buffer HOB (`gMmCommBufferHobGuid`). | ||
| /// | ||
| /// `{ 0x6c2a2520, 0x0131, 0x4aee, { 0xa7, 0x50, 0xcc, 0x38, 0x4a, 0xac, 0xe8, 0xc6 } }` | ||
| pub const MM_COMM_BUFFER_HOB_GUID: BinaryGuid = BinaryGuid::from_string("6c2a2520-0131-4aee-a750-cc384aace8c6"); | ||
|
|
||
| /// MM Common Buffer HOB Data Structure. | ||
| /// | ||
| /// Describes the communication buffer region passed via HOB from PEI to MM. | ||
| #[repr(C, packed)] | ||
| #[derive(Debug, Clone, Copy)] | ||
| pub struct MmCommonBufferHobData { | ||
| /// Physical start address of the common region. | ||
| pub physical_start: u64, | ||
| /// Number of pages in the communication buffer region. | ||
| pub number_of_pages: u64, | ||
| /// Pointer to `MmCommBufferStatus` structure. | ||
| pub status_buffer: u64, | ||
| } | ||
|
|
||
| /// MM Communication Buffer Status | ||
| /// | ||
| /// Shared structure between DXE and MM environments to communicate the status | ||
| /// of MM communication operations. This structure is written by DXE before | ||
| /// triggering an MMI and read/written by MM during MMI processing. | ||
| /// | ||
| /// This is a structure currently used in some MM Supervisor MM implementations. | ||
| #[derive(Debug, Clone, Copy, FromBytes, Immutable, KnownLayout)] | ||
| #[repr(C)] | ||
| pub struct MmCommBufferStatus { | ||
| /// Whether the data in the fixed MM communication buffer is valid when entering from non-MM to MM. | ||
| /// Must be set to TRUE before triggering MMI, will be set to FALSE by MM after processing. | ||
| pub is_comm_buffer_valid: u8, | ||
|
|
||
| /// The channel used to communicate with MM. | ||
| /// FALSE = user buffer, TRUE = supervisor buffer | ||
| pub talk_to_supervisor: u8, | ||
|
|
||
| /// The return status when returning from MM to non-MM. | ||
| pub return_status: u64, | ||
|
|
||
| /// The size in bytes of the output buffer when returning from MM to non-MM. | ||
| pub return_buffer_size: u64, | ||
| } | ||
|
|
||
| impl Default for MmCommBufferStatus { | ||
| #[coverage(off)] | ||
| fn default() -> Self { | ||
| Self::new() | ||
| } | ||
| } | ||
|
|
||
| impl MmCommBufferStatus { | ||
| /// Create a new mailbox status with all fields zeroed | ||
| pub const fn new() -> Self { | ||
| Self { is_comm_buffer_valid: 0, talk_to_supervisor: 0, return_status: 0, return_buffer_size: 0 } | ||
| } | ||
| } | ||
|
|
||
| /// UEFI MM Communicate Header | ||
| /// | ||
| /// A standard header that must be present at the beginning of any MM communication buffer. | ||
| /// | ||
| /// ## Notes | ||
| /// | ||
| /// - This only supports V1 and V2 of the MM Communicate header format. | ||
| #[derive(Debug, Clone, Copy)] | ||
| #[repr(C)] | ||
| pub struct EfiMmCommunicateHeader { | ||
| /// Allows for disambiguation of the message format. | ||
| /// Used to identify the registered MM handlers that should be given the message. | ||
| header_guid: patina::BinaryGuid, | ||
| /// The size of Data (in bytes) and does not include the size of the header. | ||
| message_length: usize, | ||
| } | ||
|
|
||
| impl EfiMmCommunicateHeader { | ||
| /// Create a new communicate header with the specified GUID and message length. | ||
| pub fn new(header_guid: Guid, message_length: usize) -> Self { | ||
| Self { header_guid: header_guid.to_efi_guid().into(), message_length } | ||
| } | ||
|
|
||
| /// Returns the communicate header as a slice of bytes using safe conversion. | ||
| /// | ||
| /// Useful if byte-level access to the header structure is needed. | ||
| pub fn as_bytes(&self) -> &[u8] { | ||
| // SAFETY: EfiMmCommunicateHeader is repr(C) with well-defined layout and size | ||
| unsafe { core::slice::from_raw_parts(self as *const _ as *const u8, Self::size()) } | ||
| } | ||
|
|
||
| /// Returns the size of the header in bytes. | ||
| pub const fn size() -> usize { | ||
| core::mem::size_of::<Self>() | ||
| } | ||
|
|
||
| /// Get the header GUID from the communication buffer. | ||
| /// | ||
| /// Returns `Some(guid)` if the buffer has been properly initialized with a GUID, | ||
| /// or `None` if the buffer is not initialized. | ||
| /// | ||
| /// # Returns | ||
| /// | ||
| /// The GUID from the communication header if available. | ||
| /// | ||
| /// # Errors | ||
| /// | ||
| /// Returns an error if the communication buffer header cannot be read. | ||
| pub fn header_guid(&self) -> Guid<'_> { | ||
| Guid::from_ref(&self.header_guid) | ||
| } | ||
|
|
||
| /// Returns the message length from this communicate header. | ||
| /// | ||
| /// The length represents the size of the message data that follows the header. | ||
| /// | ||
| /// # Returns | ||
| /// | ||
| /// The length in bytes of the message data (excluding the header size). | ||
| pub const fn message_length(&self) -> usize { | ||
| self.message_length | ||
| } | ||
| } | ||
|
|
||
| /// EFI_MM_ENTRY_CONTEXT structure. | ||
| /// | ||
| /// Processor information and functionality needed by MM Foundation. | ||
| /// Matches the C `EFI_MM_ENTRY_CONTEXT` / `EFI_SMM_ENTRY_CONTEXT` from PI specification. | ||
| /// | ||
| /// Layout (x86_64, all fields 8 bytes): | ||
| /// - `mm_startup_this_ap`: Function pointer for `EFI_MM_STARTUP_THIS_AP` | ||
| /// - `currently_executing_cpu`: Index of the processor executing the MM Foundation | ||
| /// - `number_of_cpus`: Total number of possible processors in the platform (1-based) | ||
| /// - `cpu_save_state_size`: Pointer to array of save state sizes per CPU | ||
| /// - `cpu_save_state`: Pointer to array of CPU save state pointers | ||
| #[derive(Debug, Clone, Copy)] | ||
| #[repr(C)] | ||
| pub struct EfiMmEntryContext { | ||
| /// Function pointer for EFI_MM_STARTUP_THIS_AP. | ||
| pub mm_startup_this_ap: u64, | ||
| /// Index of the currently executing CPU. | ||
| pub currently_executing_cpu: u64, | ||
| /// Total number of CPUs (1-based). | ||
| pub number_of_cpus: u64, | ||
| /// Pointer to array of per-CPU save state sizes. | ||
| pub cpu_save_state_size: u64, | ||
| /// Pointer to array of per-CPU save state pointers. | ||
| pub cpu_save_state: u64, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,3 +9,4 @@ | |
| //! SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| pub mod mm_comm_buffer_update; | ||
| pub mod mm_supervisor_request; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.