]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/VirtioNetDxe/ComponentName.c
OvmfPkg/VirtioNetDxe: list "VirtioNet.h" in the INF file
[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
8 This program and the accompanying materials are licensed and made available\r
9 under the terms and conditions of the BSD License which accompanies this\r
10 distribution. The full text of the license may be found at\r
11 http://opensource.org/licenses/bsd-license.php\r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
14 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15\r
16**/\r
17\r
18#include <Library/UefiLib.h>\r
19\r
20#include "VirtioNet.h"\r
21\r
22STATIC\r
23EFI_UNICODE_STRING_TABLE mVirtioNetDriverNameTable[] = {\r
24 { "eng;en", L"Virtio Network Driver" },\r
25 { NULL, NULL }\r
26};\r
27\r
28STATIC\r
29EFI_UNICODE_STRING_TABLE mVirtioNetControllerNameTable[] = {\r
30 { "eng;en", L"Virtio Network Device" },\r
31 { NULL, NULL }\r
32};\r
33\r
34/**\r
35 Retrieves a Unicode string that is the user-readable name of the EFI Driver.\r
36\r
37 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
38 @param Language A pointer to a three-character ISO 639-2 language\r
39 identifier. This is the language of the driver name that\r
40 that the caller is requesting, and it must match one of\r
41 the languages specified in SupportedLanguages. The number\r
42 of languages supported by a driver is up to the driver\r
43 writer.\r
44 @param DriverName A pointer to the Unicode string to return. This Unicode\r
45 string is the name of the driver specified by This in the\r
46 language specified by Language.\r
47\r
48 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
49 This and the language specified by Language was\r
50 returned in DriverName.\r
51 @retval EFI_INVALID_PARAMETER Language is NULL.\r
52 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
53 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
54 the language specified by Language.\r
55\r
56**/\r
57\r
58STATIC\r
59EFI_STATUS\r
60EFIAPI\r
61VirtioNetGetDriverName (\r
62 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
63 IN CHAR8 *Language,\r
64 OUT CHAR16 **DriverName\r
65 )\r
66{\r
67 return (Language == NULL || DriverName == NULL) ?\r
68 EFI_INVALID_PARAMETER :\r
69 LookupUnicodeString2 (\r
70 Language,\r
71 This->SupportedLanguages,\r
72 mVirtioNetDriverNameTable,\r
73 DriverName,\r
74 (BOOLEAN) (This == &gVirtioNetComponentName) // Iso639Language\r
75 );\r
76}\r
77\r
78\r
79/**\r
80 Retrieves a Unicode string that is the user readable name of the controller\r
81 that is being managed by an EFI Driver.\r
82\r
83 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL\r
84 instance.\r
85 @param ControllerHandle The handle of a controller that the driver specified\r
86 by This is managing. This handle specifies the\r
87 controller whose name is to be returned.\r
88 @param ChildHandle The handle of the child controller to retrieve the\r
89 name of. This is an optional parameter that may be\r
90 NULL. It will be NULL for device drivers. It will\r
91 also be NULL for a bus drivers that wish to retrieve\r
92 the name of the bus controller. It will not be NULL\r
93 for a bus driver that wishes to retrieve the name of\r
94 a child controller.\r
95 @param Language A pointer to a three character ISO 639-2 language\r
96 identifier. This is the language of the controller\r
97 name that the caller is requesting, and it must\r
98 match one of the languages specified in\r
99 SupportedLanguages. The number of languages\r
100 supported by a driver is up to the driver writer.\r
101 @param ControllerName A pointer to the Unicode string to return. This\r
102 Unicode string is the name of the controller\r
103 specified by ControllerHandle and ChildHandle in the\r
104 language specified by Language, from the point of\r
105 view of the driver specified by This.\r
106\r
107 @retval EFI_SUCCESS The Unicode string for the user-readable name\r
108 in the language specified by Language for the\r
109 driver specified by This was returned in\r
110 DriverName.\r
111 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
112 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
113 EFI_HANDLE.\r
114 @retval EFI_INVALID_PARAMETER Language is NULL.\r
115 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
116 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
117 managing the controller specified by\r
118 ControllerHandle and ChildHandle.\r
119 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
120 the language specified by Language.\r
121\r
122**/\r
123\r
124STATIC\r
125EFI_STATUS\r
126EFIAPI\r
127VirtioNetGetControllerName (\r
128 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
129 IN EFI_HANDLE ControllerHandle,\r
130 IN EFI_HANDLE ChildHandle,\r
131 IN CHAR8 *Language,\r
132 OUT CHAR16 **ControllerName\r
133 )\r
134{\r
135 EFI_STATUS Status;\r
136\r
137 if (ControllerHandle == NULL || Language == NULL || ControllerName == NULL) {\r
138 return EFI_INVALID_PARAMETER;\r
139 }\r
140\r
141 //\r
56f65ed8 142 // confirm that the device is managed by this driver, using the VirtIo\r
bde8a2e0
LE
143 // Protocol\r
144 //\r
145 Status = EfiTestManagedDevice (\r
146 ControllerHandle,\r
147 gVirtioNetDriverBinding.DriverBindingHandle,\r
56f65ed8 148 &gVirtioDeviceProtocolGuid\r
bde8a2e0
LE
149 );\r
150 if (EFI_ERROR (Status)) {\r
151 return Status;\r
152 }\r
153\r
154 //\r
56f65ed8 155 // we don't give different names to the bus (= parent) handle and the\r
bde8a2e0
LE
156 // child (= MAC) handle\r
157 //\r
158 return LookupUnicodeString2 (\r
159 Language,\r
160 This->SupportedLanguages,\r
161 mVirtioNetControllerNameTable,\r
162 ControllerName,\r
163 (BOOLEAN) (This == &gVirtioNetComponentName) // Iso639Language\r
164 );\r
165}\r
166\r
167EFI_COMPONENT_NAME_PROTOCOL gVirtioNetComponentName = {\r
168 &VirtioNetGetDriverName,\r
169 &VirtioNetGetControllerName,\r
170 "eng" // SupportedLanguages, ISO 639-2 language codes\r
171};\r
172\r
173EFI_COMPONENT_NAME2_PROTOCOL gVirtioNetComponentName2 = {\r
174 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) &VirtioNetGetDriverName,\r
175 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) &VirtioNetGetControllerName,\r
176 "en" // SupportedLanguages, RFC 4646 language codes\r
177};\r