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