]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/VirtioNetDxe/ComponentName.c
OvmfPkg: Apply uncrustify changes
[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
ac0a286f 17EFI_UNICODE_STRING_TABLE mVirtioNetDriverNameTable[] = {\r
bde8a2e0
LE
18 { "eng;en", L"Virtio Network Driver" },\r
19 { NULL, NULL }\r
20};\r
21\r
22STATIC\r
ac0a286f 23EFI_UNICODE_STRING_TABLE mVirtioNetControllerNameTable[] = {\r
bde8a2e0
LE
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
bde8a2e0
LE
51STATIC\r
52EFI_STATUS\r
53EFIAPI\r
54VirtioNetGetDriverName (\r
ac0a286f
MK
55 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
56 IN CHAR8 *Language,\r
57 OUT CHAR16 **DriverName\r
bde8a2e0
LE
58 )\r
59{\r
60 return (Language == NULL || DriverName == NULL) ?\r
61 EFI_INVALID_PARAMETER :\r
62 LookupUnicodeString2 (\r
63 Language,\r
64 This->SupportedLanguages,\r
65 mVirtioNetDriverNameTable,\r
66 DriverName,\r
ac0a286f 67 (BOOLEAN)(This == &gVirtioNetComponentName) // Iso639Language\r
bde8a2e0
LE
68 );\r
69}\r
70\r
bde8a2e0
LE
71/**\r
72 Retrieves a Unicode string that is the user readable name of the controller\r
73 that is being managed by an EFI Driver.\r
74\r
75 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL\r
76 instance.\r
77 @param ControllerHandle The handle of a controller that the driver specified\r
78 by This is managing. This handle specifies the\r
79 controller whose name is to be returned.\r
80 @param ChildHandle The handle of the child controller to retrieve the\r
81 name of. This is an optional parameter that may be\r
82 NULL. It will be NULL for device drivers. It will\r
83 also be NULL for a bus drivers that wish to retrieve\r
84 the name of the bus controller. It will not be NULL\r
85 for a bus driver that wishes to retrieve the name of\r
86 a child controller.\r
87 @param Language A pointer to a three character ISO 639-2 language\r
88 identifier. This is the language of the controller\r
89 name that the caller is requesting, and it must\r
90 match one of the languages specified in\r
91 SupportedLanguages. The number of languages\r
92 supported by a driver is up to the driver writer.\r
93 @param ControllerName A pointer to the Unicode string to return. This\r
94 Unicode string is the name of the controller\r
95 specified by ControllerHandle and ChildHandle in the\r
96 language specified by Language, from the point of\r
97 view of the driver specified by This.\r
98\r
99 @retval EFI_SUCCESS The Unicode string for the user-readable name\r
100 in the language specified by Language for the\r
101 driver specified by This was returned in\r
102 DriverName.\r
103 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
104 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
105 EFI_HANDLE.\r
106 @retval EFI_INVALID_PARAMETER Language is NULL.\r
107 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
108 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
109 managing the controller specified by\r
110 ControllerHandle and ChildHandle.\r
111 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
112 the language specified by Language.\r
113\r
114**/\r
bde8a2e0
LE
115STATIC\r
116EFI_STATUS\r
117EFIAPI\r
118VirtioNetGetControllerName (\r
ac0a286f
MK
119 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
120 IN EFI_HANDLE ControllerHandle,\r
121 IN EFI_HANDLE ChildHandle,\r
122 IN CHAR8 *Language,\r
123 OUT CHAR16 **ControllerName\r
bde8a2e0
LE
124 )\r
125{\r
ac0a286f 126 EFI_STATUS Status;\r
bde8a2e0 127\r
ac0a286f 128 if ((ControllerHandle == NULL) || (Language == NULL) || (ControllerName == NULL)) {\r
bde8a2e0
LE
129 return EFI_INVALID_PARAMETER;\r
130 }\r
131\r
132 //\r
56f65ed8 133 // confirm that the device is managed by this driver, using the VirtIo\r
bde8a2e0
LE
134 // Protocol\r
135 //\r
136 Status = EfiTestManagedDevice (\r
137 ControllerHandle,\r
138 gVirtioNetDriverBinding.DriverBindingHandle,\r
56f65ed8 139 &gVirtioDeviceProtocolGuid\r
bde8a2e0
LE
140 );\r
141 if (EFI_ERROR (Status)) {\r
142 return Status;\r
143 }\r
144\r
145 //\r
56f65ed8 146 // we don't give different names to the bus (= parent) handle and the\r
bde8a2e0
LE
147 // child (= MAC) handle\r
148 //\r
149 return LookupUnicodeString2 (\r
150 Language,\r
151 This->SupportedLanguages,\r
152 mVirtioNetControllerNameTable,\r
153 ControllerName,\r
ac0a286f 154 (BOOLEAN)(This == &gVirtioNetComponentName) // Iso639Language\r
bde8a2e0
LE
155 );\r
156}\r
157\r
ac0a286f 158EFI_COMPONENT_NAME_PROTOCOL gVirtioNetComponentName = {\r
bde8a2e0
LE
159 &VirtioNetGetDriverName,\r
160 &VirtioNetGetControllerName,\r
161 "eng" // SupportedLanguages, ISO 639-2 language codes\r
162};\r
163\r
ac0a286f
MK
164EFI_COMPONENT_NAME2_PROTOCOL gVirtioNetComponentName2 = {\r
165 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)&VirtioNetGetDriverName,\r
166 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)&VirtioNetGetControllerName,\r
bde8a2e0
LE
167 "en" // SupportedLanguages, RFC 4646 language codes\r
168};\r