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