@@ -109,23 +109,27 @@ void efi_char16_printk(efi_system_table_t *table, efi_char16_t *str)
109
109
}
110
110
111
111
static efi_status_t
112
- __setup_efi_pci32 ( efi_pci_io_protocol_32_t * pci , struct pci_setup_rom * * __rom )
112
+ __setup_efi_pci ( efi_pci_io_protocol_t * pci , struct pci_setup_rom * * __rom )
113
113
{
114
114
struct pci_setup_rom * rom = NULL ;
115
115
efi_status_t status ;
116
116
unsigned long size ;
117
- uint64_t attributes ;
117
+ uint64_t attributes , romsize ;
118
+ void * romimage ;
118
119
119
- status = efi_early -> call ( pci -> attributes , pci ,
120
- EfiPciIoAttributeOperationGet , 0 , 0 ,
121
- & attributes );
120
+ status = efi_call_proto ( efi_pci_io_protocol , attributes , pci ,
121
+ EfiPciIoAttributeOperationGet , 0 , 0 ,
122
+ & attributes );
122
123
if (status != EFI_SUCCESS )
123
124
return status ;
124
125
125
- if (!pci -> romimage || !pci -> romsize )
126
+ romimage = (void * )(unsigned long )efi_table_attr (efi_pci_io_protocol ,
127
+ romimage , pci );
128
+ romsize = efi_table_attr (efi_pci_io_protocol , romsize , pci );
129
+ if (!romimage || !romsize )
126
130
return EFI_INVALID_PARAMETER ;
127
131
128
- size = pci -> romsize + sizeof (* rom );
132
+ size = romsize + sizeof (* rom );
129
133
130
134
status = efi_call_early (allocate_pool , EFI_LOADER_DATA , size , & rom );
131
135
if (status != EFI_SUCCESS ) {
@@ -141,30 +145,32 @@ __setup_efi_pci32(efi_pci_io_protocol_32_t *pci, struct pci_setup_rom **__rom)
141
145
rom -> pcilen = pci -> romsize ;
142
146
* __rom = rom ;
143
147
144
- status = efi_early -> call (pci -> pci .read , pci , EfiPciIoWidthUint16 ,
145
- PCI_VENDOR_ID , 1 , & (rom -> vendor ));
148
+ status = efi_call_proto (efi_pci_io_protocol , pci .read , pci ,
149
+ EfiPciIoWidthUint16 , PCI_VENDOR_ID , 1 ,
150
+ & rom -> vendor );
146
151
147
152
if (status != EFI_SUCCESS ) {
148
153
efi_printk (sys_table , "Failed to read rom->vendor\n" );
149
154
goto free_struct ;
150
155
}
151
156
152
- status = efi_early -> call (pci -> pci .read , pci , EfiPciIoWidthUint16 ,
153
- PCI_DEVICE_ID , 1 , & (rom -> devid ));
157
+ status = efi_call_proto (efi_pci_io_protocol , pci .read , pci ,
158
+ EfiPciIoWidthUint16 , PCI_DEVICE_ID , 1 ,
159
+ & rom -> devid );
154
160
155
161
if (status != EFI_SUCCESS ) {
156
162
efi_printk (sys_table , "Failed to read rom->devid\n" );
157
163
goto free_struct ;
158
164
}
159
165
160
- status = efi_early -> call (pci -> get_location , pci , & (rom -> segment ),
161
- & (rom -> bus ), & (rom -> device ), & (rom -> function ));
166
+ status = efi_call_proto (efi_pci_io_protocol , get_location , pci ,
167
+ & rom -> segment , & rom -> bus , & rom -> device ,
168
+ & rom -> function );
162
169
163
170
if (status != EFI_SUCCESS )
164
171
goto free_struct ;
165
172
166
- memcpy (rom -> romdata , (void * )(unsigned long )pci -> romimage ,
167
- pci -> romsize );
173
+ memcpy (rom -> romdata , romimage , romsize );
168
174
return status ;
169
175
170
176
free_struct :
@@ -176,7 +182,7 @@ static void
176
182
setup_efi_pci32 (struct boot_params * params , void * * pci_handle ,
177
183
unsigned long size )
178
184
{
179
- efi_pci_io_protocol_32_t * pci = NULL ;
185
+ efi_pci_io_protocol_t * pci = NULL ;
180
186
efi_guid_t pci_proto = EFI_PCI_IO_PROTOCOL_GUID ;
181
187
u32 * handles = (u32 * )(unsigned long )pci_handle ;
182
188
efi_status_t status ;
@@ -203,7 +209,7 @@ setup_efi_pci32(struct boot_params *params, void **pci_handle,
203
209
if (!pci )
204
210
continue ;
205
211
206
- status = __setup_efi_pci32 (pci , & rom );
212
+ status = __setup_efi_pci (pci , & rom );
207
213
if (status != EFI_SUCCESS )
208
214
continue ;
209
215
@@ -217,74 +223,11 @@ setup_efi_pci32(struct boot_params *params, void **pci_handle,
217
223
}
218
224
}
219
225
220
- static efi_status_t
221
- __setup_efi_pci64 (efi_pci_io_protocol_64_t * pci , struct pci_setup_rom * * __rom )
222
- {
223
- struct pci_setup_rom * rom ;
224
- efi_status_t status ;
225
- unsigned long size ;
226
- uint64_t attributes ;
227
-
228
- status = efi_early -> call (pci -> attributes , pci ,
229
- EfiPciIoAttributeOperationGet , 0 ,
230
- & attributes );
231
- if (status != EFI_SUCCESS )
232
- return status ;
233
-
234
- if (!pci -> romimage || !pci -> romsize )
235
- return EFI_INVALID_PARAMETER ;
236
-
237
- size = pci -> romsize + sizeof (* rom );
238
-
239
- status = efi_call_early (allocate_pool , EFI_LOADER_DATA , size , & rom );
240
- if (status != EFI_SUCCESS ) {
241
- efi_printk (sys_table , "Failed to alloc mem for rom\n" );
242
- return status ;
243
- }
244
-
245
- rom -> data .type = SETUP_PCI ;
246
- rom -> data .len = size - sizeof (struct setup_data );
247
- rom -> data .next = 0 ;
248
- rom -> pcilen = pci -> romsize ;
249
- * __rom = rom ;
250
-
251
- status = efi_early -> call (pci -> pci .read , pci , EfiPciIoWidthUint16 ,
252
- PCI_VENDOR_ID , 1 , & (rom -> vendor ));
253
-
254
- if (status != EFI_SUCCESS ) {
255
- efi_printk (sys_table , "Failed to read rom->vendor\n" );
256
- goto free_struct ;
257
- }
258
-
259
- status = efi_early -> call (pci -> pci .read , pci , EfiPciIoWidthUint16 ,
260
- PCI_DEVICE_ID , 1 , & (rom -> devid ));
261
-
262
- if (status != EFI_SUCCESS ) {
263
- efi_printk (sys_table , "Failed to read rom->devid\n" );
264
- goto free_struct ;
265
- }
266
-
267
- status = efi_early -> call (pci -> get_location , pci , & (rom -> segment ),
268
- & (rom -> bus ), & (rom -> device ), & (rom -> function ));
269
-
270
- if (status != EFI_SUCCESS )
271
- goto free_struct ;
272
-
273
- memcpy (rom -> romdata , (void * )(unsigned long )pci -> romimage ,
274
- pci -> romsize );
275
- return status ;
276
-
277
- free_struct :
278
- efi_call_early (free_pool , rom );
279
- return status ;
280
-
281
- }
282
-
283
226
static void
284
227
setup_efi_pci64 (struct boot_params * params , void * * pci_handle ,
285
228
unsigned long size )
286
229
{
287
- efi_pci_io_protocol_64_t * pci = NULL ;
230
+ efi_pci_io_protocol_t * pci = NULL ;
288
231
efi_guid_t pci_proto = EFI_PCI_IO_PROTOCOL_GUID ;
289
232
u64 * handles = (u64 * )(unsigned long )pci_handle ;
290
233
efi_status_t status ;
@@ -311,7 +254,7 @@ setup_efi_pci64(struct boot_params *params, void **pci_handle,
311
254
if (!pci )
312
255
continue ;
313
256
314
- status = __setup_efi_pci64 (pci , & rom );
257
+ status = __setup_efi_pci (pci , & rom );
315
258
if (status != EFI_SUCCESS )
316
259
continue ;
317
260
0 commit comments