+++ /dev/null
-/*++\r
-\r
-Copyright (c) 2006, Intel Corporation \r
-All rights reserved. This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-\r
-Module Name:\r
-\r
- ComponentName.c\r
-\r
-Abstract:\r
-\r
---*/\r
-\r
-#include "ConPlatform.h"\r
-#include "ComponentName.h"\r
-\r
-//\r
-// EFI Component Name Protocol\r
-//\r
-EFI_COMPONENT_NAME_PROTOCOL gConPlatformComponentName = {\r
- ConPlatformComponentNameGetDriverName,\r
- ConPlatformComponentNameGetControllerName,\r
- "eng"\r
-};\r
-\r
-STATIC EFI_UNICODE_STRING_TABLE mConPlatformDriverNameTable[] = {\r
- {\r
- "eng",\r
- L"Platform Console Management Driver"\r
- },\r
- {\r
- NULL,\r
- NULL\r
- }\r
-};\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-ConPlatformComponentNameGetDriverName (\r
- IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
- IN CHAR8 *Language,\r
- OUT CHAR16 **DriverName\r
- )\r
-/*++\r
-\r
- Routine Description:\r
- Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
-\r
- Arguments:\r
- This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
- Language - A pointer to a three character ISO 639-2 language identifier.\r
- This is the language of the driver name that that the caller \r
- is requesting, and it must match one of the languages specified\r
- in SupportedLanguages. The number of languages supported by a \r
- driver is up to the driver writer.\r
- DriverName - A pointer to the Unicode string to return. This Unicode string\r
- is the name of the driver specified by This in the language \r
- specified by Language.\r
-\r
- Returns:\r
- EFI_SUCCESS - The Unicode string for the Driver specified by This\r
- and the language specified by Language was returned \r
- in DriverName.\r
- EFI_INVALID_PARAMETER - Language is NULL.\r
- EFI_INVALID_PARAMETER - DriverName is NULL.\r
- EFI_UNSUPPORTED - The driver specified by This does not support the \r
- language specified by Language.\r
-\r
---*/\r
-{\r
- return LookupUnicodeString (\r
- Language,\r
- gConPlatformComponentName.SupportedLanguages,\r
- mConPlatformDriverNameTable,\r
- DriverName\r
- );\r
-}\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-ConPlatformComponentNameGetControllerName (\r
- IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
- IN EFI_HANDLE ControllerHandle,\r
- IN EFI_HANDLE ChildHandle OPTIONAL,\r
- IN CHAR8 *Language,\r
- OUT CHAR16 **ControllerName\r
- )\r
-/*++\r
-\r
- Routine Description:\r
- Retrieves a Unicode string that is the user readable name of the controller\r
- that is being managed by an EFI Driver.\r
-\r
- Arguments:\r
- This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
- ControllerHandle - The handle of a controller that the driver specified by \r
- This is managing. This handle specifies the controller \r
- whose name is to be returned.\r
- ChildHandle - The handle of the child controller to retrieve the name \r
- of. This is an optional parameter that may be NULL. It \r
- will be NULL for device drivers. It will also be NULL \r
- for a bus drivers that wish to retrieve the name of the \r
- bus controller. It will not be NULL for a bus driver \r
- that wishes to retrieve the name of a child controller.\r
- Language - A pointer to a three character ISO 639-2 language \r
- identifier. This is the language of the controller name \r
- that that the caller is requesting, and it must match one\r
- of the languages specified in SupportedLanguages. The \r
- number of languages supported by a driver is up to the \r
- driver writer.\r
- ControllerName - A pointer to the Unicode string to return. This Unicode\r
- string is the name of the controller specified by \r
- ControllerHandle and ChildHandle in the language \r
- specified by Language from the point of view of the \r
- driver specified by This. \r
-\r
- Returns:\r
- EFI_SUCCESS - The Unicode string for the user readable name in the\r
- language specified by Language for the driver \r
- specified by This was returned in DriverName.\r
- EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
- EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid \r
- EFI_HANDLE.\r
- EFI_INVALID_PARAMETER - Language is NULL.\r
- EFI_INVALID_PARAMETER - ControllerName is NULL.\r
- EFI_UNSUPPORTED - The driver specified by This is not currently \r
- managing the controller specified by \r
- ControllerHandle and ChildHandle.\r
- EFI_UNSUPPORTED - The driver specified by This does not support the \r
- language specified by Language.\r
-\r
---*/\r
-{\r
- return EFI_UNSUPPORTED;\r
-}\r
+++ /dev/null
-/*++\r
-\r
-Copyright (c) 2006, Intel Corporation \r
-All rights reserved. This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-\r
-Module Name:\r
-\r
- ConPlatform.c\r
- \r
-Abstract:\r
-\r
---*/\r
-\r
-#include "ConPlatform.h"\r
-\r
-EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextInDriverBinding = {\r
- ConPlatformTextInDriverBindingSupported,\r
- ConPlatformTextInDriverBindingStart,\r
- ConPlatformDriverBindingStop,\r
- 0x10,\r
- NULL,\r
- NULL\r
-};\r
-\r
-EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextOutDriverBinding = {\r
- ConPlatformTextOutDriverBindingSupported,\r
- ConPlatformTextOutDriverBindingStart,\r
- ConPlatformDriverBindingStop,\r
- 0x10,\r
- NULL,\r
- NULL\r
-};\r
-\r
-STATIC\r
-EFI_STATUS\r
-EFIAPI\r
-ConPlatformTextInDriverBindingSupported (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE ControllerHandle,\r
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- Supported \r
-\r
-Arguments:\r
- (Standard DriverBinding Protocol Supported() function)\r
-\r
-Returns:\r
-\r
- None\r
-\r
---*/\r
-{\r
- return ConPlatformDriverBindingSupported (\r
- This,\r
- ControllerHandle,\r
- RemainingDevicePath,\r
- &gEfiSimpleTextInProtocolGuid\r
- );\r
-}\r
-\r
-STATIC\r
-EFI_STATUS\r
-EFIAPI\r
-ConPlatformTextOutDriverBindingSupported (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE ControllerHandle,\r
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- Supported \r
-\r
-Arguments:\r
- (Standard DriverBinding Protocol Supported() function)\r
-\r
-Returns:\r
-\r
- None\r
-\r
---*/\r
-{\r
- return ConPlatformDriverBindingSupported (\r
- This,\r
- ControllerHandle,\r
- RemainingDevicePath,\r
- &gEfiSimpleTextOutProtocolGuid\r
- );\r
-}\r
-\r
-EFI_STATUS\r
-ConPlatformDriverBindingSupported (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE ControllerHandle,\r
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath,\r
- IN EFI_GUID *ProtocolGuid\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- Supported \r
-\r
-Arguments:\r
- (Standard DriverBinding Protocol Supported() function)\r
-\r
-Returns:\r
-\r
- None\r
-\r
---*/\r
-{\r
- EFI_STATUS Status;\r
- VOID *Interface;\r
-\r
- //\r
- // Test to see if this is a physical device by checking to see if\r
- // it has a Device Path Protocol\r
- //\r
- Status = gBS->OpenProtocol (\r
- ControllerHandle,\r
- &gEfiDevicePathProtocolGuid,\r
- NULL,\r
- This->DriverBindingHandle,\r
- ControllerHandle,\r
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
- //\r
- // Test to see if this device supports the Simple Text Output Protocol\r
- //\r
- Status = gBS->OpenProtocol (\r
- ControllerHandle,\r
- ProtocolGuid,\r
- (VOID **) &Interface,\r
- This->DriverBindingHandle,\r
- ControllerHandle,\r
- EFI_OPEN_PROTOCOL_BY_DRIVER\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- gBS->CloseProtocol (\r
- ControllerHandle,\r
- ProtocolGuid,\r
- This->DriverBindingHandle,\r
- ControllerHandle\r
- );\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-STATIC\r
-EFI_STATUS\r
-EFIAPI\r
-ConPlatformTextInDriverBindingStart (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE ControllerHandle,\r
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-\r
-Arguments:\r
- (Standard DriverBinding Protocol Start() function)\r
-\r
-Returns:\r
-\r
-\r
---*/\r
-{\r
- EFI_STATUS Status;\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
- EFI_SIMPLE_TEXT_IN_PROTOCOL *TextIn;\r
-\r
- //\r
- // Get the Device Path Protocol so the environment variables can be updated\r
- //\r
- Status = gBS->OpenProtocol (\r
- ControllerHandle,\r
- &gEfiDevicePathProtocolGuid,\r
- (VOID **) &DevicePath,\r
- This->DriverBindingHandle,\r
- ControllerHandle,\r
- EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
- //\r
- // Open the Simple Input Protocol BY_DRIVER\r
- //\r
- Status = gBS->OpenProtocol (\r
- ControllerHandle,\r
- &gEfiSimpleTextInProtocolGuid,\r
- (VOID **) &TextIn,\r
- This->DriverBindingHandle,\r
- ControllerHandle,\r
- EFI_OPEN_PROTOCOL_BY_DRIVER\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
- //\r
- // Check the device handle, if it is a hot plug device,\r
- // do not put the device path into ConInDev, and install\r
- // gEfiConsoleInDeviceGuid to the device handle directly.\r
- // The policy is, make hot plug device plug in and play immediately.\r
- //\r
- if (IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) {\r
- gBS->InstallMultipleProtocolInterfaces (\r
- &ControllerHandle,\r
- &gEfiConsoleInDeviceGuid,\r
- NULL,\r
- NULL\r
- );\r
- } else {\r
- //\r
- // Append the device path to the ConInDev environment variable\r
- //\r
- ConPlatformUpdateDeviceVariable (\r
- VarConsoleInpDev,\r
- DevicePath,\r
- APPEND\r
- );\r
-\r
- //\r
- // If the device path is an instance in the ConIn environment variable,\r
- // then install EfiConsoleInDeviceGuid onto ControllerHandle\r
- //\r
- Status = ConPlatformUpdateDeviceVariable (\r
- VarConsoleInp,\r
- DevicePath,\r
- CHECK\r
- );\r
-\r
- if (!EFI_ERROR (Status)) {\r
- gBS->InstallMultipleProtocolInterfaces (\r
- &ControllerHandle,\r
- &gEfiConsoleInDeviceGuid,\r
- NULL,\r
- NULL\r
- );\r
- } else {\r
- gBS->CloseProtocol (\r
- ControllerHandle,\r
- &gEfiSimpleTextInProtocolGuid,\r
- This->DriverBindingHandle,\r
- ControllerHandle\r
- );\r
- }\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-STATIC\r
-EFI_STATUS\r
-EFIAPI\r
-ConPlatformTextOutDriverBindingStart (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE ControllerHandle,\r
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-\r
-Arguments:\r
- (Standard DriverBinding Protocol Start() function)\r
-\r
-Returns:\r
-\r
-\r
---*/\r
-{\r
- EFI_STATUS Status;\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
- EFI_SIMPLE_TEXT_OUT_PROTOCOL *TextOut;\r
-\r
- BOOLEAN NeedClose;\r
-\r
- NeedClose = TRUE;\r
-\r
- //\r
- // Get the Device Path Protocol so the environment variables can be updated\r
- //\r
- Status = gBS->OpenProtocol (\r
- ControllerHandle,\r
- &gEfiDevicePathProtocolGuid,\r
- (VOID **) &DevicePath,\r
- This->DriverBindingHandle,\r
- ControllerHandle,\r
- EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
- //\r
- // Open the Simple Text Output Protocol BY_DRIVER\r
- //\r
- Status = gBS->OpenProtocol (\r
- ControllerHandle,\r
- &gEfiSimpleTextOutProtocolGuid,\r
- (VOID **) &TextOut,\r
- This->DriverBindingHandle,\r
- ControllerHandle,\r
- EFI_OPEN_PROTOCOL_BY_DRIVER\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
- //\r
- // Check the device handle, if it is a hot plug device,\r
- // do not put the device path into ConOutDev and StdErrDev,\r
- // and install gEfiConsoleOutDeviceGuid to the device handle directly.\r
- // The policy is, make hot plug device plug in and play immediately.\r
- //\r
- if (IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) {\r
- gBS->InstallMultipleProtocolInterfaces (\r
- &ControllerHandle,\r
- &gEfiConsoleOutDeviceGuid,\r
- NULL,\r
- NULL\r
- );\r
- } else {\r
- //\r
- // Append the device path to the ConOutDev environment variable\r
- //\r
- ConPlatformUpdateDeviceVariable (\r
- VarConsoleOutDev,\r
- DevicePath,\r
- APPEND\r
- );\r
- //\r
- // Append the device path to the StdErrDev environment variable\r
- //\r
- ConPlatformUpdateDeviceVariable (\r
- VarErrorOutDev,\r
- DevicePath,\r
- APPEND\r
- );\r
-\r
- //\r
- // If the device path is an instance in the ConOut environment variable,\r
- // then install EfiConsoleOutDeviceGuid onto ControllerHandle\r
- //\r
- Status = ConPlatformUpdateDeviceVariable (\r
- VarConsoleOut,\r
- DevicePath,\r
- CHECK\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- NeedClose = FALSE;\r
- Status = gBS->InstallMultipleProtocolInterfaces (\r
- &ControllerHandle,\r
- &gEfiConsoleOutDeviceGuid,\r
- NULL,\r
- NULL\r
- );\r
- }\r
- //\r
- // If the device path is an instance in the StdErr environment variable,\r
- // then install EfiStandardErrorDeviceGuid onto ControllerHandle\r
- //\r
- Status = ConPlatformUpdateDeviceVariable (\r
- VarErrorOut,\r
- DevicePath,\r
- CHECK\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- NeedClose = FALSE;\r
- gBS->InstallMultipleProtocolInterfaces (\r
- &ControllerHandle,\r
- &gEfiStandardErrorDeviceGuid,\r
- NULL,\r
- NULL\r
- );\r
- }\r
-\r
- if (NeedClose) {\r
- gBS->CloseProtocol (\r
- ControllerHandle,\r
- &gEfiSimpleTextOutProtocolGuid,\r
- This->DriverBindingHandle,\r
- ControllerHandle\r
- );\r
- }\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-STATIC\r
-EFI_STATUS\r
-EFIAPI\r
-ConPlatformDriverBindingStop (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE ControllerHandle,\r
- IN UINTN NumberOfChildren,\r
- IN EFI_HANDLE *ChildHandleBuffer\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
- (Standard DriverBinding Protocol Stop() function)\r
-\r
-Returns:\r
-\r
- None\r
-\r
---*/\r
-{\r
- EFI_STATUS Status;\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
-\r
- //\r
- // hot plug device is not included into the console associated variables,\r
- // so no need to check variable for those hot plug devices.\r
- //\r
- if (!IsHotPlugDevice (This->DriverBindingHandle, ControllerHandle)) {\r
- //\r
- // Get the Device Path Protocol so the environment variables can be updated\r
- //\r
- Status = gBS->OpenProtocol (\r
- ControllerHandle,\r
- &gEfiDevicePathProtocolGuid,\r
- (VOID **) &DevicePath,\r
- This->DriverBindingHandle,\r
- ControllerHandle,\r
- EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- //\r
- // Remove DevicePath from ConInDev, ConOutDev, and StdErrDev\r
- //\r
- ConPlatformUpdateDeviceVariable (\r
- VarConsoleInpDev,\r
- DevicePath,\r
- DELETE\r
- );\r
- ConPlatformUpdateDeviceVariable (\r
- VarConsoleOutDev,\r
- DevicePath,\r
- DELETE\r
- );\r
- ConPlatformUpdateDeviceVariable (\r
- VarErrorOutDev,\r
- DevicePath,\r
- DELETE\r
- );\r
- }\r
- }\r
- //\r
- // Uninstall the Console Device GUIDs from Controller Handle\r
- //\r
- ConPlatformUnInstallProtocol (\r
- This,\r
- ControllerHandle,\r
- &gEfiConsoleInDeviceGuid\r
- );\r
-\r
- ConPlatformUnInstallProtocol (\r
- This,\r
- ControllerHandle,\r
- &gEfiConsoleOutDeviceGuid\r
- );\r
-\r
- ConPlatformUnInstallProtocol (\r
- This,\r
- ControllerHandle,\r
- &gEfiStandardErrorDeviceGuid\r
- );\r
-\r
- //\r
- // Close the Simple Input and Simple Text Output Protocols\r
- //\r
- gBS->CloseProtocol (\r
- ControllerHandle,\r
- &gEfiSimpleTextInProtocolGuid,\r
- This->DriverBindingHandle,\r
- ControllerHandle\r
- );\r
-\r
- gBS->CloseProtocol (\r
- ControllerHandle,\r
- &gEfiSimpleTextOutProtocolGuid,\r
- This->DriverBindingHandle,\r
- ControllerHandle\r
- );\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-VOID\r
-ConPlatformUnInstallProtocol (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE Handle,\r
- IN EFI_GUID *ProtocolGuid\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- Status = gBS->OpenProtocol (\r
- Handle,\r
- ProtocolGuid,\r
- NULL,\r
- This->DriverBindingHandle,\r
- Handle,\r
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
- );\r
-\r
- if (!EFI_ERROR (Status)) {\r
- gBS->UninstallMultipleProtocolInterfaces (\r
- Handle,\r
- ProtocolGuid,\r
- NULL,\r
- NULL\r
- );\r
- }\r
-\r
- return ;\r
-}\r
-\r
-VOID *\r
-ConPlatformGetVariable (\r
- IN CHAR16 *Name\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- Read the EFI variable (Name) and return a dynamically allocated\r
- buffer, and the size of the buffer. On failure return NULL.\r
-\r
-Arguments:\r
- Name - String part of EFI variable name\r
-\r
-Returns:\r
- Dynamically allocated memory that contains a copy of the EFI variable.\r
- Caller is repsoncible freeing the buffer.\r
-\r
- NULL - Variable was not read\r
- \r
---*/\r
-{\r
- EFI_STATUS Status;\r
- VOID *Buffer;\r
- UINTN BufferSize;\r
-\r
- BufferSize = 0;\r
- Buffer = NULL;\r
-\r
- //\r
- // Test to see if the variable exists. If it doesn't reuturn NULL\r
- //\r
- Status = gRT->GetVariable (\r
- Name,\r
- &gEfiGlobalVariableGuid,\r
- NULL,\r
- &BufferSize,\r
- Buffer\r
- );\r
-\r
- if (Status == EFI_BUFFER_TOO_SMALL) {\r
- //\r
- // Allocate the buffer to return\r
- //\r
- Status = gBS->AllocatePool (EfiBootServicesData, BufferSize, &Buffer);\r
- if (EFI_ERROR (Status)) {\r
- return NULL;\r
- }\r
- //\r
- // Read variable into the allocated buffer.\r
- //\r
- Status = gRT->GetVariable (\r
- Name,\r
- &gEfiGlobalVariableGuid,\r
- NULL,\r
- &BufferSize,\r
- Buffer\r
- );\r
- if (EFI_ERROR (Status)) {\r
- gBS->FreePool (Buffer);\r
- Buffer = NULL;\r
- }\r
- }\r
-\r
- return Buffer;\r
-}\r
-\r
-EFI_STATUS\r
-ConPlatformMatchDevicePaths (\r
- IN EFI_DEVICE_PATH_PROTOCOL * Multi,\r
- IN EFI_DEVICE_PATH_PROTOCOL * Single,\r
- IN EFI_DEVICE_PATH_PROTOCOL **NewDevicePath OPTIONAL,\r
- IN BOOLEAN Delete\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- Function compares a device path data structure to that of all the nodes of a\r
- second device path instance.\r
-\r
-Arguments:\r
- Multi - A pointer to a multi-instance device path data structure.\r
-\r
- Single - A pointer to a single-instance device path data structure.\r
- \r
- NewDevicePath - If Delete is TRUE, this parameter must not be null, and it\r
- points to the remaining device path data structure. \r
- (remaining device path = Multi - Single.)\r
- \r
- Delete - If TRUE, means removing Single from Multi.\r
- If FALSE, the routine just check whether Single matches \r
- with any instance in Multi.\r
-\r
-Returns:\r
-\r
- The function returns EFI_SUCCESS if the Single is contained within Multi. \r
- Otherwise, EFI_NOT_FOUND is returned.\r
-\r
---*/\r
-{\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
- EFI_DEVICE_PATH_PROTOCOL *TempDevicePath1;\r
- EFI_DEVICE_PATH_PROTOCOL *TempDevicePath2;\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePathInst;\r
- UINTN Size;\r
-\r
- //\r
- // The passed in DevicePath should not be NULL\r
- //\r
- if ((!Multi) || (!Single)) {\r
- return EFI_NOT_FOUND;\r
- }\r
- //\r
- // if performing Delete operation, the NewDevicePath must not be NULL.\r
- //\r
- TempDevicePath1 = NULL;\r
-\r
- DevicePath = Multi;\r
- DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);\r
-\r
- //\r
- // search for the match of 'Single' in 'Multi'\r
- //\r
- while (DevicePathInst) {\r
- if (CompareMem (Single, DevicePathInst, Size) == 0) {\r
- if (!Delete) {\r
- gBS->FreePool (DevicePathInst);\r
- return EFI_SUCCESS;\r
- }\r
- } else {\r
- if (Delete) {\r
- TempDevicePath2 = AppendDevicePathInstance (\r
- TempDevicePath1,\r
- DevicePathInst\r
- );\r
- gBS->FreePool (TempDevicePath1);\r
- TempDevicePath1 = TempDevicePath2;\r
- }\r
- }\r
-\r
- gBS->FreePool (DevicePathInst);\r
- DevicePathInst = GetNextDevicePathInstance (&DevicePath, &Size);\r
- }\r
-\r
- if (Delete) {\r
- *NewDevicePath = TempDevicePath1;\r
- return EFI_SUCCESS;\r
- }\r
-\r
- return EFI_NOT_FOUND;\r
-}\r
-\r
-EFI_STATUS\r
-ConPlatformUpdateDeviceVariable (\r
- IN CHAR16 *VariableName,\r
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
- IN CONPLATFORM_VAR_OPERATION Operation\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
- None\r
-\r
---*/\r
-{\r
- EFI_STATUS Status;\r
- EFI_DEVICE_PATH_PROTOCOL *VariableDevicePath;\r
- EFI_DEVICE_PATH_PROTOCOL *NewVariableDevicePath;\r
-\r
- VariableDevicePath = NULL;\r
- NewVariableDevicePath = NULL;\r
-\r
- //\r
- // Get Variable according to variable name.\r
- // The memory for Variable is allocated within ConPlatformGetVarible(),\r
- // it is the caller's responsibility to free the memory before return.\r
- //\r
- VariableDevicePath = ConPlatformGetVariable (VariableName);\r
-\r
- if (Operation != DELETE) {\r
-\r
- Status = ConPlatformMatchDevicePaths (\r
- VariableDevicePath,\r
- DevicePath,\r
- NULL,\r
- FALSE\r
- );\r
-\r
- if ((Operation == CHECK) || (!EFI_ERROR (Status))) {\r
- //\r
- // The device path is already in the variable\r
- //\r
- gBS->FreePool (VariableDevicePath);\r
-\r
- return Status;\r
- }\r
- //\r
- // The device path is not in variable. Append DevicePath to the\r
- // environment variable that is a multi-instance device path.\r
- //\r
- Status = EFI_SUCCESS;\r
- NewVariableDevicePath = AppendDevicePathInstance (\r
- VariableDevicePath,\r
- DevicePath\r
- );\r
- if (NewVariableDevicePath == NULL) {\r
- Status = EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- } else {\r
- //\r
- // Remove DevicePath from the environment variable that\r
- // is a multi-instance device path.\r
- //\r
- Status = ConPlatformMatchDevicePaths (\r
- VariableDevicePath,\r
- DevicePath,\r
- &NewVariableDevicePath,\r
- TRUE\r
- );\r
- }\r
-\r
- gBS->FreePool (VariableDevicePath);\r
-\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- Status = gRT->SetVariable (\r
- VariableName,\r
- &gEfiGlobalVariableGuid,\r
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
- GetDevicePathSize (NewVariableDevicePath),\r
- NewVariableDevicePath\r
- );\r
-\r
- gBS->FreePool (NewVariableDevicePath);\r
-\r
- return Status;\r
-}\r
-\r
-BOOLEAN\r
-IsHotPlugDevice (\r
- EFI_HANDLE DriverBindingHandle,\r
- EFI_HANDLE ControllerHandle\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- //\r
- // HotPlugDeviceGuid indicates ControllerHandle stands for a hot plug device.\r
- //\r
- Status = gBS->OpenProtocol (\r
- ControllerHandle,\r
- &gEfiHotPlugDeviceGuid,\r
- NULL,\r
- DriverBindingHandle,\r
- ControllerHandle,\r
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return FALSE;\r
- }\r
-\r
- return TRUE;\r
-}\r
+++ /dev/null
-/*++\r
-\r
-Copyright (c) 2006, Intel Corporation \r
-All rights reserved. This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-\r
-Module Name:\r
-\r
- ConPlatform.h\r
- \r
-Abstract:\r
-\r
---*/\r
-\r
-#ifndef CON_MANAGE_H_\r
-#define CON_MANAGE_H_\r
-\r
-//\r
-//\r
-//\r
-#define VarConsoleInpDev L"ConInDev"\r
-#define VarConsoleInp L"ConIn"\r
-#define VarConsoleOutDev L"ConOutDev"\r
-#define VarConsoleOut L"ConOut"\r
-#define VarErrorOutDev L"ErrOutDev"\r
-#define VarErrorOut L"ErrOut"\r
-\r
-typedef enum {\r
- CHECK,\r
- APPEND,\r
- DELETE\r
-} CONPLATFORM_VAR_OPERATION;\r
-\r
-EFI_STATUS\r
-ConPlatformDriverBindingSupported (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE ControllerHandle,\r
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath,\r
- IN EFI_GUID *ProtocolGuid\r
- );\r
-\r
-STATIC\r
-EFI_STATUS\r
-EFIAPI\r
-ConPlatformTextInDriverBindingSupported (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE Handle,\r
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
- );\r
-\r
-STATIC\r
-EFI_STATUS\r
-EFIAPI\r
-ConPlatformTextOutDriverBindingSupported (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE Handle,\r
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
- );\r
-\r
-STATIC\r
-EFI_STATUS\r
-EFIAPI\r
-ConPlatformTextInDriverBindingStart (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE Handle,\r
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
- );\r
-\r
-STATIC\r
-EFI_STATUS\r
-EFIAPI\r
-ConPlatformTextOutDriverBindingStart (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE Handle,\r
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
- );\r
-\r
-STATIC\r
-EFI_STATUS\r
-EFIAPI\r
-ConPlatformDriverBindingStop (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE Handle,\r
- IN UINTN NumberOfChildren,\r
- IN EFI_HANDLE *ChildHandleBuffer\r
- );\r
-\r
-VOID\r
-ConPlatformUnInstallProtocol (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE Handle,\r
- IN EFI_GUID *ProtocolGuid\r
- );\r
-\r
-VOID *\r
-ConPlatformGetVariable (\r
- IN CHAR16 *Name\r
- );\r
-\r
-EFI_STATUS\r
-ConPlatformMatchDevicePaths (\r
- IN EFI_DEVICE_PATH_PROTOCOL * Multi,\r
- IN EFI_DEVICE_PATH_PROTOCOL * Single,\r
- IN EFI_DEVICE_PATH_PROTOCOL **NewDevicePath OPTIONAL,\r
- IN BOOLEAN Delete\r
- );\r
-\r
-EFI_STATUS\r
-ConPlatformUpdateDeviceVariable (\r
- IN CHAR16 *VariableName,\r
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
- IN CONPLATFORM_VAR_OPERATION Operation\r
- );\r
-\r
-BOOLEAN\r
-IsHotPlugDevice (\r
- EFI_HANDLE DriverBindingHandle,\r
- EFI_HANDLE ControllerHandle\r
- );\r
-\r
-#endif\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-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.-->\r
-<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0">\r
- <MsaHeader>\r
- <ModuleName>ConPlatform</ModuleName>\r
- <ModuleType>UEFI_DRIVER</ModuleType>\r
- <GuidValue>51ccf399-4fdf-4e55-a45b-e123f84d456a</GuidValue>\r
- <Version>1.0</Version>\r
- <Abstract>Console Platfrom Driver</Abstract>\r
- <Description>Console Platfrom DXE Driver, install Console protocols</Description>\r
- <Copyright>Copyright (c) 2006, Intel Corporation</Copyright>\r
- <License>All rights reserved. This program and the accompanying materials
- 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.</License>\r
- <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>\r
- </MsaHeader>\r
- <ModuleDefinitions>\r
- <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
- <BinaryModule>false</BinaryModule>\r
- <OutputFileBasename>ConPlatform</OutputFileBasename>\r
- </ModuleDefinitions>\r
- <LibraryClassDefinitions>\r
- <LibraryClass Usage="ALWAYS_CONSUMED">\r
- <Keyword>DebugLib</Keyword>\r
- </LibraryClass>\r
- <LibraryClass Usage="ALWAYS_CONSUMED">\r
- <Keyword>UefiDriverModelLib</Keyword>\r
- </LibraryClass>\r
- <LibraryClass Usage="ALWAYS_CONSUMED">\r
- <Keyword>UefiDriverEntryPoint</Keyword>\r
- </LibraryClass>\r
- <LibraryClass Usage="ALWAYS_CONSUMED">\r
- <Keyword>UefiLib</Keyword>\r
- </LibraryClass>\r
- <LibraryClass Usage="ALWAYS_CONSUMED">\r
- <Keyword>BaseLib</Keyword>\r
- </LibraryClass>\r
- <LibraryClass Usage="ALWAYS_CONSUMED">\r
- <Keyword>BaseMemoryLib</Keyword>\r
- </LibraryClass>\r
- <LibraryClass Usage="ALWAYS_CONSUMED">\r
- <Keyword>MemoryAllocationLib</Keyword>\r
- </LibraryClass>\r
- <LibraryClass Usage="ALWAYS_CONSUMED">\r
- <Keyword>UefiBootServicesTableLib</Keyword>\r
- </LibraryClass>\r
- <LibraryClass Usage="ALWAYS_CONSUMED">\r
- <Keyword>UefiRuntimeServicesTableLib</Keyword>\r
- </LibraryClass>\r
- <LibraryClass Usage="ALWAYS_CONSUMED">\r
- <Keyword>DevicePathLib</Keyword>\r
- </LibraryClass>\r
- </LibraryClassDefinitions>\r
- <SourceFiles>\r
- <Filename>ConPlatform.c</Filename>\r
- <Filename>ConPlatform.h</Filename>\r
- <Filename>ComponentName.h</Filename>\r
- <Filename>ComponentName.c</Filename>\r
- </SourceFiles>\r
- <PackageDependencies>\r
- <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
- <Package PackageGuid="B6EC423C-21D2-490D-85C6-DD5864EAA674"/>\r
- </PackageDependencies>\r
- <Protocols>\r
- <Protocol Usage="TO_START">\r
- <ProtocolCName>gEfiSimpleTextOutProtocolGuid</ProtocolCName>\r
- </Protocol>\r
- <Protocol Usage="TO_START">\r
- <ProtocolCName>gEfiSimpleTextInProtocolGuid</ProtocolCName>\r
- </Protocol>\r
- <Protocol Usage="TO_START">\r
- <ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>\r
- </Protocol>\r
- </Protocols>\r
- <Variables>\r
- <Variable Usage="SOMETIMES_CONSUMED">\r
- <VariableName>0x0043 0x006F 0x006E 0x0049 0x006E 0x0044 0x0065 0x0076</VariableName>\r
- <GuidC_Name>gConInDevGuid</GuidC_Name>\r
- </Variable>\r
- <Variable Usage="SOMETIMES_CONSUMED">\r
- <VariableName>0x0043 0x006F 0x006E 0x0049 0x006E</VariableName>\r
- <GuidC_Name>gConInGuid</GuidC_Name>\r
- </Variable>\r
- <Variable Usage="SOMETIMES_CONSUMED">\r
- <VariableName>0x0043 0x006F 0x006E 0x004F 0x0075 0x0074 0x0044 0x0065 0x0076</VariableName>\r
- <GuidC_Name>gConOutDevGuid</GuidC_Name>\r
- </Variable>\r
- <Variable Usage="SOMETIMES_CONSUMED">\r
- <VariableName>0x0043 0x006F 0x006E 0x004F 0x0075 0x0074</VariableName>\r
- <GuidC_Name>gConOutGuid</GuidC_Name>\r
- </Variable>\r
- <Variable Usage="SOMETIMES_CONSUMED">\r
- <VariableName>0x0045 0x0072 0x0072 0x004F 0x0075 0x0074 0x0044 0x0065 0x0076</VariableName>\r
- <GuidC_Name>gErrOutDevGuid</GuidC_Name>\r
- </Variable>\r
- <Variable Usage="SOMETIMES_CONSUMED">\r
- <VariableName>0x0045 0x0072 0x0072 0x004F 0x0075 0x0074</VariableName>\r
- <GuidC_Name>gErrOutGuid</GuidC_Name>\r
- </Variable>\r
- </Variables>\r
- <Guids>\r
- <GuidCNames Usage="SOMETIMES_PRODUCED">\r
- <GuidCName>gEfiConsoleInDeviceGuid</GuidCName>\r
- </GuidCNames>\r
- <GuidCNames Usage="SOMETIMES_PRODUCED">\r
- <GuidCName>gEfiConsoleOutDeviceGuid</GuidCName>\r
- </GuidCNames>\r
- <GuidCNames Usage="SOMETIMES_PRODUCED">\r
- <GuidCName>gEfiStandardErrorDeviceGuid</GuidCName>\r
- </GuidCNames>\r
- <GuidCNames Usage="SOMETIMES_CONSUMED">\r
- <GuidCName>gEfiHotPlugDeviceGuid</GuidCName>\r
- </GuidCNames>\r
- <GuidCNames Usage="SOMETIMES_CONSUMED">\r
- <GuidCName>gEfiGlobalVariableGuid</GuidCName>\r
- </GuidCNames>\r
- </Guids>\r
- <Externs>\r
- <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
- <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
- <Extern>\r
- <DriverBinding>gConPlatformTextInDriverBinding</DriverBinding>\r
- </Extern>\r
- <Extern>\r
- <ComponentName>gConPlatformComponentName</ComponentName>\r
- </Extern>\r
- <Extern>\r
- <DriverBinding>gConPlatformTextOutDriverBinding</DriverBinding>\r
- </Extern>\r
- <Extern>\r
- <ComponentName>gConPlatformComponentName</ComponentName>\r
- </Extern>\r
- </Externs>\r
-</ModuleSurfaceArea>
\ No newline at end of file