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 "StatusCodeHandlerSmm.h"
12 RUNTIME_MEMORY_STATUSCODE_HEADER
*mSmmMemoryStatusCodeTable
;
15 Initialize SMM memory status code table as initialization for memory status code worker
17 @retval EFI_SUCCESS SMM memory status code table successfully initialized.
18 @retval others Errors from gSmst->SmmInstallConfigurationTable().
21 MemoryStatusCodeInitializeWorker (
28 // Allocate SMM memory status code pool.
30 mSmmMemoryStatusCodeTable
= (RUNTIME_MEMORY_STATUSCODE_HEADER
*)AllocateZeroPool (sizeof (RUNTIME_MEMORY_STATUSCODE_HEADER
) + PcdGet16 (PcdStatusCodeMemorySize
) * 1024);
31 ASSERT (mSmmMemoryStatusCodeTable
!= NULL
);
33 mSmmMemoryStatusCodeTable
->MaxRecordsNumber
= (PcdGet16 (PcdStatusCodeMemorySize
) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD
);
34 Status
= gSmst
->SmmInstallConfigurationTable (
36 &gMemoryStatusCodeRecordGuid
,
37 &mSmmMemoryStatusCodeTable
,
38 sizeof (mSmmMemoryStatusCodeTable
)
45 Report status code into runtime memory. If the runtime pool is full, roll back to the
46 first record and overwrite it.
48 @param CodeType Indicates the type of status code being reported.
49 @param Value Describes the current status of a hardware or software entity.
50 This included information about the class and subclass that is used to
51 classify the entity as well as an operation.
52 @param Instance The enumeration of a hardware or software entity within
53 the system. Valid instance numbers start with 1.
54 @param CallerId This optional parameter may be used to identify the caller.
55 This parameter allows the status code driver to apply different rules to
57 @param Data This optional parameter may be used to pass additional data.
59 @retval EFI_SUCCESS Status code successfully recorded in runtime memory status code table.
64 MemoryStatusCodeReportWorker (
65 IN EFI_STATUS_CODE_TYPE CodeType
,
66 IN EFI_STATUS_CODE_VALUE Value
,
68 IN EFI_GUID
*CallerId
,
69 IN EFI_STATUS_CODE_DATA
*Data OPTIONAL
72 MEMORY_STATUSCODE_RECORD
*Record
;
75 // Locate current record buffer.
77 Record
= (MEMORY_STATUSCODE_RECORD
*) (mSmmMemoryStatusCodeTable
+ 1);
78 Record
= &Record
[mSmmMemoryStatusCodeTable
->RecordIndex
++];
83 Record
->CodeType
= CodeType
;
84 Record
->Value
= Value
;
85 Record
->Instance
= Instance
;
88 // If record index equals to max record number, then wrap around record index to zero.
90 // The reader of status code should compare the number of records with max records number,
91 // If it is equal to or larger than the max number, then the wrap-around had happened,
92 // so the first record is pointed by record index.
93 // If it is less then max number, index of the first record is zero.
95 mSmmMemoryStatusCodeTable
->NumberOfRecords
++;
96 if (mSmmMemoryStatusCodeTable
->RecordIndex
== mSmmMemoryStatusCodeTable
->MaxRecordsNumber
) {
98 // Wrap around record index.
100 mSmmMemoryStatusCodeTable
->RecordIndex
= 0;