2008-04-10 10:49:28 +02:00
|
|
|
/** @file
|
2008-12-17 10:35:12 +01:00
|
|
|
Console Platform DXE Driver, install Console Device Guids and update Console
|
2008-07-04 09:58:57 +02:00
|
|
|
Environment Variables.
|
2007-07-05 09:05:28 +02:00
|
|
|
|
2010-04-24 11:33:45 +02:00
|
|
|
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
|
|
|
This program and the accompanying materials
|
2007-07-05 09:05:28 +02:00
|
|
|
are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
which accompanies this distribution. The full text of the license may be found at
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
|
2008-04-10 10:49:28 +02:00
|
|
|
**/
|
2007-07-05 09:05:28 +02:00
|
|
|
|
2008-10-31 05:38:10 +01:00
|
|
|
#include "ConPlatform.h"
|
2007-07-05 09:05:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextInDriverBinding = {
|
|
|
|
ConPlatformTextInDriverBindingSupported,
|
|
|
|
ConPlatformTextInDriverBindingStart,
|
|
|
|
ConPlatformTextInDriverBindingStop,
|
|
|
|
0xa,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextOutDriverBinding = {
|
|
|
|
ConPlatformTextOutDriverBindingSupported,
|
|
|
|
ConPlatformTextOutDriverBindingStart,
|
|
|
|
ConPlatformTextOutDriverBindingStop,
|
|
|
|
0xa,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2008-11-07 08:18:15 +01:00
|
|
|
Entrypoint of this module.
|
|
|
|
|
|
|
|
This function is the entrypoint of this module. It installs Driver Binding
|
|
|
|
Protocols together with Component Name Protocols.
|
2007-07-05 09:05:28 +02:00
|
|
|
|
2008-07-15 10:16:24 +02:00
|
|
|
@param ImageHandle The firmware allocated handle for the EFI image.
|
|
|
|
@param SystemTable A pointer to the EFI System Table.
|
2007-09-29 04:57:38 +02:00
|
|
|
|
2007-07-05 09:05:28 +02:00
|
|
|
@retval EFI_SUCCESS The entry point is executed successfully.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
InitializeConPlatform(
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
|
2007-09-30 05:05:10 +02:00
|
|
|
Status = EfiLibInstallDriverBindingComponentName2 (
|
2007-07-05 09:05:28 +02:00
|
|
|
ImageHandle,
|
|
|
|
SystemTable,
|
|
|
|
&gConPlatformTextInDriverBinding,
|
|
|
|
ImageHandle,
|
|
|
|
&gConPlatformComponentName,
|
2007-09-30 05:05:10 +02:00
|
|
|
&gConPlatformComponentName2
|
2007-07-05 09:05:28 +02:00
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
2007-09-30 05:05:10 +02:00
|
|
|
Status = EfiLibInstallDriverBindingComponentName2 (
|
2007-07-05 09:05:28 +02:00
|
|
|
ImageHandle,
|
|
|
|
SystemTable,
|
|
|
|
&gConPlatformTextOutDriverBinding,
|
|
|
|
NULL,
|
|
|
|
&gConPlatformComponentName,
|
2007-09-30 05:05:10 +02:00
|
|
|
&gConPlatformComponentName2
|
2007-07-05 09:05:28 +02:00
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
2008-11-07 08:18:15 +01:00
|
|
|
return EFI_SUCCESS;
|
2007-07-05 09:05:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-04 09:58:57 +02:00
|
|
|
/**
|
2008-11-07 08:18:15 +01:00
|
|
|
Test to see if EFI_SIMPLE_TEXT_INPUT_PROTOCOL is supported on ControllerHandle.
|
2008-07-04 09:58:57 +02:00
|
|
|
|
|
|
|
@param This Protocol instance pointer.
|
|
|
|
@param ControllerHandle Handle of device to test.
|
|
|
|
@param RemainingDevicePath Optional parameter use to pick a specific child
|
|
|
|
device to start.
|
|
|
|
|
2008-07-15 10:16:24 +02:00
|
|
|
@retval EFI_SUCCESS This driver supports this device.
|
|
|
|
@retval other This driver does not support this device.
|
2008-07-04 09:58:57 +02:00
|
|
|
|
|
|
|
**/
|
2007-07-05 09:05:28 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ConPlatformTextInDriverBindingSupported (
|
|
|
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
|
|
IN EFI_HANDLE ControllerHandle,
|
2008-11-07 08:18:15 +01:00
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
2007-07-05 09:05:28 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
return ConPlatformDriverBindingSupported (
|
2008-11-07 08:18:15 +01:00
|
|
|
This,
|
|
|
|
ControllerHandle,
|
|
|
|
&gEfiSimpleTextInProtocolGuid
|
|
|
|
);
|
2007-07-05 09:05:28 +02:00
|
|
|
}
|
|
|
|
|
2008-07-04 09:58:57 +02:00
|
|
|
|
|
|
|
/**
|
2008-11-07 08:18:15 +01:00
|
|
|
Test to see if EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL is supported on ControllerHandle.
|
2008-07-04 09:58:57 +02:00
|
|
|
|
|
|
|
@param This Protocol instance pointer.
|
|
|
|
@param ControllerHandle Handle of device to test.
|
|
|
|
@param RemainingDevicePath Optional parameter use to pick a specific child
|
|
|
|
device to start.
|
|
|
|
|
2008-07-15 10:16:24 +02:00
|
|
|
@retval EFI_SUCCESS This driver supports this device.
|
|
|
|
@retval other This driver does not support this device.
|
2008-07-04 09:58:57 +02:00
|
|
|
|
|
|
|
**/
|
2007-07-05 09:05:28 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ConPlatformTextOutDriverBindingSupported (
|
|
|
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
|
|
IN EFI_HANDLE ControllerHandle,
|
2008-11-07 08:18:15 +01:00
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
2007-07-05 09:05:28 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
return ConPlatformDriverBindingSupported (
|
2008-11-07 08:18:15 +01:00
|
|
|
This,
|
|
|
|
ControllerHandle,
|
|
|
|
&gEfiSimpleTextOutProtocolGuid
|
|
|
|
);
|
2007-07-05 09:05:28 +02:00
|
|
|
}
|
|
|
|
|
2008-07-04 09:58:57 +02:00
|
|
|
|
|
|
|
/**
|
2008-11-07 08:18:15 +01:00
|
|
|
Test to see if the specified protocol is supported on ControllerHandle.
|
2008-07-04 09:58:57 +02:00
|
|
|
|
|
|
|
@param This Protocol instance pointer.
|
|
|
|
@param ControllerHandle Handle of device to test.
|
|
|
|
@param ProtocolGuid The specfic protocol.
|
|
|
|
|
2008-07-15 10:16:24 +02:00
|
|
|
@retval EFI_SUCCESS This driver supports this device.
|
|
|
|
@retval other This driver does not support this device.
|
2008-07-04 09:58:57 +02:00
|
|
|
|
|
|
|
**/
|
2007-07-05 09:05:28 +02:00
|
|
|
EFI_STATUS
|
|
|
|
ConPlatformDriverBindingSupported (
|
|
|
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
|
|
IN EFI_HANDLE ControllerHandle,
|
|
|
|
IN EFI_GUID *ProtocolGuid
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
VOID *Interface;
|
|
|
|
|
|
|
|
//
|
2008-07-15 10:16:24 +02:00
|
|
|
// Test to see if this is a physical device by checking if
|
|
|
|
// it has a Device Path Protocol.
|
2007-07-05 09:05:28 +02:00
|
|
|
//
|
|
|
|
Status = gBS->OpenProtocol (
|
|
|
|
ControllerHandle,
|
|
|
|
&gEfiDevicePathProtocolGuid,
|
|
|
|
NULL,
|
|
|
|
This->DriverBindingHandle,
|
|
|
|
ControllerHandle,
|
|
|
|
EFI_OPEN_PROTOCOL_TEST_PROTOCOL
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
//
|
2008-07-15 10:16:24 +02:00
|
|
|
// Test to see if this device supports the specified Protocol.
|
2007-07-05 09:05:28 +02:00
|
|
|
//
|
|
|
|
Status = gBS->OpenProtocol (
|
|
|
|
ControllerHandle,
|
|
|
|
ProtocolGuid,
|
|
|
|
(VOID **) &Interface,
|
|
|
|
This->DriverBindingHandle,
|
|
|
|
ControllerHandle,
|
|
|
|
EFI_OPEN_PROTOCOL_BY_DRIVER
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
gBS->CloseProtocol (
|
2008-11-07 08:18:15 +01:00
|
|
|
ControllerHandle,
|
|
|
|
ProtocolGuid,
|
|
|
|
This->DriverBindingHandle,
|
|
|
|
ControllerHandle
|
|
|
|
);
|
2007-07-05 09:05:28 +02:00
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-07-04 09:58:57 +02:00
|
|
|
/**
|
2008-11-07 08:18:15 +01:00
|
|
|
Start this driver on the device for console input.
|
|
|
|
|
|
|
|
Start this driver on ControllerHandle by opening Simple Text Input Protocol,
|
2008-07-07 07:23:31 +02:00
|
|
|
reading Device Path, and installing Console In Devcice GUID on ControllerHandle.
|
2008-07-04 09:58:57 +02:00
|
|
|
|
|
|
|
If this devcie is not one hot-plug devce, append its device path into the
|
|
|
|
console environment variables ConInDev.
|
|
|
|
|
|
|
|
@param This Protocol instance pointer.
|
|
|
|
@param ControllerHandle Handle of device to bind driver to
|
|
|
|
@param RemainingDevicePath Optional parameter use to pick a specific child
|
|
|
|
device to start.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS This driver is added to ControllerHandle
|
|
|
|
@retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
|
2008-07-10 05:25:37 +02:00
|
|
|
@retval other This driver does not support this device.
|
2008-07-04 09:58:57 +02:00
|
|
|
|
|
|
|
**/
|
2007-07-05 09:05:28 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ConPlatformTextInDriverBindingStart (
|
|
|
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
|
|
IN EFI_HANDLE ControllerHandle,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
|
|
|
)
|
|
|
|
{
|
2008-11-07 08:18:15 +01:00
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
2007-07-05 09:05:28 +02:00
|
|
|
EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn;
|
2009-03-04 06:48:09 +01:00
|
|
|
BOOLEAN IsInConInVariable;
|
2007-07-05 09:05:28 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Get the Device Path Protocol so the environment variables can be updated
|
|
|
|
//
|
|
|
|
Status = gBS->OpenProtocol (
|
|
|
|
ControllerHandle,
|
|
|
|
&gEfiDevicePathProtocolGuid,
|
|
|
|
(VOID **) &DevicePath,
|
|
|
|
This->DriverBindingHandle,
|
|
|
|
ControllerHandle,
|
|
|
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
//
|
2008-11-07 08:18:15 +01:00
|
|
|
// Open the Simple Text Input Protocol BY_DRIVER
|
2007-07-05 09:05:28 +02:00
|
|
|
//
|
|
|
|
Status = gBS->OpenProtocol (
|
|
|
|
ControllerHandle,
|
|
|
|
&gEfiSimpleTextInProtocolGuid,
|
|
|
|
(VOID **) &TextIn,
|
|
|
|
This->DriverBindingHandle,
|
|
|
|
ControllerHandle,
|
|
|
|
EFI_OPEN_PROTOCOL_BY_DRIVER
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
2009-03-04 06:48:09 +01:00
|
|
|
//
|
|
|
|
// Check if the device path is in ConIn Variable
|
|
|
|
//
|
|
|
|
IsInConInVariable = FALSE;
|
|
|
|
Status = ConPlatformUpdateDeviceVariable (
|
|
|
|
L"ConIn",
|
|
|
|
DevicePath,
|
2010-01-19 07:42:21 +01:00
|
|
|
Check
|
2009-03-04 06:48:09 +01:00
|
|
|
);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
IsInConInVariable = TRUE;
|
|
|
|
}
|
|
|
|
|
2007-07-05 09:05:28 +02:00
|
|
|
//
|
2009-02-25 08:54:57 +01:00
|
|
|
// Check the device path, if it is a hot plug device,
|
2007-07-05 09:05:28 +02:00
|
|
|
// do not put the device path into ConInDev, and install
|
|
|
|
// gEfiConsoleInDeviceGuid to the device handle directly.
|
|
|
|
// The policy is, make hot plug device plug in and play immediately.
|
|
|
|
//
|
2009-02-25 08:54:57 +01:00
|
|
|
if (IsHotPlugDevice (DevicePath)) {
|
2007-07-05 09:05:28 +02:00
|
|
|
gBS->InstallMultipleProtocolInterfaces (
|
2008-11-07 08:18:15 +01:00
|
|
|
&ControllerHandle,
|
|
|
|
&gEfiConsoleInDeviceGuid,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
);
|
2009-03-04 06:48:09 +01:00
|
|
|
//
|
|
|
|
// Append the device path to ConInDev only if it is in ConIn variable.
|
|
|
|
//
|
|
|
|
if (IsInConInVariable) {
|
|
|
|
ConPlatformUpdateDeviceVariable (
|
|
|
|
L"ConInDev",
|
|
|
|
DevicePath,
|
2010-01-19 07:42:21 +01:00
|
|
|
Append
|
2009-03-04 06:48:09 +01:00
|
|
|
);
|
|
|
|
}
|
2007-07-05 09:05:28 +02:00
|
|
|
} else {
|
|
|
|
//
|
2008-11-07 08:18:15 +01:00
|
|
|
// If it is not a hot-plug device, append the device path to the
|
|
|
|
// ConInDev environment variable
|
2007-07-05 09:05:28 +02:00
|
|
|
//
|
|
|
|
ConPlatformUpdateDeviceVariable (
|
2007-08-17 01:32:10 +02:00
|
|
|
L"ConInDev",
|
2007-07-05 09:05:28 +02:00
|
|
|
DevicePath,
|
2010-01-19 07:42:21 +01:00
|
|
|
Append
|
2007-07-05 09:05:28 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
//
|
2009-02-25 08:47:11 +01:00
|
|
|
// If the device path is an instance in the ConIn environment variable,
|
2007-07-05 09:05:28 +02:00
|
|
|
// then install EfiConsoleInDeviceGuid onto ControllerHandle
|
|
|
|
//
|
2009-03-04 06:48:09 +01:00
|
|
|
if (IsInConInVariable) {
|
2007-07-05 09:05:28 +02:00
|
|
|
gBS->InstallMultipleProtocolInterfaces (
|
2008-11-07 08:18:15 +01:00
|
|
|
&ControllerHandle,
|
|
|
|
&gEfiConsoleInDeviceGuid,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
);
|
2007-07-05 09:05:28 +02:00
|
|
|
} else {
|
|
|
|
gBS->CloseProtocol (
|
2008-11-07 08:18:15 +01:00
|
|
|
ControllerHandle,
|
|
|
|
&gEfiSimpleTextInProtocolGuid,
|
|
|
|
This->DriverBindingHandle,
|
|
|
|
ControllerHandle
|
|
|
|
);
|
2007-07-05 09:05:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-07-04 09:58:57 +02:00
|
|
|
/**
|
2008-11-07 08:18:15 +01:00
|
|
|
Start this driver on the device for console output and stardard error output.
|
|
|
|
|
|
|
|
Start this driver on ControllerHandle by opening Simple Text Output Protocol,
|
2008-07-07 07:23:31 +02:00
|
|
|
reading Device Path, and installing Console Out Devcic GUID, Standard Error
|
2008-07-04 09:58:57 +02:00
|
|
|
Device GUID on ControllerHandle.
|
|
|
|
|
|
|
|
If this devcie is not one hot-plug devce, append its device path into the
|
2009-01-23 11:01:51 +01:00
|
|
|
console environment variables ConOutDev, ErrOutDev.
|
2008-07-04 09:58:57 +02:00
|
|
|
|
|
|
|
@param This Protocol instance pointer.
|
|
|
|
@param ControllerHandle Handle of device to bind driver to
|
|
|
|
@param RemainingDevicePath Optional parameter use to pick a specific child
|
|
|
|
device to start.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS This driver is added to ControllerHandle
|
|
|
|
@retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
|
|
|
|
@retval other This driver does not support this device
|
|
|
|
|
|
|
|
**/
|
2007-07-05 09:05:28 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ConPlatformTextOutDriverBindingStart (
|
|
|
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
|
|
IN EFI_HANDLE ControllerHandle,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
|
|
|
)
|
|
|
|
{
|
2008-11-07 08:18:15 +01:00
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
2007-07-05 09:05:28 +02:00
|
|
|
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;
|
2008-11-07 08:18:15 +01:00
|
|
|
BOOLEAN NeedClose;
|
2009-03-04 06:48:09 +01:00
|
|
|
BOOLEAN IsInConOutVariable;
|
|
|
|
BOOLEAN IsInErrOutVariable;
|
2007-07-05 09:05:28 +02:00
|
|
|
|
|
|
|
NeedClose = TRUE;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get the Device Path Protocol so the environment variables can be updated
|
|
|
|
//
|
|
|
|
Status = gBS->OpenProtocol (
|
|
|
|
ControllerHandle,
|
|
|
|
&gEfiDevicePathProtocolGuid,
|
|
|
|
(VOID **) &DevicePath,
|
|
|
|
This->DriverBindingHandle,
|
|
|
|
ControllerHandle,
|
|
|
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Open the Simple Text Output Protocol BY_DRIVER
|
|
|
|
//
|
|
|
|
Status = gBS->OpenProtocol (
|
|
|
|
ControllerHandle,
|
|
|
|
&gEfiSimpleTextOutProtocolGuid,
|
|
|
|
(VOID **) &TextOut,
|
|
|
|
This->DriverBindingHandle,
|
|
|
|
ControllerHandle,
|
|
|
|
EFI_OPEN_PROTOCOL_BY_DRIVER
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
2009-03-04 06:48:09 +01:00
|
|
|
//
|
|
|
|
// Check if the device path is in ConOut & ErrOut Variable
|
|
|
|
//
|
|
|
|
IsInConOutVariable = FALSE;
|
|
|
|
Status = ConPlatformUpdateDeviceVariable (
|
|
|
|
L"ConOut",
|
|
|
|
DevicePath,
|
2010-01-19 07:42:21 +01:00
|
|
|
Check
|
2009-03-04 06:48:09 +01:00
|
|
|
);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
IsInConOutVariable = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IsInErrOutVariable = FALSE;
|
|
|
|
Status = ConPlatformUpdateDeviceVariable (
|
|
|
|
L"ErrOut",
|
|
|
|
DevicePath,
|
2010-01-19 07:42:21 +01:00
|
|
|
Check
|
2009-03-04 06:48:09 +01:00
|
|
|
);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
IsInErrOutVariable = TRUE;
|
|
|
|
}
|
|
|
|
|
2007-07-05 09:05:28 +02:00
|
|
|
//
|
2009-02-25 08:54:57 +01:00
|
|
|
// Check the device path, if it is a hot plug device,
|
2009-01-23 11:01:51 +01:00
|
|
|
// do not put the device path into ConOutDev and ErrOutDev,
|
2007-07-05 09:05:28 +02:00
|
|
|
// and install gEfiConsoleOutDeviceGuid to the device handle directly.
|
|
|
|
// The policy is, make hot plug device plug in and play immediately.
|
|
|
|
//
|
2009-02-25 08:54:57 +01:00
|
|
|
if (IsHotPlugDevice (DevicePath)) {
|
2007-07-05 09:05:28 +02:00
|
|
|
gBS->InstallMultipleProtocolInterfaces (
|
2008-11-07 08:18:15 +01:00
|
|
|
&ControllerHandle,
|
|
|
|
&gEfiConsoleOutDeviceGuid,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
);
|
2009-03-04 06:48:09 +01:00
|
|
|
//
|
|
|
|
// Append the device path to ConOutDev only if it is in ConOut variable.
|
|
|
|
//
|
|
|
|
if (IsInConOutVariable) {
|
|
|
|
ConPlatformUpdateDeviceVariable (
|
|
|
|
L"ConOutDev",
|
|
|
|
DevicePath,
|
2010-01-19 07:42:21 +01:00
|
|
|
Append
|
2009-03-04 06:48:09 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Append the device path to ErrOutDev only if it is in ErrOut variable.
|
|
|
|
//
|
|
|
|
if (IsInErrOutVariable) {
|
|
|
|
ConPlatformUpdateDeviceVariable (
|
|
|
|
L"ErrOutDev",
|
|
|
|
DevicePath,
|
2010-01-19 07:42:21 +01:00
|
|
|
Append
|
2009-03-04 06:48:09 +01:00
|
|
|
);
|
|
|
|
}
|
2007-07-05 09:05:28 +02:00
|
|
|
} else {
|
|
|
|
//
|
2010-10-14 06:49:31 +02:00
|
|
|
// If it is not a hot-plug device, append the device path to
|
|
|
|
// the ConOutDev and ErrOutDev environment variable.
|
|
|
|
// For GOP device path, append the sibling device path as well.
|
2007-07-05 09:05:28 +02:00
|
|
|
//
|
2010-10-14 06:49:31 +02:00
|
|
|
if (!ConPlatformUpdateGopCandidate (DevicePath)) {
|
|
|
|
ConPlatformUpdateDeviceVariable (
|
|
|
|
L"ConOutDev",
|
|
|
|
DevicePath,
|
|
|
|
Append
|
|
|
|
);
|
|
|
|
//
|
|
|
|
// Then append the device path to the ErrOutDev environment variable
|
|
|
|
//
|
|
|
|
ConPlatformUpdateDeviceVariable (
|
|
|
|
L"ErrOutDev",
|
|
|
|
DevicePath,
|
|
|
|
Append
|
|
|
|
);
|
|
|
|
}
|
2007-07-05 09:05:28 +02:00
|
|
|
|
|
|
|
//
|
2009-02-25 08:47:11 +01:00
|
|
|
// If the device path is an instance in the ConOut environment variable,
|
2007-07-05 09:05:28 +02:00
|
|
|
// then install EfiConsoleOutDeviceGuid onto ControllerHandle
|
|
|
|
//
|
2009-03-04 06:48:09 +01:00
|
|
|
if (IsInConOutVariable) {
|
2007-07-05 09:05:28 +02:00
|
|
|
NeedClose = FALSE;
|
|
|
|
Status = gBS->InstallMultipleProtocolInterfaces (
|
|
|
|
&ControllerHandle,
|
|
|
|
&gEfiConsoleOutDeviceGuid,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
}
|
|
|
|
//
|
2009-02-25 08:47:11 +01:00
|
|
|
// If the device path is an instance in the ErrOut environment variable,
|
2007-07-05 09:05:28 +02:00
|
|
|
// then install EfiStandardErrorDeviceGuid onto ControllerHandle
|
|
|
|
//
|
2009-03-04 06:48:09 +01:00
|
|
|
if (IsInErrOutVariable) {
|
2007-07-05 09:05:28 +02:00
|
|
|
NeedClose = FALSE;
|
|
|
|
gBS->InstallMultipleProtocolInterfaces (
|
2008-11-07 08:18:15 +01:00
|
|
|
&ControllerHandle,
|
|
|
|
&gEfiStandardErrorDeviceGuid,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
);
|
2007-07-05 09:05:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (NeedClose) {
|
|
|
|
gBS->CloseProtocol (
|
2008-11-07 08:18:15 +01:00
|
|
|
ControllerHandle,
|
|
|
|
&gEfiSimpleTextOutProtocolGuid,
|
|
|
|
This->DriverBindingHandle,
|
|
|
|
ControllerHandle
|
|
|
|
);
|
2007-07-05 09:05:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-07-04 09:58:57 +02:00
|
|
|
/**
|
2008-07-07 07:23:31 +02:00
|
|
|
Stop this driver on ControllerHandle by removing Console In Devcice GUID
|
2008-11-07 08:18:15 +01:00
|
|
|
and closing the Simple Text Input protocol on ControllerHandle.
|
2008-07-04 09:58:57 +02:00
|
|
|
|
|
|
|
@param This Protocol instance pointer.
|
|
|
|
@param ControllerHandle Handle of device to stop driver on
|
|
|
|
@param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
|
|
|
|
children is zero stop the entire bus driver.
|
|
|
|
@param ChildHandleBuffer List of Child Handles to Stop.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS This driver is removed ControllerHandle
|
|
|
|
@retval other This driver was not removed from this device
|
|
|
|
|
|
|
|
**/
|
2007-07-05 09:05:28 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ConPlatformTextInDriverBindingStop (
|
|
|
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
|
|
IN EFI_HANDLE ControllerHandle,
|
|
|
|
IN UINTN NumberOfChildren,
|
|
|
|
IN EFI_HANDLE *ChildHandleBuffer
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
|
|
|
|
|
|
|
//
|
2009-02-25 08:54:57 +01:00
|
|
|
// Get the Device Path Protocol firstly
|
2007-07-05 09:05:28 +02:00
|
|
|
//
|
2009-02-25 08:54:57 +01:00
|
|
|
Status = gBS->OpenProtocol (
|
|
|
|
ControllerHandle,
|
|
|
|
&gEfiDevicePathProtocolGuid,
|
|
|
|
(VOID **) &DevicePath,
|
|
|
|
This->DriverBindingHandle,
|
|
|
|
ControllerHandle,
|
|
|
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
|
|
|
);
|
|
|
|
//
|
|
|
|
// If there is device path on ControllerHandle
|
|
|
|
//
|
|
|
|
if (!EFI_ERROR (Status)) {
|
2007-07-05 09:05:28 +02:00
|
|
|
//
|
2009-03-04 06:48:09 +01:00
|
|
|
// Remove DevicePath from ConInDev if exists.
|
2009-02-24 09:03:42 +01:00
|
|
|
//
|
2009-03-04 06:48:09 +01:00
|
|
|
ConPlatformUpdateDeviceVariable (
|
|
|
|
L"ConInDev",
|
|
|
|
DevicePath,
|
2010-01-19 07:42:21 +01:00
|
|
|
Delete
|
2009-03-04 06:48:09 +01:00
|
|
|
);
|
2007-07-05 09:05:28 +02:00
|
|
|
}
|
2009-02-25 08:54:57 +01:00
|
|
|
|
2007-07-05 09:05:28 +02:00
|
|
|
//
|
|
|
|
// Uninstall the Console Device GUIDs from Controller Handle
|
|
|
|
//
|
|
|
|
ConPlatformUnInstallProtocol (
|
|
|
|
This,
|
|
|
|
ControllerHandle,
|
|
|
|
&gEfiConsoleInDeviceGuid
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
2008-11-07 08:18:15 +01:00
|
|
|
// Close the Simple Text Input Protocol
|
2007-07-05 09:05:28 +02:00
|
|
|
//
|
|
|
|
gBS->CloseProtocol (
|
2009-03-04 06:48:09 +01:00
|
|
|
ControllerHandle,
|
|
|
|
&gEfiSimpleTextInProtocolGuid,
|
|
|
|
This->DriverBindingHandle,
|
|
|
|
ControllerHandle
|
|
|
|
);
|
2007-07-05 09:05:28 +02:00
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-07-04 09:58:57 +02:00
|
|
|
|
|
|
|
/**
|
2008-07-07 07:23:31 +02:00
|
|
|
Stop this driver on ControllerHandle by removing Console Out Devcice GUID
|
2008-11-07 08:18:15 +01:00
|
|
|
and closing the Simple Text Output protocol on ControllerHandle.
|
2008-07-04 09:58:57 +02:00
|
|
|
|
|
|
|
@param This Protocol instance pointer.
|
|
|
|
@param ControllerHandle Handle of device to stop driver on
|
|
|
|
@param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
|
|
|
|
children is zero stop the entire bus driver.
|
|
|
|
@param ChildHandleBuffer List of Child Handles to Stop.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS This driver is removed ControllerHandle
|
|
|
|
@retval other This driver was not removed from this device
|
|
|
|
|
|
|
|
**/
|
2007-07-05 09:05:28 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ConPlatformTextOutDriverBindingStop (
|
|
|
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
|
|
IN EFI_HANDLE ControllerHandle,
|
|
|
|
IN UINTN NumberOfChildren,
|
|
|
|
IN EFI_HANDLE *ChildHandleBuffer
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
|
|
|
|
|
|
|
//
|
2009-02-25 08:54:57 +01:00
|
|
|
// Get the Device Path Protocol firstly
|
2007-07-05 09:05:28 +02:00
|
|
|
//
|
2009-02-25 08:54:57 +01:00
|
|
|
Status = gBS->OpenProtocol (
|
|
|
|
ControllerHandle,
|
|
|
|
&gEfiDevicePathProtocolGuid,
|
|
|
|
(VOID **) &DevicePath,
|
|
|
|
This->DriverBindingHandle,
|
|
|
|
ControllerHandle,
|
|
|
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
|
|
|
);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
2007-07-05 09:05:28 +02:00
|
|
|
//
|
2009-03-04 06:48:09 +01:00
|
|
|
// Remove DevicePath from ConOutDev and ErrOutDev if exists.
|
2007-07-05 09:05:28 +02:00
|
|
|
//
|
2009-03-04 06:48:09 +01:00
|
|
|
ConPlatformUpdateDeviceVariable (
|
|
|
|
L"ConOutDev",
|
|
|
|
DevicePath,
|
2010-01-19 07:42:21 +01:00
|
|
|
Delete
|
2009-03-04 06:48:09 +01:00
|
|
|
);
|
|
|
|
ConPlatformUpdateDeviceVariable (
|
|
|
|
L"ErrOutDev",
|
|
|
|
DevicePath,
|
2010-01-19 07:42:21 +01:00
|
|
|
Delete
|
2009-03-04 06:48:09 +01:00
|
|
|
);
|
2007-07-05 09:05:28 +02:00
|
|
|
}
|
2009-02-25 08:54:57 +01:00
|
|
|
|
2007-07-05 09:05:28 +02:00
|
|
|
//
|
|
|
|
// Uninstall the Console Device GUIDs from Controller Handle
|
|
|
|
//
|
|
|
|
ConPlatformUnInstallProtocol (
|
|
|
|
This,
|
|
|
|
ControllerHandle,
|
|
|
|
&gEfiConsoleOutDeviceGuid
|
|
|
|
);
|
|
|
|
|
|
|
|
ConPlatformUnInstallProtocol (
|
|
|
|
This,
|
|
|
|
ControllerHandle,
|
|
|
|
&gEfiStandardErrorDeviceGuid
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Close the Simple Text Output Protocol
|
|
|
|
//
|
|
|
|
gBS->CloseProtocol (
|
|
|
|
ControllerHandle,
|
|
|
|
&gEfiSimpleTextOutProtocolGuid,
|
|
|
|
This->DriverBindingHandle,
|
|
|
|
ControllerHandle
|
|
|
|
);
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-04 09:58:57 +02:00
|
|
|
/**
|
2008-07-15 10:16:24 +02:00
|
|
|
Uninstall the specified protocol.
|
2008-07-04 09:58:57 +02:00
|
|
|
|
|
|
|
@param This Protocol instance pointer.
|
2008-07-15 10:16:24 +02:00
|
|
|
@param Handle Handle of device to uninstall protocol on.
|
|
|
|
@param ProtocolGuid The specified protocol need to be uninstalled.
|
2008-07-04 09:58:57 +02:00
|
|
|
|
|
|
|
**/
|
2007-07-05 09:05:28 +02:00
|
|
|
VOID
|
|
|
|
ConPlatformUnInstallProtocol (
|
|
|
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
|
|
IN EFI_HANDLE Handle,
|
|
|
|
IN EFI_GUID *ProtocolGuid
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
|
|
|
|
Status = gBS->OpenProtocol (
|
|
|
|
Handle,
|
|
|
|
ProtocolGuid,
|
|
|
|
NULL,
|
|
|
|
This->DriverBindingHandle,
|
|
|
|
Handle,
|
|
|
|
EFI_OPEN_PROTOCOL_TEST_PROTOCOL
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
gBS->UninstallMultipleProtocolInterfaces (
|
2008-11-07 08:18:15 +01:00
|
|
|
Handle,
|
|
|
|
ProtocolGuid,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
);
|
2007-07-05 09:05:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
|
2008-07-04 09:58:57 +02:00
|
|
|
/**
|
2009-01-23 11:01:51 +01:00
|
|
|
Get the necessary size of buffer and read the variable.
|
2008-11-07 08:18:15 +01:00
|
|
|
|
|
|
|
First get the necessary size of buffer. Then read the
|
|
|
|
EFI variable (Name) and return a dynamically allocated
|
|
|
|
buffer. On failure return NULL.
|
2007-07-05 09:05:28 +02:00
|
|
|
|
2008-07-04 09:58:57 +02:00
|
|
|
@param Name String part of EFI variable name
|
2007-07-05 09:05:28 +02:00
|
|
|
|
2008-07-04 09:58:57 +02:00
|
|
|
@return Dynamically allocated memory that contains a copy of the EFI variable.
|
2008-07-15 10:16:24 +02:00
|
|
|
Caller is repsoncible freeing the buffer. Return NULL means Variable
|
|
|
|
was not read.
|
2007-07-05 09:05:28 +02:00
|
|
|
|
2008-07-04 09:58:57 +02:00
|
|
|
**/
|
|
|
|
VOID *
|
|
|
|
ConPlatformGetVariable (
|
|
|
|
IN CHAR16 *Name
|
|
|
|
)
|
2007-07-05 09:05:28 +02:00
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
VOID *Buffer;
|
|
|
|
UINTN BufferSize;
|
|
|
|
|
|
|
|
BufferSize = 0;
|
|
|
|
Buffer = NULL;
|
|
|
|
|
|
|
|
//
|
2008-11-07 08:18:15 +01:00
|
|
|
// Test to see if the variable exists. If it doesn't, return NULL.
|
2007-07-05 09:05:28 +02:00
|
|
|
//
|
|
|
|
Status = gRT->GetVariable (
|
|
|
|
Name,
|
|
|
|
&gEfiGlobalVariableGuid,
|
|
|
|
NULL,
|
|
|
|
&BufferSize,
|
|
|
|
Buffer
|
|
|
|
);
|
|
|
|
|
|
|
|
if (Status == EFI_BUFFER_TOO_SMALL) {
|
|
|
|
//
|
|
|
|
// Allocate the buffer to return
|
|
|
|
//
|
|
|
|
Buffer = AllocatePool (BufferSize);
|
|
|
|
if (Buffer == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Read variable into the allocated buffer.
|
|
|
|
//
|
|
|
|
Status = gRT->GetVariable (
|
|
|
|
Name,
|
|
|
|
&gEfiGlobalVariableGuid,
|
|
|
|
NULL,
|
|
|
|
&BufferSize,
|
|
|
|
Buffer
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
FreePool (Buffer);
|
2008-07-15 10:16:24 +02:00
|
|
|
//
|
|
|
|
// To make sure Buffer is NULL if any error occurs.
|
|
|
|
//
|
2007-07-05 09:05:28 +02:00
|
|
|
Buffer = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Buffer;
|
|
|
|
}
|
|
|
|
|
2008-07-04 09:58:57 +02:00
|
|
|
/**
|
2007-07-05 09:05:28 +02:00
|
|
|
Function compares a device path data structure to that of all the nodes of a
|
|
|
|
second device path instance.
|
|
|
|
|
2008-07-04 09:58:57 +02:00
|
|
|
@param Multi A pointer to a multi-instance device path data structure.
|
|
|
|
@param Single A pointer to a single-instance device path data structure.
|
|
|
|
@param NewDevicePath If Delete is TRUE, this parameter must not be null, and it
|
|
|
|
points to the remaining device path data structure.
|
|
|
|
(remaining device path = Multi - Single.)
|
|
|
|
@param Delete If TRUE, means removing Single from Multi.
|
|
|
|
If FALSE, the routine just check whether Single matches
|
|
|
|
with any instance in Multi.
|
2007-07-05 09:05:28 +02:00
|
|
|
|
2008-11-07 08:18:15 +01:00
|
|
|
@retval EFI_SUCCESS If the Single is contained within Multi.
|
|
|
|
@retval EFI_NOT_FOUND If the Single is not contained within Multi.
|
|
|
|
@retval EFI_INVALID_PARAMETER Multi is NULL.
|
|
|
|
@retval EFI_INVALID_PARAMETER Single is NULL.
|
|
|
|
@retval EFI_INVALID_PARAMETER NewDevicePath is NULL when Delete is TRUE.
|
2007-07-05 09:05:28 +02:00
|
|
|
|
2008-07-04 09:58:57 +02:00
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
ConPlatformMatchDevicePaths (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *Multi,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *Single,
|
2008-07-15 10:16:24 +02:00
|
|
|
OUT EFI_DEVICE_PATH_PROTOCOL **NewDevicePath OPTIONAL,
|
2008-07-04 09:58:57 +02:00
|
|
|
IN BOOLEAN Delete
|
|
|
|
)
|
2007-07-05 09:05:28 +02:00
|
|
|
{
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
2008-07-15 10:16:24 +02:00
|
|
|
EFI_DEVICE_PATH_PROTOCOL *TempDevicePath1;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *TempDevicePath2;
|
2007-07-05 09:05:28 +02:00
|
|
|
EFI_DEVICE_PATH_PROTOCOL *DevicePathInst;
|
|
|
|
UINTN Size;
|
|
|
|
|
|
|
|
//
|
|
|
|
// The passed in DevicePath should not be NULL
|
|
|
|
//
|
2008-07-04 09:58:57 +02:00
|
|
|
if ((Multi == NULL) || (Single == NULL)) {
|
2008-11-07 08:18:15 +01:00
|
|
|
return EFI_INVALID_PARAMETER;
|
2007-07-05 09:05:28 +02:00
|
|
|
}
|
2008-07-15 10:16:24 +02:00
|
|
|
|
2007-07-05 09:05:28 +02:00
|
|
|
//
|
2008-07-15 10:16:24 +02:00
|
|
|
// If performing Delete operation, the NewDevicePath must not be NULL.
|
2007-07-05 09:05:28 +02:00
|
|
|
//
|
2008-07-15 10:16:24 +02:00
|
|
|
if (Delete) {
|
2008-11-07 08:18:15 +01:00
|
|
|
if (NewDevicePath == NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
2008-07-15 10:16:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TempDevicePath1 = NULL;
|
2007-07-05 09:05:28 +02:00
|
|
|
|
|
|
|
DevicePath = Multi;
|
|
|
|
DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);
|
|
|
|
|
|
|
|
//
|
2008-07-15 10:16:24 +02:00
|
|
|
// Search for the match of 'Single' in 'Multi'
|
2007-07-05 09:05:28 +02:00
|
|
|
//
|
2008-07-04 09:58:57 +02:00
|
|
|
while (DevicePathInst != NULL) {
|
2007-07-05 09:05:28 +02:00
|
|
|
if (CompareMem (Single, DevicePathInst, Size) == 0) {
|
|
|
|
if (!Delete) {
|
2008-07-15 10:16:24 +02:00
|
|
|
//
|
|
|
|
// If Delete is FALSE, return EFI_SUCCESS if Single is found in Multi.
|
|
|
|
//
|
2007-07-05 09:05:28 +02:00
|
|
|
FreePool (DevicePathInst);
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (Delete) {
|
2008-07-15 10:16:24 +02:00
|
|
|
//
|
2008-11-07 08:18:15 +01:00
|
|
|
// If the node of Multi does not match Single, then added it back to the result.
|
|
|
|
// That is, the node matching Single will be dropped and deleted from result.
|
2008-07-15 10:16:24 +02:00
|
|
|
//
|
|
|
|
TempDevicePath2 = AppendDevicePathInstance (
|
|
|
|
TempDevicePath1,
|
2007-07-05 09:05:28 +02:00
|
|
|
DevicePathInst
|
|
|
|
);
|
2008-10-30 08:32:46 +01:00
|
|
|
if (TempDevicePath1 != NULL) {
|
|
|
|
FreePool (TempDevicePath1);
|
|
|
|
}
|
2008-07-15 10:16:24 +02:00
|
|
|
TempDevicePath1 = TempDevicePath2;
|
2007-07-05 09:05:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FreePool (DevicePathInst);
|
|
|
|
DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Delete) {
|
2008-07-15 10:16:24 +02:00
|
|
|
//
|
2008-11-07 08:18:15 +01:00
|
|
|
// Return the new device path data structure with specified node deleted.
|
2008-07-15 10:16:24 +02:00
|
|
|
//
|
|
|
|
*NewDevicePath = TempDevicePath1;
|
2007-07-05 09:05:28 +02:00
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
2008-07-04 09:58:57 +02:00
|
|
|
/**
|
2008-07-15 10:16:24 +02:00
|
|
|
Update console environment variables.
|
2008-07-04 09:58:57 +02:00
|
|
|
|
|
|
|
@param VariableName Console environment variables, ConOutDev, ConInDev
|
2009-01-23 11:01:51 +01:00
|
|
|
ErrOutDev, ConIn ,ConOut or ErrOut.
|
2008-07-04 09:58:57 +02:00
|
|
|
@param DevicePath Console devcie's device path.
|
2008-11-07 08:18:15 +01:00
|
|
|
@param Operation Variable operations, including APPEND, CHECK and DELETE.
|
2008-07-04 09:58:57 +02:00
|
|
|
|
|
|
|
@retval EFI_SUCCESS Variable operates successfully.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES If variable cannot be appended.
|
|
|
|
@retval other Variable updating failed.
|
|
|
|
|
|
|
|
**/
|
2007-07-05 09:05:28 +02:00
|
|
|
EFI_STATUS
|
|
|
|
ConPlatformUpdateDeviceVariable (
|
|
|
|
IN CHAR16 *VariableName,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
|
|
|
|
IN CONPLATFORM_VAR_OPERATION Operation
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *VariableDevicePath;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *NewVariableDevicePath;
|
|
|
|
|
|
|
|
VariableDevicePath = NULL;
|
|
|
|
NewVariableDevicePath = NULL;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get Variable according to variable name.
|
|
|
|
// The memory for Variable is allocated within ConPlatformGetVarible(),
|
|
|
|
// it is the caller's responsibility to free the memory before return.
|
|
|
|
//
|
|
|
|
VariableDevicePath = ConPlatformGetVariable (VariableName);
|
|
|
|
|
2010-01-19 07:42:21 +01:00
|
|
|
if (Operation != Delete) {
|
2008-07-15 10:16:24 +02:00
|
|
|
//
|
|
|
|
// Match specified DevicePath in Console Variable.
|
|
|
|
//
|
2007-07-05 09:05:28 +02:00
|
|
|
Status = ConPlatformMatchDevicePaths (
|
2008-11-07 08:18:15 +01:00
|
|
|
VariableDevicePath,
|
|
|
|
DevicePath,
|
|
|
|
NULL,
|
|
|
|
FALSE
|
|
|
|
);
|
2007-07-05 09:05:28 +02:00
|
|
|
|
2010-01-19 07:42:21 +01:00
|
|
|
if ((Operation == Check) || (!EFI_ERROR (Status))) {
|
2007-07-05 09:05:28 +02:00
|
|
|
//
|
2008-11-07 08:18:15 +01:00
|
|
|
// Branch here includes 2 cases:
|
|
|
|
// 1. Operation is CHECK, simply return Status.
|
|
|
|
// 2. Operation is APPEND, and device path already exists in variable, also return.
|
2007-07-05 09:05:28 +02:00
|
|
|
//
|
|
|
|
if (VariableDevicePath != NULL) {
|
|
|
|
FreePool (VariableDevicePath);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
//
|
2008-11-07 08:18:15 +01:00
|
|
|
// We reach here to append a device path that does not exist in variable.
|
2007-07-05 09:05:28 +02:00
|
|
|
//
|
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
NewVariableDevicePath = AppendDevicePathInstance (
|
|
|
|
VariableDevicePath,
|
|
|
|
DevicePath
|
|
|
|
);
|
|
|
|
if (NewVariableDevicePath == NULL) {
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
//
|
2008-11-07 08:18:15 +01:00
|
|
|
// We reach here to remove DevicePath from the environment variable that
|
2007-07-05 09:05:28 +02:00
|
|
|
// is a multi-instance device path.
|
|
|
|
//
|
|
|
|
Status = ConPlatformMatchDevicePaths (
|
2008-11-07 08:18:15 +01:00
|
|
|
VariableDevicePath,
|
|
|
|
DevicePath,
|
|
|
|
&NewVariableDevicePath,
|
|
|
|
TRUE
|
|
|
|
);
|
2007-07-05 09:05:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (VariableDevicePath != NULL) {
|
|
|
|
FreePool (VariableDevicePath);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2007-09-29 04:57:38 +02:00
|
|
|
if (NewVariableDevicePath != NULL) {
|
2008-07-15 10:16:24 +02:00
|
|
|
//
|
|
|
|
// Update Console Environment Variable.
|
|
|
|
//
|
2007-09-29 04:57:38 +02:00
|
|
|
Status = gRT->SetVariable (
|
|
|
|
VariableName,
|
|
|
|
&gEfiGlobalVariableGuid,
|
|
|
|
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
|
|
|
GetDevicePathSize (NewVariableDevicePath),
|
|
|
|
NewVariableDevicePath
|
|
|
|
);
|
2007-07-05 09:05:28 +02:00
|
|
|
|
2007-09-29 04:57:38 +02:00
|
|
|
FreePool (NewVariableDevicePath);
|
|
|
|
}
|
2007-07-05 09:05:28 +02:00
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2008-07-04 09:58:57 +02:00
|
|
|
/**
|
2009-02-25 08:54:57 +01:00
|
|
|
Check if the device supports hot-plug through its device path.
|
|
|
|
|
|
|
|
This function could be updated to check more types of Hot Plug devices.
|
|
|
|
Currently, it checks USB and PCCard device.
|
2008-07-04 09:58:57 +02:00
|
|
|
|
2009-02-25 08:54:57 +01:00
|
|
|
@param DevicePath Pointer to device's device path.
|
2008-07-04 09:58:57 +02:00
|
|
|
|
|
|
|
@retval TRUE The devcie is a hot-plug device
|
|
|
|
@retval FALSE The devcie is not a hot-plug device.
|
|
|
|
|
|
|
|
**/
|
2007-07-05 09:05:28 +02:00
|
|
|
BOOLEAN
|
|
|
|
IsHotPlugDevice (
|
2009-02-25 08:54:57 +01:00
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
2007-07-05 09:05:28 +02:00
|
|
|
)
|
|
|
|
{
|
2009-02-25 08:54:57 +01:00
|
|
|
EFI_DEVICE_PATH_PROTOCOL *CheckDevicePath;
|
2009-02-23 03:51:45 +01:00
|
|
|
|
2009-02-25 08:54:57 +01:00
|
|
|
CheckDevicePath = DevicePath;
|
|
|
|
while (!IsDevicePathEnd (CheckDevicePath)) {
|
|
|
|
//
|
|
|
|
// Check device whether is hot plug device or not throught Device Path
|
|
|
|
//
|
|
|
|
if ((DevicePathType (CheckDevicePath) == MESSAGING_DEVICE_PATH) &&
|
|
|
|
(DevicePathSubType (CheckDevicePath) == MSG_USB_DP ||
|
|
|
|
DevicePathSubType (CheckDevicePath) == MSG_USB_CLASS_DP ||
|
|
|
|
DevicePathSubType (CheckDevicePath) == MSG_USB_WWID_DP)) {
|
|
|
|
//
|
|
|
|
// If Device is USB device
|
|
|
|
//
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
if ((DevicePathType (CheckDevicePath) == HARDWARE_DEVICE_PATH) &&
|
|
|
|
(DevicePathSubType (CheckDevicePath) == HW_PCCARD_DP)) {
|
|
|
|
//
|
|
|
|
// If Device is PCCard
|
|
|
|
//
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
CheckDevicePath = NextDevicePathNode (CheckDevicePath);
|
2007-07-05 09:05:28 +02:00
|
|
|
}
|
|
|
|
|
2009-02-25 08:54:57 +01:00
|
|
|
return FALSE;
|
2007-07-05 09:05:28 +02:00
|
|
|
}
|
2009-02-25 08:54:57 +01:00
|
|
|
|
2010-10-14 06:49:31 +02:00
|
|
|
/**
|
|
|
|
Update ConOutDev and ErrOutDev variables to add the device path of
|
|
|
|
GOP controller itself and the sibling controllers.
|
|
|
|
|
|
|
|
@param DevicePath Pointer to device's device path.
|
|
|
|
|
|
|
|
@retval TRUE The devcie is a GOP device.
|
|
|
|
@retval FALSE The devcie is not a GOP device.
|
|
|
|
|
|
|
|
**/
|
|
|
|
BOOLEAN
|
|
|
|
ConPlatformUpdateGopCandidate (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_HANDLE PciHandle;
|
|
|
|
EFI_HANDLE GopHandle;
|
|
|
|
EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;
|
|
|
|
UINTN EntryCount;
|
|
|
|
UINTN Index;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *ChildDevicePath;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Check whether it's a GOP device.
|
|
|
|
//
|
|
|
|
TempDevicePath = DevicePath;
|
|
|
|
Status = gBS->LocateDevicePath (&gEfiGraphicsOutputProtocolGuid, &TempDevicePath, &GopHandle);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Get the parent PciIo handle in order to find all the children
|
|
|
|
//
|
|
|
|
Status = gBS->LocateDevicePath (&gEfiPciIoProtocolGuid, &DevicePath, &PciHandle);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = gBS->OpenProtocolInformation (
|
|
|
|
PciHandle,
|
|
|
|
&gEfiPciIoProtocolGuid,
|
|
|
|
&OpenInfoBuffer,
|
|
|
|
&EntryCount
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Index = 0; Index < EntryCount; Index++) {
|
|
|
|
//
|
|
|
|
// Query all the children created by the GOP driver
|
|
|
|
//
|
|
|
|
if ((OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
|
|
|
|
Status = gBS->OpenProtocol (
|
|
|
|
OpenInfoBuffer[Index].ControllerHandle,
|
|
|
|
&gEfiDevicePathProtocolGuid,
|
|
|
|
(VOID **) &ChildDevicePath,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
|
|
|
);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
//
|
|
|
|
// Append the device path to ConOutDev and ErrOutDev
|
|
|
|
//
|
|
|
|
ConPlatformUpdateDeviceVariable (L"ConOutDev", ChildDevicePath, Append);
|
|
|
|
ConPlatformUpdateDeviceVariable (L"ErrOutDev", ChildDevicePath, Append);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FreePool (OpenInfoBuffer);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|