]>
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 | |
8a09cdd7 | 10 | #include "StatusCodeHandlerMm.h"\r |
3af9b388 | 11 | \r |
8a09cdd7 | 12 | RUNTIME_MEMORY_STATUSCODE_HEADER *mMmMemoryStatusCodeTable;\r |
3af9b388 | 13 | \r |
14 | /**\r | |
8a09cdd7 | 15 | Initialize MM memory status code table as initialization for memory status code worker\r |
3af9b388 | 16 | \r |
8a09cdd7 KQ |
17 | @retval EFI_SUCCESS MM memory status code table successfully initialized.\r |
18 | @retval others Errors from gMmst->MmInstallConfigurationTable().\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 |
8a09cdd7 | 28 | // Allocate MM memory status code pool.\r |
3af9b388 | 29 | //\r |
8a09cdd7 KQ |
30 | mMmMemoryStatusCodeTable = (RUNTIME_MEMORY_STATUSCODE_HEADER *)AllocateZeroPool (sizeof (RUNTIME_MEMORY_STATUSCODE_HEADER) + PcdGet16 (PcdStatusCodeMemorySize) * 1024);\r |
31 | ASSERT (mMmMemoryStatusCodeTable != NULL);\r | |
3af9b388 | 32 | \r |
8a09cdd7 KQ |
33 | mMmMemoryStatusCodeTable->MaxRecordsNumber = (PcdGet16 (PcdStatusCodeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);\r |
34 | Status = gMmst->MmInstallConfigurationTable (\r | |
35 | gMmst,\r | |
848e1472 | 36 | &gMemoryStatusCodeRecordGuid,\r |
8a09cdd7 KQ |
37 | &mMmMemoryStatusCodeTable,\r |
38 | sizeof (mMmMemoryStatusCodeTable)\r | |
848e1472 CS |
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 | |
8a09cdd7 KQ |
77 | Record = (MEMORY_STATUSCODE_RECORD *) (mMmMemoryStatusCodeTable + 1);\r |
78 | Record = &Record[mMmMemoryStatusCodeTable->RecordIndex++];\r | |
3af9b388 | 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 | |
8a09cdd7 KQ |
95 | mMmMemoryStatusCodeTable->NumberOfRecords++;\r |
96 | if (mMmMemoryStatusCodeTable->RecordIndex == mMmMemoryStatusCodeTable->MaxRecordsNumber) {\r | |
3af9b388 | 97 | //\r |
98 | // Wrap around record index.\r | |
99 | //\r | |
8a09cdd7 | 100 | mMmMemoryStatusCodeTable->RecordIndex = 0;\r |
3af9b388 | 101 | }\r |
102 | \r | |
103 | return EFI_SUCCESS;\r | |
104 | }\r | |
105 | \r | |
106 | \r | |
107 | \r |