]>
Commit | Line | Data |
---|---|---|
88da06ca MX |
1 | /** @file\r |
2 | CPU MP Initialize Library common functions for Td guest.\r | |
3 | \r | |
4 | Copyright (c) 2020 - 2022, Intel Corporation. All rights reserved.<BR>\r | |
5 | \r | |
6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
7 | \r | |
8 | **/\r | |
9 | \r | |
10 | #include "MpLib.h"\r | |
11 | #include "MpIntelTdx.h"\r | |
12 | \r | |
13 | /**\r | |
14 | Gets detailed MP-related information on the requested processor at the\r | |
15 | instant this call is made. This service may only be called from the BSP.\r | |
16 | \r | |
17 | In current stage only the BSP is workable. So ProcessorNumber should be 0.\r | |
18 | \r | |
19 | @param[in] ProcessorNumber The handle number of processor.\r | |
20 | @param[out] ProcessorInfoBuffer A pointer to the buffer where information for\r | |
21 | the requested processor is deposited.\r | |
22 | @param[out] HealthData Return processor health data.\r | |
23 | \r | |
24 | @retval EFI_SUCCESS Processor information was returned.\r | |
25 | @retval EFI_DEVICE_ERROR The calling processor is an AP.\r | |
26 | @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL or ProcessorNumber is not 0.\r | |
27 | @retval EFI_NOT_FOUND The processor with the handle specified by\r | |
28 | ProcessorNumber does not exist in the platform.\r | |
29 | @retval EFI_NOT_READY MP Initialize Library is not initialized.\r | |
30 | \r | |
31 | **/\r | |
32 | EFI_STATUS\r | |
33 | TdxMpInitLibGetProcessorInfo (\r | |
34 | IN UINTN ProcessorNumber,\r | |
35 | OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer,\r | |
36 | OUT EFI_HEALTH_FLAGS *HealthData OPTIONAL\r | |
37 | )\r | |
38 | {\r | |
39 | UINTN OriginalProcessorNumber;\r | |
40 | \r | |
41 | //\r | |
42 | // Lower 24 bits contains the actual processor number.\r | |
43 | //\r | |
44 | OriginalProcessorNumber = ProcessorNumber;\r | |
45 | ProcessorNumber &= BIT24 - 1;\r | |
46 | \r | |
47 | if ((ProcessorInfoBuffer == NULL) || (ProcessorNumber != 0)) {\r | |
48 | return EFI_INVALID_PARAMETER;\r | |
49 | }\r | |
50 | \r | |
51 | ProcessorInfoBuffer->ProcessorId = 0;\r | |
52 | ProcessorInfoBuffer->StatusFlag = PROCESSOR_AS_BSP_BIT | PROCESSOR_ENABLED_BIT;\r | |
53 | ZeroMem (&ProcessorInfoBuffer->Location, sizeof (EFI_CPU_PHYSICAL_LOCATION));\r | |
54 | \r | |
55 | if ((OriginalProcessorNumber & CPU_V2_EXTENDED_TOPOLOGY) != 0) {\r | |
56 | ZeroMem (&ProcessorInfoBuffer->ExtendedInformation.Location2, sizeof (EFI_CPU_PHYSICAL_LOCATION2));\r | |
57 | }\r | |
58 | \r | |
59 | if (HealthData != NULL) {\r | |
60 | HealthData->Uint32 = 0;\r | |
61 | }\r | |
62 | \r | |
63 | return EFI_SUCCESS;\r | |
64 | }\r | |
65 | \r | |
66 | /**\r | |
67 | Retrieves the number of logical processor in the platform and the number of\r | |
68 | those logical processors that are enabled on this boot. This service may only\r | |
69 | be called from the BSP.\r | |
70 | \r | |
71 | @param[out] NumberOfProcessors Pointer to the total number of logical\r | |
72 | processors in the system, including the BSP\r | |
73 | and disabled APs.\r | |
74 | @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical\r | |
75 | processors that exist in system, including\r | |
76 | the BSP.\r | |
77 | \r | |
78 | @retval EFI_SUCCESS The number of logical processors and enabled\r | |
79 | logical processors was retrieved.\r | |
80 | @retval EFI_DEVICE_ERROR The calling processor is an AP.\r | |
81 | @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL and NumberOfEnabledProcessors\r | |
82 | is NULL.\r | |
83 | @retval EFI_NOT_READY MP Initialize Library is not initialized.\r | |
84 | \r | |
85 | **/\r | |
86 | EFI_STATUS\r | |
87 | TdxMpInitLibGetNumberOfProcessors (\r | |
88 | OUT UINTN *NumberOfProcessors, OPTIONAL\r | |
89 | OUT UINTN *NumberOfEnabledProcessors OPTIONAL\r | |
90 | )\r | |
91 | {\r | |
92 | ASSERT (NumberOfProcessors != NULL || NumberOfEnabledProcessors != NULL);\r | |
93 | //\r | |
94 | // In current stage only the BSP is workable. So NumberOfProcessors\r | |
95 | // & NumberOfEnableddProcessors are both 1.\r | |
96 | //\r | |
97 | if (NumberOfProcessors != NULL) {\r | |
98 | *NumberOfProcessors = 1;\r | |
99 | }\r | |
100 | \r | |
101 | if (NumberOfEnabledProcessors != NULL) {\r | |
102 | *NumberOfEnabledProcessors = 1;\r | |
103 | }\r | |
104 | \r | |
105 | return EFI_SUCCESS;\r | |
106 | }\r |