]>
Commit | Line | Data |
---|---|---|
3af9b388 | 1 | /** @file\r |
2 | Runtime memory status code worker.\r | |
3 | \r | |
4 | Copyright (c) 2006 - 2009, 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 | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #include "StatusCodeHandlerRuntimeDxe.h"\r | |
16 | \r | |
17 | RUNTIME_MEMORY_STATUSCODE_HEADER *mRtMemoryStatusCodeTable;\r | |
18 | \r | |
19 | /**\r | |
20 | Initialize runtime memory status code table as initialization for runtime memory status code worker\r | |
21 | \r | |
22 | @retval EFI_SUCCESS Runtime memory status code table successfully initialized.\r | |
23 | \r | |
24 | **/\r | |
25 | EFI_STATUS\r | |
26 | RtMemoryStatusCodeInitializeWorker (\r | |
27 | VOID\r | |
28 | )\r | |
29 | {\r | |
30 | //\r | |
31 | // Allocate runtime memory status code pool.\r | |
32 | //\r | |
33 | mRtMemoryStatusCodeTable = AllocateRuntimePool (\r | |
34 | sizeof (RUNTIME_MEMORY_STATUSCODE_HEADER) +\r | |
35 | PcdGet16 (PcdStatusCodeMemorySize) * 1024\r | |
36 | );\r | |
37 | ASSERT (mRtMemoryStatusCodeTable != NULL);\r | |
38 | \r | |
39 | mRtMemoryStatusCodeTable->RecordIndex = 0;\r | |
40 | mRtMemoryStatusCodeTable->NumberOfRecords = 0;\r | |
41 | mRtMemoryStatusCodeTable->MaxRecordsNumber = \r | |
42 | (PcdGet16 (PcdStatusCodeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);\r | |
43 | \r | |
44 | return EFI_SUCCESS;\r | |
45 | }\r | |
46 | \r | |
47 | \r | |
48 | /**\r | |
49 | Report status code into runtime memory. If the runtime pool is full, roll back to the \r | |
50 | first record and overwrite it.\r | |
51 | \r | |
52 | @param CodeType Indicates the type of status code being reported.\r | |
53 | @param Value Describes the current status of a hardware or software entity.\r | |
54 | This included information about the class and subclass that is used to\r | |
55 | classify the entity as well as an operation.\r | |
56 | @param Instance The enumeration of a hardware or software entity within\r | |
57 | the system. Valid instance numbers start with 1.\r | |
58 | @param CallerId This optional parameter may be used to identify the caller.\r | |
59 | This parameter allows the status code driver to apply different rules to\r | |
60 | different callers.\r | |
61 | @param Data This optional parameter may be used to pass additional data.\r | |
62 | \r | |
63 | @retval EFI_SUCCESS Status code successfully recorded in runtime memory status code table.\r | |
64 | \r | |
65 | **/\r | |
66 | EFI_STATUS\r | |
e798cd87 | 67 | EFIAPI\r |
3af9b388 | 68 | RtMemoryStatusCodeReportWorker (\r |
69 | IN EFI_STATUS_CODE_TYPE CodeType,\r | |
70 | IN EFI_STATUS_CODE_VALUE Value,\r | |
71 | IN UINT32 Instance,\r | |
72 | IN EFI_GUID *CallerId,\r | |
73 | IN EFI_STATUS_CODE_DATA *Data OPTIONAL\r | |
74 | )\r | |
75 | {\r | |
76 | MEMORY_STATUSCODE_RECORD *Record;\r | |
77 | \r | |
78 | //\r | |
79 | // Locate current record buffer.\r | |
80 | //\r | |
81 | Record = (MEMORY_STATUSCODE_RECORD *) (mRtMemoryStatusCodeTable + 1);\r | |
82 | Record = &Record[mRtMemoryStatusCodeTable->RecordIndex++];\r | |
83 | \r | |
84 | //\r | |
85 | // Save status code.\r | |
86 | //\r | |
87 | Record->CodeType = CodeType;\r | |
88 | Record->Value = Value;\r | |
89 | Record->Instance = Instance;\r | |
90 | \r | |
91 | //\r | |
92 | // If record index equals to max record number, then wrap around record index to zero.\r | |
93 | //\r | |
94 | // The reader of status code should compare the number of records with max records number,\r | |
95 | // If it is equal to or larger than the max number, then the wrap-around had happened,\r | |
96 | // so the first record is pointed by record index.\r | |
97 | // If it is less then max number, index of the first record is zero.\r | |
98 | //\r | |
99 | mRtMemoryStatusCodeTable->NumberOfRecords++;\r | |
100 | if (mRtMemoryStatusCodeTable->RecordIndex == mRtMemoryStatusCodeTable->MaxRecordsNumber) {\r | |
101 | //\r | |
102 | // Wrap around record index.\r | |
103 | //\r | |
104 | mRtMemoryStatusCodeTable->RecordIndex = 0;\r | |
105 | }\r | |
106 | \r | |
107 | return EFI_SUCCESS;\r | |
108 | }\r | |
109 | \r | |
110 | \r | |
111 | \r |