2 Runtime memory status code worker.
4 Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
5 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "StatusCodeHandlerRuntimeDxe.h"
18 RUNTIME_MEMORY_STATUSCODE_HEADER
*mRtMemoryStatusCodeTable
;
21 Initialize runtime memory status code table as initialization for runtime memory status code worker
23 @retval EFI_SUCCESS Runtime memory status code table successfully initialized.
24 @retval others Errors from gBS->InstallConfigurationTable().
28 RtMemoryStatusCodeInitializeWorker (
35 // Allocate runtime memory status code pool.
37 mRtMemoryStatusCodeTable
= AllocateRuntimePool (
38 sizeof (RUNTIME_MEMORY_STATUSCODE_HEADER
) +
39 PcdGet16 (PcdStatusCodeMemorySize
) * 1024
41 ASSERT (mRtMemoryStatusCodeTable
!= NULL
);
43 mRtMemoryStatusCodeTable
->RecordIndex
= 0;
44 mRtMemoryStatusCodeTable
->NumberOfRecords
= 0;
45 mRtMemoryStatusCodeTable
->MaxRecordsNumber
=
46 (PcdGet16 (PcdStatusCodeMemorySize
) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD
);
47 Status
= gBS
->InstallConfigurationTable (&gMemoryStatusCodeRecordGuid
, mRtMemoryStatusCodeTable
);
54 Report status code into runtime memory. If the runtime pool is full, roll back to the
55 first record and overwrite it.
57 @param CodeType Indicates the type of status code being reported.
58 @param Value Describes the current status of a hardware or software entity.
59 This included information about the class and subclass that is used to
60 classify the entity as well as an operation.
61 @param Instance The enumeration of a hardware or software entity within
62 the system. Valid instance numbers start with 1.
63 @param CallerId This optional parameter may be used to identify the caller.
64 This parameter allows the status code driver to apply different rules to
66 @param Data This optional parameter may be used to pass additional data.
68 @retval EFI_SUCCESS Status code successfully recorded in runtime memory status code table.
73 RtMemoryStatusCodeReportWorker (
74 IN EFI_STATUS_CODE_TYPE CodeType
,
75 IN EFI_STATUS_CODE_VALUE Value
,
77 IN EFI_GUID
*CallerId
,
78 IN EFI_STATUS_CODE_DATA
*Data OPTIONAL
81 MEMORY_STATUSCODE_RECORD
*Record
;
84 // Locate current record buffer.
86 Record
= (MEMORY_STATUSCODE_RECORD
*) (mRtMemoryStatusCodeTable
+ 1);
87 Record
= &Record
[mRtMemoryStatusCodeTable
->RecordIndex
++];
92 Record
->CodeType
= CodeType
;
93 Record
->Value
= Value
;
94 Record
->Instance
= Instance
;
97 // If record index equals to max record number, then wrap around record index to zero.
99 // The reader of status code should compare the number of records with max records number,
100 // If it is equal to or larger than the max number, then the wrap-around had happened,
101 // so the first record is pointed by record index.
102 // If it is less then max number, index of the first record is zero.
104 mRtMemoryStatusCodeTable
->NumberOfRecords
++;
105 if (mRtMemoryStatusCodeTable
->RecordIndex
== mRtMemoryStatusCodeTable
->MaxRecordsNumber
) {
107 // Wrap around record index.
109 mRtMemoryStatusCodeTable
->RecordIndex
= 0;