flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Multiprocessor support in UEFI

Author
Thread Post new topic Reply to topic
Feryno



Joined: 23 Mar 2005
Posts: 514
Location: Czech republic, Slovak republic
Feryno 10 Jan 2014, 13:10
MP = multiprocessor
BSP = bootstrap CPU
AP = application CPU

UEFI runs at single CPU, it is usually initial BSP if it is healthy (UEFI has a capability to switch to different healthy CPU and make it BSP if the intial BSP is unhealthy).
The BSP is allowed to call UEFI services.
At the time of executing our UEFI applications / bootloaders / drivers (e.g. from UEFI shell or as a boot menu = after UEFI is already initialized but OS is not yet loaded) APs are already activated (at least because UEFI had to know how much CPUs are present) but aren't executing anything.
It is possible to use APs in a limited way. It is possible to post a work to them, but they are not allowed to call almost any UEFI service (they are allowed to call only MP WhoAmI).
Studying more about 2 MultiProcessor protocols:
ftp://ftp.heanet.ie/mirrors/sourceforge/e/ed/edk2-startcore/UEFI_Plugfest_2010.pdf
http://www.uefi.org/sites/default/files/resources/PI_Spec_1.3.zip
(MP Protocol is in Vol2 - chapters 13.3, 13.4 - Multiprocessor Services Protocol)

2 slightly different MP protocols exist. Even if none of them is present in your UEFI then it is still possible to activate all APs by own way (sending INIT-SIPI from BSP to APs).
This example attempts to use the suggested newer MP protocol, if it is not found, then the older one (Framework MP Protocol). If none of them found, then send INIT-SIPI from BSP to APs and activate them anyway (in a way like every MP capable OS is doing that).
The example measures CPUID cycles at every CPU in the system (100h iterations at every CPU and taking the best one as a result). CPU number shown in result is obtained from APIC_ID.

For Intel, I didn't implement x2APIC, so the last possible way (INIT-SIPI) is limited upto max. 256 CPUs. Using x2APIC it is possible to handle much more CPUs than 256 (if anyone needs that I may add it).


Description: UEFI MultiProcessor MP example
Download
Filename: UEFI.MultiProcessor_MP_cpuid.zip
Filesize: 27.74 KB
Downloaded: 801 Time(s)

Post 10 Jan 2014, 13:10
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
sid123



Joined: 30 Jul 2013
Posts: 339
Location: Asia, Singapore
sid123 11 Jan 2014, 16:01
If I understand correctly this example turns on all the possible CPU Processors?
It's interesting to see that UEFI can change the BSP if it's damaged.
Nice examples, would use them when EFI/UEFI will finally take over.

_________________
"Those who can make you believe in absurdities can make you commit atrocities" -- Voltaire https://github.com/Benderx2/R3X
XD
Post 11 Jan 2014, 16:01
View user's profile Send private message Reply with quote
Feryno



Joined: 23 Mar 2005
Posts: 514
Location: Czech republic, Slovak republic
Feryno 14 Jan 2014, 09:18
sid123 wrote:
If I understand correctly this example turns on all the possible CPU Processors?

All APs are already activated at the time when we are allowed to execute our applications / drivers (because UEFI already counted all CPUs and prepared MP ACPI tables, then UEFI let APs sleeping in a wait loop and only BSP was allowed to execute the rest). Using MP Protocol it is possible to post some work to APs. If none of the 2 MP protocols is present (I don't believe such UEFI exist) I added manual way of activating APs (sending INIT-SIPI from BSP to APs and all APs then switch from real mode to long mode). MP OSes are doing it via the third way because OSes are doing that quite late - after calling ExitBootServices (then only runtime services stay available).
Post 14 Jan 2014, 09:18
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.