2 Runtime memory status code worker in DXE.
4 Copyright (c) 2006, Intel Corporation. All rights reserved.
5 This software and associated documentation (if any) is furnished
6 under a license and may only be used or copied in accordance
7 with the terms of the license. Except as permitted by such
8 license, no part of this software or documentation may be
9 reproduced, stored in a retrieval system, or transmitted in any
10 form or by any means without the express written consent of
13 Module Name: RtMemoryStatusCodeWorker.c
17 #include "DxeStatusCode.h"
20 Initialize runtime memory status code.
22 @return The function always return EFI_SUCCESS
26 RtMemoryStatusCodeInitializeWorker (
30 RUNTIME_MEMORY_STATUSCODE_HEADER
*RtMemoryStatusCodeTable
;
33 // Allocate runtime memory status code pool.
35 RtMemoryStatusCodeTable
=
36 (RUNTIME_MEMORY_STATUSCODE_HEADER
*) AllocatePool (
37 sizeof (RUNTIME_MEMORY_STATUSCODE_HEADER
) + PcdGet16 (PcdStatusCodeRuntimeMemorySize
) * 1024
40 ASSERT (NULL
!= RtMemoryStatusCodeTable
);
42 RtMemoryStatusCodeTable
->RecordIndex
= 0;
43 RtMemoryStatusCodeTable
->NumberOfRecords
= 0;
44 RtMemoryStatusCodeTable
->MaxRecordsNumber
=
45 (PcdGet16 (PcdStatusCodeRuntimeMemorySize
) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD
);
47 gDxeStatusCode
.RtMemoryStatusCodeTable
[PHYSICAL_MODE
] = RtMemoryStatusCodeTable
;
53 Report status code into runtime memory. If the runtime pool is full, roll back to the
54 first record and overwrite it.
56 @param RtMemoryStatusCodeTable
57 Point to Runtime memory table header.
59 @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions¡± below.
61 @param Value Describes the current status of a hardware or software entity.
62 This included information about the class and subclass that is used to classify the entity
63 as well as an operation. For progress codes, the operation is the current activity.
64 For error codes, it is the exception. For debug codes, it is not defined at this time.
65 Type EFI_STATUS_CODE_VALUE is defined in ¡°Related Definitions¡± below.
66 Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.
68 @param Instance The enumeration of a hardware or software entity within the system.
69 A system may contain multiple entities that match a class/subclass pairing.
70 The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,
71 not meaningful, or not relevant. Valid instance numbers start with 1.
73 @return The function always return EFI_SUCCESS.
77 RtMemoryStatusCodeReportWorker (
78 RUNTIME_MEMORY_STATUSCODE_HEADER
*RtMemoryStatusCodeTable
,
79 IN EFI_STATUS_CODE_TYPE CodeType
,
80 IN EFI_STATUS_CODE_VALUE Value
,
84 MEMORY_STATUSCODE_RECORD
*Record
;
86 ASSERT (NULL
!= RtMemoryStatusCodeTable
);
89 // Locate current record buffer.
91 Record
= (MEMORY_STATUSCODE_RECORD
*) (RtMemoryStatusCodeTable
+ 1);
92 Record
= &Record
[RtMemoryStatusCodeTable
->RecordIndex
++];
97 Record
->CodeType
= CodeType
;
98 Record
->Value
= Value
;
99 Record
->Instance
= Instance
;
102 // Record total number of records, we compare the number with max records number,
103 // if it is bigger than the max number, then the roll back had happened, the record index points to
104 // the first record. if it is less then max number, then the zero index is the first record.
106 RtMemoryStatusCodeTable
->NumberOfRecords
++;
107 if (RtMemoryStatusCodeTable
->RecordIndex
== RtMemoryStatusCodeTable
->MaxRecordsNumber
) {
109 // Roll back record index.
111 RtMemoryStatusCodeTable
->RecordIndex
= 0;