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