]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Universal/StatusCode/Pei/MemoryStausCodeWorker.c
Update PEIM entry point to follow PEIM entry point.
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / StatusCode / Pei / MemoryStausCodeWorker.c
CommitLineData
ad1a1798 1/** @file\r
2 Memory status code worker in PEI.\r
3\r
ececc2eb 4 Copyright (c) 2006, Intel Corporation\r
5 All rights reserved. This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
ad1a1798 12\r
13 Module Name: MemoryStatusCodeWorker.c\r
14\r
15**/\r
16\r
ad1a1798 17#include "PeiStatusCode.h"\r
18\r
19/**\r
ececc2eb 20 Create one memory status code GUID'ed HOB, use PacketIndex\r
ad1a1798 21 to identify the packet.\r
22\r
ececc2eb 23 @param PacketIndex Index of records packet.\r
24\r
ad1a1798 25 @return Always return pointer of memory status code packet.\r
26\r
27**/\r
ad1a1798 28MEMORY_STATUSCODE_PACKET_HEADER *\r
29CreateMemoryStatusCodePacket (\r
30 UINT16 PacketIndex\r
31 )\r
32{\r
33 MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;\r
34\r
35 //\r
36 // Build GUID'ed HOB with PCD defined size.\r
37 //\r
38 PacketHeader =\r
39 (MEMORY_STATUSCODE_PACKET_HEADER *) BuildGuidHob (\r
ececc2eb 40 &gMemoryStatusCodeRecordGuid,\r
41 PcdGet16 (PcdStatusCodeMemorySize) *\r
ad1a1798 42 1024 +\r
43 sizeof (MEMORY_STATUSCODE_PACKET_HEADER)\r
44 );\r
45 ASSERT (PacketHeader != NULL);\r
46\r
47 PacketHeader->MaxRecordsNumber = (PcdGet16 (PcdStatusCodeMemorySize) * 1024)/ sizeof (MEMORY_STATUSCODE_RECORD);\r
48 PacketHeader->PacketIndex = PacketIndex;\r
49 PacketHeader->RecordIndex = 0;\r
50\r
51 return PacketHeader;\r
52}\r
53\r
54\r
55\r
56/**\r
57 Initialize memory status code.\r
ececc2eb 58 Create one GUID'ed HOB with PCD defined size. If create required size\r
ad1a1798 59 GUID'ed HOB failed, then ASSERT().\r
ececc2eb 60\r
ad1a1798 61 @return The function always return EFI_SUCCESS\r
62\r
63**/\r
64EFI_STATUS\r
65MemoryStatusCodeInitializeWorker (\r
66 VOID\r
67 )\r
68{\r
69 //\r
70 // Create first memory status code GUID'ed HOB.\r
71 //\r
72 CreateMemoryStatusCodePacket (0);\r
73\r
74 return EFI_SUCCESS;\r
75}\r
76\r
77\r
78/**\r
79 Report status code into GUID'ed HOB..\r
ececc2eb 80\r
ad1a1798 81 @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
ececc2eb 82\r
83 @param Value Describes the current status of a hardware or software entity.\r
84 This included information about the class and subclass that is used to classify the entity\r
85 as well as an operation. For progress codes, the operation is the current activity.\r
86 For error codes, it is the exception. For debug codes, it is not defined at this time.\r
87 Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.\r
ad1a1798 88 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
ececc2eb 89\r
90 @param Instance The enumeration of a hardware or software entity within the system.\r
91 A system may contain multiple entities that match a class/subclass pairing.\r
92 The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,\r
ad1a1798 93 not meaningful, or not relevant. Valid instance numbers start with 1.\r
ececc2eb 94\r
ad1a1798 95 @return The function always return EFI_SUCCESS.\r
96\r
97**/\r
98EFI_STATUS\r
99MemoryStatusCodeReportWorker (\r
100 IN EFI_STATUS_CODE_TYPE CodeType,\r
101 IN EFI_STATUS_CODE_VALUE Value,\r
102 IN UINT32 Instance\r
103 )\r
104{\r
105\r
106 EFI_PEI_HOB_POINTERS Hob;\r
107 MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;\r
108 MEMORY_STATUSCODE_RECORD *Record = NULL;\r
109 UINT16 PacketIndex = 0;;\r
110\r
111 //\r
112 // Journal GUID'ed HOBs to find empty record entry, if found, then save status code in it.\r
113 // otherwise, create a new GUID'ed HOB.\r
114 //\r
115 Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);\r
116 while (Hob.Raw != NULL) {\r
117 PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);\r
118\r
119 //\r
120 // Check whether pccket is full or not.\r
121 //\r
122 if (PacketHeader->RecordIndex < PacketHeader->MaxRecordsNumber) {\r
123 Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r
124 Record = &Record[PacketHeader->RecordIndex++];\r
125 break;\r
126 }\r
127 //\r
128 // Cache number of found packet in PacketIndex.\r
129 //\r
130 PacketIndex++;\r
131\r
132 Hob.Raw = GetNextGuidHob (&gMemoryStatusCodeRecordGuid, Hob.Raw);\r
133 }\r
134\r
135 if (NULL == Record) {\r
136 //\r
ececc2eb 137 // In order to save status code , create new packet.\r
ad1a1798 138 //\r
139 PacketHeader = CreateMemoryStatusCodePacket (PacketIndex);\r
140\r
ececc2eb 141 Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r
ad1a1798 142 Record = &Record[PacketHeader->RecordIndex++];\r
143 }\r
144\r
145 Record->CodeType = CodeType;\r
146 Record->Instance = Instance;\r
147 Record->Value = Value;\r
148\r
149 return EFI_SUCCESS;\r
150}\r
bcd70414 151\r