]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/RtMemoryStatusCodeWorker.c
Reviewed the code comments in the Include/Protocol directory for typos, grammar issue...
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / StatusCode / RuntimeDxe / RtMemoryStatusCodeWorker.c
CommitLineData
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
20e7a774 15#include "StatusCodeRuntimeDxe.h"\r
ad1a1798 16\r
a8cbf345 17RUNTIME_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
25EFI_STATUS\r
26RtMemoryStatusCodeInitializeWorker (\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
ad1a1798 59 \r
a8cbf345 60 @retval EFI_SUCCESS Status code successfully recorded in runtime memory status code table.\r
ad1a1798 61\r
62**/\r
63EFI_STATUS\r
64RtMemoryStatusCodeReportWorker (\r
ad1a1798 65 IN EFI_STATUS_CODE_TYPE CodeType,\r
66 IN EFI_STATUS_CODE_VALUE Value,\r
67 IN UINT32 Instance\r
68 )\r
69{\r
70 MEMORY_STATUSCODE_RECORD *Record;\r
71\r
ad1a1798 72 //\r
73 // Locate current record buffer.\r
74 //\r
a8cbf345 75 Record = (MEMORY_STATUSCODE_RECORD *) (mRtMemoryStatusCodeTable + 1);\r
76 Record = &Record[mRtMemoryStatusCodeTable->RecordIndex++];\r
ad1a1798 77\r
78 //\r
79 // Save status code.\r
80 //\r
a8cbf345 81 Record->CodeType = CodeType;\r
82 Record->Value = Value;\r
83 Record->Instance = Instance;\r
ad1a1798 84\r
85 //\r
a8cbf345 86 // If record index equals to max record number, then wrap around record index to zero.\r
87 //\r
88 // The reader of status code should compare the number of records with max records number,\r
89 // If it is equal to or larger than the max number, then the wrap-around had happened,\r
90 // so the first record is pointed by record index.\r
91 // If it is less then max number, index of the first record is zero.\r
ad1a1798 92 //\r
a8cbf345 93 mRtMemoryStatusCodeTable->NumberOfRecords++;\r
94 if (mRtMemoryStatusCodeTable->RecordIndex == mRtMemoryStatusCodeTable->MaxRecordsNumber) {\r
ad1a1798 95 //\r
a8cbf345 96 // Wrap around record index.\r
ad1a1798 97 //\r
a8cbf345 98 mRtMemoryStatusCodeTable->RecordIndex = 0;\r
ad1a1798 99 }\r
100\r
101 return EFI_SUCCESS;\r
102}\r
103\r
104\r
105\r