2 Memory status code worker in PEI.
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 Module Name: MemoryStatusCodeWorker.c
17 #include "PeiStatusCode.h"
20 Create one memory status code GUID'ed HOB, use PacketIndex
21 to identify the packet.
23 @param PacketIndex Index of records packet.
25 @return Always return pointer of memory status code packet.
29 MEMORY_STATUSCODE_PACKET_HEADER
*
30 CreateMemoryStatusCodePacket (
34 MEMORY_STATUSCODE_PACKET_HEADER
*PacketHeader
;
37 // Build GUID'ed HOB with PCD defined size.
40 (MEMORY_STATUSCODE_PACKET_HEADER
*) BuildGuidHob (
41 &gMemoryStatusCodeRecordGuid
,
42 PcdGet16 (PcdStatusCodeMemorySize
) *
44 sizeof (MEMORY_STATUSCODE_PACKET_HEADER
)
46 ASSERT (PacketHeader
!= NULL
);
48 PacketHeader
->MaxRecordsNumber
= (PcdGet16 (PcdStatusCodeMemorySize
) * 1024)/ sizeof (MEMORY_STATUSCODE_RECORD
);
49 PacketHeader
->PacketIndex
= PacketIndex
;
50 PacketHeader
->RecordIndex
= 0;
58 Initialize memory status code.
59 Create one GUID'ed HOB with PCD defined size. If create required size
60 GUID'ed HOB failed, then ASSERT().
62 @return The function always return EFI_SUCCESS
66 MemoryStatusCodeInitializeWorker (
71 // Create first memory status code GUID'ed HOB.
73 CreateMemoryStatusCodePacket (0);
80 Report status code into GUID'ed HOB..
82 @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
84 @param Value Describes the current status of a hardware or software entity.
85 This included information about the class and subclass that is used to classify the entity
86 as well as an operation. For progress codes, the operation is the current activity.
87 For error codes, it is the exception. For debug codes, it is not defined at this time.
88 Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.
89 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
91 @param Instance The enumeration of a hardware or software entity within the system.
92 A system may contain multiple entities that match a class/subclass pairing.
93 The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,
94 not meaningful, or not relevant. Valid instance numbers start with 1.
96 @return The function always return EFI_SUCCESS.
100 MemoryStatusCodeReportWorker (
101 IN EFI_STATUS_CODE_TYPE CodeType
,
102 IN EFI_STATUS_CODE_VALUE Value
,
107 EFI_PEI_HOB_POINTERS Hob
;
108 MEMORY_STATUSCODE_PACKET_HEADER
*PacketHeader
;
109 MEMORY_STATUSCODE_RECORD
*Record
= NULL
;
110 UINT16 PacketIndex
= 0;;
113 // Journal GUID'ed HOBs to find empty record entry, if found, then save status code in it.
114 // otherwise, create a new GUID'ed HOB.
116 Hob
.Raw
= GetFirstGuidHob (&gMemoryStatusCodeRecordGuid
);
117 while (Hob
.Raw
!= NULL
) {
118 PacketHeader
= (MEMORY_STATUSCODE_PACKET_HEADER
*) GET_GUID_HOB_DATA (Hob
.Guid
);
121 // Check whether pccket is full or not.
123 if (PacketHeader
->RecordIndex
< PacketHeader
->MaxRecordsNumber
) {
124 Record
= (MEMORY_STATUSCODE_RECORD
*) (PacketHeader
+ 1);
125 Record
= &Record
[PacketHeader
->RecordIndex
++];
129 // Cache number of found packet in PacketIndex.
133 Hob
.Raw
= GetNextGuidHob (&gMemoryStatusCodeRecordGuid
, Hob
.Raw
);
136 if (NULL
== Record
) {
138 // In order to save status code , create new packet.
140 PacketHeader
= CreateMemoryStatusCodePacket (PacketIndex
);
142 Record
= (MEMORY_STATUSCODE_RECORD
*) (PacketHeader
+ 1);
143 Record
= &Record
[PacketHeader
->RecordIndex
++];
146 Record
->CodeType
= CodeType
;
147 Record
->Instance
= Instance
;
148 Record
->Value
= Value
;