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