]>
Commit | Line | Data |
---|---|---|
ad1a1798 | 1 | /** @file\r |
d5aea10c | 2 | PEI memory status code worker.\r |
ad1a1798 | 3 | \r |
180a5a35 HT |
4 | Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r |
5 | This program and the accompanying materials\r | |
ececc2eb | 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 |
ad1a1798 | 13 | **/\r |
14 | \r | |
85eb5794 | 15 | #include "StatusCodePei.h"\r |
ad1a1798 | 16 | \r |
17 | /**\r | |
d5aea10c | 18 | Worker function to create one memory status code GUID'ed HOB,\r |
19 | using PacketIndex to identify the packet.\r | |
ad1a1798 | 20 | \r |
ececc2eb | 21 | @param PacketIndex Index of records packet.\r |
22 | \r | |
d5aea10c | 23 | @return Pointer to the memory status code packet.\r |
ad1a1798 | 24 | \r |
25 | **/\r | |
ad1a1798 | 26 | MEMORY_STATUSCODE_PACKET_HEADER *\r |
27 | CreateMemoryStatusCodePacket (\r | |
28 | UINT16 PacketIndex\r | |
29 | )\r | |
30 | {\r | |
31 | MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;\r | |
32 | \r | |
33 | //\r | |
34 | // Build GUID'ed HOB with PCD defined size.\r | |
35 | //\r | |
d5aea10c | 36 | PacketHeader = BuildGuidHob (\r |
37 | &gMemoryStatusCodeRecordGuid,\r | |
38 | PcdGet16 (PcdStatusCodeMemorySize) * 1024 + sizeof (MEMORY_STATUSCODE_PACKET_HEADER)\r | |
39 | );\r | |
ad1a1798 | 40 | ASSERT (PacketHeader != NULL);\r |
41 | \r | |
d5aea10c | 42 | PacketHeader->MaxRecordsNumber = (PcdGet16 (PcdStatusCodeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);\r |
ad1a1798 | 43 | PacketHeader->PacketIndex = PacketIndex;\r |
44 | PacketHeader->RecordIndex = 0;\r | |
45 | \r | |
46 | return PacketHeader;\r | |
47 | }\r | |
48 | \r | |
ad1a1798 | 49 | /**\r |
d5aea10c | 50 | Create the first memory status code GUID'ed HOB as initialization for memory status code worker.\r |
ececc2eb | 51 | \r |
d5aea10c | 52 | @retval EFI_SUCCESS The GUID'ed HOB is created successfully.\r |
ad1a1798 | 53 | \r |
54 | **/\r | |
55 | EFI_STATUS\r | |
56 | MemoryStatusCodeInitializeWorker (\r | |
57 | VOID\r | |
58 | )\r | |
59 | {\r | |
60 | //\r | |
61 | // Create first memory status code GUID'ed HOB.\r | |
62 | //\r | |
63 | CreateMemoryStatusCodePacket (0);\r | |
64 | \r | |
65 | return EFI_SUCCESS;\r | |
66 | }\r | |
67 | \r | |
68 | \r | |
69 | /**\r | |
d5aea10c | 70 | Report status code into GUID'ed HOB.\r |
ececc2eb | 71 | \r |
d5aea10c | 72 | This function reports status code into GUID'ed HOB. If not all packets are full, then\r |
73 | write status code into available entry. Otherwise, create a new packet for it.\r | |
ececc2eb | 74 | \r |
d5aea10c | 75 | @param CodeType Indicates the type of status code being reported.\r |
76 | @param Value Describes the current status of a hardware or\r | |
77 | software entity. This includes information about the class and\r | |
78 | subclass that is used to classify the entity as well as an operation.\r | |
79 | For progress codes, the operation is the current activity.\r | |
80 | For error codes, it is the exception.For debug codes,it is not defined at this time.\r | |
81 | @param Instance The enumeration of a hardware or software entity within\r | |
82 | the system. A system may contain multiple entities that match a class/subclass\r | |
83 | pairing. The instance differentiates between them. An instance of 0 indicates\r | |
84 | that instance information is unavailable, not meaningful, or not relevant.\r | |
85 | Valid instance numbers start with 1.\r | |
ececc2eb | 86 | \r |
d5aea10c | 87 | @retval EFI_SUCCESS The function always return EFI_SUCCESS.\r |
ad1a1798 | 88 | \r |
89 | **/\r | |
90 | EFI_STATUS\r | |
91 | MemoryStatusCodeReportWorker (\r | |
92 | IN EFI_STATUS_CODE_TYPE CodeType,\r | |
93 | IN EFI_STATUS_CODE_VALUE Value,\r | |
94 | IN UINT32 Instance\r | |
95 | )\r | |
96 | {\r | |
97 | \r | |
98 | EFI_PEI_HOB_POINTERS Hob;\r | |
99 | MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;\r | |
d5aea10c | 100 | MEMORY_STATUSCODE_RECORD *Record;\r |
101 | UINT16 PacketIndex;\r | |
102 | \r | |
103 | Record = NULL;\r | |
104 | PacketIndex = 0;\r | |
ad1a1798 | 105 | \r |
106 | //\r | |
d5aea10c | 107 | // Journal GUID'ed HOBs to find empty record entry. if found, then save status code in it.\r |
ad1a1798 | 108 | // otherwise, create a new GUID'ed HOB.\r |
109 | //\r | |
110 | Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);\r | |
111 | while (Hob.Raw != NULL) {\r | |
112 | PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);\r | |
113 | \r | |
114 | //\r | |
115 | // Check whether pccket is full or not.\r | |
116 | //\r | |
117 | if (PacketHeader->RecordIndex < PacketHeader->MaxRecordsNumber) {\r | |
118 | Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r | |
119 | Record = &Record[PacketHeader->RecordIndex++];\r | |
120 | break;\r | |
121 | }\r | |
122 | //\r | |
123 | // Cache number of found packet in PacketIndex.\r | |
124 | //\r | |
125 | PacketIndex++;\r | |
126 | \r | |
127 | Hob.Raw = GetNextGuidHob (&gMemoryStatusCodeRecordGuid, Hob.Raw);\r | |
128 | }\r | |
129 | \r | |
d5aea10c | 130 | if (Record == NULL) {\r |
ad1a1798 | 131 | //\r |
d5aea10c | 132 | // No available entry found, so create new packet.\r |
ad1a1798 | 133 | //\r |
134 | PacketHeader = CreateMemoryStatusCodePacket (PacketIndex);\r | |
135 | \r | |
ececc2eb | 136 | Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r |
ad1a1798 | 137 | Record = &Record[PacketHeader->RecordIndex++];\r |
138 | }\r | |
139 | \r | |
140 | Record->CodeType = CodeType;\r | |
141 | Record->Instance = Instance;\r | |
142 | Record->Value = Value;\r | |
143 | \r | |
144 | return EFI_SUCCESS;\r | |
145 | }\r | |
bcd70414 | 146 | \r |