
Is multiprocessing possible in UEFI?
According to the Unified Extensible Firmware Interface specification, the software environment that provides initialization procedures before loading the operating system does not support multithreaded processing. The main reason is the single-threaded UEFI ideology and, as a consequence, the unprofitableness of the UEFI API service procedures. At the same time, a number of tasks not related to calling service functions (for example, testing RAM) not only allow parallel execution by several program threads, but also get an increase in performance from such a trip.
Note: a few years ago, in our laboratory, experiments were carried out to initialize a multiprocessor platform in a 16-bit MS-DOS environment, using direct programming of hardware resources, in particular, Local APIC interrupt controllers. The experience was successful from a technical point of view, however, it turned out to be somewhat similar to a joke about a trainer who taught the dog how to play the violin, and the audience, as it turned out, didn’t go to the circus to listen to the violin concert ...
Presence in the UEFI The firmware of a documented set of service functions called EFI_MP_SERVICES_PROTOCOL suggests that the fate of multi-threaded processing under UEFI will be somewhat different. Let us consider in more detail one of the functions of this protocol.
Consider the set of parameters and the principles of using one of the main functions of StartupThisAP , which ensures the launch of the AP (Application Processors) multiprocessor system and the coordination of their work from the side of the BSP (Bootstrap Processor).

Description of the StartupThisAP function in the UEFI Platform Initialization Specification. Volume 2. Driver Execution Environment Core Interface. Version 1.3.
The function allows you to run an arbitrary procedure on a given logical processor of a multiprocessor platform. The control object is logical processors , for example, in a system with two 8-core processors that support Hyper-Threading technology, the number of logical processors will be 2 * 8 * 2 = 32. To request the number of processors, the GetNumberOfProcessors function is used , an example of which is given in the description of the SMP Detect utility .
So, the StartupThisAP function takes 7 parameters.
After execution, the function returns the UEFI status in the RAX register.
It can be stated that, compared to the Legacy BIOS, UEFI firmware significantly simplifies the task of a system programmer when initializing a multiprocessor platform. The transfer of interprocessor interrupts, known as IPI or Inter Processor Interrupts, as well as the transfer of the AP processor to a mode compatible with the UEFI context, can be carried out not by directly programming the equipment, but using service functions. An exception may be tasks for which platform resources providing support for multiprocessing are an independent object of research or diagnostics.
UPD The picture was replaced: initially by mistake there was a structure of the interface unit EFI_MP_SERVICES_PROTOCOL
Note: a few years ago, in our laboratory, experiments were carried out to initialize a multiprocessor platform in a 16-bit MS-DOS environment, using direct programming of hardware resources, in particular, Local APIC interrupt controllers. The experience was successful from a technical point of view, however, it turned out to be somewhat similar to a joke about a trainer who taught the dog how to play the violin, and the audience, as it turned out, didn’t go to the circus to listen to the violin concert ...
Presence in the UEFI The firmware of a documented set of service functions called EFI_MP_SERVICES_PROTOCOL suggests that the fate of multi-threaded processing under UEFI will be somewhat different. Let us consider in more detail one of the functions of this protocol.
Launch AP: how to do it
Consider the set of parameters and the principles of using one of the main functions of StartupThisAP , which ensures the launch of the AP (Application Processors) multiprocessor system and the coordination of their work from the side of the BSP (Bootstrap Processor).

Description of the StartupThisAP function in the UEFI Platform Initialization Specification. Volume 2. Driver Execution Environment Core Interface. Version 1.3.
The function allows you to run an arbitrary procedure on a given logical processor of a multiprocessor platform. The control object is logical processors , for example, in a system with two 8-core processors that support Hyper-Threading technology, the number of logical processors will be 2 * 8 * 2 = 32. To request the number of processors, the GetNumberOfProcessors function is used , an example of which is given in the description of the SMP Detect utility .
So, the StartupThisAP function takes 7 parameters.
- EFI_MP_SERVICES_PROTOCOL - pointer to the interface unit of the called protocol returned by the EFI_Locate_Protocol function.
- EFI_AP_PROCEDURE - A pointer to the procedure that the AP processor should perform. The procedure must be pre-prepared in memory in accordance with the rules for the current processor mode, for example, Microsoft x64 calling convention is used for UEFI x64.
- ProcessorNumber - number of the launched processor, counting from 0.
- WaitEvent - the number (handle) of the event reserved by the calling procedure. The called procedure generates this event to signal the successful completion of the routine on the AP processor or the timeout has expired. A special case - the zero value of this parameter means that the BSP processor that launched the procedure on the AP processor must wait for this procedure to complete before returning from the function. However, events are not generated. This mode is called Blocking Mode.
- TimeoutInMicroseconds - The timeout value in microseconds that determines the timeout for the completion of the procedure running on the AP processor. After the timeout expires, the procedure is terminated with an error. Zero value of this parameter means that there are no restrictions on the execution time of the procedure (endless waiting).
- ProcedureArgument - parameter passed to the procedure running on the AP processor. A value of zero means not to use parameter passing.
- Finished - a pointer to the variable set by the UEFI firmware to TRUE if the procedure running on the AP successfully completed before the timeout expired. A value of zero means not to use such a variable.
After execution, the function returns the UEFI status in the RAX register.
Summary
It can be stated that, compared to the Legacy BIOS, UEFI firmware significantly simplifies the task of a system programmer when initializing a multiprocessor platform. The transfer of interprocessor interrupts, known as IPI or Inter Processor Interrupts, as well as the transfer of the AP processor to a mode compatible with the UEFI context, can be carried out not by directly programming the equipment, but using service functions. An exception may be tasks for which platform resources providing support for multiprocessing are an independent object of research or diagnostics.
application
UPD The picture was replaced: initially by mistake there was a structure of the interface unit EFI_MP_SERVICES_PROTOCOL