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