2 Runtime memory status code worker.
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include "StatusCodeHandlerMm.h"
12 RUNTIME_MEMORY_STATUSCODE_HEADER
*mMmMemoryStatusCodeTable
;
15 Initialize MM memory status code table as initialization for memory status code worker
17 @retval EFI_SUCCESS MM memory status code table successfully initialized.
18 @retval others Errors from gMmst->MmInstallConfigurationTable().
21 MemoryStatusCodeInitializeWorker (
28 // Allocate MM memory status code pool.
30 mMmMemoryStatusCodeTable
= (RUNTIME_MEMORY_STATUSCODE_HEADER
*)AllocateZeroPool (sizeof (RUNTIME_MEMORY_STATUSCODE_HEADER
) + PcdGet16 (PcdStatusCodeMemorySize
) * 1024);
31 ASSERT (mMmMemoryStatusCodeTable
!= NULL
);
33 mMmMemoryStatusCodeTable
->MaxRecordsNumber
= (PcdGet16 (PcdStatusCodeMemorySize
) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD
);
34 Status
= gMmst
->MmInstallConfigurationTable (
36 &gMemoryStatusCodeRecordGuid
,
37 &mMmMemoryStatusCodeTable
,
38 sizeof (mMmMemoryStatusCodeTable
)
44 Report status code into runtime memory. If the runtime pool is full, roll back to the
45 first record and overwrite it.
47 @param CodeType Indicates the type of status code being reported.
48 @param Value Describes the current status of a hardware or software entity.
49 This included information about the class and subclass that is used to
50 classify the entity as well as an operation.
51 @param Instance The enumeration of a hardware or software entity within
52 the system. Valid instance numbers start with 1.
53 @param CallerId This optional parameter may be used to identify the caller.
54 This parameter allows the status code driver to apply different rules to
56 @param Data This optional parameter may be used to pass additional data.
58 @retval EFI_SUCCESS Status code successfully recorded in runtime memory status code table.
63 MemoryStatusCodeReportWorker (
64 IN EFI_STATUS_CODE_TYPE CodeType
,
65 IN EFI_STATUS_CODE_VALUE Value
,
67 IN EFI_GUID
*CallerId
,
68 IN EFI_STATUS_CODE_DATA
*Data OPTIONAL
71 MEMORY_STATUSCODE_RECORD
*Record
;
74 // Locate current record buffer.
76 Record
= (MEMORY_STATUSCODE_RECORD
*)(mMmMemoryStatusCodeTable
+ 1);
77 Record
= &Record
[mMmMemoryStatusCodeTable
->RecordIndex
++];
82 Record
->CodeType
= CodeType
;
83 Record
->Value
= Value
;
84 Record
->Instance
= Instance
;
87 // If record index equals to max record number, then wrap around record index to zero.
89 // The reader of status code should compare the number of records with max records number,
90 // If it is equal to or larger than the max number, then the wrap-around had happened,
91 // so the first record is pointed by record index.
92 // If it is less then max number, index of the first record is zero.
94 mMmMemoryStatusCodeTable
->NumberOfRecords
++;
95 if (mMmMemoryStatusCodeTable
->RecordIndex
== mMmMemoryStatusCodeTable
->MaxRecordsNumber
) {
97 // Wrap around record index.
99 mMmMemoryStatusCodeTable
->RecordIndex
= 0;