2011-06-28 01:32:56 +02:00
|
|
|
/** @file
|
|
|
|
Collect Sio information from Native EFI Drivers.
|
|
|
|
Sio is floppy, parallel, serial, ... hardware
|
|
|
|
|
2016-06-12 08:45:53 +02:00
|
|
|
Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
|
2011-06-28 01:32:56 +02:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include "LegacyBiosInterface.h"
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2016-06-12 08:45:53 +02:00
|
|
|
Collect EFI Info about legacy devices through ISA IO interface.
|
2011-06-28 01:32:56 +02:00
|
|
|
|
2016-06-12 08:45:53 +02:00
|
|
|
@param SioPtr Pointer to SIO data.
|
2011-06-28 01:32:56 +02:00
|
|
|
|
2016-06-12 08:54:02 +02:00
|
|
|
@retval EFI_SUCCESS When SIO data is got successfully.
|
|
|
|
@retval EFI_NOT_FOUND When ISA IO interface is absent.
|
2011-06-28 01:32:56 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
2016-06-12 08:45:53 +02:00
|
|
|
LegacyBiosBuildSioDataFromIsaIo (
|
|
|
|
IN DEVICE_PRODUCER_DATA_HEADER *SioPtr
|
2011-06-28 01:32:56 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
2016-06-12 08:58:00 +02:00
|
|
|
DEVICE_PRODUCER_SERIAL *SioSerial;
|
|
|
|
DEVICE_PRODUCER_PARALLEL *SioParallel;
|
|
|
|
DEVICE_PRODUCER_FLOPPY *SioFloppy;
|
2011-06-28 01:32:56 +02:00
|
|
|
UINTN HandleCount;
|
|
|
|
EFI_HANDLE *HandleBuffer;
|
|
|
|
UINTN Index;
|
|
|
|
UINTN ResourceIndex;
|
|
|
|
UINTN ChildIndex;
|
|
|
|
EFI_ISA_IO_PROTOCOL *IsaIo;
|
|
|
|
EFI_ISA_ACPI_RESOURCE_LIST *ResourceList;
|
|
|
|
EFI_ISA_ACPI_RESOURCE *IoResource;
|
|
|
|
EFI_ISA_ACPI_RESOURCE *DmaResource;
|
|
|
|
EFI_ISA_ACPI_RESOURCE *InterruptResource;
|
|
|
|
UINTN EntryCount;
|
|
|
|
EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;
|
|
|
|
EFI_BLOCK_IO_PROTOCOL *BlockIo;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get the list of ISA controllers in the system
|
|
|
|
//
|
|
|
|
Status = gBS->LocateHandleBuffer (
|
|
|
|
ByProtocol,
|
|
|
|
&gEfiIsaIoProtocolGuid,
|
|
|
|
NULL,
|
|
|
|
&HandleCount,
|
|
|
|
&HandleBuffer
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
2016-06-12 08:54:02 +02:00
|
|
|
return EFI_NOT_FOUND;
|
2011-06-28 01:32:56 +02:00
|
|
|
}
|
|
|
|
//
|
|
|
|
// Collect legacy information from each of the ISA controllers in the system
|
|
|
|
//
|
|
|
|
for (Index = 0; Index < HandleCount; Index++) {
|
|
|
|
|
|
|
|
Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiIsaIoProtocolGuid, (VOID **) &IsaIo);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ResourceList = IsaIo->ResourceList;
|
|
|
|
|
|
|
|
if (ResourceList == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Collect the resource types neededto fill in the SIO data structure
|
|
|
|
//
|
|
|
|
IoResource = NULL;
|
|
|
|
DmaResource = NULL;
|
|
|
|
InterruptResource = NULL;
|
|
|
|
for (ResourceIndex = 0;
|
|
|
|
ResourceList->ResourceItem[ResourceIndex].Type != EfiIsaAcpiResourceEndOfList;
|
|
|
|
ResourceIndex++
|
|
|
|
) {
|
|
|
|
switch (ResourceList->ResourceItem[ResourceIndex].Type) {
|
|
|
|
case EfiIsaAcpiResourceIo:
|
|
|
|
IoResource = &ResourceList->ResourceItem[ResourceIndex];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EfiIsaAcpiResourceMemory:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EfiIsaAcpiResourceDma:
|
|
|
|
DmaResource = &ResourceList->ResourceItem[ResourceIndex];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EfiIsaAcpiResourceInterrupt:
|
|
|
|
InterruptResource = &ResourceList->ResourceItem[ResourceIndex];
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// See if this is an ISA serial port
|
|
|
|
//
|
|
|
|
// Ignore DMA resource since it is always returned NULL
|
|
|
|
//
|
|
|
|
if (ResourceList->Device.HID == EISA_PNP_ID (0x500) || ResourceList->Device.HID == EISA_PNP_ID (0x501)) {
|
|
|
|
|
|
|
|
if (ResourceList->Device.UID <= 3 &&
|
|
|
|
IoResource != NULL &&
|
|
|
|
InterruptResource != NULL
|
|
|
|
) {
|
|
|
|
//
|
|
|
|
// Get the handle of the child device that has opened the ISA I/O Protocol
|
|
|
|
//
|
|
|
|
Status = gBS->OpenProtocolInformation (
|
|
|
|
HandleBuffer[Index],
|
|
|
|
&gEfiIsaIoProtocolGuid,
|
|
|
|
&OpenInfoBuffer,
|
|
|
|
&EntryCount
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// We want resource for legacy even if no 32-bit driver installed
|
|
|
|
//
|
|
|
|
for (ChildIndex = 0; ChildIndex < EntryCount; ChildIndex++) {
|
2016-06-12 08:58:00 +02:00
|
|
|
SioSerial = &SioPtr->Serial[ResourceList->Device.UID];
|
|
|
|
SioSerial->Address = (UINT16) IoResource->StartRange;
|
|
|
|
SioSerial->Irq = (UINT8) InterruptResource->StartRange;
|
|
|
|
SioSerial->Mode = DEVICE_SERIAL_MODE_NORMAL | DEVICE_SERIAL_MODE_DUPLEX_HALF;
|
2011-06-28 01:32:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
FreePool (OpenInfoBuffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// See if this is an ISA parallel port
|
|
|
|
//
|
|
|
|
// Ignore DMA resource since it is always returned NULL, port
|
|
|
|
// only used in output mode.
|
|
|
|
//
|
|
|
|
if (ResourceList->Device.HID == EISA_PNP_ID (0x400) || ResourceList->Device.HID == EISA_PNP_ID (0x401)) {
|
|
|
|
if (ResourceList->Device.UID <= 2 &&
|
|
|
|
IoResource != NULL &&
|
|
|
|
InterruptResource != NULL &&
|
|
|
|
DmaResource != NULL
|
|
|
|
) {
|
2016-06-12 08:58:00 +02:00
|
|
|
SioParallel = &SioPtr->Parallel[ResourceList->Device.UID];
|
|
|
|
SioParallel->Address = (UINT16) IoResource->StartRange;
|
|
|
|
SioParallel->Irq = (UINT8) InterruptResource->StartRange;
|
|
|
|
SioParallel->Dma = (UINT8) DmaResource->StartRange;
|
|
|
|
SioParallel->Mode = DEVICE_PARALLEL_MODE_MODE_OUTPUT_ONLY;
|
2011-06-28 01:32:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// See if this is an ISA floppy controller
|
|
|
|
//
|
|
|
|
if (ResourceList->Device.HID == EISA_PNP_ID (0x604)) {
|
|
|
|
if (IoResource != NULL && InterruptResource != NULL && DmaResource != NULL) {
|
|
|
|
Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiBlockIoProtocolGuid, (VOID **) &BlockIo);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
2016-06-12 08:58:00 +02:00
|
|
|
SioFloppy = &SioPtr->Floppy;
|
|
|
|
SioFloppy->Address = (UINT16) IoResource->StartRange;
|
|
|
|
SioFloppy->Irq = (UINT8) InterruptResource->StartRange;
|
|
|
|
SioFloppy->Dma = (UINT8) DmaResource->StartRange;
|
|
|
|
SioFloppy->NumberOfFloppy++;
|
2011-06-28 01:32:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// See if this is a mouse
|
|
|
|
// Always set mouse found so USB hot plug will work
|
|
|
|
//
|
|
|
|
// Ignore lower byte of HID. Pnp0fxx is any type of mouse.
|
|
|
|
//
|
|
|
|
// Hid = ResourceList->Device.HID & 0xff00ffff;
|
|
|
|
// PnpId = EISA_PNP_ID(0x0f00);
|
|
|
|
// if (Hid == PnpId) {
|
|
|
|
// if (ResourceList->Device.UID == 1) {
|
|
|
|
// Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiSimplePointerProtocolGuid, &SimplePointer);
|
|
|
|
// if (!EFI_ERROR (Status)) {
|
|
|
|
//
|
|
|
|
SioPtr->MousePresent = 0x01;
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
FreePool (HandleBuffer);
|
2016-06-12 08:45:53 +02:00
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Collect EFI Info about legacy devices.
|
|
|
|
|
|
|
|
@param Private Legacy BIOS Instance data
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS It should always work.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
LegacyBiosBuildSioData (
|
|
|
|
IN LEGACY_BIOS_INSTANCE *Private
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
DEVICE_PRODUCER_DATA_HEADER *SioPtr;
|
|
|
|
EFI_HANDLE IsaBusController;
|
|
|
|
UINTN HandleCount;
|
|
|
|
EFI_HANDLE *HandleBuffer;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get the pointer to the SIO data structure
|
|
|
|
//
|
|
|
|
SioPtr = &Private->IntThunk->EfiToLegacy16BootTable.SioData;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Zero the data in the SIO data structure
|
|
|
|
//
|
|
|
|
gBS->SetMem (SioPtr, sizeof (DEVICE_PRODUCER_DATA_HEADER), 0);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Find the ISA Bus Controller used for legacy
|
|
|
|
//
|
|
|
|
Status = Private->LegacyBiosPlatform->GetPlatformHandle (
|
|
|
|
Private->LegacyBiosPlatform,
|
|
|
|
EfiGetPlatformIsaBusHandle,
|
|
|
|
0,
|
|
|
|
&HandleBuffer,
|
|
|
|
&HandleCount,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
IsaBusController = HandleBuffer[0];
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
//
|
|
|
|
// Force ISA Bus Controller to produce all ISA devices
|
|
|
|
//
|
|
|
|
gBS->ConnectController (IsaBusController, NULL, NULL, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
LegacyBiosBuildSioDataFromIsaIo (SioPtr);
|
2011-06-28 01:32:56 +02:00
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|