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