<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	「Step to UEFI (72） &#8212;&#8211; MP_Service_Protocol 获得CPU信息」的评论	</title>
	<atom:link href="https://www.lab-z.com/mpscpu/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.lab-z.com/mpscpu/</link>
	<description></description>
	<lastBuildDate>Thu, 10 Dec 2020 05:48:36 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>
	<item>
		<title>
		评论者：ziv2013		</title>
		<link>https://www.lab-z.com/mpscpu/#comment-96925</link>

		<dc:creator><![CDATA[ziv2013]]></dc:creator>
		<pubDate>Thu, 10 Dec 2020 05:48:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.lab-z.com/?p=3777#comment-96925</guid>

					<description><![CDATA[回复给 &lt;a href=&quot;https://www.lab-z.com/mpscpu/#comment-96923&quot;&gt;James&lt;/a&gt;。

学习了，谢谢！]]></description>
			<content:encoded><![CDATA[<p>回复给 <a href="https://www.lab-z.com/mpscpu/#comment-96923">James</a>。</p>
<p>学习了，谢谢！</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		评论者：James		</title>
		<link>https://www.lab-z.com/mpscpu/#comment-96923</link>

		<dc:creator><![CDATA[James]]></dc:creator>
		<pubDate>Thu, 10 Dec 2020 05:07:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.lab-z.com/?p=3777#comment-96923</guid>

					<description><![CDATA[感謝博主分享，
在.c 中
EFI_GUID gEfiMpServiceProtocolGuid = {0x3fdda605, 0xa76e, 0x4f46, {0xad, 0x29, 0x12, 0xf4, 0x53, 0x1b, 0x3d, 0x08}}; 這個GUID 可以在.inf 中宣告即可:
[Protocols]
  gEfiMpServiceProtocolGuid
這個 GUID 已經在 MdePkg.dec 中定義，而 MdePkg 已包在 .inf 的 packages 中]]></description>
			<content:encoded><![CDATA[<p>感謝博主分享，<br />
在.c 中<br />
EFI_GUID gEfiMpServiceProtocolGuid = {0x3fdda605, 0xa76e, 0x4f46, {0xad, 0x29, 0x12, 0xf4, 0x53, 0x1b, 0x3d, 0x08}}; 這個GUID 可以在.inf 中宣告即可:<br />
[Protocols]<br />
  gEfiMpServiceProtocolGuid<br />
這個 GUID 已經在 MdePkg.dec 中定義，而 MdePkg 已包在 .inf 的 packages 中</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		评论者：Bain		</title>
		<link>https://www.lab-z.com/mpscpu/#comment-92479</link>

		<dc:creator><![CDATA[Bain]]></dc:creator>
		<pubDate>Sat, 06 Jun 2020 15:56:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.lab-z.com/?p=3777#comment-92479</guid>

					<description><![CDATA[今天刚遇到了和博主同样的问题，当时无奈只得将APP改为DXE才能编过。终于在这就得到答案了。感谢博主，又学习了。]]></description>
			<content:encoded><![CDATA[<p>今天刚遇到了和博主同样的问题，当时无奈只得将APP改为DXE才能编过。终于在这就得到答案了。感谢博主，又学习了。</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		评论者：ziv2013		</title>
		<link>https://www.lab-z.com/mpscpu/#comment-91711</link>

		<dc:creator><![CDATA[ziv2013]]></dc:creator>
		<pubDate>Wed, 29 Apr 2020 12:00:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.lab-z.com/?p=3777#comment-91711</guid>

					<description><![CDATA[回复给 &lt;a href=&quot;https://www.lab-z.com/mpscpu/#comment-91708&quot;&gt;Gabi&lt;/a&gt;。

You can compare the test result with CPU-z under OS. BIOS may be return an error result as this Protocol is not an important one.

And if you just want to get the number of CPU cores, you may study the usage of CPUID.]]></description>
			<content:encoded><![CDATA[<p>回复给 <a href="https://www.lab-z.com/mpscpu/#comment-91708">Gabi</a>。</p>
<p>You can compare the test result with CPU-z under OS. BIOS may be return an error result as this Protocol is not an important one.</p>
<p>And if you just want to get the number of CPU cores, you may study the usage of CPUID.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		评论者：Gabi		</title>
		<link>https://www.lab-z.com/mpscpu/#comment-91709</link>

		<dc:creator><![CDATA[Gabi]]></dc:creator>
		<pubDate>Wed, 29 Apr 2020 10:48:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.lab-z.com/?p=3777#comment-91709</guid>

					<description><![CDATA[#include  
#include  
#include  
#include  
#include  
Seem like some parts of text doesn&#039;t appear in previous message.
Anyway if this get same result I write again. what is at include
Uefi.h
Library/UefiLib.h
Library/ShellCEntryLib.h
Pi/PiDxeCis.h
Include/Protocol/FrameworkMpService.h]]></description>
			<content:encoded><![CDATA[<p>#include<br />
#include<br />
#include<br />
#include<br />
#include<br />
Seem like some parts of text doesn&#8217;t appear in previous message.<br />
Anyway if this get same result I write again. what is at include<br />
Uefi.h<br />
Library/UefiLib.h<br />
Library/ShellCEntryLib.h<br />
Pi/PiDxeCis.h<br />
Include/Protocol/FrameworkMpService.h</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		评论者：Gabi		</title>
		<link>https://www.lab-z.com/mpscpu/#comment-91708</link>

		<dc:creator><![CDATA[Gabi]]></dc:creator>
		<pubDate>Wed, 29 Apr 2020 10:39:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.lab-z.com/?p=3777#comment-91708</guid>

					<description><![CDATA[Hello again
Thanks for answer.
Indeed under windows works.
But my HP laptop Insyde 3.5 BIOS use an deprecated protocol 
 FRAMEWORK_EFI_MP_SERVICES_PROTOCOL_GUID:[0xf33261e7, 0x23cb, 0x11d5, 0xbd, 0x5c, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81]
Using your code as template I made this,don&#039;t know if is correct but result is 
Number of Processors 4
Max number of Processors 8
Number of Enabled Processors 4
RendezvousIntNumber 0
RendezvousProcLength 4096
Processor #0 ACPI Apic ID = 0, Enabled = 1, Designation = 1, Health = 0, PackageNumber = 0, NumberOfCores = 8, NumberOfThreads = 2, ProcessorPALCompatibilityFlags = 2, ProcessorTestMask = 0 
Processor #1 ACPI Apic ID = 1, Enabled = 1, Designation = 0, Health = 0, PackageNumber = 0, NumberOfCores = 8, NumberOfThreads = 2, ProcessorPALCompatibilityFlags = 2, ProcessorTestMask = 0 
Processor #2 ACPI Apic ID = 4, Enabled = 1, Designation = 0, Health = 0, PackageNumber = 0, NumberOfCores = 8, NumberOfThreads = 2, ProcessorPALCompatibilityFlags = 2, ProcessorTestMask = 0 
Processor #3 ACPI Apic ID = 5, Enabled = 1, Designation = 0, Health = 0, PackageNumber = 0, NumberOfCores = 8, NumberOfThreads = 2, ProcessorPALCompatibilityFlags = 2, ProcessorTestMask = 0 

I did something wrong since it say 8 cores.
On some generation of HP laptops there is a problem with some OS, doesn&#039;t detect right all cores and complain about LAPIC,So I try to investigate what&#039;s the problem not all cores enabled by BIOS or LAPIC doesn&#039;t configured properly.
Here is what I did

#include  
#include  
#include  
#include  
#include  

EFI_GUID  gFrameworkEfiMpServiceProtocolGuid = { 0xf33261e7, 0x23cb, 0x11d5, 
						{ 0xbd, 0x5c, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 }};
  
extern EFI_BOOT_SERVICES         *gBS;

int
EFIAPI
main (
  IN int Argc,
  IN CHAR16 **Argv
  )
{
	EFI_STATUS	Status;
	FRAMEWORK_EFI_MP_SERVICES_PROTOCOL	*MP=NULL;
	UINTN   i;	
	UINTN	NumberOfCPUs;
	UINTN	NumberOfEnabledCPUs;
	UINTN	BufferLenght;
	UINTN	MaximumNumberOfCPUs;
	UINTN	RendezvousIntNumber;
	UINTN	RendezvousProcLength;
	EFI_MP_PROC_CONTEXT	ProcessorContextBuffer;
	
	//Get MP_Service Protocol
	Status = gBS-&#062;LocateProtocol (&#038;gFrameworkEfiMpServiceProtocolGuid, NULL, (VOID**)&#038;MP);
	if (EFI_ERROR (Status)) {
		Print(L&quot;Unable to initialize MP protocol interface!&quot;);
		return EFI_UNSUPPORTED;
	}
	
	// Determine number of processors
	Status = MP-&#062;GetGeneralMPInfo( MP, &#038;NumberOfCPUs , &#038;MaximumNumberOfCPUs , &#038;NumberOfEnabledCPUs , &#038;RendezvousIntNumber , &#038;RendezvousProcLength );
	
	if (EFI_ERROR (Status))
	{
		Print( L&quot;MP-&#062;GetNumEnabledProcessors:Unable to determine number of processors\n&quot;) ;
		return EFI_UNSUPPORTED;
	}	
	Print(L&quot;Number of Processors %d\n&quot;,NumberOfCPUs);
	Print(L&quot;Max number of Processors %d\n&quot;,MaximumNumberOfCPUs);
	Print(L&quot;Number of Enabled Processors %d\n&quot;,NumberOfEnabledCPUs);
	Print(L&quot;RendezvousIntNumber %d\n&quot;,RendezvousIntNumber);
	Print(L&quot;RendezvousProcLength %d\n&quot;,RendezvousProcLength);
	
	//Get more information by GetProcessorContext
	for (i=0;iGetProcessorContext(MP, i , &#038;BufferLenght , &#038;ProcessorContextBuffer);
		
		Print( L&quot;Processor #%d ACPI Apic ID = %lX, Enabled = %x, Designation = %x, Health = %x, PackageNumber = %x, NumberOfCores = %x, NumberOfThreads = %x, ProcessorPALCompatibilityFlags = %x, ProcessorTestMask = %x \n&quot;, 
					i,
					ProcessorContextBuffer.ApicID, 
					ProcessorContextBuffer.Enabled,
					ProcessorContextBuffer.Designation,
					ProcessorContextBuffer.Health,
					ProcessorContextBuffer.PackageNumber,
					ProcessorContextBuffer.NumberOfCores,
					ProcessorContextBuffer.NumberOfThreads,
					ProcessorContextBuffer.ProcessorPALCompatibilityFlags,
					ProcessorContextBuffer.ProcessorTestMask);
	}
	
	return EFI_SUCCESS;
}]]></description>
			<content:encoded><![CDATA[<p>Hello again<br />
Thanks for answer.<br />
Indeed under windows works.<br />
But my HP laptop Insyde 3.5 BIOS use an deprecated protocol<br />
 FRAMEWORK_EFI_MP_SERVICES_PROTOCOL_GUID:[0xf33261e7, 0x23cb, 0x11d5, 0xbd, 0x5c, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81]<br />
Using your code as template I made this,don&#8217;t know if is correct but result is<br />
Number of Processors 4<br />
Max number of Processors 8<br />
Number of Enabled Processors 4<br />
RendezvousIntNumber 0<br />
RendezvousProcLength 4096<br />
Processor #0 ACPI Apic ID = 0, Enabled = 1, Designation = 1, Health = 0, PackageNumber = 0, NumberOfCores = 8, NumberOfThreads = 2, ProcessorPALCompatibilityFlags = 2, ProcessorTestMask = 0<br />
Processor #1 ACPI Apic ID = 1, Enabled = 1, Designation = 0, Health = 0, PackageNumber = 0, NumberOfCores = 8, NumberOfThreads = 2, ProcessorPALCompatibilityFlags = 2, ProcessorTestMask = 0<br />
Processor #2 ACPI Apic ID = 4, Enabled = 1, Designation = 0, Health = 0, PackageNumber = 0, NumberOfCores = 8, NumberOfThreads = 2, ProcessorPALCompatibilityFlags = 2, ProcessorTestMask = 0<br />
Processor #3 ACPI Apic ID = 5, Enabled = 1, Designation = 0, Health = 0, PackageNumber = 0, NumberOfCores = 8, NumberOfThreads = 2, ProcessorPALCompatibilityFlags = 2, ProcessorTestMask = 0 </p>
<p>I did something wrong since it say 8 cores.<br />
On some generation of HP laptops there is a problem with some OS, doesn&#8217;t detect right all cores and complain about LAPIC,So I try to investigate what&#8217;s the problem not all cores enabled by BIOS or LAPIC doesn&#8217;t configured properly.<br />
Here is what I did</p>
<p>#include<br />
#include<br />
#include<br />
#include<br />
#include  </p>
<p>EFI_GUID  gFrameworkEfiMpServiceProtocolGuid = { 0xf33261e7, 0x23cb, 0x11d5,<br />
						{ 0xbd, 0x5c, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 }};</p>
<p>extern EFI_BOOT_SERVICES         *gBS;</p>
<p>int<br />
EFIAPI<br />
main (<br />
  IN int Argc,<br />
  IN CHAR16 **Argv<br />
  )<br />
{<br />
	EFI_STATUS	Status;<br />
	FRAMEWORK_EFI_MP_SERVICES_PROTOCOL	*MP=NULL;<br />
	UINTN   i;<br />
	UINTN	NumberOfCPUs;<br />
	UINTN	NumberOfEnabledCPUs;<br />
	UINTN	BufferLenght;<br />
	UINTN	MaximumNumberOfCPUs;<br />
	UINTN	RendezvousIntNumber;<br />
	UINTN	RendezvousProcLength;<br />
	EFI_MP_PROC_CONTEXT	ProcessorContextBuffer;</p>
<p>	//Get MP_Service Protocol<br />
	Status = gBS-&gt;LocateProtocol (&amp;gFrameworkEfiMpServiceProtocolGuid, NULL, (VOID**)&amp;MP);<br />
	if (EFI_ERROR (Status)) {<br />
		Print(L&#8221;Unable to initialize MP protocol interface!&#8221;);<br />
		return EFI_UNSUPPORTED;<br />
	}</p>
<p>	// Determine number of processors<br />
	Status = MP-&gt;GetGeneralMPInfo( MP, &amp;NumberOfCPUs , &amp;MaximumNumberOfCPUs , &amp;NumberOfEnabledCPUs , &amp;RendezvousIntNumber , &amp;RendezvousProcLength );</p>
<p>	if (EFI_ERROR (Status))<br />
	{<br />
		Print( L&#8221;MP-&gt;GetNumEnabledProcessors:Unable to determine number of processors\n&#8221;) ;<br />
		return EFI_UNSUPPORTED;<br />
	}<br />
	Print(L&#8221;Number of Processors %d\n&#8221;,NumberOfCPUs);<br />
	Print(L&#8221;Max number of Processors %d\n&#8221;,MaximumNumberOfCPUs);<br />
	Print(L&#8221;Number of Enabled Processors %d\n&#8221;,NumberOfEnabledCPUs);<br />
	Print(L&#8221;RendezvousIntNumber %d\n&#8221;,RendezvousIntNumber);<br />
	Print(L&#8221;RendezvousProcLength %d\n&#8221;,RendezvousProcLength);</p>
<p>	//Get more information by GetProcessorContext<br />
	for (i=0;iGetProcessorContext(MP, i , &amp;BufferLenght , &amp;ProcessorContextBuffer);</p>
<p>		Print( L&#8221;Processor #%d ACPI Apic ID = %lX, Enabled = %x, Designation = %x, Health = %x, PackageNumber = %x, NumberOfCores = %x, NumberOfThreads = %x, ProcessorPALCompatibilityFlags = %x, ProcessorTestMask = %x \n&#8221;,<br />
					i,<br />
					ProcessorContextBuffer.ApicID,<br />
					ProcessorContextBuffer.Enabled,<br />
					ProcessorContextBuffer.Designation,<br />
					ProcessorContextBuffer.Health,<br />
					ProcessorContextBuffer.PackageNumber,<br />
					ProcessorContextBuffer.NumberOfCores,<br />
					ProcessorContextBuffer.NumberOfThreads,<br />
					ProcessorContextBuffer.ProcessorPALCompatibilityFlags,<br />
					ProcessorContextBuffer.ProcessorTestMask);<br />
	}</p>
<p>	return EFI_SUCCESS;<br />
}</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		评论者：ziv2013		</title>
		<link>https://www.lab-z.com/mpscpu/#comment-91698</link>

		<dc:creator><![CDATA[ziv2013]]></dc:creator>
		<pubDate>Wed, 29 Apr 2020 01:02:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.lab-z.com/?p=3777#comment-91698</guid>

					<description><![CDATA[回复给 &lt;a href=&quot;https://www.lab-z.com/mpscpu/#comment-91682&quot;&gt;Gabi&lt;/a&gt;。

Hi, 

My suggestion is to build with Windows + VS2015, eg: you can install a virtualbox under Ubuntu.
As EDK2 is developed with Windows Tools Chain, it would get errors when you switch to Linux enviroment.

And you can try latest release https://github.com/tianocore/edk2/releases/tag/edk2-stable202002 . 
It may have better support for Linux.]]></description>
			<content:encoded><![CDATA[<p>回复给 <a href="https://www.lab-z.com/mpscpu/#comment-91682">Gabi</a>。</p>
<p>Hi, </p>
<p>My suggestion is to build with Windows + VS2015, eg: you can install a virtualbox under Ubuntu.<br />
As EDK2 is developed with Windows Tools Chain, it would get errors when you switch to Linux enviroment.</p>
<p>And you can try latest release <a href="https://github.com/tianocore/edk2/releases/tag/edk2-stable202002" rel="nofollow ugc">https://github.com/tianocore/edk2/releases/tag/edk2-stable202002</a> .<br />
It may have better support for Linux.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		评论者：Gabi		</title>
		<link>https://www.lab-z.com/mpscpu/#comment-91682</link>

		<dc:creator><![CDATA[Gabi]]></dc:creator>
		<pubDate>Tue, 28 Apr 2020 08:19:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.lab-z.com/?p=3777#comment-91682</guid>

					<description><![CDATA[Hello 
First let me thank you for your work and examples.
Second,I don&#039;t know any programming language so I ask for help.
Try to build x64 version but no luck yet.
Used Ubuntu few version (14 16 and 18) and few version of EDK2 but allway get these errors.
For two of them I find a workaround but one still remain.
Can you provide a fix?
Thankyou.
 
Library error
error 4000: Instance of library class [LibC] is not found
in [/home/G62/src/edk2/MPTest1/MPTest1.inf] [X64]
-solved by adding &quot;!include StdLib\StdLib.inc&quot;

main error
/home/G62/src/edk2/MPTest1/MPTest1.c:14:1: error: second argument of ‘main’ should be ‘char **’ [-Werror=main]
 main ( ...

return EFI_UNSUPPORTED error
/home/G62/src/edk2/MdePkg/Include/Base.h:927:38: error: overflow in implicit constant conversion [-Werror=overflow]
 #define ENCODE_ERROR(StatusCode)     ((RETURN_STATUS)(MAX_BIT &#124; (StatusCode)))
-quick fix replaced return EFI_UNSUPPORTED with return EFI_SUCCESS]]></description>
			<content:encoded><![CDATA[<p>Hello<br />
First let me thank you for your work and examples.<br />
Second,I don&#8217;t know any programming language so I ask for help.<br />
Try to build x64 version but no luck yet.<br />
Used Ubuntu few version (14 16 and 18) and few version of EDK2 but allway get these errors.<br />
For two of them I find a workaround but one still remain.<br />
Can you provide a fix?<br />
Thankyou.</p>
<p>Library error<br />
error 4000: Instance of library class [LibC] is not found<br />
in [/home/G62/src/edk2/MPTest1/MPTest1.inf] [X64]<br />
-solved by adding &#8220;!include StdLib\StdLib.inc&#8221;</p>
<p>main error<br />
/home/G62/src/edk2/MPTest1/MPTest1.c:14:1: error: second argument of ‘main’ should be ‘char **’ [-Werror=main]<br />
 main ( &#8230;</p>
<p>return EFI_UNSUPPORTED error<br />
/home/G62/src/edk2/MdePkg/Include/Base.h:927:38: error: overflow in implicit constant conversion [-Werror=overflow]<br />
 #define ENCODE_ERROR(StatusCode)     ((RETURN_STATUS)(MAX_BIT | (StatusCode)))<br />
-quick fix replaced return EFI_UNSUPPORTED with return EFI_SUCCESS</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		评论者：ziv2013		</title>
		<link>https://www.lab-z.com/mpscpu/#comment-80468</link>

		<dc:creator><![CDATA[ziv2013]]></dc:creator>
		<pubDate>Mon, 30 Dec 2019 00:54:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.lab-z.com/?p=3777#comment-80468</guid>

					<description><![CDATA[回复给 &lt;a href=&quot;https://www.lab-z.com/mpscpu/#comment-80453&quot;&gt;Marco&lt;/a&gt;。

谢谢哈，我补充上。]]></description>
			<content:encoded><![CDATA[<p>回复给 <a href="https://www.lab-z.com/mpscpu/#comment-80453">Marco</a>。</p>
<p>谢谢哈，我补充上。</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		评论者：Marco		</title>
		<link>https://www.lab-z.com/mpscpu/#comment-80453</link>

		<dc:creator><![CDATA[Marco]]></dc:creator>
		<pubDate>Sun, 29 Dec 2019 09:36:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.lab-z.com/?p=3777#comment-80453</guid>

					<description><![CDATA[因为缺少了PiDxe.h这个头文件，所以才报的问题。]]></description>
			<content:encoded><![CDATA[<p>因为缺少了PiDxe.h这个头文件，所以才报的问题。</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
