2 Runtime memory status code worker.
4 Copyright (c) 2006 - 2009, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "DxeStatusCode.h"
17 RUNTIME_MEMORY_STATUSCODE_HEADER
*mRtMemoryStatusCodeTable
;
20 Initialize runtime memory status code table as initialization for runtime memory status code worker
22 @retval EFI_SUCCESS Runtime memory status code table successfully initialized.
26 RtMemoryStatusCodeInitializeWorker (
31 // Allocate runtime memory status code pool.
33 mRtMemoryStatusCodeTable
= AllocateRuntimePool (
34 sizeof (RUNTIME_MEMORY_STATUSCODE_HEADER
) +
35 PcdGet16 (PcdStatusCodeRuntimeMemorySize
) *
38 ASSERT (mRtMemoryStatusCodeTable
!= NULL
);
40 mRtMemoryStatusCodeTable
->RecordIndex
= 0;
41 mRtMemoryStatusCodeTable
->NumberOfRecords
= 0;
42 mRtMemoryStatusCodeTable
->MaxRecordsNumber
=
43 (PcdGet16 (PcdStatusCodeRuntimeMemorySize
) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD
);
50 Report status code into runtime memory. If the runtime pool is full, roll back to the
51 first record and overwrite it.
53 @param CodeType Indicates the type of status code being reported.
54 @param Value Describes the current status of a hardware or software entity.
55 This included information about the class and subclass that is used to
56 classify the entity as well as an operation.
57 @param Instance The enumeration of a hardware or software entity within
58 the system. Valid instance numbers start with 1.
60 @retval EFI_SUCCESS Status code successfully recorded in runtime memory status code table.
64 RtMemoryStatusCodeReportWorker (
65 IN EFI_STATUS_CODE_TYPE CodeType
,
66 IN EFI_STATUS_CODE_VALUE Value
,
70 MEMORY_STATUSCODE_RECORD
*Record
;
73 // Locate current record buffer.
75 Record
= (MEMORY_STATUSCODE_RECORD
*) (mRtMemoryStatusCodeTable
+ 1);
76 Record
= &Record
[mRtMemoryStatusCodeTable
->RecordIndex
++];
81 Record
->CodeType
= CodeType
;
82 Record
->Value
= Value
;
83 Record
->Instance
= Instance
;
86 // If record index equals to max record number, then wrap around record index to zero.
88 // The reader of status code should compare the number of records with max records number,
89 // If it is equal to or larger than the max number, then the wrap-around had happened,
90 // so the first record is pointed by record index.
91 // If it is less then max number, index of the first record is zero.
93 mRtMemoryStatusCodeTable
->NumberOfRecords
++;
94 if (mRtMemoryStatusCodeTable
->RecordIndex
== mRtMemoryStatusCodeTable
->MaxRecordsNumber
) {
96 // Wrap around record index.
98 mRtMemoryStatusCodeTable
->RecordIndex
= 0;