]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Universal/StatusCode/Dxe/RtMemoryStatusCodeWorker.c
1) Check in Pei/Dxe status code;
[mirror_edk2.git] / EdkModulePkg / Universal / StatusCode / Dxe / RtMemoryStatusCodeWorker.c
1 /** @file
2 Runtime memory status code worker in DXE.
3
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
11 Intel Corporation.
12
13 Module Name: RtMemoryStatusCodeWorker.c
14
15 **/
16
17 #include "DxeStatusCode.h"
18
19 /**
20 Initialize runtime memory status code.
21
22 @return The function always return EFI_SUCCESS
23
24 **/
25 EFI_STATUS
26 RtMemoryStatusCodeInitializeWorker (
27 VOID
28 )
29 {
30 RUNTIME_MEMORY_STATUSCODE_HEADER *RtMemoryStatusCodeTable;
31
32 //
33 // Allocate runtime memory status code pool.
34 //
35 RtMemoryStatusCodeTable =
36 (RUNTIME_MEMORY_STATUSCODE_HEADER *) AllocatePool (
37 sizeof (RUNTIME_MEMORY_STATUSCODE_HEADER) + PcdGet16 (PcdStatusCodeRuntimeMemorySize) * 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
115 return EFI_SUCCESS;
116 }
117
118
119