]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/StatusCodeHandler/Smm/MemoryStatusCodeWorker.c
Update the copyright notice format
[mirror_edk2.git] / MdeModulePkg / Universal / StatusCodeHandler / Smm / MemoryStatusCodeWorker.c
CommitLineData
3af9b388 1/** @file\r
2 Runtime memory status code worker.\r
3\r
e5eed7d3
HT
4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
5 This program and the accompanying materials \r
3af9b388 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 "StatusCodeHandlerSmm.h"\r
16\r
17RUNTIME_MEMORY_STATUSCODE_HEADER *mSmmMemoryStatusCodeTable;\r
18\r
19/**\r
20 Initialize SMM memory status code table as initialization for memory status code worker\r
21 \r
22 @retval EFI_SUCCESS SMM memory status code table successfully initialized.\r
23\r
24**/\r
25EFI_STATUS\r
26MemoryStatusCodeInitializeWorker (\r
27 VOID\r
28 )\r
29{\r
3af9b388 30 //\r
31 // Allocate SMM memory status code pool.\r
32 //\r
d3308de7 33 mSmmMemoryStatusCodeTable = (RUNTIME_MEMORY_STATUSCODE_HEADER *)AllocateZeroPool (sizeof (RUNTIME_MEMORY_STATUSCODE_HEADER) + PcdGet16 (PcdStatusCodeMemorySize) * 1024);\r
3af9b388 34 ASSERT (mSmmMemoryStatusCodeTable != NULL);\r
35\r
d3308de7 36 mSmmMemoryStatusCodeTable->MaxRecordsNumber = (PcdGet16 (PcdStatusCodeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);\r
3af9b388 37 return EFI_SUCCESS;\r
38}\r
39\r
40\r
41/**\r
42 Report status code into runtime memory. If the runtime pool is full, roll back to the \r
43 first record and overwrite it.\r
44 \r
45 @param CodeType Indicates the type of status code being reported.\r
46 @param Value Describes the current status of a hardware or software entity.\r
47 This included information about the class and subclass that is used to\r
48 classify the entity as well as an operation.\r
49 @param Instance The enumeration of a hardware or software entity within\r
50 the system. Valid instance numbers start with 1.\r
51 @param CallerId This optional parameter may be used to identify the caller.\r
52 This parameter allows the status code driver to apply different rules to\r
53 different callers.\r
54 @param Data This optional parameter may be used to pass additional data.\r
55 \r
56 @retval EFI_SUCCESS Status code successfully recorded in runtime memory status code table.\r
57\r
58**/\r
59EFI_STATUS\r
e798cd87 60EFIAPI\r
3af9b388 61MemoryStatusCodeReportWorker (\r
62 IN EFI_STATUS_CODE_TYPE CodeType,\r
63 IN EFI_STATUS_CODE_VALUE Value,\r
64 IN UINT32 Instance,\r
65 IN EFI_GUID *CallerId,\r
66 IN EFI_STATUS_CODE_DATA *Data OPTIONAL\r
67 )\r
68{\r
69 MEMORY_STATUSCODE_RECORD *Record;\r
70\r
71 //\r
72 // Locate current record buffer.\r
73 //\r
74 Record = (MEMORY_STATUSCODE_RECORD *) (mSmmMemoryStatusCodeTable + 1);\r
75 Record = &Record[mSmmMemoryStatusCodeTable->RecordIndex++];\r
76\r
77 //\r
78 // Save status code.\r
79 //\r
80 Record->CodeType = CodeType;\r
81 Record->Value = Value;\r
82 Record->Instance = Instance;\r
83\r
84 //\r
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
91 //\r
92 mSmmMemoryStatusCodeTable->NumberOfRecords++;\r
93 if (mSmmMemoryStatusCodeTable->RecordIndex == mSmmMemoryStatusCodeTable->MaxRecordsNumber) {\r
94 //\r
95 // Wrap around record index.\r
96 //\r
97 mSmmMemoryStatusCodeTable->RecordIndex = 0;\r
98 }\r
99\r
100 return EFI_SUCCESS;\r
101}\r
102\r
103\r
104\r