]>
Commit | Line | Data |
---|---|---|
ad1a1798 | 1 | /** @file\r |
a8cbf345 | 2 | Runtime memory status code worker.\r |
ad1a1798 | 3 | \r |
180a5a35 HT |
4 | Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r |
5 | This program and the accompanying materials \r | |
ad1a1798 | 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 | |
20e7a774 | 15 | #include "StatusCodeRuntimeDxe.h"\r |
ad1a1798 | 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 | |
d2c315e6 | 35 | PcdGet16 (PcdStatusCodeMemorySize) * 1024\r |
a8cbf345 | 36 | );\r |
37 | ASSERT (mRtMemoryStatusCodeTable != NULL);\r | |
38 | \r | |
39 | mRtMemoryStatusCodeTable->RecordIndex = 0;\r | |
40 | mRtMemoryStatusCodeTable->NumberOfRecords = 0;\r | |
41 | mRtMemoryStatusCodeTable->MaxRecordsNumber = \r | |
d2c315e6 | 42 | (PcdGet16 (PcdStatusCodeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);\r |
ad1a1798 | 43 | \r |
ad1a1798 | 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 | |
a8cbf345 | 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 | |
ad1a1798 | 58 | \r |
a8cbf345 | 59 | @retval EFI_SUCCESS Status code successfully recorded in runtime memory status code table.\r |
ad1a1798 | 60 | \r |
61 | **/\r | |
62 | EFI_STATUS\r | |
63 | RtMemoryStatusCodeReportWorker (\r | |
ad1a1798 | 64 | IN EFI_STATUS_CODE_TYPE CodeType,\r |
65 | IN EFI_STATUS_CODE_VALUE Value,\r | |
66 | IN UINT32 Instance\r | |
67 | )\r | |
68 | {\r | |
69 | MEMORY_STATUSCODE_RECORD *Record;\r | |
70 | \r | |
ad1a1798 | 71 | //\r |
72 | // Locate current record buffer.\r | |
73 | //\r | |
a8cbf345 | 74 | Record = (MEMORY_STATUSCODE_RECORD *) (mRtMemoryStatusCodeTable + 1);\r |
75 | Record = &Record[mRtMemoryStatusCodeTable->RecordIndex++];\r | |
ad1a1798 | 76 | \r |
77 | //\r | |
78 | // Save status code.\r | |
79 | //\r | |
a8cbf345 | 80 | Record->CodeType = CodeType;\r |
81 | Record->Value = Value;\r | |
82 | Record->Instance = Instance;\r | |
ad1a1798 | 83 | \r |
84 | //\r | |
a8cbf345 | 85 | // If record index equals to max record number, then wrap around record index to zero.\r |
86 | //\r | |
87 | // The reader of status code should compare the number of records with max records number,\r | |
88 | // If it is equal to or larger than the max number, then the wrap-around had happened,\r | |
89 | // so the first record is pointed by record index.\r | |
90 | // If it is less then max number, index of the first record is zero.\r | |
ad1a1798 | 91 | //\r |
a8cbf345 | 92 | mRtMemoryStatusCodeTable->NumberOfRecords++;\r |
93 | if (mRtMemoryStatusCodeTable->RecordIndex == mRtMemoryStatusCodeTable->MaxRecordsNumber) {\r | |
ad1a1798 | 94 | //\r |
a8cbf345 | 95 | // Wrap around record index.\r |
ad1a1798 | 96 | //\r |
a8cbf345 | 97 | mRtMemoryStatusCodeTable->RecordIndex = 0;\r |
ad1a1798 | 98 | }\r |
99 | \r | |
100 | return EFI_SUCCESS;\r | |
101 | }\r | |
102 | \r | |
103 | \r | |
104 | \r |