]>
Commit | Line | Data |
---|---|---|
56836fe9 | 1 | /** @file\r |
2 | Runtime memory status code worker in DXE.\r | |
3 | \r | |
161c26a7 | 4 | Copyright (c) 2006, Intel Corporation \r |
5 | All rights reserved. This program and the accompanying materials \r | |
6 | are licensed and made available under the terms and conditions of the BSD License \r | |
7 | which accompanies this distribution. The full text of the license may be found at \r | |
8 | http://opensource.org/licenses/bsd-license.php \r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
56836fe9 | 12 | \r |
13 | Module Name: RtMemoryStatusCodeWorker.c\r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | #include "DxeStatusCode.h"\r | |
18 | \r | |
19 | /**\r | |
20 | Initialize runtime memory status code.\r | |
21 | \r | |
22 | @return The function always return EFI_SUCCESS\r | |
23 | \r | |
24 | **/\r | |
25 | EFI_STATUS\r | |
26 | RtMemoryStatusCodeInitializeWorker (\r | |
27 | VOID\r | |
28 | )\r | |
29 | {\r | |
30 | RUNTIME_MEMORY_STATUSCODE_HEADER *RtMemoryStatusCodeTable;\r | |
31 | \r | |
32 | //\r | |
33 | // Allocate runtime memory status code pool.\r | |
34 | //\r | |
35 | RtMemoryStatusCodeTable = \r | |
36 | (RUNTIME_MEMORY_STATUSCODE_HEADER *) AllocatePool (\r | |
a93763b7 | 37 | sizeof (RUNTIME_MEMORY_STATUSCODE_HEADER) +\r |
38 | PcdGet16 (PcdStatusCodeRuntimeMemorySize) *\r | |
39 | 1024\r | |
56836fe9 | 40 | );\r |
41 | \r | |
42 | ASSERT (NULL != RtMemoryStatusCodeTable);\r | |
43 | \r | |
44 | RtMemoryStatusCodeTable->RecordIndex = 0;\r | |
45 | RtMemoryStatusCodeTable->NumberOfRecords = 0;\r | |
46 | RtMemoryStatusCodeTable->MaxRecordsNumber = \r | |
47 | (PcdGet16 (PcdStatusCodeRuntimeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);\r | |
48 | \r | |
49 | gDxeStatusCode.RtMemoryStatusCodeTable[PHYSICAL_MODE] = RtMemoryStatusCodeTable;\r | |
50 | return EFI_SUCCESS;\r | |
51 | }\r | |
52 | \r | |
53 | \r | |
54 | /**\r | |
55 | Report status code into runtime memory. If the runtime pool is full, roll back to the \r | |
56 | first record and overwrite it.\r | |
57 | \r | |
58 | @param RtMemoryStatusCodeTable \r | |
59 | Point to Runtime memory table header.\r | |
60 | \r | |
511710d6 | 61 | @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r |
56836fe9 | 62 | \r |
63 | @param Value Describes the current status of a hardware or software entity. \r | |
64 | This included information about the class and subclass that is used to classify the entity \r | |
65 | as well as an operation. For progress codes, the operation is the current activity. \r | |
66 | For error codes, it is the exception. For debug codes, it is not defined at this time. \r | |
511710d6 | 67 | Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below. \r |
56836fe9 | 68 | Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r |
69 | \r | |
70 | @param Instance The enumeration of a hardware or software entity within the system. \r | |
71 | A system may contain multiple entities that match a class/subclass pairing. \r | |
72 | The instance differentiates between them. An instance of 0 indicates that instance information is unavailable, \r | |
73 | not meaningful, or not relevant. Valid instance numbers start with 1.\r | |
74 | \r | |
75 | @return The function always return EFI_SUCCESS.\r | |
76 | \r | |
77 | **/\r | |
78 | EFI_STATUS\r | |
79 | RtMemoryStatusCodeReportWorker (\r | |
80 | RUNTIME_MEMORY_STATUSCODE_HEADER *RtMemoryStatusCodeTable,\r | |
81 | IN EFI_STATUS_CODE_TYPE CodeType,\r | |
82 | IN EFI_STATUS_CODE_VALUE Value,\r | |
83 | IN UINT32 Instance\r | |
84 | )\r | |
85 | {\r | |
86 | MEMORY_STATUSCODE_RECORD *Record;\r | |
87 | \r | |
88 | ASSERT (NULL != RtMemoryStatusCodeTable);\r | |
89 | \r | |
90 | //\r | |
91 | // Locate current record buffer.\r | |
92 | //\r | |
93 | Record = (MEMORY_STATUSCODE_RECORD *) (RtMemoryStatusCodeTable + 1);\r | |
94 | Record = &Record[RtMemoryStatusCodeTable->RecordIndex++];\r | |
95 | \r | |
96 | //\r | |
97 | // Save status code.\r | |
98 | //\r | |
99 | Record->CodeType = CodeType;\r | |
100 | Record->Value = Value;\r | |
101 | Record->Instance = Instance;\r | |
102 | \r | |
103 | //\r | |
104 | // Record total number of records, we compare the number with max records number,\r | |
105 | // if it is bigger than the max number, then the roll back had happened, the record index points to \r | |
106 | // the first record. if it is less then max number, then the zero index is the first record.\r | |
107 | //\r | |
108 | RtMemoryStatusCodeTable->NumberOfRecords++;\r | |
109 | if (RtMemoryStatusCodeTable->RecordIndex == RtMemoryStatusCodeTable->MaxRecordsNumber) {\r | |
110 | //\r | |
111 | // Roll back record index.\r | |
112 | //\r | |
113 | RtMemoryStatusCodeTable->RecordIndex = 0;\r | |
114 | }\r | |
115 | \r | |
56836fe9 | 116 | return EFI_SUCCESS;\r |
117 | }\r | |
118 | \r | |
119 | \r | |
120 | \r |