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