]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/VirtioPciDeviceDxe/VirtioPciDevice.c
OvmfPkg: raise PcdShellFileOperationSize to 128KB
[mirror_edk2.git] / OvmfPkg / VirtioPciDeviceDxe / VirtioPciDevice.c
CommitLineData
3bb56c06
OM
1/** @file\r
2\r
3 This driver produces Virtio Device Protocol instances for Virtio PCI devices.\r
4\r
5 Copyright (C) 2012, Red Hat, Inc.\r
694673c9 6 Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.<BR>\r
3bb56c06 7 Copyright (C) 2013, ARM Ltd.\r
4157b841 8 Copyright (C) 2017, AMD Inc, All rights reserved.<BR>\r
3bb56c06 9\r
b26f0cf9 10 SPDX-License-Identifier: BSD-2-Clause-Patent\r
3bb56c06
OM
11\r
12**/\r
13\r
14#include <IndustryStandard/Pci.h>\r
15#include <Library/BaseMemoryLib.h>\r
16#include <Library/DebugLib.h>\r
17#include <Library/MemoryAllocationLib.h>\r
18#include <Library/UefiBootServicesTableLib.h>\r
19#include <Library/UefiLib.h>\r
20\r
21#include "VirtioPciDevice.h"\r
22\r
23STATIC VIRTIO_DEVICE_PROTOCOL mDeviceProtocolTemplate = {\r
24 0, // Revision\r
25 0, // SubSystemDeviceId\r
26 VirtioPciGetDeviceFeatures, // GetDeviceFeatures\r
27 VirtioPciSetGuestFeatures, // SetGuestFeatures\r
3bb56c06
OM
28 VirtioPciSetQueueAddress, // SetQueueAddress\r
29 VirtioPciSetQueueSel, // SetQueueSel\r
30 VirtioPciSetQueueNotify, // SetQueueNotify\r
31 VirtioPciSetQueueAlignment, // SetQueueAlignment\r
32 VirtioPciSetPageSize, // SetPageSize\r
33 VirtioPciGetQueueSize, // GetQueueNumMax\r
34 VirtioPciSetQueueSize, // SetQueueNum\r
35 VirtioPciGetDeviceStatus, // GetDeviceStatus\r
36 VirtioPciSetDeviceStatus, // SetDeviceStatus\r
37 VirtioPciDeviceWrite, // WriteDevice\r
4157b841
BS
38 VirtioPciDeviceRead, // ReadDevice\r
39 VirtioPciAllocateSharedPages, // AllocateSharedPages\r
40 VirtioPciFreeSharedPages, // FreeSharedPages\r
41 VirtioPciMapSharedBuffer, // MapSharedBuffer\r
42 VirtioPciUnmapSharedBuffer, // UnmapSharedBuffer\r
3bb56c06
OM
43};\r
44\r
45/**\r
46\r
47 Read a word from Region 0 of the device specified by PciIo.\r
48\r
49 Region 0 must be an iomem region. This is an internal function for the PCI\r
50 implementation of the protocol.\r
51\r
52 @param[in] Dev Virtio PCI device.\r
53\r
54 @param[in] FieldOffset Source offset.\r
55\r
56 @param[in] FieldSize Source field size, must be in { 1, 2, 4, 8 }.\r
57\r
58 @param[in] BufferSize Number of bytes available in the target buffer. Must\r
59 equal FieldSize.\r
60\r
61 @param[out] Buffer Target buffer.\r
62\r
63\r
64 @return Status code returned by PciIo->Io.Read().\r
65\r
66**/\r
67EFI_STATUS\r
68EFIAPI\r
69VirtioPciIoRead (\r
70 IN VIRTIO_PCI_DEVICE *Dev,\r
71 IN UINTN FieldOffset,\r
72 IN UINTN FieldSize,\r
73 IN UINTN BufferSize,\r
74 OUT VOID *Buffer\r
75 )\r
76{\r
77 UINTN Count;\r
78 EFI_PCI_IO_PROTOCOL_WIDTH Width;\r
79 EFI_PCI_IO_PROTOCOL *PciIo;\r
80\r
81 ASSERT (FieldSize == BufferSize);\r
82\r
83 PciIo = Dev->PciIo;\r
84 Count = 1;\r
85\r
86 switch (FieldSize) {\r
87 case 1:\r
88 Width = EfiPciIoWidthUint8;\r
89 break;\r
90\r
91 case 2:\r
92 Width = EfiPciIoWidthUint16;\r
93 break;\r
94\r
95 case 8:\r
96 //\r
97 // The 64bit PCI I/O is broken down into two 32bit reads to prevent\r
98 // any alignment or width issues.\r
99 // The UEFI spec says under EFI_PCI_IO_PROTOCOL.Io.Write():\r
100 //\r
101 // The I/O operations are carried out exactly as requested. The caller\r
102 // is responsible for any alignment and I/O width issues which the\r
103 // bus, device, platform, or type of I/O might require. For example on\r
104 // some platforms, width requests of EfiPciIoWidthUint64 do not work.\r
105 //\r
106 Count = 2;\r
107\r
108 //\r
109 // fall through\r
110 //\r
111 case 4:\r
112 Width = EfiPciIoWidthUint32;\r
113 break;\r
114\r
115 default:\r
116 ASSERT (FALSE);\r
117 return EFI_INVALID_PARAMETER;\r
118 }\r
119\r
120 return PciIo->Io.Read (\r
121 PciIo,\r
122 Width,\r
123 PCI_BAR_IDX0,\r
124 FieldOffset,\r
125 Count,\r
126 Buffer\r
127 );\r
128}\r
129\r
130/**\r
131\r
132 Write a word into Region 0 of the device specified by PciIo.\r
133\r
134 Region 0 must be an iomem region. This is an internal function for the PCI\r
135 implementation of the protocol.\r
136\r
137 @param[in] Dev Virtio PCI device.\r
138\r
139 @param[in] FieldOffset Destination offset.\r
140\r
141 @param[in] FieldSize Destination field size, must be in { 1, 2, 4, 8 }.\r
142\r
143 @param[in] Value Little endian value to write, converted to UINT64.\r
144 The least significant FieldSize bytes will be used.\r
145\r
146\r
147 @return Status code returned by PciIo->Io.Write().\r
148\r
149**/\r
150EFI_STATUS\r
151EFIAPI\r
152VirtioPciIoWrite (\r
153 IN VIRTIO_PCI_DEVICE *Dev,\r
154 IN UINTN FieldOffset,\r
155 IN UINTN FieldSize,\r
156 IN UINT64 Value\r
157 )\r
158{\r
159 UINTN Count;\r
160 EFI_PCI_IO_PROTOCOL_WIDTH Width;\r
161 EFI_PCI_IO_PROTOCOL *PciIo;\r
162\r
163 PciIo = Dev->PciIo;\r
164 Count = 1;\r
165\r
166 switch (FieldSize) {\r
167 case 1:\r
168 Width = EfiPciIoWidthUint8;\r
169 break;\r
170\r
171 case 2:\r
172 Width = EfiPciIoWidthUint16;\r
173 break;\r
174\r
175 case 8:\r
176 //\r
177 // The 64bit PCI I/O is broken down into two 32bit writes to prevent\r
178 // any alignment or width issues.\r
179 // The UEFI spec says under EFI_PCI_IO_PROTOCOL.Io.Write():\r
180 //\r
181 // The I/O operations are carried out exactly as requested. The caller\r
182 // is responsible for any alignment and I/O width issues which the\r
183 // bus, device, platform, or type of I/O might require. For example on\r
184 // some platforms, width requests of EfiPciIoWidthUint64 do not work\r
185 //\r
186 Count = Count * 2;\r
187\r
188 //\r
189 // fall through\r
190 //\r
191 case 4:\r
192 Width = EfiPciIoWidthUint32;\r
193 break;\r
194\r
195 default:\r
196 ASSERT (FALSE);\r
197 return EFI_INVALID_PARAMETER;\r
198 }\r
199\r
200 return PciIo->Io.Write (\r
201 PciIo,\r
202 Width,\r
203 PCI_BAR_IDX0,\r
204 FieldOffset,\r
205 Count,\r
206 &Value\r
207 );\r
208}\r
209\r
210/**\r
211\r
212 Device probe function for this driver.\r
213\r
214 The DXE core calls this function for any given device in order to see if the\r
215 driver can drive the device.\r
216\r
217 @param[in] This The EFI_DRIVER_BINDING_PROTOCOL object\r
218 incorporating this driver (independently of\r
219 any device).\r
220\r
221 @param[in] DeviceHandle The device to probe.\r
222\r
223 @param[in] RemainingDevicePath Relevant only for bus drivers, ignored.\r
224\r
225\r
226 @retval EFI_SUCCESS The driver supports the device being probed.\r
227\r
228 @retval EFI_UNSUPPORTED Based on virtio-pci discovery, we do not support\r
229 the device.\r
230\r
231 @return Error codes from the OpenProtocol() boot service or\r
232 the PciIo protocol.\r
233\r
234**/\r
235STATIC\r
236EFI_STATUS\r
237EFIAPI\r
238VirtioPciDeviceBindingSupported (\r
239 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
240 IN EFI_HANDLE DeviceHandle,\r
241 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
242 )\r
243{\r
244 EFI_STATUS Status;\r
245 EFI_PCI_IO_PROTOCOL *PciIo;\r
246 PCI_TYPE00 Pci;\r
247\r
248 //\r
249 // Attempt to open the device with the PciIo set of interfaces. On success,\r
250 // the protocol is "instantiated" for the PCI device. Covers duplicate open\r
251 // attempts (EFI_ALREADY_STARTED).\r
252 //\r
253 Status = gBS->OpenProtocol (\r
254 DeviceHandle, // candidate device\r
255 &gEfiPciIoProtocolGuid, // for generic PCI access\r
256 (VOID **)&PciIo, // handle to instantiate\r
257 This->DriverBindingHandle, // requestor driver identity\r
258 DeviceHandle, // ControllerHandle, according to\r
259 // the UEFI Driver Model\r
260 EFI_OPEN_PROTOCOL_BY_DRIVER // get exclusive PciIo access to\r
261 // the device; to be released\r
262 );\r
263 if (EFI_ERROR (Status)) {\r
264 return Status;\r
265 }\r
266\r
267 //\r
268 // Read entire PCI configuration header for more extensive check ahead.\r
269 //\r
270 Status = PciIo->Pci.Read (\r
271 PciIo, // (protocol, device)\r
272 // handle\r
273 EfiPciIoWidthUint32, // access width & copy\r
274 // mode\r
275 0, // Offset\r
276 sizeof Pci / sizeof (UINT32), // Count\r
277 &Pci // target buffer\r
278 );\r
279\r
280 if (Status == EFI_SUCCESS) {\r
281 //\r
282 // virtio-0.9.5, 2.1 PCI Discovery\r
283 //\r
284 if ((Pci.Hdr.VendorId == VIRTIO_VENDOR_ID) &&\r
285 (Pci.Hdr.DeviceId >= 0x1000) &&\r
286 (Pci.Hdr.DeviceId <= 0x103F) &&\r
287 (Pci.Hdr.RevisionID == 0x00)) {\r
288 Status = EFI_SUCCESS;\r
289 } else {\r
290 Status = EFI_UNSUPPORTED;\r
291 }\r
292 }\r
293\r
294 //\r
295 // We needed PCI IO access only transitorily, to see whether we support the\r
296 // device or not.\r
297 //\r
298 gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,\r
299 This->DriverBindingHandle, DeviceHandle);\r
300\r
301 return Status;\r
302}\r
303\r
304/**\r
305\r
306 Initialize the VirtIo PCI Device\r
307\r
308 @param[in, out] Dev The driver instance to configure. The caller is\r
309 responsible for Device->PciIo's validity (ie. working IO\r
310 access to the underlying virtio-pci device).\r
311\r
312 @retval EFI_SUCCESS Setup complete.\r
313\r
314 @retval EFI_UNSUPPORTED The underlying IO device doesn't support the\r
315 provided address offset and read size.\r
316\r
317 @return Error codes from PciIo->Pci.Read().\r
318\r
319**/\r
320STATIC\r
321EFI_STATUS\r
322EFIAPI\r
323VirtioPciInit (\r
324 IN OUT VIRTIO_PCI_DEVICE *Device\r
325 )\r
326{\r
327 EFI_STATUS Status;\r
328 EFI_PCI_IO_PROTOCOL *PciIo;\r
329 PCI_TYPE00 Pci;\r
330\r
331 ASSERT (Device != NULL);\r
332 PciIo = Device->PciIo;\r
333 ASSERT (PciIo != NULL);\r
334 ASSERT (PciIo->Pci.Read != NULL);\r
335\r
336 Status = PciIo->Pci.Read (\r
337 PciIo, // (protocol, device)\r
338 // handle\r
339 EfiPciIoWidthUint32, // access width & copy\r
340 // mode\r
341 0, // Offset\r
342 sizeof (Pci) / sizeof (UINT32), // Count\r
343 &Pci // target buffer\r
344 );\r
345 if (EFI_ERROR (Status)) {\r
346 return Status;\r
347 }\r
348\r
349 //\r
350 // Copy protocol template\r
351 //\r
352 CopyMem (&Device->VirtioDevice, &mDeviceProtocolTemplate,\r
353 sizeof (VIRTIO_DEVICE_PROTOCOL));\r
354\r
355 //\r
356 // Initialize the protocol interface attributes\r
357 //\r
358 Device->VirtioDevice.Revision = VIRTIO_SPEC_REVISION (0, 9, 5);\r
359 Device->VirtioDevice.SubSystemDeviceId = Pci.Device.SubsystemID;\r
360\r
361 //\r
362 // Note: We don't support the MSI-X capability. If we did,\r
363 // the offset would become 24 after enabling MSI-X.\r
364 //\r
365 Device->DeviceSpecificConfigurationOffset =\r
366 VIRTIO_DEVICE_SPECIFIC_CONFIGURATION_OFFSET_PCI;\r
367\r
368 return EFI_SUCCESS;\r
369}\r
370\r
371/**\r
372\r
373 Uninitialize the internals of a virtio-pci device that has been successfully\r
374 set up with VirtioPciInit().\r
375\r
376 @param[in, out] Dev The device to clean up.\r
377\r
378**/\r
379\r
380STATIC\r
381VOID\r
382EFIAPI\r
383VirtioPciUninit (\r
384 IN OUT VIRTIO_PCI_DEVICE *Device\r
385 )\r
386{\r
387 // Note: This function mirrors VirtioPciInit() that does not allocate any\r
388 // resources - there's nothing to free here.\r
389}\r
390\r
391/**\r
392\r
393 After we've pronounced support for a specific device in\r
394 DriverBindingSupported(), we start managing said device (passed in by the\r
694673c9 395 Driver Execution Environment) with the following service.\r
3bb56c06
OM
396\r
397 See DriverBindingSupported() for specification references.\r
398\r
399 @param[in] This The EFI_DRIVER_BINDING_PROTOCOL object\r
400 incorporating this driver (independently of\r
401 any device).\r
402\r
403 @param[in] DeviceHandle The supported device to drive.\r
404\r
405 @param[in] RemainingDevicePath Relevant only for bus drivers, ignored.\r
406\r
407\r
408 @retval EFI_SUCCESS Driver instance has been created and\r
409 initialized for the virtio-pci device, it\r
410 is now accessible via VIRTIO_DEVICE_PROTOCOL.\r
411\r
412 @retval EFI_OUT_OF_RESOURCES Memory allocation failed.\r
413\r
414 @return Error codes from the OpenProtocol() boot\r
415 service, the PciIo protocol, VirtioPciInit(),\r
416 or the InstallProtocolInterface() boot service.\r
417\r
418**/\r
419STATIC\r
420EFI_STATUS\r
421EFIAPI\r
422VirtioPciDeviceBindingStart (\r
423 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
424 IN EFI_HANDLE DeviceHandle,\r
425 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
426 )\r
427{\r
428 VIRTIO_PCI_DEVICE *Device;\r
429 EFI_STATUS Status;\r
430\r
431 Device = (VIRTIO_PCI_DEVICE *) AllocateZeroPool (sizeof *Device);\r
432 if (Device == NULL) {\r
433 return EFI_OUT_OF_RESOURCES;\r
434 }\r
435\r
436 Status = gBS->OpenProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,\r
437 (VOID **)&Device->PciIo, This->DriverBindingHandle,\r
438 DeviceHandle, EFI_OPEN_PROTOCOL_BY_DRIVER);\r
439 if (EFI_ERROR (Status)) {\r
440 goto FreeVirtioPci;\r
441 }\r
442\r
443 //\r
444 // We must retain and ultimately restore the original PCI attributes of the\r
445 // device. See Driver Writer's Guide for UEFI 2.3.1 v1.01, 18.3 PCI drivers /\r
446 // 18.3.2 Start() and Stop().\r
447 //\r
448 // The third parameter ("Attributes", input) is ignored by the Get operation.\r
449 // The fourth parameter ("Result", output) is ignored by the Enable and Set\r
450 // operations.\r
451 //\r
452 // For virtio-pci we only need IO space access.\r
453 //\r
454 Status = Device->PciIo->Attributes (Device->PciIo,\r
455 EfiPciIoAttributeOperationGet, 0, &Device->OriginalPciAttributes);\r
456 if (EFI_ERROR (Status)) {\r
457 goto ClosePciIo;\r
458 }\r
459\r
78ef454b
BS
460 Status = Device->PciIo->Attributes (\r
461 Device->PciIo,\r
462 EfiPciIoAttributeOperationEnable,\r
463 (EFI_PCI_IO_ATTRIBUTE_IO |\r
464 EFI_PCI_IO_ATTRIBUTE_BUS_MASTER),\r
465 NULL\r
466 );\r
3bb56c06
OM
467 if (EFI_ERROR (Status)) {\r
468 goto ClosePciIo;\r
469 }\r
470\r
471 //\r
472 // PCI IO access granted, configure protocol instance\r
473 //\r
474\r
475 Status = VirtioPciInit (Device);\r
476 if (EFI_ERROR (Status)) {\r
477 goto RestorePciAttributes;\r
478 }\r
479\r
480 //\r
481 // Setup complete, attempt to export the driver instance's VirtioDevice\r
482 // interface.\r
483 //\r
484 Device->Signature = VIRTIO_PCI_DEVICE_SIGNATURE;\r
485 Status = gBS->InstallProtocolInterface (&DeviceHandle,\r
486 &gVirtioDeviceProtocolGuid, EFI_NATIVE_INTERFACE,\r
487 &Device->VirtioDevice);\r
488 if (EFI_ERROR (Status)) {\r
489 goto UninitDev;\r
490 }\r
491\r
492 return EFI_SUCCESS;\r
493\r
494UninitDev:\r
495 VirtioPciUninit (Device);\r
496\r
497RestorePciAttributes:\r
498 Device->PciIo->Attributes (Device->PciIo, EfiPciIoAttributeOperationSet,\r
499 Device->OriginalPciAttributes, NULL);\r
500\r
501ClosePciIo:\r
502 gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,\r
503 This->DriverBindingHandle, DeviceHandle);\r
504\r
505FreeVirtioPci:\r
506 FreePool (Device);\r
507\r
508 return Status;\r
509}\r
510\r
511/**\r
512\r
513 Stop driving the Virtio PCI device\r
514\r
515 @param[in] This The EFI_DRIVER_BINDING_PROTOCOL object\r
516 incorporating this driver (independently of any\r
517 device).\r
518\r
519 @param[in] DeviceHandle Stop driving this device.\r
520\r
521 @param[in] NumberOfChildren Since this function belongs to a device driver\r
522 only (as opposed to a bus driver), the caller\r
523 environment sets NumberOfChildren to zero, and\r
524 we ignore it.\r
525\r
526 @param[in] ChildHandleBuffer Ignored (corresponding to NumberOfChildren).\r
527\r
528 @retval EFI_SUCCESS Driver instance has been stopped and the PCI\r
529 configuration attributes have been restored.\r
530\r
531 @return Error codes from the OpenProtocol() or\r
532 CloseProtocol(), UninstallProtocolInterface()\r
533 boot services.\r
534\r
535**/\r
536STATIC\r
537EFI_STATUS\r
538EFIAPI\r
539VirtioPciDeviceBindingStop (\r
540 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
541 IN EFI_HANDLE DeviceHandle,\r
542 IN UINTN NumberOfChildren,\r
543 IN EFI_HANDLE *ChildHandleBuffer\r
544 )\r
545{\r
546 EFI_STATUS Status;\r
547 VIRTIO_DEVICE_PROTOCOL *VirtioDevice;\r
548 VIRTIO_PCI_DEVICE *Device;\r
549\r
550 Status = gBS->OpenProtocol (\r
551 DeviceHandle, // candidate device\r
552 &gVirtioDeviceProtocolGuid, // retrieve the VirtIo iface\r
553 (VOID **)&VirtioDevice, // target pointer\r
554 This->DriverBindingHandle, // requestor driver identity\r
555 DeviceHandle, // requesting lookup for dev.\r
556 EFI_OPEN_PROTOCOL_GET_PROTOCOL // lookup only, no ref. added\r
557 );\r
558 if (EFI_ERROR (Status)) {\r
559 return Status;\r
560 }\r
561\r
562 Device = VIRTIO_PCI_DEVICE_FROM_VIRTIO_DEVICE (VirtioDevice);\r
563\r
564 //\r
565 // Handle Stop() requests for in-use driver instances gracefully.\r
566 //\r
567 Status = gBS->UninstallProtocolInterface (DeviceHandle,\r
568 &gVirtioDeviceProtocolGuid, &Device->VirtioDevice);\r
569 if (EFI_ERROR (Status)) {\r
570 return Status;\r
571 }\r
572\r
573 VirtioPciUninit (Device);\r
574\r
575 Device->PciIo->Attributes (Device->PciIo, EfiPciIoAttributeOperationSet,\r
576 Device->OriginalPciAttributes, NULL);\r
577\r
578 Status = gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,\r
579 This->DriverBindingHandle, DeviceHandle);\r
580\r
581 FreePool (Device);\r
582\r
583 return Status;\r
584}\r
585\r
586\r
587//\r
588// The static object that groups the Supported() (ie. probe), Start() and\r
589// Stop() functions of the driver together. Refer to UEFI Spec 2.3.1 + Errata\r
590// C, 10.1 EFI Driver Binding Protocol.\r
591//\r
592STATIC EFI_DRIVER_BINDING_PROTOCOL gDriverBinding = {\r
593 &VirtioPciDeviceBindingSupported,\r
594 &VirtioPciDeviceBindingStart,\r
595 &VirtioPciDeviceBindingStop,\r
596 0x10, // Version, must be in [0x10 .. 0xFFFFFFEF] for IHV-developed drivers\r
597 NULL, // ImageHandle, to be overwritten by\r
598 // EfiLibInstallDriverBindingComponentName2() in VirtioPciEntryPoint()\r
599 NULL // DriverBindingHandle, ditto\r
600};\r
601\r
602\r
603//\r
604// The purpose of the following scaffolding (EFI_COMPONENT_NAME_PROTOCOL and\r
605// EFI_COMPONENT_NAME2_PROTOCOL implementation) is to format the driver's name\r
606// in English, for display on standard console devices. This is recommended for\r
607// UEFI drivers that follow the UEFI Driver Model. Refer to the Driver Writer's\r
608// Guide for UEFI 2.3.1 v1.01, 11 UEFI Driver and Controller Names.\r
609//\r
610STATIC\r
611EFI_UNICODE_STRING_TABLE mDriverNameTable[] = {\r
612 { "eng;en", L"Virtio PCI Driver" },\r
613 { NULL, NULL }\r
614};\r
615\r
616STATIC\r
617EFI_COMPONENT_NAME_PROTOCOL gComponentName;\r
618\r
619EFI_STATUS\r
620EFIAPI\r
621VirtioPciGetDriverName (\r
622 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
623 IN CHAR8 *Language,\r
624 OUT CHAR16 **DriverName\r
625 )\r
626{\r
627 return LookupUnicodeString2 (\r
628 Language,\r
629 This->SupportedLanguages,\r
630 mDriverNameTable,\r
631 DriverName,\r
632 (BOOLEAN)(This == &gComponentName) // Iso639Language\r
633 );\r
634}\r
635\r
636EFI_STATUS\r
637EFIAPI\r
638VirtioPciGetDeviceName (\r
639 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
640 IN EFI_HANDLE DeviceHandle,\r
641 IN EFI_HANDLE ChildHandle,\r
642 IN CHAR8 *Language,\r
643 OUT CHAR16 **ControllerName\r
644 )\r
645{\r
646 return EFI_UNSUPPORTED;\r
647}\r
648\r
649STATIC\r
650EFI_COMPONENT_NAME_PROTOCOL gComponentName = {\r
651 &VirtioPciGetDriverName,\r
652 &VirtioPciGetDeviceName,\r
653 "eng" // SupportedLanguages, ISO 639-2 language codes\r
654};\r
655\r
656STATIC\r
657EFI_COMPONENT_NAME2_PROTOCOL gComponentName2 = {\r
658 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) &VirtioPciGetDriverName,\r
659 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) &VirtioPciGetDeviceName,\r
660 "en" // SupportedLanguages, RFC 4646 language codes\r
661};\r
662\r
663\r
664//\r
665// Entry point of this driver.\r
666//\r
667EFI_STATUS\r
668EFIAPI\r
669VirtioPciDeviceEntryPoint (\r
670 IN EFI_HANDLE ImageHandle,\r
671 IN EFI_SYSTEM_TABLE *SystemTable\r
672 )\r
673{\r
674 return EfiLibInstallDriverBindingComponentName2 (\r
675 ImageHandle,\r
676 SystemTable,\r
677 &gDriverBinding,\r
678 ImageHandle,\r
679 &gComponentName,\r
680 &gComponentName2\r
681 );\r
682}\r