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