| 1 |
//! Multi-Processor Services Protocol |
| 2 |
//! |
| 3 |
//! This Protocol is defined in the UEFI Platform Integration Specification, |
| 4 |
//! Section 13.4. |
| 5 |
//! |
| 6 |
//! This provides a generalized way of performing the following tasks: |
| 7 |
//! - Retrieving information of multi-processor environments. |
| 8 |
//! - Dispatching user-provided function to APs. |
| 9 |
//! - Maintain MP-related processor status. |
| 10 |
|
| 11 |
pub const PROTOCOL_GUID: crate::base::Guid = crate::base::Guid::from_fields( |
| 12 |
0x3fdda605, |
| 13 |
0xa76e, |
| 14 |
0x4f46, |
| 15 |
0xad, |
| 16 |
0x29, |
| 17 |
&[0x12, 0xf4, 0x53, 0x1b, 0x3d, 0x08], |
| 18 |
); |
| 19 |
|
| 20 |
pub const PROCESSOR_AS_BSP_BIT: u32 = 0x00000001; |
| 21 |
pub const PROCESSOR_ENABLED_BIT: u32 = 0x00000002; |
| 22 |
pub const PROCESSOR_HEALTH_STATUS_BIT: u32 = 0x00000004; |
| 23 |
|
| 24 |
pub const END_OF_CPU_LIST: usize = usize::MAX; |
| 25 |
|
| 26 |
#[repr(C)] |
| 27 |
#[derive(Debug, Clone, Copy)] |
| 28 |
pub struct CpuPhysicalLocation { |
| 29 |
pub package: u32, |
| 30 |
pub core: u32, |
| 31 |
pub thread: u32, |
| 32 |
} |
| 33 |
|
| 34 |
#[repr(C)] |
| 35 |
#[derive(Debug, Clone, Copy)] |
| 36 |
pub struct CpuPhysicalLocation2 { |
| 37 |
pub package: u32, |
| 38 |
pub module: u32, |
| 39 |
pub tile: u32, |
| 40 |
pub die: u32, |
| 41 |
pub core: u32, |
| 42 |
pub thread: u32, |
| 43 |
} |
| 44 |
|
| 45 |
#[repr(C)] |
| 46 |
#[derive(Clone, Copy)] |
| 47 |
pub union ExtendedProcessorInformation { |
| 48 |
pub location2: CpuPhysicalLocation2, |
| 49 |
} |
| 50 |
|
| 51 |
#[repr(C)] |
| 52 |
#[derive(Clone, Copy)] |
| 53 |
pub struct ProcessorInformation { |
| 54 |
pub processor_id: u64, |
| 55 |
pub status_flag: u32, |
| 56 |
pub location: CpuPhysicalLocation, |
| 57 |
pub extended_information: ExtendedProcessorInformation, |
| 58 |
} |
| 59 |
|
| 60 |
pub type ApProcedure = eficall! {fn(*mut core::ffi::c_void)}; |
| 61 |
|
| 62 |
pub type GetNumberOfProcessors = eficall! {fn( |
| 63 |
*mut Protocol, |
| 64 |
*mut usize, |
| 65 |
*mut usize, |
| 66 |
) -> crate::base::Status}; |
| 67 |
|
| 68 |
pub type GetProcessorInfo = eficall! {fn( |
| 69 |
*mut Protocol, |
| 70 |
usize, |
| 71 |
*mut ProcessorInformation, |
| 72 |
) -> crate::base::Status}; |
| 73 |
|
| 74 |
pub type StartupAllAps = eficall! {fn( |
| 75 |
*mut Protocol, |
| 76 |
ApProcedure, |
| 77 |
crate::base::Boolean, |
| 78 |
crate::base::Event, |
| 79 |
usize, |
| 80 |
*mut core::ffi::c_void, |
| 81 |
*mut *mut usize, |
| 82 |
) -> crate::base::Status}; |
| 83 |
|
| 84 |
pub type StartupThisAp = eficall! {fn( |
| 85 |
*mut Protocol, |
| 86 |
ApProcedure, |
| 87 |
usize, |
| 88 |
crate::base::Event, |
| 89 |
usize, |
| 90 |
*mut core::ffi::c_void, |
| 91 |
*mut crate::base::Boolean, |
| 92 |
) -> crate::base::Status}; |
| 93 |
|
| 94 |
pub type SwitchBsp = eficall! {fn( |
| 95 |
*mut Protocol, |
| 96 |
usize, |
| 97 |
crate::base::Boolean, |
| 98 |
) -> crate::base::Status}; |
| 99 |
|
| 100 |
pub type EnableDisableAp = eficall! {fn( |
| 101 |
*mut Protocol, |
| 102 |
usize, |
| 103 |
crate::base::Boolean, |
| 104 |
*mut u32, |
| 105 |
) -> crate::base::Status}; |
| 106 |
|
| 107 |
pub type WhoAmI = eficall! {fn( |
| 108 |
*mut Protocol, |
| 109 |
*mut usize, |
| 110 |
) -> crate::base::Status}; |
| 111 |
|
| 112 |
#[repr(C)] |
| 113 |
pub struct Protocol { |
| 114 |
pub get_number_of_processors: GetNumberOfProcessors, |
| 115 |
pub get_processor_info: GetProcessorInfo, |
| 116 |
pub startup_all_aps: StartupAllAps, |
| 117 |
pub startup_this_ap: StartupThisAp, |
| 118 |
pub switch_bsp: SwitchBsp, |
| 119 |
pub enable_disable_ap: EnableDisableAp, |
| 120 |
pub who_am_i: WhoAmI, |
| 121 |
} |