2 PEI memory status code worker.
4 Copyright (c) 2006 - 2009, 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.
15 #include "StatusCodePei.h"
18 Worker function to create one memory status code GUID'ed HOB,
19 using PacketIndex to identify the packet.
21 @param PacketIndex Index of records packet.
23 @return Pointer to the memory status code packet.
26 MEMORY_STATUSCODE_PACKET_HEADER
*
27 CreateMemoryStatusCodePacket (
31 MEMORY_STATUSCODE_PACKET_HEADER
*PacketHeader
;
34 // Build GUID'ed HOB with PCD defined size.
36 PacketHeader
= BuildGuidHob (
37 &gMemoryStatusCodeRecordGuid
,
38 PcdGet16 (PcdStatusCodeMemorySize
) * 1024 + sizeof (MEMORY_STATUSCODE_PACKET_HEADER
)
40 ASSERT (PacketHeader
!= NULL
);
42 PacketHeader
->MaxRecordsNumber
= (PcdGet16 (PcdStatusCodeMemorySize
) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD
);
43 PacketHeader
->PacketIndex
= PacketIndex
;
44 PacketHeader
->RecordIndex
= 0;
50 Create the first memory status code GUID'ed HOB as initialization for memory status code worker.
52 @retval EFI_SUCCESS The GUID'ed HOB is created successfully.
56 MemoryStatusCodeInitializeWorker (
61 // Create first memory status code GUID'ed HOB.
63 CreateMemoryStatusCodePacket (0);
70 Report status code into GUID'ed HOB.
72 This function reports status code into GUID'ed HOB. If not all packets are full, then
73 write status code into available entry. Otherwise, create a new packet for it.
75 @param CodeType Indicates the type of status code being reported.
76 @param Value Describes the current status of a hardware or
77 software entity. This includes information about the class and
78 subclass that is used to classify the entity as well as an operation.
79 For progress codes, the operation is the current activity.
80 For error codes, it is the exception.For debug codes,it is not defined at this time.
81 @param Instance The enumeration of a hardware or software entity within
82 the system. A system may contain multiple entities that match a class/subclass
83 pairing. The instance differentiates between them. An instance of 0 indicates
84 that instance information is unavailable, not meaningful, or not relevant.
85 Valid instance numbers start with 1.
87 @retval EFI_SUCCESS The function always return EFI_SUCCESS.
91 MemoryStatusCodeReportWorker (
92 IN EFI_STATUS_CODE_TYPE CodeType
,
93 IN EFI_STATUS_CODE_VALUE Value
,
98 EFI_PEI_HOB_POINTERS Hob
;
99 MEMORY_STATUSCODE_PACKET_HEADER
*PacketHeader
;
100 MEMORY_STATUSCODE_RECORD
*Record
;
107 // Journal GUID'ed HOBs to find empty record entry. if found, then save status code in it.
108 // otherwise, create a new GUID'ed HOB.
110 Hob
.Raw
= GetFirstGuidHob (&gMemoryStatusCodeRecordGuid
);
111 while (Hob
.Raw
!= NULL
) {
112 PacketHeader
= (MEMORY_STATUSCODE_PACKET_HEADER
*) GET_GUID_HOB_DATA (Hob
.Guid
);
115 // Check whether pccket is full or not.
117 if (PacketHeader
->RecordIndex
< PacketHeader
->MaxRecordsNumber
) {
118 Record
= (MEMORY_STATUSCODE_RECORD
*) (PacketHeader
+ 1);
119 Record
= &Record
[PacketHeader
->RecordIndex
++];
123 // Cache number of found packet in PacketIndex.
127 Hob
.Raw
= GetNextGuidHob (&gMemoryStatusCodeRecordGuid
, Hob
.Raw
);
130 if (Record
== NULL
) {
132 // No available entry found, so create new packet.
134 PacketHeader
= CreateMemoryStatusCodePacket (PacketIndex
);
136 Record
= (MEMORY_STATUSCODE_RECORD
*) (PacketHeader
+ 1);
137 Record
= &Record
[PacketHeader
->RecordIndex
++];
140 Record
->CodeType
= CodeType
;
141 Record
->Instance
= Instance
;
142 Record
->Value
= Value
;