Aamir Bohra | 30cca6c | 2021-02-04 20:57:51 +0530 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <fsp/api.h> |
| 4 | #include <fsp/ppi/mp_service_ppi.h> |
| 5 | #include <Ppi/MpServices2.h> |
| 6 | |
| 7 | typedef EDKII_PEI_MP_SERVICES2_PPI efi_pei_mp_services_ppi; |
| 8 | |
Jeremy Compostella | 3f43184 | 2024-02-16 13:29:26 -0800 | [diff] [blame^] | 9 | static __efiapi efi_return_status_t mps2_get_number_of_processors( |
Aamir Bohra | 30cca6c | 2021-02-04 20:57:51 +0530 | [diff] [blame] | 10 | efi_pei_mp_services_ppi *ignored1, |
| 11 | efi_uintn_t *number_of_processors, |
| 12 | efi_uintn_t *number_of_enabled_processors) |
| 13 | { |
| 14 | return mp_get_number_of_processors(number_of_processors, number_of_enabled_processors); |
| 15 | } |
| 16 | |
Jeremy Compostella | 3f43184 | 2024-02-16 13:29:26 -0800 | [diff] [blame^] | 17 | static __efiapi efi_return_status_t mps2_get_processor_info( |
Aamir Bohra | 30cca6c | 2021-02-04 20:57:51 +0530 | [diff] [blame] | 18 | efi_pei_mp_services_ppi *ignored1, |
| 19 | efi_uintn_t processor_number, |
| 20 | efi_processor_information *processor_info_buffer) |
| 21 | { |
| 22 | return mp_get_processor_info(processor_number, processor_info_buffer); |
| 23 | } |
| 24 | |
Jeremy Compostella | 3f43184 | 2024-02-16 13:29:26 -0800 | [diff] [blame^] | 25 | static __efiapi efi_return_status_t mps2_startup_all_aps( |
Aamir Bohra | 30cca6c | 2021-02-04 20:57:51 +0530 | [diff] [blame] | 26 | efi_pei_mp_services_ppi *ignored1, |
Aamir Bohra | 813a3ba | 2021-02-25 13:25:57 +0530 | [diff] [blame] | 27 | efi_ap_procedure procedure, efi_boolean_t run_serial, |
Aamir Bohra | 30cca6c | 2021-02-04 20:57:51 +0530 | [diff] [blame] | 28 | efi_uintn_t timeout_usec, void *argument) |
| 29 | { |
Aamir Bohra | 813a3ba | 2021-02-25 13:25:57 +0530 | [diff] [blame] | 30 | return mp_startup_all_aps(procedure, run_serial, timeout_usec, argument); |
Aamir Bohra | 30cca6c | 2021-02-04 20:57:51 +0530 | [diff] [blame] | 31 | } |
| 32 | |
Jeremy Compostella | 3f43184 | 2024-02-16 13:29:26 -0800 | [diff] [blame^] | 33 | static __efiapi efi_return_status_t mps2_startup_all_cpus( |
Aamir Bohra | 30cca6c | 2021-02-04 20:57:51 +0530 | [diff] [blame] | 34 | efi_pei_mp_services_ppi *ignored1, |
| 35 | efi_ap_procedure procedure, |
| 36 | efi_uintn_t timeout_usec, void *argument) |
| 37 | { |
| 38 | return mp_startup_all_cpus(procedure, timeout_usec, argument); |
| 39 | } |
| 40 | |
Jeremy Compostella | 3f43184 | 2024-02-16 13:29:26 -0800 | [diff] [blame^] | 41 | static __efiapi efi_return_status_t mps2_startup_this_ap( |
Aamir Bohra | 30cca6c | 2021-02-04 20:57:51 +0530 | [diff] [blame] | 42 | efi_pei_mp_services_ppi *ignored1, |
| 43 | efi_ap_procedure procedure, efi_uintn_t processor_number, |
| 44 | efi_uintn_t timeout_usec, void *argument) |
| 45 | { |
| 46 | return mp_startup_this_ap(procedure, processor_number, timeout_usec, argument); |
| 47 | } |
| 48 | |
Jeremy Compostella | 3f43184 | 2024-02-16 13:29:26 -0800 | [diff] [blame^] | 49 | static __efiapi efi_return_status_t mps2_switch_bsp( |
Aamir Bohra | 30cca6c | 2021-02-04 20:57:51 +0530 | [diff] [blame] | 50 | efi_pei_mp_services_ppi *ignored1, efi_uintn_t ignored2, |
| 51 | efi_boolean_t ignored3) |
| 52 | { |
| 53 | return mp_api_unsupported(); |
| 54 | } |
| 55 | |
Jeremy Compostella | 3f43184 | 2024-02-16 13:29:26 -0800 | [diff] [blame^] | 56 | static __efiapi efi_return_status_t mps2_enable_disable_ap( |
Aamir Bohra | 30cca6c | 2021-02-04 20:57:51 +0530 | [diff] [blame] | 57 | efi_pei_mp_services_ppi *ignored1, |
| 58 | efi_uintn_t ignored2, efi_boolean_t ignored3, efi_uint32_t *ignored4) |
| 59 | { |
| 60 | return mp_api_unsupported(); |
| 61 | } |
| 62 | |
Jeremy Compostella | 3f43184 | 2024-02-16 13:29:26 -0800 | [diff] [blame^] | 63 | static __efiapi efi_return_status_t mps2_identify_processor( |
Aamir Bohra | 30cca6c | 2021-02-04 20:57:51 +0530 | [diff] [blame] | 64 | efi_pei_mp_services_ppi *ignored1, |
| 65 | efi_uintn_t *processor_number) |
| 66 | { |
| 67 | return mp_identify_processor(processor_number); |
| 68 | } |
| 69 | |
Sean Rhodes | 38c99b5 | 2022-07-13 10:11:44 +0100 | [diff] [blame] | 70 | /* edk2 UEFIPKG Open Source MP Services 2 PPI to be installed */ |
Aamir Bohra | 30cca6c | 2021-02-04 20:57:51 +0530 | [diff] [blame] | 71 | |
| 72 | static efi_pei_mp_services_ppi mp_service2_ppi = { |
| 73 | mps2_get_number_of_processors, |
| 74 | mps2_get_processor_info, |
| 75 | mps2_startup_all_aps, |
| 76 | mps2_startup_this_ap, |
| 77 | mps2_switch_bsp, |
| 78 | mps2_enable_disable_ap, |
| 79 | mps2_identify_processor, |
| 80 | mps2_startup_all_cpus, |
| 81 | }; |
| 82 | |
| 83 | void *mp_fill_ppi_services_data(void) |
| 84 | { |
| 85 | return (void *)&mp_service2_ppi; |
| 86 | } |