VirtioPciDevice.c 21 KB

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