]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/VirtioNetDxe/ComponentName.c
OvmfPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / OvmfPkg / VirtioNetDxe / ComponentName.c
CommitLineData
bde8a2e0
LE
1/** @file\r
2\r
3 Component Name code for the virtio-net driver.\r
4\r
5 Copyright (C) 2013, Red Hat, Inc.\r
6 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
7\r
b26f0cf9 8 SPDX-License-Identifier: BSD-2-Clause-Patent\r
bde8a2e0
LE
9\r
10**/\r
11\r
12#include <Library/UefiLib.h>\r
13\r
14#include "VirtioNet.h"\r
15\r
16STATIC\r
17EFI_UNICODE_STRING_TABLE mVirtioNetDriverNameTable[] = {\r
18 { "eng;en", L"Virtio Network Driver" },\r
19 { NULL, NULL }\r
20};\r
21\r
22STATIC\r
23EFI_UNICODE_STRING_TABLE mVirtioNetControllerNameTable[] = {\r
24 { "eng;en", L"Virtio Network Device" },\r
25 { NULL, NULL }\r
26};\r
27\r
28/**\r
29 Retrieves a Unicode string that is the user-readable name of the EFI Driver.\r
30\r
31 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
32 @param Language A pointer to a three-character ISO 639-2 language\r
33 identifier. This is the language of the driver name that\r
34 that the caller is requesting, and it must match one of\r
35 the languages specified in SupportedLanguages. The number\r
36 of languages supported by a driver is up to the driver\r
37 writer.\r
38 @param DriverName A pointer to the Unicode string to return. This Unicode\r
39 string is the name of the driver specified by This in the\r
40 language specified by Language.\r
41\r
42 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
43 This and the language specified by Language was\r
44 returned in DriverName.\r
45 @retval EFI_INVALID_PARAMETER Language is NULL.\r
46 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
47 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
48 the language specified by Language.\r
49\r
50**/\r
51\r
52STATIC\r
53EFI_STATUS\r
54EFIAPI\r
55VirtioNetGetDriverName (\r
56 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
57 IN CHAR8 *Language,\r
58 OUT CHAR16 **DriverName\r
59 )\r
60{\r
61 return (Language == NULL || DriverName == NULL) ?\r
62 EFI_INVALID_PARAMETER :\r
63 LookupUnicodeString2 (\r
64 Language,\r
65 This->SupportedLanguages,\r
66 mVirtioNetDriverNameTable,\r
67 DriverName,\r
68 (BOOLEAN) (This == &gVirtioNetComponentName) // Iso639Language\r
69 );\r
70}\r
71\r
72\r
73/**\r
74 Retrieves a Unicode string that is the user readable name of the controller\r
75 that is being managed by an EFI Driver.\r
76\r
77 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL\r
78 instance.\r
79 @param ControllerHandle The handle of a controller that the driver specified\r
80 by This is managing. This handle specifies the\r
81 controller whose name is to be returned.\r
82 @param ChildHandle The handle of the child controller to retrieve the\r
83 name of. This is an optional parameter that may be\r
84 NULL. It will be NULL for device drivers. It will\r
85 also be NULL for a bus drivers that wish to retrieve\r
86 the name of the bus controller. It will not be NULL\r
87 for a bus driver that wishes to retrieve the name of\r
88 a child controller.\r
89 @param Language A pointer to a three character ISO 639-2 language\r
90 identifier. This is the language of the controller\r
91 name that the caller is requesting, and it must\r
92 match one of the languages specified in\r
93 SupportedLanguages. The number of languages\r
94 supported by a driver is up to the driver writer.\r
95 @param ControllerName A pointer to the Unicode string to return. This\r
96 Unicode string is the name of the controller\r
97 specified by ControllerHandle and ChildHandle in the\r
98 language specified by Language, from the point of\r
99 view of the driver specified by This.\r
100\r
101 @retval EFI_SUCCESS The Unicode string for the user-readable name\r
102 in the language specified by Language for the\r
103 driver specified by This was returned in\r
104 DriverName.\r
105 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
106 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
107 EFI_HANDLE.\r
108 @retval EFI_INVALID_PARAMETER Language is NULL.\r
109 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
110 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
111 managing the controller specified by\r
112 ControllerHandle and ChildHandle.\r
113 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
114 the language specified by Language.\r
115\r
116**/\r
117\r
118STATIC\r
119EFI_STATUS\r
120EFIAPI\r
121VirtioNetGetControllerName (\r
122 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
123 IN EFI_HANDLE ControllerHandle,\r
124 IN EFI_HANDLE ChildHandle,\r
125 IN CHAR8 *Language,\r
126 OUT CHAR16 **ControllerName\r
127 )\r
128{\r
129 EFI_STATUS Status;\r
130\r
131 if (ControllerHandle == NULL || Language == NULL || ControllerName == NULL) {\r
132 return EFI_INVALID_PARAMETER;\r
133 }\r
134\r
135 //\r
56f65ed8 136 // confirm that the device is managed by this driver, using the VirtIo\r
bde8a2e0
LE
137 // Protocol\r
138 //\r
139 Status = EfiTestManagedDevice (\r
140 ControllerHandle,\r
141 gVirtioNetDriverBinding.DriverBindingHandle,\r
56f65ed8 142 &gVirtioDeviceProtocolGuid\r
bde8a2e0
LE
143 );\r
144 if (EFI_ERROR (Status)) {\r
145 return Status;\r
146 }\r
147\r
148 //\r
56f65ed8 149 // we don't give different names to the bus (= parent) handle and the\r
bde8a2e0
LE
150 // child (= MAC) handle\r
151 //\r
152 return LookupUnicodeString2 (\r
153 Language,\r
154 This->SupportedLanguages,\r
155 mVirtioNetControllerNameTable,\r
156 ControllerName,\r
157 (BOOLEAN) (This == &gVirtioNetComponentName) // Iso639Language\r
158 );\r
159}\r
160\r
161EFI_COMPONENT_NAME_PROTOCOL gVirtioNetComponentName = {\r
162 &VirtioNetGetDriverName,\r
163 &VirtioNetGetControllerName,\r
164 "eng" // SupportedLanguages, ISO 639-2 language codes\r
165};\r
166\r
167EFI_COMPONENT_NAME2_PROTOCOL gVirtioNetComponentName2 = {\r
168 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) &VirtioNetGetDriverName,\r
169 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) &VirtioNetGetControllerName,\r
170 "en" // SupportedLanguages, RFC 4646 language codes\r
171};\r