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