@@ -109,23 +109,27 @@ void efi_char16_printk(efi_system_table_t *table, efi_char16_t *str)
109109}
110110
111111static 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 )
113113{
114114 struct pci_setup_rom * rom = NULL ;
115115 efi_status_t status ;
116116 unsigned long size ;
117- uint64_t attributes ;
117+ uint64_t attributes , romsize ;
118+ void * romimage ;
118119
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 );
122123 if (status != EFI_SUCCESS )
123124 return status ;
124125
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 )
126130 return EFI_INVALID_PARAMETER ;
127131
128- size = pci -> romsize + sizeof (* rom );
132+ size = romsize + sizeof (* rom );
129133
130134 status = efi_call_early (allocate_pool , EFI_LOADER_DATA , size , & rom );
131135 if (status != EFI_SUCCESS ) {
@@ -141,30 +145,32 @@ __setup_efi_pci32(efi_pci_io_protocol_32_t *pci, struct pci_setup_rom **__rom)
141145 rom -> pcilen = pci -> romsize ;
142146 * __rom = rom ;
143147
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 );
146151
147152 if (status != EFI_SUCCESS ) {
148153 efi_printk (sys_table , "Failed to read rom->vendor\n" );
149154 goto free_struct ;
150155 }
151156
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 );
154160
155161 if (status != EFI_SUCCESS ) {
156162 efi_printk (sys_table , "Failed to read rom->devid\n" );
157163 goto free_struct ;
158164 }
159165
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 );
162169
163170 if (status != EFI_SUCCESS )
164171 goto free_struct ;
165172
166- memcpy (rom -> romdata , (void * )(unsigned long )pci -> romimage ,
167- pci -> romsize );
173+ memcpy (rom -> romdata , romimage , romsize );
168174 return status ;
169175
170176free_struct :
@@ -176,7 +182,7 @@ static void
176182setup_efi_pci32 (struct boot_params * params , void * * pci_handle ,
177183 unsigned long size )
178184{
179- efi_pci_io_protocol_32_t * pci = NULL ;
185+ efi_pci_io_protocol_t * pci = NULL ;
180186 efi_guid_t pci_proto = EFI_PCI_IO_PROTOCOL_GUID ;
181187 u32 * handles = (u32 * )(unsigned long )pci_handle ;
182188 efi_status_t status ;
@@ -203,7 +209,7 @@ setup_efi_pci32(struct boot_params *params, void **pci_handle,
203209 if (!pci )
204210 continue ;
205211
206- status = __setup_efi_pci32 (pci , & rom );
212+ status = __setup_efi_pci (pci , & rom );
207213 if (status != EFI_SUCCESS )
208214 continue ;
209215
@@ -217,74 +223,11 @@ setup_efi_pci32(struct boot_params *params, void **pci_handle,
217223 }
218224}
219225
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-
283226static void
284227setup_efi_pci64 (struct boot_params * params , void * * pci_handle ,
285228 unsigned long size )
286229{
287- efi_pci_io_protocol_64_t * pci = NULL ;
230+ efi_pci_io_protocol_t * pci = NULL ;
288231 efi_guid_t pci_proto = EFI_PCI_IO_PROTOCOL_GUID ;
289232 u64 * handles = (u64 * )(unsigned long )pci_handle ;
290233 efi_status_t status ;
@@ -311,7 +254,7 @@ setup_efi_pci64(struct boot_params *params, void **pci_handle,
311254 if (!pci )
312255 continue ;
313256
314- status = __setup_efi_pci64 (pci , & rom );
257+ status = __setup_efi_pci (pci , & rom );
315258 if (status != EFI_SUCCESS )
316259 continue ;
317260
0 commit comments