]>
Commit | Line | Data |
---|---|---|
3af9b388 | 1 | /** @file\r |
2 | PEI memory status code worker.\r | |
3 | \r | |
d1102dba | 4 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r |
9d510e61 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
3af9b388 | 6 | \r |
7 | **/\r | |
8 | \r | |
9 | #include "StatusCodeHandlerPei.h"\r | |
10 | \r | |
11 | /**\r | |
be63a20a | 12 | Create the first memory status code GUID'ed HOB as initialization for memory status code worker.\r |
3af9b388 | 13 | \r |
be63a20a | 14 | @retval EFI_SUCCESS The GUID'ed HOB is created successfully.\r |
3af9b388 | 15 | \r |
16 | **/\r | |
be63a20a LG |
17 | EFI_STATUS\r |
18 | MemoryStatusCodeInitializeWorker (\r | |
19 | VOID\r | |
3af9b388 | 20 | )\r |
21 | {\r | |
be63a20a LG |
22 | //\r |
23 | // Create memory status code GUID'ed HOB.\r | |
24 | //\r | |
3af9b388 | 25 | MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;\r |
26 | \r | |
27 | //\r | |
28 | // Build GUID'ed HOB with PCD defined size.\r | |
29 | //\r | |
30 | PacketHeader = BuildGuidHob (\r | |
31 | &gMemoryStatusCodeRecordGuid,\r | |
32 | PcdGet16 (PcdStatusCodeMemorySize) * 1024 + sizeof (MEMORY_STATUSCODE_PACKET_HEADER)\r | |
33 | );\r | |
34 | ASSERT (PacketHeader != NULL);\r | |
35 | \r | |
36 | PacketHeader->MaxRecordsNumber = (PcdGet16 (PcdStatusCodeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);\r | |
be63a20a | 37 | PacketHeader->PacketIndex = 0;\r |
3af9b388 | 38 | PacketHeader->RecordIndex = 0;\r |
39 | \r | |
3af9b388 | 40 | return EFI_SUCCESS;\r |
41 | }\r | |
42 | \r | |
43 | \r | |
44 | /**\r | |
45 | Report status code into GUID'ed HOB.\r | |
46 | \r | |
47 | This function reports status code into GUID'ed HOB. If not all packets are full, then\r | |
48 | write status code into available entry. Otherwise, create a new packet for it.\r | |
49 | \r | |
50 | @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r | |
51 | @param CodeType Indicates the type of status code being reported.\r | |
52 | @param Value Describes the current status of a hardware or\r | |
53 | software entity. This includes information about the class and\r | |
54 | subclass that is used to classify the entity as well as an operation.\r | |
55 | For progress codes, the operation is the current activity.\r | |
56 | For error codes, it is the exception.For debug codes,it is not defined at this time.\r | |
57 | @param Instance The enumeration of a hardware or software entity within\r | |
58 | the system. A system may contain multiple entities that match a class/subclass\r | |
59 | pairing. The instance differentiates between them. An instance of 0 indicates\r | |
60 | that instance information is unavailable, not meaningful, or not relevant.\r | |
61 | Valid instance numbers start with 1.\r | |
62 | @param CallerId This optional parameter may be used to identify the caller.\r | |
63 | This parameter allows the status code driver to apply different rules to\r | |
64 | different callers.\r | |
65 | @param Data This optional parameter may be used to pass additional data.\r | |
66 | \r | |
67 | @retval EFI_SUCCESS The function always return EFI_SUCCESS.\r | |
68 | \r | |
69 | **/\r | |
70 | EFI_STATUS\r | |
4a5b245a | 71 | EFIAPI\r |
3af9b388 | 72 | MemoryStatusCodeReportWorker (\r |
73 | IN CONST EFI_PEI_SERVICES **PeiServices,\r | |
74 | IN EFI_STATUS_CODE_TYPE CodeType,\r | |
75 | IN EFI_STATUS_CODE_VALUE Value,\r | |
76 | IN UINT32 Instance,\r | |
77 | IN CONST EFI_GUID *CallerId,\r | |
78 | IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL\r | |
79 | )\r | |
80 | {\r | |
81 | \r | |
82 | EFI_PEI_HOB_POINTERS Hob;\r | |
83 | MEMORY_STATUSCODE_PACKET_HEADER *PacketHeader;\r | |
84 | MEMORY_STATUSCODE_RECORD *Record;\r | |
3af9b388 | 85 | \r |
86 | //\r | |
d1102dba | 87 | // Find GUID'ed HOBs to locate current record buffer.\r |
3af9b388 | 88 | //\r |
89 | Hob.Raw = GetFirstGuidHob (&gMemoryStatusCodeRecordGuid);\r | |
be63a20a | 90 | ASSERT (Hob.Raw != NULL);\r |
3af9b388 | 91 | \r |
be63a20a LG |
92 | PacketHeader = (MEMORY_STATUSCODE_PACKET_HEADER *) GET_GUID_HOB_DATA (Hob.Guid);\r |
93 | Record = (MEMORY_STATUSCODE_RECORD *) (PacketHeader + 1);\r | |
94 | Record = &Record[PacketHeader->RecordIndex++];\r | |
3af9b388 | 95 | \r |
be63a20a LG |
96 | //\r |
97 | // Save status code.\r | |
98 | //\r | |
99 | Record->CodeType = CodeType;\r | |
100 | Record->Instance = Instance;\r | |
101 | Record->Value = Value;\r | |
3af9b388 | 102 | \r |
be63a20a LG |
103 | //\r |
104 | // If record index equals to max record number, then wrap around record index to zero.\r | |
105 | //\r | |
106 | // The reader of status code should compare the number of records with max records number,\r | |
107 | // If it is equal to or larger than the max number, then the wrap-around had happened,\r | |
108 | // so the first record is pointed by record index.\r | |
109 | // If it is less then max number, index of the first record is zero.\r | |
110 | //\r | |
111 | if (PacketHeader->RecordIndex == PacketHeader->MaxRecordsNumber) {\r | |
3af9b388 | 112 | //\r |
be63a20a | 113 | // Wrap around record index.\r |
3af9b388 | 114 | //\r |
be63a20a LG |
115 | PacketHeader->RecordIndex = 0;\r |
116 | PacketHeader->PacketIndex ++;\r | |
3af9b388 | 117 | }\r |
118 | \r | |
3af9b388 | 119 | return EFI_SUCCESS;\r |
120 | }\r | |
be63a20a | 121 | \r |