]>
Commit | Line | Data |
---|---|---|
3af9b388 | 1 | /** @file\r |
2 | Runtime memory status code worker.\r | |
3 | \r | |
d1102dba | 4 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r |
848e1472 CS |
5 | (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r |
6 | This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
3af9b388 | 13 | \r |
14 | **/\r | |
15 | \r | |
16 | #include "StatusCodeHandlerRuntimeDxe.h"\r | |
17 | \r | |
18 | RUNTIME_MEMORY_STATUSCODE_HEADER *mRtMemoryStatusCodeTable;\r | |
19 | \r | |
20 | /**\r | |
21 | Initialize runtime memory status code table as initialization for runtime memory status code worker\r | |
848e1472 | 22 | \r |
3af9b388 | 23 | @retval EFI_SUCCESS Runtime memory status code table successfully initialized.\r |
848e1472 | 24 | @retval others Errors from gBS->InstallConfigurationTable().\r |
3af9b388 | 25 | \r |
26 | **/\r | |
27 | EFI_STATUS\r | |
28 | RtMemoryStatusCodeInitializeWorker (\r | |
29 | VOID\r | |
30 | )\r | |
31 | {\r | |
848e1472 CS |
32 | EFI_STATUS Status;\r |
33 | \r | |
3af9b388 | 34 | //\r |
35 | // Allocate runtime memory status code pool.\r | |
36 | //\r | |
37 | mRtMemoryStatusCodeTable = AllocateRuntimePool (\r | |
38 | sizeof (RUNTIME_MEMORY_STATUSCODE_HEADER) +\r | |
39 | PcdGet16 (PcdStatusCodeMemorySize) * 1024\r | |
40 | );\r | |
41 | ASSERT (mRtMemoryStatusCodeTable != NULL);\r | |
42 | \r | |
43 | mRtMemoryStatusCodeTable->RecordIndex = 0;\r | |
44 | mRtMemoryStatusCodeTable->NumberOfRecords = 0;\r | |
d1102dba | 45 | mRtMemoryStatusCodeTable->MaxRecordsNumber =\r |
3af9b388 | 46 | (PcdGet16 (PcdStatusCodeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);\r |
848e1472 | 47 | Status = gBS->InstallConfigurationTable (&gMemoryStatusCodeRecordGuid, mRtMemoryStatusCodeTable);\r |
3af9b388 | 48 | \r |
848e1472 | 49 | return Status;\r |
3af9b388 | 50 | }\r |
51 | \r | |
52 | \r | |
53 | /**\r | |
d1102dba | 54 | Report status code into runtime memory. If the runtime pool is full, roll back to the\r |
3af9b388 | 55 | first record and overwrite it.\r |
848e1472 | 56 | \r |
3af9b388 | 57 | @param CodeType Indicates the type of status code being reported.\r |
58 | @param Value Describes the current status of a hardware or software entity.\r | |
59 | This included information about the class and subclass that is used to\r | |
60 | classify the entity as well as an operation.\r | |
61 | @param Instance The enumeration of a hardware or software entity within\r | |
62 | the system. Valid instance numbers start with 1.\r | |
63 | @param CallerId This optional parameter may be used to identify the caller.\r | |
64 | This parameter allows the status code driver to apply different rules to\r | |
65 | different callers.\r | |
66 | @param Data This optional parameter may be used to pass additional data.\r | |
848e1472 | 67 | \r |
3af9b388 | 68 | @retval EFI_SUCCESS Status code successfully recorded in runtime memory status code table.\r |
69 | \r | |
70 | **/\r | |
71 | EFI_STATUS\r | |
e798cd87 | 72 | EFIAPI\r |
3af9b388 | 73 | RtMemoryStatusCodeReportWorker (\r |
74 | IN EFI_STATUS_CODE_TYPE CodeType,\r | |
75 | IN EFI_STATUS_CODE_VALUE Value,\r | |
76 | IN UINT32 Instance,\r | |
77 | IN EFI_GUID *CallerId,\r | |
78 | IN EFI_STATUS_CODE_DATA *Data OPTIONAL\r | |
79 | )\r | |
80 | {\r | |
81 | MEMORY_STATUSCODE_RECORD *Record;\r | |
82 | \r | |
83 | //\r | |
84 | // Locate current record buffer.\r | |
85 | //\r | |
86 | Record = (MEMORY_STATUSCODE_RECORD *) (mRtMemoryStatusCodeTable + 1);\r | |
87 | Record = &Record[mRtMemoryStatusCodeTable->RecordIndex++];\r | |
88 | \r | |
89 | //\r | |
90 | // Save status code.\r | |
91 | //\r | |
92 | Record->CodeType = CodeType;\r | |
93 | Record->Value = Value;\r | |
94 | Record->Instance = Instance;\r | |
95 | \r | |
96 | //\r | |
97 | // If record index equals to max record number, then wrap around record index to zero.\r | |
98 | //\r | |
99 | // The reader of status code should compare the number of records with max records number,\r | |
100 | // If it is equal to or larger than the max number, then the wrap-around had happened,\r | |
101 | // so the first record is pointed by record index.\r | |
102 | // If it is less then max number, index of the first record is zero.\r | |
103 | //\r | |
104 | mRtMemoryStatusCodeTable->NumberOfRecords++;\r | |
105 | if (mRtMemoryStatusCodeTable->RecordIndex == mRtMemoryStatusCodeTable->MaxRecordsNumber) {\r | |
106 | //\r | |
107 | // Wrap around record index.\r | |
108 | //\r | |
109 | mRtMemoryStatusCodeTable->RecordIndex = 0;\r | |
110 | }\r | |
111 | \r | |
112 | return EFI_SUCCESS;\r | |
113 | }\r | |
114 | \r | |
115 | \r | |
116 | \r |