35#define USB_BASE_CLASS_MISCELLANEOUS 0xEF
36#define USB_MISCELLANEOUS_SUBCLASS_COMMON 0x02
37#define USB_MISCELLANEOUS_PROTOCOL_IAD 0x01
63 &gConPlatformTextInDriverBinding,
65 &gConPlatformComponentName,
66 &gConPlatformComponentName2
73 &gConPlatformTextOutDriverBinding,
75 &gConPlatformComponentName,
76 &gConPlatformComponentName2
106 &gEfiSimpleTextInProtocolGuid
133 &gEfiSimpleTextOutProtocolGuid
162 Status =
gBS->OpenProtocol (
164 &gEfiDevicePathProtocolGuid,
166 This->DriverBindingHandle,
168 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
170 if (EFI_ERROR (Status)) {
177 Status =
gBS->OpenProtocol (
181 This->DriverBindingHandle,
183 EFI_OPEN_PROTOCOL_BY_DRIVER
185 if (EFI_ERROR (Status)) {
192 This->DriverBindingHandle,
228 BOOLEAN IsInConInVariable;
233 Status =
gBS->OpenProtocol (
235 &gEfiDevicePathProtocolGuid,
236 (VOID **)&DevicePath,
237 This->DriverBindingHandle,
239 EFI_OPEN_PROTOCOL_GET_PROTOCOL
241 if (EFI_ERROR (Status)) {
248 Status =
gBS->OpenProtocol (
250 &gEfiSimpleTextInProtocolGuid,
252 This->DriverBindingHandle,
254 EFI_OPEN_PROTOCOL_BY_DRIVER
256 if (EFI_ERROR (Status)) {
263 IsInConInVariable =
FALSE;
269 if (!EFI_ERROR (Status)) {
270 IsInConInVariable =
TRUE;
286 if (IsInConInVariable) {
287 gBS->InstallMultipleProtocolInterfaces (
289 &gEfiConsoleInDeviceGuid,
296 &gEfiSimpleTextInProtocolGuid,
297 This->DriverBindingHandle,
336 BOOLEAN IsInConOutVariable;
337 BOOLEAN IsInErrOutVariable;
344 Status =
gBS->OpenProtocol (
346 &gEfiDevicePathProtocolGuid,
347 (VOID **)&DevicePath,
348 This->DriverBindingHandle,
350 EFI_OPEN_PROTOCOL_GET_PROTOCOL
352 if (EFI_ERROR (Status)) {
359 Status =
gBS->OpenProtocol (
361 &gEfiSimpleTextOutProtocolGuid,
363 This->DriverBindingHandle,
365 EFI_OPEN_PROTOCOL_BY_DRIVER
367 if (EFI_ERROR (Status)) {
374 IsInConOutVariable =
FALSE;
380 if (!EFI_ERROR (Status)) {
381 IsInConOutVariable =
TRUE;
384 IsInErrOutVariable =
FALSE;
390 if (!EFI_ERROR (Status)) {
391 IsInErrOutVariable =
TRUE;
418 if (IsInConOutVariable) {
420 Status =
gBS->InstallMultipleProtocolInterfaces (
422 &gEfiConsoleOutDeviceGuid,
432 if (IsInErrOutVariable) {
434 gBS->InstallMultipleProtocolInterfaces (
436 &gEfiStandardErrorDeviceGuid,
445 &gEfiSimpleTextOutProtocolGuid,
446 This->DriverBindingHandle,
483 Status =
gBS->OpenProtocol (
485 &gEfiDevicePathProtocolGuid,
486 (VOID **)&DevicePath,
487 This->DriverBindingHandle,
489 EFI_OPEN_PROTOCOL_GET_PROTOCOL
494 if (!EFI_ERROR (Status)) {
511 &gEfiConsoleInDeviceGuid
519 &gEfiSimpleTextInProtocolGuid,
520 This->DriverBindingHandle,
556 Status =
gBS->OpenProtocol (
558 &gEfiDevicePathProtocolGuid,
559 (VOID **)&DevicePath,
560 This->DriverBindingHandle,
562 EFI_OPEN_PROTOCOL_GET_PROTOCOL
564 if (!EFI_ERROR (Status)) {
586 &gEfiConsoleOutDeviceGuid
592 &gEfiStandardErrorDeviceGuid
600 &gEfiSimpleTextOutProtocolGuid,
601 This->DriverBindingHandle,
625 Status =
gBS->OpenProtocol (
629 This->DriverBindingHandle,
631 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
634 if (!EFI_ERROR (Status)) {
635 gBS->UninstallMultipleProtocolInterfaces (
675 Status =
gRT->GetVariable (
677 &gEfiGlobalVariableGuid,
683 if (Status == EFI_BUFFER_TOO_SMALL) {
688 if (Buffer ==
NULL) {
695 Status =
gRT->GetVariable (
697 &gEfiGlobalVariableGuid,
702 if (EFI_ERROR (Status)) {
788 UINT8 DeviceSubClass;
789 UINT8 DeviceProtocol;
800 Status = UsbIo->UsbGetDeviceDescriptor (UsbIo, &DevDesc);
801 if (EFI_ERROR (Status)) {
805 if ((UsbClass->VendorId != 0xffff) &&
806 (UsbClass->VendorId != DevDesc.IdVendor))
811 if ((UsbClass->ProductId != 0xffff) &&
812 (UsbClass->ProductId != DevDesc.IdProduct))
817 DeviceClass = DevDesc.DeviceClass;
818 DeviceSubClass = DevDesc.DeviceSubClass;
819 DeviceProtocol = DevDesc.DeviceProtocol;
821 if ((DeviceClass == 0) ||
822 ((DeviceClass == USB_BASE_CLASS_MISCELLANEOUS) &&
823 (DeviceSubClass == USB_MISCELLANEOUS_SUBCLASS_COMMON) &&
824 (DeviceProtocol == USB_MISCELLANEOUS_PROTOCOL_IAD)))
831 Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &IfDesc);
832 if (EFI_ERROR (Status)) {
836 DeviceClass = IfDesc.InterfaceClass;
837 DeviceSubClass = IfDesc.InterfaceSubClass;
838 DeviceProtocol = IfDesc.InterfaceProtocol;
844 if ((UsbClass->DeviceClass != 0xff) &&
845 (UsbClass->DeviceClass != DeviceClass))
850 if ((UsbClass->DeviceSubClass != 0xff) &&
851 (UsbClass->DeviceSubClass != DeviceSubClass))
856 if ((UsbClass->DeviceProtocol != 0xff) &&
857 (UsbClass->DeviceProtocol != DeviceProtocol))
890 CHAR16 *SerialNumberStr;
902 Status = UsbIo->UsbGetDeviceDescriptor (UsbIo, &DevDesc);
903 if (EFI_ERROR (Status)) {
907 if ((DevDesc.IdVendor != UsbWwid->VendorId) ||
908 (DevDesc.IdProduct != UsbWwid->ProductId))
916 Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &IfDesc);
917 if (EFI_ERROR (Status)) {
921 if (IfDesc.InterfaceNumber != UsbWwid->InterfaceNumber) {
928 if (DevDesc.StrSerialNumber == 0) {
937 Status = UsbIo->UsbGetSupportedLanguages (UsbIo, &LangIdTable, &TableSize);
938 if (EFI_ERROR (Status) || (TableSize == 0) || (LangIdTable ==
NULL)) {
945 CompareStr = (CHAR16 *)(
UINTN)(UsbWwid + 1);
947 if (CompareStr[CompareLen - 1] == L
'\0') {
954 for (Index = 0; Index < TableSize /
sizeof (UINT16); Index++) {
955 SerialNumberStr =
NULL;
956 Status = UsbIo->UsbGetStringDescriptor (
959 DevDesc.StrSerialNumber,
962 if (EFI_ERROR (Status) || (SerialNumberStr ==
NULL)) {
966 Length =
StrLen (SerialNumberStr);
967 if ((Length >= CompareLen) &&
968 (
CompareMem (SerialNumberStr + Length - CompareLen, CompareStr, CompareLen *
sizeof (CHAR16)) == 0))
997 UINTN ParentDevicePathSize;
1002 for ( ShortformNode = ShortformPath
1026 ParentDevicePathSize = (
UINTN)ShortformNode - (
UINTN)ShortformPath;
1027 RemainingDevicePath = FullPath;
1028 Status =
gBS->LocateDevicePath (&gEfiUsbIoProtocolGuid, &RemainingDevicePath, &Handle);
1029 if (EFI_ERROR (Status)) {
1033 if (ParentDevicePathSize != 0) {
1034 if ((ParentDevicePathSize > (
UINTN)RemainingDevicePath - (
UINTN)FullPath) ||
1035 (
CompareMem (FullPath, ShortformPath, ParentDevicePathSize) != 0))
1044 Status =
gBS->HandleProtocol (
1046 &gEfiUsbIoProtocolGuid,
1092 if ((Multi ==
NULL) || (Single ==
NULL)) {
1093 return EFI_INVALID_PARAMETER;
1100 if (NewDevicePath ==
NULL) {
1101 return EFI_INVALID_PARAMETER;
1105 TempDevicePath1 =
NULL;
1113 while (DevicePathInst !=
NULL) {
1114 if ((
CompareMem (Single, DevicePathInst, Size) == 0) ||
1134 if (TempDevicePath1 !=
NULL) {
1138 TempDevicePath1 = TempDevicePath2;
1150 *NewDevicePath = TempDevicePath1;
1154 return EFI_NOT_FOUND;
1172 IN CHAR16 *VariableName,
1174 IN CONPLATFORM_VAR_OPERATION Operation
1181 VariableDevicePath =
NULL;
1182 NewVariableDevicePath =
NULL;
1191 if (Operation != Delete) {
1202 if ((Operation == Check) || (!EFI_ERROR (Status))) {
1208 if (VariableDevicePath !=
NULL) {
1223 if (NewVariableDevicePath ==
NULL) {
1224 Status = EFI_OUT_OF_RESOURCES;
1234 &NewVariableDevicePath,
1239 if (VariableDevicePath !=
NULL) {
1243 if (EFI_ERROR (Status)) {
1247 if (NewVariableDevicePath !=
NULL) {
1251 Status =
gRT->SetVariable (
1253 &gEfiGlobalVariableGuid,
1254 EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
1256 NewVariableDevicePath
1288 TempDevicePath = DevicePath;
1289 Status =
gBS->LocateDevicePath (&gEfiGraphicsOutputProtocolGuid, &TempDevicePath, &GopHandle);
1290 if (EFI_ERROR (Status)) {
1297 Status =
gBS->LocateDevicePath (&gEfiPciIoProtocolGuid, &DevicePath, &PciHandle);
1298 if (EFI_ERROR (Status)) {
1303 if (TempDevicePath !=
NULL) {
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
#define HARDWARE_DEVICE_PATH
#define MESSAGING_DEVICE_PATH
UINT8 EFIAPI DevicePathType(IN CONST VOID *Node)
UINTN EFIAPI DevicePathNodeLength(IN CONST VOID *Node)
UINT8 EFIAPI DevicePathSubType(IN CONST VOID *Node)
BOOLEAN EFIAPI IsDevicePathEnd(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI NextDevicePathNode(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI AppendDevicePathInstance(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance OPTIONAL)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI GetNextDevicePathInstance(IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, OUT UINTN *Size)
UINTN EFIAPI GetDevicePathSize(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
BOOLEAN EFIAPI IsDevicePathEndType(IN CONST VOID *Node)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_RUNTIME_SERVICES * gRT
#define ASSERT_EFI_ERROR(StatusParameter)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI EfiBootManagerGetGopDevicePath(IN EFI_HANDLE VideoController)
EFI_STATUS EFIAPI EfiLibInstallDriverBindingComponentName2(IN CONST EFI_HANDLE ImageHandle, IN CONST EFI_SYSTEM_TABLE *SystemTable, IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, IN EFI_HANDLE DriverBindingHandle, IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL, IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL)