VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/E1kNetDxe/ComponentName.c@ 108198

Last change on this file since 108198 was 106066, checked in by vboxsync, 5 months ago

Manual copyright year updates.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette