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