]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/Library/CpuCacheInfoLib/PeiCpuCacheInfoLib.c
UefiCpuPkg: Apply uncrustify changes
[mirror_edk2.git] / UefiCpuPkg / Library / CpuCacheInfoLib / PeiCpuCacheInfoLib.c
CommitLineData
83facfd1
LY
1/** @file\r
2 Provides cache info for each package, core type, cache level and cache type.\r
3\r
4 Copyright (c) 2020 Intel Corporation. All rights reserved.<BR>\r
5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
6\r
7**/\r
8\r
9#include <PiPei.h>\r
10#include <Library/BaseLib.h>\r
11#include <Library/DebugLib.h>\r
12#include <Library/PeiServicesLib.h>\r
13#include <Library/PeiServicesTablePointerLib.h>\r
14#include <Library/CpuCacheInfoLib.h>\r
15#include <InternalCpuCacheInfoLib.h>\r
16\r
17/**\r
18 Get EDKII_PEI_MP_SERVICES2_PPI pointer.\r
19\r
20 @param[out] MpServices A pointer to the buffer where EDKII_PEI_MP_SERVICES2_PPI is stored\r
21\r
22 @retval EFI_SUCCESS EDKII_PEI_MP_SERVICES2_PPI interface is returned\r
23 @retval EFI_NOT_FOUND EDKII_PEI_MP_SERVICES2_PPI interface is not found\r
24**/\r
25EFI_STATUS\r
26CpuCacheInfoGetMpServices (\r
053e878b 27 OUT MP_SERVICES *MpServices\r
83facfd1
LY
28 )\r
29{\r
053e878b 30 EFI_STATUS Status;\r
83facfd1
LY
31\r
32 Status = PeiServicesLocatePpi (&gEdkiiPeiMpServices2PpiGuid, 0, NULL, (VOID **)&MpServices->Ppi);\r
33 ASSERT_EFI_ERROR (Status);\r
34\r
35 return Status;\r
36}\r
37\r
38/**\r
39 Activate all of the logical processors.\r
40\r
41 @param[in] MpServices MP_SERVICES structure.\r
42 @param[in] Procedure A pointer to the function to be run on enabled logical processors.\r
43 @param[in] ProcedureArgument The parameter passed into Procedure for all enabled logical processors.\r
44**/\r
45VOID\r
46CpuCacheInfoStartupAllCPUs (\r
053e878b
MK
47 IN MP_SERVICES MpServices,\r
48 IN EFI_AP_PROCEDURE Procedure,\r
49 IN VOID *ProcedureArgument\r
83facfd1
LY
50 )\r
51{\r
053e878b 52 EFI_STATUS Status;\r
83facfd1
LY
53\r
54 Status = MpServices.Ppi->StartupAllCPUs (MpServices.Ppi, Procedure, 0, ProcedureArgument);\r
55 ASSERT_EFI_ERROR (Status);\r
56}\r
57\r
58/**\r
59 Get detailed information of the requested logical processor.\r
60\r
61 @param[in] MpServices MP_SERVICES structure.\r
62 @param[in] ProcessorNum The requested logical processor number.\r
63 @param[out] ProcessorInfo A pointer to the buffer where the processor information is stored\r
64**/\r
65VOID\r
66CpuCacheInfoGetProcessorInfo (\r
053e878b
MK
67 IN MP_SERVICES MpServices,\r
68 IN UINTN ProcessorNum,\r
69 OUT EFI_PROCESSOR_INFORMATION *ProcessorInfo\r
83facfd1
LY
70 )\r
71{\r
053e878b 72 EFI_STATUS Status;\r
83facfd1
LY
73\r
74 Status = MpServices.Ppi->GetProcessorInfo (MpServices.Ppi, ProcessorNum, ProcessorInfo);\r
75 ASSERT_EFI_ERROR (Status);\r
76}\r
77\r
78/**\r
79 Get the logical processor number.\r
80\r
81 @param[in] MpServices MP_SERVICES structure.\r
82\r
83 @retval Return the logical processor number.\r
84**/\r
85UINT32\r
86CpuCacheInfoWhoAmI (\r
053e878b 87 IN MP_SERVICES MpServices\r
83facfd1
LY
88 )\r
89{\r
053e878b
MK
90 EFI_STATUS Status;\r
91 UINTN ProcessorNum;\r
83facfd1
LY
92\r
93 Status = MpServices.Ppi->WhoAmI (MpServices.Ppi, &ProcessorNum);\r
94 ASSERT_EFI_ERROR (Status);\r
95\r
96 return (UINT32)ProcessorNum;\r
97}\r
98\r
99/**\r
100 Get the total number of logical processors in the platform.\r
101\r
102 @param[in] MpServices MP_SERVICES structure.\r
103\r
104 @retval Return the total number of logical processors.\r
105**/\r
106UINT32\r
107CpuCacheInfoGetNumberOfProcessors (\r
053e878b 108 IN MP_SERVICES MpServices\r
83facfd1
LY
109 )\r
110{\r
053e878b
MK
111 EFI_STATUS Status;\r
112 UINTN NumberOfProcessor;\r
113 UINTN NumberOfEnabledProcessor;\r
83facfd1
LY
114\r
115 Status = MpServices.Ppi->GetNumberOfProcessors (MpServices.Ppi, &NumberOfProcessor, &NumberOfEnabledProcessor);\r
116 ASSERT_EFI_ERROR (Status);\r
117\r
118 return (UINT32)NumberOfProcessor;\r
119}\r