]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Dxe/Misc/InstallConfigurationTable.c
Add doxygen style comments for functions in DxeMain.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Misc / InstallConfigurationTable.c
CommitLineData
504214c4
LG
1/** @file \r
2\r
3 UEFI Miscellaneous boot Services InstallConfigurationTable service\r
28a00297 4\r
504214c4 5Copyright (c) 2006 - 2008, Intel Corporation \r
28a00297 6All rights reserved. This program and the accompanying materials \r
7are licensed and made available under the terms and conditions of the BSD License \r
8which accompanies this distribution. The full text of the license may be found at \r
9http://opensource.org/licenses/bsd-license.php \r
10 \r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
13\r
504214c4 14**/\r
28a00297 15\r
16#include <DxeMain.h>\r
17\r
18#define CONFIG_TABLE_SIZE_INCREASED 0x10\r
19\r
20UINTN mSystemTableAllocateSize = 0;\r
21\r
22\r
28a00297 23\r
162ed594 24/**\r
28a00297 25 Find a config table by name in system table's ConfigurationTable.\r
26\r
162ed594 27 @param Guid The table name to look for \r
28 @param Table Pointer of the config table \r
28a00297 29\r
162ed594 30 @retval EFI_NOT_FOUND Could not find the table in system table's \r
31 ConfigurationTable. \r
32 @retval EFI_SUCCESS Table successfully found.\r
28a00297 33\r
162ed594 34**/\r
35EFI_STATUS\r
36CoreGetConfigTable (\r
37 IN EFI_GUID *Guid,\r
38 OUT VOID **Table\r
39 )\r
28a00297 40{\r
41 UINTN Index;\r
42\r
43 for (Index = 0; Index < gDxeCoreST->NumberOfTableEntries; Index++) {\r
44 if (CompareGuid (Guid, &(gDxeCoreST->ConfigurationTable[Index].VendorGuid))) {\r
45 *Table = gDxeCoreST->ConfigurationTable[Index].VendorTable;\r
46 return EFI_SUCCESS;\r
47 }\r
48 }\r
49\r
50 return EFI_NOT_FOUND;\r
51}\r
52\r
53\r
54\r
162ed594 55\r
56/**\r
57 Boot Service called to add, modify, or remove a system configuration table from\r
58 the EFI System Table.\r
59\r
60 @param Guid Pointer to the GUID for the entry to add, update, or \r
61 remove \r
62 @param Table Pointer to the configuration table for the entry to add, \r
63 update, or remove, may be NULL. \r
64\r
65 @return EFI_SUCCESS Guid, Table pair added, updated, or removed.\r
66 @return EFI_INVALID_PARAMETER Input GUID not valid.\r
67 @return EFI_NOT_FOUND Attempted to delete non-existant entry\r
68 @return EFI_OUT_OF_RESOURCES Not enough memory available\r
69\r
70**/\r
28a00297 71EFI_STATUS\r
72EFIAPI\r
73CoreInstallConfigurationTable (\r
74 IN EFI_GUID *Guid,\r
75 IN VOID *Table\r
76 )\r
28a00297 77{\r
78 UINTN Index;\r
79 EFI_CONFIGURATION_TABLE *EfiConfigurationTable;\r
80\r
81 //\r
82 // If Guid is NULL, then this operation cannot be performed\r
83 //\r
84 if (Guid == NULL) {\r
85 return EFI_INVALID_PARAMETER;\r
86 }\r
87\r
88 EfiConfigurationTable = gDxeCoreST->ConfigurationTable;\r
89\r
90 //\r
91 // Search all the table for an entry that matches Guid\r
92 //\r
93 for (Index = 0; Index < gDxeCoreST->NumberOfTableEntries; Index++) {\r
94 if (CompareGuid (Guid, &(gDxeCoreST->ConfigurationTable[Index].VendorGuid))) {\r
95 break;\r
96 }\r
97 }\r
98\r
99 if (Index < gDxeCoreST->NumberOfTableEntries) {\r
100 //\r
101 // A match was found, so this is either a modify or a delete operation\r
102 //\r
103 if (Table != NULL) {\r
104 //\r
105 // If Table is not NULL, then this is a modify operation.\r
106 // Modify the table enty and return.\r
107 //\r
108 gDxeCoreST->ConfigurationTable[Index].VendorTable = Table;\r
109\r
110 //\r
111 // Signal Configuration Table change\r
112 //\r
113 CoreNotifySignalList (Guid);\r
114\r
115 return EFI_SUCCESS;\r
116 }\r
117\r
118 //\r
119 // A match was found and Table is NULL, so this is a delete operation.\r
120 //\r
121 gDxeCoreST->NumberOfTableEntries--;\r
122\r
123 //\r
124 // Copy over deleted entry\r
125 //\r
126 CopyMem (\r
127 &(EfiConfigurationTable[Index]),\r
128 &(gDxeCoreST->ConfigurationTable[Index + 1]),\r
129 (gDxeCoreST->NumberOfTableEntries - Index) * sizeof (EFI_CONFIGURATION_TABLE)\r
130 );\r
131\r
132 } else {\r
133\r
134 //\r
135 // No matching GUIDs were found, so this is an add operation.\r
136 //\r
137\r
138 if (Table == NULL) {\r
139 //\r
140 // If Table is NULL on an add operation, then return an error.\r
141 //\r
142 return EFI_NOT_FOUND;\r
143 }\r
144\r
145 //\r
146 // Assume that Index == gDxeCoreST->NumberOfTableEntries\r
147 //\r
148 if ((Index * sizeof (EFI_CONFIGURATION_TABLE)) >= mSystemTableAllocateSize) {\r
149 //\r
150 // Allocate a table with one additional entry.\r
151 //\r
152 mSystemTableAllocateSize += (CONFIG_TABLE_SIZE_INCREASED * sizeof (EFI_CONFIGURATION_TABLE));\r
153 EfiConfigurationTable = CoreAllocateRuntimePool (mSystemTableAllocateSize);\r
154 if (EfiConfigurationTable == NULL) {\r
155 //\r
156 // If a new table could not be allocated, then return an error.\r
157 //\r
158 return EFI_OUT_OF_RESOURCES;\r
159 }\r
160\r
161 if (gDxeCoreST->ConfigurationTable != NULL) {\r
162 //\r
163 // Copy the old table to the new table.\r
164 //\r
165 CopyMem (\r
166 EfiConfigurationTable,\r
167 gDxeCoreST->ConfigurationTable,\r
168 Index * sizeof (EFI_CONFIGURATION_TABLE)\r
169 );\r
170\r
171 //\r
172 // Free Old Table\r
173 //\r
174 CoreFreePool (gDxeCoreST->ConfigurationTable);\r
175 }\r
176\r
177 //\r
178 // Update System Table\r
179 //\r
180 gDxeCoreST->ConfigurationTable = EfiConfigurationTable;\r
181 }\r
182\r
183 //\r
184 // Fill in the new entry\r
185 //\r
186 CopyMem ((VOID *)&EfiConfigurationTable[Index].VendorGuid, Guid, sizeof (EFI_GUID));\r
187 EfiConfigurationTable[Index].VendorTable = Table;\r
188\r
189 //\r
190 // This is an add operation, so increment the number of table entries\r
191 //\r
192 gDxeCoreST->NumberOfTableEntries++;\r
193 }\r
194\r
195 //\r
196 // Fix up the CRC-32 in the EFI System Table\r
197 //\r
198 CalculateEfiHdrCrc (&gDxeCoreST->Hdr);\r
199\r
200 //\r
201 // Signal Configuration Table change\r
202 //\r
203 CoreNotifySignalList (Guid);\r
204\r
205 return EFI_SUCCESS;\r
206}\r