2009-05-27 23:10:18 +02:00
|
|
|
/** @file
|
|
|
|
Platform BDS customizations.
|
|
|
|
|
2014-08-13 08:31:08 +02:00
|
|
|
Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
|
2010-04-28 14:43:04 +02:00
|
|
|
This program and the accompanying materials
|
2009-05-27 23:10:18 +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.
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include "BdsPlatform.h"
|
2015-01-02 13:07:57 +01:00
|
|
|
#include <Library/QemuBootOrderLib.h>
|
2009-05-27 23:10:18 +02:00
|
|
|
|
|
|
|
|
2009-06-30 17:57:35 +02:00
|
|
|
//
|
|
|
|
// Global data
|
|
|
|
//
|
|
|
|
|
|
|
|
VOID *mEfiDevPathNotifyReg;
|
|
|
|
EFI_EVENT mEfiDevPathEvent;
|
2009-09-26 09:15:55 +02:00
|
|
|
VOID *mEmuVariableEventReg;
|
|
|
|
EFI_EVENT mEmuVariableEvent;
|
2009-09-16 18:29:00 +02:00
|
|
|
BOOLEAN mDetectVgaOnly;
|
2014-11-17 20:09:12 +01:00
|
|
|
UINT16 mHostBridgeDevId;
|
2009-09-16 18:29:00 +02:00
|
|
|
|
2014-11-17 20:09:12 +01:00
|
|
|
//
|
|
|
|
// Table of host IRQs matching PCI IRQs A-D
|
|
|
|
// (for configuring PCI Interrupt Line register)
|
|
|
|
//
|
|
|
|
CONST UINT8 PciHostIrqs[] = {
|
|
|
|
0x0a, 0x0a, 0x0b, 0x0b
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// Array Size macro
|
|
|
|
//
|
|
|
|
#define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))
|
2009-09-16 18:29:00 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Type definitions
|
|
|
|
//
|
|
|
|
|
|
|
|
typedef
|
|
|
|
EFI_STATUS
|
|
|
|
(EFIAPI *PROTOCOL_INSTANCE_CALLBACK)(
|
|
|
|
IN EFI_HANDLE Handle,
|
|
|
|
IN VOID *Instance,
|
|
|
|
IN VOID *Context
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
@param[in] Handle - Handle of PCI device instance
|
|
|
|
@param[in] PciIo - PCI IO protocol instance
|
|
|
|
@param[in] Pci - PCI Header register block
|
|
|
|
**/
|
|
|
|
typedef
|
|
|
|
EFI_STATUS
|
|
|
|
(EFIAPI *VISIT_PCI_INSTANCE_CALLBACK)(
|
|
|
|
IN EFI_HANDLE Handle,
|
|
|
|
IN EFI_PCI_IO_PROTOCOL *PciIo,
|
|
|
|
IN PCI_TYPE00 *Pci
|
|
|
|
);
|
2009-06-30 17:57:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Function prototypes
|
|
|
|
//
|
|
|
|
|
2009-09-16 18:29:00 +02:00
|
|
|
EFI_STATUS
|
|
|
|
VisitAllInstancesOfProtocol (
|
|
|
|
IN EFI_GUID *Id,
|
|
|
|
IN PROTOCOL_INSTANCE_CALLBACK CallBackFunction,
|
|
|
|
IN VOID *Context
|
|
|
|
);
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
VisitAllPciInstancesOfProtocol (
|
|
|
|
IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction
|
|
|
|
);
|
|
|
|
|
2009-06-30 17:57:35 +02:00
|
|
|
VOID
|
|
|
|
InstallDevicePathCallback (
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2009-05-27 23:10:18 +02:00
|
|
|
//
|
|
|
|
// BDS Platform Functions
|
|
|
|
//
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
PlatformBdsInit (
|
2009-06-07 06:44:53 +02:00
|
|
|
VOID
|
2009-05-27 23:10:18 +02:00
|
|
|
)
|
|
|
|
/*++
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
|
|
|
|
Platform Bds init. Incude the platform firmware vendor, revision
|
|
|
|
and so crc check.
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
None.
|
|
|
|
|
|
|
|
--*/
|
|
|
|
{
|
|
|
|
DEBUG ((EFI_D_INFO, "PlatformBdsInit\n"));
|
2009-06-30 17:57:35 +02:00
|
|
|
InstallDevicePathCallback ();
|
2009-05-27 23:10:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
ConnectRootBridge (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
/*++
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
|
|
|
|
Connect RootBridge
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
None.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
EFI_SUCCESS - Connect RootBridge successfully.
|
|
|
|
EFI_STATUS - Connect RootBridge fail.
|
|
|
|
|
|
|
|
--*/
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_HANDLE RootHandle;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Make all the PCI_IO protocols on PCI Seg 0 show up
|
|
|
|
//
|
|
|
|
BdsLibConnectDevicePath (gPlatformRootBridges[0]);
|
|
|
|
|
|
|
|
Status = gBS->LocateDevicePath (
|
|
|
|
&gEfiDevicePathProtocolGuid,
|
|
|
|
&gPlatformRootBridges[0],
|
|
|
|
&RootHandle
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = gBS->ConnectController (RootHandle, NULL, NULL, FALSE);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
PrepareLpcBridgeDevicePath (
|
|
|
|
IN EFI_HANDLE DeviceHandle
|
|
|
|
)
|
|
|
|
/*++
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
|
|
|
|
Add IsaKeyboard to ConIn,
|
|
|
|
add IsaSerial to ConOut, ConIn, ErrOut.
|
|
|
|
LPC Bridge: 06 01 00
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
DeviceHandle - Handle of PCIIO protocol.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
EFI_SUCCESS - LPC bridge is added to ConOut, ConIn, and ErrOut.
|
|
|
|
EFI_STATUS - No LPC bridge is added.
|
|
|
|
|
|
|
|
--*/
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
|
|
|
|
CHAR16 *DevPathStr;
|
|
|
|
|
|
|
|
DevicePath = NULL;
|
|
|
|
Status = gBS->HandleProtocol (
|
|
|
|
DeviceHandle,
|
|
|
|
&gEfiDevicePathProtocolGuid,
|
|
|
|
(VOID*)&DevicePath
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
TempDevicePath = DevicePath;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Register Keyboard
|
|
|
|
//
|
|
|
|
DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnpPs2KeyboardDeviceNode);
|
|
|
|
|
|
|
|
BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Register COM1
|
|
|
|
//
|
|
|
|
DevicePath = TempDevicePath;
|
|
|
|
gPnp16550ComPortDeviceNode.UID = 0;
|
|
|
|
|
|
|
|
DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);
|
|
|
|
DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
|
|
|
|
DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Print Device Path
|
|
|
|
//
|
|
|
|
DevPathStr = DevicePathToStr(DevicePath);
|
2013-07-26 05:14:08 +02:00
|
|
|
if (DevPathStr != NULL) {
|
|
|
|
DEBUG((
|
|
|
|
EFI_D_INFO,
|
|
|
|
"BdsPlatform.c+%d: COM%d DevPath: %s\n",
|
|
|
|
__LINE__,
|
|
|
|
gPnp16550ComPortDeviceNode.UID + 1,
|
|
|
|
DevPathStr
|
|
|
|
));
|
|
|
|
FreePool(DevPathStr);
|
|
|
|
}
|
2009-05-27 23:10:18 +02:00
|
|
|
|
|
|
|
BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);
|
|
|
|
BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);
|
|
|
|
BdsLibUpdateConsoleVariable (VarErrorOut, DevicePath, NULL);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Register COM2
|
|
|
|
//
|
|
|
|
DevicePath = TempDevicePath;
|
|
|
|
gPnp16550ComPortDeviceNode.UID = 1;
|
|
|
|
|
|
|
|
DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode);
|
|
|
|
DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
|
|
|
|
DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Print Device Path
|
|
|
|
//
|
|
|
|
DevPathStr = DevicePathToStr(DevicePath);
|
2013-07-26 05:14:08 +02:00
|
|
|
if (DevPathStr != NULL) {
|
|
|
|
DEBUG((
|
|
|
|
EFI_D_INFO,
|
|
|
|
"BdsPlatform.c+%d: COM%d DevPath: %s\n",
|
|
|
|
__LINE__,
|
|
|
|
gPnp16550ComPortDeviceNode.UID + 1,
|
|
|
|
DevPathStr
|
|
|
|
));
|
|
|
|
FreePool(DevPathStr);
|
|
|
|
}
|
2009-05-27 23:10:18 +02:00
|
|
|
|
|
|
|
BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);
|
|
|
|
BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);
|
|
|
|
BdsLibUpdateConsoleVariable (VarErrorOut, DevicePath, NULL);
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
GetGopDevicePath (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *PciDevicePath,
|
|
|
|
OUT EFI_DEVICE_PATH_PROTOCOL **GopDevicePath
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINTN Index;
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_HANDLE PciDeviceHandle;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *TempPciDevicePath;
|
|
|
|
UINTN GopHandleCount;
|
|
|
|
EFI_HANDLE *GopHandleBuffer;
|
|
|
|
|
|
|
|
if (PciDevicePath == NULL || GopDevicePath == NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Initialize the GopDevicePath to be PciDevicePath
|
|
|
|
//
|
|
|
|
*GopDevicePath = PciDevicePath;
|
|
|
|
TempPciDevicePath = PciDevicePath;
|
|
|
|
|
|
|
|
Status = gBS->LocateDevicePath (
|
|
|
|
&gEfiDevicePathProtocolGuid,
|
|
|
|
&TempPciDevicePath,
|
|
|
|
&PciDeviceHandle
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Try to connect this handle, so that GOP dirver could start on this
|
|
|
|
// device and create child handles with GraphicsOutput Protocol installed
|
|
|
|
// on them, then we get device paths of these child handles and select
|
|
|
|
// them as possible console device.
|
|
|
|
//
|
|
|
|
gBS->ConnectController (PciDeviceHandle, NULL, NULL, FALSE);
|
|
|
|
|
|
|
|
Status = gBS->LocateHandleBuffer (
|
|
|
|
ByProtocol,
|
|
|
|
&gEfiGraphicsOutputProtocolGuid,
|
|
|
|
NULL,
|
|
|
|
&GopHandleCount,
|
|
|
|
&GopHandleBuffer
|
|
|
|
);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
//
|
|
|
|
// Add all the child handles as possible Console Device
|
|
|
|
//
|
|
|
|
for (Index = 0; Index < GopHandleCount; Index++) {
|
|
|
|
Status = gBS->HandleProtocol (GopHandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID*)&TempDevicePath);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (CompareMem (
|
|
|
|
PciDevicePath,
|
|
|
|
TempDevicePath,
|
|
|
|
GetDevicePathSize (PciDevicePath) - END_DEVICE_PATH_LENGTH
|
|
|
|
) == 0) {
|
|
|
|
//
|
|
|
|
// In current implementation, we only enable one of the child handles
|
|
|
|
// as console device, i.e. sotre one of the child handle's device
|
|
|
|
// path to variable "ConOut"
|
|
|
|
// In futhure, we could select all child handles to be console device
|
|
|
|
//
|
|
|
|
|
|
|
|
*GopDevicePath = TempDevicePath;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Delete the PCI device's path that added by GetPlugInPciVgaDevicePath()
|
|
|
|
// Add the integrity GOP device path.
|
|
|
|
//
|
|
|
|
BdsLibUpdateConsoleVariable (VarConsoleOutDev, NULL, PciDevicePath);
|
|
|
|
BdsLibUpdateConsoleVariable (VarConsoleOutDev, TempDevicePath, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gBS->FreePool (GopHandleBuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
PreparePciVgaDevicePath (
|
|
|
|
IN EFI_HANDLE DeviceHandle
|
|
|
|
)
|
|
|
|
/*++
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
|
|
|
|
Add PCI VGA to ConOut.
|
|
|
|
PCI VGA: 03 00 00
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
DeviceHandle - Handle of PCIIO protocol.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
EFI_SUCCESS - PCI VGA is added to ConOut.
|
|
|
|
EFI_STATUS - No PCI VGA device is added.
|
|
|
|
|
|
|
|
--*/
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;
|
|
|
|
|
2014-08-13 08:31:08 +02:00
|
|
|
DevicePath = NULL;
|
|
|
|
GopDevicePath = NULL;
|
2009-05-27 23:10:18 +02:00
|
|
|
Status = gBS->HandleProtocol (
|
|
|
|
DeviceHandle,
|
|
|
|
&gEfiDevicePathProtocolGuid,
|
|
|
|
(VOID*)&DevicePath
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetGopDevicePath (DevicePath, &GopDevicePath);
|
|
|
|
DevicePath = GopDevicePath;
|
|
|
|
|
|
|
|
BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
PreparePciSerialDevicePath (
|
|
|
|
IN EFI_HANDLE DeviceHandle
|
|
|
|
)
|
|
|
|
/*++
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
|
|
|
|
Add PCI Serial to ConOut, ConIn, ErrOut.
|
|
|
|
PCI Serial: 07 00 02
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
DeviceHandle - Handle of PCIIO protocol.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
EFI_SUCCESS - PCI Serial is added to ConOut, ConIn, and ErrOut.
|
|
|
|
EFI_STATUS - No PCI Serial device is added.
|
|
|
|
|
|
|
|
--*/
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
|
|
|
|
|
|
|
DevicePath = NULL;
|
|
|
|
Status = gBS->HandleProtocol (
|
|
|
|
DeviceHandle,
|
|
|
|
&gEfiDevicePathProtocolGuid,
|
|
|
|
(VOID*)&DevicePath
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);
|
|
|
|
DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);
|
|
|
|
|
|
|
|
BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);
|
|
|
|
BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);
|
|
|
|
BdsLibUpdateConsoleVariable (VarErrorOut, DevicePath, NULL);
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
EFI_STATUS
|
2009-09-16 18:29:00 +02:00
|
|
|
VisitAllInstancesOfProtocol (
|
|
|
|
IN EFI_GUID *Id,
|
|
|
|
IN PROTOCOL_INSTANCE_CALLBACK CallBackFunction,
|
|
|
|
IN VOID *Context
|
2009-05-27 23:10:18 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
UINTN HandleCount;
|
|
|
|
EFI_HANDLE *HandleBuffer;
|
|
|
|
UINTN Index;
|
2009-09-16 18:29:00 +02:00
|
|
|
VOID *Instance;
|
2009-05-27 23:10:18 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Start to check all the PciIo to find all possible device
|
|
|
|
//
|
|
|
|
HandleCount = 0;
|
|
|
|
HandleBuffer = NULL;
|
|
|
|
Status = gBS->LocateHandleBuffer (
|
|
|
|
ByProtocol,
|
2009-09-16 18:29:00 +02:00
|
|
|
Id,
|
2009-05-27 23:10:18 +02:00
|
|
|
NULL,
|
|
|
|
&HandleCount,
|
|
|
|
&HandleBuffer
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Index = 0; Index < HandleCount; Index++) {
|
2009-09-16 18:29:00 +02:00
|
|
|
Status = gBS->HandleProtocol (HandleBuffer[Index], Id, &Instance);
|
2009-05-27 23:10:18 +02:00
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-09-16 18:29:00 +02:00
|
|
|
Status = (*CallBackFunction) (
|
|
|
|
HandleBuffer[Index],
|
|
|
|
Instance,
|
|
|
|
Context
|
|
|
|
);
|
|
|
|
}
|
2009-05-27 23:10:18 +02:00
|
|
|
|
2009-09-16 18:29:00 +02:00
|
|
|
gBS->FreePool (HandleBuffer);
|
2009-09-07 22:18:19 +02:00
|
|
|
|
2009-09-16 18:29:00 +02:00
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
VisitingAPciInstance (
|
|
|
|
IN EFI_HANDLE Handle,
|
|
|
|
IN VOID *Instance,
|
|
|
|
IN VOID *Context
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_PCI_IO_PROTOCOL *PciIo;
|
|
|
|
PCI_TYPE00 Pci;
|
|
|
|
|
|
|
|
PciIo = (EFI_PCI_IO_PROTOCOL*) Instance;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Check for all PCI device
|
|
|
|
//
|
|
|
|
Status = PciIo->Pci.Read (
|
|
|
|
PciIo,
|
|
|
|
EfiPciIoWidthUint32,
|
|
|
|
0,
|
|
|
|
sizeof (Pci) / sizeof (UINT32),
|
|
|
|
&Pci
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2009-09-21 16:20:11 +02:00
|
|
|
return (*(VISIT_PCI_INSTANCE_CALLBACK)(UINTN) Context) (
|
2009-09-16 18:29:00 +02:00
|
|
|
Handle,
|
|
|
|
PciIo,
|
|
|
|
&Pci
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
VisitAllPciInstances (
|
|
|
|
IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return VisitAllInstancesOfProtocol (
|
|
|
|
&gEfiPciIoProtocolGuid,
|
|
|
|
VisitingAPciInstance,
|
2009-09-21 16:20:11 +02:00
|
|
|
(VOID*)(UINTN) CallBackFunction
|
2009-09-16 18:29:00 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Do platform specific PCI Device check and add them to
|
|
|
|
ConOut, ConIn, ErrOut.
|
|
|
|
|
|
|
|
@param[in] Handle - Handle of PCI device instance
|
|
|
|
@param[in] PciIo - PCI IO protocol instance
|
|
|
|
@param[in] Pci - PCI Header register block
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS - PCI Device check and Console variable update successfully.
|
|
|
|
@retval EFI_STATUS - PCI Device check or Console variable update fail.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
2009-12-17 00:28:46 +01:00
|
|
|
EFIAPI
|
2009-09-16 18:29:00 +02:00
|
|
|
DetectAndPreparePlatformPciDevicePath (
|
|
|
|
IN EFI_HANDLE Handle,
|
|
|
|
IN EFI_PCI_IO_PROTOCOL *PciIo,
|
|
|
|
IN PCI_TYPE00 *Pci
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
|
|
|
|
Status = PciIo->Attributes (
|
|
|
|
PciIo,
|
|
|
|
EfiPciIoAttributeOperationEnable,
|
|
|
|
EFI_PCI_DEVICE_ENABLE,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
if (!mDetectVgaOnly) {
|
|
|
|
//
|
|
|
|
// Here we decide whether it is LPC Bridge
|
|
|
|
//
|
|
|
|
if ((IS_PCI_LPC (Pci)) ||
|
|
|
|
((IS_PCI_ISA_PDECODE (Pci)) &&
|
|
|
|
(Pci->Hdr.VendorId == 0x8086) &&
|
|
|
|
(Pci->Hdr.DeviceId == 0x7000)
|
|
|
|
)
|
|
|
|
) {
|
2009-05-27 23:10:18 +02:00
|
|
|
//
|
2009-09-16 18:29:00 +02:00
|
|
|
// Add IsaKeyboard to ConIn,
|
|
|
|
// add IsaSerial to ConOut, ConIn, ErrOut
|
2009-05-27 23:10:18 +02:00
|
|
|
//
|
2009-09-16 18:29:00 +02:00
|
|
|
DEBUG ((EFI_D_INFO, "Found LPC Bridge device\n"));
|
|
|
|
PrepareLpcBridgeDevicePath (Handle);
|
|
|
|
return EFI_SUCCESS;
|
2009-05-27 23:10:18 +02:00
|
|
|
}
|
|
|
|
//
|
2009-09-16 18:29:00 +02:00
|
|
|
// Here we decide which Serial device to enable in PCI bus
|
2009-05-27 23:10:18 +02:00
|
|
|
//
|
2009-09-16 18:29:00 +02:00
|
|
|
if (IS_PCI_16550SERIAL (Pci)) {
|
2009-05-27 23:10:18 +02:00
|
|
|
//
|
2009-09-16 18:29:00 +02:00
|
|
|
// Add them to ConOut, ConIn, ErrOut.
|
2009-05-27 23:10:18 +02:00
|
|
|
//
|
2009-09-16 18:29:00 +02:00
|
|
|
DEBUG ((EFI_D_INFO, "Found PCI 16550 SERIAL device\n"));
|
|
|
|
PreparePciSerialDevicePath (Handle);
|
|
|
|
return EFI_SUCCESS;
|
2009-05-27 23:10:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-16 18:29:00 +02:00
|
|
|
//
|
|
|
|
// Here we decide which VGA device to enable in PCI bus
|
|
|
|
//
|
|
|
|
if (IS_PCI_VGA (Pci)) {
|
|
|
|
//
|
|
|
|
// Add them to ConOut.
|
|
|
|
//
|
|
|
|
DEBUG ((EFI_D_INFO, "Found PCI VGA device\n"));
|
|
|
|
PreparePciVgaDevicePath (Handle);
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
2009-05-27 23:10:18 +02:00
|
|
|
|
2009-09-16 18:29:00 +02:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut
|
|
|
|
|
|
|
|
@param[in] DetectVgaOnly - Only detect VGA device if it's TRUE.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS - PCI Device check and Console variable update successfully.
|
|
|
|
@retval EFI_STATUS - PCI Device check or Console variable update fail.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
DetectAndPreparePlatformPciDevicePaths (
|
|
|
|
BOOLEAN DetectVgaOnly
|
|
|
|
)
|
|
|
|
{
|
|
|
|
mDetectVgaOnly = DetectVgaOnly;
|
|
|
|
return VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath);
|
2009-05-27 23:10:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
PlatformBdsConnectConsole (
|
|
|
|
IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole
|
|
|
|
)
|
|
|
|
/*++
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
|
|
|
|
Connect the predefined platform default console device. Always try to find
|
|
|
|
and enable the vga device if have.
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
PlatformConsole - Predfined platform default console device array.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
EFI_SUCCESS - Success connect at least one ConIn and ConOut
|
|
|
|
device, there must have one ConOut device is
|
|
|
|
active vga device.
|
|
|
|
|
|
|
|
EFI_STATUS - Return the status of
|
|
|
|
BdsLibConnectAllDefaultConsoles ()
|
|
|
|
|
|
|
|
--*/
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
UINTN Index;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *VarConout;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *VarConin;
|
|
|
|
UINTN DevicePathSize;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Connect RootBridge
|
|
|
|
//
|
|
|
|
VarConout = BdsLibGetVariableAndSize (
|
|
|
|
VarConsoleOut,
|
|
|
|
&gEfiGlobalVariableGuid,
|
|
|
|
&DevicePathSize
|
|
|
|
);
|
|
|
|
VarConin = BdsLibGetVariableAndSize (
|
|
|
|
VarConsoleInp,
|
|
|
|
&gEfiGlobalVariableGuid,
|
|
|
|
&DevicePathSize
|
|
|
|
);
|
|
|
|
|
|
|
|
if (VarConout == NULL || VarConin == NULL) {
|
|
|
|
//
|
|
|
|
// Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut
|
|
|
|
//
|
2009-09-16 18:29:00 +02:00
|
|
|
DetectAndPreparePlatformPciDevicePaths (FALSE);
|
2009-05-27 23:10:18 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Have chance to connect the platform default console,
|
|
|
|
// the platform default console is the minimue device group
|
|
|
|
// the platform should support
|
|
|
|
//
|
|
|
|
for (Index = 0; PlatformConsole[Index].DevicePath != NULL; ++Index) {
|
|
|
|
//
|
|
|
|
// Update the console variable with the connect type
|
|
|
|
//
|
|
|
|
if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {
|
|
|
|
BdsLibUpdateConsoleVariable (VarConsoleInp, PlatformConsole[Index].DevicePath, NULL);
|
|
|
|
}
|
|
|
|
if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {
|
|
|
|
BdsLibUpdateConsoleVariable (VarConsoleOut, PlatformConsole[Index].DevicePath, NULL);
|
|
|
|
}
|
|
|
|
if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {
|
|
|
|
BdsLibUpdateConsoleVariable (VarErrorOut, PlatformConsole[Index].DevicePath, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//
|
|
|
|
// Only detect VGA device and add them to ConOut
|
|
|
|
//
|
2009-09-16 18:29:00 +02:00
|
|
|
DetectAndPreparePlatformPciDevicePaths (TRUE);
|
2009-05-27 23:10:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Connect the all the default console with current cosole variable
|
|
|
|
//
|
|
|
|
Status = BdsLibConnectAllDefaultConsoles ();
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-17 20:09:12 +01:00
|
|
|
/**
|
|
|
|
Configure PCI Interrupt Line register for applicable devices
|
|
|
|
Ported from SeaBIOS, src/fw/pciinit.c, *_pci_slot_get_irq()
|
|
|
|
|
|
|
|
@param[in] Handle - Handle of PCI device instance
|
|
|
|
@param[in] PciIo - PCI IO protocol instance
|
|
|
|
@param[in] PciHdr - PCI Header register block
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS - PCI Interrupt Line register configured successfully.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
SetPciIntLine (
|
|
|
|
IN EFI_HANDLE Handle,
|
|
|
|
IN EFI_PCI_IO_PROTOCOL *PciIo,
|
|
|
|
IN PCI_TYPE00 *PciHdr
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
|
|
|
|
UINTN RootSlot;
|
|
|
|
UINTN Idx;
|
|
|
|
UINT8 IrqLine;
|
|
|
|
EFI_STATUS Status;
|
|
|
|
|
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
|
|
|
|
if (PciHdr->Device.InterruptPin != 0) {
|
|
|
|
|
|
|
|
DevPathNode = DevicePathFromHandle (Handle);
|
|
|
|
ASSERT (DevPathNode != NULL);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Compute index into PciHostIrqs[] table by walking
|
|
|
|
// the device path and adding up all device numbers
|
|
|
|
//
|
|
|
|
Status = EFI_NOT_FOUND;
|
|
|
|
RootSlot = 0;
|
|
|
|
Idx = PciHdr->Device.InterruptPin - 1;
|
|
|
|
while (!IsDevicePathEnd (DevPathNode)) {
|
|
|
|
if (DevicePathType (DevPathNode) == HARDWARE_DEVICE_PATH &&
|
|
|
|
DevicePathSubType (DevPathNode) == HW_PCI_DP) {
|
|
|
|
|
|
|
|
Idx += ((PCI_DEVICE_PATH *)DevPathNode)->Device;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Unlike SeaBIOS, which starts climbing from the leaf device
|
|
|
|
// up toward the root, we traverse the device path starting at
|
|
|
|
// the root moving toward the leaf node.
|
|
|
|
// The slot number of the top-level parent bridge is needed for
|
|
|
|
// Q35 cases with more than 24 slots on the root bus.
|
|
|
|
//
|
|
|
|
if (Status != EFI_SUCCESS) {
|
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
RootSlot = ((PCI_DEVICE_PATH *)DevPathNode)->Device;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DevPathNode = NextDevicePathNode (DevPathNode);
|
|
|
|
}
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
if (RootSlot == 0) {
|
|
|
|
DEBUG((
|
|
|
|
EFI_D_ERROR,
|
|
|
|
"%a: PCI host bridge (00:00.0) should have no interrupts!\n",
|
|
|
|
__FUNCTION__
|
|
|
|
));
|
|
|
|
ASSERT (FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Final PciHostIrqs[] index calculation depends on the platform
|
|
|
|
// and should match SeaBIOS src/fw/pciinit.c *_pci_slot_get_irq()
|
|
|
|
//
|
|
|
|
switch (mHostBridgeDevId) {
|
|
|
|
case INTEL_82441_DEVICE_ID:
|
|
|
|
Idx -= 1;
|
|
|
|
break;
|
|
|
|
case INTEL_Q35_MCH_DEVICE_ID:
|
|
|
|
//
|
|
|
|
// SeaBIOS contains the following comment:
|
|
|
|
// "Slots 0-24 rotate slot:pin mapping similar to piix above, but
|
|
|
|
// with a different starting index - see q35-acpi-dsdt.dsl.
|
|
|
|
//
|
|
|
|
// Slots 25-31 all use LNKA mapping (or LNKE, but A:D = E:H)"
|
|
|
|
//
|
|
|
|
if (RootSlot > 24) {
|
|
|
|
//
|
|
|
|
// in this case, subtract back out RootSlot from Idx
|
|
|
|
// (SeaBIOS never adds it to begin with, but that would make our
|
|
|
|
// device path traversal loop above too awkward)
|
|
|
|
//
|
|
|
|
Idx -= RootSlot;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ASSERT (FALSE); // should never get here
|
|
|
|
}
|
|
|
|
Idx %= ARRAY_SIZE (PciHostIrqs);
|
|
|
|
IrqLine = PciHostIrqs[Idx];
|
|
|
|
|
|
|
|
//
|
|
|
|
// Set PCI Interrupt Line register for this device to PciHostIrqs[Idx]
|
|
|
|
//
|
|
|
|
Status = PciIo->Pci.Write (
|
|
|
|
PciIo,
|
|
|
|
EfiPciIoWidthUint8,
|
|
|
|
PCI_INT_LINE_OFFSET,
|
|
|
|
1,
|
|
|
|
&IrqLine
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-27 23:10:18 +02:00
|
|
|
VOID
|
2014-11-14 01:39:04 +01:00
|
|
|
PciAcpiInitialization (
|
2009-05-27 23:10:18 +02:00
|
|
|
)
|
|
|
|
{
|
2014-11-14 01:39:04 +01:00
|
|
|
UINTN Pmba;
|
2009-05-27 23:10:18 +02:00
|
|
|
|
|
|
|
//
|
2014-11-14 01:39:04 +01:00
|
|
|
// Query Host Bridge DID to determine platform type
|
2009-05-27 23:10:18 +02:00
|
|
|
//
|
2014-11-17 20:09:12 +01:00
|
|
|
mHostBridgeDevId = PcdGet16 (PcdOvmfHostBridgePciDevId);
|
|
|
|
switch (mHostBridgeDevId) {
|
2014-11-14 01:39:04 +01:00
|
|
|
case INTEL_82441_DEVICE_ID:
|
2015-05-13 11:31:49 +02:00
|
|
|
Pmba = POWER_MGMT_REGISTER_PIIX4 (PIIX4_PMBA);
|
2014-11-14 01:39:04 +01:00
|
|
|
//
|
|
|
|
// 00:01.0 ISA Bridge (PIIX4) LNK routing targets
|
|
|
|
//
|
|
|
|
PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x60), 0x0b); // A
|
|
|
|
PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x61), 0x0b); // B
|
|
|
|
PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x62), 0x0a); // C
|
|
|
|
PciWrite8 (PCI_LIB_ADDRESS (0, 1, 0, 0x63), 0x0a); // D
|
|
|
|
break;
|
|
|
|
case INTEL_Q35_MCH_DEVICE_ID:
|
2015-05-13 11:31:44 +02:00
|
|
|
Pmba = POWER_MGMT_REGISTER_Q35 (ICH9_PMBASE);
|
2014-11-14 01:39:04 +01:00
|
|
|
//
|
|
|
|
// 00:1f.0 LPC Bridge (Q35) LNK routing targets
|
|
|
|
//
|
|
|
|
PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x60), 0x0a); // A
|
|
|
|
PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x61), 0x0a); // B
|
|
|
|
PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x62), 0x0b); // C
|
|
|
|
PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x63), 0x0b); // D
|
|
|
|
PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x68), 0x0a); // E
|
|
|
|
PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x69), 0x0a); // F
|
|
|
|
PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x6a), 0x0b); // G
|
|
|
|
PciWrite8 (PCI_LIB_ADDRESS (0, 0x1f, 0, 0x6b), 0x0b); // H
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
DEBUG ((EFI_D_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",
|
2014-11-17 20:09:12 +01:00
|
|
|
__FUNCTION__, mHostBridgeDevId));
|
2014-11-14 01:39:04 +01:00
|
|
|
ASSERT (FALSE);
|
|
|
|
return;
|
|
|
|
}
|
2009-05-27 23:10:18 +02:00
|
|
|
|
2012-05-04 17:01:56 +02:00
|
|
|
//
|
2014-11-17 20:09:12 +01:00
|
|
|
// Initialize PCI_INTERRUPT_LINE for applicable present PCI devices
|
2012-05-04 17:01:56 +02:00
|
|
|
//
|
2014-11-17 20:09:12 +01:00
|
|
|
VisitAllPciInstances (SetPciIntLine);
|
2014-11-14 01:39:04 +01:00
|
|
|
|
|
|
|
//
|
2014-11-17 20:09:12 +01:00
|
|
|
// Set ACPI SCI_EN bit in PMCNTRL
|
2014-11-14 01:39:04 +01:00
|
|
|
//
|
2014-11-17 20:09:12 +01:00
|
|
|
IoOr16 ((PciRead32 (Pmba) & ~BIT0) + 4, BIT0);
|
2012-05-04 17:01:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-16 18:29:03 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ConnectRecursivelyIfPciMassStorage (
|
|
|
|
IN EFI_HANDLE Handle,
|
|
|
|
IN EFI_PCI_IO_PROTOCOL *Instance,
|
|
|
|
IN PCI_TYPE00 *PciHeader
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
|
|
|
CHAR16 *DevPathStr;
|
|
|
|
|
|
|
|
if (IS_CLASS1 (PciHeader, PCI_CLASS_MASS_STORAGE)) {
|
|
|
|
DevicePath = NULL;
|
|
|
|
Status = gBS->HandleProtocol (
|
|
|
|
Handle,
|
|
|
|
&gEfiDevicePathProtocolGuid,
|
|
|
|
(VOID*)&DevicePath
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Print Device Path
|
|
|
|
//
|
|
|
|
DevPathStr = DevicePathToStr (DevicePath);
|
2013-07-26 05:14:08 +02:00
|
|
|
if (DevPathStr != NULL) {
|
|
|
|
DEBUG((
|
|
|
|
EFI_D_INFO,
|
|
|
|
"Found Mass Storage device: %s\n",
|
|
|
|
DevPathStr
|
|
|
|
));
|
|
|
|
FreePool(DevPathStr);
|
|
|
|
}
|
2009-09-16 18:29:03 +02:00
|
|
|
|
|
|
|
Status = gBS->ConnectController (Handle, NULL, NULL, TRUE);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-26 09:15:55 +02:00
|
|
|
/**
|
|
|
|
This notification function is invoked when the
|
|
|
|
EMU Variable FVB has been changed.
|
|
|
|
|
|
|
|
@param Event The event that occured
|
|
|
|
@param Context For EFI compatiblity. Not used.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
EmuVariablesUpdatedCallback (
|
|
|
|
IN EFI_EVENT Event,
|
|
|
|
IN VOID *Context
|
|
|
|
)
|
|
|
|
{
|
|
|
|
DEBUG ((EFI_D_INFO, "EmuVariablesUpdatedCallback\n"));
|
|
|
|
UpdateNvVarsOnFileSystem ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-16 18:29:03 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
VisitingFileSystemInstance (
|
|
|
|
IN EFI_HANDLE Handle,
|
|
|
|
IN VOID *Instance,
|
|
|
|
IN VOID *Context
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
STATIC BOOLEAN ConnectedToFileSystem = FALSE;
|
|
|
|
|
|
|
|
if (ConnectedToFileSystem) {
|
|
|
|
return EFI_ALREADY_STARTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = ConnectNvVarsToFileSystem (Handle);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
ConnectedToFileSystem = TRUE;
|
2009-09-26 09:15:55 +02:00
|
|
|
mEmuVariableEvent =
|
|
|
|
EfiCreateProtocolNotifyEvent (
|
|
|
|
&gEfiDevicePathProtocolGuid,
|
|
|
|
TPL_CALLBACK,
|
|
|
|
EmuVariablesUpdatedCallback,
|
|
|
|
NULL,
|
|
|
|
&mEmuVariableEventReg
|
|
|
|
);
|
|
|
|
PcdSet64 (PcdEmuVariableEvent, (UINT64)(UINTN) mEmuVariableEvent);
|
|
|
|
|
2009-09-16 18:29:03 +02:00
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VOID
|
|
|
|
PlatformBdsRestoreNvVarsFromHardDisk (
|
|
|
|
)
|
|
|
|
{
|
|
|
|
VisitAllPciInstances (ConnectRecursivelyIfPciMassStorage);
|
|
|
|
VisitAllInstancesOfProtocol (
|
|
|
|
&gEfiSimpleFileSystemProtocolGuid,
|
|
|
|
VisitingFileSystemInstance,
|
|
|
|
NULL
|
|
|
|
);
|
2010-10-13 09:07:16 +02:00
|
|
|
|
2009-09-16 18:29:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-27 23:10:18 +02:00
|
|
|
VOID
|
|
|
|
PlatformBdsConnectSequence (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
/*++
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
|
|
|
|
Connect with predeined platform connect sequence,
|
|
|
|
the OEM/IBV can customize with their own connect sequence.
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
None.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
None.
|
|
|
|
|
|
|
|
--*/
|
|
|
|
{
|
|
|
|
UINTN Index;
|
|
|
|
|
|
|
|
DEBUG ((EFI_D_INFO, "PlatformBdsConnectSequence\n"));
|
|
|
|
|
|
|
|
Index = 0;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Here we can get the customized platform connect sequence
|
|
|
|
// Notes: we can connect with new variable which record the
|
|
|
|
// last time boots connect device path sequence
|
|
|
|
//
|
|
|
|
while (gPlatformConnectSequence[Index] != NULL) {
|
|
|
|
//
|
|
|
|
// Build the platform boot option
|
|
|
|
//
|
|
|
|
BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);
|
|
|
|
Index++;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Just use the simple policy to connect all devices
|
|
|
|
//
|
|
|
|
BdsLibConnectAll ();
|
|
|
|
|
2014-11-14 01:39:04 +01:00
|
|
|
PciAcpiInitialization ();
|
2009-06-30 17:57:35 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Clear the logo after all devices are connected.
|
|
|
|
//
|
|
|
|
gST->ConOut->ClearScreen (gST->ConOut);
|
2009-05-27 23:10:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
PlatformBdsGetDriverOption (
|
|
|
|
IN OUT LIST_ENTRY *BdsDriverLists
|
|
|
|
)
|
|
|
|
/*++
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
|
|
|
|
Load the predefined driver option, OEM/IBV can customize this
|
|
|
|
to load their own drivers
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
BdsDriverLists - The header of the driver option link list.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
None.
|
|
|
|
|
|
|
|
--*/
|
|
|
|
{
|
|
|
|
DEBUG ((EFI_D_INFO, "PlatformBdsGetDriverOption\n"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
PlatformBdsDiagnostics (
|
|
|
|
IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,
|
2009-07-13 14:07:26 +02:00
|
|
|
IN BOOLEAN QuietBoot,
|
|
|
|
IN BASEM_MEMORY_TEST BaseMemoryTest
|
2009-05-27 23:10:18 +02:00
|
|
|
)
|
|
|
|
/*++
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
|
|
|
|
Perform the platform diagnostic, such like test memory. OEM/IBV also
|
|
|
|
can customize this fuction to support specific platform diagnostic.
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
MemoryTestLevel - The memory test intensive level
|
|
|
|
|
|
|
|
QuietBoot - Indicate if need to enable the quiet boot
|
|
|
|
|
2009-07-13 14:07:26 +02:00
|
|
|
BaseMemoryTest - A pointer to BaseMemoryTest()
|
|
|
|
|
2009-05-27 23:10:18 +02:00
|
|
|
Returns:
|
|
|
|
|
|
|
|
None.
|
|
|
|
|
|
|
|
--*/
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
|
|
|
|
DEBUG ((EFI_D_INFO, "PlatformBdsDiagnostics\n"));
|
|
|
|
|
|
|
|
//
|
|
|
|
// Here we can decide if we need to show
|
|
|
|
// the diagnostics screen
|
|
|
|
// Notes: this quiet boot code should be remove
|
|
|
|
// from the graphic lib
|
|
|
|
//
|
|
|
|
if (QuietBoot) {
|
2009-07-09 07:48:35 +02:00
|
|
|
EnableQuietBoot (PcdGetPtr(PcdLogoFile));
|
2009-05-27 23:10:18 +02:00
|
|
|
//
|
|
|
|
// Perform system diagnostic
|
|
|
|
//
|
2009-07-13 14:07:26 +02:00
|
|
|
Status = BaseMemoryTest (MemoryTestLevel);
|
2009-05-27 23:10:18 +02:00
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
DisableQuietBoot ();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Perform system diagnostic
|
|
|
|
//
|
2009-07-13 14:07:26 +02:00
|
|
|
Status = BaseMemoryTest (MemoryTestLevel);
|
2009-05-27 23:10:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
PlatformBdsPolicyBehavior (
|
|
|
|
IN OUT LIST_ENTRY *DriverOptionList,
|
2009-07-13 14:07:26 +02:00
|
|
|
IN OUT LIST_ENTRY *BootOptionList,
|
|
|
|
IN PROCESS_CAPSULES ProcessCapsules,
|
|
|
|
IN BASEM_MEMORY_TEST BaseMemoryTest
|
2009-05-27 23:10:18 +02:00
|
|
|
)
|
|
|
|
/*++
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
|
|
|
|
The function will excute with as the platform policy, current policy
|
|
|
|
is driven by boot mode. IBV/OEM can customize this code for their specific
|
|
|
|
policy action.
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
DriverOptionList - The header of the driver option link list
|
|
|
|
|
|
|
|
BootOptionList - The header of the boot option link list
|
|
|
|
|
2009-07-13 14:07:26 +02:00
|
|
|
ProcessCapsules - A pointer to ProcessCapsules()
|
|
|
|
|
|
|
|
BaseMemoryTest - A pointer to BaseMemoryTest()
|
|
|
|
|
2009-05-27 23:10:18 +02:00
|
|
|
Returns:
|
|
|
|
|
|
|
|
None.
|
|
|
|
|
|
|
|
--*/
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
2009-06-07 06:44:53 +02:00
|
|
|
EFI_BOOT_MODE BootMode;
|
2009-05-27 23:10:18 +02:00
|
|
|
|
|
|
|
DEBUG ((EFI_D_INFO, "PlatformBdsPolicyBehavior\n"));
|
|
|
|
|
2009-09-16 18:29:03 +02:00
|
|
|
ConnectRootBridge ();
|
|
|
|
|
2013-11-12 19:35:32 +01:00
|
|
|
if (PcdGetBool (PcdOvmfFlashVariablesEnable)) {
|
|
|
|
DEBUG ((EFI_D_INFO, "PlatformBdsPolicyBehavior: not restoring NvVars "
|
|
|
|
"from disk since flash variables appear to be supported.\n"));
|
|
|
|
} else {
|
|
|
|
//
|
|
|
|
// Try to restore variables from the hard disk early so
|
|
|
|
// they can be used for the other BDS connect operations.
|
|
|
|
//
|
|
|
|
PlatformBdsRestoreNvVarsFromHardDisk ();
|
|
|
|
}
|
2009-09-16 18:29:03 +02:00
|
|
|
|
2009-05-27 23:10:18 +02:00
|
|
|
//
|
|
|
|
// Load the driver option as the driver option list
|
|
|
|
//
|
|
|
|
PlatformBdsGetDriverOption (DriverOptionList);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get current Boot Mode
|
|
|
|
//
|
2009-06-07 06:44:53 +02:00
|
|
|
Status = BdsLibGetBootMode (&BootMode);
|
|
|
|
DEBUG ((EFI_D_ERROR, "Boot Mode:%x\n", BootMode));
|
2009-05-27 23:10:18 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Go the different platform policy with different boot mode
|
|
|
|
// Notes: this part code can be change with the table policy
|
|
|
|
//
|
2009-06-07 06:44:53 +02:00
|
|
|
ASSERT (BootMode == BOOT_WITH_FULL_CONFIGURATION);
|
2009-05-27 23:10:18 +02:00
|
|
|
//
|
|
|
|
// Connect platform console
|
|
|
|
//
|
|
|
|
Status = PlatformBdsConnectConsole (gPlatformConsole);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
//
|
|
|
|
// Here OEM/IBV can customize with defined action
|
|
|
|
//
|
|
|
|
PlatformBdsNoConsoleAction ();
|
|
|
|
}
|
2014-11-06 15:21:15 +01:00
|
|
|
|
2009-05-27 23:10:18 +02:00
|
|
|
//
|
|
|
|
// Memory test and Logo show
|
|
|
|
//
|
2009-07-13 14:07:26 +02:00
|
|
|
PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest);
|
2009-05-27 23:10:18 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Perform some platform specific connect sequence
|
|
|
|
//
|
|
|
|
PlatformBdsConnectSequence ();
|
|
|
|
|
2012-11-02 19:28:17 +01:00
|
|
|
//
|
|
|
|
// Process QEMU's -kernel command line option
|
|
|
|
//
|
|
|
|
TryRunningQemuKernel ();
|
|
|
|
|
2009-05-27 23:10:18 +02:00
|
|
|
DEBUG ((EFI_D_INFO, "BdsLibConnectAll\n"));
|
|
|
|
BdsLibConnectAll ();
|
|
|
|
BdsLibEnumerateAllBootOption (BootOptionList);
|
|
|
|
|
2012-08-28 01:28:30 +02:00
|
|
|
SetBootOrderFromQemu (BootOptionList);
|
2009-05-27 23:10:18 +02:00
|
|
|
//
|
OvmfPkg: BDS: remove historic (now defunct) boot mode hack
When PI can distinguish the "full config" boot mode from "assume no
changes", then the following BDS logic is correct:
if BootMode == BOOT_WITH_FULL_CONFIGURATION:
//
// connect all devices
// create & append each default boot option that's missing
//
BdsLibConnectAll
BdsLibEnumerateAllBootOption
else if BootMode == BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:
//
// just stick with current BootOrder and the Boot#### variables
// referenced by it
//
In theory, the first branch is intended to run infrequently, and the
"assume no changes" branch should run most of the time.
However, some platforms can't tell these two boot modes apart. The
following substitute had been introduced:
//
// Technically, always assume "full config", but the BootMode HOB is
// actually meaningless wrt. to "full config" or "assume no changes".
//
ASSERT (BootMode == BOOT_WITH_FULL_CONFIGURATION);
//
// Key off the existence of BootOrder. Try to prepare an in-memory list
// of boot options, based on BootOrder and the referenced Boot####
// variables.
//
Status = BdsLibBuildOptionFromVar()
//
// If that succeeded, we'll treat it as "assume no changes". If it
// failed (*only* if it failed), we'll build default boot options,
// calling it "full config":
//
if EFI_ERROR(Status):
BdsLibConnectAll()
BdsLibEnumerateAllBootOption(BootOptionList)
What we have now in OVMF is a mixture of the hack, and the behavior that's
theoretically correct for "full config":
- We assert "full config" -- this is OK.
- We call "connect all" and "enumerate all" deliberately -- this is OK
too. It matches "full config" which we assert.
- However, we also have the hack in place, which had been meant as an
alternative.
In order to clean this up, we either need to restore the hack to its
original form (ie. comment out the unconditional calls again), or we ought
to remove the hack altogether.
The unconditional "connect all" + "enumerate all" calls are the correct
approach for OVMF, because we want, in fact, to start with "full config".
The QEMU boot order specification and the set of emulated devices might
change "out of band", which excludes "assume no changes".
In other words, removing the hack corresponds to the "real production"
case that the comment hints at.
Because SetBootOrderFromQemu() may change the BootOrder NvVar, we must
preserve the BdsLibBuildOptionFromVar() function call, in order to
refresh the in-memory list with the new boot priorities.
(The last step of BdsLibEnumerateAllBootOption() is such a call too.)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15326 6f19259b-4bc3-4df7-8a09-765794883524
2014-03-13 18:34:55 +01:00
|
|
|
// The BootOrder variable may have changed, reload the in-memory list with
|
|
|
|
// it.
|
2009-05-27 23:10:18 +02:00
|
|
|
//
|
OvmfPkg: BDS: remove historic (now defunct) boot mode hack
When PI can distinguish the "full config" boot mode from "assume no
changes", then the following BDS logic is correct:
if BootMode == BOOT_WITH_FULL_CONFIGURATION:
//
// connect all devices
// create & append each default boot option that's missing
//
BdsLibConnectAll
BdsLibEnumerateAllBootOption
else if BootMode == BOOT_ASSUMING_NO_CONFIGURATION_CHANGES:
//
// just stick with current BootOrder and the Boot#### variables
// referenced by it
//
In theory, the first branch is intended to run infrequently, and the
"assume no changes" branch should run most of the time.
However, some platforms can't tell these two boot modes apart. The
following substitute had been introduced:
//
// Technically, always assume "full config", but the BootMode HOB is
// actually meaningless wrt. to "full config" or "assume no changes".
//
ASSERT (BootMode == BOOT_WITH_FULL_CONFIGURATION);
//
// Key off the existence of BootOrder. Try to prepare an in-memory list
// of boot options, based on BootOrder and the referenced Boot####
// variables.
//
Status = BdsLibBuildOptionFromVar()
//
// If that succeeded, we'll treat it as "assume no changes". If it
// failed (*only* if it failed), we'll build default boot options,
// calling it "full config":
//
if EFI_ERROR(Status):
BdsLibConnectAll()
BdsLibEnumerateAllBootOption(BootOptionList)
What we have now in OVMF is a mixture of the hack, and the behavior that's
theoretically correct for "full config":
- We assert "full config" -- this is OK.
- We call "connect all" and "enumerate all" deliberately -- this is OK
too. It matches "full config" which we assert.
- However, we also have the hack in place, which had been meant as an
alternative.
In order to clean this up, we either need to restore the hack to its
original form (ie. comment out the unconditional calls again), or we ought
to remove the hack altogether.
The unconditional "connect all" + "enumerate all" calls are the correct
approach for OVMF, because we want, in fact, to start with "full config".
The QEMU boot order specification and the set of emulated devices might
change "out of band", which excludes "assume no changes".
In other words, removing the hack corresponds to the "real production"
case that the comment hints at.
Because SetBootOrderFromQemu() may change the BootOrder NvVar, we must
preserve the BdsLibBuildOptionFromVar() function call, in order to
refresh the in-memory list with the new boot priorities.
(The last step of BdsLibEnumerateAllBootOption() is such a call too.)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15326 6f19259b-4bc3-4df7-8a09-765794883524
2014-03-13 18:34:55 +01:00
|
|
|
BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");
|
2009-05-27 23:10:18 +02:00
|
|
|
|
2015-01-14 17:25:59 +01:00
|
|
|
PlatformBdsEnterFrontPage (GetFrontPageTimeoutFromQemu(), TRUE);
|
2009-05-27 23:10:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
PlatformBdsBootSuccess (
|
|
|
|
IN BDS_COMMON_OPTION *Option
|
|
|
|
)
|
|
|
|
/*++
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
|
|
|
|
Hook point after a boot attempt succeeds. We don't expect a boot option to
|
|
|
|
return, so the EFI 1.0 specification defines that you will default to an
|
|
|
|
interactive mode and stop processing the BootOrder list in this case. This
|
|
|
|
is alos a platform implementation and can be customized by IBV/OEM.
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
Option - Pointer to Boot Option that succeeded to boot.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
None.
|
|
|
|
|
|
|
|
--*/
|
|
|
|
{
|
|
|
|
CHAR16 *TmpStr;
|
|
|
|
|
|
|
|
DEBUG ((EFI_D_INFO, "PlatformBdsBootSuccess\n"));
|
|
|
|
//
|
|
|
|
// If Boot returned with EFI_SUCCESS and there is not in the boot device
|
|
|
|
// select loop then we need to pop up a UI and wait for user input.
|
|
|
|
//
|
|
|
|
TmpStr = Option->StatusString;
|
|
|
|
if (TmpStr != NULL) {
|
|
|
|
BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);
|
|
|
|
FreePool (TmpStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
PlatformBdsBootFail (
|
|
|
|
IN BDS_COMMON_OPTION *Option,
|
|
|
|
IN EFI_STATUS Status,
|
|
|
|
IN CHAR16 *ExitData,
|
|
|
|
IN UINTN ExitDataSize
|
|
|
|
)
|
|
|
|
/*++
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
|
|
|
|
Hook point after a boot attempt fails.
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
Option - Pointer to Boot Option that failed to boot.
|
|
|
|
|
|
|
|
Status - Status returned from failed boot.
|
|
|
|
|
|
|
|
ExitData - Exit data returned from failed boot.
|
|
|
|
|
|
|
|
ExitDataSize - Exit data size returned from failed boot.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
None.
|
|
|
|
|
|
|
|
--*/
|
|
|
|
{
|
|
|
|
CHAR16 *TmpStr;
|
|
|
|
|
|
|
|
DEBUG ((EFI_D_INFO, "PlatformBdsBootFail\n"));
|
|
|
|
|
|
|
|
//
|
|
|
|
// If Boot returned with failed status then we need to pop up a UI and wait
|
|
|
|
// for user input.
|
|
|
|
//
|
|
|
|
TmpStr = Option->StatusString;
|
|
|
|
if (TmpStr != NULL) {
|
|
|
|
BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);
|
|
|
|
FreePool (TmpStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
PlatformBdsNoConsoleAction (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
/*++
|
|
|
|
|
|
|
|
Routine Description:
|
|
|
|
|
|
|
|
This function is remained for IBV/OEM to do some platform action,
|
|
|
|
if there no console device can be connected.
|
|
|
|
|
|
|
|
Arguments:
|
|
|
|
|
|
|
|
None.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
EFI_SUCCESS - Direct return success now.
|
|
|
|
|
|
|
|
--*/
|
|
|
|
{
|
|
|
|
DEBUG ((EFI_D_INFO, "PlatformBdsNoConsoleAction\n"));
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2009-07-10 05:26:52 +02:00
|
|
|
VOID
|
2009-05-27 23:10:18 +02:00
|
|
|
EFIAPI
|
|
|
|
PlatformBdsLockNonUpdatableFlash (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
DEBUG ((EFI_D_INFO, "PlatformBdsLockNonUpdatableFlash\n"));
|
2009-07-10 05:26:52 +02:00
|
|
|
return;
|
2009-05-27 23:10:18 +02:00
|
|
|
}
|
2009-06-30 17:57:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
This notification function is invoked when an instance of the
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL is produced.
|
|
|
|
|
|
|
|
@param Event The event that occured
|
|
|
|
@param Context For EFI compatiblity. Not used.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
NotifyDevPath (
|
|
|
|
IN EFI_EVENT Event,
|
|
|
|
IN VOID *Context
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_HANDLE Handle;
|
|
|
|
EFI_STATUS Status;
|
|
|
|
UINTN BufferSize;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *DevPathNode;
|
|
|
|
ATAPI_DEVICE_PATH *Atapi;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Examine all new handles
|
|
|
|
//
|
|
|
|
for (;;) {
|
|
|
|
//
|
|
|
|
// Get the next handle
|
|
|
|
//
|
|
|
|
BufferSize = sizeof (Handle);
|
|
|
|
Status = gBS->LocateHandle (
|
|
|
|
ByRegisterNotify,
|
|
|
|
NULL,
|
|
|
|
mEfiDevPathNotifyReg,
|
|
|
|
&BufferSize,
|
|
|
|
&Handle
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// If not found, we're done
|
|
|
|
//
|
|
|
|
if (EFI_NOT_FOUND == Status) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get the DevicePath protocol on that handle
|
|
|
|
//
|
|
|
|
Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **)&DevPathNode);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
while (!IsDevicePathEnd (DevPathNode)) {
|
|
|
|
//
|
|
|
|
// Find the handler to dump this device path node
|
|
|
|
//
|
|
|
|
if (
|
|
|
|
(DevicePathType(DevPathNode) == MESSAGING_DEVICE_PATH) &&
|
|
|
|
(DevicePathSubType(DevPathNode) == MSG_ATAPI_DP)
|
|
|
|
) {
|
|
|
|
Atapi = (ATAPI_DEVICE_PATH*) DevPathNode;
|
|
|
|
PciOr16 (
|
|
|
|
PCI_LIB_ADDRESS (
|
|
|
|
0,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
(Atapi->PrimarySecondary == 1) ? 0x42: 0x40
|
|
|
|
),
|
|
|
|
BIT15
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Next device path node
|
|
|
|
//
|
|
|
|
DevPathNode = NextDevicePathNode (DevPathNode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VOID
|
|
|
|
InstallDevicePathCallback (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
DEBUG ((EFI_D_INFO, "Registered NotifyDevPath Event\n"));
|
|
|
|
mEfiDevPathEvent = EfiCreateProtocolNotifyEvent (
|
|
|
|
&gEfiDevicePathProtocolGuid,
|
|
|
|
TPL_CALLBACK,
|
|
|
|
NotifyDevPath,
|
|
|
|
NULL,
|
|
|
|
&mEfiDevPathNotifyReg
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2009-07-10 05:26:52 +02:00
|
|
|
/**
|
|
|
|
Lock the ConsoleIn device in system table. All key
|
|
|
|
presses will be ignored until the Password is typed in. The only way to
|
|
|
|
disable the password is to type it in to a ConIn device.
|
|
|
|
|
|
|
|
@param Password Password used to lock ConIn device.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.
|
|
|
|
@retval EFI_UNSUPPORTED Password not found
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
LockKeyboards (
|
|
|
|
IN CHAR16 *Password
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
2009-07-15 01:32:32 +02:00
|
|
|
|