]>
Commit | Line | Data |
---|---|---|
ad1a1798 | 1 | /** @file\r |
d5aea10c | 2 | PEI memory status code worker.\r |
ad1a1798 | 3 | \r |
0a6f4824 | 4 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r |
180a5a35 | 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 | |
c945216e | 18 | Create the first memory status code GUID'ed HOB as initialization for memory status code worker.\r |
ececc2eb | 19 | \r |
c945216e | 20 | @retval EFI_SUCCESS The GUID'ed HOB is created successfully.\r |
ad1a1798 | 21 | \r |
22 | **/\r | |
c945216e LG |
23 | EFI_STATUS\r |
24 | MemoryStatusCodeInitializeWorker (\r | |
25 | VOID\r | |
ad1a1798 | 26 | )\r |
27 | {\r | |
c945216e LG |
28 | //\r |
29 | // Create memory status code GUID'ed HOB.\r | |
30 | //\r | |
ad1a1798 | 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 |
c945216e | 43 | PacketHeader->PacketIndex = 0;\r |
ad1a1798 | 44 | PacketHeader->RecordIndex = 0;\r |
45 | \r | |
ad1a1798 | 46 | return EFI_SUCCESS;\r |
47 | }\r | |
48 | \r | |
49 | \r | |
50 | /**\r | |
d5aea10c | 51 | Report status code into GUID'ed HOB.\r |
ececc2eb | 52 | \r |
d5aea10c | 53 | This function reports status code into GUID'ed HOB. If not all packets are full, then\r |
54 | write status code into available entry. Otherwise, create a new packet for it.\r | |
ececc2eb | 55 | \r |
d5aea10c | 56 | @param CodeType Indicates the type of status code being reported.\r |
57 | @param Value Describes the current status of a hardware or\r | |
58 | software entity. This includes information about the class and\r | |
59 | subclass that is used to classify the entity as well as an operation.\r | |
60 | For progress codes, the operation is the current activity.\r | |
61 | For error codes, it is the exception.For debug codes,it is not defined at this time.\r | |
62 | @param Instance The enumeration of a hardware or software entity within\r | |
63 | the system. A system may contain multiple entities that match a class/subclass\r | |
64 | pairing. The instance differentiates between them. An instance of 0 indicates\r | |
65 | that instance information is unavailable, not meaningful, or not relevant.\r | |
66 | Valid instance numbers start with 1.\r | |
ececc2eb | 67 | \r |
d5aea10c | 68 | @retval EFI_SUCCESS The function always return EFI_SUCCESS.\r |
ad1a1798 | 69 | \r |
70 | **/\r | |
71 | EFI_STATUS\r | |
72 | MemoryStatusCodeReportWorker (\r | |
73 | IN EFI_STATUS_CODE_TYPE CodeType,\r | |
74 | IN EFI_STATUS_CODE_VALUE Value,\r | |
75 | IN UINT32 Instance\r | |
76 | )\r | |
77 | {\r | |
78 | \r | |
79 | EFI_PEI_HOB_POINTERS Hob;\r | |
80 | MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;\r | |
d5aea10c | 81 | MEMORY_STATUSCODE_RECORD *Record;\r |
ad1a1798 | 82 | \r |
83 | //\r | |
0a6f4824 | 84 | // Find GUID'ed HOBs to locate current record buffer.\r |
ad1a1798 | 85 | //\r |
86 | Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);\r | |
c945216e | 87 | ASSERT (Hob.Raw != NULL);\r |
ad1a1798 | 88 | \r |
c945216e LG |
89 | PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);\r |
90 | Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r | |
91 | Record = &Record[PacketHeader->RecordIndex++];\r | |
ad1a1798 | 92 | \r |
c945216e LG |
93 | //\r |
94 | // Save status code.\r | |
95 | //\r | |
96 | Record->CodeType = CodeType;\r | |
97 | Record->Instance = Instance;\r | |
98 | Record->Value = Value;\r | |
ad1a1798 | 99 | \r |
c945216e LG |
100 | //\r |
101 | // If record index equals to max record number, then wrap around record index to zero.\r | |
102 | //\r | |
103 | // The reader of status code should compare the number of records with max records number,\r | |
104 | // If it is equal to or larger than the max number, then the wrap-around had happened,\r | |
105 | // so the first record is pointed by record index.\r | |
106 | // If it is less then max number, index of the first record is zero.\r | |
107 | //\r | |
108 | if (PacketHeader->RecordIndex == PacketHeader->MaxRecordsNumber) {\r | |
ad1a1798 | 109 | //\r |
c945216e | 110 | // Wrap around record index.\r |
ad1a1798 | 111 | //\r |
c945216e LG |
112 | PacketHeader->RecordIndex = 0;\r |
113 | PacketHeader->PacketIndex ++;\r | |
ad1a1798 | 114 | }\r |
115 | \r | |
ad1a1798 | 116 | return EFI_SUCCESS;\r |
117 | }\r | |
bcd70414 | 118 | \r |