]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Universal/StatusCode/Dxe/RtMemoryStatusCodeWorker.c
Update the comments header.
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / StatusCode / Dxe / RtMemoryStatusCodeWorker.c
1 /** @file
2 Runtime memory status code worker in DXE.
3
4 Copyright (c) 2006, 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
9
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.
12
13 **/
14
15 #include "DxeStatusCode.h"
16
17 /**
18 Initialize runtime memory status code.
19
20 @return The function always return EFI_SUCCESS
21
22 **/
23 EFI_STATUS
24 RtMemoryStatusCodeInitializeWorker (
25 VOID
26 )
27 {
28 RUNTIME_MEMORY_STATUSCODE_HEADER *RtMemoryStatusCodeTable;
29
30 //
31 // Allocate runtime memory status code pool.
32 //
33 RtMemoryStatusCodeTable =
34 (RUNTIME_MEMORY_STATUSCODE_HEADER *) AllocatePool (
35 sizeof (RUNTIME_MEMORY_STATUSCODE_HEADER) +
36 PcdGet16 (PcdStatusCodeRuntimeMemorySize) *
37 1024
38 );
39
40 ASSERT (NULL != RtMemoryStatusCodeTable);
41
42 RtMemoryStatusCodeTable->RecordIndex = 0;
43 RtMemoryStatusCodeTable->NumberOfRecords = 0;
44 RtMemoryStatusCodeTable->MaxRecordsNumber =
45 (PcdGet16 (PcdStatusCodeRuntimeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);
46
47 gDxeStatusCode.RtMemoryStatusCodeTable[PHYSICAL_MODE] = RtMemoryStatusCodeTable;
48 return EFI_SUCCESS;
49 }
50
51
52 /**
53 Report status code into runtime memory. If the runtime pool is full, roll back to the
54 first record and overwrite it.
55
56 @param RtMemoryStatusCodeTable
57 Point to Runtime memory table header.
58
59 @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.
60
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.
67
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.
72
73 @return The function always return EFI_SUCCESS.
74
75 **/
76 EFI_STATUS
77 RtMemoryStatusCodeReportWorker (
78 RUNTIME_MEMORY_STATUSCODE_HEADER *RtMemoryStatusCodeTable,
79 IN EFI_STATUS_CODE_TYPE CodeType,
80 IN EFI_STATUS_CODE_VALUE Value,
81 IN UINT32 Instance
82 )
83 {
84 MEMORY_STATUSCODE_RECORD *Record;
85
86 ASSERT (NULL != RtMemoryStatusCodeTable);
87
88 //
89 // Locate current record buffer.
90 //
91 Record = (MEMORY_STATUSCODE_RECORD *) (RtMemoryStatusCodeTable + 1);
92 Record = &Record[RtMemoryStatusCodeTable->RecordIndex++];
93
94 //
95 // Save status code.
96 //
97 Record->CodeType = CodeType;
98 Record->Value = Value;
99 Record->Instance = Instance;
100
101 //
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.
105 //
106 RtMemoryStatusCodeTable->NumberOfRecords++;
107 if (RtMemoryStatusCodeTable->RecordIndex == RtMemoryStatusCodeTable->MaxRecordsNumber) {
108 //
109 // Roll back record index.
110 //
111 RtMemoryStatusCodeTable->RecordIndex = 0;
112 }
113
114 return EFI_SUCCESS;
115 }
116
117
118