diff options
author | Guo Mang <mang.guo@intel.com> | 2017-04-27 11:03:56 +0800 |
---|---|---|
committer | Guo Mang <mang.guo@intel.com> | 2017-04-27 11:03:56 +0800 |
commit | 001e57a103fce87245bfb7ae9c32ffb499a64135 (patch) | |
tree | ab51b54ee5833b82a8e0be983f1e4a2a9f449f8a /IntelFrameworkModulePkg/Bus | |
parent | 1bd9f3b4f700a16b3ed645af759c66c336ca4965 (diff) | |
download | edk2-platforms-001e57a103fce87245bfb7ae9c32ffb499a64135.tar.xz |
IntelFrameworkModulePkg: Move to new location
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Guo Mang <mang.guo@intel.com>
Diffstat (limited to 'IntelFrameworkModulePkg/Bus')
83 files changed, 0 insertions, 37406 deletions
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/ComponentName.c b/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/ComponentName.c deleted file mode 100644 index 1663d7fcd5..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/ComponentName.c +++ /dev/null @@ -1,182 +0,0 @@ -/** @file
- UEFI Component Name(2) protocol implementation for IsaBus driver.
-
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
-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 "InternalIsaBus.h"
-
-//
-// EFI Component Name Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIsaBusComponentName = {
- IsaBusComponentNameGetDriverName,
- IsaBusComponentNameGetControllerName,
- "eng"
-};
-
-//
-// EFI Component Name 2 Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIsaBusComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IsaBusComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IsaBusComponentNameGetControllerName,
- "en"
-};
-
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIsaBusDriverNameTable[] = {
- {
- "eng;en",
- L"ISA Bus Driver"
- },
- {
- NULL,
- NULL
- }
-};
-
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
-
- @param DriverName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-IsaBusComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- )
-{
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mIsaBusDriverNameTable,
- DriverName,
- (BOOLEAN)(This == &gIsaBusComponentName)
- );
-}
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param ControllerHandle[in] The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
-
- @param ChildHandle[in] The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
-
- @param ControllerName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
-
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
-
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-IsaBusComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- )
-{
- return EFI_UNSUPPORTED;
-}
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/ComponentName.h b/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/ComponentName.h deleted file mode 100644 index ffacf44063..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/ComponentName.h +++ /dev/null @@ -1,148 +0,0 @@ -/** @file
- Header file for implementation of UEFI Component Name(2) protocol.
-
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
-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.
-
-**/
-
-#ifndef _COMPONENT_NAME_H_
-#define _COMPONENT_NAME_H_
-
-extern EFI_COMPONENT_NAME_PROTOCOL gIsaBusComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gIsaBusComponentName2;
-
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
-
- @param DriverName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-IsaBusComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- );
-
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param ControllerHandle[in] The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
-
- @param ChildHandle[in] The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
-
- @param ControllerName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
-
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
-
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-IsaBusComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- );
-
-#endif
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/InternalIsaBus.h b/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/InternalIsaBus.h deleted file mode 100644 index 9e559da72b..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/InternalIsaBus.h +++ /dev/null @@ -1,297 +0,0 @@ -/** @file
- The header file for ISA bus driver
-
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
-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.
-
-**/
-
-#ifndef _INTERNAL_ISA_BUS_H_
-#define _INTERNAL_ISA_BUS_H_
-
-
-#include <Uefi.h>
-
-#include <Protocol/PciIo.h>
-#include <Protocol/ComponentName.h>
-#include <Protocol/IsaIo.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/IsaAcpi.h>
-#include <Protocol/DriverBinding.h>
-#include <Protocol/GenericMemoryTest.h>
-#include <Guid/StatusCodeDataTypeId.h>
-
-#include <Library/DebugLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/UefiLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/ReportStatusCodeLib.h>
-#include <Library/PcdLib.h>
-
-#include "ComponentName.h"
-
-//
-// 8237 DMA registers
-//
-#define R_8237_DMA_BASE_CA_CH0 0x00
-#define R_8237_DMA_BASE_CA_CH1 0x02
-#define R_8237_DMA_BASE_CA_CH2 0x04
-#define R_8237_DMA_BASE_CA_CH3 0xd6
-#define R_8237_DMA_BASE_CA_CH5 0xc4
-#define R_8237_DMA_BASE_CA_CH6 0xc8
-#define R_8237_DMA_BASE_CA_CH7 0xcc
-
-#define R_8237_DMA_BASE_CC_CH0 0x01
-#define R_8237_DMA_BASE_CC_CH1 0x03
-#define R_8237_DMA_BASE_CC_CH2 0x05
-#define R_8237_DMA_BASE_CC_CH3 0xd7
-#define R_8237_DMA_BASE_CC_CH5 0xc6
-#define R_8237_DMA_BASE_CC_CH6 0xca
-#define R_8237_DMA_BASE_CC_CH7 0xce
-
-#define R_8237_DMA_MEM_LP_CH0 0x87
-#define R_8237_DMA_MEM_LP_CH1 0x83
-#define R_8237_DMA_MEM_LP_CH2 0x81
-#define R_8237_DMA_MEM_LP_CH3 0x82
-#define R_8237_DMA_MEM_LP_CH5 0x8B
-#define R_8237_DMA_MEM_LP_CH6 0x89
-#define R_8237_DMA_MEM_LP_CH7 0x8A
-
-
-#define R_8237_DMA_COMMAND_CH0_3 0x08
-#define R_8237_DMA_COMMAND_CH4_7 0xd0
-#define B_8237_DMA_COMMAND_GAP 0x10
-#define B_8237_DMA_COMMAND_CGE 0x04
-
-
-#define R_8237_DMA_STA_CH0_3 0xd8
-#define R_8237_DMA_STA_CH4_7 0xd0
-
-#define R_8237_DMA_WRSMSK_CH0_3 0x0a
-#define R_8237_DMA_WRSMSK_CH4_7 0xd4
-#define B_8237_DMA_WRSMSK_CMS 0x04
-
-
-#define R_8237_DMA_CHMODE_CH0_3 0x0b
-#define R_8237_DMA_CHMODE_CH4_7 0xd6
-#define V_8237_DMA_CHMODE_DEMAND 0x00
-#define V_8237_DMA_CHMODE_SINGLE 0x40
-#define V_8237_DMA_CHMODE_CASCADE 0xc0
-#define B_8237_DMA_CHMODE_DECREMENT 0x20
-#define B_8237_DMA_CHMODE_INCREMENT 0x00
-#define B_8237_DMA_CHMODE_AE 0x10
-#define V_8237_DMA_CHMODE_VERIFY 0
-#define V_8237_DMA_CHMODE_IO2MEM 0x04
-#define V_8237_DMA_CHMODE_MEM2IO 0x08
-
-#define R_8237_DMA_CBPR_CH0_3 0x0c
-#define R_8237_DMA_CBPR_CH4_7 0xd8
-
-#define R_8237_DMA_MCR_CH0_3 0x0d
-#define R_8237_DMA_MCR_CH4_7 0xda
-
-#define R_8237_DMA_CLMSK_CH0_3 0x0e
-#define R_8237_DMA_CLMSK_CH4_7 0xdc
-
-#define R_8237_DMA_WRMSK_CH0_3 0x0f
-#define R_8237_DMA_WRMSK_CH4_7 0xde
-
-typedef enum {
- IsaAccessTypeUnknown,
- IsaAccessTypeIo,
- IsaAccessTypeMem,
- IsaAccessTypeMaxType
-} ISA_ACCESS_TYPE;
-
-//
-// 16 MB Memory Range
-//
-#define ISA_MAX_MEMORY_ADDRESS 0x1000000
-//
-// 64K I/O Range
-//
-#define ISA_MAX_IO_ADDRESS 0x10000
-
-typedef struct {
- UINT8 Address;
- UINT8 Page;
- UINT8 Count;
-} EFI_ISA_DMA_REGISTERS;
-
-//
-// ISA I/O Device Structure
-//
-#define ISA_IO_DEVICE_SIGNATURE SIGNATURE_32 ('i', 's', 'a', 'i')
-
-typedef struct {
- UINT32 Signature;
- EFI_HANDLE Handle;
- EFI_ISA_IO_PROTOCOL IsaIo;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_PCI_IO_PROTOCOL *PciIo;
-} ISA_IO_DEVICE;
-
-#define ISA_IO_DEVICE_FROM_ISA_IO_THIS(a) CR (a, ISA_IO_DEVICE, IsaIo, ISA_IO_DEVICE_SIGNATURE)
-
-//
-// Mapping structure for performing ISA DMA to a buffer above 16 MB
-//
-typedef struct {
- EFI_ISA_IO_PROTOCOL_OPERATION Operation;
- UINTN NumberOfBytes;
- UINTN NumberOfPages;
- EFI_PHYSICAL_ADDRESS HostAddress;
- EFI_PHYSICAL_ADDRESS MappedHostAddress;
-} ISA_MAP_INFO;
-
-//
-// EFI Driver Binding Protocol Interface Functions
-//
-
-/**
- Tests to see if a controller can be managed by the ISA Bus Driver. If a child device is provided,
- it further tests to see if this driver supports creating a handle for the specified child device.
-
- Note that the ISA Bus driver always creates all of its child handles on the first call to Start().
- How the Start() function of a driver is implemented can affect how the Supported() function is implemented.
-
- @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param[in] Controller The handle of the controller to test.
- @param[in] RemainingDevicePath A pointer to the remaining portion of a device path.
-
- @retval EFI_SUCCESS The device is supported by this driver.
- @retval EFI_ALREADY_STARTED The device is already being managed by this driver.
- @retval EFI_ACCESS_DENIED The device is already being managed by a different driver
- or an application that requires exclusive access.
- @retval EFI_UNSUPPORTED The device is is not supported by this driver.
-
-**/
-EFI_STATUS
-EFIAPI
-IsaBusControllerDriverSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
- );
-
-/**
- Start this driver on ControllerHandle.
-
- Note that the ISA Bus driver always creates all of its child handles on the first call to Start().
- The Start() function is designed to be invoked from the EFI boot service ConnectController().
- As a result, much of the error checking on the parameters to Start() has been moved into this
- common boot service. It is legal to call Start() from other locations, but the following calling
- restrictions must be followed or the system behavior will not be deterministic.
- 1. ControllerHandle must be a valid EFI_HANDLE.
- 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
- EFI_DEVICE_PATH_PROTOCOL.
- 3. Prior to calling Start(), the Supported() function for the driver specified by This must
- have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
-
- @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param[in] ControllerHandle The handle of the controller to start. This handle
- must support a protocol interface that supplies
- an I/O abstraction to the driver.
- @param[in] RemainingDevicePath A pointer to the remaining portion of a device path.
- This parameter is ignored by device drivers, and is optional for bus drivers.
-
- @retval EFI_SUCCESS The device was started.
- @retval EFI_DEVICE_ERROR The device could not be started due to a device error.
- Currently not implemented.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
- @retval Others The driver failded to start the device.
-**/
-EFI_STATUS
-EFIAPI
-IsaBusControllerDriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
- );
-
-/**
- Stop this driver on ControllerHandle.
-
- The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
- As a result, much of the error checking on the parameters to Stop() has been moved
- into this common boot service. It is legal to call Stop() from other locations,
- but the following calling restrictions must be followed or the system behavior will not be deterministic.
- 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
- same driver's Start() function.
- 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
- EFI_HANDLE. In addition, all of these handles must have been created in this driver's
- Start() function, and the Start() function must have called OpenProtocol() on
- ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
-
- @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param[in] ControllerHandle A handle to the device being stopped. The handle must
- support a bus specific I/O protocol for the driver
- to use to stop the device.
- @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
- @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
- if NumberOfChildren is 0.
-
- @retval EFI_SUCCESS The device was stopped.
- @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
-**/
-EFI_STATUS
-EFIAPI
-IsaBusControllerDriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL * This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE * ChildHandleBuffer OPTIONAL
- );
-
-//
-// Function Prototypes
-//
-
-/**
- Create EFI Handle for a ISA device found via ISA ACPI Protocol
-
- @param[in] This The EFI_DRIVER_BINDING_PROTOCOL instance.
- @param[in] Controller The handle of ISA bus controller(PCI to ISA bridge)
- @param[in] PciIo The Pointer to the PCI protocol
- @param[in] ParentDevicePath Device path of the ISA bus controller
- @param[in] IsaDeviceResourceList The resource list of the ISA device
- @param[out] ChildDevicePath The pointer to the child device.
-
- @retval EFI_SUCCESS The handle for the child device was created.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
- @retval EFI_DEVICE_ERROR The handle for the child device can not be created.
-**/
-EFI_STATUS
-IsaCreateDevice (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,
- IN EFI_ISA_ACPI_RESOURCE_LIST *IsaDeviceResourceList,
- OUT EFI_DEVICE_PATH_PROTOCOL **ChildDevicePath
- );
-
-/**
- Initializes an ISA I/O Instance
-
- @param[in] IsaIoDevice The iso device to be initialized.
- @param[in] IsaDeviceResourceList The resource list.
-
-**/
-VOID
-InitializeIsaIoInstance (
- IN ISA_IO_DEVICE *IsaIoDevice,
- IN EFI_ISA_ACPI_RESOURCE_LIST *IsaDevice
- );
-
-#endif
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/InternalIsaIo.h b/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/InternalIsaIo.h deleted file mode 100644 index 054a6b9bab..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/InternalIsaIo.h +++ /dev/null @@ -1,331 +0,0 @@ -/** @file
- The header file for EFI_ISA_IO protocol implementation.
-
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
-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.
-
-**/
-
-#ifndef _INTERNAL_ISA_IO_H_
-#define _INTERNAL_ISA_IO_H_
-
-#include "InternalIsaBus.h"
-
-//
-// Bits definition of PcdIsaBusSupportedFeatures
-//
-#define PCD_ISA_BUS_SUPPORT_DMA BIT0
-#define PCD_ISA_BUS_ONLY_SUPPORT_SLAVE_DMA BIT1
-#define PCD_ISA_BUS_SUPPORT_ISA_MEMORY BIT2
-
-//
-// ISA I/O Support Function Prototypes
-//
-
-/**
- Verifies access to an ISA device
-
- @param[in] IsaIoDevice The ISA device to be verified.
- @param[in] Type The Access type. The input must be either IsaAccessTypeMem or IsaAccessTypeIo.
- @param[in] Width The width of the memory operation.
- @param[in] Count The number of memory operations to perform.
- @param[in] Offset The offset in ISA memory space to start the memory operation.
-
- @retval EFI_SUCCESS Verify success.
- @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
- @retval EFI_UNSUPPORTED The device ont support the access type.
-**/
-EFI_STATUS
-IsaIoVerifyAccess (
- IN ISA_IO_DEVICE *IsaIoDevice,
- IN ISA_ACCESS_TYPE Type,
- IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
- IN UINTN Count,
- IN UINT32 Offset
- );
-
-/**
- Performs an ISA I/O Read Cycle
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Width Specifies the width of the I/O operation.
- @param[in] Offset The offset in ISA I/O space to start the I/O operation.
- @param[in] Count The number of I/O operations to perform.
- @param[out] Buffer The destination buffer to store the results
-
- @retval EFI_SUCCESS The data was read from the device sucessfully.
- @retval EFI_UNSUPPORTED The Offset is not valid for this device.
- @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoIoRead (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
- IN UINT32 Offset,
- IN UINTN Count,
- OUT VOID *Buffer
- );
-
-/**
- Performs an ISA I/O Write Cycle
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Width Specifies the width of the I/O operation.
- @param[in] Offset The offset in ISA I/O space to start the I/O operation.
- @param[in] Count The number of I/O operations to perform.
- @param[in] Buffer The source buffer to write data from
-
- @retval EFI_SUCCESS The data was writen to the device sucessfully.
- @retval EFI_UNSUPPORTED The Offset is not valid for this device.
- @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoIoWrite (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
- IN UINT32 Offset,
- IN UINTN Count,
- IN VOID *Buffer
- );
-
-/**
- Maps a memory region for DMA
-
- @param This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param Operation Indicates the type of DMA (slave or bus master), and if
- the DMA operation is going to read or write to system memory.
- @param ChannelNumber The slave channel number to use for this DMA operation.
- If Operation and ChannelAttributes shows that this device
- performs bus mastering DMA, then this field is ignored.
- The legal range for this field is 0..7.
- @param ChannelAttributes The attributes of the DMA channel to use for this DMA operation
- @param HostAddress The system memory address to map to the device.
- @param NumberOfBytes On input the number of bytes to map. On output the number
- of bytes that were mapped.
- @param DeviceAddress The resulting map address for the bus master device to use
- to access the hosts HostAddress.
- @param Mapping A resulting value to pass to EFI_ISA_IO.Unmap().
-
- @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
- @retval EFI_INVALID_PARAMETER The Operation or HostAddress is undefined.
- @retval EFI_UNSUPPORTED The HostAddress can not be mapped as a common buffer.
- @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
- @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoMap (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_OPERATION Operation,
- IN UINT8 ChannelNumber OPTIONAL,
- IN UINT32 ChannelAttributes,
- IN VOID *HostAddress,
- IN OUT UINTN *NumberOfBytes,
- OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
- OUT VOID **Mapping
- );
-
-/**
- Unmaps a memory region for DMA
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Mapping The mapping value returned from EFI_ISA_IO.Map().
-
- @retval EFI_SUCCESS The range was unmapped.
- @retval EFI_DEVICE_ERROR The data was not committed to the target system memory.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoUnmap (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN VOID *Mapping
- );
-
-/**
- Flushes any posted write data to the system memory.
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
-
- @retval EFI_SUCCESS The buffers were flushed.
- @retval EFI_DEVICE_ERROR The buffers were not flushed due to a hardware error.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoFlush (
- IN EFI_ISA_IO_PROTOCOL *This
- );
-
-/**
- Writes I/O operation base address and count number to a 8 bit I/O Port.
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] AddrOffset The address' offset.
- @param[in] PageOffset The page's offest.
- @param[in] CountOffset The count's offset.
- @param[in] BaseAddress The base address.
- @param[in] Count The number of I/O operations to perform.
-
- @retval EFI_SUCCESS Success.
- @retval EFI_INVALID_PARAMETER Parameter is invalid.
- @retval EFI_UNSUPPORTED The address range specified by these Offsets and Count is not valid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-WriteDmaPort (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN UINT32 AddrOffset,
- IN UINT32 PageOffset,
- IN UINT32 CountOffset,
- IN UINT32 BaseAddress,
- IN UINT16 Count
- );
-
-/**
- Writes an 8-bit I/O Port
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Offset The offset in ISA IO space to start the IO operation.
- @param[in] Value The data to write port.
-
- @retval EFI_SUCCESS Success.
- @retval EFI_INVALID_PARAMETER Parameter is invalid.
- @retval EFI_UNSUPPORTED The address range specified by Offset is not valid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-WritePort (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN UINT32 Offset,
- IN UINT8 Value
- );
-
-/**
- Performs an ISA Memory Read Cycle
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Width Specifies the width of the memory operation.
- @param[in] Offset The offset in ISA memory space to start the memory operation.
- @param[in] Count The number of memory operations to perform.
- @param[out] Buffer The destination buffer to store the results
-
- @retval EFI_SUCCESS The data was read from the device successfully.
- @retval EFI_UNSUPPORTED The Offset is not valid for this device.
- @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoMemRead (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
- IN UINT32 Offset,
- IN UINTN Count,
- OUT VOID *Buffer
- );
-
-
-/**
- Performs an ISA Memory Write Cycle
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Width Specifies the width of the memory operation.
- @param[in] Offset The offset in ISA memory space to start the memory operation.
- @param[in] Count The number of memory operations to perform.
- @param[in] Buffer The source buffer to write data from
-
- @retval EFI_SUCCESS The data was written to the device sucessfully.
- @retval EFI_UNSUPPORTED The Offset is not valid for this device.
- @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoMemWrite (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
- IN UINT32 Offset,
- IN UINTN Count,
- IN VOID *Buffer
- );
-
-/**
- Copy one region of ISA memory space to another region of ISA memory space on the ISA controller.
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Width Specifies the width of the memory copy operation.
- @param[in] DestOffset The offset of the destination
- @param[in] SrcOffset The offset of the source
- @param[in] Count The number of memory copy operations to perform
-
- @retval EFI_SUCCESS The data was copied sucessfully.
- @retval EFI_UNSUPPORTED The DestOffset or SrcOffset is not valid for this device.
- @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoCopyMem (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
- IN UINT32 DestOffset,
- IN UINT32 SrcOffset,
- IN UINTN Count
- );
-
-/**
- Allocates pages that are suitable for an EfiIsaIoOperationBusMasterCommonBuffer mapping.
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Type The type allocation to perform.
- @param[in] MemoryType The type of memory to allocate.
- @param[in] Pages The number of pages to allocate.
- @param[out] HostAddress A pointer to store the base address of the allocated range.
- @param[in] Attributes The requested bit mask of attributes for the allocated range.
-
- @retval EFI_SUCCESS The requested memory pages were allocated.
- @retval EFI_INVALID_PARAMETER Type is invalid or MemoryType is invalid or HostAddress is NULL
- @retval EFI_UNSUPPORTED Attributes is unsupported or the memory range specified
- by HostAddress, Pages, and Type is not available for common buffer use.
- @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoAllocateBuffer (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ALLOCATE_TYPE Type,
- IN EFI_MEMORY_TYPE MemoryType,
- IN UINTN Pages,
- OUT VOID **HostAddress,
- IN UINT64 Attributes
- );
-
-/**
- Frees memory that was allocated with EFI_ISA_IO.AllocateBuffer().
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Pages The number of pages to free.
- @param[in] HostAddress The base address of the allocated range.
-
- @retval EFI_SUCCESS The requested memory pages were freed.
- @retval EFI_INVALID_PARAMETER The memory was not allocated with EFI_ISA_IO.AllocateBufer().
-**/
-EFI_STATUS
-EFIAPI
-IsaIoFreeBuffer (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN UINTN Pages,
- IN VOID *HostAddress
- );
-
-#endif
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBus.c b/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBus.c deleted file mode 100644 index 1312f260f9..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBus.c +++ /dev/null @@ -1,673 +0,0 @@ -/** @file
- ISA Bus UEFI driver.
-
- Discovers all the ISA Controllers and their resources by using the ISA ACPI
- Protocol, produces an instance of the ISA I/O Protocol for every ISA
- Controller found. This driver is designed to manage a PCI-to-ISA bridge Device
- such as LPC bridge.
-
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
-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 "InternalIsaBus.h"
-
-//
-// ISA Bus Driver Global Variables
-//
-EFI_DRIVER_BINDING_PROTOCOL gIsaBusControllerDriver = {
- IsaBusControllerDriverSupported,
- IsaBusControllerDriverStart,
- IsaBusControllerDriverStop,
- 0xa,
- NULL,
- NULL
-};
-
-/**
- The main entry point for the ISA Bus driver.
-
- @param[in] ImageHandle The firmware allocated handle for the EFI image.
- @param[in] SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The entry point is executed successfully.
- @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols.
-**/
-EFI_STATUS
-EFIAPI
-InitializeIsaBus(
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- //
- // Install driver model protocol(s).
- //
- Status = EfiLibInstallDriverBindingComponentName2 (
- ImageHandle,
- SystemTable,
- &gIsaBusControllerDriver,
- ImageHandle,
- &gIsaBusComponentName,
- &gIsaBusComponentName2
- );
- ASSERT_EFI_ERROR (Status);
-
- return Status;
-}
-
-/**
- Tests to see if a controller can be managed by the ISA Bus Driver. If a child device is provided,
- it further tests to see if this driver supports creating a handle for the specified child device.
-
- Note that the ISA Bus driver always creates all of its child handles on the first call to Start().
- How the Start() function of a driver is implemented can affect how the Supported() function is implemented.
-
- @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param[in] Controller The handle of the controller to test.
- @param[in] RemainingDevicePath A pointer to the remaining portion of a device path.
-
- @retval EFI_SUCCESS The device is supported by this driver.
- @retval EFI_ALREADY_STARTED The device is already being managed by this driver.
- @retval EFI_ACCESS_DENIED The device is already being managed by a different driver
- or an application that requires exclusive access.
- @retval EFI_UNSUPPORTED The device is is not supported by this driver.
-
-**/
-EFI_STATUS
-EFIAPI
-IsaBusControllerDriverSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
- )
-{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
- EFI_ISA_ACPI_PROTOCOL *IsaAcpi;
-
- //
- // If RemainingDevicePath is not NULL, it should verify that the first device
- // path node in RemainingDevicePath is an ACPI Device path node which is a
- // legal Device Path Node for this bus driver's children.
- //
- if (RemainingDevicePath != NULL) {
- if (RemainingDevicePath->Type != ACPI_DEVICE_PATH) {
- return EFI_UNSUPPORTED;
- } else if (RemainingDevicePath->SubType == ACPI_DP) {
- if (DevicePathNodeLength (RemainingDevicePath) != sizeof (ACPI_HID_DEVICE_PATH)) {
- return EFI_UNSUPPORTED;
- }
- } else if (RemainingDevicePath->SubType == ACPI_EXTENDED_DP) {
- if (DevicePathNodeLength (RemainingDevicePath) != sizeof (ACPI_EXTENDED_HID_DEVICE_PATH)) {
- return EFI_UNSUPPORTED;
- }
- } else {
- return EFI_UNSUPPORTED;
- }
- }
- //
- // Try to open EFI DEVICE PATH protocol on the controller
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- //
- // Although this driver creates all child handles at one time,
- // but because all child handles may be not stopped at one time in EFI Driver Binding.Stop(),
- // So it is allowed to create child handles again in successive calls to EFI Driver Binding.Start().
- //
- if (Status == EFI_ALREADY_STARTED) {
- return EFI_SUCCESS;
- }
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- //
- // Try to get Pci IO Protocol because it is assumed
- // to have been opened by ISA ACPI driver
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- NULL,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Try to open the Isa Acpi protocol on the controller
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiIsaAcpiProtocolGuid,
- (VOID **) &IsaAcpi,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Add more check to see if the child device is valid by calling IsaAcpi->DeviceEnumerate?
- //
-
- gBS->CloseProtocol (
- Controller,
- &gEfiIsaAcpiProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- return Status;
-}
-
-/**
- Start this driver on ControllerHandle.
-
- Note that the ISA Bus driver always creates all of its child handles on the first call to Start().
- The Start() function is designed to be invoked from the EFI boot service ConnectController().
- As a result, much of the error checking on the parameters to Start() has been moved into this
- common boot service. It is legal to call Start() from other locations, but the following calling
- restrictions must be followed or the system behavior will not be deterministic.
- 1. ControllerHandle must be a valid EFI_HANDLE.
- 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
- EFI_DEVICE_PATH_PROTOCOL.
- 3. Prior to calling Start(), the Supported() function for the driver specified by This must
- have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
-
- @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param[in] ControllerHandle The handle of the controller to start. This handle
- must support a protocol interface that supplies
- an I/O abstraction to the driver.
- @param[in] RemainingDevicePath A pointer to the remaining portion of a device path.
- This parameter is ignored by device drivers, and is optional for bus drivers.
-
- @retval EFI_SUCCESS The device was started.
- @retval EFI_DEVICE_ERROR The device could not be started due to a device error.
- Currently not implemented.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
- @retval Others The driver failded to start the device.
-**/
-EFI_STATUS
-EFIAPI
-IsaBusControllerDriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
- )
-{
- EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL *PciIo;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
- EFI_ISA_ACPI_PROTOCOL *IsaAcpi;
- EFI_ISA_ACPI_DEVICE_ID *IsaDevice;
- EFI_ISA_ACPI_RESOURCE_LIST *ResourceList;
- EFI_GENERIC_MEMORY_TEST_PROTOCOL *GenMemoryTest;
-
- //
- // Local variables declaration for StatusCode reporting
- //
- EFI_DEVICE_PATH_PROTOCOL *DevicePathData;
-
- DevicePathData = NULL;
-
- //
- // Get Pci IO Protocol
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- (VOID **) &PciIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Open Device Path Protocol
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {
- return Status;
- }
-
- //
- // Open ISA Acpi Protocol
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiIsaAcpiProtocolGuid,
- (VOID **) &IsaAcpi,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {
- //
- // Close opened protocol
- //
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- return Status;
- }
- //
- // The IsaBus driver will use memory below 16M, which is not tested yet,
- // so call CompatibleRangeTest to test them. Since memory below 1M should
- // be reserved to CSM, and 15M~16M might be reserved for Isa hole, test 1M
- // ~15M here
- //
- Status = gBS->LocateProtocol (
- &gEfiGenericMemTestProtocolGuid,
- NULL,
- (VOID **) &GenMemoryTest
- );
-
- if (!EFI_ERROR (Status)) {
- Status = GenMemoryTest->CompatibleRangeTest (
- GenMemoryTest,
- 0x100000,
- 0xE00000
- );
- }
- //
- // Report Status Code here since we will initialize the host controller
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- (EFI_IO_BUS_LPC | EFI_IOB_PC_INIT),
- ParentDevicePath
- );
-
- //
- // first init ISA interface
- //
- IsaAcpi->InterfaceInit (IsaAcpi);
-
- //
- // Report Status Code here since we will enable the host controller
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- (EFI_IO_BUS_LPC | EFI_IOB_PC_ENABLE),
- ParentDevicePath
- );
-
- //
- // Create each ISA device handle in this ISA bus
- //
- IsaDevice = NULL;
- do {
- Status = IsaAcpi->DeviceEnumerate (IsaAcpi, &IsaDevice);
- if (EFI_ERROR (Status)) {
- break;
- }
- //
- // Get current resource of this ISA device
- //
- ResourceList = NULL;
- Status = IsaAcpi->GetCurResource (IsaAcpi, IsaDevice, &ResourceList);
- if (EFI_ERROR (Status)) {
- continue;
- }
-
- //
- // Create handle for this ISA device
- //
- // If any child device handle was created in previous call to Start() and not stopped
- // in previous call to Stop(), it will not be created again because the
- // InstallMultipleProtocolInterfaces() boot service will reject same device path.
- //
- Status = IsaCreateDevice (
- This,
- Controller,
- PciIo,
- ParentDevicePath,
- ResourceList,
- &DevicePathData
- );
-
- if (EFI_ERROR (Status)) {
- continue;
- }
- //
- // Initialize ISA device
- //
- IsaAcpi->InitDevice (IsaAcpi, IsaDevice);
-
- //
- // Set resources for this ISA device
- //
- Status = IsaAcpi->SetResource (IsaAcpi, IsaDevice, ResourceList);
-
- //
- // Report Status Code here when failed to resource conflicts
- //
- if (EFI_ERROR (Status) && (Status != EFI_UNSUPPORTED)) {
- //
- // It's hard to tell which resource conflicts
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_ERROR_CODE,
- (EFI_IO_BUS_LPC | EFI_IOB_EC_RESOURCE_CONFLICT),
- DevicePathData
- );
-
- }
- //
- // Set power for this ISA device
- //
- IsaAcpi->SetPower (IsaAcpi, IsaDevice, TRUE);
-
- //
- // Enable this ISA device
- //
- IsaAcpi->EnableDevice (IsaAcpi, IsaDevice, TRUE);
-
- } while (TRUE);
-
- return EFI_SUCCESS;
-}
-
-/**
- Stop this driver on ControllerHandle.
-
- The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
- As a result, much of the error checking on the parameters to Stop() has been moved
- into this common boot service. It is legal to call Stop() from other locations,
- but the following calling restrictions must be followed or the system behavior will not be deterministic.
- 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
- same driver's Start() function.
- 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
- EFI_HANDLE. In addition, all of these handles must have been created in this driver's
- Start() function, and the Start() function must have called OpenProtocol() on
- ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
-
- @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param[in] ControllerHandle A handle to the device being stopped. The handle must
- support a bus specific I/O protocol for the driver
- to use to stop the device.
- @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
- @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
- if NumberOfChildren is 0.
-
- @retval EFI_SUCCESS The device was stopped.
- @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
-**/
-EFI_STATUS
-EFIAPI
-IsaBusControllerDriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL * This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE * ChildHandleBuffer OPTIONAL
- )
-{
- EFI_STATUS Status;
- UINTN Index;
- BOOLEAN AllChildrenStopped;
- ISA_IO_DEVICE *IsaIoDevice;
- EFI_ISA_IO_PROTOCOL *IsaIo;
- EFI_PCI_IO_PROTOCOL *PciIo;
-
- if (NumberOfChildren == 0) {
- //
- // Close the bus driver
- //
- Status = gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = gBS->CloseProtocol (
- Controller,
- &gEfiIsaAcpiProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- return EFI_SUCCESS;
- }
- //
- // Complete all outstanding transactions to Controller.
- // Don't allow any new transaction to Controller to be started.
- //
- //
- // Stop all the children
- // Find all the ISA devices that were discovered on this PCI to ISA Bridge
- // with the Start() function.
- //
- AllChildrenStopped = TRUE;
-
- for (Index = 0; Index < NumberOfChildren; Index++) {
-
- Status = gBS->OpenProtocol (
- ChildHandleBuffer[Index],
- &gEfiIsaIoProtocolGuid,
- (VOID **) &IsaIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (!EFI_ERROR (Status)) {
-
- IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (IsaIo);
-
- //
- // Close the child handle
- //
-
- Status = gBS->CloseProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle,
- ChildHandleBuffer[Index]
- );
- Status = gBS->UninstallMultipleProtocolInterfaces (
- ChildHandleBuffer[Index],
- &gEfiDevicePathProtocolGuid,
- IsaIoDevice->DevicePath,
- &gEfiIsaIoProtocolGuid,
- &IsaIoDevice->IsaIo,
- NULL
- );
-
- if (!EFI_ERROR (Status)) {
- FreePool (IsaIoDevice->DevicePath);
- FreePool (IsaIoDevice);
- } else {
- //
- // Re-open PCI IO Protocol on behalf of the child device
- // because of failure of destroying the child device handle
- //
- gBS->OpenProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- (VOID **) &PciIo,
- This->DriverBindingHandle,
- ChildHandleBuffer[Index],
- EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
- );
- }
- }
-
- if (EFI_ERROR (Status)) {
- AllChildrenStopped = FALSE;
- }
- }
-
- if (!AllChildrenStopped) {
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-//
-// Internal Function
-//
-
-/**
- Create EFI Handle for a ISA device found via ISA ACPI Protocol
-
- @param[in] This The EFI_DRIVER_BINDING_PROTOCOL instance.
- @param[in] Controller The handle of ISA bus controller(PCI to ISA bridge)
- @param[in] PciIo The Pointer to the PCI protocol
- @param[in] ParentDevicePath Device path of the ISA bus controller
- @param[in] IsaDeviceResourceList The resource list of the ISA device
- @param[out] ChildDevicePath The pointer to the child device.
-
- @retval EFI_SUCCESS The handle for the child device was created.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
- @retval EFI_DEVICE_ERROR The handle for the child device can not be created.
-**/
-EFI_STATUS
-IsaCreateDevice (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,
- IN EFI_ISA_ACPI_RESOURCE_LIST *IsaDeviceResourceList,
- OUT EFI_DEVICE_PATH_PROTOCOL **ChildDevicePath
- )
-{
- EFI_STATUS Status;
- ISA_IO_DEVICE *IsaIoDevice;
- EFI_DEV_PATH Node;
-
- //
- // Initialize the PCI_IO_DEVICE structure
- //
- IsaIoDevice = AllocateZeroPool (sizeof (ISA_IO_DEVICE));
- if (IsaIoDevice == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- IsaIoDevice->Signature = ISA_IO_DEVICE_SIGNATURE;
- IsaIoDevice->Handle = NULL;
- IsaIoDevice->PciIo = PciIo;
-
- //
- // Initialize the ISA I/O instance structure
- //
- InitializeIsaIoInstance (IsaIoDevice, IsaDeviceResourceList);
-
- //
- // Build the child device path
- //
- Node.DevPath.Type = ACPI_DEVICE_PATH;
- Node.DevPath.SubType = ACPI_DP;
- SetDevicePathNodeLength (&Node.DevPath, sizeof (ACPI_HID_DEVICE_PATH));
- Node.Acpi.HID = IsaDeviceResourceList->Device.HID;
- Node.Acpi.UID = IsaDeviceResourceList->Device.UID;
-
- IsaIoDevice->DevicePath = AppendDevicePathNode (
- ParentDevicePath,
- &Node.DevPath
- );
-
- if (IsaIoDevice->DevicePath == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Done;
- }
-
- *ChildDevicePath = IsaIoDevice->DevicePath;
-
- //
- // Create a child handle and install Device Path and ISA I/O protocols
- //
- Status = gBS->InstallMultipleProtocolInterfaces (
- &IsaIoDevice->Handle,
- &gEfiDevicePathProtocolGuid,
- IsaIoDevice->DevicePath,
- &gEfiIsaIoProtocolGuid,
- &IsaIoDevice->IsaIo,
- NULL
- );
- if (EFI_ERROR (Status)) {
- goto Done;
- }
-
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- (VOID **) &PciIo,
- This->DriverBindingHandle,
- IsaIoDevice->Handle,
- EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
- );
- if (EFI_ERROR (Status)) {
- gBS->UninstallMultipleProtocolInterfaces (
- IsaIoDevice->Handle,
- &gEfiDevicePathProtocolGuid,
- IsaIoDevice->DevicePath,
- &gEfiIsaIoProtocolGuid,
- &IsaIoDevice->IsaIo,
- NULL
- );
- }
-
-Done:
-
- if (EFI_ERROR (Status)) {
- if (IsaIoDevice->DevicePath != NULL) {
- FreePool (IsaIoDevice->DevicePath);
- }
-
- FreePool (IsaIoDevice);
- }
-
- return Status;
-}
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.inf b/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.inf deleted file mode 100644 index be6dd43ea6..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.inf +++ /dev/null @@ -1,73 +0,0 @@ -## @file
-# Generates ISA I/O Protocols based on the ISA ACPI Protocol instances.
-#
-# Discovers all the ISA Controllers and their resources by using the ISA ACPI
-# Protocol, produces an instance of the ISA I/O Protocol for every ISA
-# Controller found. This driver is designed to manage a PCI-to-ISA bridge Device
-# such as an LPC bridge.
-#
-# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
-#
-# 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.
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = IsaBusDxe
- MODULE_UNI_FILE = IsaBusDxe.uni
- FILE_GUID = 240612B5-A063-11d4-9A3A-0090273FC14D
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = InitializeIsaBus
-
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-# DRIVER_BINDING = gIsaBusControllerDriver
-# COMPONENT_NAME = gIsaBusComponentName;
-# COMPONENT_NAME2 = gIsaBusComponentName2;
-#
-
-[Sources]
- ComponentName.c
- IsaIo.c
- IsaBus.c
- InternalIsaIo.h
- InternalIsaBus.h
- ComponentName.h
-
-[Packages]
- MdePkg/MdePkg.dec
- IntelFrameworkPkg/IntelFrameworkPkg.dec
- IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
- MdeModulePkg/MdeModulePkg.dec
-
-[LibraryClasses]
- PcdLib
- ReportStatusCodeLib
- UefiBootServicesTableLib
- MemoryAllocationLib
- BaseMemoryLib
- DevicePathLib
- UefiLib
- UefiDriverEntryPoint
- DebugLib
-
-[Protocols]
- gEfiIsaIoProtocolGuid ## BY_START
- gEfiDevicePathProtocolGuid ## BY_START
- gEfiIsaAcpiProtocolGuid ## TO_START
- gEfiPciIoProtocolGuid ## TO_START
- gEfiDevicePathProtocolGuid ## TO_START
- gEfiGenericMemTestProtocolGuid ## TO_START
-
-[Pcd]
- gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdIsaBusSupportedFeatures ## CONSUMES
-
-[UserExtensions.TianoCore."ExtraFiles"]
- IsaBusDxeExtra.uni
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.uni b/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.uni deleted file mode 100644 index 2496381592..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.uni +++ /dev/null @@ -1,25 +0,0 @@ -// /** @file
-// Generates ISA I/O Protocols based on the ISA ACPI Protocol instances.
-//
-// Discovers all the ISA Controllers and their resources by using the ISA ACPI
-// Protocol, produces an instance of the ISA I/O Protocol for every ISA
-// Controller found. This driver is designed to manage a PCI-to-ISA bridge Device
-// such as an LPC bridge.
-//
-// Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
-//
-// 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.
-//
-// **/
-
-
-#string STR_MODULE_ABSTRACT #language en-US "Generates ISA I/O Protocols based on the ISA ACPI Protocol instances"
-
-#string STR_MODULE_DESCRIPTION #language en-US "Discovers all the ISA Controllers and their resources by using the ISA ACPI Protocol, and produces an instance of the ISA I/O Protocol for every ISA Controller found. This driver is designed to manage a PCI-to-ISA bridge Device such as an LPC bridge."
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxeExtra.uni b/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxeExtra.uni deleted file mode 100644 index fd4cda0a73..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxeExtra.uni +++ /dev/null @@ -1,20 +0,0 @@ -// /** @file
-// IsaBusDxe Localized Strings and Content
-//
-// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
-//
-// 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.
-//
-// **/
-
-#string STR_PROPERTIES_MODULE_NAME
-#language en-US
-"ISA Bus DXE Driver"
-
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaIo.c b/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaIo.c deleted file mode 100644 index 6f1cd1b8b1..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaIo.c +++ /dev/null @@ -1,1463 +0,0 @@ -/** @file
- The implementation for EFI_ISA_IO_PROTOCOL.
-
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
-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 "InternalIsaIo.h"
-
-//
-// Module Variables
-//
-EFI_ISA_IO_PROTOCOL mIsaIoInterface = {
- {
- IsaIoMemRead,
- IsaIoMemWrite
- },
- {
- IsaIoIoRead,
- IsaIoIoWrite
- },
- IsaIoCopyMem,
- IsaIoMap,
- IsaIoUnmap,
- IsaIoAllocateBuffer,
- IsaIoFreeBuffer,
- IsaIoFlush,
- NULL,
- 0,
- NULL
-};
-
-EFI_ISA_DMA_REGISTERS mDmaRegisters[8] = {
- {
- 0x00,
- 0x87,
- 0x01
- },
- {
- 0x02,
- 0x83,
- 0x03
- },
- {
- 0x04,
- 0x81,
- 0x05
- },
- {
- 0x06,
- 0x82,
- 0x07
- },
- {
- 0x00,
- 0x00,
- 0x00
- }, // Channel 4 is invalid
- {
- 0xC4,
- 0x8B,
- 0xC6
- },
- {
- 0xC8,
- 0x89,
- 0xCA
- },
- {
- 0xCC,
- 0x8A,
- 0xCE
- },
-};
-
-/**
- Initializes an ISA I/O Instance
-
- @param[in] IsaIoDevice The iso device to be initialized.
- @param[in] IsaDeviceResourceList The resource list.
-
-**/
-VOID
-InitializeIsaIoInstance (
- IN ISA_IO_DEVICE *IsaIoDevice,
- IN EFI_ISA_ACPI_RESOURCE_LIST *IsaDeviceResourceList
- )
-{
- //
- // Use the ISA IO Protocol structure template to initialize the ISA IO instance
- //
- CopyMem (
- &IsaIoDevice->IsaIo,
- &mIsaIoInterface,
- sizeof (EFI_ISA_IO_PROTOCOL)
- );
-
- IsaIoDevice->IsaIo.ResourceList = IsaDeviceResourceList;
-}
-
-/**
- Performs an ISA I/O Read Cycle
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Width Specifies the width of the I/O operation.
- @param[in] Offset The offset in ISA I/O space to start the I/O operation.
- @param[in] Count The number of I/O operations to perform.
- @param[out] Buffer The destination buffer to store the results
-
- @retval EFI_SUCCESS The data was read from the device sucessfully.
- @retval EFI_UNSUPPORTED The Offset is not valid for this device.
- @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoIoRead (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
- IN UINT32 Offset,
- IN UINTN Count,
- OUT VOID *Buffer
- )
-{
- EFI_STATUS Status;
- ISA_IO_DEVICE *IsaIoDevice;
-
- IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);
-
- //
- // Verify Isa IO Access
- //
- Status = IsaIoVerifyAccess (
- IsaIoDevice,
- IsaAccessTypeIo,
- Width,
- Count,
- Offset
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = IsaIoDevice->PciIo->Io.Read (
- IsaIoDevice->PciIo,
- (EFI_PCI_IO_PROTOCOL_WIDTH) Width,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- Offset,
- Count,
- Buffer
- );
-
- if (EFI_ERROR (Status)) {
- REPORT_STATUS_CODE (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR
- );
- }
-
- return Status;
-}
-
-/**
- Performs an ISA I/O Write Cycle
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Width Specifies the width of the I/O operation.
- @param[in] Offset The offset in ISA I/O space to start the I/O operation.
- @param[in] Count The number of I/O operations to perform.
- @param[in] Buffer The source buffer to write data from
-
- @retval EFI_SUCCESS The data was writen to the device sucessfully.
- @retval EFI_UNSUPPORTED The Offset is not valid for this device.
- @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoIoWrite (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
- IN UINT32 Offset,
- IN UINTN Count,
- IN VOID *Buffer
- )
-{
- EFI_STATUS Status;
- ISA_IO_DEVICE *IsaIoDevice;
-
- IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);
-
- //
- // Verify Isa IO Access
- //
- Status = IsaIoVerifyAccess (
- IsaIoDevice,
- IsaAccessTypeIo,
- Width,
- Count,
- Offset
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = IsaIoDevice->PciIo->Io.Write (
- IsaIoDevice->PciIo,
- (EFI_PCI_IO_PROTOCOL_WIDTH) Width,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- Offset,
- Count,
- Buffer
- );
-
- if (EFI_ERROR (Status)) {
- REPORT_STATUS_CODE (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR
- );
- }
-
- return Status;
-}
-
-/**
- Writes an 8-bit I/O Port
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Offset The offset in ISA IO space to start the IO operation.
- @param[in] Value The data to write port.
-
- @retval EFI_SUCCESS Success.
- @retval EFI_INVALID_PARAMETER Parameter is invalid.
- @retval EFI_UNSUPPORTED The address range specified by Offset is not valid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-WritePort (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN UINT32 Offset,
- IN UINT8 Value
- )
-{
- EFI_STATUS Status;
- ISA_IO_DEVICE *IsaIoDevice;
-
- IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);
-
- Status = IsaIoDevice->PciIo->Io.Write (
- IsaIoDevice->PciIo,
- EfiPciIoWidthUint8,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- Offset,
- 1,
- &Value
- );
- if (EFI_ERROR (Status)) {
- REPORT_STATUS_CODE (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR
- );
- return Status;
- }
-
- gBS->Stall (50);
-
- return EFI_SUCCESS;
-}
-
-/**
- Writes I/O operation base address and count number to a 8 bit I/O Port.
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] AddrOffset The address' offset.
- @param[in] PageOffset The page's offest.
- @param[in] CountOffset The count's offset.
- @param[in] BaseAddress The base address.
- @param[in] Count The number of I/O operations to perform.
-
- @retval EFI_SUCCESS Success.
- @retval EFI_INVALID_PARAMETER Parameter is invalid.
- @retval EFI_UNSUPPORTED The address range specified by these Offsets and Count is not valid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-WriteDmaPort (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN UINT32 AddrOffset,
- IN UINT32 PageOffset,
- IN UINT32 CountOffset,
- IN UINT32 BaseAddress,
- IN UINT16 Count
- )
-{
- EFI_STATUS Status;
-
- Status = WritePort (This, AddrOffset, (UINT8) (BaseAddress & 0xff));
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = WritePort (This, AddrOffset, (UINT8) ((BaseAddress >> 8) & 0xff));
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = WritePort (This, PageOffset, (UINT8) ((BaseAddress >> 16) & 0xff));
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = WritePort (This, CountOffset, (UINT8) (Count & 0xff));
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = WritePort (This, CountOffset, (UINT8) ((Count >> 8) & 0xff));
- return Status;
-}
-
-/**
- Unmaps a memory region for DMA
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Mapping The mapping value returned from EFI_ISA_IO.Map().
-
- @retval EFI_SUCCESS The range was unmapped.
- @retval EFI_DEVICE_ERROR The data was not committed to the target system memory.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoUnmap (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN VOID *Mapping
- )
-{
- ISA_MAP_INFO *IsaMapInfo;
-
- //
- // Check if DMA is supported.
- //
- if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_DMA) == 0) {
- return EFI_UNSUPPORTED;
- }
-
- //
- // See if the Map() operation associated with this Unmap() required a mapping
- // buffer.If a mapping buffer was not required, then this function simply
- // returns EFI_SUCCESS.
- //
- if (Mapping != NULL) {
- //
- // Get the MAP_INFO structure from Mapping
- //
- IsaMapInfo = (ISA_MAP_INFO *) Mapping;
-
- //
- // If this is a write operation from the Agent's point of view,
- // then copy the contents of the mapped buffer into the real buffer
- // so the processor can read the contents of the real buffer.
- //
- if (IsaMapInfo->Operation == EfiIsaIoOperationBusMasterWrite) {
- CopyMem (
- (VOID *) (UINTN) IsaMapInfo->HostAddress,
- (VOID *) (UINTN) IsaMapInfo->MappedHostAddress,
- IsaMapInfo->NumberOfBytes
- );
- }
- //
- // Free the mapped buffer and the MAP_INFO structure.
- //
- gBS->FreePages (IsaMapInfo->MappedHostAddress, IsaMapInfo->NumberOfPages);
- FreePool (IsaMapInfo);
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Flushes any posted write data to the system memory.
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
-
- @retval EFI_SUCCESS The buffers were flushed.
- @retval EFI_DEVICE_ERROR The buffers were not flushed due to a hardware error.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoFlush (
- IN EFI_ISA_IO_PROTOCOL *This
- )
-{
- EFI_STATUS Status;
- ISA_IO_DEVICE *IsaIoDevice;
-
- IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);
-
- Status = IsaIoDevice->PciIo->Flush (IsaIoDevice->PciIo);
-
- if (EFI_ERROR (Status)) {
- REPORT_STATUS_CODE (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR
- );
- }
-
- return Status;
-}
-
-/**
- Verifies access to an ISA device
-
- @param[in] IsaIoDevice The ISA device to be verified.
- @param[in] Type The Access type. The input must be either IsaAccessTypeMem or IsaAccessTypeIo.
- @param[in] Width The width of the memory operation.
- @param[in] Count The number of memory operations to perform.
- @param[in] Offset The offset in ISA memory space to start the memory operation.
-
- @retval EFI_SUCCESS Verify success.
- @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
- @retval EFI_UNSUPPORTED The device ont support the access type.
-**/
-EFI_STATUS
-IsaIoVerifyAccess (
- IN ISA_IO_DEVICE *IsaIoDevice,
- IN ISA_ACCESS_TYPE Type,
- IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
- IN UINTN Count,
- IN UINT32 Offset
- )
-{
- EFI_ISA_ACPI_RESOURCE *Item;
- EFI_STATUS Status;
-
- if ((UINT32)Width >= EfiIsaIoWidthMaximum ||
- Width == EfiIsaIoWidthReserved ||
- Width == EfiIsaIoWidthFifoReserved ||
- Width == EfiIsaIoWidthFillReserved
- ) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // If Width is EfiIsaIoWidthFifoUintX then convert to EfiIsaIoWidthUintX
- // If Width is EfiIsaIoWidthFillUintX then convert to EfiIsaIoWidthUintX
- //
- if (Width >= EfiIsaIoWidthFifoUint8 && Width < EfiIsaIoWidthFifoReserved) {
- Count = 1;
- }
-
- Width = (EFI_ISA_IO_PROTOCOL_WIDTH) (Width & 0x03);
-
- Status = EFI_UNSUPPORTED;
- Item = IsaIoDevice->IsaIo.ResourceList->ResourceItem;
- while (Item->Type != EfiIsaAcpiResourceEndOfList) {
- if ((Type == IsaAccessTypeMem && Item->Type == EfiIsaAcpiResourceMemory) ||
- (Type == IsaAccessTypeIo && Item->Type == EfiIsaAcpiResourceIo)) {
- if (Offset >= Item->StartRange && (Offset + Count * (UINT32)(1 << Width)) - 1 <= Item->EndRange) {
- return EFI_SUCCESS;
- }
-
- if (Offset >= Item->StartRange && Offset <= Item->EndRange) {
- Status = EFI_INVALID_PARAMETER;
- }
- }
-
- Item++;
- }
-
- return Status;
-}
-
-/**
- Performs an ISA Memory Read Cycle
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Width Specifies the width of the memory operation.
- @param[in] Offset The offset in ISA memory space to start the memory operation.
- @param[in] Count The number of memory operations to perform.
- @param[out] Buffer The destination buffer to store the results
-
- @retval EFI_SUCCESS The data was read from the device successfully.
- @retval EFI_UNSUPPORTED The Offset is not valid for this device.
- @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoMemRead (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
- IN UINT32 Offset,
- IN UINTN Count,
- OUT VOID *Buffer
- )
-{
- EFI_STATUS Status;
- ISA_IO_DEVICE *IsaIoDevice;
-
- //
- // Check if ISA memory is supported.
- //
- if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_ISA_MEMORY) == 0) {
- return EFI_UNSUPPORTED;
- }
-
- IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);
-
- //
- // Verify the Isa Io Access
- //
- Status = IsaIoVerifyAccess (
- IsaIoDevice,
- IsaAccessTypeMem,
- Width,
- Count,
- Offset
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = IsaIoDevice->PciIo->Mem.Read (
- IsaIoDevice->PciIo,
- (EFI_PCI_IO_PROTOCOL_WIDTH) Width,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- Offset,
- Count,
- Buffer
- );
-
- if (EFI_ERROR (Status)) {
- REPORT_STATUS_CODE (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR
- );
- }
-
- return Status;
-}
-
-/**
- Performs an ISA Memory Write Cycle
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Width Specifies the width of the memory operation.
- @param[in] Offset The offset in ISA memory space to start the memory operation.
- @param[in] Count The number of memory operations to perform.
- @param[in] Buffer The source buffer to write data from
-
- @retval EFI_SUCCESS The data was written to the device sucessfully.
- @retval EFI_UNSUPPORTED The Offset is not valid for this device.
- @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoMemWrite (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
- IN UINT32 Offset,
- IN UINTN Count,
- IN VOID *Buffer
- )
-{
- EFI_STATUS Status;
- ISA_IO_DEVICE *IsaIoDevice;
-
- //
- // Check if ISA memory is supported.
- //
- if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_ISA_MEMORY) == 0) {
- return EFI_UNSUPPORTED;
- }
-
- IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);
-
- //
- // Verify Isa IO Access
- //
- Status = IsaIoVerifyAccess (
- IsaIoDevice,
- IsaAccessTypeMem,
- Width,
- Count,
- Offset
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = IsaIoDevice->PciIo->Mem.Write (
- IsaIoDevice->PciIo,
- (EFI_PCI_IO_PROTOCOL_WIDTH) Width,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- Offset,
- Count,
- Buffer
- );
-
- if (EFI_ERROR (Status)) {
- REPORT_STATUS_CODE (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR
- );
- }
-
- return Status;
-}
-
-/**
- Copy one region of ISA memory space to another region of ISA memory space on the ISA controller.
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Width Specifies the width of the memory copy operation.
- @param[in] DestOffset The offset of the destination
- @param[in] SrcOffset The offset of the source
- @param[in] Count The number of memory copy operations to perform
-
- @retval EFI_SUCCESS The data was copied sucessfully.
- @retval EFI_UNSUPPORTED The DestOffset or SrcOffset is not valid for this device.
- @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoCopyMem (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
- IN UINT32 DestOffset,
- IN UINT32 SrcOffset,
- IN UINTN Count
- )
-{
- EFI_STATUS Status;
- ISA_IO_DEVICE *IsaIoDevice;
-
- //
- // Check if ISA memory is supported.
- //
- if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_ISA_MEMORY) == 0) {
- return EFI_UNSUPPORTED;
- }
-
- IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);
-
- //
- // Verify Isa IO Access for destination and source
- //
- Status = IsaIoVerifyAccess (
- IsaIoDevice,
- IsaAccessTypeMem,
- Width,
- Count,
- DestOffset
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = IsaIoVerifyAccess (
- IsaIoDevice,
- IsaAccessTypeMem,
- Width,
- Count,
- SrcOffset
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = IsaIoDevice->PciIo->CopyMem (
- IsaIoDevice->PciIo,
- (EFI_PCI_IO_PROTOCOL_WIDTH) Width,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- DestOffset,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- SrcOffset,
- Count
- );
-
- if (EFI_ERROR (Status)) {
- REPORT_STATUS_CODE (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR
- );
- }
-
- return Status;
-}
-
-/**
- Maps a memory region for DMA, note this implementation
- only supports slave read/write operation to save code size.
-
- @param This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param Operation Indicates the type of DMA (slave or bus master), and if
- the DMA operation is going to read or write to system memory.
- @param ChannelNumber The slave channel number to use for this DMA operation.
- If Operation and ChannelAttributes shows that this device
- performs bus mastering DMA, then this field is ignored.
- The legal range for this field is 0..7.
- @param ChannelAttributes The attributes of the DMA channel to use for this DMA operation
- @param HostAddress The system memory address to map to the device.
- @param NumberOfBytes On input the number of bytes to map. On output the number
- of bytes that were mapped.
- @param DeviceAddress The resulting map address for the bus master device to use
- to access the hosts HostAddress.
- @param Mapping A resulting value to pass to EFI_ISA_IO.Unmap().
-
- @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
- @retval EFI_INVALID_PARAMETER The Operation or HostAddress is undefined.
- @retval EFI_UNSUPPORTED The HostAddress can not be mapped as a common buffer.
- @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
- @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
-**/
-EFI_STATUS
-IsaIoMapOnlySupportSlaveReadWrite (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_OPERATION Operation,
- IN UINT8 ChannelNumber OPTIONAL,
- IN UINT32 ChannelAttributes,
- IN VOID *HostAddress,
- IN OUT UINTN *NumberOfBytes,
- OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
- OUT VOID **Mapping
- )
-{
- EFI_STATUS Status;
- EFI_PHYSICAL_ADDRESS PhysicalAddress;
- ISA_MAP_INFO *IsaMapInfo;
- UINT8 DmaMode;
- UINTN MaxNumberOfBytes;
- UINT32 BaseAddress;
- UINT16 Count;
- UINT8 DmaMask;
- UINT8 DmaClear;
- UINT8 DmaChannelMode;
-
- if ((NULL == This) ||
- (NULL == HostAddress) ||
- (NULL == NumberOfBytes) ||
- (NULL == DeviceAddress) ||
- (NULL == Mapping)
- ) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Initialize the return values to their defaults
- //
- *Mapping = NULL;
-
- //
- // Make sure the Operation parameter is valid.
- // Light IsaIo only supports two operations.
- //
- if (!(Operation == EfiIsaIoOperationSlaveRead ||
- Operation == EfiIsaIoOperationSlaveWrite)) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (ChannelNumber >= 4) {
- //
- // The Light IsaIo doesn't support channelNumber larger than 4.
- //
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Map the HostAddress to a DeviceAddress.
- //
- PhysicalAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress;
- if ((PhysicalAddress + *NumberOfBytes) > ISA_MAX_MEMORY_ADDRESS) {
- //
- // Common Buffer operations can not be remapped. If the common buffer
- // is above 16MB, then it is not possible to generate a mapping, so return
- // an error.
- //
- if (Operation == EfiIsaIoOperationBusMasterCommonBuffer) {
- return EFI_UNSUPPORTED;
- }
- //
- // Allocate an ISA_MAP_INFO structure to remember the mapping when Unmap()
- // is called later.
- //
- IsaMapInfo = AllocatePool (sizeof (ISA_MAP_INFO));
- if (IsaMapInfo == NULL) {
- *NumberOfBytes = 0;
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // Return a pointer to the MAP_INFO structure in Mapping
- //
- *Mapping = IsaMapInfo;
-
- //
- // Initialize the MAP_INFO structure
- //
- IsaMapInfo->Operation = Operation;
- IsaMapInfo->NumberOfBytes = *NumberOfBytes;
- IsaMapInfo->NumberOfPages = EFI_SIZE_TO_PAGES (*NumberOfBytes);
- IsaMapInfo->HostAddress = PhysicalAddress;
- IsaMapInfo->MappedHostAddress = ISA_MAX_MEMORY_ADDRESS - 1;
-
- //
- // Allocate a buffer below 16MB to map the transfer to.
- //
- Status = gBS->AllocatePages (
- AllocateMaxAddress,
- EfiBootServicesData,
- IsaMapInfo->NumberOfPages,
- &IsaMapInfo->MappedHostAddress
- );
- if (EFI_ERROR (Status)) {
- FreePool (IsaMapInfo);
- *NumberOfBytes = 0;
- *Mapping = NULL;
- return Status;
- }
- //
- // If this is a read operation from the DMA agents's point of view,
- // then copy the contents of the real buffer into the mapped buffer
- // so the DMA agent can read the contents of the real buffer.
- //
- if (Operation == EfiIsaIoOperationSlaveRead) {
- CopyMem (
- (VOID *) (UINTN) IsaMapInfo->MappedHostAddress,
- (VOID *) (UINTN) IsaMapInfo->HostAddress,
- IsaMapInfo->NumberOfBytes
- );
- }
- //
- // The DeviceAddress is the address of the maped buffer below 16 MB
- //
- *DeviceAddress = IsaMapInfo->MappedHostAddress;
- } else {
- //
- // The transfer is below 16 MB, so the DeviceAddress is simply the
- // HostAddress
- //
- *DeviceAddress = PhysicalAddress;
- }
-
- //
- // Figure out what to program into the DMA Channel Mode Register
- //
- DmaMode = (UINT8) (B_8237_DMA_CHMODE_INCREMENT | (ChannelNumber & 0x03));
- if (Operation == EfiIsaIoOperationSlaveRead) {
- DmaMode |= V_8237_DMA_CHMODE_MEM2IO;
- } else {
- DmaMode |= V_8237_DMA_CHMODE_IO2MEM;
- }
- //
- // We only support EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE in simplified IsaIo
- //
- DmaMode |= V_8237_DMA_CHMODE_SINGLE;
-
- //
- // A Slave DMA transfer can not cross a 64K boundary.
- // Compute *NumberOfBytes based on this restriction.
- //
- MaxNumberOfBytes = 0x10000 - ((UINT32) (*DeviceAddress) & 0xffff);
- if (*NumberOfBytes > MaxNumberOfBytes) {
- *NumberOfBytes = MaxNumberOfBytes;
- }
- //
- // Compute the values to program into the BaseAddress and Count registers
- // of the Slave DMA controller
- //
- BaseAddress = (UINT32) (*DeviceAddress);
- Count = (UINT16) (*NumberOfBytes - 1);
- //
- // Program the DMA Write Single Mask Register for ChannelNumber
- // Clear the DMA Byte Pointer Register
- //
- DmaMask = R_8237_DMA_WRSMSK_CH0_3;
- DmaClear = R_8237_DMA_CBPR_CH0_3;
- DmaChannelMode = R_8237_DMA_CHMODE_CH0_3;
-
- Status = WritePort (
- This,
- DmaMask,
- (UINT8) (B_8237_DMA_WRSMSK_CMS | (ChannelNumber & 0x03))
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = WritePort (
- This,
- DmaClear,
- (UINT8) (B_8237_DMA_WRSMSK_CMS | (ChannelNumber & 0x03))
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = WritePort (This, DmaChannelMode, DmaMode);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = WriteDmaPort (
- This,
- mDmaRegisters[ChannelNumber].Address,
- mDmaRegisters[ChannelNumber].Page,
- mDmaRegisters[ChannelNumber].Count,
- BaseAddress,
- Count
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = WritePort (
- This,
- DmaMask,
- (UINT8) (ChannelNumber & 0x03)
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Maps a memory region for DMA. This implementation implement the
- the full mapping support.
-
- @param This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param Operation Indicates the type of DMA (slave or bus master), and if
- the DMA operation is going to read or write to system memory.
- @param ChannelNumber The slave channel number to use for this DMA operation.
- If Operation and ChannelAttributes shows that this device
- performs bus mastering DMA, then this field is ignored.
- The legal range for this field is 0..7.
- @param ChannelAttributes The attributes of the DMA channel to use for this DMA operation
- @param HostAddress The system memory address to map to the device.
- @param NumberOfBytes On input the number of bytes to map. On output the number
- of bytes that were mapped.
- @param DeviceAddress The resulting map address for the bus master device to use
- to access the hosts HostAddress.
- @param Mapping A resulting value to pass to EFI_ISA_IO.Unmap().
-
- @retval EFI_SUCCESS - The range was mapped for the returned NumberOfBytes.
- @retval EFI_INVALID_PARAMETER - The Operation or HostAddress is undefined.
- @retval EFI_UNSUPPORTED - The HostAddress can not be mapped as a common buffer.
- @retval EFI_DEVICE_ERROR - The system hardware could not map the requested address.
- @retval EFI_OUT_OF_RESOURCES - The memory pages could not be allocated.
-**/
-EFI_STATUS
-IsaIoMapFullSupport (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_OPERATION Operation,
- IN UINT8 ChannelNumber OPTIONAL,
- IN UINT32 ChannelAttributes,
- IN VOID *HostAddress,
- IN OUT UINTN *NumberOfBytes,
- OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
- OUT VOID **Mapping
- )
-{
- EFI_STATUS Status;
- BOOLEAN Master;
- BOOLEAN Read;
- EFI_PHYSICAL_ADDRESS PhysicalAddress;
- ISA_MAP_INFO *IsaMapInfo;
- UINT8 DmaMode;
- UINTN MaxNumberOfBytes;
- UINT32 BaseAddress;
- UINT16 Count;
- UINT8 DmaMask;
- UINT8 DmaClear;
- UINT8 DmaChannelMode;
-
- if ((NULL == This) ||
- (NULL == HostAddress) ||
- (NULL == NumberOfBytes) ||
- (NULL == DeviceAddress) ||
- (NULL == Mapping)
- ) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Initialize the return values to their defaults
- //
- *Mapping = NULL;
-
- //
- // Make sure the Operation parameter is valid
- //
- if ((UINT32)Operation >= EfiIsaIoOperationMaximum) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (ChannelNumber >= 8) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // See if this is a Slave DMA Operation
- //
- Master = TRUE;
- Read = FALSE;
- if (Operation == EfiIsaIoOperationSlaveRead) {
- Operation = EfiIsaIoOperationBusMasterRead;
- Master = FALSE;
- Read = TRUE;
- }
-
- if (Operation == EfiIsaIoOperationSlaveWrite) {
- Operation = EfiIsaIoOperationBusMasterWrite;
- Master = FALSE;
- Read = FALSE;
- }
-
- if (!Master) {
- //
- // Make sure that ChannelNumber is a valid channel number
- // Channel 4 is used to cascade, so it is illegal.
- //
- if (ChannelNumber == 4 || ChannelNumber > 7) {
- return EFI_INVALID_PARAMETER;
- }
- //
- // This implementation only support COMPATIBLE DMA Transfers
- //
- if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_COMPATIBLE) == 0) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((ChannelAttributes &
- (EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_A |
- EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_B |
- EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_C)) != 0) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (ChannelNumber < 4) {
- //
- // If this is Channel 0..3, then the width must be 8 bit
- //
- if (((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_8) == 0) ||
- ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_16) != 0)
- ) {
- return EFI_INVALID_PARAMETER;
- }
- } else {
- //
- // If this is Channel 4..7, then the width must be 16 bit
- //
- if (((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_8) != 0) ||
- ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_16) == 0)) {
- return EFI_INVALID_PARAMETER;
- }
- }
- //
- // Either Demand Mode or Single Mode must be selected, but not both
- //
- if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE) != 0) {
- if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_DEMAND_MODE) != 0) {
- return EFI_INVALID_PARAMETER;
- }
- } else {
- if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_DEMAND_MODE) == 0) {
- return EFI_INVALID_PARAMETER;
- }
- }
- }
- //
- // Map the HostAddress to a DeviceAddress.
- //
- PhysicalAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress;
- if ((PhysicalAddress +*NumberOfBytes) > ISA_MAX_MEMORY_ADDRESS) {
- //
- // Common Buffer operations can not be remapped. If the common buffer
- // is above 16MB, then it is not possible to generate a mapping, so return
- // an error.
- //
- if (Operation == EfiIsaIoOperationBusMasterCommonBuffer) {
- return EFI_UNSUPPORTED;
- }
- //
- // Allocate an ISA_MAP_INFO structure to remember the mapping when Unmap()
- // is called later.
- //
- IsaMapInfo = AllocatePool (sizeof (ISA_MAP_INFO));
- if (IsaMapInfo == NULL) {
- *NumberOfBytes = 0;
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // Return a pointer to the MAP_INFO structure in Mapping
- //
- *Mapping = IsaMapInfo;
-
- //
- // Initialize the MAP_INFO structure
- //
- IsaMapInfo->Operation = Operation;
- IsaMapInfo->NumberOfBytes = *NumberOfBytes;
- IsaMapInfo->NumberOfPages = EFI_SIZE_TO_PAGES (*NumberOfBytes);
- IsaMapInfo->HostAddress = PhysicalAddress;
- IsaMapInfo->MappedHostAddress = ISA_MAX_MEMORY_ADDRESS - 1;
-
- //
- // Allocate a buffer below 16MB to map the transfer to.
- //
- Status = gBS->AllocatePages (
- AllocateMaxAddress,
- EfiBootServicesData,
- IsaMapInfo->NumberOfPages,
- &IsaMapInfo->MappedHostAddress
- );
- if (EFI_ERROR (Status)) {
- FreePool (IsaMapInfo);
- *NumberOfBytes = 0;
- *Mapping = NULL;
- return Status;
- }
- //
- // If this is a read operation from the DMA agents's point of view,
- // then copy the contents of the real buffer into the mapped buffer
- // so the DMA agent can read the contents of the real buffer.
- //
- if (Operation == EfiIsaIoOperationBusMasterRead) {
- CopyMem (
- (VOID *) (UINTN) IsaMapInfo->MappedHostAddress,
- (VOID *) (UINTN) IsaMapInfo->HostAddress,
- IsaMapInfo->NumberOfBytes
- );
- }
- //
- // The DeviceAddress is the address of the maped buffer below 16 MB
- //
- *DeviceAddress = IsaMapInfo->MappedHostAddress;
- } else {
- //
- // The transfer is below 16 MB, so the DeviceAddress is simply the
- // HostAddress
- //
- *DeviceAddress = PhysicalAddress;
- }
- //
- // If this is a Bus Master operation then return
- //
- if (Master) {
- return EFI_SUCCESS;
- }
- //
- // Figure out what to program into the DMA Channel Mode Register
- //
- DmaMode = (UINT8) (B_8237_DMA_CHMODE_INCREMENT | (ChannelNumber & 0x03));
- if (Read) {
- DmaMode |= V_8237_DMA_CHMODE_MEM2IO;
- } else {
- DmaMode |= V_8237_DMA_CHMODE_IO2MEM;
- }
-
- if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_AUTO_INITIALIZE) != 0) {
- DmaMode |= B_8237_DMA_CHMODE_AE;
- }
-
- if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_DEMAND_MODE) != 0) {
- DmaMode |= V_8237_DMA_CHMODE_DEMAND;
- }
-
- if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE) != 0) {
- DmaMode |= V_8237_DMA_CHMODE_SINGLE;
- }
- //
- // A Slave DMA transfer can not cross a 64K boundary.
- // Compute *NumberOfBytes based on this restriction.
- //
- MaxNumberOfBytes = 0x10000 - ((UINT32) (*DeviceAddress) & 0xffff);
- if (*NumberOfBytes > MaxNumberOfBytes) {
- *NumberOfBytes = MaxNumberOfBytes;
- }
- //
- // Compute the values to program into the BaseAddress and Count registers
- // of the Slave DMA controller
- //
- if (ChannelNumber < 4) {
- BaseAddress = (UINT32) (*DeviceAddress);
- Count = (UINT16) (*NumberOfBytes - 1);
- } else {
- BaseAddress = (UINT32) (((UINT32) (*DeviceAddress) & 0xff0000) | (((UINT32) (*DeviceAddress) & 0xffff) >> 1));
- Count = (UINT16) ((*NumberOfBytes - 1) >> 1);
- }
- //
- // Program the DMA Write Single Mask Register for ChannelNumber
- // Clear the DMA Byte Pointer Register
- //
- if (ChannelNumber < 4) {
- DmaMask = R_8237_DMA_WRSMSK_CH0_3;
- DmaClear = R_8237_DMA_CBPR_CH0_3;
- DmaChannelMode = R_8237_DMA_CHMODE_CH0_3;
- } else {
- DmaMask = R_8237_DMA_WRSMSK_CH4_7;
- DmaClear = R_8237_DMA_CBPR_CH4_7;
- DmaChannelMode = R_8237_DMA_CHMODE_CH4_7;
- }
-
- Status = WritePort (
- This,
- DmaMask,
- (UINT8) (B_8237_DMA_WRSMSK_CMS | (ChannelNumber & 0x03))
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = WritePort (
- This,
- DmaClear,
- (UINT8) (B_8237_DMA_WRSMSK_CMS | (ChannelNumber & 0x03))
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = WritePort (This, DmaChannelMode, DmaMode);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = WriteDmaPort (
- This,
- mDmaRegisters[ChannelNumber].Address,
- mDmaRegisters[ChannelNumber].Page,
- mDmaRegisters[ChannelNumber].Count,
- BaseAddress,
- Count
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = WritePort (
- This,
- DmaMask,
- (UINT8) (ChannelNumber & 0x03)
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Maps a memory region for DMA
-
- @param This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param Operation Indicates the type of DMA (slave or bus master), and if
- the DMA operation is going to read or write to system memory.
- @param ChannelNumber The slave channel number to use for this DMA operation.
- If Operation and ChannelAttributes shows that this device
- performs bus mastering DMA, then this field is ignored.
- The legal range for this field is 0..7.
- @param ChannelAttributes The attributes of the DMA channel to use for this DMA operation
- @param HostAddress The system memory address to map to the device.
- @param NumberOfBytes On input the number of bytes to map. On output the number
- of bytes that were mapped.
- @param DeviceAddress The resulting map address for the bus master device to use
- to access the hosts HostAddress.
- @param Mapping A resulting value to pass to EFI_ISA_IO.Unmap().
-
- @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
- @retval EFI_INVALID_PARAMETER The Operation or HostAddress is undefined.
- @retval EFI_UNSUPPORTED The HostAddress can not be mapped as a common buffer.
- @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
- @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoMap (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_OPERATION Operation,
- IN UINT8 ChannelNumber OPTIONAL,
- IN UINT32 ChannelAttributes,
- IN VOID *HostAddress,
- IN OUT UINTN *NumberOfBytes,
- OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
- OUT VOID **Mapping
- )
-{
- //
- // Check if DMA is supported.
- //
- if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_DMA) == 0) {
- return EFI_UNSUPPORTED;
- }
- //
- // Set Feature Flag PcdIsaBusSupportBusMaster to FALSE to disable support for
- // ISA Bus Master.
- //
- // So we just return EFI_UNSUPPORTED for these functions.
- //
- if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_ONLY_SUPPORT_SLAVE_DMA) != 0) {
- return IsaIoMapOnlySupportSlaveReadWrite (
- This,
- Operation,
- ChannelNumber,
- ChannelAttributes,
- HostAddress,
- NumberOfBytes,
- DeviceAddress,
- Mapping
- );
-
- } else {
- return IsaIoMapFullSupport (
- This,
- Operation,
- ChannelNumber,
- ChannelAttributes,
- HostAddress,
- NumberOfBytes,
- DeviceAddress,
- Mapping
- );
- }
-}
-
-/**
- Allocates pages that are suitable for an EfiIsaIoOperationBusMasterCommonBuffer mapping.
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Type The type allocation to perform.
- @param[in] MemoryType The type of memory to allocate.
- @param[in] Pages The number of pages to allocate.
- @param[out] HostAddress A pointer to store the base address of the allocated range.
- @param[in] Attributes The requested bit mask of attributes for the allocated range.
-
- @retval EFI_SUCCESS The requested memory pages were allocated.
- @retval EFI_INVALID_PARAMETER Type is invalid or MemoryType is invalid or HostAddress is NULL
- @retval EFI_UNSUPPORTED Attributes is unsupported or the memory range specified
- by HostAddress, Pages, and Type is not available for common buffer use.
- @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoAllocateBuffer (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ALLOCATE_TYPE Type,
- IN EFI_MEMORY_TYPE MemoryType,
- IN UINTN Pages,
- OUT VOID **HostAddress,
- IN UINT64 Attributes
- )
-{
- EFI_STATUS Status;
- EFI_PHYSICAL_ADDRESS PhysicalAddress;
-
- //
- // Set Feature Flag PcdIsaBusOnlySupportSlaveDma to FALSE to disable support for
- // ISA Bus Master.
- // Or unset Feature Flag PcdIsaBusSupportDma to disable support for ISA DMA.
- //
- if (((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_DMA) == 0) ||
- ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_ONLY_SUPPORT_SLAVE_DMA) != 0)) {
- return EFI_UNSUPPORTED;
- }
-
- if (HostAddress == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((UINT32)Type >= MaxAllocateType) {
- return EFI_INVALID_PARAMETER;
- }
- //
- // The only valid memory types are EfiBootServicesData and EfiRuntimeServicesData
- //
- if (MemoryType != EfiBootServicesData && MemoryType != EfiRuntimeServicesData) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((Attributes & ~(EFI_ISA_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE | EFI_ISA_IO_ATTRIBUTE_MEMORY_CACHED)) != 0) {
- return EFI_UNSUPPORTED;
- }
-
- PhysicalAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) (ISA_MAX_MEMORY_ADDRESS - 1);
- if (Type == AllocateAddress) {
- if ((UINTN) (*HostAddress) >= ISA_MAX_MEMORY_ADDRESS) {
- return EFI_UNSUPPORTED;
- } else {
- PhysicalAddress = (UINTN) (*HostAddress);
- }
- }
-
- if (Type == AllocateAnyPages) {
- Type = AllocateMaxAddress;
- }
-
- Status = gBS->AllocatePages (Type, MemoryType, Pages, &PhysicalAddress);
- if (EFI_ERROR (Status)) {
- REPORT_STATUS_CODE (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR
- );
- return Status;
- }
-
- *HostAddress = (VOID *) (UINTN) PhysicalAddress;
- return Status;
-}
-
-/**
- Frees memory that was allocated with EFI_ISA_IO.AllocateBuffer().
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Pages The number of pages to free.
- @param[in] HostAddress The base address of the allocated range.
-
- @retval EFI_SUCCESS The requested memory pages were freed.
- @retval EFI_INVALID_PARAMETER The memory was not allocated with EFI_ISA_IO.AllocateBufer().
-**/
-EFI_STATUS
-EFIAPI
-IsaIoFreeBuffer (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN UINTN Pages,
- IN VOID *HostAddress
- )
-{
- EFI_STATUS Status;
-
- //
- // Set Feature Flag PcdIsaBusOnlySupportSlaveDma to FALSE to disable support for
- // ISA Bus Master.
- // Or unset Feature Flag PcdIsaBusSupportDma to disable support for ISA DMA.
- //
- if (((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_DMA) == 0) ||
- ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_ONLY_SUPPORT_SLAVE_DMA) != 0)) {
- return EFI_UNSUPPORTED;
- }
-
- Status = gBS->FreePages (
- (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress,
- Pages
- );
- if (EFI_ERROR (Status)) {
- REPORT_STATUS_CODE (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR
- );
- }
-
- return Status;
-}
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/ComponentName.c b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/ComponentName.c deleted file mode 100644 index f3341ed884..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/ComponentName.c +++ /dev/null @@ -1,249 +0,0 @@ -/** @file
- UEFI Component Name(2) protocol implementation for Isa Floppy driver.
-
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
-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 "IsaFloppy.h"
-
-//
-// EFI Component Name Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIsaFloppyComponentName = {
- IsaFloppyComponentNameGetDriverName,
- IsaFloppyComponentNameGetControllerName,
- "eng"
-};
-
-//
-// EFI Component Name 2 Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIsaFloppyComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IsaFloppyComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IsaFloppyComponentNameGetControllerName,
- "en"
-};
-
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIsaFloppyDriverNameTable[] = {
- {
- "eng;en",
- L"ISA Floppy Driver"
- },
- {
- NULL,
- NULL
- }
-};
-
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
- @param[in] Language A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
- @param[out] DriverName A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-**/
-EFI_STATUS
-EFIAPI
-IsaFloppyComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- )
-{
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mIsaFloppyDriverNameTable,
- DriverName,
- (BOOLEAN)(This == &gIsaFloppyComponentName)
- );
-}
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
- @param[in] ControllerHandle The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
- @param[in] ChildHandle The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
- @param[in] Language A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
- @param[out] ControllerName A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
- @retval EFI_INVALID_PARAMETER Language is NULL.
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-**/
-EFI_STATUS
-EFIAPI
-IsaFloppyComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- )
-{
- EFI_STATUS Status;
- EFI_BLOCK_IO_PROTOCOL *BlkIo;
- FDC_BLK_IO_DEV *FdcDev;
-
- if (Language == NULL || ControllerName == NULL) {
- return EFI_INVALID_PARAMETER;
- }
- //
- // This is a device driver, so ChildHandle must be NULL.
- //
- if (ChildHandle != NULL) {
- return EFI_UNSUPPORTED;
- }
-
- //
- // Check if this driver is currently managing ControllerHandle
- //
- Status = EfiTestManagedDevice (
- ControllerHandle,
- gFdcControllerDriver.DriverBindingHandle,
- &gEfiIsaIoProtocolGuid
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Get the device context
- //
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiBlockIoProtocolGuid,
- (VOID **) &BlkIo,
- gFdcControllerDriver.DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- FdcDev = FDD_BLK_IO_FROM_THIS (BlkIo);
-
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- FdcDev->ControllerNameTable,
- ControllerName,
- (BOOLEAN)(This == &gIsaFloppyComponentName)
- );
-}
-
-/**
- Add the component name for the floppy device
-
- @param[in] FdcDev A pointer to the FDC_BLK_IO_DEV instance.
-
-**/
-VOID
-AddName (
- IN FDC_BLK_IO_DEV *FdcDev
- )
-{
- CHAR16 FloppyDriveName[FLOPPY_DRIVE_NAME_LEN + 1];
-
- if (!(FeaturePcdGet(PcdComponentNameDisable) && FeaturePcdGet(PcdComponentName2Disable))) {
- StrCpyS (FloppyDriveName, FLOPPY_DRIVE_NAME_LEN + 1, FLOPPY_DRIVE_NAME);
- FloppyDriveName[FLOPPY_DRIVE_NAME_LEN - 1] = (CHAR16) (L'0' + FdcDev->Disk);
-
- AddUnicodeString2 (
- "eng",
- gIsaFloppyComponentName.SupportedLanguages,
- &FdcDev->ControllerNameTable,
- FloppyDriveName,
- TRUE
- );
- AddUnicodeString2 (
- "en",
- gIsaFloppyComponentName2.SupportedLanguages,
- &FdcDev->ControllerNameTable,
- FloppyDriveName,
- FALSE
- );
- }
-}
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/ComponentName.h b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/ComponentName.h deleted file mode 100644 index a136022ceb..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/ComponentName.h +++ /dev/null @@ -1,146 +0,0 @@ -/** @file
- Header file for implementation of UEFI Component Name(2) protocol.
-
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
-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.
-
-**/
-
-#ifndef _COMPONENT_NAME_H_
-#define _COMPONENT_NAME_H_
-
-#define FLOPPY_DRIVE_NAME L"ISA Floppy Drive # "
-#define FLOPPY_DRIVE_NAME_LEN ((sizeof (FLOPPY_DRIVE_NAME) / sizeof (CHAR16)) - 1)
-
-extern EFI_COMPONENT_NAME_PROTOCOL gIsaFloppyComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gIsaFloppyComponentName2;
-
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
- @param[in] Language A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
- @param[out] DriverName A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-**/
-EFI_STATUS
-EFIAPI
-IsaFloppyComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- );
-
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
- @param[in] ControllerHandle The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
- @param[in] ChildHandle The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
- @param[in] Language A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
- @param[out] ControllerName A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
- @retval EFI_INVALID_PARAMETER Language is NULL.
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-**/
-EFI_STATUS
-EFIAPI
-IsaFloppyComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- );
-
-
-/**
- Add the component name for the floppy device
-
- @param[in] FdcDev A pointer to the FDC_BLK_IO_DEV instance.
-
-**/
-VOID
-AddName (
- IN FDC_BLK_IO_DEV *FdcDev
- );
-
-#endif
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.c b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.c deleted file mode 100644 index 65555d3eb1..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.c +++ /dev/null @@ -1,515 +0,0 @@ -/** @file
- ISA Floppy Disk UEFI Driver conforming to the UEFI driver model
-
- 1. Support two types diskette drive
- 1.44M drive and 2.88M drive (and now only support 1.44M)
- 2. Support two diskette drives per floppy disk controller
- 3. Use DMA channel 2 to transfer data
- 4. Do not use interrupt
- 5. Support diskette change line signal and write protect
-
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
-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 "IsaFloppy.h"
-
-LIST_ENTRY mControllerHead = INITIALIZE_LIST_HEAD_VARIABLE (mControllerHead);
-
-//
-// ISA Floppy Driver Binding Protocol
-//
-EFI_DRIVER_BINDING_PROTOCOL gFdcControllerDriver = {
- FdcControllerDriverSupported,
- FdcControllerDriverStart,
- FdcControllerDriverStop,
- 0xa,
- NULL,
- NULL
-};
-
-
-/**
- The main Entry Point for this driver.
-
- @param[in] ImageHandle The firmware allocated handle for the EFI image.
- @param[in] SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The entry point is executed successfully.
- @retval other Some error occurs when executing this entry point.
-**/
-EFI_STATUS
-EFIAPI
-InitializeIsaFloppy(
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- //
- // Install driver model protocol(s).
- //
- Status = EfiLibInstallDriverBindingComponentName2 (
- ImageHandle,
- SystemTable,
- &gFdcControllerDriver,
- ImageHandle,
- &gIsaFloppyComponentName,
- &gIsaFloppyComponentName2
- );
- ASSERT_EFI_ERROR (Status);
-
- return Status;
-}
-
-/**
- Test if the controller is a floppy disk drive device
-
- @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param[in] Controller The handle of the controller to test.
- @param[in] RemainingDevicePath A pointer to the remaining portion of a device path.
-
- @retval EFI_SUCCESS The device is supported by this driver.
- @retval EFI_ALREADY_STARTED The device is already being managed by this driver.
- @retval EFI_ACCESS_DENIED The device is already being managed by a different driver
- or an application that requires exclusive access.
- @retval EFI_UNSUPPORTED The device is is not supported by this driver.
-**/
-EFI_STATUS
-EFIAPI
-FdcControllerDriverSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- EFI_STATUS Status;
- EFI_ISA_IO_PROTOCOL *IsaIo;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
-
- //
- // Ignore the parameter RemainingDevicePath because this is a device driver.
- //
-
- //
- // Open the device path protocol
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- //
- // Open the ISA I/O Protocol
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- (VOID **) &IsaIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Use the ISA I/O Protocol to see if Controller is a floppy disk drive device
- //
- Status = EFI_SUCCESS;
- if (IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x604)) {
- Status = EFI_UNSUPPORTED;
- }
- //
- // Close the ISA I/O Protocol
- //
- gBS->CloseProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- return Status;
-}
-
-/**
- Start this driver on Controller.
-
- @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param[in] ControllerHandle The handle of the controller to start. This handle
- must support a protocol interface that supplies
- an I/O abstraction to the driver.
- @param[in] RemainingDevicePath A pointer to the remaining portion of a device path.
- This parameter is ignored by device drivers, and is optional for bus drivers.
-
- @retval EFI_SUCCESS The device was started.
- @retval EFI_DEVICE_ERROR The device could not be started due to a device error.
- Currently not implemented.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
- @retval Others The driver failded to start the device.
-**/
-EFI_STATUS
-EFIAPI
-FdcControllerDriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- EFI_STATUS Status;
- FDC_BLK_IO_DEV *FdcDev;
- EFI_ISA_IO_PROTOCOL *IsaIo;
- UINTN Index;
- LIST_ENTRY *List;
- BOOLEAN Found;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
-
- FdcDev = NULL;
- IsaIo = NULL;
-
- //
- // Open the device path protocol
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Report enable progress code
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_PC_ENABLE,
- ParentDevicePath
- );
-
- //
- // Open the ISA I/O Protocol
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- (VOID **) &IsaIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- goto Done;
- }
- //
- // Allocate the floppy device's Device structure
- //
- FdcDev = AllocateZeroPool (sizeof (FDC_BLK_IO_DEV));
- if (FdcDev == NULL) {
- goto Done;
- }
- //
- // Initialize the floppy device's device structure
- //
- FdcDev->Signature = FDC_BLK_IO_DEV_SIGNATURE;
- FdcDev->Handle = Controller;
- FdcDev->IsaIo = IsaIo;
- FdcDev->Disk = (EFI_FDC_DISK) IsaIo->ResourceList->Device.UID;
- FdcDev->Cache = NULL;
- FdcDev->Event = NULL;
- FdcDev->ControllerState = NULL;
- FdcDev->DevicePath = ParentDevicePath;
-
- FdcDev->ControllerNameTable = NULL;
- AddName (FdcDev);
-
- //
- // Look up the base address of the Floppy Disk Controller which controls this floppy device
- //
- for (Index = 0; FdcDev->IsaIo->ResourceList->ResourceItem[Index].Type != EfiIsaAcpiResourceEndOfList; Index++) {
- if (FdcDev->IsaIo->ResourceList->ResourceItem[Index].Type == EfiIsaAcpiResourceIo) {
- FdcDev->BaseAddress = (UINT16) FdcDev->IsaIo->ResourceList->ResourceItem[Index].StartRange;
- }
- }
- //
- // Maintain the list of floppy disk controllers
- //
- Found = FALSE;
- List = mControllerHead.ForwardLink;
- while (List != &mControllerHead) {
- FdcDev->ControllerState = FLOPPY_CONTROLLER_FROM_LIST_ENTRY (List);
- if (FdcDev->BaseAddress == FdcDev->ControllerState->BaseAddress) {
- Found = TRUE;
- break;
- }
-
- List = List->ForwardLink;
- }
-
- if (!Found) {
- //
- // A new floppy disk controller controlling this floppy disk drive is found
- //
- FdcDev->ControllerState = AllocatePool (sizeof (FLOPPY_CONTROLLER_CONTEXT));
- if (FdcDev->ControllerState == NULL) {
- goto Done;
- }
-
- FdcDev->ControllerState->Signature = FLOPPY_CONTROLLER_CONTEXT_SIGNATURE;
- FdcDev->ControllerState->FddResetPerformed = FALSE;
- FdcDev->ControllerState->NeedRecalibrate = FALSE;
- FdcDev->ControllerState->BaseAddress = FdcDev->BaseAddress;
- FdcDev->ControllerState->NumberOfDrive = 0;
-
- InsertTailList (&mControllerHead, &FdcDev->ControllerState->Link);
- }
- //
- // Create a timer event for each floppy disk drive device.
- // This timer event is used to control the motor on and off
- //
- Status = gBS->CreateEvent (
- EVT_TIMER | EVT_NOTIFY_SIGNAL,
- TPL_NOTIFY,
- FddTimerProc,
- FdcDev,
- &FdcDev->Event
- );
- if (EFI_ERROR (Status)) {
- goto Done;
- }
- //
- // Reset the Floppy Disk Controller
- //
- if (!FdcDev->ControllerState->FddResetPerformed) {
- FdcDev->ControllerState->FddResetPerformed = TRUE;
- FdcDev->ControllerState->FddResetStatus = FddReset (FdcDev);
- }
-
- if (EFI_ERROR (FdcDev->ControllerState->FddResetStatus)) {
- Status = EFI_DEVICE_ERROR;
- goto Done;
- }
-
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_PC_PRESENCE_DETECT,
- ParentDevicePath
- );
-
- //
- // Discover the Floppy Drive
- //
- Status = DiscoverFddDevice (FdcDev);
- if (EFI_ERROR (Status)) {
- Status = EFI_DEVICE_ERROR;
- goto Done;
- }
- //
- // Install protocol interfaces for the serial device.
- //
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Controller,
- &gEfiBlockIoProtocolGuid,
- &FdcDev->BlkIo,
- NULL
- );
- if (!EFI_ERROR (Status)) {
- FdcDev->ControllerState->NumberOfDrive++;
- }
-
-Done:
- if (EFI_ERROR (Status)) {
-
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_EC_CONTROLLER_ERROR,
- ParentDevicePath
- );
-
- //
- // If a floppy drive device structure was allocated, then free it
- //
- if (FdcDev != NULL) {
- if (FdcDev->Event != NULL) {
- //
- // Close the event for turning the motor off
- //
- gBS->CloseEvent (FdcDev->Event);
- }
-
- FreeUnicodeStringTable (FdcDev->ControllerNameTable);
- FreePool (FdcDev);
- }
-
- //
- // Close the ISA I/O Protocol
- //
- if (IsaIo != NULL) {
- gBS->CloseProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- }
-
- //
- // Close the device path protocol
- //
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- }
-
- return Status;
-}
-
-/**
- Stop this driver on ControllerHandle.
-
- @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param[in] ControllerHandle A handle to the device being stopped. The handle must
- support a bus specific I/O protocol for the driver
- to use to stop the device.
- @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
- @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
- if NumberOfChildren is 0.
-
- @retval EFI_SUCCESS The device was stopped.
- @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
-**/
-EFI_STATUS
-EFIAPI
-FdcControllerDriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- )
-{
- EFI_STATUS Status;
- EFI_BLOCK_IO_PROTOCOL *BlkIo;
- FDC_BLK_IO_DEV *FdcDev;
-
- //
- // Ignore NumberOfChildren since this is a device driver
- //
-
- //
- // Get the Block I/O Protocol on Controller
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiBlockIoProtocolGuid,
- (VOID **) &BlkIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Get the floppy drive device's Device structure
- //
- FdcDev = FDD_BLK_IO_FROM_THIS (BlkIo);
-
- //
- // Report disable progress code
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_PC_DISABLE,
- FdcDev->DevicePath
- );
-
- //
- // Uninstall the Block I/O Protocol
- //
- Status = gBS->UninstallProtocolInterface (
- Controller,
- &gEfiBlockIoProtocolGuid,
- &FdcDev->BlkIo
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Close the event for turning the motor off
- //
- gBS->CloseEvent (FdcDev->Event);
-
- //
- // Turn the motor off on the floppy drive device
- //
- FddTimerProc (FdcDev->Event, FdcDev);
-
- //
- // Close the device path protocol
- //
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- //
- // Close the ISA I/O Protocol
- //
- gBS->CloseProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- //
- // Free the controller list if needed
- //
- FdcDev->ControllerState->NumberOfDrive--;
-
- //
- // Free the cache if one was allocated
- //
- FdcFreeCache (FdcDev);
-
- //
- // Free the floppy drive device's device structure
- //
- FreeUnicodeStringTable (FdcDev->ControllerNameTable);
- FreePool (FdcDev);
-
- return EFI_SUCCESS;
-}
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.h b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.h deleted file mode 100644 index 30a2d7bf0c..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.h +++ /dev/null @@ -1,1093 +0,0 @@ -/** @file
- Include file for ISA Floppy Driver
-
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
-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.
-
-**/
-
-#ifndef _ISA_FLOPPY_H_
-#define _ISA_FLOPPY_H_
-
-#include <Uefi.h>
-
-#include <Protocol/BlockIo.h>
-#include <Protocol/IsaIo.h>
-#include <Protocol/DevicePath.h>
-#include <Guid/StatusCodeDataTypeId.h>
-
-#include <Library/TimerLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/BaseLib.h>
-#include <Library/UefiLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/ReportStatusCodeLib.h>
-#include <Library/PcdLib.h>
-
-extern EFI_DRIVER_BINDING_PROTOCOL gFdcControllerDriver;
-
-#define STALL_1_SECOND 1000000
-#define STALL_1_MSECOND 1000
-
-#define DATA_IN 1
-#define DATA_OUT 0
-#define READ 0
-#define WRITE 1
-
-//
-// Internal Data Structures
-//
-#define FDC_BLK_IO_DEV_SIGNATURE SIGNATURE_32 ('F', 'B', 'I', 'O')
-#define FLOPPY_CONTROLLER_CONTEXT_SIGNATURE SIGNATURE_32 ('F', 'D', 'C', 'C')
-
-typedef enum {
- FdcDisk0 = 0,
- FdcDisk1 = 1,
- FdcMaxDisk = 2
-} EFI_FDC_DISK;
-
-typedef struct {
- UINT32 Signature;
- LIST_ENTRY Link;
- BOOLEAN FddResetPerformed;
- EFI_STATUS FddResetStatus;
- BOOLEAN NeedRecalibrate;
- UINT8 NumberOfDrive;
- UINT16 BaseAddress;
-} FLOPPY_CONTROLLER_CONTEXT;
-
-typedef struct {
- UINTN Signature;
- EFI_HANDLE Handle;
- EFI_BLOCK_IO_PROTOCOL BlkIo;
- EFI_BLOCK_IO_MEDIA BlkMedia;
-
- EFI_ISA_IO_PROTOCOL *IsaIo;
-
- UINT16 BaseAddress;
-
- EFI_FDC_DISK Disk;
- UINT8 PresentCylinderNumber;
- UINT8 *Cache;
-
- EFI_EVENT Event;
- EFI_UNICODE_STRING_TABLE *ControllerNameTable;
- FLOPPY_CONTROLLER_CONTEXT *ControllerState;
-
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
-} FDC_BLK_IO_DEV;
-
-#include "ComponentName.h"
-
-#define FDD_BLK_IO_FROM_THIS(a) CR (a, FDC_BLK_IO_DEV, BlkIo, FDC_BLK_IO_DEV_SIGNATURE)
-#define FLOPPY_CONTROLLER_FROM_LIST_ENTRY(a) \
- CR (a, \
- FLOPPY_CONTROLLER_CONTEXT, \
- Link, \
- FLOPPY_CONTROLLER_CONTEXT_SIGNATURE \
- )
-
-#define DISK_1440K_EOT 0x12
-#define DISK_1440K_GPL 0x1b
-#define DISK_1440K_DTL 0xff
-#define DISK_1440K_NUMBER 0x02
-#define DISK_1440K_MAXTRACKNUM 0x4f
-#define DISK_1440K_BYTEPERSECTOR 512
-
-typedef struct {
- UINT8 CommandCode;
- UINT8 DiskHeadSel;
- UINT8 Cylinder;
- UINT8 Head;
- UINT8 Sector;
- UINT8 Number;
- UINT8 EndOfTrack;
- UINT8 GapLength;
- UINT8 DataLength;
-} FDD_COMMAND_PACKET1;
-
-typedef struct {
- UINT8 CommandCode;
- UINT8 DiskHeadSel;
-} FDD_COMMAND_PACKET2;
-
-typedef struct {
- UINT8 CommandCode;
- UINT8 SrtHut;
- UINT8 HltNd;
-} FDD_SPECIFY_CMD;
-
-typedef struct {
- UINT8 CommandCode;
- UINT8 DiskHeadSel;
- UINT8 NewCylinder;
-} FDD_SEEK_CMD;
-
-typedef struct {
- UINT8 CommandCode;
- UINT8 DiskHeadSel;
- UINT8 Cylinder;
- UINT8 Head;
- UINT8 Sector;
- UINT8 EndOfTrack;
- UINT8 GapLength;
- UINT8 ScanTestPause;
-} FDD_SCAN_CMD;
-
-typedef struct {
- UINT8 Status0;
- UINT8 Status1;
- UINT8 Status2;
- UINT8 Cylinder;
- UINT8 Head;
- UINT8 Sector;
- UINT8 Number;
-} FDD_RESULT_PACKET;
-
-//
-// FDC Registers
-//
-//
-// Digital Output Register address offset
-//
-#define FDC_REGISTER_DOR 2
-
-//
-// Main Status Register address offset
-//
-#define FDC_REGISTER_MSR 4
-
-//
-// Data Register address offset
-//
-#define FDC_REGISTER_DTR 5
-
-//
-// Configuration Control Register(data rate select) address offset
-//
-#define FDC_REGISTER_CCR 7
-
-//
-// Digital Input Register(diskchange) address offset
-//
-#define FDC_REGISTER_DIR 7
-
-
-//
-// FDC Register Bit Definitions
-//
-//
-// Digital Out Register(WO)
-//
-//
-// Select Drive: 0=A 1=B
-//
-#define SELECT_DRV BIT0
-
-//
-// Reset FDC
-//
-#define RESET_FDC BIT2
-
-//
-// Enable Int & DMA
-//
-#define INT_DMA_ENABLE BIT3
-
-//
-// Turn On Drive A Motor
-//
-#define DRVA_MOTOR_ON BIT4
-
-//
-// Turn On Drive B Motor
-//
-#define DRVB_MOTOR_ON BIT5
-
-//
-// Main Status Register(RO)
-//
-//
-// Drive A Busy
-//
-#define MSR_DAB BIT0
-
-//
-// Drive B Busy
-//
-#define MSR_DBB BIT1
-
-//
-// FDC Busy
-//
-#define MSR_CB BIT4
-
-//
-// Non-DMA Mode
-//
-#define MSR_NDM BIT5
-
-//
-// Data Input/Output
-//
-#define MSR_DIO BIT6
-
-//
-// Request For Master
-//
-#define MSR_RQM BIT7
-
-//
-// Configuration Control Register(WO)
-//
-//
-// Data Rate select
-//
-#define CCR_DRC (BIT0 | BIT1)
-
-//
-// Digital Input Register(RO)
-//
-//
-// Disk change line
-//
-#define DIR_DCL BIT7
-//
-// #define CCR_DCL BIT7 // Diskette change
-//
-// 500K
-//
-#define DRC_500KBS 0x0
-
-//
-// 300K
-//
-#define DRC_300KBS 0x01
-
-//
-// 250K
-//
-#define DRC_250KBS 0x02
-
-//
-// FDC Command Code
-//
-#define READ_DATA_CMD 0x06
-#define WRITE_DATA_CMD 0x05
-#define WRITE_DEL_DATA_CMD 0x09
-#define READ_DEL_DATA_CMD 0x0C
-#define READ_TRACK_CMD 0x02
-#define READ_ID_CMD 0x0A
-#define FORMAT_TRACK_CMD 0x0D
-#define SCAN_EQU_CMD 0x11
-#define SCAN_LOW_EQU_CMD 0x19
-#define SCAN_HIGH_EQU_CMD 0x1D
-#define SEEK_CMD 0x0F
-#define RECALIBRATE_CMD 0x07
-#define SENSE_INT_STATUS_CMD 0x08
-#define SPECIFY_CMD 0x03
-#define SENSE_DRV_STATUS_CMD 0x04
-
-//
-// CMD_MT: Multi_Track Selector
-// when set , this flag selects the multi-track operating mode.
-// In this mode, the FDC treats a complete cylinder under head0 and 1
-// as a single track
-//
-#define CMD_MT BIT7
-
-//
-// CMD_MFM: MFM/FM Mode Selector
-// A one selects the double density(MFM) mode
-// A zero selects single density (FM) mode
-//
-#define CMD_MFM BIT6
-
-//
-// CMD_SK: Skip Flag
-// When set to 1, sectors containing a deleted data address mark will
-// automatically be skipped during the execution of Read Data.
-// When set to 0, the sector is read or written the same as the read and
-// write commands.
-//
-#define CMD_SK BIT5
-
-//
-// FDC Status Register Bit Definitions
-//
-//
-// Status Register 0
-//
-//
-// Interrupt Code
-//
-#define STS0_IC (BIT7 | BIT6)
-
-//
-// Seek End: the FDC completed a seek or recalibrate command
-//
-#define STS0_SE BIT5
-
-//
-// Equipment Check
-//
-#define STS0_EC BIT4
-
-//
-// Not Ready(unused), this bit is always 0
-//
-#define STS0_NR BIT3
-
-//
-// Head Address: the current head address
-//
-#define STS0_HA BIT2
-
-//
-// STS0_US1 & STS0_US0: Drive Select(the current selected drive)
-//
-//
-// Unit Select1
-//
-#define STS0_US1 BIT1
-
-//
-// Unit Select0
-//
-#define STS0_US0 BIT0
-
-//
-// Status Register 1
-//
-//
-// End of Cylinder
-//
-#define STS1_EN BIT7
-
-//
-// BIT6 is unused
-//
-//
-// Data Error: The FDC detected a CRC error in either the ID field or
-// data field of a sector
-//
-#define STS1_DE BIT5
-
-//
-// Overrun/Underrun: Becomes set if FDC does not receive CPU or DMA service
-// within the required time interval
-//
-#define STS1_OR BIT4
-
-//
-// BIT3 is unused
-//
-//
-// No data
-//
-#define STS1_ND BIT2
-
-//
-// Not Writable
-//
-#define STS1_NW BIT1
-
-//
-// Missing Address Mark
-//
-#define STS1_MA BIT0
-
-//
-// Control Mark
-//
-#define STS2_CM BIT6
-
-//
-// Data Error in Data Field: The FDC detected a CRC error in the data field
-//
-#define STS2_DD BIT5
-
-//
-// Wrong Cylinder: The track address from sector ID field is different from
-// the track address maintained inside FDC
-//
-#define STS2_WC BIT4
-
-//
-// Bad Cylinder
-//
-#define STS2_BC BIT1
-
-//
-// Missing Address Mark in Data Field
-//
-#define STS2_MD BIT0
-
-//
-// Write Protected
-//
-#define STS3_WP BIT6
-
-//
-// Track 0
-//
-#define STS3_T0 BIT4
-
-//
-// Head Address
-//
-#define STS3_HD BIT2
-
-//
-// STS3_US1 & STS3_US0 : Drive Select
-//
-#define STS3_US1 BIT1
-#define STS3_US0 BIT0
-
-//
-// Status Register 0 Interrupt Code Description
-//
-//
-// Normal Termination of Command
-//
-#define IC_NT 0x0
-
-//
-// Abnormal Termination of Command
-//
-#define IC_AT 0x40
-
-//
-// Invalid Command
-//
-#define IC_IC 0x80
-
-//
-// Abnormal Termination caused by Polling
-//
-#define IC_ATRC 0xC0
-
-//
-// EFI Driver Binding Protocol Functions
-//
-
-/**
- Test controller is a floppy disk drive device
-
- @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param[in] Controller The handle of the controller to test.
- @param[in] RemainingDevicePath A pointer to the remaining portion of a device path.
-
- @retval EFI_SUCCESS The device is supported by this driver.
- @retval EFI_ALREADY_STARTED The device is already being managed by this driver.
- @retval EFI_ACCESS_DENIED The device is already being managed by a different driver
- or an application that requires exclusive access.
-**/
-EFI_STATUS
-EFIAPI
-FdcControllerDriverSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-/**
- Start this driver on Controller.
-
- @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param[in] ControllerHandle The handle of the controller to start. This handle
- must support a protocol interface that supplies
- an I/O abstraction to the driver.
- @param[in] RemainingDevicePath A pointer to the remaining portion of a device path.
- This parameter is ignored by device drivers, and is optional for bus drivers.
-
- @retval EFI_SUCCESS The device was started.
- @retval EFI_DEVICE_ERROR The device could not be started due to a device error.
- Currently not implemented.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
- @retval Others The driver failded to start the device.
-**/
-EFI_STATUS
-EFIAPI
-FdcControllerDriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-/**
- Stop this driver on ControllerHandle.
-
- @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param[in] ControllerHandle A handle to the device being stopped. The handle must
- support a bus specific I/O protocol for the driver
- to use to stop the device.
- @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
- @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
- if NumberOfChildren is 0.
-
- @retval EFI_SUCCESS The device was stopped.
- @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
-**/
-EFI_STATUS
-EFIAPI
-FdcControllerDriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- );
-
-//
-// EFI Block I/O Protocol Functions
-//
-
-/**
- Reset the Floppy Logic Drive, call the FddReset function.
-
- @param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface
- @param ExtendedVerification BOOLEAN: Indicate that the driver may perform a more
- exhaustive verification operation of the device during
- reset, now this par is ignored in this driver
- @retval EFI_SUCCESS: The Floppy Logic Drive is reset
- @retval EFI_DEVICE_ERROR: The Floppy Logic Drive is not functioning correctly
- and can not be reset
-
-**/
-EFI_STATUS
-EFIAPI
-FdcReset (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- );
-
-/**
- Flush block via fdd controller.
-
- @param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface
- @return EFI_SUCCESS
-
-**/
-EFI_STATUS
-EFIAPI
-FddFlushBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This
- );
-
-/**
- Read the requested number of blocks from the device.
-
- @param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface
- @param MediaId UINT32: The media id that the read request is for
- @param Lba EFI_LBA: The starting logic block address to read from on the device
- @param BufferSize UINTN: The size of the Buffer in bytes
- @param Buffer VOID *: A pointer to the destination buffer for the data
-
- @retval EFI_SUCCESS: The data was read correctly from the device
- @retval EFI_DEVICE_ERROR:The device reported an error while attempting to perform
- the read operation
- @retval EFI_NO_MEDIA: There is no media in the device
- @retval EFI_MEDIA_CHANGED: The MediaId is not for the current media
- @retval EFI_BAD_BUFFER_SIZE: The BufferSize parameter is not a multiple of the
- intrinsic block size of the device
- @retval EFI_INVALID_PARAMETER:The read request contains LBAs that are not valid,
- or the buffer is not on proper alignment
-
-**/
-EFI_STATUS
-EFIAPI
-FddReadBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- );
-
-/**
- Write a specified number of blocks to the device.
-
- @param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface
- @param MediaId UINT32: The media id that the write request is for
- @param Lba EFI_LBA: The starting logic block address to be written
- @param BufferSize UINTN: The size in bytes in Buffer
- @param Buffer VOID *: A pointer to the source buffer for the data
-
- @retval EFI_SUCCESS: The data were written correctly to the device
- @retval EFI_WRITE_PROTECTED: The device can not be written to
- @retval EFI_NO_MEDIA: There is no media in the device
- @retval EFI_MEDIA_CHANGED: The MediaId is not for the current media
- @retval EFI_DEVICE_ERROR: The device reported an error while attempting to perform
- the write operation
- @retval EFI_BAD_BUFFER_SIZE: The BufferSize parameter is not a multiple of the
- intrinsic block size of the device
- @retval EFI_INVALID_PARAMETER:The write request contains LBAs that are not valid,
- or the buffer is not on proper alignment
-**/
-EFI_STATUS
-EFIAPI
-FddWriteBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- IN VOID *Buffer
- );
-
-//
-// Prototypes of internal functions
-//
-/**
-
- Detect the floppy drive is presented or not.
-
- @param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV
- @retval EFI_SUCCESS Drive is presented
- @retval EFI_NOT_FOUND Drive is not presented
-
-**/
-EFI_STATUS
-DiscoverFddDevice (
- IN FDC_BLK_IO_DEV *FdcDev
- );
-
-/**
-
- Do recalibrate and see the drive is presented or not.
- Set the media parameters.
-
- @param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV
- @return the drive is presented or not
-
-**/
-EFI_STATUS
-FddIdentify (
- IN FDC_BLK_IO_DEV *FdcDev
- );
-
-/**
-
- Reset the Floppy Logic Drive.
-
- @param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV
-
- @retval EFI_SUCCESS: The Floppy Logic Drive is reset
- @retval EFI_DEVICE_ERROR: The Floppy Logic Drive is not functioning correctly and
- can not be reset
-
-**/
-EFI_STATUS
-FddReset (
- IN FDC_BLK_IO_DEV *FdcDev
- );
-
-/**
-
- Turn the drive's motor on.
- The drive's motor must be on before any command can be executed.
-
- @param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV
-
- @retval EFI_SUCCESS: Turn the drive's motor on successfully
- @retval EFI_DEVICE_ERROR: The drive is busy, so can not turn motor on
- @retval EFI_INVALID_PARAMETER: Fail to Set timer(Cancel timer)
-
-**/
-EFI_STATUS
-MotorOn (
- IN FDC_BLK_IO_DEV *FdcDev
- );
-
-/**
-
- Set a Timer and when Timer goes off, turn the motor off.
-
-
- @param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV
-
- @retval EFI_SUCCESS: Set the Timer successfully
- @retval EFI_INVALID_PARAMETER: Fail to Set the timer
-
-**/
-EFI_STATUS
-MotorOff (
- IN FDC_BLK_IO_DEV *FdcDev
- );
-
-/**
- Detect the disk in the drive is changed or not.
-
-
- @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
-
- @retval EFI_SUCCESS: No disk media change
- @retval EFI_DEVICE_ERROR: Fail to do the recalibrate or seek operation
- @retval EFI_NO_MEDIA: No disk in the drive
- @retval EFI_MEDIA_CHANGED: There is a new disk in the drive
-**/
-EFI_STATUS
-DisketChanged (
- IN FDC_BLK_IO_DEV *FdcDev
- );
-
-/**
- Do the Specify command, this command sets DMA operation
- and the initial values for each of the three internal
- times: HUT, SRT and HLT.
-
- @param FdcDev Pointer to instance of FDC_BLK_IO_DEV
-
- @retval EFI_SUCCESS: Execute the Specify command successfully
- @retval EFI_DEVICE_ERROR: Fail to execute the command
-
-**/
-EFI_STATUS
-Specify (
- IN FDC_BLK_IO_DEV *FdcDev
- );
-
-/**
- Set the head of floppy drive to track 0.
-
- @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
- @retval EFI_SUCCESS: Execute the Recalibrate operation successfully
- @retval EFI_DEVICE_ERROR: Fail to execute the Recalibrate operation
-
-**/
-EFI_STATUS
-Recalibrate (
- IN FDC_BLK_IO_DEV *FdcDev
- );
-
-/**
- Set the head of floppy drive to the new cylinder.
-
- @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
- @param Lba EFI_LBA : The logic block address want to seek
-
- @retval EFI_SUCCESS: Execute the Seek operation successfully
- @retval EFI_DEVICE_ERROR: Fail to execute the Seek operation
-
-**/
-EFI_STATUS
-Seek (
- IN FDC_BLK_IO_DEV *FdcDev,
- IN EFI_LBA Lba
- );
-
-/**
- Do the Sense Interrupt Status command, this command resets the interrupt signal.
-
- @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
- @param StatusRegister0 UINT8 *: Be used to save Status Register 0 read from FDC
- @param PresentCylinderNumber UINT8 *: Be used to save present cylinder number
- read from FDC
-
- @retval EFI_SUCCESS: Execute the Sense Interrupt Status command successfully
- @retval EFI_DEVICE_ERROR: Fail to execute the command
-
-**/
-EFI_STATUS
-SenseIntStatus (
- IN FDC_BLK_IO_DEV *FdcDev,
- IN OUT UINT8 *StatusRegister0,
- IN OUT UINT8 *PresentCylinderNumber
- );
-
-/**
- Do the Sense Drive Status command.
-
- @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
- @param Lba EFI_LBA : Logic block address
-
- @retval EFI_SUCCESS: Execute the Sense Drive Status command successfully
- @retval EFI_DEVICE_ERROR: Fail to execute the command
- @retval EFI_WRITE_PROTECTED:The disk is write protected
-
-**/
-EFI_STATUS
-SenseDrvStatus (
- IN FDC_BLK_IO_DEV *FdcDev,
- IN EFI_LBA Lba
- );
-
-/**
- Update the disk media properties and if necessary reinstall Block I/O interface.
-
- @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
-
- @retval EFI_SUCCESS: Do the operation successfully
- @retval EFI_DEVICE_ERROR: Fail to the operation
-
-**/
-EFI_STATUS
-DetectMedia (
- IN FDC_BLK_IO_DEV *FdcDev
- );
-
-/**
- Set the data rate and so on.
-
- @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
-
- @retval EFI_SUCCESS success to set the data rate
-**/
-EFI_STATUS
-Setup (
- IN FDC_BLK_IO_DEV *FdcDev
- );
-
-/**
- Read or Write a number of blocks in the same cylinder.
-
- @param FdcDev A pointer to Data Structure FDC_BLK_IO_DEV
- @param HostAddress device address
- @param Lba The starting logic block address to read from on the device
- @param NumberOfBlocks The number of block wanted to be read or write
- @param Read Operation type: read or write
-
- @retval EFI_SUCCESS Success operate
-
-**/
-EFI_STATUS
-ReadWriteDataSector (
- IN FDC_BLK_IO_DEV *FdcDev,
- IN VOID *HostAddress,
- IN EFI_LBA Lba,
- IN UINTN NumberOfBlocks,
- IN BOOLEAN Read
- );
-
-/**
- Fill in FDD command's parameter.
-
- @param FdcDev Pointer to instance of FDC_BLK_IO_DEV
- @param Lba The starting logic block address to read from on the device
- @param Command FDD command
-
-**/
-VOID
-FillPara (
- IN FDC_BLK_IO_DEV *FdcDev,
- IN EFI_LBA Lba,
- IN FDD_COMMAND_PACKET1 *Command
- );
-
-/**
- Read result byte from Data Register of FDC.
-
- @param FdcDev Pointer to instance of FDC_BLK_IO_DEV
- @param Pointer Buffer to store the byte read from FDC
-
- @retval EFI_SUCCESS Read result byte from FDC successfully
- @retval EFI_DEVICE_ERROR The FDC is not ready to be read
-
-**/
-EFI_STATUS
-DataInByte (
- IN FDC_BLK_IO_DEV *FdcDev,
- OUT UINT8 *Pointer
- );
-
-/**
- Write command byte to Data Register of FDC.
-
- @param FdcDev Pointer to instance of FDC_BLK_IO_DEV
- @param Pointer Be used to save command byte written to FDC
-
- @retval EFI_SUCCESS: Write command byte to FDC successfully
- @retval EFI_DEVICE_ERROR: The FDC is not ready to be written
-
-**/
-EFI_STATUS
-DataOutByte (
- IN FDC_BLK_IO_DEV *FdcDev,
- IN UINT8 *Pointer
- );
-
-/**
- Detect the specified floppy logic drive is busy or not within a period of time.
-
- @param FdcDev Indicate it is drive A or drive B
- @param Timeout The time period for waiting
-
- @retval EFI_SUCCESS: The drive and command are not busy
- @retval EFI_TIMEOUT: The drive or command is still busy after a period time that
- set by Timeout
-
-**/
-EFI_STATUS
-FddWaitForBSYClear (
- IN FDC_BLK_IO_DEV *FdcDev,
- IN UINTN Timeout
- );
-
-/**
- Determine whether FDC is ready to write or read.
-
- @param FdcDev Pointer to instance of FDC_BLK_IO_DEV
- @param Dio BOOLEAN: Indicate the FDC is waiting to write or read
- @param Timeout The time period for waiting
-
- @retval EFI_SUCCESS: FDC is ready to write or read
- @retval EFI_NOT_READY: FDC is not ready within the specified time period
-
-**/
-EFI_STATUS
-FddDRQReady (
- IN FDC_BLK_IO_DEV *FdcDev,
- IN BOOLEAN Dio,
- IN UINTN Timeout
- );
-
-/**
- Set FDC control structure's attribute according to result.
-
- @param Result Point to result structure
- @param FdcDev FDC control structure
-
- @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value
- @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value
- @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value
- @retval EFI_SUCCESS - GC_TODO: Add description for return value
-
-**/
-EFI_STATUS
-CheckResult (
- IN FDD_RESULT_PACKET *Result,
- IN OUT FDC_BLK_IO_DEV *FdcDev
- );
-
-/**
- Check the drive status information.
-
- @param StatusRegister3 the value of Status Register 3
-
- @retval EFI_SUCCESS The disk is not write protected
- @retval EFI_WRITE_PROTECTED: The disk is write protected
-
-**/
-EFI_STATUS
-CheckStatus3 (
- IN UINT8 StatusRegister3
- );
-
-/**
- Calculate the number of block in the same cylinder according to Lba.
-
- @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
- @param Lba EFI_LBA: The starting logic block address
- @param NumberOfBlocks UINTN: The number of blocks
-
- @return The number of blocks in the same cylinder which the starting
- logic block address is Lba
-
-**/
-UINTN
-GetTransferBlockCount (
- IN FDC_BLK_IO_DEV *FdcDev,
- IN EFI_LBA Lba,
- IN UINTN NumberOfBlocks
- );
-
-/**
- When the Timer(2s) off, turn the drive's motor off.
-
- @param Event EFI_EVENT: Event(the timer) whose notification function is being
- invoked
- @param Context VOID *: Pointer to the notification function's context
-
-**/
-VOID
-EFIAPI
-FddTimerProc (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
-
-/**
- Read I/O port for FDC.
-
- @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
- @param Offset The offset address of port
-
-**/
-UINT8
-FdcReadPort (
- IN FDC_BLK_IO_DEV *FdcDev,
- IN UINT32 Offset
- );
-
-/**
- Write I/O port for FDC.
-
- @param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
- @param Offset The offset address of port
- @param Data Value written to port
-
-**/
-VOID
-FdcWritePort (
- IN FDC_BLK_IO_DEV *FdcDev,
- IN UINT32 Offset,
- IN UINT8 Data
- );
-
-/**
- Read or Write a number of blocks to floppy device.
-
- @param This Pointer to instance of EFI_BLOCK_IO_PROTOCOL
- @param MediaId The media id of read/write request
- @param Lba The starting logic block address to read from on the device
- @param BufferSize The size of the Buffer in bytes
- @param Operation - GC_TODO: add argument description
- @param Buffer - GC_TODO: add argument description
-
- @retval EFI_INVALID_PARAMETER - GC_TODO: Add description for return value
- @retval EFI_SUCCESS - GC_TODO: Add description for return value
- @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value
- @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value
- @retval EFI_NO_MEDIA - GC_TODO: Add description for return value
- @retval EFI_MEDIA_CHANGED - GC_TODO: Add description for return value
- @retval EFI_WRITE_PROTECTED - GC_TODO: Add description for return value
- @retval EFI_BAD_BUFFER_SIZE - GC_TODO: Add description for return value
- @retval EFI_INVALID_PARAMETER - GC_TODO: Add description for return value
- @retval EFI_INVALID_PARAMETER - GC_TODO: Add description for return value
- @retval EFI_SUCCESS - GC_TODO: Add description for return value
- @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value
- @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value
- @retval EFI_SUCCESS - GC_TODO: Add description for return value
-
-**/
-EFI_STATUS
-FddReadWriteBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- IN BOOLEAN Operation,
- OUT VOID *Buffer
- );
-
-/**
- Common interface for free cache.
-
- @param FdcDev Pointer of FDC_BLK_IO_DEV instance
-
-**/
-VOID
-FdcFreeCache (
- IN FDC_BLK_IO_DEV *FdcDev
- );
-
-#endif
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyBlock.c b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyBlock.c deleted file mode 100644 index 39f0ba0191..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyBlock.c +++ /dev/null @@ -1,375 +0,0 @@ -/** @file
- Implementation of the EFI Block IO Protocol for ISA Floppy driver
-
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
-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 "IsaFloppy.h"
-
-/**
- Reset the Block Device.
-
- @param This Indicates a pointer to the calling context.
- @param ExtendedVerification Driver may perform diagnostics on reset.
-
- @retval EFI_SUCCESS The device was reset.
- @retval EFI_DEVICE_ERROR The device is not functioning properly and could
- not be reset.
-**/
-EFI_STATUS
-EFIAPI
-FdcReset (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- )
-{
- FDC_BLK_IO_DEV *FdcDev;
-
- //
- // Reset the Floppy Disk Controller
- //
- FdcDev = FDD_BLK_IO_FROM_THIS (This);
-
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_P_PC_RESET | EFI_PERIPHERAL_REMOVABLE_MEDIA,
- FdcDev->DevicePath
- );
-
- return FddReset (FdcDev);
-}
-
-/**
- Flush the Block Device.
-
- @param This Indicates a pointer to the calling context.
-
- @retval EFI_SUCCESS All outstanding data was written to the device
- @retval EFI_DEVICE_ERROR The device reported an error while writting back the data
- @retval EFI_NO_MEDIA There is no media in the device.
-
-**/
-EFI_STATUS
-EFIAPI
-FddFlushBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This
- )
-{
- //
- // Not supported yet
- //
- return EFI_SUCCESS;
-}
-
-/**
- Common report status code interface.
-
- @param This Pointer of FDC_BLK_IO_DEV instance
- @param Read Read or write operation when error occurrs
-**/
-VOID
-FddReportStatus (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN Read
- )
-{
- FDC_BLK_IO_DEV *FdcDev;
-
- FdcDev = FDD_BLK_IO_FROM_THIS (This);
-
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_ERROR_CODE,
- ((Read) ? EFI_P_EC_INPUT_ERROR : EFI_P_EC_OUTPUT_ERROR) | EFI_PERIPHERAL_REMOVABLE_MEDIA,
- FdcDev->DevicePath
- );
-}
-
-/**
- Read BufferSize bytes from Lba into Buffer.
-
- @param This Indicates a pointer to the calling context.
- @param MediaId Id of the media, changes every time the media is replaced.
- @param Lba The starting Logical Block Address to read from
- @param BufferSize Size of Buffer, must be a multiple of device block size.
- @param Buffer A pointer to the destination buffer for the data. The caller is
- responsible for either having implicit or explicit ownership of the buffer.
-
- @retval EFI_SUCCESS The data was read correctly from the device.
- @retval EFI_DEVICE_ERROR The device reported an error while performing the read.
- @retval EFI_NO_MEDIA There is no media in the device.
- @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.
- @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
- @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
- or the buffer is not on proper alignment.
-
-**/
-EFI_STATUS
-EFIAPI
-FddReadBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- )
-{
- EFI_STATUS Status;
-
- Status = FddReadWriteBlocks (This, MediaId, Lba, BufferSize, READ, Buffer);
-
- if (EFI_ERROR (Status)) {
- FddReportStatus (This, TRUE);
- }
-
- return Status;
-}
-
-/**
- Write BufferSize bytes from Lba into Buffer.
-
- @param This Indicates a pointer to the calling context.
- @param MediaId The media ID that the write request is for.
- @param Lba The starting logical block address to be written. The caller is
- responsible for writing to only legitimate locations.
- @param BufferSize Size of Buffer, must be a multiple of device block size.
- @param Buffer A pointer to the source buffer for the data.
-
- @retval EFI_SUCCESS The data was written correctly to the device.
- @retval EFI_WRITE_PROTECTED The device can not be written to.
- @retval EFI_DEVICE_ERROR The device reported an error while performing the write.
- @retval EFI_NO_MEDIA There is no media in the device.
- @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
- @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
- @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
- or the buffer is not on proper alignment.
-
-**/
-EFI_STATUS
-EFIAPI
-FddWriteBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- IN VOID *Buffer
- )
-{
- EFI_STATUS Status;
-
- Status = FddReadWriteBlocks (This, MediaId, Lba, BufferSize, WRITE, Buffer);
-
- if (EFI_ERROR (Status)) {
- FddReportStatus (This, FALSE);
- }
-
- return Status;
-}
-
-/**
- Read or Write a number of blocks to floppy disk
-
- @param This Indicates a pointer to the calling context.
- @param MediaId Id of the media, changes every time the media is replaced.
- @param Lba The starting Logical Block Address to read from
- @param BufferSize Size of Buffer, must be a multiple of device block size.
- @param Operation Specifies the read or write operation.
- @param Buffer A pointer to the destination buffer for the data. The caller is
- responsible for either having implicit or explicit ownership of the buffer.
-
- @retval EFI_SUCCESS The data was read correctly from the device.
- @retval EFI_DEVICE_ERROR The device reported an error while performing the read.
- @retval EFI_NO_MEDIA There is no media in the device.
- @retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.
- @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
- @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
- or the buffer is not on proper alignment.
- @retval EFI_WRITE_PROTECTED The device can not be written to.
-
-**/
-EFI_STATUS
-FddReadWriteBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- IN BOOLEAN Operation,
- OUT VOID *Buffer
- )
-{
- EFI_BLOCK_IO_MEDIA *Media;
- FDC_BLK_IO_DEV *FdcDev;
- UINTN BlockSize;
- UINTN NumberOfBlocks;
- UINTN BlockCount;
- EFI_STATUS Status;
- EFI_LBA Lba0;
- UINT8 *Pointer;
-
- //
- // Get the intrinsic block size
- //
- Media = This->Media;
- BlockSize = Media->BlockSize;
- FdcDev = FDD_BLK_IO_FROM_THIS (This);
-
- if (Operation == WRITE) {
- if (Lba == 0) {
- FdcFreeCache (FdcDev);
- }
- }
-
- //
- // Set the drive motor on
- //
- Status = MotorOn (FdcDev);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
- //
- // Check to see if media can be detected
- //
- Status = DetectMedia (FdcDev);
- if (EFI_ERROR (Status)) {
- MotorOff (FdcDev);
- FdcFreeCache (FdcDev);
- return EFI_DEVICE_ERROR;
- }
- //
- // Check to see if media is present
- //
- if (!(Media->MediaPresent)) {
- MotorOff (FdcDev);
- FdcFreeCache (FdcDev);
- return EFI_NO_MEDIA;
- }
- //
- // Check to see if media has been changed
- //
- if (MediaId != Media->MediaId) {
- MotorOff (FdcDev);
- FdcFreeCache (FdcDev);
- return EFI_MEDIA_CHANGED;
- }
-
- if (BufferSize == 0) {
- MotorOff (FdcDev);
- return EFI_SUCCESS;
- }
-
- if (Operation == WRITE) {
- if (Media->ReadOnly) {
- MotorOff (FdcDev);
- return EFI_WRITE_PROTECTED;
- }
- }
- //
- // Check the parameters for this read/write operation
- //
- if (Buffer == NULL) {
- MotorOff (FdcDev);
- return EFI_INVALID_PARAMETER;
- }
-
- if (BufferSize % BlockSize != 0) {
- MotorOff (FdcDev);
- return EFI_BAD_BUFFER_SIZE;
- }
-
- if (Lba > Media->LastBlock) {
- MotorOff (FdcDev);
- return EFI_INVALID_PARAMETER;
- }
-
- if (((BufferSize / BlockSize) + Lba - 1) > Media->LastBlock) {
- MotorOff (FdcDev);
- return EFI_INVALID_PARAMETER;
- }
-
- if (Operation == READ) {
- //
- // See if the data that is being read is already in the cache
- //
- if (FdcDev->Cache != NULL) {
- if (Lba == 0 && BufferSize == BlockSize) {
- MotorOff (FdcDev);
- CopyMem ((UINT8 *) Buffer, (UINT8 *) FdcDev->Cache, BlockSize);
- return EFI_SUCCESS;
- }
- }
- }
- //
- // Set up Floppy Disk Controller
- //
- Status = Setup (FdcDev);
- if (EFI_ERROR (Status)) {
- MotorOff (FdcDev);
- return EFI_DEVICE_ERROR;
- }
-
- NumberOfBlocks = BufferSize / BlockSize;
- Lba0 = Lba;
- Pointer = Buffer;
-
- //
- // read blocks in the same cylinder.
- // in a cylinder , there are 18 * 2 = 36 blocks
- //
- BlockCount = GetTransferBlockCount (FdcDev, Lba, NumberOfBlocks);
- while ((BlockCount != 0) && !EFI_ERROR (Status)) {
- Status = ReadWriteDataSector (FdcDev, Buffer, Lba, BlockCount, Operation);
- if (EFI_ERROR (Status)) {
- MotorOff (FdcDev);
- FddReset (FdcDev);
- return EFI_DEVICE_ERROR;
- }
-
- Lba += BlockCount;
- NumberOfBlocks -= BlockCount;
- Buffer = (VOID *) ((UINTN) Buffer + BlockCount * BlockSize);
- BlockCount = GetTransferBlockCount (FdcDev, Lba, NumberOfBlocks);
- }
-
- Buffer = Pointer;
-
- //
- // Turn the motor off
- //
- MotorOff (FdcDev);
-
- if (Operation == READ) {
- //
- // Cache the data read
- //
- if (Lba0 == 0 && FdcDev->Cache == NULL) {
- FdcDev->Cache = AllocateCopyPool (BlockSize, Buffer);
- }
- }
-
- return EFI_SUCCESS;
-
-}
-
-/**
- Free cache for a floppy disk.
-
- @param FdcDev A Pointer to FDC_BLK_IO_DEV instance
-
-**/
-VOID
-FdcFreeCache (
- IN FDC_BLK_IO_DEV *FdcDev
- )
-{
- if (FdcDev->Cache != NULL) {
- FreePool (FdcDev->Cache);
- FdcDev->Cache = NULL;
- }
-}
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyCtrl.c b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyCtrl.c deleted file mode 100644 index 16ad6b02e3..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyCtrl.c +++ /dev/null @@ -1,1398 +0,0 @@ -/** @file
- Internal floppy disk controller programming functions for the floppy driver.
-
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
-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 "IsaFloppy.h"
-
-/**
- Detect whether a floppy drive is present or not.
-
- @param[in] FdcDev A pointer to the FDC_BLK_IO_DEV
-
- @retval EFI_SUCCESS The floppy disk drive is present
- @retval EFI_NOT_FOUND The floppy disk drive is not present
-**/
-EFI_STATUS
-DiscoverFddDevice (
- IN FDC_BLK_IO_DEV *FdcDev
- )
-{
- EFI_STATUS Status;
-
- FdcDev->BlkIo.Media = &FdcDev->BlkMedia;
-
- Status = FddIdentify (FdcDev);
- if (EFI_ERROR (Status)) {
- return EFI_NOT_FOUND;
- }
-
- FdcDev->BlkIo.Reset = FdcReset;
- FdcDev->BlkIo.FlushBlocks = FddFlushBlocks;
- FdcDev->BlkIo.ReadBlocks = FddReadBlocks;
- FdcDev->BlkIo.WriteBlocks = FddWriteBlocks;
- FdcDev->BlkMedia.LogicalPartition = FALSE;
- FdcDev->BlkMedia.WriteCaching = FALSE;
-
- return EFI_SUCCESS;
-}
-
-/**
- Do recalibrate and check if the drive is present or not
- and set the media parameters if the driver is present.
-
- @param[in] FdcDev A pointer to the FDC_BLK_IO_DEV
-
- @retval EFI_SUCCESS The floppy disk drive is present
- @retval EFI_DEVICE_ERROR The floppy disk drive is not present
-**/
-EFI_STATUS
-FddIdentify (
- IN FDC_BLK_IO_DEV *FdcDev
- )
-{
- EFI_STATUS Status;
-
- //
- // Set Floppy Disk Controller's motor on
- //
- Status = MotorOn (FdcDev);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- Status = Recalibrate (FdcDev);
-
- if (EFI_ERROR (Status)) {
- MotorOff (FdcDev);
- FdcDev->ControllerState->NeedRecalibrate = TRUE;
- return EFI_DEVICE_ERROR;
- }
- //
- // Set Media Parameter
- //
- FdcDev->BlkIo.Media->RemovableMedia = TRUE;
- FdcDev->BlkIo.Media->MediaPresent = TRUE;
- FdcDev->BlkIo.Media->MediaId = 0;
-
- //
- // Check Media
- //
- Status = DisketChanged (FdcDev);
-
- if (Status == EFI_NO_MEDIA) {
- FdcDev->BlkIo.Media->MediaPresent = FALSE;
- } else if ((Status != EFI_MEDIA_CHANGED) &&
- (Status != EFI_SUCCESS)) {
- MotorOff (FdcDev);
- return Status;
- }
-
- //
- // Check Disk Write Protected
- //
- Status = SenseDrvStatus (FdcDev, 0);
-
- if (Status == EFI_WRITE_PROTECTED) {
- FdcDev->BlkIo.Media->ReadOnly = TRUE;
- } else if (Status == EFI_SUCCESS) {
- FdcDev->BlkIo.Media->ReadOnly = FALSE;
- } else {
- return EFI_DEVICE_ERROR;
- }
-
- MotorOff (FdcDev);
-
- //
- // Set Media Default Type
- //
- FdcDev->BlkIo.Media->BlockSize = DISK_1440K_BYTEPERSECTOR;
- FdcDev->BlkIo.Media->LastBlock = DISK_1440K_EOT * 2 * (DISK_1440K_MAXTRACKNUM + 1) - 1;
-
- return EFI_SUCCESS;
-}
-
-/**
- Reset the Floppy Logic Drive.
-
- @param FdcDev FDC_BLK_IO_DEV * : A pointer to the FDC_BLK_IO_DEV
-
- @retval EFI_SUCCESS: The Floppy Logic Drive is reset
- @retval EFI_DEVICE_ERROR: The Floppy Logic Drive is not functioning correctly and
- can not be reset
-
-**/
-EFI_STATUS
-FddReset (
- IN FDC_BLK_IO_DEV *FdcDev
- )
-{
- UINT8 Data;
- UINT8 StatusRegister0;
- UINT8 PresentCylinderNumber;
- UINTN Index;
-
- //
- // Report reset progress code
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_PC_RESET,
- FdcDev->DevicePath
- );
-
- //
- // Reset specified Floppy Logic Drive according to FdcDev -> Disk
- // Set Digital Output Register(DOR) to do reset work
- // bit0 & bit1 of DOR : Drive Select
- // bit2 : Reset bit
- // bit3 : DMA and Int bit
- // Reset : a "0" written to bit2 resets the FDC, this reset will remain
- // active until
- // a "1" is written to this bit.
- // Reset step 1:
- // use bit0 & bit1 to select the logic drive
- // write "0" to bit2
- //
- Data = 0x0;
- Data = (UINT8) (Data | (SELECT_DRV & FdcDev->Disk));
- FdcWritePort (FdcDev, FDC_REGISTER_DOR, Data);
-
- //
- // wait some time,at least 120us
- //
- MicroSecondDelay (500);
-
- //
- // Reset step 2:
- // write "1" to bit2
- // write "1" to bit3 : enable DMA
- //
- Data |= 0x0C;
- FdcWritePort (FdcDev, FDC_REGISTER_DOR, Data);
-
- //
- // Experience value
- //
- MicroSecondDelay (2000);
-
- //
- // wait specified floppy logic drive is not busy
- //
- if (EFI_ERROR (FddWaitForBSYClear (FdcDev, 1))) {
- return EFI_DEVICE_ERROR;
- }
- //
- // Set the Transfer Data Rate
- //
- FdcWritePort (FdcDev, FDC_REGISTER_CCR, 0x0);
-
- //
- // Experience value
- //
- MicroSecondDelay (100);
-
- //
- // Issue Sense interrupt command for each drive (total 4 drives)
- //
- for (Index = 0; Index < 4; Index++) {
- if (EFI_ERROR (SenseIntStatus (FdcDev, &StatusRegister0, &PresentCylinderNumber))) {
- return EFI_DEVICE_ERROR;
- }
- }
- //
- // issue Specify command
- //
- if (EFI_ERROR (Specify (FdcDev))) {
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Turn the floppy disk drive's motor on.
- The drive's motor must be on before any command can be executed.
-
- @param[in] FdcDev A pointer to the FDC_BLK_IO_DEV
-
- @retval EFI_SUCCESS The drive's motor was turned on successfully
- @retval EFI_DEVICE_ERROR The drive is busy, so can not turn motor on
-**/
-EFI_STATUS
-MotorOn (
- IN FDC_BLK_IO_DEV *FdcDev
- )
-{
- EFI_STATUS Status;
- UINT8 DorData;
-
- //
- // Control of the floppy drive motors is a big pain. If motor is off, you have
- // to turn it on first. But you can not leave the motor on all the time, since
- // that would wear out the disk. On the other hand, if you turn the motor off
- // after each operation, the system performance will be awful. The compromise
- // used in this driver is to leave the motor on for 2 seconds after
- // each operation. If a new operation is started in that interval(2s),
- // the motor need not be turned on again. If no new operation is started,
- // a timer goes off and the motor is turned off
- //
- //
- // Cancel the timer
- //
- Status = gBS->SetTimer (FdcDev->Event, TimerCancel, 0);
- ASSERT_EFI_ERROR (Status);
-
- //
- // Get the motor status
- //
- DorData = FdcReadPort (FdcDev, FDC_REGISTER_DOR);
-
- if (((FdcDev->Disk == FdcDisk0) && ((DorData & 0x10) == 0x10)) ||
- ((FdcDev->Disk == FdcDisk1) && ((DorData & 0x21) == 0x21))
- ) {
- return EFI_SUCCESS;
- }
- //
- // The drive's motor is off, so need turn it on
- // first look at command and drive are busy or not
- //
- if (EFI_ERROR (FddWaitForBSYClear (FdcDev, 1))) {
- return EFI_DEVICE_ERROR;
- }
- //
- // for drive A: 1CH, drive B: 2DH
- //
- DorData = 0x0C;
- DorData = (UINT8) (DorData | (SELECT_DRV & FdcDev->Disk));
- if (FdcDev->Disk == FdcDisk0) {
- //
- // drive A
- //
- DorData |= DRVA_MOTOR_ON;
- } else {
- //
- // drive B
- //
- DorData |= DRVB_MOTOR_ON;
- }
-
- FdcWritePort (FdcDev, FDC_REGISTER_DOR, DorData);
-
- //
- // Experience value
- //
- MicroSecondDelay (4000);
-
- return EFI_SUCCESS;
-}
-
-/**
- Set a Timer and when Timer goes off, turn the motor off.
-
- @param[in] FdcDev A pointer to the FDC_BLK_IO_DEV
-
- @retval EFI_SUCCESS Set the Timer successfully
- @retval EFI_INVALID_PARAMETER Fail to Set the timer
-**/
-EFI_STATUS
-MotorOff (
- IN FDC_BLK_IO_DEV *FdcDev
- )
-{
- //
- // Set the timer : 2s
- //
- return gBS->SetTimer (FdcDev->Event, TimerRelative, 20000000);
-}
-
-/**
- Detect whether the disk in the drive is changed or not.
-
- @param[in] FdcDev A pointer to FDC_BLK_IO_DEV
-
- @retval EFI_SUCCESS No disk media change
- @retval EFI_DEVICE_ERROR Fail to do the recalibrate or seek operation
- @retval EFI_NO_MEDIA No disk in the drive
- @retval EFI_MEDIA_CHANGED There is a new disk in the drive
-**/
-EFI_STATUS
-DisketChanged (
- IN FDC_BLK_IO_DEV *FdcDev
- )
-{
- EFI_STATUS Status;
- UINT8 Data;
-
- //
- // Check change line
- //
- Data = FdcReadPort (FdcDev, FDC_REGISTER_DIR);
-
- //
- // Io delay
- //
- MicroSecondDelay (50);
-
- if ((Data & DIR_DCL) == 0x80) {
- //
- // disk change line is active
- //
- if (FdcDev->PresentCylinderNumber != 0) {
- Status = Recalibrate (FdcDev);
- } else {
- Status = Seek (FdcDev, 0x30);
- }
-
- if (EFI_ERROR (Status)) {
- FdcDev->ControllerState->NeedRecalibrate = TRUE;
- return EFI_DEVICE_ERROR;
- //
- // Fail to do the seek or recalibrate operation
- //
- }
-
- Data = FdcReadPort (FdcDev, FDC_REGISTER_DIR);
-
- //
- // Io delay
- //
- MicroSecondDelay (50);
-
- if ((Data & DIR_DCL) == 0x80) {
- return EFI_NO_MEDIA;
- }
-
- return EFI_MEDIA_CHANGED;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Do the Specify command, this command sets DMA operation
- and the initial values for each of the three internal
- times: HUT, SRT and HLT.
-
- @param[in] FdcDev Pointer to instance of FDC_BLK_IO_DEV
-
- @retval EFI_SUCCESS Execute the Specify command successfully
- @retval EFI_DEVICE_ERROR Fail to execute the command
-**/
-EFI_STATUS
-Specify (
- IN FDC_BLK_IO_DEV *FdcDev
- )
-{
- FDD_SPECIFY_CMD Command;
- UINTN Index;
- UINT8 *CommandPointer;
-
- ZeroMem (&Command, sizeof (FDD_SPECIFY_CMD));
- Command.CommandCode = SPECIFY_CMD;
- //
- // set SRT, HUT
- //
- Command.SrtHut = 0xdf;
- //
- // 0xdf;
- //
- // set HLT and DMA
- //
- Command.HltNd = 0x02;
-
- CommandPointer = (UINT8 *) (&Command);
- for (Index = 0; Index < sizeof (FDD_SPECIFY_CMD); Index++) {
- if (EFI_ERROR (DataOutByte (FdcDev, CommandPointer++))) {
- return EFI_DEVICE_ERROR;
- }
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Set the head of floppy drive to track 0.
-
- @param FdcDev FDC_BLK_IO_DEV *: A pointer to FDC_BLK_IO_DEV
- @retval EFI_SUCCESS: Execute the Recalibrate operation successfully
- @retval EFI_DEVICE_ERROR: Fail to execute the Recalibrate operation
-
-**/
-EFI_STATUS
-Recalibrate (
- IN FDC_BLK_IO_DEV *FdcDev
- )
-{
- FDD_COMMAND_PACKET2 Command;
- UINTN Index;
- UINT8 StatusRegister0;
- UINT8 PresentCylinderNumber;
- UINT8 *CommandPointer;
- UINT8 Count;
-
- Count = 2;
-
- while (Count > 0) {
- ZeroMem (&Command, sizeof (FDD_COMMAND_PACKET2));
- Command.CommandCode = RECALIBRATE_CMD;
- //
- // drive select
- //
- if (FdcDev->Disk == FdcDisk0) {
- Command.DiskHeadSel = 0;
- //
- // 0
- //
- } else {
- Command.DiskHeadSel = 1;
- //
- // 1
- //
- }
-
- CommandPointer = (UINT8 *) (&Command);
- for (Index = 0; Index < sizeof (FDD_COMMAND_PACKET2); Index++) {
- if (EFI_ERROR (DataOutByte (FdcDev, CommandPointer++))) {
- return EFI_DEVICE_ERROR;
- }
- }
- //
- // Experience value
- //
- MicroSecondDelay (250000);
- //
- // need modify according to 1.44M or 2.88M
- //
- if (EFI_ERROR (SenseIntStatus (FdcDev, &StatusRegister0, &PresentCylinderNumber))) {
- return EFI_DEVICE_ERROR;
- }
-
- if ((StatusRegister0 & 0xf0) == 0x20 && PresentCylinderNumber == 0) {
- FdcDev->PresentCylinderNumber = 0;
- FdcDev->ControllerState->NeedRecalibrate = FALSE;
- return EFI_SUCCESS;
- } else {
- Count--;
- if (Count == 0) {
- return EFI_DEVICE_ERROR;
- }
- }
- }
- //
- // end while
- //
- return EFI_SUCCESS;
-}
-
-/**
- Set the head of floppy drive to the new cylinder.
-
- @param FdcDev FDC_BLK_IO_DEV *: A pointer to FDC_BLK_IO_DEV
- @param Lba EFI_LBA : The logic block address want to seek
-
- @retval EFI_SUCCESS: Execute the Seek operation successfully
- @retval EFI_DEVICE_ERROR: Fail to execute the Seek operation
-
-**/
-EFI_STATUS
-Seek (
- IN FDC_BLK_IO_DEV *FdcDev,
- IN EFI_LBA Lba
- )
-{
- FDD_SEEK_CMD Command;
- UINT8 EndOfTrack;
- UINT8 Head;
- UINT8 Cylinder;
- UINT8 StatusRegister0;
- UINT8 *CommandPointer;
- UINT8 PresentCylinderNumber;
- UINTN Index;
- UINT8 DelayTime;
-
- if (FdcDev->ControllerState->NeedRecalibrate) {
- if (EFI_ERROR (Recalibrate (FdcDev))) {
- FdcDev->ControllerState->NeedRecalibrate = TRUE;
- return EFI_DEVICE_ERROR;
- }
- }
-
- EndOfTrack = DISK_1440K_EOT;
- //
- // Calculate cylinder based on Lba and EOT
- //
- Cylinder = (UINT8) ((UINTN) Lba / EndOfTrack / 2);
-
- //
- // if the destination cylinder is the present cylinder, unnecessary to do the
- // seek operation
- //
- if (FdcDev->PresentCylinderNumber == Cylinder) {
- return EFI_SUCCESS;
- }
- //
- // Calculate the head : 0 or 1
- //
- Head = (UINT8) ((UINTN) Lba / EndOfTrack % 2);
-
- ZeroMem (&Command, sizeof (FDD_SEEK_CMD));
- Command.CommandCode = SEEK_CMD;
- if (FdcDev->Disk == FdcDisk0) {
- Command.DiskHeadSel = 0;
- //
- // 0
- //
- } else {
- Command.DiskHeadSel = 1;
- //
- // 1
- //
- }
-
- Command.DiskHeadSel = (UINT8) (Command.DiskHeadSel | (Head << 2));
- Command.NewCylinder = Cylinder;
-
- CommandPointer = (UINT8 *) (&Command);
- for (Index = 0; Index < sizeof (FDD_SEEK_CMD); Index++) {
- if (EFI_ERROR (DataOutByte (FdcDev, CommandPointer++))) {
- return EFI_DEVICE_ERROR;
- }
- }
- //
- // Io delay
- //
- MicroSecondDelay (100);
-
- //
- // Calculate waiting time
- //
- if (FdcDev->PresentCylinderNumber > Cylinder) {
- DelayTime = (UINT8) (FdcDev->PresentCylinderNumber - Cylinder);
- } else {
- DelayTime = (UINT8) (Cylinder - FdcDev->PresentCylinderNumber);
- }
-
- MicroSecondDelay ((DelayTime + 1) * 4000);
-
- if (EFI_ERROR (SenseIntStatus (FdcDev, &StatusRegister0, &PresentCylinderNumber))) {
- return EFI_DEVICE_ERROR;
- }
-
- if ((StatusRegister0 & 0xf0) == 0x20) {
- FdcDev->PresentCylinderNumber = Command.NewCylinder;
- return EFI_SUCCESS;
- } else {
- FdcDev->ControllerState->NeedRecalibrate = TRUE;
- return EFI_DEVICE_ERROR;
- }
-}
-
-/**
- Do the Sense Interrupt Status command, this command
- resets the interrupt signal.
-
- @param FdcDev FDC_BLK_IO_DEV *: A pointer to FDC_BLK_IO_DEV
- @param StatusRegister0 UINT8 *: Be used to save Status Register 0 read from FDC
- @param PresentCylinderNumber UINT8 *: Be used to save present cylinder number
- read from FDC
-
- @retval EFI_SUCCESS: Execute the Sense Interrupt Status command successfully
- @retval EFI_DEVICE_ERROR: Fail to execute the command
-
-**/
-EFI_STATUS
-SenseIntStatus (
- IN FDC_BLK_IO_DEV *FdcDev,
- IN OUT UINT8 *StatusRegister0,
- IN OUT UINT8 *PresentCylinderNumber
- )
-{
- UINT8 Command;
-
- Command = SENSE_INT_STATUS_CMD;
- if (EFI_ERROR (DataOutByte (FdcDev, &Command))) {
- return EFI_DEVICE_ERROR;
- }
-
- if (EFI_ERROR (DataInByte (FdcDev, StatusRegister0))) {
- return EFI_DEVICE_ERROR;
- }
-
- if (EFI_ERROR (DataInByte (FdcDev, PresentCylinderNumber))) {
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Do the Sense Drive Status command.
-
- @param FdcDev FDC_BLK_IO_DEV *: A pointer to FDC_BLK_IO_DEV
- @param Lba EFI_LBA : Logic block address
-
- @retval EFI_SUCCESS: Execute the Sense Drive Status command successfully
- @retval EFI_DEVICE_ERROR: Fail to execute the command
- @retval EFI_WRITE_PROTECTED:The disk is write protected
-
-**/
-EFI_STATUS
-SenseDrvStatus (
- IN FDC_BLK_IO_DEV *FdcDev,
- IN EFI_LBA Lba
- )
-{
- FDD_COMMAND_PACKET2 Command;
- UINT8 Head;
- UINT8 EndOfTrack;
- UINTN Index;
- UINT8 StatusRegister3;
- UINT8 *CommandPointer;
-
- //
- // Sense Drive Status command obtains drive status information,
- // it has not execution phase and goes directly to the result phase from the
- // command phase, Status Register 3 contains the drive status information
- //
- ZeroMem (&Command, sizeof (FDD_COMMAND_PACKET2));
- Command.CommandCode = SENSE_DRV_STATUS_CMD;
-
- if (FdcDev->Disk == FdcDisk0) {
- Command.DiskHeadSel = 0;
- } else {
- Command.DiskHeadSel = 1;
- }
-
- EndOfTrack = DISK_1440K_EOT;
- Head = (UINT8) ((UINTN) Lba / EndOfTrack % 2);
- Command.DiskHeadSel = (UINT8) (Command.DiskHeadSel | (Head << 2));
-
- CommandPointer = (UINT8 *) (&Command);
- for (Index = 0; Index < sizeof (FDD_COMMAND_PACKET2); Index++) {
- if (EFI_ERROR (DataOutByte (FdcDev, CommandPointer++))) {
- return EFI_DEVICE_ERROR;
- }
- }
-
- if (EFI_ERROR (DataInByte (FdcDev, &StatusRegister3))) {
- return EFI_DEVICE_ERROR;
- }
- //
- // Io delay
- //
- MicroSecondDelay (50);
-
- //
- // Check Status Register 3 to get drive status information
- //
- return CheckStatus3 (StatusRegister3);
-}
-
-/**
- Update the disk media properties and if necessary reinstall Block I/O interface.
-
- @param FdcDev FDC_BLK_IO_DEV *: A pointer to FDC_BLK_IO_DEV
-
- @retval EFI_SUCCESS: Do the operation successfully
- @retval EFI_DEVICE_ERROR: Fail to the operation
-
-**/
-EFI_STATUS
-DetectMedia (
- IN FDC_BLK_IO_DEV *FdcDev
- )
-{
- EFI_STATUS Status;
- BOOLEAN Reset;
- BOOLEAN ReadOnlyLastTime;
- BOOLEAN MediaPresentLastTime;
-
- Reset = FALSE;
- ReadOnlyLastTime = FdcDev->BlkIo.Media->ReadOnly;
- MediaPresentLastTime = FdcDev->BlkIo.Media->MediaPresent;
-
- //
- // Check disk change
- //
- Status = DisketChanged (FdcDev);
-
- if (Status == EFI_MEDIA_CHANGED) {
- FdcDev->BlkIo.Media->MediaId++;
- FdcDev->BlkIo.Media->MediaPresent = TRUE;
- Reset = TRUE;
- } else if (Status == EFI_NO_MEDIA) {
- FdcDev->BlkIo.Media->MediaPresent = FALSE;
- } else if (Status != EFI_SUCCESS) {
- MotorOff (FdcDev);
- return Status;
- //
- // EFI_DEVICE_ERROR
- //
- }
-
- if (FdcDev->BlkIo.Media->MediaPresent) {
- //
- // Check disk write protected
- //
- Status = SenseDrvStatus (FdcDev, 0);
- if (Status == EFI_WRITE_PROTECTED) {
- FdcDev->BlkIo.Media->ReadOnly = TRUE;
- } else {
- FdcDev->BlkIo.Media->ReadOnly = FALSE;
- }
- }
-
- if (FdcDev->BlkIo.Media->MediaPresent && (ReadOnlyLastTime != FdcDev->BlkIo.Media->ReadOnly)) {
- Reset = TRUE;
- }
-
- if (MediaPresentLastTime != FdcDev->BlkIo.Media->MediaPresent) {
- Reset = TRUE;
- }
-
- if (Reset) {
- Status = gBS->ReinstallProtocolInterface (
- FdcDev->Handle,
- &gEfiBlockIoProtocolGuid,
- &FdcDev->BlkIo,
- &FdcDev->BlkIo
- );
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Set the data rate and so on.
-
- @param FdcDev A pointer to FDC_BLK_IO_DEV
-
- @retval EFI_SUCCESS success to set the data rate
-**/
-EFI_STATUS
-Setup (
- IN FDC_BLK_IO_DEV *FdcDev
- )
-{
- EFI_STATUS Status;
-
- //
- // Set data rate 500kbs
- //
- FdcWritePort (FdcDev, FDC_REGISTER_CCR, 0x0);
-
- //
- // Io delay
- //
- MicroSecondDelay (50);
-
- Status = Specify (FdcDev);
-
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Read or Write a number of blocks in the same cylinder.
-
- @param FdcDev A pointer to FDC_BLK_IO_DEV
- @param HostAddress device address
- @param Lba The starting logic block address to read from on the device
- @param NumberOfBlocks The number of block wanted to be read or write
- @param Read Operation type: read or write
-
- @retval EFI_SUCCESS Success operate
-
-**/
-EFI_STATUS
-ReadWriteDataSector (
- IN FDC_BLK_IO_DEV *FdcDev,
- IN VOID *HostAddress,
- IN EFI_LBA Lba,
- IN UINTN NumberOfBlocks,
- IN BOOLEAN Read
- )
-{
- EFI_STATUS Status;
- FDD_COMMAND_PACKET1 Command;
- FDD_RESULT_PACKET Result;
- UINTN Index;
- UINTN Times;
- UINT8 *CommandPointer;
-
- EFI_PHYSICAL_ADDRESS DeviceAddress;
- EFI_ISA_IO_PROTOCOL *IsaIo;
- UINTN NumberofBytes;
- VOID *Mapping;
- EFI_ISA_IO_PROTOCOL_OPERATION Operation;
- EFI_STATUS Status1;
- UINT8 Channel;
- EFI_ISA_ACPI_RESOURCE *ResourceItem;
- UINT32 Attribute;
-
- Status = Seek (FdcDev, Lba);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
- //
- // Map Dma
- //
- IsaIo = FdcDev->IsaIo;
- NumberofBytes = NumberOfBlocks * 512;
- if (Read == READ) {
- Operation = EfiIsaIoOperationSlaveWrite;
- } else {
- Operation = EfiIsaIoOperationSlaveRead;
- }
-
- ResourceItem = IsaIo->ResourceList->ResourceItem;
- Index = 0;
- while (ResourceItem[Index].Type != EfiIsaAcpiResourceEndOfList) {
- if (ResourceItem[Index].Type == EfiIsaAcpiResourceDma) {
- break;
- }
-
- Index++;
- }
-
- if (ResourceItem[Index].Type == EfiIsaAcpiResourceEndOfList) {
- return EFI_DEVICE_ERROR;
- }
-
- Channel = (UINT8) IsaIo->ResourceList->ResourceItem[Index].StartRange;
- Attribute = IsaIo->ResourceList->ResourceItem[Index].Attribute;
-
- Status1 = IsaIo->Map (
- IsaIo,
- Operation,
- Channel,
- Attribute,
- HostAddress,
- &NumberofBytes,
- &DeviceAddress,
- &Mapping
- );
- if (EFI_ERROR (Status1)) {
- return Status1;
- }
-
- //
- // Allocate Read or Write command packet
- //
- ZeroMem (&Command, sizeof (FDD_COMMAND_PACKET1));
- if (Read == READ) {
- Command.CommandCode = READ_DATA_CMD | CMD_MT | CMD_MFM | CMD_SK;
- } else {
- Command.CommandCode = WRITE_DATA_CMD | CMD_MT | CMD_MFM;
- }
-
- FillPara (FdcDev, Lba, &Command);
-
- //
- // Write command bytes to FDC
- //
- CommandPointer = (UINT8 *) (&Command);
- for (Index = 0; Index < sizeof (FDD_COMMAND_PACKET1); Index++) {
- if (EFI_ERROR (DataOutByte (FdcDev, CommandPointer++))) {
- return EFI_DEVICE_ERROR;
- }
- }
- //
- // wait for some time
- //
- Times = (STALL_1_SECOND / 50) + 1;
- do {
- if ((FdcReadPort (FdcDev, FDC_REGISTER_MSR) & 0xc0) == 0xc0) {
- break;
- }
-
- MicroSecondDelay (50);
- Times = Times - 1;
- } while (Times > 0);
-
- if (Times == 0) {
- return EFI_TIMEOUT;
- }
- //
- // Read result bytes from FDC
- //
- CommandPointer = (UINT8 *) (&Result);
- for (Index = 0; Index < sizeof (FDD_RESULT_PACKET); Index++) {
- if (EFI_ERROR (DataInByte (FdcDev, CommandPointer++))) {
- return EFI_DEVICE_ERROR;
- }
- }
- //
- // Flush before Unmap
- //
- if (Read == READ) {
- Status1 = IsaIo->Flush (IsaIo);
- if (EFI_ERROR (Status1)) {
- return Status1;
- }
- }
- //
- // Unmap Dma
- //
- Status1 = IsaIo->Unmap (IsaIo, Mapping);
- if (EFI_ERROR (Status1)) {
- return Status1;
- }
-
- return CheckResult (&Result, FdcDev);
-}
-
-/**
- Fill in FDD command's parameter.
-
- @param FdcDev Pointer to instance of FDC_BLK_IO_DEV
- @param Lba The starting logic block address to read from on the device
- @param Command FDD command
-
-**/
-VOID
-FillPara (
- IN FDC_BLK_IO_DEV *FdcDev,
- IN EFI_LBA Lba,
- IN FDD_COMMAND_PACKET1 *Command
- )
-{
- UINT8 EndOfTrack;
-
- //
- // Get EndOfTrack from the Para table
- //
- EndOfTrack = DISK_1440K_EOT;
-
- //
- // Fill the command parameter
- //
- if (FdcDev->Disk == FdcDisk0) {
- Command->DiskHeadSel = 0;
- } else {
- Command->DiskHeadSel = 1;
- }
-
- Command->Cylinder = (UINT8) ((UINTN) Lba / EndOfTrack / 2);
- Command->Head = (UINT8) ((UINTN) Lba / EndOfTrack % 2);
- Command->Sector = (UINT8) ((UINT8) ((UINTN) Lba % EndOfTrack) + 1);
- Command->DiskHeadSel = (UINT8) (Command->DiskHeadSel | (Command->Head << 2));
- Command->Number = DISK_1440K_NUMBER;
- Command->EndOfTrack = DISK_1440K_EOT;
- Command->GapLength = DISK_1440K_GPL;
- Command->DataLength = DISK_1440K_DTL;
-}
-
-/**
- Read result byte from Data Register of FDC.
-
- @param FdcDev Pointer to instance of FDC_BLK_IO_DEV
- @param Pointer Buffer to store the byte read from FDC
-
- @retval EFI_SUCCESS Read result byte from FDC successfully
- @retval EFI_DEVICE_ERROR The FDC is not ready to be read
-
-**/
-EFI_STATUS
-DataInByte (
- IN FDC_BLK_IO_DEV *FdcDev,
- OUT UINT8 *Pointer
- )
-{
- UINT8 Data;
-
- //
- // wait for 1ms and detect the FDC is ready to be read
- //
- if (EFI_ERROR (FddDRQReady (FdcDev, DATA_IN, 1))) {
- return EFI_DEVICE_ERROR;
- //
- // is not ready
- //
- }
-
- Data = FdcReadPort (FdcDev, FDC_REGISTER_DTR);
-
- //
- // Io delay
- //
- MicroSecondDelay (50);
-
- *Pointer = Data;
- return EFI_SUCCESS;
-}
-
-/**
- Write command byte to Data Register of FDC.
-
- @param FdcDev Pointer to instance of FDC_BLK_IO_DEV
- @param Pointer Be used to save command byte written to FDC
-
- @retval EFI_SUCCESS: Write command byte to FDC successfully
- @retval EFI_DEVICE_ERROR: The FDC is not ready to be written
-
-**/
-EFI_STATUS
-DataOutByte (
- IN FDC_BLK_IO_DEV *FdcDev,
- IN UINT8 *Pointer
- )
-{
- UINT8 Data;
-
- //
- // wait for 1ms and detect the FDC is ready to be written
- //
- if (EFI_ERROR (FddDRQReady (FdcDev, DATA_OUT, 1))) {
- //
- // Not ready
- //
- return EFI_DEVICE_ERROR;
- }
-
- Data = *Pointer;
-
- FdcWritePort (FdcDev, FDC_REGISTER_DTR, Data);
-
- //
- // Io delay
- //
- MicroSecondDelay (50);
-
- return EFI_SUCCESS;
-}
-
-/**
- Detect the specified floppy logic drive is busy or not within a period of time.
-
- @param FdcDev Indicate it is drive A or drive B
- @param Timeout The time period for waiting
-
- @retval EFI_SUCCESS: The drive and command are not busy
- @retval EFI_TIMEOUT: The drive or command is still busy after a period time that
- set by Timeout
-
-**/
-EFI_STATUS
-FddWaitForBSYClear (
- IN FDC_BLK_IO_DEV *FdcDev,
- IN UINTN Timeout
- )
-{
- UINTN Delay;
- UINT8 StatusRegister;
- UINT8 Mask;
-
- //
- // How to determine drive and command are busy or not: by the bits of
- // Main Status Register
- // bit0: Drive 0 busy (drive A)
- // bit1: Drive 1 busy (drive B)
- // bit4: Command busy
- //
- //
- // set mask: for drive A set bit0 & bit4; for drive B set bit1 & bit4
- //
- Mask = (UINT8) ((FdcDev->Disk == FdcDisk0 ? MSR_DAB : MSR_DBB) | MSR_CB);
-
- Delay = ((Timeout * STALL_1_MSECOND) / 50) + 1;
- do {
- StatusRegister = FdcReadPort (FdcDev, FDC_REGISTER_MSR);
- if ((StatusRegister & Mask) == 0x00) {
- break;
- //
- // not busy
- //
- }
-
- MicroSecondDelay (50);
- Delay = Delay - 1;
- } while (Delay > 0);
-
- if (Delay == 0) {
- return EFI_TIMEOUT;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Determine whether FDC is ready to write or read.
-
- @param FdcDev Pointer to instance of FDC_BLK_IO_DEV
- @param Dio BOOLEAN: Indicate the FDC is waiting to write or read
- @param Timeout The time period for waiting
-
- @retval EFI_SUCCESS: FDC is ready to write or read
- @retval EFI_NOT_READY: FDC is not ready within the specified time period
-
-**/
-EFI_STATUS
-FddDRQReady (
- IN FDC_BLK_IO_DEV *FdcDev,
- IN BOOLEAN Dio,
- IN UINTN Timeout
- )
-{
- UINTN Delay;
- UINT8 StatusRegister;
- UINT8 DataInOut;
-
- //
- // Before writing to FDC or reading from FDC, the Host must examine
- // the bit7(RQM) and bit6(DIO) of the Main Status Register.
- // That is to say:
- // command bytes can not be written to Data Register
- // unless RQM is 1 and DIO is 0
- // result bytes can not be read from Data Register
- // unless RQM is 1 and DIO is 1
- //
- DataInOut = (UINT8) (Dio << 6);
- //
- // in order to compare bit6
- //
- Delay = ((Timeout * STALL_1_MSECOND) / 50) + 1;
- do {
- StatusRegister = FdcReadPort (FdcDev, FDC_REGISTER_MSR);
- if ((StatusRegister & MSR_RQM) == MSR_RQM && (StatusRegister & MSR_DIO) == DataInOut) {
- break;
- //
- // FDC is ready
- //
- }
-
- MicroSecondDelay (50);
- //
- // Stall for 50 us
- //
- Delay = Delay - 1;
- } while (Delay > 0);
-
- if (Delay == 0) {
- return EFI_NOT_READY;
- //
- // FDC is not ready within the specified time period
- //
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Set FDC control structure's attribute according to result.
-
- @param Result Point to result structure
- @param FdcDev FDC control structure
-
- @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value
- @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value
- @retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value
- @retval EFI_SUCCESS - GC_TODO: Add description for return value
-
-**/
-EFI_STATUS
-CheckResult (
- IN FDD_RESULT_PACKET *Result,
- IN OUT FDC_BLK_IO_DEV *FdcDev
- )
-{
- //
- // Check Status Register0
- //
- if ((Result->Status0 & STS0_IC) != IC_NT) {
- if ((Result->Status0 & STS0_SE) == 0x20) {
- //
- // seek error
- //
- FdcDev->ControllerState->NeedRecalibrate = TRUE;
- }
-
- FdcDev->ControllerState->NeedRecalibrate = TRUE;
- return EFI_DEVICE_ERROR;
- }
- //
- // Check Status Register1
- //
- if ((Result->Status1 & (STS1_EN | STS1_DE | STS1_OR | STS1_ND | STS1_NW | STS1_MA)) != 0) {
- FdcDev->ControllerState->NeedRecalibrate = TRUE;
- return EFI_DEVICE_ERROR;
- }
- //
- // Check Status Register2
- //
- if ((Result->Status2 & (STS2_CM | STS2_DD | STS2_WC | STS2_BC | STS2_MD)) != 0) {
- FdcDev->ControllerState->NeedRecalibrate = TRUE;
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Check the drive status information.
-
- @param StatusRegister3 the value of Status Register 3
-
- @retval EFI_SUCCESS The disk is not write protected
- @retval EFI_WRITE_PROTECTED: The disk is write protected
-
-**/
-EFI_STATUS
-CheckStatus3 (
- IN UINT8 StatusRegister3
- )
-{
- if ((StatusRegister3 & STS3_WP) != 0) {
- return EFI_WRITE_PROTECTED;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Calculate the number of block in the same cylinder according to LBA.
-
- @param FdcDev FDC_BLK_IO_DEV *: A pointer to FDC_BLK_IO_DEV
- @param LBA EFI_LBA: The starting logic block address
- @param NumberOfBlocks UINTN: The number of blocks
-
- @return The number of blocks in the same cylinder which the starting
- logic block address is LBA
-
-**/
-UINTN
-GetTransferBlockCount (
- IN FDC_BLK_IO_DEV *FdcDev,
- IN EFI_LBA LBA,
- IN UINTN NumberOfBlocks
- )
-{
- UINT8 EndOfTrack;
- UINT8 Head;
- UINT8 SectorsInTrack;
-
- //
- // Calculate the number of block in the same cylinder
- //
- EndOfTrack = DISK_1440K_EOT;
- Head = (UINT8) ((UINTN) LBA / EndOfTrack % 2);
-
- SectorsInTrack = (UINT8) (EndOfTrack * (2 - Head) - (UINT8) ((UINTN) LBA % EndOfTrack));
- if (SectorsInTrack < NumberOfBlocks) {
- return SectorsInTrack;
- } else {
- return NumberOfBlocks;
- }
-}
-
-/**
- When the Timer(2s) off, turn the drive's motor off.
-
- @param Event EFI_EVENT: Event(the timer) whose notification function is being
- invoked
- @param Context VOID *: Pointer to the notification function's context
-
-**/
-VOID
-EFIAPI
-FddTimerProc (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- FDC_BLK_IO_DEV *FdcDev;
- UINT8 Data;
-
- FdcDev = (FDC_BLK_IO_DEV *) Context;
-
- //
- // Get the motor status
- //
- Data = FdcReadPort (FdcDev, FDC_REGISTER_DOR);
-
- if (((FdcDev->Disk == FdcDisk0) && ((Data & 0x10) != 0x10)) ||
- ((FdcDev->Disk == FdcDisk1) && ((Data & 0x21) != 0x21))
- ) {
- return ;
- }
- //
- // the motor is on, so need motor off
- //
- Data = 0x0C;
- Data = (UINT8) (Data | (SELECT_DRV & FdcDev->Disk));
- FdcWritePort (FdcDev, FDC_REGISTER_DOR, Data);
- MicroSecondDelay (500);
-}
-
-/**
- Read an I/O port of FDC.
-
- @param[in] FdcDev A pointer to FDC_BLK_IO_DEV.
- @param[in] Offset The address offset of the I/O port.
-
- @retval 8-bit data read from the I/O port.
-**/
-UINT8
-FdcReadPort (
- IN FDC_BLK_IO_DEV *FdcDev,
- IN UINT32 Offset
- )
-{
- EFI_STATUS Status;
- UINT8 Data;
-
- Status = FdcDev->IsaIo->Io.Read (
- FdcDev->IsaIo,
- EfiIsaIoWidthUint8,
- FdcDev->BaseAddress + Offset,
- 1,
- &Data
- );
- ASSERT_EFI_ERROR (Status);
-
- return Data;
-}
-
-/**
- Write an I/O port of FDC.
-
- @param[in] FdcDev A pointer to FDC_BLK_IO_DEV
- @param[in] Offset The address offset of the I/O port
- @param[in] Data 8-bit Value written to the I/O port
-**/
-VOID
-FdcWritePort (
- IN FDC_BLK_IO_DEV *FdcDev,
- IN UINT32 Offset,
- IN UINT8 Data
- )
-{
- EFI_STATUS Status;
-
- Status = FdcDev->IsaIo->Io.Write (
- FdcDev->IsaIo,
- EfiIsaIoWidthUint8,
- FdcDev->BaseAddress + Offset,
- 1,
- &Data
- );
- ASSERT_EFI_ERROR (Status);
-}
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.inf b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.inf deleted file mode 100644 index 65756209f5..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.inf +++ /dev/null @@ -1,78 +0,0 @@ -## @file
-# Provides ISA Floppy Disk support.
-#
-# Provides ISA Floppy Disk UEFI Driver conforming to the UEFI driver model. The
-# driver provides support for two drives per controller, DMA channel 2, diskette
-# change line and write protect. Currently only 1.44MB drives are supported.
-#
-# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
-#
-# 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.
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = IsaFloppyDxe
- MODULE_UNI_FILE = IsaFloppyDxe.uni
- FILE_GUID = 0abd8284-6da3-4616-971a-83a5148067ba
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = InitializeIsaFloppy
-
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-# DRIVER_BINDING = gFdcControllerDriver;
-# COMPONENT_NAME = gIsaFloppyComponentName;
-# COMPONENT_NAME2 = gIsaFloppyComponentName2;
-#
-[Sources]
- ComponentName.c
- ComponentName.h
- IsaFloppyCtrl.c
- IsaFloppyBlock.c
- IsaFloppy.c
- IsaFloppy.h
-
-[Packages]
- MdePkg/MdePkg.dec
- IntelFrameworkPkg/IntelFrameworkPkg.dec
- IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
-
-[LibraryClasses]
- ReportStatusCodeLib
- UefiBootServicesTableLib
- MemoryAllocationLib
- BaseMemoryLib
- UefiLib
- BaseLib
- UefiDriverEntryPoint
- DebugLib
- TimerLib
- PcdLib
-
-[Protocols]
- gEfiIsaIoProtocolGuid ## TO_START
- gEfiBlockIoProtocolGuid ## BY_START
- gEfiDevicePathProtocolGuid ## TO_START
-
-[FeaturePcd]
- gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable ## CONSUMES
- gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable ## CONSUMES
-
-#
-# [Event]
-# ##
-# # Floppy motor control timer event.
-# #
-# EVENT_TYPE_PERIODIC_TIMER ## CONSUMES
-#
-
-[UserExtensions.TianoCore."ExtraFiles"]
- IsaFloppyDxeExtra.uni
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.uni b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.uni deleted file mode 100644 index 9bf5c6c1de..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.uni +++ /dev/null @@ -1,24 +0,0 @@ -// /** @file
-// Provides ISA Floppy Disk support.
-//
-// Provides ISA Floppy Disk UEFI Driver conforming to the UEFI driver model. The
-// driver provides support for two drives per controller, DMA channel 2, diskette
-// change line and write protect. Currently only 1.44MB drives are supported.
-//
-// Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
-//
-// 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.
-//
-// **/
-
-
-#string STR_MODULE_ABSTRACT #language en-US "Provides ISA Floppy Disk support"
-
-#string STR_MODULE_DESCRIPTION #language en-US "Provides ISA Floppy Disk UEFI Driver conforming to the UEFI driver model. The driver provides support for two drives per controller, DMA channel 2, diskette change line and write protect. Currently only 1.44MB drives are supported."
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxeExtra.uni b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxeExtra.uni deleted file mode 100644 index 07af0667ff..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxeExtra.uni +++ /dev/null @@ -1,20 +0,0 @@ -// /** @file
-// IsaFloppyDxe Localized Strings and Content
-//
-// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
-//
-// 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.
-//
-// **/
-
-#string STR_PROPERTIES_MODULE_NAME
-#language en-US
-"ISA Floppy DXE Driver"
-
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/Fdc.h b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/Fdc.h deleted file mode 100644 index a6a7e42aee..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/Fdc.h +++ /dev/null @@ -1,235 +0,0 @@ -/** @file
-Definition of FDC registers and structures.
-
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
-
-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.
-
-**/
-
-#ifndef _PEI_RECOVERY_FDC_H_
-#define _PEI_RECOVERY_FDC_H_
-
-//
-// FDC Registers
-//
-#define FDC_REGISTER_DOR 2 //Digital Output Register
-#define FDC_REGISTER_MSR 4 //Main Status Register
-#define FDC_REGISTER_DTR 5 //Data Register
-#define FDC_REGISTER_CCR 7 //Configuration Control Register(data rate select)
-#define FDC_REGISTER_DIR 7 //Digital Input Register(diskchange)
-//
-// FDC Register Bit Definitions
-//
-//
-// Digital Out Register(WO)
-//
-#define SELECT_DRV BIT0 // Select Drive: 0=A 1=B
-#define RESET_FDC BIT2 // Reset FDC
-#define INT_DMA_ENABLE BIT3 // Enable Int & DMA
-#define DRVA_MOTOR_ON BIT4 // Turn On Drive A Motor
-#define DRVB_MOTOR_ON BIT5 // Turn On Drive B Motor
-//
-// Main Status Register(RO)
-//
-#define MSR_DAB BIT0 // Drive A Busy
-#define MSR_DBB BIT1 // Drive B Busy
-#define MSR_CB BIT4 // FDC Busy
-#define MSR_NDM BIT5 // Non-DMA Mode
-#define MSR_DIO BIT6 // Data Input/Output
-#define MSR_RQM BIT7 // Request For Master
-//
-// Configuration Control Register(WO)
-//
-#define CCR_DRC (BIT0 | BIT1) // Data Rate select
-//
-// Digital Input Register(RO)
-//
-#define DIR_DCL BIT7 // Disk change line
-#define DRC_500KBS 0x0 // 500K
-#define DRC_300KBS 0x01 // 300K
-#define DRC_250KBS 0x02 // 250K
-//
-// FDC Command Code
-//
-#define READ_DATA_CMD 0x06
-#define SEEK_CMD 0x0F
-#define RECALIBRATE_CMD 0x07
-#define SENSE_INT_STATUS_CMD 0x08
-#define SPECIFY_CMD 0x03
-#define SENSE_DRV_STATUS_CMD 0x04
-
-///
-/// CMD_MT: Multi_Track Selector
-/// when set , this flag selects the multi-track operating mode.
-/// In this mode, the FDC treats a complete cylinder under head0 and 1 as a single track
-///
-#define CMD_MT BIT7
-
-///
-/// CMD_MFM: MFM/FM Mode Selector
-/// A one selects the double density(MFM) mode
-/// A zero selects single density (FM) mode
-///
-#define CMD_MFM BIT6
-
-///
-/// CMD_SK: Skip Flag
-/// When set to 1, sectors containing a deleted data address mark will automatically be skipped
-/// during the execution of Read Data.
-/// When set to 0, the sector is read or written the same as the read and write commands.
-///
-#define CMD_SK BIT5
-
-//
-// FDC Status Register Bit Definitions
-//
-//
-// Status Register 0
-//
-#define STS0_IC (BIT7 | BIT6) // Interrupt Code
-#define STS0_SE BIT5 // Seek End: the FDC completed a seek or recalibrate command
-#define STS0_EC BIT4 // Equipment Check
-#define STS0_NR BIT3 // Not Ready(unused), this bit is always 0
-#define STS0_HA BIT2 // Head Address: the current head address
-//
-// STS0_US1 & STS0_US0: Drive Select(the current selected drive)
-//
-#define STS0_US1 BIT1 // Unit Select1
-#define STS0_US0 BIT0 // Unit Select0
-//
-// Status Register 1
-//
-#define STS1_EN BIT7 // End of Cylinder
-//
-// BIT6 is unused
-//
-#define STS1_DE BIT5 // Data Error: The FDC detected a CRC error in either the ID field or data field of a sector
-#define STS1_OR BIT4 // Overrun/Underrun: Becomes set if FDC does not receive CPU or DMA service within the required time interval
-//
-// BIT3 is unused
-//
-#define STS1_ND BIT2 // No data
-#define STS1_NW BIT1 // Not Writable
-#define STS1_MA BIT0 // Missing Address Mark
-
-//
-// Status Register 2
-//
-// BIT7 is unused
-//
-#define STS2_CM BIT6 // Control Mark
-#define STS2_DD BIT5 // Data Error in Data Field: The FDC detected a CRC error in the data field
-#define STS2_WC BIT4 // Wrong Cylinder: The track address from sector ID field is different from the track address maintained inside FDC
-//
-// BIT3 is unused
-// BIT2 is unused
-//
-#define STS2_BC BIT1 // Bad Cylinder
-#define STS2_MD BIT0 // Missing Address Mark in DataField
-
-//
-// Status Register 3
-//
-// BIT7 is unused
-//
-#define STS3_WP BIT6 // Write Protected
-//
-// BIT5 is unused
-//
-#define STS3_T0 BIT4 // Track 0
-//
-// BIT3 is unused
-//
-#define STS3_HD BIT2 // Head Address
-//
-// STS3_US1 & STS3_US0 : Drive Select
-//
-#define STS3_US1 BIT1 // Unit Select1
-#define STS3_US0 BIT0 // Unit Select0
-
-//
-// Status Register 0 Interrupt Code Description
-//
-#define IC_NT 0x0 // Normal Termination of Command
-#define IC_AT 0x40 // Abnormal Termination of Command
-#define IC_IC 0x80 // Invalid Command
-#define IC_ATRC 0xC0 // Abnormal Termination caused by Polling
-
-///
-/// Table of parameters for diskette
-///
-typedef struct {
- UINT8 EndOfTrack; ///< End of track
- UINT8 GapLength; ///< Gap length
- UINT8 DataLength; ///< Data length
- UINT8 Number; ///< Number of bytes per sector
- UINT8 MaxTrackNum;
- UINT8 MotorStartTime;
- UINT8 MotorOffTime;
- UINT8 HeadSettlingTime;
- UINT8 DataTransferRate;
-} DISKET_PARA_TABLE;
-
-///
-/// Structure for FDC Command Packet 1
-///
-typedef struct {
- UINT8 CommandCode;
- UINT8 DiskHeadSel;
- UINT8 Cylinder;
- UINT8 Head;
- UINT8 Sector;
- UINT8 Number;
- UINT8 EndOfTrack;
- UINT8 GapLength;
- UINT8 DataLength;
-} FDC_COMMAND_PACKET1;
-
-///
-/// Structure for FDC Command Packet 2
-///
-typedef struct {
- UINT8 CommandCode;
- UINT8 DiskHeadSel;
-} FDC_COMMAND_PACKET2;
-
-///
-/// Structure for FDC Specify Command
-///
-typedef struct {
- UINT8 CommandCode;
- UINT8 SrtHut;
- UINT8 HltNd;
-} FDC_SPECIFY_CMD;
-
-///
-/// Structure for FDC Seek Command
-///
-typedef struct {
- UINT8 CommandCode;
- UINT8 DiskHeadSel;
- UINT8 NewCylinder;
-} FDC_SEEK_CMD;
-
-///
-/// Structure for FDC Result Packet
-///
-typedef struct {
- UINT8 Status0;
- UINT8 Status1;
- UINT8 Status2;
- UINT8 CylinderNumber;
- UINT8 HeaderAddress;
- UINT8 Record;
- UINT8 Number;
-} FDC_RESULT_PACKET;
-
-#endif
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/FloppyPeim.c b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/FloppyPeim.c deleted file mode 100644 index 765a46dd31..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/FloppyPeim.c +++ /dev/null @@ -1,1759 +0,0 @@ -/** @file
-Floppy Peim to support Recovery function from Floppy device.
-
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
-
-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 "FloppyPeim.h"
-
-
-PEI_DMA_TABLE mRegisterTable[] = {
- //
- // DMA2: Clear Byte Ptr, Enable
- //
- {
- R_8237_DMA_CBPR_CH4_7,
- 0
- },
- {
- R_8237_DMA_COMMAND_CH4_7,
- 0
- },
- //
- // DMA1: Clear Byte Ptr, Enable
- //
- {
- R_8237_DMA_CBPR_CH0_3,
- 0
- },
- {
- R_8237_DMA_COMMAND_CH0_3,
- 0
- },
- //
- // Configure Channel 4 for Cascade Mode
- // Clear DMA Request and enable DREQ
- //
- {
- R_8237_DMA_CHMODE_CH4_7,
- V_8237_DMA_CHMODE_CASCADE | 0
- },
- {
- R_8237_DMA_STA_CH4_7,
- 0
- },
- {
- R_8237_DMA_WRSMSK_CH4_7,
- 0
- },
- //
- // Configure DMA1 (Channels 0-3) for Single Mode
- // Clear DMA Request and enable DREQ
- //
- {
- R_8237_DMA_CHMODE_CH0_3,
- V_8237_DMA_CHMODE_SINGLE | 0
- },
- {
- R_8237_DMA_STA_CH0_3,
- 0
- },
- {
- R_8237_DMA_WRSMSK_CH0_3,
- 0
- },
- {
- R_8237_DMA_CHMODE_CH0_3,
- V_8237_DMA_CHMODE_SINGLE | 1
- },
- {
- R_8237_DMA_STA_CH0_3,
- 1
- },
- {
- R_8237_DMA_WRSMSK_CH0_3,
- 1
- },
- {
- R_8237_DMA_CHMODE_CH0_3,
- V_8237_DMA_CHMODE_SINGLE | 2
- },
- {
- R_8237_DMA_STA_CH0_3,
- 2
- },
- {
- R_8237_DMA_WRSMSK_CH0_3,
- 2
- },
- {
- R_8237_DMA_CHMODE_CH0_3,
- V_8237_DMA_CHMODE_SINGLE | 3
- },
- {
- R_8237_DMA_STA_CH0_3,
- 3
- },
- {
- R_8237_DMA_WRSMSK_CH0_3,
- 3
- },
- //
- // Configure DMA2 (Channels 5-7) for Single Mode
- // Clear DMA Request and enable DREQ
- //
- {
- R_8237_DMA_CHMODE_CH4_7,
- V_8237_DMA_CHMODE_SINGLE | 1
- },
- {
- R_8237_DMA_STA_CH4_7,
- 1
- },
- {
- R_8237_DMA_WRSMSK_CH4_7,
- 1
- },
- {
- R_8237_DMA_CHMODE_CH4_7,
- V_8237_DMA_CHMODE_SINGLE | 2
- },
- {
- R_8237_DMA_STA_CH4_7,
- 2
- },
- {
- R_8237_DMA_WRSMSK_CH4_7,
- 2
- },
- {
- R_8237_DMA_CHMODE_CH4_7,
- V_8237_DMA_CHMODE_SINGLE | 3
- },
- {
- R_8237_DMA_STA_CH4_7,
- 3
- },
- {
- R_8237_DMA_WRSMSK_CH4_7,
- 3
- }
-};
-
-//
-// Table of diskette parameters of various diskette types
-//
-DISKET_PARA_TABLE DiskPara[9] = {
- {
- 0x09,
- 0x50,
- 0xff,
- 0x2,
- 0x27,
- 0x4,
- 0x25,
- 0x14,
- 0x80
- },
- {
- 0x09,
- 0x2a,
- 0xff,
- 0x2,
- 0x27,
- 0x4,
- 0x25,
- 0x0f,
- 0x40
- },
- {
- 0x0f,
- 0x54,
- 0xff,
- 0x2,
- 0x4f,
- 0x4,
- 0x25,
- 0x0f,
- 0x0
- },
- {
- 0x09,
- 0x50,
- 0xff,
- 0x2,
- 0x4f,
- 0x4,
- 0x25,
- 0x0f,
- 0x80
- },
- {
- 0x09,
- 0x2a,
- 0xff,
- 0x2,
- 0x4f,
- 0x4,
- 0x25,
- 0x0f,
- 0x80
- },
- {
- 0x12,
- 0x1b,
- 0xff,
- 0x2,
- 0x4f,
- 0x4,
- 0x25,
- 0x0f,
- 0x0
- },
- {
- 0x09,
- 0x2a,
- 0xff,
- 0x2,
- 0x4f,
- 0x4,
- 0x25,
- 0x0f,
- 0x80
- },
- {
- 0x12,
- 0x1b,
- 0xff,
- 0x2,
- 0x4f,
- 0x4,
- 0x25,
- 0x0f,
- 0x0
- },
- {
- 0x24,
- 0x1b,
- 0xff,
- 0x2,
- 0x4f,
- 0x4,
- 0x25,
- 0x0f,
- 0xc0
- }
-};
-
-//
-// Byte per sector corresponding to various device types.
-//
-UINTN BytePerSector[6] = { 0, 256, 512, 1024, 2048, 4096 };
-
-FDC_BLK_IO_DEV mBlockIoDevTemplate = {
- FDC_BLK_IO_DEV_SIGNATURE,
- {
- FdcGetNumberOfBlockDevices,
- FdcGetBlockDeviceMediaInfo,
- FdcReadBlocks,
- },
- {
- (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
- &gEfiPeiVirtualBlockIoPpiGuid,
- NULL
- },
- 0,
- {{0}}
-};
-
-/**
- Wait and check if bits for DIO and RQM of FDC Main Status Register
- indicates FDC is ready for read or write.
-
- Before writing to FDC or reading from FDC, the Host must examine
- the bit7(RQM) and bit6(DIO) of the Main Status Register.
- That is to say:
- Command bytes can not be written to Data Register unless RQM is 1 and DIO is 0.
- Result bytes can not be read from Data Register unless RQM is 1 and DIO is 1.
-
- @param FdcBlkIoDev Instance of FDC_BLK_IO_DEV.
- @param DataIn Indicates data input or output.
- TRUE means input.
- FALSE means output.
- @param TimeoutInMseconds Timeout value to wait.
-
- @retval EFI_SUCCESS FDC is ready.
- @retval EFI_NOT_READY FDC is not ready within the specified time period.
-
-**/
-EFI_STATUS
-FdcDRQReady (
- IN FDC_BLK_IO_DEV *FdcBlkIoDev,
- IN BOOLEAN DataIn,
- IN UINTN TimeoutInMseconds
- )
-{
- UINTN Delay;
- UINT8 StatusRegister;
- UINT8 BitInOut;
-
- //
- // Check bit6 of Main Status Register.
- //
- BitInOut = 0;
- if (DataIn) {
- BitInOut = BIT6;
- }
-
- Delay = ((TimeoutInMseconds * STALL_1_MSECOND) / FDC_CHECK_INTERVAL) + 1;
- do {
- StatusRegister = IoRead8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_MSR));
- if ((StatusRegister & MSR_RQM) == MSR_RQM && (StatusRegister & MSR_DIO) == BitInOut) {
- //
- // FDC is ready
- //
- break;
- }
-
- MicroSecondDelay (FDC_SHORT_DELAY);
- } while (--Delay > 0);
-
- if (Delay == 0) {
- //
- // FDC is not ready within the specified time period
- //
- return EFI_NOT_READY;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Read a byte from FDC data register.
-
- @param FdcBlkIoDev Instance of FDC_BLK_IO_DEV.
- @param Pointer Pointer to buffer to hold data read from FDC.
-
- @retval EFI_SUCCESS Byte successfully read.
- @retval EFI_DEVICE_ERROR FDC is not ready.
-
-**/
-EFI_STATUS
-DataInByte (
- IN FDC_BLK_IO_DEV *FdcBlkIoDev,
- OUT UINT8 *Pointer
- )
-{
- UINT8 Data;
-
- //
- // Wait for 1ms and detect the FDC is ready to be read
- //
- if (FdcDRQReady (FdcBlkIoDev, TRUE, 1) != EFI_SUCCESS) {
- //
- // FDC is not ready.
- //
- return EFI_DEVICE_ERROR;
- }
-
- Data = IoRead8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_DTR));
- MicroSecondDelay (FDC_SHORT_DELAY);
- *Pointer = Data;
-
- return EFI_SUCCESS;
-}
-
-/**
- Write a byte to FDC data register.
-
- @param FdcBlkIoDev Instance of FDC_BLK_IO_DEV.
- @param Pointer Pointer to data to write.
-
- @retval EFI_SUCCESS Byte successfully written.
- @retval EFI_DEVICE_ERROR FDC is not ready.
-
-**/
-EFI_STATUS
-DataOutByte (
- IN FDC_BLK_IO_DEV *FdcBlkIoDev,
- IN UINT8 *Pointer
- )
-{
- UINT8 Data;
-
- //
- // Wait for 1ms and detect the FDC is ready to be written
- //
- if (FdcDRQReady (FdcBlkIoDev, FALSE, 1) != EFI_SUCCESS) {
- //
- // FDC is not ready.
- //
- return EFI_DEVICE_ERROR;
- }
-
- Data = *Pointer;
- IoWrite8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_DTR), Data);
- MicroSecondDelay (FDC_SHORT_DELAY);
-
- return EFI_SUCCESS;
-}
-
-/**
- Get Sts0 and Pcn status from FDC
-
- @param FdcBlkIoDev Instance of FDC_BLK_IO_DEV
- @param Sts0 Value of Sts0
- @param Pcn Value of Pcn
-
- @retval EFI_SUCCESS Successfully retrieved status value of Sts0 and Pcn.
- @retval EFI_DEVICE_ERROR Fail to send SENSE_INT_STATUS_CMD.
- @retval EFI_DEVICE_ERROR Fail to read Sts0.
- @retval EFI_DEVICE_ERROR Fail to read Pcn.
-
-**/
-EFI_STATUS
-SenseIntStatus (
- IN FDC_BLK_IO_DEV *FdcBlkIoDev,
- OUT UINT8 *Sts0,
- OUT UINT8 *Pcn
- )
-{
- UINT8 Command;
-
- Command = SENSE_INT_STATUS_CMD;
-
- if (DataOutByte (FdcBlkIoDev, &Command) != EFI_SUCCESS) {
- return EFI_DEVICE_ERROR;
- }
-
- if (DataInByte (FdcBlkIoDev, Sts0) != EFI_SUCCESS) {
- return EFI_DEVICE_ERROR;
- }
-
- if (DataInByte (FdcBlkIoDev, Pcn) != EFI_SUCCESS) {
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Issue Specify command.
-
- @param FdcBlkIoDev Instance of FDC_BLK_IO_DEV.
-
- @retval EFI_SUCCESS Specify command successfully issued.
- @retval EFI_DEVICE_ERROR FDC device has errors.
-
-**/
-EFI_STATUS
-Specify (
- IN FDC_BLK_IO_DEV *FdcBlkIoDev
- )
-{
- FDC_SPECIFY_CMD Command;
- UINTN Index;
- UINT8 *Pointer;
-
- ZeroMem (&Command, sizeof (FDC_SPECIFY_CMD));
- Command.CommandCode = SPECIFY_CMD;
- //
- // set SRT, HUT
- //
- Command.SrtHut = 0xdf;
- //
- // 0xdf;
- // set HLT and DMA
- //
- Command.HltNd = 0x02;
-
- Pointer = (UINT8 *) (&Command);
- for (Index = 0; Index < sizeof (FDC_SPECIFY_CMD); Index++) {
- if (DataOutByte (FdcBlkIoDev, Pointer++) != EFI_SUCCESS) {
- return EFI_DEVICE_ERROR;
- }
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Wait until busy bit is cleared.
-
- @param FdcBlkIoDev Instance of FDC_BLK_IO_DEV.
- @param DevPos Position of FDC (Driver A or B)
- @param TimeoutInMseconds Timeout value to wait.
-
- @retval EFI_SUCCESS Busy bit has been cleared before timeout.
- @retval EFI_TIMEOUT Time goes out before busy bit is cleared.
-
-**/
-EFI_STATUS
-FdcWaitForBSYClear (
- IN FDC_BLK_IO_DEV *FdcBlkIoDev,
- IN UINT8 DevPos,
- IN UINTN TimeoutInMseconds
- )
-{
- UINTN Delay;
- UINT8 StatusRegister;
- UINT8 Mask;
-
- //
- // How to determine drive and command are busy or not: by the bits of Main Status Register
- // bit0: Drive 0 busy (drive A)
- // bit1: Drive 1 busy (drive B)
- // bit4: Command busy
- //
- // set mask: for drive A set bit0 & bit4; for drive B set bit1 & bit4
- //
- Mask = (UINT8) ((DevPos == 0 ? MSR_DAB : MSR_DBB) | MSR_CB);
-
- Delay = ((TimeoutInMseconds * STALL_1_MSECOND) / FDC_CHECK_INTERVAL) + 1;
-
- do {
- StatusRegister = IoRead8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_MSR));
-
- if ((StatusRegister & Mask) == 0x00) {
- //
- // not busy
- //
- break;
- }
-
- MicroSecondDelay (FDC_SHORT_DELAY);
- } while (--Delay > 0);
-
- if (Delay == 0) {
- return EFI_TIMEOUT;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Reset FDC device.
-
- @param FdcBlkIoDev Instance of FDC_BLK_IO_DEV
- @param DevPos Index of FDC device.
-
- @retval EFI_SUCCESS FDC device successfully reset.
- @retval EFI_DEVICE_ERROR Fail to reset FDC device.
-
-**/
-EFI_STATUS
-FdcReset (
- IN FDC_BLK_IO_DEV *FdcBlkIoDev,
- IN UINT8 DevPos
- )
-{
- UINT8 Data;
- UINT8 Sts0;
- UINT8 Pcn;
- UINTN Index;
-
- //
- // Reset specified Floppy Logic Drive according to Fdd -> Disk
- // Set Digital Output Register(DOR) to do reset work
- // bit0 & bit1 of DOR : Drive Select
- // bit2 : Reset bit
- // bit3 : DMA and Int bit
- // Reset : A "0" written to bit2 resets the FDC, this reset will remain active until
- // a "1" is written to this bit.
- // Reset step 1:
- // use bit0 & bit1 to select the logic drive
- // write "0" to bit2
- //
- Data = 0x0;
- Data = (UINT8) (Data | (SELECT_DRV & DevPos));
- IoWrite8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_DOR), Data);
-
- //
- // Wait some time, at least 120us.
- //
- MicroSecondDelay (FDC_RESET_DELAY);
- //
- // Reset step 2:
- // write "1" to bit2
- // write "1" to bit3 : enable DMA
- //
- Data |= 0x0C;
- IoWrite8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_DOR), Data);
-
- MicroSecondDelay (FDC_RESET_DELAY);
-
- //
- // Wait until specified floppy logic drive is not busy
- //
- if (FdcWaitForBSYClear (FdcBlkIoDev, DevPos, 1) != EFI_SUCCESS) {
- return EFI_DEVICE_ERROR;
- }
- //
- // Set the Transfer Data Rate
- //
- IoWrite8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_CCR), 0x0);
-
- MicroSecondDelay (FDC_MEDIUM_DELAY);
-
- //
- // Issue Sense interrupt command for each drive (totally 4 drives)
- //
- for (Index = 0; Index < 4; Index++) {
- if (SenseIntStatus (FdcBlkIoDev, &Sts0, &Pcn) != EFI_SUCCESS) {
- return EFI_DEVICE_ERROR;
- }
- }
- //
- // Issue Specify command
- //
- if (Specify (FdcBlkIoDev) != EFI_SUCCESS) {
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Turn on the motor of floppy drive.
-
- @param FdcBlkIoDev Instance of FDC_BLK_IO_DEV.
- @param Info Information of floppy device.
-
- @retval EFI_SUCCESS Motor is successfully turned on.
- @retval EFI_SUCCESS Motor is already on.
- @retval EFI_DEVICE_ERROR Busy bit of FDC cannot be cleared.
-
-**/
-EFI_STATUS
-MotorOn (
- IN FDC_BLK_IO_DEV *FdcBlkIoDev,
- IN OUT PEI_FLOPPY_DEVICE_INFO *Info
- )
-{
- UINT8 Data;
- UINT8 DevPos;
-
- //
- // Control of the floppy drive motors is a big pain. If motor is off, you have to turn it
- // on first. But you can not leave the motor on all the time, since that would wear out the
- // disk. On the other hand, if you turn the motor off after each operation, the system performance
- // will be awful. The compromise used in this driver is to leave the motor on for 2 seconds after
- // each operation. If a new operation is started in that interval(2s), the motor need not be
- // turned on again. If no new operation is started, a timer goes off and the motor is turned off.
- //
- DevPos = Info->DevPos;
-
- //
- // If the Motor is already on, just return EFI_SUCCESS.
- //
- if (Info->MotorOn) {
- return EFI_SUCCESS;
- }
- //
- // The drive's motor is off, so need turn it on.
- // First check if command and drive are busy or not.
- //
- if (FdcWaitForBSYClear (FdcBlkIoDev, DevPos, 1) != EFI_SUCCESS) {
- return EFI_DEVICE_ERROR;
- }
- //
- // for drive A: 1CH, drive B: 2DH
- //
- Data = 0x0C;
- Data = (UINT8) (Data | (SELECT_DRV & DevPos));
- if (DevPos == 0) {
- Data |= DRVA_MOTOR_ON;
- } else {
- Data |= DRVB_MOTOR_ON;
- }
-
- Info->MotorOn = FALSE;
-
- //
- // Turn on the motor and wait for some time to ensure it takes effect.
- //
- IoWrite8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_DOR), Data);
- MicroSecondDelay (FDC_LONG_DELAY);
-
- Info->MotorOn = TRUE;
-
- return EFI_SUCCESS;
-}
-
-/**
- Turn off the motor of floppy drive.
-
- @param FdcBlkIoDev Instance of FDC_BLK_IO_DEV.
- @param Info Information of floppy device.
-
-**/
-VOID
-MotorOff (
- IN FDC_BLK_IO_DEV *FdcBlkIoDev,
- IN OUT PEI_FLOPPY_DEVICE_INFO *Info
- )
-{
- UINT8 Data;
- UINT8 DevPos;
-
- DevPos = Info->DevPos;
-
- if (!Info->MotorOn) {
- return;
- }
- //
- // The motor is on, so need motor off
- //
- Data = 0x0C;
- Data = (UINT8) (Data | (SELECT_DRV & DevPos));
-
- IoWrite8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_DOR), Data);
- MicroSecondDelay (FDC_SHORT_DELAY);
-
- Info->MotorOn = FALSE;
-}
-
-/**
- Recalibrate the FDC device.
-
- @param FdcBlkIoDev Instance of FDC_BLK_IO_DEV.
- @param Info Information of floppy device.
-
- @retval EFI_SUCCESS FDC successfully recalibrated.
- @retval EFI_DEVICE_ERROR Fail to send RECALIBRATE_CMD.
- @retval EFI_DEVICE_ERROR Fail to get status value of Sts0 and Pcn.
- @retval EFI_DEVICE_ERROR Fail to recalibrate FDC device.
-
-**/
-EFI_STATUS
-Recalibrate (
- IN FDC_BLK_IO_DEV *FdcBlkIoDev,
- IN OUT PEI_FLOPPY_DEVICE_INFO *Info
- )
-{
- FDC_COMMAND_PACKET2 Command;
- UINTN Index;
- UINT8 Sts0;
- UINT8 Pcn;
- UINT8 *Pointer;
- UINT8 Count;
- UINT8 DevPos;
-
- DevPos = Info->DevPos;
-
- //
- // We would try twice.
- //
- Count = 2;
- while (Count > 0) {
- ZeroMem (&Command, sizeof (FDC_COMMAND_PACKET2));
- Command.CommandCode = RECALIBRATE_CMD;
- //
- // drive select
- //
- if (DevPos == 0) {
- Command.DiskHeadSel = 0;
- } else {
- Command.DiskHeadSel = 1;
- }
-
- Pointer = (UINT8 *) (&Command);
- for (Index = 0; Index < sizeof (FDC_COMMAND_PACKET2); Index++) {
- if (DataOutByte (FdcBlkIoDev, Pointer++) != EFI_SUCCESS) {
- return EFI_DEVICE_ERROR;
- }
- }
-
- MicroSecondDelay (FDC_RECALIBRATE_DELAY);
-
- if (SenseIntStatus (FdcBlkIoDev, &Sts0, &Pcn) != EFI_SUCCESS) {
- return EFI_DEVICE_ERROR;
- }
-
- if ((Sts0 & 0xf0) == BIT5 && Pcn == 0) {
- //
- // Recalibration is successful.
- //
- Info->Pcn = 0;
- Info->NeedRecalibrate = FALSE;
-
- return EFI_SUCCESS;
- } else {
- //
- // Recalibration is not successful. Try again.
- // If trial is used out, return EFI_DEVICE_ERROR.
- //
- Count--;
- if (Count == 0) {
- return EFI_DEVICE_ERROR;
- }
- }
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Seek for the cylinder according to given LBA.
-
- @param FdcBlkIoDev Instance of FDC_BLK_IO_DEV.
- @param Info Information of floppy device.
- @param Lba LBA for which to seek for cylinder.
-
- @retval EFI_SUCCESS Successfully moved to the destination cylinder.
- @retval EFI_SUCCESS Destination cylinder is just the present cylinder.
- @retval EFI_DEVICE_ERROR Fail to move to the destination cylinder.
-
-**/
-EFI_STATUS
-Seek (
- IN FDC_BLK_IO_DEV *FdcBlkIoDev,
- IN OUT PEI_FLOPPY_DEVICE_INFO *Info,
- IN EFI_PEI_LBA Lba
- )
-{
- FDC_SEEK_CMD Command;
- DISKET_PARA_TABLE *Para;
- UINT8 EndOfTrack;
- UINT8 Head;
- UINT8 Cylinder;
- UINT8 Sts0;
- UINT8 *Pointer;
- UINT8 Pcn;
- UINTN Index;
- UINT8 Gap;
- UINT8 DevPos;
-
- DevPos = Info->DevPos;
- if (Info->NeedRecalibrate) {
- if (Recalibrate (FdcBlkIoDev, Info) != EFI_SUCCESS) {
- return EFI_DEVICE_ERROR;
- }
- //
- // Recalibrate Success
- //
- Info->NeedRecalibrate = FALSE;
- }
-
- //
- // Get the base of disk parameter information corresponding to its type.
- //
- Para = (DISKET_PARA_TABLE *) ((UINT8 *) DiskPara + sizeof (DISKET_PARA_TABLE) * Info->Type);
- EndOfTrack = Para->EndOfTrack;
- //
- // Calculate cylinder based on Lba and EOT
- //
- Cylinder = (UINT8) ((UINTN) Lba / EndOfTrack / 2);
-
- //
- // If the dest cylinder is the present cylinder, unnecessary to do the seek operation
- //
- if (Info->Pcn == Cylinder) {
- return EFI_SUCCESS;
- }
-
- //
- // Calculate the head : 0 or 1
- //
- Head = (UINT8) ((UINTN) Lba / EndOfTrack % 2);
-
- ZeroMem (&Command, sizeof (FDC_SEEK_CMD));
- Command.CommandCode = SEEK_CMD;
- if (DevPos == 0) {
- Command.DiskHeadSel = 0;
- } else {
- Command.DiskHeadSel = 1;
- }
-
- //
- // Send command to move to destination cylinder.
- //
- Command.DiskHeadSel = (UINT8) (Command.DiskHeadSel | (Head << 2));
- Command.NewCylinder = Cylinder;
-
- Pointer = (UINT8 *) (&Command);
- for (Index = 0; Index < sizeof (FDC_SEEK_CMD); Index++) {
- if (DataOutByte (FdcBlkIoDev, Pointer++) != EFI_SUCCESS) {
- return EFI_DEVICE_ERROR;
- }
- }
-
- MicroSecondDelay (FDC_SHORT_DELAY);
-
- //
- // Calculate waiting time, which is proportional to the gap between destination
- // cylinder and present cylinder.
- //
- if (Info->Pcn > Cylinder) {
- Gap = (UINT8) (Info->Pcn - Cylinder);
- } else {
- Gap = (UINT8) (Cylinder - Info->Pcn);
- }
-
- MicroSecondDelay ((Gap + 1) * FDC_LONG_DELAY);
-
- //
- // Confirm if the new cylinder is the destination and status is correct.
- //
- if (SenseIntStatus (FdcBlkIoDev, &Sts0, &Pcn) != EFI_SUCCESS) {
- return EFI_DEVICE_ERROR;
- }
-
- if ((Sts0 & 0xf0) == BIT5) {
- Info->Pcn = Command.NewCylinder;
- Info->NeedRecalibrate = FALSE;
- return EFI_SUCCESS;
- } else {
- Info->NeedRecalibrate = TRUE;
- return EFI_DEVICE_ERROR;
- }
-}
-
-/**
- Check if diskette is changed.
-
- @param FdcBlkIoDev Instance of FDC_BLK_IO_DEV
- @param Info Information of floppy device.
-
- @retval EFI_SUCCESS Diskette is not changed.
- @retval EFI_MEDIA_CHANGED Diskette is changed.
- @retval EFI_NO_MEDIA No diskette.
- @retval EFI_DEVICE_ERROR Fail to do the seek or recalibrate operation.
-
-**/
-EFI_STATUS
-DisketChanged (
- IN FDC_BLK_IO_DEV *FdcBlkIoDev,
- IN OUT PEI_FLOPPY_DEVICE_INFO *Info
- )
-{
- EFI_STATUS Status;
- UINT8 Data;
-
- //
- // Check change line
- //
- Data = IoRead8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_DIR));
-
- MicroSecondDelay (FDC_SHORT_DELAY);
-
- if ((Data & DIR_DCL) == DIR_DCL) {
- if (Info->Pcn != 0) {
- Status = Recalibrate (FdcBlkIoDev, Info);
- } else {
- Status = Seek (FdcBlkIoDev, Info, 0x30);
- }
-
- if (Status != EFI_SUCCESS) {
- //
- // Fail to do the seek or recalibrate operation
- //
- return EFI_DEVICE_ERROR;
- }
-
- Data = IoRead8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_DIR));
-
- MicroSecondDelay (FDC_SHORT_DELAY);
-
- if ((Data & DIR_DCL) == DIR_DCL) {
- return EFI_NO_MEDIA;
- }
-
- return EFI_MEDIA_CHANGED;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Detects if FDC device exists.
-
- @param FdcBlkIoDev Instance of FDC_BLK_IO_DEV
- @param Info Information of floppy device.
- @param MediaInfo Information of floppy media.
-
- @retval TRUE FDC device exists and is working properly.
- @retval FALSE FDC device does not exist or cannot work properly.
-
-**/
-BOOLEAN
-DiscoverFdcDevice (
- IN FDC_BLK_IO_DEV *FdcBlkIoDev,
- IN OUT PEI_FLOPPY_DEVICE_INFO *Info,
- OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo
- )
-{
- EFI_STATUS Status;
- DISKET_PARA_TABLE *Para;
-
- Status = MotorOn (FdcBlkIoDev, Info);
- if (Status != EFI_SUCCESS) {
- return FALSE;
- }
-
- Status = Recalibrate (FdcBlkIoDev, Info);
-
- if (Status != EFI_SUCCESS) {
- MotorOff (FdcBlkIoDev, Info);
- return FALSE;
- }
- //
- // Set Media Parameter
- //
- MediaInfo->DeviceType = LegacyFloppy;
- MediaInfo->MediaPresent = TRUE;
-
- //
- // Check Media
- //
- Status = DisketChanged (FdcBlkIoDev, Info);
- if (Status == EFI_NO_MEDIA) {
- //
- // No diskette in floppy.
- //
- MediaInfo->MediaPresent = FALSE;
- } else if (Status != EFI_MEDIA_CHANGED && Status != EFI_SUCCESS) {
- //
- // EFI_DEVICE_ERROR
- //
- MotorOff (FdcBlkIoDev, Info);
- return FALSE;
- }
-
- MotorOff (FdcBlkIoDev, Info);
-
- //
- // Get the base of disk parameter information corresponding to its type.
- //
- Para = (DISKET_PARA_TABLE *) ((UINT8 *) DiskPara + sizeof (DISKET_PARA_TABLE) * Info->Type);
-
- MediaInfo->BlockSize = BytePerSector[Para->Number];
- MediaInfo->LastBlock = Para->EndOfTrack * 2 * (Para->MaxTrackNum + 1) - 1;
-
- return TRUE;
-}
-
-/**
- Enumerate floppy device
-
- @param FdcBlkIoDev Instance of floppy device controller
-
- @return Number of FDC devices.
-
-**/
-UINT8
-FdcEnumeration (
- IN FDC_BLK_IO_DEV *FdcBlkIoDev
- )
-{
- UINT8 DevPos;
- UINT8 DevNo;
- EFI_PEI_BLOCK_IO_MEDIA MediaInfo;
- EFI_STATUS Status;
-
- DevNo = 0;
-
- //
- // DevPos=0 means Drive A, 1 means Drive B.
- //
- for (DevPos = 0; DevPos < 2; DevPos++) {
- //
- // Detecting device presence
- //
- REPORT_STATUS_CODE (EFI_PROGRESS_CODE, EFI_PERIPHERAL_REMOVABLE_MEDIA + EFI_P_PC_PRESENCE_DETECT);
-
- //
- // Reset FDC
- //
- Status = FdcReset (FdcBlkIoDev, DevPos);
-
- if (EFI_ERROR (Status)) {
- continue;
- }
-
- FdcBlkIoDev->DeviceInfo[DevPos].DevPos = DevPos;
- FdcBlkIoDev->DeviceInfo[DevPos].Pcn = 0;
- FdcBlkIoDev->DeviceInfo[DevPos].MotorOn = FALSE;
- FdcBlkIoDev->DeviceInfo[DevPos].NeedRecalibrate = TRUE;
- FdcBlkIoDev->DeviceInfo[DevPos].Type = FdcType1440K1440K;
-
- //
- // Discover FDC device
- //
- if (DiscoverFdcDevice (FdcBlkIoDev, &(FdcBlkIoDev->DeviceInfo[DevPos]), &MediaInfo)) {
- FdcBlkIoDev->DeviceInfo[DevNo].DevPos = DevPos;
-
- FdcBlkIoDev->DeviceInfo[DevNo].Pcn = FdcBlkIoDev->DeviceInfo[DevPos].Pcn;
- FdcBlkIoDev->DeviceInfo[DevNo].MotorOn = FdcBlkIoDev->DeviceInfo[DevPos].MotorOn;
- FdcBlkIoDev->DeviceInfo[DevNo].NeedRecalibrate = FdcBlkIoDev->DeviceInfo[DevPos].NeedRecalibrate;
- FdcBlkIoDev->DeviceInfo[DevNo].Type = FdcBlkIoDev->DeviceInfo[DevPos].Type;
-
- CopyMem (
- &(FdcBlkIoDev->DeviceInfo[DevNo].MediaInfo),
- &MediaInfo,
- sizeof (EFI_PEI_BLOCK_IO_MEDIA)
- );
-
- DevNo++;
- } else {
- //
- // Assume controller error
- //
- REPORT_STATUS_CODE (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_PERIPHERAL_REMOVABLE_MEDIA + EFI_P_EC_CONTROLLER_ERROR
- );
- }
- }
-
- FdcBlkIoDev->DeviceCount = DevNo;
- return DevNo;
-}
-
-/**
- Checks result reflected by FDC_RESULT_PACKET.
-
- @param Result FDC_RESULT_PACKET read from FDC after certain operation.
- @param Info Information of floppy device.
-
- @retval EFI_SUCCESS Result is healthy.
- @retval EFI_DEVICE_ERROR Result is not healthy.
-
-**/
-EFI_STATUS
-CheckResult (
- IN FDC_RESULT_PACKET *Result,
- OUT PEI_FLOPPY_DEVICE_INFO *Info
- )
-{
- if ((Result->Status0 & STS0_IC) != IC_NT) {
- if ((Result->Status0 & STS0_SE) == BIT5) {
- //
- // Seek error
- //
- Info->NeedRecalibrate = TRUE;
- }
-
- Info->NeedRecalibrate = TRUE;
- return EFI_DEVICE_ERROR;
- }
- //
- // Check Status Register1
- //
- if ((Result->Status1 & (STS1_EN | STS1_DE | STS1_OR | STS1_ND | STS1_NW | STS1_MA)) != 0) {
- Info->NeedRecalibrate = TRUE;
- return EFI_DEVICE_ERROR;
- }
- //
- // Check Status Register2
- //
- if ((Result->Status2 & (STS2_CM | STS2_DD | STS2_WC | STS2_BC | STS2_MD)) != 0) {
- Info->NeedRecalibrate = TRUE;
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Fill parameters for command packet.
-
- @param Info Information of floppy device.
- @param Lba Logical block address.
- @param Command Command for which for fill parameters.
-
-**/
-VOID
-FillPara (
- IN PEI_FLOPPY_DEVICE_INFO *Info,
- IN EFI_PEI_LBA Lba,
- OUT FDC_COMMAND_PACKET1 *Command
- )
-{
- DISKET_PARA_TABLE *Para;
- UINT8 EndOfTrack;
- UINT8 DevPos;
-
- DevPos = Info->DevPos;
-
- //
- // Get the base of disk parameter information corresponding to its type.
- //
- Para = (DISKET_PARA_TABLE *) ((UINT8 *) DiskPara + sizeof (DISKET_PARA_TABLE) * Info->Type);
-
- EndOfTrack = Para->EndOfTrack;
-
- if (DevPos == 0) {
- Command->DiskHeadSel = 0;
- } else {
- Command->DiskHeadSel = 1;
- }
-
- Command->Cylinder = (UINT8) ((UINTN) Lba / EndOfTrack / 2);
- Command->Head = (UINT8) ((UINTN) Lba / EndOfTrack % 2);
- Command->Sector = (UINT8) ((UINT8) ((UINTN) Lba % EndOfTrack) + 1);
- Command->DiskHeadSel = (UINT8) (Command->DiskHeadSel | (Command->Head << 2));
- Command->Number = Para->Number;
- Command->EndOfTrack = Para->EndOfTrack;
- Command->GapLength = Para->GapLength;
- Command->DataLength = Para->DataLength;
-}
-
-/**
- Setup specifed FDC device.
-
- @param FdcBlkIoDev Instance of FDC_BLK_IO_DEV.
- @param DevPos Index of FDC device.
-
- @retval EFI_SUCCESS FDC device successfully set up.
- @retval EFI_DEVICE_ERROR FDC device has errors.
-
-**/
-EFI_STATUS
-Setup (
- IN FDC_BLK_IO_DEV *FdcBlkIoDev,
- IN UINT8 DevPos
- )
-{
- EFI_STATUS Status;
-
- IoWrite8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_CCR), 0x0);
-
- MicroSecondDelay (FDC_MEDIUM_DELAY);
-
- Status = Specify (FdcBlkIoDev);
- return Status;
-}
-
-/**
- Setup DMA channels to read data.
-
- @param FdcBlkIoDev Instance of FDC_BLK_IO_DEV.
- @param Buffer Memory buffer for DMA transfer.
- @param BlockSize the number of the bytes in one block.
- @param NumberOfBlocks Number of blocks to read.
-
-**/
-VOID
-SetDMA (
- IN FDC_BLK_IO_DEV *FdcBlkIoDev,
- IN VOID *Buffer,
- IN UINTN BlockSize,
- IN UINTN NumberOfBlocks
- )
-{
- UINT8 Data;
- UINTN Count;
-
- //
- // Mask DMA channel 2;
- //
- IoWrite8 (R_8237_DMA_WRSMSK_CH0_3, B_8237_DMA_WRSMSK_CMS | 2);
-
- //
- // Clear first/last flip flop
- //
- IoWrite8 (R_8237_DMA_CBPR_CH0_3, B_8237_DMA_WRSMSK_CMS | 2);
-
- //
- // Set mode
- //
- IoWrite8 (R_8237_DMA_CHMODE_CH0_3, V_8237_DMA_CHMODE_SINGLE | V_8237_DMA_CHMODE_IO2MEM | 2);
-
- //
- // Set base address and page register
- //
- Data = (UINT8) (UINTN) Buffer;
- IoWrite8 (R_8237_DMA_BASE_CA_CH2, Data);
- Data = (UINT8) ((UINTN) Buffer >> 8);
- IoWrite8 (R_8237_DMA_BASE_CA_CH2, Data);
-
- Data = (UINT8) ((UINTN) Buffer >> 16);
- IoWrite8 (R_8237_DMA_MEM_LP_CH2, Data);
-
- //
- // Set count register
- //
- Count = BlockSize * NumberOfBlocks - 1;
- Data = (UINT8) (Count & 0xff);
- IoWrite8 (R_8237_DMA_BASE_CC_CH2, Data);
- Data = (UINT8) (Count >> 8);
- IoWrite8 (R_8237_DMA_BASE_CC_CH2, Data);
-
- //
- // Clear channel 2 mask
- //
- IoWrite8 (R_8237_DMA_WRSMSK_CH0_3, 0x02);
-}
-
-
-/**
- According to the block range specified by Lba and NumberOfBlocks, calculate
- the number of blocks in the same sector, which can be transferred in a batch.
-
- @param Info Information of floppy device.
- @param Lba Start address of block range.
- @param NumberOfBlocks Number of blocks of the range.
-
- @return Number of blocks in the same sector.
-
-**/
-UINTN
-GetTransferBlockCount (
- IN PEI_FLOPPY_DEVICE_INFO *Info,
- IN EFI_PEI_LBA Lba,
- IN UINTN NumberOfBlocks
- )
-{
- DISKET_PARA_TABLE *Para;
- UINT8 EndOfTrack;
- UINT8 Head;
- UINT8 SectorsInTrack;
-
- //
- // Get the base of disk parameter information corresponding to its type.
- //
- Para = (DISKET_PARA_TABLE *) ((UINT8 *) DiskPara + sizeof (DISKET_PARA_TABLE) * Info->Type);
-
- EndOfTrack = Para->EndOfTrack;
- Head = (UINT8) ((UINTN) Lba / EndOfTrack % 2);
-
- SectorsInTrack = (UINT8) (EndOfTrack * (2 - Head) - (UINT8) ((UINTN) Lba % EndOfTrack));
- if (SectorsInTrack < NumberOfBlocks) {
- //
- // Not all the block range locates in the same sector
- //
- return SectorsInTrack;
- } else {
- //
- // All the block range is in the same sector.
- //
- return NumberOfBlocks;
- }
-}
-
-/**
- Read data sector from FDC device.
-
- @param FdcBlkIoDev Instance of FDC_BLK_IO_DEV.
- @param Info Information of floppy device.
- @param Buffer Buffer to setup for DMA.
- @param Lba The start address to read.
- @param NumberOfBlocks Number of blocks to read.
-
- @retval EFI_SUCCESS Data successfully read out.
- @retval EFI_DEVICE_ERROR FDC device has errors.
- @retval EFI_TIMEOUT Command does not take effect in time.
-
-**/
-EFI_STATUS
-ReadDataSector (
- IN FDC_BLK_IO_DEV *FdcBlkIoDev,
- IN OUT PEI_FLOPPY_DEVICE_INFO *Info,
- IN VOID *Buffer,
- IN EFI_PEI_LBA Lba,
- IN UINTN NumberOfBlocks
- )
-{
- EFI_STATUS Status;
- FDC_COMMAND_PACKET1 Command;
- FDC_RESULT_PACKET Result;
- UINTN Index;
- UINTN Times;
- UINT8 *Pointer;
-
- Status = Seek (FdcBlkIoDev, Info, Lba);
- if (Status != EFI_SUCCESS) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // Set up DMA
- //
- SetDMA (FdcBlkIoDev, Buffer, Info->MediaInfo.BlockSize, NumberOfBlocks);
-
- //
- // Allocate Read command packet
- //
- ZeroMem (&Command, sizeof (FDC_COMMAND_PACKET1));
- Command.CommandCode = READ_DATA_CMD | CMD_MT | CMD_MFM | CMD_SK;
-
- //
- // Fill parameters for command.
- //
- FillPara (Info, Lba, &Command);
-
- //
- // Write command bytes to FDC
- //
- Pointer = (UINT8 *) (&Command);
- for (Index = 0; Index < sizeof (FDC_COMMAND_PACKET1); Index++) {
- if (DataOutByte (FdcBlkIoDev, Pointer++) != EFI_SUCCESS) {
- return EFI_DEVICE_ERROR;
- }
- }
-
- //
- // Wait for some time until command takes effect.
- //
- Times = (STALL_1_SECOND / FDC_CHECK_INTERVAL) + 1;
- do {
- if ((IoRead8 ((UINT16) (PcdGet16 (PcdFdcBaseAddress) + FDC_REGISTER_MSR)) & 0xc0) == 0xc0) {
- break;
- }
-
- MicroSecondDelay (FDC_SHORT_DELAY);
- } while (--Times > 0);
-
- if (Times == 0) {
- //
- // Command fails to take effect in time, return EFI_TIMEOUT.
- //
- return EFI_TIMEOUT;
- }
-
- //
- // Read result bytes from FDC
- //
- Pointer = (UINT8 *) (&Result);
- for (Index = 0; Index < sizeof (FDC_RESULT_PACKET); Index++) {
- if (DataInByte (FdcBlkIoDev, Pointer++) != EFI_SUCCESS) {
- return EFI_DEVICE_ERROR;
- }
- }
-
- return CheckResult (&Result, Info);
-}
-
-/**
- Gets the count of block I/O devices that one specific block driver detects.
-
- This function is used for getting the count of block I/O devices that one
- specific block driver detects. To the PEI ATAPI driver, it returns the number
- of all the detected ATAPI devices it detects during the enumeration process.
- To the PEI legacy floppy driver, it returns the number of all the legacy
- devices it finds during its enumeration process. If no device is detected,
- then the function will return zero.
-
- @param[in] PeiServices General-purpose services that are available
- to every PEIM.
- @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI
- instance.
- @param[out] NumberBlockDevices The number of block I/O devices discovered.
-
- @retval EFI_SUCCESS Operation performed successfully.
-
-**/
-EFI_STATUS
-EFIAPI
-FdcGetNumberOfBlockDevices (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
- OUT UINTN *NumberBlockDevices
- )
-{
- FDC_BLK_IO_DEV *FdcBlkIoDev;
-
- FdcBlkIoDev = NULL;
-
- FdcBlkIoDev = PEI_RECOVERY_FDC_FROM_BLKIO_THIS (This);
-
- *NumberBlockDevices = FdcBlkIoDev->DeviceCount;
-
- return EFI_SUCCESS;
-}
-
-/**
- Gets a block device's media information.
-
- This function will provide the caller with the specified block device's media
- information. If the media changes, calling this function will update the media
- information accordingly.
-
- @param[in] PeiServices General-purpose services that are available to every
- PEIM
- @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI instance.
- @param[in] DeviceIndex Specifies the block device to which the function wants
- to talk. Because the driver that implements Block I/O
- PPIs will manage multiple block devices, the PPIs that
- want to talk to a single device must specify the
- device index that was assigned during the enumeration
- process. This index is a number from one to
- NumberBlockDevices.
- @param[out] MediaInfo The media information of the specified block media.
- The caller is responsible for the ownership of this
- data structure.
-
- @retval EFI_SUCCESS Media information about the specified block device
- was obtained successfully.
- @retval EFI_DEVICE_ERROR Cannot get the media information due to a hardware
- error.
- @retval Others Other failure occurs.
-
-**/
-EFI_STATUS
-EFIAPI
-FdcGetBlockDeviceMediaInfo (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
- IN UINTN DeviceIndex,
- OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo
- )
-{
- UINTN DeviceCount;
- FDC_BLK_IO_DEV *FdcBlkIoDev;
- BOOLEAN Healthy;
- UINTN Index;
-
- FdcBlkIoDev = NULL;
-
- if (This == NULL || MediaInfo == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- FdcBlkIoDev = PEI_RECOVERY_FDC_FROM_BLKIO_THIS (This);
-
- DeviceCount = FdcBlkIoDev->DeviceCount;
-
- //
- // DeviceIndex is a value from 1 to NumberBlockDevices.
- //
- if ((DeviceIndex < 1) || (DeviceIndex > DeviceCount) || (DeviceIndex > 2)) {
- return EFI_INVALID_PARAMETER;
- }
-
- Index = DeviceIndex - 1;
- //
- // Probe media and retrieve latest media information
- //
- Healthy = DiscoverFdcDevice (
- FdcBlkIoDev,
- &FdcBlkIoDev->DeviceInfo[Index],
- MediaInfo
- );
-
- if (!Healthy) {
- return EFI_DEVICE_ERROR;
- }
-
- CopyMem (
- &(FdcBlkIoDev->DeviceInfo[Index].MediaInfo),
- MediaInfo,
- sizeof (EFI_PEI_BLOCK_IO_MEDIA)
- );
-
- return EFI_SUCCESS;
-}
-
-/**
- Reads the requested number of blocks from the specified block device.
-
- The function reads the requested number of blocks from the device. All the
- blocks are read, or an error is returned. If there is no media in the device,
- the function returns EFI_NO_MEDIA.
-
- @param[in] PeiServices General-purpose services that are available to
- every PEIM.
- @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI instance.
- @param[in] DeviceIndex Specifies the block device to which the function wants
- to talk. Because the driver that implements Block I/O
- PPIs will manage multiple block devices, the PPIs that
- want to talk to a single device must specify the device
- index that was assigned during the enumeration process.
- This index is a number from one to NumberBlockDevices.
- @param[in] StartLBA The starting logical block address (LBA) to read from
- on the device
- @param[in] BufferSize The size of the Buffer in bytes. This number must be
- a multiple of the intrinsic block size of the device.
- @param[out] Buffer A pointer to the destination buffer for the data.
- The caller is responsible for the ownership of the
- buffer.
-
- @retval EFI_SUCCESS The data was read correctly from the device.
- @retval EFI_DEVICE_ERROR The device reported an error while attempting
- to perform the read operation.
- @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not
- valid, or the buffer is not properly aligned.
- @retval EFI_NO_MEDIA There is no media in the device.
- @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of
- the intrinsic block size of the device.
-
-**/
-EFI_STATUS
-EFIAPI
-FdcReadBlocks (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
- IN UINTN DeviceIndex,
- IN EFI_PEI_LBA StartLBA,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- )
-{
- EFI_PEI_BLOCK_IO_MEDIA MediaInfo;
- EFI_STATUS Status;
- UINTN Count;
- UINTN NumberOfBlocks;
- UINTN BlockSize;
- FDC_BLK_IO_DEV *FdcBlkIoDev;
- VOID *MemPage;
-
- FdcBlkIoDev = NULL;
- ZeroMem (&MediaInfo, sizeof (EFI_PEI_BLOCK_IO_MEDIA));
-
- if (This == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- FdcBlkIoDev = PEI_RECOVERY_FDC_FROM_BLKIO_THIS (This);
-
- if (Buffer == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- Status = FdcGetBlockDeviceMediaInfo (PeiServices, This, DeviceIndex, &MediaInfo);
- if (Status != EFI_SUCCESS) {
- return EFI_DEVICE_ERROR;
- }
-
- if (!MediaInfo.MediaPresent) {
- return EFI_NO_MEDIA;
- }
-
- BlockSize = MediaInfo.BlockSize;
-
- //
- // If BufferSize cannot be divided by block size of FDC device,
- // return EFI_BAD_BUFFER_SIZE.
- //
- if (BufferSize % BlockSize != 0) {
- return EFI_BAD_BUFFER_SIZE;
- }
-
- NumberOfBlocks = BufferSize / BlockSize;
-
- if ((StartLBA + NumberOfBlocks - 1) > FdcBlkIoDev->DeviceInfo[DeviceIndex - 1].MediaInfo.LastBlock) {
- return EFI_INVALID_PARAMETER;
- }
-
- MemPage = AllocatePages (EFI_SIZE_TO_PAGES (BufferSize));
- if ((MemPage == NULL) || ((UINTN) MemPage >= ISA_MAX_MEMORY_ADDRESS)) {
- //
- // If fail to allocate memory under ISA_MAX_MEMORY_ADDRESS, designate the address space for DMA
- //
- MemPage = (VOID *) ((UINTN) (UINT32) 0x0f00000);
- }
- Status = MotorOn (FdcBlkIoDev, &(FdcBlkIoDev->DeviceInfo[DeviceIndex - 1]));
- if (Status != EFI_SUCCESS) {
- return EFI_DEVICE_ERROR;
- }
-
- Status = Setup (FdcBlkIoDev, FdcBlkIoDev->DeviceInfo[DeviceIndex - 1].DevPos);
- if (Status != EFI_SUCCESS) {
- MotorOff (FdcBlkIoDev, &(FdcBlkIoDev->DeviceInfo[DeviceIndex - 1]));
- return EFI_DEVICE_ERROR;
- }
- //
- // Read data in batches.
- // Blocks in the same cylinder are read out in a batch.
- //
- while ((Count = GetTransferBlockCount (
- &(FdcBlkIoDev->DeviceInfo[DeviceIndex - 1]),
- StartLBA,
- NumberOfBlocks
- )) != 0 && Status == EFI_SUCCESS) {
- Status = ReadDataSector (
- FdcBlkIoDev,
- &(FdcBlkIoDev->DeviceInfo[DeviceIndex - 1]),
- MemPage,
- StartLBA,
- Count
- );
- CopyMem (Buffer, MemPage, BlockSize * Count);
- StartLBA += Count;
- NumberOfBlocks -= Count;
- Buffer = (VOID *) ((UINTN) Buffer + Count * BlockSize);
- }
-
- MotorOff (FdcBlkIoDev, &(FdcBlkIoDev->DeviceInfo[DeviceIndex - 1]));
-
- switch (Status) {
- case EFI_SUCCESS:
- return EFI_SUCCESS;
-
- default:
- FdcReset (FdcBlkIoDev, FdcBlkIoDev->DeviceInfo[DeviceIndex - 1].DevPos);
- return EFI_DEVICE_ERROR;
- }
-}
-
-/**
- Initializes the floppy disk controller and installs FDC Block I/O PPI.
-
- @param FileHandle Handle of the file being invoked.
- @param PeiServices Describes the list of possible PEI Services.
-
- @retval EFI_SUCCESS Successfully initialized FDC and installed PPI.
- @retval EFI_NOT_FOUND Cannot find FDC device.
- @retval EFI_OUT_OF_RESOURCES Have no enough memory to create instance or descriptors.
- @retval Other Fail to install FDC Block I/O PPI.
-
-**/
-EFI_STATUS
-EFIAPI
-FdcPeimEntry (
- IN EFI_PEI_FILE_HANDLE FileHandle,
- IN CONST EFI_PEI_SERVICES **PeiServices
- )
-{
- EFI_STATUS Status;
- FDC_BLK_IO_DEV *FdcBlkIoDev;
- UINTN DeviceCount;
- UINT32 Index;
-
- Status = PeiServicesRegisterForShadow (FileHandle);
- if (!EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Allocate memory for instance of FDC_BLK_IO_DEV and copy initial value
- // from template to it.
- //
- FdcBlkIoDev = AllocatePages (EFI_SIZE_TO_PAGES(sizeof (FDC_BLK_IO_DEV)));
- if (FdcBlkIoDev == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- CopyMem (FdcBlkIoDev, &mBlockIoDevTemplate, sizeof (mBlockIoDevTemplate));
-
- //
- // Initialize DMA controller to enable all channels.
- //
- for (Index = 0; Index < sizeof (mRegisterTable) / sizeof (PEI_DMA_TABLE); Index++) {
- IoWrite8 (mRegisterTable[Index].Register, mRegisterTable[Index].Value);
- }
- REPORT_STATUS_CODE (EFI_PROGRESS_CODE, EFI_PERIPHERAL_REMOVABLE_MEDIA + EFI_P_PC_INIT);
-
- //
- // Enumerate FDC devices.
- //
- DeviceCount = FdcEnumeration (FdcBlkIoDev);
- if (DeviceCount == 0) {
- return EFI_NOT_FOUND;
- }
-
- FdcBlkIoDev->PpiDescriptor.Ppi = &FdcBlkIoDev->FdcBlkIo;
-
- return PeiServicesInstallPpi (&FdcBlkIoDev->PpiDescriptor);
-}
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/FloppyPeim.h b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/FloppyPeim.h deleted file mode 100644 index 6477394efc..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/FloppyPeim.h +++ /dev/null @@ -1,246 +0,0 @@ -/** @file
-Private include file for IsaFloppyPei PEIM.
-
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
-
-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.
-
-**/
-
-#ifndef _RECOVERY_FLOPPY_H_
-#define _RECOVERY_FLOPPY_H_
-
-#include <Ppi/BlockIo.h>
-
-#include <Library/DebugLib.h>
-#include <Library/PeimEntryPoint.h>
-#include <Library/PeiServicesLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/ReportStatusCodeLib.h>
-#include <Library/TimerLib.h>
-#include <Library/IoLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/PcdLib.h>
-
-#include "Fdc.h"
-
-
-//
-// Some PC AT Compatible Device definitions
-//
-//
-// 8237 DMA registers
-//
-#define R_8237_DMA_BASE_CA_CH0 0x00
-#define R_8237_DMA_BASE_CA_CH1 0x02
-#define R_8237_DMA_BASE_CA_CH2 0x04
-#define R_8237_DMA_BASE_CA_CH3 0xd6
-#define R_8237_DMA_BASE_CA_CH5 0xc4
-#define R_8237_DMA_BASE_CA_CH6 0xc8
-#define R_8237_DMA_BASE_CA_CH7 0xcc
-
-#define R_8237_DMA_BASE_CC_CH0 0x01
-#define R_8237_DMA_BASE_CC_CH1 0x03
-#define R_8237_DMA_BASE_CC_CH2 0x05
-#define R_8237_DMA_BASE_CC_CH3 0xd7
-#define R_8237_DMA_BASE_CC_CH5 0xc6
-#define R_8237_DMA_BASE_CC_CH6 0xca
-#define R_8237_DMA_BASE_CC_CH7 0xce
-
-#define R_8237_DMA_MEM_LP_CH0 0x87
-#define R_8237_DMA_MEM_LP_CH1 0x83
-#define R_8237_DMA_MEM_LP_CH2 0x81
-#define R_8237_DMA_MEM_LP_CH3 0x82
-#define R_8237_DMA_MEM_LP_CH5 0x8B
-#define R_8237_DMA_MEM_LP_CH6 0x89
-#define R_8237_DMA_MEM_LP_CH7 0x8A
-
-
-#define R_8237_DMA_COMMAND_CH0_3 0x08
-#define R_8237_DMA_COMMAND_CH4_7 0xd0
-#define B_8237_DMA_COMMAND_GAP 0x10
-#define B_8237_DMA_COMMAND_CGE 0x04
-
-
-#define R_8237_DMA_STA_CH0_3 0x09
-#define R_8237_DMA_STA_CH4_7 0xd2
-
-#define R_8237_DMA_WRSMSK_CH0_3 0x0a
-#define R_8237_DMA_WRSMSK_CH4_7 0xd4
-#define B_8237_DMA_WRSMSK_CMS 0x04
-
-
-#define R_8237_DMA_CHMODE_CH0_3 0x0b
-#define R_8237_DMA_CHMODE_CH4_7 0xd6
-#define V_8237_DMA_CHMODE_DEMAND 0x00
-#define V_8237_DMA_CHMODE_SINGLE 0x40
-#define V_8237_DMA_CHMODE_CASCADE 0xc0
-#define B_8237_DMA_CHMODE_DECREMENT 0x20
-#define B_8237_DMA_CHMODE_INCREMENT 0x00
-#define B_8237_DMA_CHMODE_AE 0x10
-#define V_8237_DMA_CHMODE_VERIFY 0
-#define V_8237_DMA_CHMODE_IO2MEM 0x04
-#define V_8237_DMA_CHMODE_MEM2IO 0x08
-
-#define R_8237_DMA_CBPR_CH0_3 0x0c
-#define R_8237_DMA_CBPR_CH4_7 0xd8
-
-#define R_8237_DMA_MCR_CH0_3 0x0d
-#define R_8237_DMA_MCR_CH4_7 0xda
-
-#define R_8237_DMA_CLMSK_CH0_3 0x0e
-#define R_8237_DMA_CLMSK_CH4_7 0xdc
-
-#define R_8237_DMA_WRMSK_CH0_3 0x0f
-#define R_8237_DMA_WRMSK_CH4_7 0xde
-
-///
-/// ISA memory range
-///
-#define ISA_MAX_MEMORY_ADDRESS 0x1000000
-
-//
-// Macro for time delay & interval
-//
-#define STALL_1_SECOND 1000000
-#define STALL_1_MSECOND 1000
-#define FDC_CHECK_INTERVAL 50
-
-#define FDC_SHORT_DELAY 50
-#define FDC_MEDIUM_DELAY 100
-#define FDC_LONG_DELAY 4000
-#define FDC_RESET_DELAY 2000
-#define FDC_RECALIBRATE_DELAY 250000
-
-typedef enum {
- FdcType360K360K = 0,
- FdcType360K1200K,
- FdcType1200K1200K,
- FdcType720K720K,
- FdcType720K1440K,
- FdcType1440K1440K,
- FdcType720K2880K,
- FdcType1440K2880K,
- FdcType2880K2880K
-} FDC_DISKET_TYPE;
-
-typedef struct {
- UINT8 Register;
- UINT8 Value;
-} PEI_DMA_TABLE;
-
-typedef struct {
- UINT8 DevPos;
- UINT8 Pcn;
- BOOLEAN MotorOn;
- BOOLEAN NeedRecalibrate;
- FDC_DISKET_TYPE Type;
- EFI_PEI_BLOCK_IO_MEDIA MediaInfo;
-} PEI_FLOPPY_DEVICE_INFO;
-
-#define FDC_BLK_IO_DEV_SIGNATURE SIGNATURE_32 ('F', 'b', 'i', 'o')
-
-typedef struct {
- UINTN Signature;
- EFI_PEI_RECOVERY_BLOCK_IO_PPI FdcBlkIo;
- EFI_PEI_PPI_DESCRIPTOR PpiDescriptor;
- UINTN DeviceCount;
- PEI_FLOPPY_DEVICE_INFO DeviceInfo[2];
-} FDC_BLK_IO_DEV;
-
-#define PEI_RECOVERY_FDC_FROM_BLKIO_THIS(a) CR (a, FDC_BLK_IO_DEV, FdcBlkIo, FDC_BLK_IO_DEV_SIGNATURE)
-
-//
-// PEI Recovery Block I/O PPI
-//
-
-/**
- Get the number of FDC devices.
-
- This function implements EFI_PEI_RECOVERY_BLOCK_IO_PPI.GetNumberOfBlockDevices.
- It get the number of FDC devices in the system.
-
- @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
- @param This Pointer to this PPI instance.
- @param NumberBlockDevices Pointer to the the number of FDC devices for output.
-
- @retval EFI_SUCCESS Number of FDC devices is retrieved successfully.
- @retval EFI_INVALID_PARAMETER Parameter This is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-FdcGetNumberOfBlockDevices (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
- OUT UINTN *NumberBlockDevices
- );
-
-/**
- Get the specified media information.
-
- This function implements EFI_PEI_RECOVERY_BLOCK_IO_PPI.GetBlockDeviceMediaInfo.
- It gets the specified media information.
-
- @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
- @param This Pointer to this PPI instance.
- @param DeviceIndex Index of FDC device to get information.
- @param MediaInfo Pointer to the media info buffer for output.
-
- @retval EFI_SUCCESS Number of FDC devices is retrieved successfully.
- @retval EFI_INVALID_PARAMETER Parameter This is NULL.
- @retval EFI_INVALID_PARAMETER Parameter MediaInfo is NULL.
- @retval EFI_INVALID_PARAMETER DeviceIndex is not valid.
- @retval EFI_DEVICE_ERROR FDC device does not exist or has errors.
-
-**/
-EFI_STATUS
-EFIAPI
-FdcGetBlockDeviceMediaInfo (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
- IN UINTN DeviceIndex,
- OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo
- );
-
-/**
- Get the requested number of blocks from the specified FDC device.
-
- This function implements EFI_PEI_RECOVERY_BLOCK_IO_PPI.ReadBlocks.
- It reads the requested number of blocks from the specified FDC device.
-
- @param PeiServices An indirect pointer to the PEI Services Table published by the PEI Foundation.
- @param This Pointer to this PPI instance.
- @param DeviceIndex Index of FDC device to get information.
- @param StartLba The start LBA to read from.
- @param BufferSize The size of range to read.
- @param Buffer Buffer to hold the data read from FDC.
-
- @retval EFI_SUCCESS Number of FDC devices is retrieved successfully.
- @retval EFI_INVALID_PARAMETER Parameter This is NULL.
- @retval EFI_INVALID_PARAMETER Parameter Buffer is NULL.
- @retval EFI_INVALID_PARAMETER Parameter BufferSize cannot be divided by block size of FDC device.
- @retval EFI_NO_MEDIA No media present.
- @retval EFI_DEVICE_ERROR FDC device has error.
- @retval Others Fail to read blocks.
-
-**/
-EFI_STATUS
-EFIAPI
-FdcReadBlocks (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
- IN UINTN DeviceIndex,
- IN EFI_PEI_LBA StartLba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- );
-
-#endif
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/IsaFloppyPei.inf b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/IsaFloppyPei.inf deleted file mode 100644 index 8d4db34fbe..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/IsaFloppyPei.inf +++ /dev/null @@ -1,73 +0,0 @@ -## @file
-# ISA Floppy PEIM to support recovery boot via floppy disk.
-#
-# This module detects and supports ISA Floppy drives. If a drive is discovered
-# the PEIM will install the BlockIo PPI. This module is only dispatched if it
-# is in the Recovery Boot mode.
-#
-# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
-#
-# 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.
-#
-##
-
-################################################################################
-#
-# Defines Section - statements that will be processed to create a Makefile.
-#
-################################################################################
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = IsaFloppyPei
- MODULE_UNI_FILE = IsaFloppyPei.uni
- FILE_GUID = 7F6E0A24-DBFD-43df-9755-0292D7D3DD48
- MODULE_TYPE = PEIM
- VERSION_STRING = 1.0
-
- ENTRY_POINT = FdcPeimEntry
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC (EBC is for build only)
-#
-
-[Sources]
- FloppyPeim.c
- FloppyPeim.h
- Fdc.h
-
-[Packages]
- MdePkg/MdePkg.dec
- IntelFrameworkPkg/IntelFrameworkPkg.dec
- IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
-
-[LibraryClasses]
- IoLib
- TimerLib
- ReportStatusCodeLib
- BaseMemoryLib
- PeiServicesLib
- PeimEntryPoint
- DebugLib
- MemoryAllocationLib
- PcdLib
-
-[Ppis]
- gEfiPeiVirtualBlockIoPpiGuid ## PRODUCES
-
-[Pcd]
- gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdFdcBaseAddress ## CONSUMES
-
-[Depex]
- gEfiPeiMemoryDiscoveredPpiGuid AND gEfiPeiBootInRecoveryModePpiGuid
-
-[UserExtensions.TianoCore."ExtraFiles"]
- IsaFloppyPeiExtra.uni
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/IsaFloppyPei.uni b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/IsaFloppyPei.uni deleted file mode 100644 index 6d99cded27..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/IsaFloppyPei.uni +++ /dev/null @@ -1,25 +0,0 @@ -// /** @file
-// ISA Floppy PEIM to support recovery boot via floppy disk.
-//
-// This module detects and supports ISA Floppy drives. If a drive is discovered
-// the PEIM will install the BlockIo PPI. This module is only dispatched if it
-// is in the Recovery Boot mode.
-//
-// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
-//
-// 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.
-//
-// **/
-
-
-#string STR_MODULE_ABSTRACT #language en-US "ISA Floppy PEIM to support recovery boot via floppy disk"
-
-#string STR_MODULE_DESCRIPTION #language en-US "This module detects and supports ISA Floppy drives. If a drive is discovered the PEIM will install the BlockIo PPI. This module is only dispatched if it is in the Recovery Boot mode."
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/IsaFloppyPeiExtra.uni b/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/IsaFloppyPeiExtra.uni deleted file mode 100644 index 897389c521..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/IsaFloppyPeiExtra.uni +++ /dev/null @@ -1,21 +0,0 @@ -// /** @file
-// IsaFloppyPei Localized Strings and Content
-//
-// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
-//
-// 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.
-//
-// **/
-
-#string STR_PROPERTIES_MODULE_NAME
-#language en-US
-"ISA Floppy PEI Module"
-
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/ComponentName.c b/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/ComponentName.c deleted file mode 100644 index 97c196037a..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/ComponentName.c +++ /dev/null @@ -1,182 +0,0 @@ -/** @file
- UEFI Component Name(2) protocol implementation for Isa driver.
-
-Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
-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 "IsaDriver.h"
-
-//
-// EFI Component Name Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIsaIoComponentName = {
- IsaIoComponentNameGetDriverName,
- IsaIoComponentNameGetControllerName,
- "eng"
-};
-
-//
-// EFI Component Name 2 Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIsaIoComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IsaIoComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IsaIoComponentNameGetControllerName,
- "en"
-};
-
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIsaIoDriverNameTable[] = {
- {
- "eng;en",
- L"ISA IO Driver"
- },
- {
- NULL,
- NULL
- }
-};
-
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
-
- @param DriverName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-IsaIoComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- )
-{
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mIsaIoDriverNameTable,
- DriverName,
- (BOOLEAN)(This == &gIsaIoComponentName)
- );
-}
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param ControllerHandle[in] The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
-
- @param ChildHandle[in] The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
-
- @param ControllerName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
-
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
-
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-IsaIoComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- )
-{
- return EFI_UNSUPPORTED;
-}
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/ComponentName.h b/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/ComponentName.h deleted file mode 100644 index 8e8178773b..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/ComponentName.h +++ /dev/null @@ -1,148 +0,0 @@ -/** @file
- Header file for implementation of UEFI Component Name(2) protocol.
-
-Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
-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.
-
-**/
-
-#ifndef _COMPONENT_NAME_H_
-#define _COMPONENT_NAME_H_
-
-extern EFI_COMPONENT_NAME_PROTOCOL gIsaIoComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gIsaIoComponentName2;
-
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
-
- @param DriverName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-IsaIoComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- );
-
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param ControllerHandle[in] The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
-
- @param ChildHandle[in] The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
-
- @param ControllerName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
-
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
-
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-IsaIoComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- );
-
-#endif
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaDriver.c b/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaDriver.c deleted file mode 100644 index 8c58b318c6..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaDriver.c +++ /dev/null @@ -1,326 +0,0 @@ -/** @file
- IsaIo UEFI driver.
-
- Produce an instance of the ISA I/O Protocol for every SIO controller.
-
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
-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 "IsaDriver.h"
-
-//
-// IsaIo Driver Global Variables
-//
-EFI_DRIVER_BINDING_PROTOCOL gIsaIoDriver = {
- IsaIoDriverSupported,
- IsaIoDriverStart,
- IsaIoDriverStop,
- 0xa,
- NULL,
- NULL
-};
-
-/**
- The main entry point for the IsaIo driver.
-
- @param[in] ImageHandle The firmware allocated handle for the EFI image.
- @param[in] SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The entry point is executed successfully.
- @retval EFI_OUT_OF_RESOURCES There was not enough memory in pool to install all the protocols.
-**/
-EFI_STATUS
-EFIAPI
-InitializeIsaIo (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- //
- // Install driver model protocol(s).
- //
- Status = EfiLibInstallDriverBindingComponentName2 (
- ImageHandle,
- SystemTable,
- &gIsaIoDriver,
- ImageHandle,
- &gIsaIoComponentName,
- &gIsaIoComponentName2
- );
- ASSERT_EFI_ERROR (Status);
-
- return Status;
-}
-
-/**
- Tests to see if a controller can be managed by the IsaIo driver.
-
- @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param[in] Controller The handle of the controller to test.
- @param[in] RemainingDevicePath A pointer to the remaining portion of a device path.
-
- @retval EFI_SUCCESS The device is supported by this driver.
- @retval EFI_ALREADY_STARTED The device is already being managed by this driver.
- @retval EFI_ACCESS_DENIED The device is already being managed by a different driver
- or an application that requires exclusive access.
- @retval EFI_UNSUPPORTED The device is is not supported by this driver.
-
-**/
-EFI_STATUS
-EFIAPI
-IsaIoDriverSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
- )
-{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_SIO_PROTOCOL *Sio;
- EFI_HANDLE PciHandle;
-
- //
- // Try to open EFI DEVICE PATH protocol on the controller
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &DevicePath,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
-
- if (!EFI_ERROR (Status)) {
- //
- // Get the PciIo protocol from its parent controller.
- //
- Status = gBS->LocateDevicePath (&gEfiPciIoProtocolGuid, &DevicePath, &PciHandle);
- }
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Try to open the Super IO protocol on the controller
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiSioProtocolGuid,
- (VOID **) &Sio,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (!EFI_ERROR (Status)) {
- gBS->CloseProtocol (
- Controller,
- &gEfiSioProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- }
-
- return Status;
-}
-
-/**
- Start this driver on ControllerHandle.
-
- The Start() function is designed to be invoked from the EFI boot service ConnectController().
- As a result, much of the error checking on the parameters to Start() has been moved into this
- common boot service. It is legal to call Start() from other locations, but the following calling
- restrictions must be followed or the system behavior will not be deterministic.
- 1. ControllerHandle must be a valid EFI_HANDLE.
- 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
- EFI_DEVICE_PATH_PROTOCOL.
- 3. Prior to calling Start(), the Supported() function for the driver specified by This must
- have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
-
- @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param[in] ControllerHandle The handle of the controller to start. This handle
- must support a protocol interface that supplies
- an I/O abstraction to the driver.
- @param[in] RemainingDevicePath A pointer to the remaining portion of a device path.
- This parameter is ignored by device drivers, and is optional for bus drivers.
-
- @retval EFI_SUCCESS The device was started.
- @retval EFI_DEVICE_ERROR The device could not be started due to a device error.
- Currently not implemented.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
- @retval Others The driver failded to start the device.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoDriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
- )
-{
- EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL *PciIo;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_HANDLE PciHandle;
- EFI_SIO_PROTOCOL *Sio;
- ACPI_RESOURCE_HEADER_PTR Resources;
- EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
- ISA_IO_DEVICE *IsaIoDevice;
-
- PciIo = NULL;
- Sio = NULL;
-
- //
- // Open Device Path Protocol
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &DevicePath,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Get the PciIo protocol from its parent controller.
- //
- TempDevicePath = DevicePath;
- Status = gBS->LocateDevicePath (&gEfiPciIoProtocolGuid, &TempDevicePath, &PciHandle);
- if (!EFI_ERROR (Status)) {
- Status = gBS->HandleProtocol (PciHandle, &gEfiPciIoProtocolGuid, (VOID **) &PciIo);
- ASSERT_EFI_ERROR (Status);
-
- //
- // Open Super IO Protocol
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiSioProtocolGuid,
- (VOID **) &Sio,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- }
-
- if (EFI_ERROR (Status)) {
- //
- // Fail due to LocateDevicePath(...) or OpenProtocol(Sio, BY_DRIVER)
- //
- return Status;
- }
-
- Status = Sio->GetResources (Sio, &Resources);
- ASSERT_EFI_ERROR (Status);
-
- IsaIoDevice = AllocatePool (sizeof (ISA_IO_DEVICE));
- ASSERT (IsaIoDevice != NULL);
-
- IsaIoDevice->Signature = ISA_IO_DEVICE_SIGNATURE;
- IsaIoDevice->PciIo = PciIo;
-
- //
- // Initialize the ISA I/O instance structure
- //
- InitializeIsaIoInstance (IsaIoDevice, DevicePath, Resources);
-
- //
- // Install the ISA I/O protocol on the Controller handle
- //
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Controller,
- &gEfiIsaIoProtocolGuid,
- &IsaIoDevice->IsaIo,
- NULL
- );
- ASSERT_EFI_ERROR (Status);
-
- return EFI_SUCCESS;
-}
-
-/**
- Stop this driver on ControllerHandle.
-
- The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
- As a result, much of the error checking on the parameters to Stop() has been moved
- into this common boot service. It is legal to call Stop() from other locations,
- but the following calling restrictions must be followed or the system behavior will not be deterministic.
- 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
- same driver's Start() function.
- 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
- EFI_HANDLE. In addition, all of these handles must have been created in this driver's
- Start() function, and the Start() function must have called OpenProtocol() on
- ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
-
- @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param[in] ControllerHandle A handle to the device being stopped. The handle must
- support a bus specific I/O protocol for the driver
- to use to stop the device.
- @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
- @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
- if NumberOfChildren is 0.
-
- @retval EFI_SUCCESS The device was stopped.
- @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoDriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL * This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE * ChildHandleBuffer OPTIONAL
- )
-{
- EFI_STATUS Status;
- ISA_IO_DEVICE *IsaIoDevice;
- EFI_ISA_IO_PROTOCOL *IsaIo;
-
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- (VOID **) &IsaIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return EFI_UNSUPPORTED;
- }
-
- IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (IsaIo);
-
- Status = gBS->UninstallMultipleProtocolInterfaces (
- Controller,
- &gEfiIsaIoProtocolGuid,
- &IsaIoDevice->IsaIo,
- NULL
- );
- if (!EFI_ERROR (Status)) {
- Status = gBS->CloseProtocol (
- Controller,
- &gEfiSioProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- FreePool (IsaIoDevice->IsaIo.ResourceList);
- FreePool (IsaIoDevice);
- }
-
- return Status;
-}
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaDriver.h b/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaDriver.h deleted file mode 100644 index 64f710bcec..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaDriver.h +++ /dev/null @@ -1,263 +0,0 @@ -/** @file
- The header file for ISA driver
-
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
-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.
-
-**/
-
-#ifndef _ISA_DRIVER_H_
-#define _ISA_DRIVER_H_
-
-
-#include <Uefi.h>
-
-#include <Protocol/PciIo.h>
-#include <Protocol/SuperIo.h>
-#include <Protocol/ComponentName.h>
-#include <Protocol/IsaIo.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/DriverBinding.h>
-#include <Protocol/GenericMemoryTest.h>
-#include <Guid/StatusCodeDataTypeId.h>
-
-#include <Library/DebugLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/UefiLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/ReportStatusCodeLib.h>
-#include <Library/PcdLib.h>
-#include <IndustryStandard/Acpi.h>
-
-#include "ComponentName.h"
-
-//
-// 8237 DMA registers
-//
-#define R_8237_DMA_BASE_CA_CH0 0x00
-#define R_8237_DMA_BASE_CA_CH1 0x02
-#define R_8237_DMA_BASE_CA_CH2 0x04
-#define R_8237_DMA_BASE_CA_CH3 0xd6
-#define R_8237_DMA_BASE_CA_CH5 0xc4
-#define R_8237_DMA_BASE_CA_CH6 0xc8
-#define R_8237_DMA_BASE_CA_CH7 0xcc
-
-#define R_8237_DMA_BASE_CC_CH0 0x01
-#define R_8237_DMA_BASE_CC_CH1 0x03
-#define R_8237_DMA_BASE_CC_CH2 0x05
-#define R_8237_DMA_BASE_CC_CH3 0xd7
-#define R_8237_DMA_BASE_CC_CH5 0xc6
-#define R_8237_DMA_BASE_CC_CH6 0xca
-#define R_8237_DMA_BASE_CC_CH7 0xce
-
-#define R_8237_DMA_MEM_LP_CH0 0x87
-#define R_8237_DMA_MEM_LP_CH1 0x83
-#define R_8237_DMA_MEM_LP_CH2 0x81
-#define R_8237_DMA_MEM_LP_CH3 0x82
-#define R_8237_DMA_MEM_LP_CH5 0x8B
-#define R_8237_DMA_MEM_LP_CH6 0x89
-#define R_8237_DMA_MEM_LP_CH7 0x8A
-
-
-#define R_8237_DMA_COMMAND_CH0_3 0x08
-#define R_8237_DMA_COMMAND_CH4_7 0xd0
-#define B_8237_DMA_COMMAND_GAP 0x10
-#define B_8237_DMA_COMMAND_CGE 0x04
-
-
-#define R_8237_DMA_STA_CH0_3 0xd8
-#define R_8237_DMA_STA_CH4_7 0xd0
-
-#define R_8237_DMA_WRSMSK_CH0_3 0x0a
-#define R_8237_DMA_WRSMSK_CH4_7 0xd4
-#define B_8237_DMA_WRSMSK_CMS 0x04
-
-
-#define R_8237_DMA_CHMODE_CH0_3 0x0b
-#define R_8237_DMA_CHMODE_CH4_7 0xd6
-#define V_8237_DMA_CHMODE_DEMAND 0x00
-#define V_8237_DMA_CHMODE_SINGLE 0x40
-#define V_8237_DMA_CHMODE_CASCADE 0xc0
-#define B_8237_DMA_CHMODE_DECREMENT 0x20
-#define B_8237_DMA_CHMODE_INCREMENT 0x00
-#define B_8237_DMA_CHMODE_AE 0x10
-#define V_8237_DMA_CHMODE_VERIFY 0
-#define V_8237_DMA_CHMODE_IO2MEM 0x04
-#define V_8237_DMA_CHMODE_MEM2IO 0x08
-
-#define R_8237_DMA_CBPR_CH0_3 0x0c
-#define R_8237_DMA_CBPR_CH4_7 0xd8
-
-#define R_8237_DMA_MCR_CH0_3 0x0d
-#define R_8237_DMA_MCR_CH4_7 0xda
-
-#define R_8237_DMA_CLMSK_CH0_3 0x0e
-#define R_8237_DMA_CLMSK_CH4_7 0xdc
-
-#define R_8237_DMA_WRMSK_CH0_3 0x0f
-#define R_8237_DMA_WRMSK_CH4_7 0xde
-
-typedef enum {
- IsaAccessTypeUnknown,
- IsaAccessTypeIo,
- IsaAccessTypeMem,
- IsaAccessTypeMaxType
-} ISA_ACCESS_TYPE;
-
-typedef struct {
- UINT8 Address;
- UINT8 Page;
- UINT8 Count;
-} EFI_ISA_DMA_REGISTERS;
-
-//
-// ISA I/O Device Structure
-//
-#define ISA_IO_DEVICE_SIGNATURE SIGNATURE_32 ('i', 's', 'a', 'i')
-
-typedef struct {
- UINT32 Signature;
- EFI_HANDLE Handle;
- EFI_ISA_IO_PROTOCOL IsaIo;
- EFI_PCI_IO_PROTOCOL *PciIo;
-} ISA_IO_DEVICE;
-
-#define ISA_IO_DEVICE_FROM_ISA_IO_THIS(a) CR (a, ISA_IO_DEVICE, IsaIo, ISA_IO_DEVICE_SIGNATURE)
-
-//
-// Mapping structure for performing ISA DMA to a buffer above 16 MB
-//
-typedef struct {
- EFI_ISA_IO_PROTOCOL_OPERATION Operation;
- UINTN NumberOfBytes;
- UINTN NumberOfPages;
- EFI_PHYSICAL_ADDRESS HostAddress;
- EFI_PHYSICAL_ADDRESS MappedHostAddress;
-} ISA_MAP_INFO;
-
-//
-// EFI Driver Binding Protocol Interface Functions
-//
-
-/**
- Tests to see if a controller can be managed by the ISA Driver.
-
- How the Start() function of a driver is implemented can affect how the Supported() function is implemented.
-
- @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param[in] Controller The handle of the controller to test.
- @param[in] RemainingDevicePath A pointer to the remaining portion of a device path.
-
- @retval EFI_SUCCESS The device is supported by this driver.
- @retval EFI_ALREADY_STARTED The device is already being managed by this driver.
- @retval EFI_ACCESS_DENIED The device is already being managed by a different driver
- or an application that requires exclusive access.
- @retval EFI_UNSUPPORTED The device is is not supported by this driver.
-
-**/
-EFI_STATUS
-EFIAPI
-IsaIoDriverSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
- );
-
-/**
- Start this driver on ControllerHandle.
-
- The Start() function is designed to be invoked from the EFI boot service ConnectController().
- As a result, much of the error checking on the parameters to Start() has been moved into this
- common boot service. It is legal to call Start() from other locations, but the following calling
- restrictions must be followed or the system behavior will not be deterministic.
- 1. ControllerHandle must be a valid EFI_HANDLE.
- 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
- EFI_DEVICE_PATH_PROTOCOL.
- 3. Prior to calling Start(), the Supported() function for the driver specified by This must
- have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
-
- @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param[in] ControllerHandle The handle of the controller to start. This handle
- must support a protocol interface that supplies
- an I/O abstraction to the driver.
- @param[in] RemainingDevicePath A pointer to the remaining portion of a device path.
- This parameter is ignored by device drivers, and is optional for bus drivers.
-
- @retval EFI_SUCCESS The device was started.
- @retval EFI_DEVICE_ERROR The device could not be started due to a device error.
- Currently not implemented.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
- @retval Others The driver failded to start the device.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoDriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
- );
-
-/**
- Stop this driver on ControllerHandle.
-
- The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
- As a result, much of the error checking on the parameters to Stop() has been moved
- into this common boot service. It is legal to call Stop() from other locations,
- but the following calling restrictions must be followed or the system behavior will not be deterministic.
- 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
- same driver's Start() function.
- 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
- EFI_HANDLE. In addition, all of these handles must have been created in this driver's
- Start() function, and the Start() function must have called OpenProtocol() on
- ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
-
- @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param[in] ControllerHandle A handle to the device being stopped. The handle must
- support a bus specific I/O protocol for the driver
- to use to stop the device.
- @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
- @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
- if NumberOfChildren is 0.
-
- @retval EFI_SUCCESS The device was stopped.
- @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoDriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL * This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE * ChildHandleBuffer OPTIONAL
- );
-
-//
-// Function Prototypes
-//
-
-/**
- Initializes an ISA I/O Instance
-
- @param[in] IsaIoDevice The isa device to be initialized.
- @param[in] DevicePath The device path of the isa device.
- @param[in] Resources The ACPI resource list.
-
-**/
-VOID
-InitializeIsaIoInstance (
- IN ISA_IO_DEVICE *IsaIoDevice,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- IN ACPI_RESOURCE_HEADER_PTR Resources
- );
-
-#endif
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIo.c b/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIo.c deleted file mode 100644 index 2e4361fc0d..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIo.c +++ /dev/null @@ -1,1803 +0,0 @@ -/** @file
- The implementation for EFI_ISA_IO_PROTOCOL.
-
-Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
-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 "IsaIo.h"
-
-//
-// Module Variables
-//
-EFI_ISA_IO_PROTOCOL mIsaIoInterface = {
- {
- IsaIoMemRead,
- IsaIoMemWrite
- },
- {
- IsaIoIoRead,
- IsaIoIoWrite
- },
- IsaIoCopyMem,
- IsaIoMap,
- IsaIoUnmap,
- IsaIoAllocateBuffer,
- IsaIoFreeBuffer,
- IsaIoFlush,
- NULL,
- 0,
- NULL
-};
-
-EFI_ISA_DMA_REGISTERS mDmaRegisters[8] = {
- {
- 0x00,
- 0x87,
- 0x01
- },
- {
- 0x02,
- 0x83,
- 0x03
- },
- {
- 0x04,
- 0x81,
- 0x05
- },
- {
- 0x06,
- 0x82,
- 0x07
- },
- {
- 0x00,
- 0x00,
- 0x00
- }, // Channel 4 is invalid
- {
- 0xC4,
- 0x8B,
- 0xC6
- },
- {
- 0xC8,
- 0x89,
- 0xCA
- },
- {
- 0xCC,
- 0x8A,
- 0xCE
- },
-};
-
-/**
- Verifies access to an ISA device
-
- @param[in] IsaIoDevice The ISA device to be verified.
- @param[in] Type The Access type. The input must be either IsaAccessTypeMem or IsaAccessTypeIo.
- @param[in] Width The width of the memory operation.
- @param[in] Count The number of memory operations to perform.
- @param[in] Offset The offset in ISA memory space to start the memory operation.
-
- @retval EFI_SUCCESS Verify success.
- @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
- @retval EFI_UNSUPPORTED The device ont support the access type.
-**/
-EFI_STATUS
-IsaIoVerifyAccess (
- IN ISA_IO_DEVICE *IsaIoDevice,
- IN ISA_ACCESS_TYPE Type,
- IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
- IN UINTN Count,
- IN UINT32 Offset
- )
-{
- EFI_ISA_ACPI_RESOURCE *Item;
- EFI_STATUS Status;
-
- if ((UINT32)Width >= EfiIsaIoWidthMaximum ||
- Width == EfiIsaIoWidthReserved ||
- Width == EfiIsaIoWidthFifoReserved ||
- Width == EfiIsaIoWidthFillReserved
- ) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // If Width is EfiIsaIoWidthFifoUintX then convert to EfiIsaIoWidthUintX
- // If Width is EfiIsaIoWidthFillUintX then convert to EfiIsaIoWidthUintX
- //
- if (Width >= EfiIsaIoWidthFifoUint8 && Width < EfiIsaIoWidthFifoReserved) {
- Count = 1;
- }
-
- Width = (EFI_ISA_IO_PROTOCOL_WIDTH) (Width & 0x03);
-
- Status = EFI_UNSUPPORTED;
- Item = IsaIoDevice->IsaIo.ResourceList->ResourceItem;
- while (Item->Type != EfiIsaAcpiResourceEndOfList) {
- if ((Type == IsaAccessTypeMem && Item->Type == EfiIsaAcpiResourceMemory) ||
- (Type == IsaAccessTypeIo && Item->Type == EfiIsaAcpiResourceIo)) {
- if (Offset >= Item->StartRange && (Offset + Count * (UINT32)(1 << Width)) - 1 <= Item->EndRange) {
- return EFI_SUCCESS;
- }
-
- if (Offset >= Item->StartRange && Offset <= Item->EndRange) {
- Status = EFI_INVALID_PARAMETER;
- }
- }
-
- Item++;
- }
-
- return Status;
-}
-
-/**
- Convert the IO Information in ACPI descriptor to IO ISA Attribute.
-
- @param[in] Information The IO Information in ACPI descriptor
-
- @return UINT32 The IO ISA Attribute
-**/
-UINT32
-IsaIoAttribute (
- IN UINT8 Information
- )
-{
- UINT32 Attribute;
-
- Attribute = 0;
-
- switch (Information & EFI_ACPI_IO_DECODE_MASK) {
- case EFI_ACPI_IO_DECODE_16_BIT:
- Attribute |= EFI_ISA_ACPI_IO_DECODE_16_BITS;
- break;
-
- case EFI_ACPI_IO_DECODE_10_BIT:
- Attribute |= EFI_ISA_ACPI_IO_DECODE_10_BITS;
- break;
- }
-
- return Attribute;
-}
-
-/**
- Convert the IRQ Information in ACPI descriptor to IRQ ISA Attribute.
-
- @param[in] Information The IRQ Information in ACPI descriptor
-
- @return UINT32 The IRQ ISA Attribute
-**/
-UINT32
-IsaIrqAttribute (
- IN UINT8 Information
- )
-{
- UINT32 Attribute;
-
- Attribute = 0;
-
- if ((Information & EFI_ACPI_IRQ_POLARITY_MASK) == EFI_ACPI_IRQ_HIGH_TRUE) {
- if ((Information & EFI_ACPI_IRQ_MODE) == EFI_ACPI_IRQ_LEVEL_TRIGGERED) {
- Attribute = EFI_ISA_ACPI_IRQ_TYPE_HIGH_TRUE_LEVEL_SENSITIVE;
- } else {
- Attribute = EFI_ISA_ACPI_IRQ_TYPE_HIGH_TRUE_EDGE_SENSITIVE;
- }
- } else {
- if ((Information & EFI_ACPI_IRQ_MODE) == EFI_ACPI_IRQ_LEVEL_TRIGGERED) {
- Attribute = EFI_ISA_ACPI_IRQ_TYPE_LOW_TRUE_LEVEL_SENSITIVE;
- } else {
- Attribute = EFI_ISA_ACPI_IRQ_TYPE_LOW_TRUE_EDGE_SENSITIVE;
- }
- }
- return Attribute;
-}
-
-/**
- Convert the Memory Information in ACPI descriptor to Memory ISA Attribute.
-
- @param[in] Information The Memory Information in ACPI descriptor
-
- @return UINT32 The Memory ISA Attribute
-**/
-UINT32
-IsaMemoryAttribute (
- IN UINT8 Information
- )
-{
- UINT32 Attribute;
-
- Attribute = 0;
-
- switch (Information & EFI_ACPI_MEMORY_WRITE_STATUS_MASK) {
- case EFI_ACPI_MEMORY_WRITABLE:
- Attribute |= EFI_ISA_ACPI_MEMORY_WRITEABLE;
- break;
- }
-
- return Attribute;
-}
-
-/**
- Convert the DMA Information in ACPI descriptor to DMA ISA Attribute.
-
- @param[in] Information The DMA Information in ACPI descriptor
-
- @return UINT32 The DMA ISA Attribute
-**/
-UINT32
-IsaDmaAttribute (
- IN UINT8 Information
- )
-{
- UINT32 Attribute;
-
- Attribute = EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE;
-
- switch (Information & EFI_ACPI_DMA_SPEED_TYPE_MASK) {
- case EFI_ACPI_DMA_SPEED_TYPE_COMPATIBILITY:
- Attribute |= EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_COMPATIBLE;
- break;
- case EFI_ACPI_DMA_SPEED_TYPE_A:
- Attribute |= EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_A;
- break;
- case EFI_ACPI_DMA_SPEED_TYPE_B:
- Attribute |= EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_B;
- break;
- case EFI_ACPI_DMA_SPEED_TYPE_F:
- Attribute |= EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_C;
- break;
- }
-
- switch (Information & EFI_ACPI_DMA_TRANSFER_TYPE_MASK) {
- case EFI_ACPI_DMA_TRANSFER_TYPE_8_BIT:
- Attribute |= EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_8;
- break;
- case EFI_ACPI_DMA_TRANSFER_TYPE_16_BIT:
- Attribute |= EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_16;
- break;
- }
-
- return Attribute;
-}
-
-/**
- Convert the ACPI resource descriptor to ISA resource descriptor.
-
- @param[in] AcpiResource Pointer to the ACPI resource descriptor
- @param[out] IsaResource The optional pointer to the buffer to
- store the converted ISA resource descriptor
-
- @return UINTN Number of ISA resource descriptor needed
-**/
-UINTN
-AcpiResourceToIsaResource (
- IN ACPI_RESOURCE_HEADER_PTR AcpiResource,
- OUT EFI_ISA_ACPI_RESOURCE *IsaResource OPTIONAL
- )
-{
- UINT32 Index;
- UINTN Count;
- UINT32 LastIndex;
- EFI_ACPI_IO_PORT_DESCRIPTOR *Io;
- EFI_ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR *FixedIo;
- EFI_ACPI_IRQ_DESCRIPTOR *Irq;
- EFI_ACPI_DMA_DESCRIPTOR *Dma;
- EFI_ACPI_32_BIT_MEMORY_RANGE_DESCRIPTOR *Memory;
- EFI_ACPI_32_BIT_FIXED_MEMORY_RANGE_DESCRIPTOR *FixedMemory;
-
- Count = 0;
- LastIndex = 0;
-
- switch (AcpiResource.SmallHeader->Byte) {
- case ACPI_DMA_DESCRIPTOR:
- Dma = (EFI_ACPI_DMA_DESCRIPTOR *) AcpiResource.SmallHeader;
- for (Index = 0; Index < sizeof (Dma->ChannelMask) * 8; Index++) {
- if (Dma->ChannelMask & (1 << Index)) {
- if ((Count > 0) && (LastIndex + 1 == Index)) {
- if (IsaResource != NULL) {
- IsaResource[Count - 1].EndRange ++;
- }
- } else {
- if (IsaResource != NULL) {
- IsaResource[Count].Type = EfiIsaAcpiResourceDma;
- IsaResource[Count].Attribute = IsaDmaAttribute (Dma->Information);
- IsaResource[Count].StartRange = Index;
- IsaResource[Count].EndRange = Index;
- }
- Count ++;
- }
-
- LastIndex = Index;
- }
- }
- break;
-
- case ACPI_IO_PORT_DESCRIPTOR:
- Io = (EFI_ACPI_IO_PORT_DESCRIPTOR *) AcpiResource.SmallHeader;
- if (Io->Length != 0) {
- if (IsaResource != NULL) {
- IsaResource[Count].Type = EfiIsaAcpiResourceIo;
- IsaResource[Count].Attribute = IsaIoAttribute (Io->Information);
- IsaResource[Count].StartRange = Io->BaseAddressMin;
- IsaResource[Count].EndRange = Io->BaseAddressMin + Io->Length - 1;
- }
- Count ++;
- }
- break;
-
- case ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR:
- FixedIo = (EFI_ACPI_FIXED_LOCATION_IO_PORT_DESCRIPTOR *) AcpiResource.SmallHeader;
- if (FixedIo->Length != 0) {
- if (IsaResource != NULL) {
- IsaResource[Count].Type = EfiIsaAcpiResourceIo;
- IsaResource[Count].Attribute = EFI_ISA_ACPI_IO_DECODE_10_BITS;
- IsaResource[Count].StartRange = FixedIo->BaseAddress;
- IsaResource[Count].EndRange = FixedIo->BaseAddress + FixedIo->Length - 1;
- }
- Count ++;
- }
- break;
-
- case ACPI_IRQ_DESCRIPTOR:
- case ACPI_IRQ_NOFLAG_DESCRIPTOR:
- Irq = (EFI_ACPI_IRQ_DESCRIPTOR *) AcpiResource.SmallHeader;
- for (Index = 0; Index < sizeof (Irq->Mask) * 8; Index++) {
- if (Irq->Mask & (1 << Index)) {
- if ((Count > 0) && (LastIndex + 1 == Index)) {
- if (IsaResource != NULL) {
- IsaResource[Count - 1].EndRange ++;
- }
- } else {
- if (IsaResource != NULL) {
- IsaResource[Count].Type = EfiIsaAcpiResourceInterrupt;
- if (AcpiResource.SmallHeader->Byte == ACPI_IRQ_DESCRIPTOR) {
- IsaResource[Count].Attribute = IsaIrqAttribute (Irq->Information);
- } else {
- IsaResource[Count].Attribute = EFI_ISA_ACPI_IRQ_TYPE_HIGH_TRUE_EDGE_SENSITIVE;
- }
- IsaResource[Count].StartRange = Index;
- IsaResource[Count].EndRange = Index;
- }
- Count++;
- }
-
- LastIndex = Index;
- }
- }
- break;
-
- case ACPI_32_BIT_MEMORY_RANGE_DESCRIPTOR:
- Memory = (EFI_ACPI_32_BIT_MEMORY_RANGE_DESCRIPTOR *) AcpiResource.LargeHeader;
- if (Memory->Length != 0) {
- if (IsaResource != NULL) {
- IsaResource[Count].Type = EfiIsaAcpiResourceMemory;
- IsaResource[Count].Attribute = IsaMemoryAttribute (Memory->Information);
- IsaResource[Count].StartRange = Memory->BaseAddressMin;
- IsaResource[Count].EndRange = Memory->BaseAddressMin + Memory->Length - 1;
- }
- Count ++;
- }
- break;
-
- case ACPI_32_BIT_FIXED_MEMORY_RANGE_DESCRIPTOR:
- FixedMemory = (EFI_ACPI_32_BIT_FIXED_MEMORY_RANGE_DESCRIPTOR *) AcpiResource.LargeHeader;
- if (FixedMemory->Length != 0) {
- if (IsaResource != NULL) {
- IsaResource[Count].Type = EfiIsaAcpiResourceMemory;
- IsaResource[Count].Attribute = IsaMemoryAttribute (FixedMemory->Information);
- IsaResource[Count].StartRange = FixedMemory->BaseAddress;
- IsaResource[Count].EndRange = FixedMemory->BaseAddress + FixedMemory->Length - 1;
- }
- Count ++;
- }
- break;
-
- case ACPI_END_TAG_DESCRIPTOR:
- if (IsaResource != NULL) {
- IsaResource[Count].Type = EfiIsaAcpiResourceEndOfList;
- IsaResource[Count].Attribute = 0;
- IsaResource[Count].StartRange = 0;
- IsaResource[Count].EndRange = 0;
- }
- Count ++;
- break;
- }
-
- return Count;
-}
-
-/**
- Initializes an ISA I/O Instance
-
- @param[in] IsaIoDevice The isa device to be initialized.
- @param[in] DevicePath The device path of the isa device.
- @param[in] Resources The ACPI resource list.
-
-**/
-VOID
-InitializeIsaIoInstance (
- IN ISA_IO_DEVICE *IsaIoDevice,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- IN ACPI_RESOURCE_HEADER_PTR Resources
- )
-{
- UINTN Index;
- ACPI_HID_DEVICE_PATH *AcpiNode;
- ACPI_RESOURCE_HEADER_PTR ResourcePtr;
-
- //
- // Use the ISA IO Protocol structure template to initialize the ISA IO instance
- //
- CopyMem (
- &IsaIoDevice->IsaIo,
- &mIsaIoInterface,
- sizeof (EFI_ISA_IO_PROTOCOL)
- );
-
- //
- // Count the resources including the ACPI End Tag
- //
- ResourcePtr = Resources;
- Index = 0;
- while (ResourcePtr.SmallHeader->Byte != ACPI_END_TAG_DESCRIPTOR) {
-
- Index += AcpiResourceToIsaResource (ResourcePtr, NULL);
-
- if (ResourcePtr.SmallHeader->Bits.Type == 0) {
- ResourcePtr.SmallHeader = (ACPI_SMALL_RESOURCE_HEADER *) ((UINT8 *) ResourcePtr.SmallHeader
- + ResourcePtr.SmallHeader->Bits.Length
- + sizeof (*ResourcePtr.SmallHeader));
- } else {
- ResourcePtr.LargeHeader = (ACPI_LARGE_RESOURCE_HEADER *) ((UINT8 *) ResourcePtr.LargeHeader
- + ResourcePtr.LargeHeader->Length
- + sizeof (*ResourcePtr.LargeHeader));
- }
-
- }
- //
- // Get the Isa Resource count for ACPI End Tag
- //
- Index += AcpiResourceToIsaResource (ResourcePtr, NULL);
-
- //
- // Initialize the ResourceList
- //
- IsaIoDevice->IsaIo.ResourceList = AllocatePool (sizeof (EFI_ISA_ACPI_RESOURCE_LIST) + Index * sizeof (EFI_ISA_ACPI_RESOURCE));
- ASSERT (IsaIoDevice->IsaIo.ResourceList != NULL);
- IsaIoDevice->IsaIo.ResourceList->ResourceItem = (EFI_ISA_ACPI_RESOURCE *) (IsaIoDevice->IsaIo.ResourceList + 1);
-
- AcpiNode = (ACPI_HID_DEVICE_PATH *) ((UINT8 *) DevicePath + GetDevicePathSize (DevicePath) - END_DEVICE_PATH_LENGTH - sizeof (ACPI_HID_DEVICE_PATH));
- IsaIoDevice->IsaIo.ResourceList->Device.HID = AcpiNode->HID;
- IsaIoDevice->IsaIo.ResourceList->Device.UID = AcpiNode->UID;
-
- ResourcePtr = Resources;
- Index = 0;
- while (ResourcePtr.SmallHeader->Byte != ACPI_END_TAG_DESCRIPTOR) {
-
- Index += AcpiResourceToIsaResource (ResourcePtr, &IsaIoDevice->IsaIo.ResourceList->ResourceItem[Index]);
-
- if (ResourcePtr.SmallHeader->Bits.Type == 0) {
- ResourcePtr.SmallHeader = (ACPI_SMALL_RESOURCE_HEADER *) ((UINT8 *) ResourcePtr.SmallHeader
- + ResourcePtr.SmallHeader->Bits.Length
- + sizeof (*ResourcePtr.SmallHeader));
- } else {
- ResourcePtr.LargeHeader = (ACPI_LARGE_RESOURCE_HEADER *) ((UINT8 *) ResourcePtr.LargeHeader
- + ResourcePtr.LargeHeader->Length
- + sizeof (*ResourcePtr.LargeHeader));
- }
- }
-
- //
- // Convert the ACPI End Tag
- //
- AcpiResourceToIsaResource (ResourcePtr, &IsaIoDevice->IsaIo.ResourceList->ResourceItem[Index]);
-}
-
-/**
- Performs an ISA I/O Read Cycle
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Width Specifies the width of the I/O operation.
- @param[in] Offset The offset in ISA I/O space to start the I/O operation.
- @param[in] Count The number of I/O operations to perform.
- @param[out] Buffer The destination buffer to store the results
-
- @retval EFI_SUCCESS The data was read from the device sucessfully.
- @retval EFI_UNSUPPORTED The Offset is not valid for this device.
- @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoIoRead (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
- IN UINT32 Offset,
- IN UINTN Count,
- OUT VOID *Buffer
- )
-{
- EFI_STATUS Status;
- ISA_IO_DEVICE *IsaIoDevice;
-
- IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);
-
- //
- // Verify Isa IO Access
- //
- Status = IsaIoVerifyAccess (
- IsaIoDevice,
- IsaAccessTypeIo,
- Width,
- Count,
- Offset
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = IsaIoDevice->PciIo->Io.Read (
- IsaIoDevice->PciIo,
- (EFI_PCI_IO_PROTOCOL_WIDTH) Width,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- Offset,
- Count,
- Buffer
- );
-
- if (EFI_ERROR (Status)) {
- REPORT_STATUS_CODE (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR
- );
- }
-
- return Status;
-}
-
-/**
- Performs an ISA I/O Write Cycle
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Width Specifies the width of the I/O operation.
- @param[in] Offset The offset in ISA I/O space to start the I/O operation.
- @param[in] Count The number of I/O operations to perform.
- @param[in] Buffer The source buffer to write data from
-
- @retval EFI_SUCCESS The data was writen to the device sucessfully.
- @retval EFI_UNSUPPORTED The Offset is not valid for this device.
- @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoIoWrite (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
- IN UINT32 Offset,
- IN UINTN Count,
- IN VOID *Buffer
- )
-{
- EFI_STATUS Status;
- ISA_IO_DEVICE *IsaIoDevice;
-
- IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);
-
- //
- // Verify Isa IO Access
- //
- Status = IsaIoVerifyAccess (
- IsaIoDevice,
- IsaAccessTypeIo,
- Width,
- Count,
- Offset
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = IsaIoDevice->PciIo->Io.Write (
- IsaIoDevice->PciIo,
- (EFI_PCI_IO_PROTOCOL_WIDTH) Width,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- Offset,
- Count,
- Buffer
- );
-
- if (EFI_ERROR (Status)) {
- REPORT_STATUS_CODE (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR
- );
- }
-
- return Status;
-}
-
-/**
- Writes an 8-bit I/O Port
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Offset The offset in ISA IO space to start the IO operation.
- @param[in] Value The data to write port.
-
- @retval EFI_SUCCESS Success.
- @retval EFI_INVALID_PARAMETER Parameter is invalid.
- @retval EFI_UNSUPPORTED The address range specified by Offset is not valid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-WritePort (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN UINT32 Offset,
- IN UINT8 Value
- )
-{
- EFI_STATUS Status;
- ISA_IO_DEVICE *IsaIoDevice;
-
- IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);
-
- Status = IsaIoDevice->PciIo->Io.Write (
- IsaIoDevice->PciIo,
- EfiPciIoWidthUint8,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- Offset,
- 1,
- &Value
- );
- if (EFI_ERROR (Status)) {
- REPORT_STATUS_CODE (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR
- );
- return Status;
- }
-
- //
- // Wait for 50 microseconds to take affect.
- //
- gBS->Stall (50);
-
- return EFI_SUCCESS;
-}
-
-/**
- Writes I/O operation base address and count number to a 8 bit I/O Port.
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] AddrOffset The address' offset.
- @param[in] PageOffset The page's offest.
- @param[in] CountOffset The count's offset.
- @param[in] BaseAddress The base address.
- @param[in] Count The number of I/O operations to perform.
-
- @retval EFI_SUCCESS Success.
- @retval EFI_INVALID_PARAMETER Parameter is invalid.
- @retval EFI_UNSUPPORTED The address range specified by these Offsets and Count is not valid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-WriteDmaPort (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN UINT32 AddrOffset,
- IN UINT32 PageOffset,
- IN UINT32 CountOffset,
- IN UINT32 BaseAddress,
- IN UINT16 Count
- )
-{
- EFI_STATUS Status;
-
- Status = WritePort (This, AddrOffset, (UINT8) (BaseAddress & 0xff));
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = WritePort (This, AddrOffset, (UINT8) ((BaseAddress >> 8) & 0xff));
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = WritePort (This, PageOffset, (UINT8) ((BaseAddress >> 16) & 0xff));
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = WritePort (This, CountOffset, (UINT8) (Count & 0xff));
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = WritePort (This, CountOffset, (UINT8) ((Count >> 8) & 0xff));
- return Status;
-}
-
-/**
- Unmaps a memory region for DMA
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Mapping The mapping value returned from EFI_ISA_IO.Map().
-
- @retval EFI_SUCCESS The range was unmapped.
- @retval EFI_DEVICE_ERROR The data was not committed to the target system memory.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoUnmap (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN VOID *Mapping
- )
-{
- ISA_MAP_INFO *IsaMapInfo;
-
- //
- // Check if DMA is supported.
- //
- if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_DMA) == 0) {
- return EFI_UNSUPPORTED;
- }
-
- //
- // See if the Map() operation associated with this Unmap() required a mapping
- // buffer.If a mapping buffer was not required, then this function simply
- // returns EFI_SUCCESS.
- //
- if (Mapping != NULL) {
- //
- // Get the MAP_INFO structure from Mapping
- //
- IsaMapInfo = (ISA_MAP_INFO *) Mapping;
-
- //
- // If this is a write operation from the Agent's point of view,
- // then copy the contents of the mapped buffer into the real buffer
- // so the processor can read the contents of the real buffer.
- //
- if (IsaMapInfo->Operation == EfiIsaIoOperationBusMasterWrite) {
- CopyMem (
- (VOID *) (UINTN) IsaMapInfo->HostAddress,
- (VOID *) (UINTN) IsaMapInfo->MappedHostAddress,
- IsaMapInfo->NumberOfBytes
- );
- }
- //
- // Free the mapped buffer and the MAP_INFO structure.
- //
- gBS->FreePages (IsaMapInfo->MappedHostAddress, IsaMapInfo->NumberOfPages);
- FreePool (IsaMapInfo);
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Flushes any posted write data to the system memory.
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
-
- @retval EFI_SUCCESS The buffers were flushed.
- @retval EFI_DEVICE_ERROR The buffers were not flushed due to a hardware error.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoFlush (
- IN EFI_ISA_IO_PROTOCOL *This
- )
-{
- EFI_STATUS Status;
- ISA_IO_DEVICE *IsaIoDevice;
-
- IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);
-
- Status = IsaIoDevice->PciIo->Flush (IsaIoDevice->PciIo);
-
- if (EFI_ERROR (Status)) {
- REPORT_STATUS_CODE (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR
- );
- }
-
- return Status;
-}
-
-/**
- Performs an ISA Memory Read Cycle
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Width Specifies the width of the memory operation.
- @param[in] Offset The offset in ISA memory space to start the memory operation.
- @param[in] Count The number of memory operations to perform.
- @param[out] Buffer The destination buffer to store the results
-
- @retval EFI_SUCCESS The data was read from the device successfully.
- @retval EFI_UNSUPPORTED The Offset is not valid for this device.
- @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoMemRead (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
- IN UINT32 Offset,
- IN UINTN Count,
- OUT VOID *Buffer
- )
-{
- EFI_STATUS Status;
- ISA_IO_DEVICE *IsaIoDevice;
-
- //
- // Check if ISA memory is supported.
- //
- if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_ISA_MEMORY) == 0) {
- return EFI_UNSUPPORTED;
- }
-
- IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);
-
- //
- // Verify the Isa Io Access
- //
- Status = IsaIoVerifyAccess (
- IsaIoDevice,
- IsaAccessTypeMem,
- Width,
- Count,
- Offset
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = IsaIoDevice->PciIo->Mem.Read (
- IsaIoDevice->PciIo,
- (EFI_PCI_IO_PROTOCOL_WIDTH) Width,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- Offset,
- Count,
- Buffer
- );
-
- if (EFI_ERROR (Status)) {
- REPORT_STATUS_CODE (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR
- );
- }
-
- return Status;
-}
-
-/**
- Performs an ISA Memory Write Cycle
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Width Specifies the width of the memory operation.
- @param[in] Offset The offset in ISA memory space to start the memory operation.
- @param[in] Count The number of memory operations to perform.
- @param[in] Buffer The source buffer to write data from
-
- @retval EFI_SUCCESS The data was written to the device sucessfully.
- @retval EFI_UNSUPPORTED The Offset is not valid for this device.
- @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoMemWrite (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
- IN UINT32 Offset,
- IN UINTN Count,
- IN VOID *Buffer
- )
-{
- EFI_STATUS Status;
- ISA_IO_DEVICE *IsaIoDevice;
-
- //
- // Check if ISA memory is supported.
- //
- if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_ISA_MEMORY) == 0) {
- return EFI_UNSUPPORTED;
- }
-
- IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);
-
- //
- // Verify Isa IO Access
- //
- Status = IsaIoVerifyAccess (
- IsaIoDevice,
- IsaAccessTypeMem,
- Width,
- Count,
- Offset
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = IsaIoDevice->PciIo->Mem.Write (
- IsaIoDevice->PciIo,
- (EFI_PCI_IO_PROTOCOL_WIDTH) Width,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- Offset,
- Count,
- Buffer
- );
-
- if (EFI_ERROR (Status)) {
- REPORT_STATUS_CODE (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR
- );
- }
-
- return Status;
-}
-
-/**
- Copy one region of ISA memory space to another region of ISA memory space on the ISA controller.
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Width Specifies the width of the memory copy operation.
- @param[in] DestOffset The offset of the destination
- @param[in] SrcOffset The offset of the source
- @param[in] Count The number of memory copy operations to perform
-
- @retval EFI_SUCCESS The data was copied sucessfully.
- @retval EFI_UNSUPPORTED The DestOffset or SrcOffset is not valid for this device.
- @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoCopyMem (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
- IN UINT32 DestOffset,
- IN UINT32 SrcOffset,
- IN UINTN Count
- )
-{
- EFI_STATUS Status;
- ISA_IO_DEVICE *IsaIoDevice;
-
- //
- // Check if ISA memory is supported.
- //
- if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_ISA_MEMORY) == 0) {
- return EFI_UNSUPPORTED;
- }
-
- IsaIoDevice = ISA_IO_DEVICE_FROM_ISA_IO_THIS (This);
-
- //
- // Verify Isa IO Access for destination and source
- //
- Status = IsaIoVerifyAccess (
- IsaIoDevice,
- IsaAccessTypeMem,
- Width,
- Count,
- DestOffset
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = IsaIoVerifyAccess (
- IsaIoDevice,
- IsaAccessTypeMem,
- Width,
- Count,
- SrcOffset
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = IsaIoDevice->PciIo->CopyMem (
- IsaIoDevice->PciIo,
- (EFI_PCI_IO_PROTOCOL_WIDTH) Width,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- DestOffset,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- SrcOffset,
- Count
- );
-
- if (EFI_ERROR (Status)) {
- REPORT_STATUS_CODE (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR
- );
- }
-
- return Status;
-}
-
-/**
- Maps a memory region for DMA, note this implementation
- only supports slave read/write operation to save code size.
-
- @param This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param Operation Indicates the type of DMA (slave or bus master), and if
- the DMA operation is going to read or write to system memory.
- @param ChannelNumber The slave channel number to use for this DMA operation.
- If Operation and ChannelAttributes shows that this device
- performs bus mastering DMA, then this field is ignored.
- The legal range for this field is 0..7.
- @param ChannelAttributes The attributes of the DMA channel to use for this DMA operation
- @param HostAddress The system memory address to map to the device.
- @param NumberOfBytes On input the number of bytes to map. On output the number
- of bytes that were mapped.
- @param DeviceAddress The resulting map address for the bus master device to use
- to access the hosts HostAddress.
- @param Mapping A resulting value to pass to EFI_ISA_IO.Unmap().
-
- @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
- @retval EFI_INVALID_PARAMETER The Operation or HostAddress is undefined.
- @retval EFI_UNSUPPORTED The HostAddress can not be mapped as a common buffer.
- @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
- @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
-**/
-EFI_STATUS
-IsaIoMapOnlySupportSlaveReadWrite (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_OPERATION Operation,
- IN UINT8 ChannelNumber OPTIONAL,
- IN UINT32 ChannelAttributes,
- IN VOID *HostAddress,
- IN OUT UINTN *NumberOfBytes,
- OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
- OUT VOID **Mapping
- )
-{
- EFI_STATUS Status;
- EFI_PHYSICAL_ADDRESS PhysicalAddress;
- ISA_MAP_INFO *IsaMapInfo;
- UINT8 DmaMode;
- UINTN MaxNumberOfBytes;
- UINT32 BaseAddress;
- UINT16 Count;
- UINT8 DmaMask;
- UINT8 DmaClear;
- UINT8 DmaChannelMode;
-
- if ((NULL == This) ||
- (NULL == HostAddress) ||
- (NULL == NumberOfBytes) ||
- (NULL == DeviceAddress) ||
- (NULL == Mapping)
- ) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Initialize the return values to their defaults
- //
- *Mapping = NULL;
-
- //
- // Make sure the Operation parameter is valid.
- // Light IsaIo only supports two operations.
- //
- if (!(Operation == EfiIsaIoOperationSlaveRead ||
- Operation == EfiIsaIoOperationSlaveWrite)) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (ChannelNumber >= 4) {
- //
- // The Light IsaIo doesn't support channelNumber larger than 4.
- //
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Map the HostAddress to a DeviceAddress.
- //
- PhysicalAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress;
- if ((PhysicalAddress + *NumberOfBytes) > BASE_16MB) {
- //
- // Common Buffer operations can not be remapped. If the common buffer
- // is above 16MB, then it is not possible to generate a mapping, so return
- // an error.
- //
- if (Operation == EfiIsaIoOperationBusMasterCommonBuffer) {
- return EFI_UNSUPPORTED;
- }
- //
- // Allocate an ISA_MAP_INFO structure to remember the mapping when Unmap()
- // is called later.
- //
- IsaMapInfo = AllocatePool (sizeof (ISA_MAP_INFO));
- if (IsaMapInfo == NULL) {
- *NumberOfBytes = 0;
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // Return a pointer to the MAP_INFO structure in Mapping
- //
- *Mapping = IsaMapInfo;
-
- //
- // Initialize the MAP_INFO structure
- //
- IsaMapInfo->Operation = Operation;
- IsaMapInfo->NumberOfBytes = *NumberOfBytes;
- IsaMapInfo->NumberOfPages = EFI_SIZE_TO_PAGES (*NumberOfBytes);
- IsaMapInfo->HostAddress = PhysicalAddress;
- IsaMapInfo->MappedHostAddress = BASE_16MB - 1;
-
- //
- // Allocate a buffer below 16MB to map the transfer to.
- //
- Status = gBS->AllocatePages (
- AllocateMaxAddress,
- EfiBootServicesData,
- IsaMapInfo->NumberOfPages,
- &IsaMapInfo->MappedHostAddress
- );
- if (EFI_ERROR (Status)) {
- FreePool (IsaMapInfo);
- *NumberOfBytes = 0;
- *Mapping = NULL;
- return Status;
- }
- //
- // If this is a read operation from the DMA agents's point of view,
- // then copy the contents of the real buffer into the mapped buffer
- // so the DMA agent can read the contents of the real buffer.
- //
- if (Operation == EfiIsaIoOperationSlaveRead) {
- CopyMem (
- (VOID *) (UINTN) IsaMapInfo->MappedHostAddress,
- (VOID *) (UINTN) IsaMapInfo->HostAddress,
- IsaMapInfo->NumberOfBytes
- );
- }
- //
- // The DeviceAddress is the address of the maped buffer below 16 MB
- //
- *DeviceAddress = IsaMapInfo->MappedHostAddress;
- } else {
- //
- // The transfer is below 16 MB, so the DeviceAddress is simply the
- // HostAddress
- //
- *DeviceAddress = PhysicalAddress;
- }
-
- //
- // Figure out what to program into the DMA Channel Mode Register
- //
- DmaMode = (UINT8) (B_8237_DMA_CHMODE_INCREMENT | (ChannelNumber & 0x03));
- if (Operation == EfiIsaIoOperationSlaveRead) {
- DmaMode |= V_8237_DMA_CHMODE_MEM2IO;
- } else {
- DmaMode |= V_8237_DMA_CHMODE_IO2MEM;
- }
- //
- // We only support EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE in simplified IsaIo
- //
- DmaMode |= V_8237_DMA_CHMODE_SINGLE;
-
- //
- // A Slave DMA transfer can not cross a 64K boundary.
- // Compute *NumberOfBytes based on this restriction.
- //
- MaxNumberOfBytes = 0x10000 - ((UINT32) (*DeviceAddress) & 0xffff);
- if (*NumberOfBytes > MaxNumberOfBytes) {
- *NumberOfBytes = MaxNumberOfBytes;
- }
- //
- // Compute the values to program into the BaseAddress and Count registers
- // of the Slave DMA controller
- //
- BaseAddress = (UINT32) (*DeviceAddress);
- Count = (UINT16) (*NumberOfBytes - 1);
- //
- // Program the DMA Write Single Mask Register for ChannelNumber
- // Clear the DMA Byte Pointer Register
- //
- DmaMask = R_8237_DMA_WRSMSK_CH0_3;
- DmaClear = R_8237_DMA_CBPR_CH0_3;
- DmaChannelMode = R_8237_DMA_CHMODE_CH0_3;
-
- Status = WritePort (
- This,
- DmaMask,
- (UINT8) (B_8237_DMA_WRSMSK_CMS | (ChannelNumber & 0x03))
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = WritePort (
- This,
- DmaClear,
- (UINT8) (B_8237_DMA_WRSMSK_CMS | (ChannelNumber & 0x03))
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = WritePort (This, DmaChannelMode, DmaMode);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = WriteDmaPort (
- This,
- mDmaRegisters[ChannelNumber].Address,
- mDmaRegisters[ChannelNumber].Page,
- mDmaRegisters[ChannelNumber].Count,
- BaseAddress,
- Count
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = WritePort (
- This,
- DmaMask,
- (UINT8) (ChannelNumber & 0x03)
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Maps a memory region for DMA. This implementation implement the
- the full mapping support.
-
- @param This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param Operation Indicates the type of DMA (slave or bus master), and if
- the DMA operation is going to read or write to system memory.
- @param ChannelNumber The slave channel number to use for this DMA operation.
- If Operation and ChannelAttributes shows that this device
- performs bus mastering DMA, then this field is ignored.
- The legal range for this field is 0..7.
- @param ChannelAttributes The attributes of the DMA channel to use for this DMA operation
- @param HostAddress The system memory address to map to the device.
- @param NumberOfBytes On input the number of bytes to map. On output the number
- of bytes that were mapped.
- @param DeviceAddress The resulting map address for the bus master device to use
- to access the hosts HostAddress.
- @param Mapping A resulting value to pass to EFI_ISA_IO.Unmap().
-
- @retval EFI_SUCCESS - The range was mapped for the returned NumberOfBytes.
- @retval EFI_INVALID_PARAMETER - The Operation or HostAddress is undefined.
- @retval EFI_UNSUPPORTED - The HostAddress can not be mapped as a common buffer.
- @retval EFI_DEVICE_ERROR - The system hardware could not map the requested address.
- @retval EFI_OUT_OF_RESOURCES - The memory pages could not be allocated.
-**/
-EFI_STATUS
-IsaIoMapFullSupport (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_OPERATION Operation,
- IN UINT8 ChannelNumber OPTIONAL,
- IN UINT32 ChannelAttributes,
- IN VOID *HostAddress,
- IN OUT UINTN *NumberOfBytes,
- OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
- OUT VOID **Mapping
- )
-{
- EFI_STATUS Status;
- BOOLEAN Master;
- BOOLEAN Read;
- EFI_PHYSICAL_ADDRESS PhysicalAddress;
- ISA_MAP_INFO *IsaMapInfo;
- UINT8 DmaMode;
- UINTN MaxNumberOfBytes;
- UINT32 BaseAddress;
- UINT16 Count;
- UINT8 DmaMask;
- UINT8 DmaClear;
- UINT8 DmaChannelMode;
-
- if ((NULL == This) ||
- (NULL == HostAddress) ||
- (NULL == NumberOfBytes) ||
- (NULL == DeviceAddress) ||
- (NULL == Mapping)
- ) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Initialize the return values to their defaults
- //
- *Mapping = NULL;
-
- //
- // Make sure the Operation parameter is valid
- //
- if ((UINT32)Operation >= EfiIsaIoOperationMaximum) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (ChannelNumber >= 8) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // See if this is a Slave DMA Operation
- //
- Master = TRUE;
- Read = FALSE;
- if (Operation == EfiIsaIoOperationSlaveRead) {
- Operation = EfiIsaIoOperationBusMasterRead;
- Master = FALSE;
- Read = TRUE;
- }
-
- if (Operation == EfiIsaIoOperationSlaveWrite) {
- Operation = EfiIsaIoOperationBusMasterWrite;
- Master = FALSE;
- Read = FALSE;
- }
-
- if (!Master) {
- //
- // Make sure that ChannelNumber is a valid channel number
- // Channel 4 is used to cascade, so it is illegal.
- //
- if (ChannelNumber == 4 || ChannelNumber > 7) {
- return EFI_INVALID_PARAMETER;
- }
- //
- // This implementation only support COMPATIBLE DMA Transfers
- //
- if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_COMPATIBLE) == 0) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((ChannelAttributes &
- (EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_A |
- EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_B |
- EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_C)) != 0) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (ChannelNumber < 4) {
- //
- // If this is Channel 0..3, then the width must be 8 bit
- //
- if (((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_8) == 0) ||
- ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_16) != 0)
- ) {
- return EFI_INVALID_PARAMETER;
- }
- } else {
- //
- // If this is Channel 4..7, then the width must be 16 bit
- //
- if (((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_8) != 0) ||
- ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_16) == 0)) {
- return EFI_INVALID_PARAMETER;
- }
- }
- //
- // Either Demand Mode or Single Mode must be selected, but not both
- //
- if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE) != 0) {
- if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_DEMAND_MODE) != 0) {
- return EFI_INVALID_PARAMETER;
- }
- } else {
- if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_DEMAND_MODE) == 0) {
- return EFI_INVALID_PARAMETER;
- }
- }
- }
- //
- // Map the HostAddress to a DeviceAddress.
- //
- PhysicalAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress;
- if ((PhysicalAddress +*NumberOfBytes) > BASE_16MB) {
- //
- // Common Buffer operations can not be remapped. If the common buffer
- // is above 16MB, then it is not possible to generate a mapping, so return
- // an error.
- //
- if (Operation == EfiIsaIoOperationBusMasterCommonBuffer) {
- return EFI_UNSUPPORTED;
- }
- //
- // Allocate an ISA_MAP_INFO structure to remember the mapping when Unmap()
- // is called later.
- //
- IsaMapInfo = AllocatePool (sizeof (ISA_MAP_INFO));
- if (IsaMapInfo == NULL) {
- *NumberOfBytes = 0;
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // Return a pointer to the MAP_INFO structure in Mapping
- //
- *Mapping = IsaMapInfo;
-
- //
- // Initialize the MAP_INFO structure
- //
- IsaMapInfo->Operation = Operation;
- IsaMapInfo->NumberOfBytes = *NumberOfBytes;
- IsaMapInfo->NumberOfPages = EFI_SIZE_TO_PAGES (*NumberOfBytes);
- IsaMapInfo->HostAddress = PhysicalAddress;
- IsaMapInfo->MappedHostAddress = BASE_16MB - 1;
-
- //
- // Allocate a buffer below 16MB to map the transfer to.
- //
- Status = gBS->AllocatePages (
- AllocateMaxAddress,
- EfiBootServicesData,
- IsaMapInfo->NumberOfPages,
- &IsaMapInfo->MappedHostAddress
- );
- if (EFI_ERROR (Status)) {
- FreePool (IsaMapInfo);
- *NumberOfBytes = 0;
- *Mapping = NULL;
- return Status;
- }
- //
- // If this is a read operation from the DMA agents's point of view,
- // then copy the contents of the real buffer into the mapped buffer
- // so the DMA agent can read the contents of the real buffer.
- //
- if (Operation == EfiIsaIoOperationBusMasterRead) {
- CopyMem (
- (VOID *) (UINTN) IsaMapInfo->MappedHostAddress,
- (VOID *) (UINTN) IsaMapInfo->HostAddress,
- IsaMapInfo->NumberOfBytes
- );
- }
- //
- // The DeviceAddress is the address of the maped buffer below 16 MB
- //
- *DeviceAddress = IsaMapInfo->MappedHostAddress;
- } else {
- //
- // The transfer is below 16 MB, so the DeviceAddress is simply the
- // HostAddress
- //
- *DeviceAddress = PhysicalAddress;
- }
- //
- // If this is a Bus Master operation then return
- //
- if (Master) {
- return EFI_SUCCESS;
- }
- //
- // Figure out what to program into the DMA Channel Mode Register
- //
- DmaMode = (UINT8) (B_8237_DMA_CHMODE_INCREMENT | (ChannelNumber & 0x03));
- if (Read) {
- DmaMode |= V_8237_DMA_CHMODE_MEM2IO;
- } else {
- DmaMode |= V_8237_DMA_CHMODE_IO2MEM;
- }
-
- if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_AUTO_INITIALIZE) != 0) {
- DmaMode |= B_8237_DMA_CHMODE_AE;
- }
-
- if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_DEMAND_MODE) != 0) {
- DmaMode |= V_8237_DMA_CHMODE_DEMAND;
- }
-
- if ((ChannelAttributes & EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE) != 0) {
- DmaMode |= V_8237_DMA_CHMODE_SINGLE;
- }
- //
- // A Slave DMA transfer can not cross a 64K boundary.
- // Compute *NumberOfBytes based on this restriction.
- //
- MaxNumberOfBytes = 0x10000 - ((UINT32) (*DeviceAddress) & 0xffff);
- if (*NumberOfBytes > MaxNumberOfBytes) {
- *NumberOfBytes = MaxNumberOfBytes;
- }
- //
- // Compute the values to program into the BaseAddress and Count registers
- // of the Slave DMA controller
- //
- if (ChannelNumber < 4) {
- BaseAddress = (UINT32) (*DeviceAddress);
- Count = (UINT16) (*NumberOfBytes - 1);
- } else {
- BaseAddress = (UINT32) (((UINT32) (*DeviceAddress) & 0xff0000) | (((UINT32) (*DeviceAddress) & 0xffff) >> 1));
- Count = (UINT16) ((*NumberOfBytes - 1) >> 1);
- }
- //
- // Program the DMA Write Single Mask Register for ChannelNumber
- // Clear the DMA Byte Pointer Register
- //
- if (ChannelNumber < 4) {
- DmaMask = R_8237_DMA_WRSMSK_CH0_3;
- DmaClear = R_8237_DMA_CBPR_CH0_3;
- DmaChannelMode = R_8237_DMA_CHMODE_CH0_3;
- } else {
- DmaMask = R_8237_DMA_WRSMSK_CH4_7;
- DmaClear = R_8237_DMA_CBPR_CH4_7;
- DmaChannelMode = R_8237_DMA_CHMODE_CH4_7;
- }
-
- Status = WritePort (
- This,
- DmaMask,
- (UINT8) (B_8237_DMA_WRSMSK_CMS | (ChannelNumber & 0x03))
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = WritePort (
- This,
- DmaClear,
- (UINT8) (B_8237_DMA_WRSMSK_CMS | (ChannelNumber & 0x03))
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = WritePort (This, DmaChannelMode, DmaMode);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = WriteDmaPort (
- This,
- mDmaRegisters[ChannelNumber].Address,
- mDmaRegisters[ChannelNumber].Page,
- mDmaRegisters[ChannelNumber].Count,
- BaseAddress,
- Count
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = WritePort (
- This,
- DmaMask,
- (UINT8) (ChannelNumber & 0x03)
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Maps a memory region for DMA
-
- @param This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param Operation Indicates the type of DMA (slave or bus master), and if
- the DMA operation is going to read or write to system memory.
- @param ChannelNumber The slave channel number to use for this DMA operation.
- If Operation and ChannelAttributes shows that this device
- performs bus mastering DMA, then this field is ignored.
- The legal range for this field is 0..7.
- @param ChannelAttributes The attributes of the DMA channel to use for this DMA operation
- @param HostAddress The system memory address to map to the device.
- @param NumberOfBytes On input the number of bytes to map. On output the number
- of bytes that were mapped.
- @param DeviceAddress The resulting map address for the bus master device to use
- to access the hosts HostAddress.
- @param Mapping A resulting value to pass to EFI_ISA_IO.Unmap().
-
- @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
- @retval EFI_INVALID_PARAMETER The Operation or HostAddress is undefined.
- @retval EFI_UNSUPPORTED The HostAddress can not be mapped as a common buffer.
- @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
- @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoMap (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_OPERATION Operation,
- IN UINT8 ChannelNumber OPTIONAL,
- IN UINT32 ChannelAttributes,
- IN VOID *HostAddress,
- IN OUT UINTN *NumberOfBytes,
- OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
- OUT VOID **Mapping
- )
-{
- //
- // Check if DMA is supported.
- //
- if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_DMA) == 0) {
- return EFI_UNSUPPORTED;
- }
- //
- // Set Feature Flag PcdIsaBusSupportBusMaster to FALSE to disable support for
- // ISA Bus Master.
- //
- // So we just return EFI_UNSUPPORTED for these functions.
- //
- if ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_ONLY_SUPPORT_SLAVE_DMA) != 0) {
- return IsaIoMapOnlySupportSlaveReadWrite (
- This,
- Operation,
- ChannelNumber,
- ChannelAttributes,
- HostAddress,
- NumberOfBytes,
- DeviceAddress,
- Mapping
- );
-
- } else {
- return IsaIoMapFullSupport (
- This,
- Operation,
- ChannelNumber,
- ChannelAttributes,
- HostAddress,
- NumberOfBytes,
- DeviceAddress,
- Mapping
- );
- }
-}
-
-/**
- Allocates pages that are suitable for an EfiIsaIoOperationBusMasterCommonBuffer mapping.
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Type The type allocation to perform.
- @param[in] MemoryType The type of memory to allocate.
- @param[in] Pages The number of pages to allocate.
- @param[out] HostAddress A pointer to store the base address of the allocated range.
- @param[in] Attributes The requested bit mask of attributes for the allocated range.
-
- @retval EFI_SUCCESS The requested memory pages were allocated.
- @retval EFI_INVALID_PARAMETER Type is invalid or MemoryType is invalid or HostAddress is NULL
- @retval EFI_UNSUPPORTED Attributes is unsupported or the memory range specified
- by HostAddress, Pages, and Type is not available for common buffer use.
- @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoAllocateBuffer (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ALLOCATE_TYPE Type,
- IN EFI_MEMORY_TYPE MemoryType,
- IN UINTN Pages,
- OUT VOID **HostAddress,
- IN UINT64 Attributes
- )
-{
- EFI_STATUS Status;
- EFI_PHYSICAL_ADDRESS PhysicalAddress;
-
- //
- // Set Feature Flag PcdIsaBusOnlySupportSlaveDma to FALSE to disable support for
- // ISA Bus Master.
- // Or unset Feature Flag PcdIsaBusSupportDma to disable support for ISA DMA.
- //
- if (((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_DMA) == 0) ||
- ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_ONLY_SUPPORT_SLAVE_DMA) != 0)) {
- return EFI_UNSUPPORTED;
- }
-
- if (HostAddress == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((UINT32)Type >= MaxAllocateType) {
- return EFI_INVALID_PARAMETER;
- }
- //
- // The only valid memory types are EfiBootServicesData and EfiRuntimeServicesData
- //
- if (MemoryType != EfiBootServicesData && MemoryType != EfiRuntimeServicesData) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((Attributes & ~(EFI_ISA_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE | EFI_ISA_IO_ATTRIBUTE_MEMORY_CACHED)) != 0) {
- return EFI_UNSUPPORTED;
- }
-
- PhysicalAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) (BASE_16MB - 1);
- if (Type == AllocateAddress) {
- if ((UINTN) (*HostAddress) >= BASE_16MB) {
- return EFI_UNSUPPORTED;
- } else {
- PhysicalAddress = (UINTN) (*HostAddress);
- }
- }
-
- if (Type == AllocateAnyPages) {
- Type = AllocateMaxAddress;
- }
-
- Status = gBS->AllocatePages (Type, MemoryType, Pages, &PhysicalAddress);
- if (EFI_ERROR (Status)) {
- REPORT_STATUS_CODE (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR
- );
- return Status;
- }
-
- *HostAddress = (VOID *) (UINTN) PhysicalAddress;
- return Status;
-}
-
-/**
- Frees memory that was allocated with EFI_ISA_IO.AllocateBuffer().
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Pages The number of pages to free.
- @param[in] HostAddress The base address of the allocated range.
-
- @retval EFI_SUCCESS The requested memory pages were freed.
- @retval EFI_INVALID_PARAMETER The memory was not allocated with EFI_ISA_IO.AllocateBufer().
-**/
-EFI_STATUS
-EFIAPI
-IsaIoFreeBuffer (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN UINTN Pages,
- IN VOID *HostAddress
- )
-{
- EFI_STATUS Status;
-
- //
- // Set Feature Flag PcdIsaBusOnlySupportSlaveDma to FALSE to disable support for
- // ISA Bus Master.
- // Or unset Feature Flag PcdIsaBusSupportDma to disable support for ISA DMA.
- //
- if (((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_SUPPORT_DMA) == 0) ||
- ((PcdGet8 (PcdIsaBusSupportedFeatures) & PCD_ISA_BUS_ONLY_SUPPORT_SLAVE_DMA) != 0)) {
- return EFI_UNSUPPORTED;
- }
-
- Status = gBS->FreePages (
- (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress,
- Pages
- );
- if (EFI_ERROR (Status)) {
- REPORT_STATUS_CODE (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_IO_BUS_LPC | EFI_IOB_EC_CONTROLLER_ERROR
- );
- }
-
- return Status;
-}
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIo.h b/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIo.h deleted file mode 100644 index cc4a1f8b80..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIo.h +++ /dev/null @@ -1,331 +0,0 @@ -/** @file
- The header file for EFI_ISA_IO protocol implementation.
-
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
-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.
-
-**/
-
-#ifndef _ISA_IO_H_
-#define _ISA_IO_H_
-
-#include "IsaDriver.h"
-
-//
-// Bits definition of PcdIsaBusSupportedFeatures
-//
-#define PCD_ISA_BUS_SUPPORT_DMA BIT0
-#define PCD_ISA_BUS_ONLY_SUPPORT_SLAVE_DMA BIT1
-#define PCD_ISA_BUS_SUPPORT_ISA_MEMORY BIT2
-
-//
-// ISA I/O Support Function Prototypes
-//
-
-/**
- Verifies access to an ISA device
-
- @param[in] IsaIoDevice The ISA device to be verified.
- @param[in] Type The Access type. The input must be either IsaAccessTypeMem or IsaAccessTypeIo.
- @param[in] Width The width of the memory operation.
- @param[in] Count The number of memory operations to perform.
- @param[in] Offset The offset in ISA memory space to start the memory operation.
-
- @retval EFI_SUCCESS Verify success.
- @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
- @retval EFI_UNSUPPORTED The device ont support the access type.
-**/
-EFI_STATUS
-IsaIoVerifyAccess (
- IN ISA_IO_DEVICE *IsaIoDevice,
- IN ISA_ACCESS_TYPE Type,
- IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
- IN UINTN Count,
- IN UINT32 Offset
- );
-
-/**
- Performs an ISA I/O Read Cycle
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Width Specifies the width of the I/O operation.
- @param[in] Offset The offset in ISA I/O space to start the I/O operation.
- @param[in] Count The number of I/O operations to perform.
- @param[out] Buffer The destination buffer to store the results
-
- @retval EFI_SUCCESS The data was read from the device sucessfully.
- @retval EFI_UNSUPPORTED The Offset is not valid for this device.
- @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoIoRead (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
- IN UINT32 Offset,
- IN UINTN Count,
- OUT VOID *Buffer
- );
-
-/**
- Performs an ISA I/O Write Cycle
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Width Specifies the width of the I/O operation.
- @param[in] Offset The offset in ISA I/O space to start the I/O operation.
- @param[in] Count The number of I/O operations to perform.
- @param[in] Buffer The source buffer to write data from
-
- @retval EFI_SUCCESS The data was writen to the device sucessfully.
- @retval EFI_UNSUPPORTED The Offset is not valid for this device.
- @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoIoWrite (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
- IN UINT32 Offset,
- IN UINTN Count,
- IN VOID *Buffer
- );
-
-/**
- Maps a memory region for DMA
-
- @param This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param Operation Indicates the type of DMA (slave or bus master), and if
- the DMA operation is going to read or write to system memory.
- @param ChannelNumber The slave channel number to use for this DMA operation.
- If Operation and ChannelAttributes shows that this device
- performs bus mastering DMA, then this field is ignored.
- The legal range for this field is 0..7.
- @param ChannelAttributes The attributes of the DMA channel to use for this DMA operation
- @param HostAddress The system memory address to map to the device.
- @param NumberOfBytes On input the number of bytes to map. On output the number
- of bytes that were mapped.
- @param DeviceAddress The resulting map address for the bus master device to use
- to access the hosts HostAddress.
- @param Mapping A resulting value to pass to EFI_ISA_IO.Unmap().
-
- @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
- @retval EFI_INVALID_PARAMETER The Operation or HostAddress is undefined.
- @retval EFI_UNSUPPORTED The HostAddress can not be mapped as a common buffer.
- @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
- @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoMap (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_OPERATION Operation,
- IN UINT8 ChannelNumber OPTIONAL,
- IN UINT32 ChannelAttributes,
- IN VOID *HostAddress,
- IN OUT UINTN *NumberOfBytes,
- OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
- OUT VOID **Mapping
- );
-
-/**
- Unmaps a memory region for DMA
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Mapping The mapping value returned from EFI_ISA_IO.Map().
-
- @retval EFI_SUCCESS The range was unmapped.
- @retval EFI_DEVICE_ERROR The data was not committed to the target system memory.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoUnmap (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN VOID *Mapping
- );
-
-/**
- Flushes any posted write data to the system memory.
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
-
- @retval EFI_SUCCESS The buffers were flushed.
- @retval EFI_DEVICE_ERROR The buffers were not flushed due to a hardware error.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoFlush (
- IN EFI_ISA_IO_PROTOCOL *This
- );
-
-/**
- Writes I/O operation base address and count number to a 8 bit I/O Port.
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] AddrOffset The address' offset.
- @param[in] PageOffset The page's offest.
- @param[in] CountOffset The count's offset.
- @param[in] BaseAddress The base address.
- @param[in] Count The number of I/O operations to perform.
-
- @retval EFI_SUCCESS Success.
- @retval EFI_INVALID_PARAMETER Parameter is invalid.
- @retval EFI_UNSUPPORTED The address range specified by these Offsets and Count is not valid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-WriteDmaPort (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN UINT32 AddrOffset,
- IN UINT32 PageOffset,
- IN UINT32 CountOffset,
- IN UINT32 BaseAddress,
- IN UINT16 Count
- );
-
-/**
- Writes an 8-bit I/O Port
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Offset The offset in ISA IO space to start the IO operation.
- @param[in] Value The data to write port.
-
- @retval EFI_SUCCESS Success.
- @retval EFI_INVALID_PARAMETER Parameter is invalid.
- @retval EFI_UNSUPPORTED The address range specified by Offset is not valid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-WritePort (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN UINT32 Offset,
- IN UINT8 Value
- );
-
-/**
- Performs an ISA Memory Read Cycle
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Width Specifies the width of the memory operation.
- @param[in] Offset The offset in ISA memory space to start the memory operation.
- @param[in] Count The number of memory operations to perform.
- @param[out] Buffer The destination buffer to store the results
-
- @retval EFI_SUCCESS The data was read from the device successfully.
- @retval EFI_UNSUPPORTED The Offset is not valid for this device.
- @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoMemRead (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
- IN UINT32 Offset,
- IN UINTN Count,
- OUT VOID *Buffer
- );
-
-
-/**
- Performs an ISA Memory Write Cycle
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Width Specifies the width of the memory operation.
- @param[in] Offset The offset in ISA memory space to start the memory operation.
- @param[in] Count The number of memory operations to perform.
- @param[in] Buffer The source buffer to write data from
-
- @retval EFI_SUCCESS The data was written to the device sucessfully.
- @retval EFI_UNSUPPORTED The Offset is not valid for this device.
- @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoMemWrite (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
- IN UINT32 Offset,
- IN UINTN Count,
- IN VOID *Buffer
- );
-
-/**
- Copy one region of ISA memory space to another region of ISA memory space on the ISA controller.
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Width Specifies the width of the memory copy operation.
- @param[in] DestOffset The offset of the destination
- @param[in] SrcOffset The offset of the source
- @param[in] Count The number of memory copy operations to perform
-
- @retval EFI_SUCCESS The data was copied sucessfully.
- @retval EFI_UNSUPPORTED The DestOffset or SrcOffset is not valid for this device.
- @retval EFI_INVALID_PARAMETER Width or Count, or both, were invalid.
- @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoCopyMem (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
- IN UINT32 DestOffset,
- IN UINT32 SrcOffset,
- IN UINTN Count
- );
-
-/**
- Allocates pages that are suitable for an EfiIsaIoOperationBusMasterCommonBuffer mapping.
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Type The type allocation to perform.
- @param[in] MemoryType The type of memory to allocate.
- @param[in] Pages The number of pages to allocate.
- @param[out] HostAddress A pointer to store the base address of the allocated range.
- @param[in] Attributes The requested bit mask of attributes for the allocated range.
-
- @retval EFI_SUCCESS The requested memory pages were allocated.
- @retval EFI_INVALID_PARAMETER Type is invalid or MemoryType is invalid or HostAddress is NULL
- @retval EFI_UNSUPPORTED Attributes is unsupported or the memory range specified
- by HostAddress, Pages, and Type is not available for common buffer use.
- @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
-**/
-EFI_STATUS
-EFIAPI
-IsaIoAllocateBuffer (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN EFI_ALLOCATE_TYPE Type,
- IN EFI_MEMORY_TYPE MemoryType,
- IN UINTN Pages,
- OUT VOID **HostAddress,
- IN UINT64 Attributes
- );
-
-/**
- Frees memory that was allocated with EFI_ISA_IO.AllocateBuffer().
-
- @param[in] This A pointer to the EFI_ISA_IO_PROTOCOL instance.
- @param[in] Pages The number of pages to free.
- @param[in] HostAddress The base address of the allocated range.
-
- @retval EFI_SUCCESS The requested memory pages were freed.
- @retval EFI_INVALID_PARAMETER The memory was not allocated with EFI_ISA_IO.AllocateBufer().
-**/
-EFI_STATUS
-EFIAPI
-IsaIoFreeBuffer (
- IN EFI_ISA_IO_PROTOCOL *This,
- IN UINTN Pages,
- IN VOID *HostAddress
- );
-
-#endif
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIoDxe.inf b/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIoDxe.inf deleted file mode 100644 index 499cf434f5..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIoDxe.inf +++ /dev/null @@ -1,71 +0,0 @@ -## @file
-# Produces an instance of the ISA I/O Protocol for every SIO controller.
-#
-# Produces an instance of the ISA I/O Protocol for every SIO controller. The ISA
-# I/O protocols are installed based off of the information provided by each
-# instance of the SIO Protocol found.
-#
-# Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
-#
-# 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.
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = IsaIoDxe
- MODULE_UNI_FILE = IsaIoDxe.uni
- FILE_GUID = 61AD3083-DCAD-4850-A50C-73B23B3B14F9
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = InitializeIsaIo
-
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-# DRIVER_BINDING = gIsaIoDriver
-# COMPONENT_NAME = gIsaIoComponentName;
-# COMPONENT_NAME2 = gIsaIoComponentName2;
-#
-
-[Sources]
- ComponentName.h
- ComponentName.c
- IsaIo.h
- IsaIo.c
- IsaDriver.h
- IsaDriver.c
-
-[Packages]
- MdePkg/MdePkg.dec
- IntelFrameworkPkg/IntelFrameworkPkg.dec
- IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
- MdeModulePkg/MdeModulePkg.dec
-
-[LibraryClasses]
- PcdLib
- ReportStatusCodeLib
- UefiBootServicesTableLib
- MemoryAllocationLib
- BaseMemoryLib
- DevicePathLib
- UefiLib
- UefiDriverEntryPoint
- DebugLib
-
-[Protocols]
- gEfiIsaIoProtocolGuid ## BY_START
- gEfiSioProtocolGuid ## TO_START
- gEfiPciIoProtocolGuid ## TO_START
- gEfiDevicePathProtocolGuid ## TO_START
- gEfiGenericMemTestProtocolGuid ## TO_START
-
-[Pcd]
- gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdIsaBusSupportedFeatures ## CONSUMES
-
-[UserExtensions.TianoCore."ExtraFiles"]
- IsaIoDxeExtra.uni
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIoDxe.uni b/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIoDxe.uni deleted file mode 100644 index ea988f9e7d..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIoDxe.uni +++ /dev/null @@ -1,24 +0,0 @@ -// /** @file
-// Produces an instance of the ISA I/O Protocol for every SIO controller.
-//
-// Produces an instance of the ISA I/O Protocol for every SIO controller. The ISA
-// I/O protocols are installed based off of the information provided by each
-// instance of the SIO Protocol found.
-//
-// Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
-//
-// 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.
-//
-// **/
-
-
-#string STR_MODULE_ABSTRACT #language en-US "Produces an instance of the ISA I/O Protocol for every SIO controller"
-
-#string STR_MODULE_DESCRIPTION #language en-US "Produces an instance of the ISA I/O Protocol for every SIO controller. The ISA I/O protocols are installed based off of the information provided by each instance of the SIO Protocol found."
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIoDxeExtra.uni b/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIoDxeExtra.uni deleted file mode 100644 index 26112e8dc7..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIoDxeExtra.uni +++ /dev/null @@ -1,20 +0,0 @@ -// /** @file
-// IsaIoDxe Localized Strings and Content
-//
-// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
-//
-// 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.
-//
-// **/
-
-#string STR_PROPERTIES_MODULE_NAME
-#language en-US
-"ISA I/O DXE Driver"
-
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/ComponentName.c b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/ComponentName.c deleted file mode 100644 index ef24008f6b..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/ComponentName.c +++ /dev/null @@ -1,272 +0,0 @@ -/** @file
- UEFI Component Name and Name2 protocol for Isa serial driver.
-
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
-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 "Serial.h"
-
-//
-// EFI Component Name Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIsaSerialComponentName = {
- IsaSerialComponentNameGetDriverName,
- IsaSerialComponentNameGetControllerName,
- "eng"
-};
-
-//
-// EFI Component Name 2 Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIsaSerialComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IsaSerialComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IsaSerialComponentNameGetControllerName,
- "en"
-};
-
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIsaSerialDriverNameTable[] = {
- {
- "eng;en",
- L"ISA Serial Driver"
- },
- {
- NULL,
- NULL
- }
-};
-
-GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 mSerialPortName[] = L"ISA Serial Port # ";
-
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
-
- @param DriverName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-IsaSerialComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- )
-{
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mIsaSerialDriverNameTable,
- DriverName,
- (BOOLEAN)(This == &gIsaSerialComponentName)
- );
-}
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param ControllerHandle[in] The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
-
- @param ChildHandle[in] The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
-
- @param ControllerName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
-
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
-
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-IsaSerialComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- )
-{
- EFI_STATUS Status;
- EFI_SERIAL_IO_PROTOCOL *SerialIo;
- SERIAL_DEV *SerialDevice;
- EFI_UNICODE_STRING_TABLE *ControllerNameTable;
-
- //
- // Make sure this driver is currently managing ControllerHandle
- //
- Status = EfiTestManagedDevice (
- ControllerHandle,
- gSerialControllerDriver.DriverBindingHandle,
- &gEfiIsaIoProtocolGuid
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- ControllerNameTable = NULL;
- if (ChildHandle != NULL) {
- Status = EfiTestChildHandle (
- ControllerHandle,
- ChildHandle,
- &gEfiIsaIoProtocolGuid
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Get the Serial I/O Protocol from the child handle
- //
- Status = gBS->OpenProtocol (
- ChildHandle,
- &gEfiSerialIoProtocolGuid,
- (VOID **) &SerialIo,
- gSerialControllerDriver.DriverBindingHandle,
- ChildHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Get the Serial Controller's Device structure
- //
- SerialDevice = SERIAL_DEV_FROM_THIS (SerialIo);
- ControllerNameTable = SerialDevice->ControllerNameTable;
- }
-
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- ControllerNameTable,
- ControllerName,
- (BOOLEAN)(This == &gIsaSerialComponentName)
- );
-}
-
-/**
- Add the ISO639-2 and RFC4646 component name both for the Serial IO device
-
- @param SerialDevice A pointer to the SERIAL_DEV instance.
-
- @param IsaIo A pointer to the EFI_ISA_IO_PROTOCOL instance.
-
-**/
-VOID
-AddName (
- IN SERIAL_DEV *SerialDevice,
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- )
-{
- mSerialPortName[(sizeof (mSerialPortName) / 2) - 2] = (CHAR16) (L'0' + (UINT8) IsaIo->ResourceList->Device.UID);
- AddUnicodeString2 (
- "eng",
- gIsaSerialComponentName.SupportedLanguages,
- &SerialDevice->ControllerNameTable,
- mSerialPortName,
- TRUE
- );
- AddUnicodeString2 (
- "en",
- gIsaSerialComponentName2.SupportedLanguages,
- &SerialDevice->ControllerNameTable,
- mSerialPortName,
- FALSE
- );
-
-}
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf deleted file mode 100644 index 4abaac9ff8..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf +++ /dev/null @@ -1,80 +0,0 @@ -## @file
-# Serial driver for standard UARTS on an ISA bus.
-#
-# Produces the Serial I/O protocol for standard UARTS using ISA I/O. This driver
-# supports the 8250, 16450, 16550 and 16550A UART types.
-#
-# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
-#
-# 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.
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = IsaSerialDxe
- MODULE_UNI_FILE = IsaSerialDxe.uni
- FILE_GUID = 93B80003-9FB3-11d4-9A3A-0090273FC14D
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = InitializeIsaSerial
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-#
-# DRIVER_BINDING = gSerialControllerDriver
-# COMPONENT_NAME = gIsaSerialComponentName
-# COMPONENT_NAME2 = gIsaSerialComponentName2
-#
-
-[Sources]
- ComponentName.c
- Serial.h
- Serial.c
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- IntelFrameworkPkg/IntelFrameworkPkg.dec
- IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
-
-[LibraryClasses]
- PcdLib
- ReportStatusCodeLib
- UefiBootServicesTableLib
- MemoryAllocationLib
- BaseMemoryLib
- DevicePathLib
- UefiLib
- UefiDriverEntryPoint
- DebugLib
-
-[Guids]
- gEfiUartDevicePathGuid ## SOMETIMES_CONSUMES ## GUID
-
-[Protocols]
- gEfiIsaIoProtocolGuid ## TO_START
- gEfiDevicePathProtocolGuid ## TO_START
- gEfiSerialIoProtocolGuid ## BY_START
- gEfiDevicePathProtocolGuid ## BY_START
-
-[FeaturePcd]
- gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdIsaBusSerialUseHalfHandshake|FALSE ## CONSUMES
-
-[Pcd]
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200 ## CONSUMES
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits|8 ## CONSUMES
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity|1 ## CONSUMES
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits|1 ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|1843200 ## CONSUMES
-
-[UserExtensions.TianoCore."ExtraFiles"]
- IsaSerialDxeExtra.uni
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.uni b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.uni deleted file mode 100644 index 154fdd5d42..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.uni +++ /dev/null @@ -1,23 +0,0 @@ -// /** @file
-// Serial driver for standard UARTS on an ISA bus.
-//
-// Produces the Serial I/O protocol for standard UARTS using ISA I/O. This driver
-// supports the 8250, 16450, 16550 and 16550A UART types.
-//
-// Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
-//
-// 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.
-//
-// **/
-
-
-#string STR_MODULE_ABSTRACT #language en-US "Serial driver for standard UARTS on an ISA bus"
-
-#string STR_MODULE_DESCRIPTION #language en-US "Produces the Serial I/O protocol for standard UARTS using ISA I/O. This driver supports the 8250, 16450, 16550 and 16550A UART types."
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxeExtra.uni b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxeExtra.uni deleted file mode 100644 index d45d304a73..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxeExtra.uni +++ /dev/null @@ -1,20 +0,0 @@ -// /** @file
-// IsaSerialDxe Localized Strings and Content
-//
-// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
-//
-// 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.
-//
-// **/
-
-#string STR_PROPERTIES_MODULE_NAME
-#language en-US
-"ISA UART Serial Bus DXE Driver"
-
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c deleted file mode 100644 index 57ee669d14..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c +++ /dev/null @@ -1,2038 +0,0 @@ -/** @file
- Serial driver for standard UARTS on an ISA bus.
-
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
-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 "Serial.h"
-
-//
-// ISA Serial Driver Global Variables
-//
-EFI_DRIVER_BINDING_PROTOCOL gSerialControllerDriver = {
- SerialControllerDriverSupported,
- SerialControllerDriverStart,
- SerialControllerDriverStop,
- 0xa,
- NULL,
- NULL
-};
-
-
-SERIAL_DEV gSerialDevTempate = {
- SERIAL_DEV_SIGNATURE,
- NULL,
- { // SerialIo
- SERIAL_IO_INTERFACE_REVISION,
- IsaSerialReset,
- IsaSerialSetAttributes,
- IsaSerialSetControl,
- IsaSerialGetControl,
- IsaSerialWrite,
- IsaSerialRead,
- NULL
- },
- { // SerialMode
- SERIAL_PORT_SUPPORT_CONTROL_MASK,
- SERIAL_PORT_DEFAULT_TIMEOUT,
- 0,
- SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH,
- 0,
- 0,
- 0
- },
- NULL,
- NULL,
- { // UartDevicePath
- {
- MESSAGING_DEVICE_PATH,
- MSG_UART_DP,
- {
- (UINT8) (sizeof (UART_DEVICE_PATH)),
- (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8)
- }
- },
- 0,
- 0,
- 0,
- 0,
- 0
- },
- NULL,
- 0, //BaseAddress
- {
- 0,
- 0,
- SERIAL_MAX_BUFFER_SIZE,
- { 0 }
- },
- {
- 0,
- 0,
- SERIAL_MAX_BUFFER_SIZE,
- { 0 }
- },
- FALSE,
- FALSE,
- Uart16550A,
- NULL
-};
-
-/**
- Check the device path node whether it's the Flow Control node or not.
-
- @param[in] FlowControl The device path node to be checked.
-
- @retval TRUE It's the Flow Control node.
- @retval FALSE It's not.
-
-**/
-BOOLEAN
-IsUartFlowControlNode (
- IN UART_FLOW_CONTROL_DEVICE_PATH *FlowControl
- )
-{
- return (BOOLEAN) (
- (DevicePathType (FlowControl) == MESSAGING_DEVICE_PATH) &&
- (DevicePathSubType (FlowControl) == MSG_VENDOR_DP) &&
- (CompareGuid (&FlowControl->Guid, &gEfiUartDevicePathGuid))
- );
-}
-
-/**
- Check the device path node whether it contains Flow Control node or not.
-
- @param[in] DevicePath The device path to be checked.
-
- @retval TRUE It contains the Flow Control node.
- @retval FALSE It doesn't.
-
-**/
-BOOLEAN
-ContainsFlowControl (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
- )
-{
- while (!IsDevicePathEnd (DevicePath)) {
- if (IsUartFlowControlNode ((UART_FLOW_CONTROL_DEVICE_PATH *) DevicePath)) {
- return TRUE;
- }
- DevicePath = NextDevicePathNode (DevicePath);
- }
-
- return FALSE;
-}
-
-/**
- The user Entry Point for module IsaSerial. The user code starts with this function.
-
- @param[in] ImageHandle The firmware allocated handle for the EFI image.
- @param[in] SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The entry point is executed successfully.
- @retval other Some error occurs when executing this entry point.
-
-**/
-EFI_STATUS
-EFIAPI
-InitializeIsaSerial (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- //
- // Install driver model protocol(s).
- //
- Status = EfiLibInstallDriverBindingComponentName2 (
- ImageHandle,
- SystemTable,
- &gSerialControllerDriver,
- ImageHandle,
- &gIsaSerialComponentName,
- &gIsaSerialComponentName2
- );
- ASSERT_EFI_ERROR (Status);
-
- //
- // Initialize UART default setting in gSerialDevTempate
- //
- gSerialDevTempate.SerialMode.BaudRate = PcdGet64 (PcdUartDefaultBaudRate);
- gSerialDevTempate.SerialMode.DataBits = PcdGet8 (PcdUartDefaultDataBits);
- gSerialDevTempate.SerialMode.Parity = PcdGet8 (PcdUartDefaultParity);
- gSerialDevTempate.SerialMode.StopBits = PcdGet8 (PcdUartDefaultStopBits);
- gSerialDevTempate.UartDevicePath.BaudRate = PcdGet64 (PcdUartDefaultBaudRate);
- gSerialDevTempate.UartDevicePath.DataBits = PcdGet8 (PcdUartDefaultDataBits);
- gSerialDevTempate.UartDevicePath.Parity = PcdGet8 (PcdUartDefaultParity);
- gSerialDevTempate.UartDevicePath.StopBits = PcdGet8 (PcdUartDefaultStopBits);
-
- return Status;
-}
-
-/**
- Check to see if this driver supports the given controller
-
- @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param Controller The handle of the controller to test.
- @param RemainingDevicePath A pointer to the remaining portion of a device path.
-
- @return EFI_SUCCESS This driver can support the given controller
-
-**/
-EFI_STATUS
-EFIAPI
-SerialControllerDriverSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-
-{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
- EFI_ISA_IO_PROTOCOL *IsaIo;
- UART_DEVICE_PATH *UartNode;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- UART_FLOW_CONTROL_DEVICE_PATH *FlowControlNode;
- EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;
- UINTN EntryCount;
- UINTN Index;
- BOOLEAN HasFlowControl;
-
- //
- // Check RemainingDevicePath validation
- //
- if (RemainingDevicePath != NULL) {
- //
- // Check if RemainingDevicePath is the End of Device Path Node,
- // if yes, go on checking other conditions
- //
- if (!IsDevicePathEnd (RemainingDevicePath)) {
- //
- // If RemainingDevicePath isn't the End of Device Path Node,
- // check its validation
- //
- Status = EFI_UNSUPPORTED;
-
- UartNode = (UART_DEVICE_PATH *) RemainingDevicePath;
- if (UartNode->Header.Type != MESSAGING_DEVICE_PATH ||
- UartNode->Header.SubType != MSG_UART_DP ||
- sizeof (UART_DEVICE_PATH) != DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) UartNode)
- ) {
- goto Error;
- }
-
- if (UartNode->BaudRate > SERIAL_PORT_MAX_BAUD_RATE) {
- goto Error;
- }
-
- if (UartNode->Parity < NoParity || UartNode->Parity > SpaceParity) {
- goto Error;
- }
-
- if (UartNode->DataBits < 5 || UartNode->DataBits > 8) {
- goto Error;
- }
-
- if (UartNode->StopBits < OneStopBit || UartNode->StopBits > TwoStopBits) {
- goto Error;
- }
-
- if ((UartNode->DataBits == 5) && (UartNode->StopBits == TwoStopBits)) {
- goto Error;
- }
-
- if ((UartNode->DataBits >= 6) && (UartNode->DataBits <= 8) && (UartNode->StopBits == OneFiveStopBits)) {
- goto Error;
- }
-
- FlowControlNode = (UART_FLOW_CONTROL_DEVICE_PATH *) NextDevicePathNode (UartNode);
- if (IsUartFlowControlNode (FlowControlNode)) {
- //
- // If the second node is Flow Control Node,
- // return error when it request other than hardware flow control.
- //
- if ((ReadUnaligned32 (&FlowControlNode->FlowControlMap) & ~UART_FLOW_CONTROL_HARDWARE) != 0) {
- goto Error;
- }
- }
- }
- }
-
- //
- // Open the IO Abstraction(s) needed to perform the supported test
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- (VOID **) &IsaIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (Status == EFI_ALREADY_STARTED) {
- if (RemainingDevicePath == NULL || IsDevicePathEnd (RemainingDevicePath)) {
- //
- // If RemainingDevicePath is NULL or is the End of Device Path Node
- //
- return EFI_SUCCESS;
- }
- //
- // When the driver has produced device path with flow control node but RemainingDevicePath only contains UART node,
- // return unsupported, and vice versa.
- //
- Status = gBS->OpenProtocolInformation (
- Controller,
- &gEfiIsaIoProtocolGuid,
- &OpenInfoBuffer,
- &EntryCount
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- for (Index = 0; Index < EntryCount; Index++) {
- if ((OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
- Status = gBS->OpenProtocol (
- OpenInfoBuffer[Index].ControllerHandle,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &DevicePath,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (!EFI_ERROR (Status)) {
- HasFlowControl = ContainsFlowControl (RemainingDevicePath);
- if (HasFlowControl ^ ContainsFlowControl (DevicePath)) {
- Status = EFI_UNSUPPORTED;
- }
- }
- break;
- }
- }
- FreePool (OpenInfoBuffer);
- return Status;
- }
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Close the I/O Abstraction(s) used to perform the supported test
- //
- gBS->CloseProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- //
- // Open the EFI Device Path protocol needed to perform the supported test
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (Status == EFI_ALREADY_STARTED) {
- return EFI_SUCCESS;
- }
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Use the ISA I/O Protocol to see if Controller is standard ISA UART that
- // can be managed by this driver.
- //
- Status = EFI_SUCCESS;
- if (IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x501)) {
- Status = EFI_UNSUPPORTED;
- goto Error;
- }
-
-Error:
- //
- // Close protocol, don't use device path protocol in the Support() function
- //
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- return Status;
-}
-
-/**
- Start to management the controller passed in
-
- @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param Controller The handle of the controller to test.
- @param RemainingDevicePath A pointer to the remaining portion of a device path.
-
- @return EFI_SUCCESS Driver is started successfully
-
-**/
-EFI_STATUS
-EFIAPI
-SerialControllerDriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-
-{
- EFI_STATUS Status;
- EFI_ISA_IO_PROTOCOL *IsaIo;
- SERIAL_DEV *SerialDevice;
- UINTN Index;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
- EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;
- UINTN EntryCount;
- EFI_SERIAL_IO_PROTOCOL *SerialIo;
- UART_DEVICE_PATH *Uart;
- UINT32 FlowControlMap;
- UART_FLOW_CONTROL_DEVICE_PATH *FlowControl;
- EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
- UINT32 Control;
-
- SerialDevice = NULL;
- //
- // Get the Parent Device Path
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {
- return Status;
- }
- //
- // Report status code enable the serial
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_P_PC_ENABLE | EFI_PERIPHERAL_SERIAL_PORT,
- ParentDevicePath
- );
-
- //
- // Grab the IO abstraction we need to get any work done
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- (VOID **) &IsaIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {
- goto Error;
- }
-
- if (Status == EFI_ALREADY_STARTED) {
-
- if (RemainingDevicePath == NULL || IsDevicePathEnd (RemainingDevicePath)) {
- //
- // If RemainingDevicePath is NULL or is the End of Device Path Node
- //
- return EFI_SUCCESS;
- }
-
- //
- // Make sure a child handle does not already exist. This driver can only
- // produce one child per serial port.
- //
- Status = gBS->OpenProtocolInformation (
- Controller,
- &gEfiIsaIoProtocolGuid,
- &OpenInfoBuffer,
- &EntryCount
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = EFI_ALREADY_STARTED;
- for (Index = 0; Index < EntryCount; Index++) {
- if ((OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
- Status = gBS->OpenProtocol (
- OpenInfoBuffer[Index].ControllerHandle,
- &gEfiSerialIoProtocolGuid,
- (VOID **) &SerialIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (!EFI_ERROR (Status)) {
- Uart = (UART_DEVICE_PATH *) RemainingDevicePath;
- Status = SerialIo->SetAttributes (
- SerialIo,
- Uart->BaudRate,
- SerialIo->Mode->ReceiveFifoDepth,
- SerialIo->Mode->Timeout,
- (EFI_PARITY_TYPE) Uart->Parity,
- Uart->DataBits,
- (EFI_STOP_BITS_TYPE) Uart->StopBits
- );
-
- FlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) NextDevicePathNode (Uart);
- if (!EFI_ERROR (Status) && IsUartFlowControlNode (FlowControl)) {
- Status = SerialIo->GetControl (SerialIo, &Control);
- if (!EFI_ERROR (Status)) {
- if (ReadUnaligned32 (&FlowControl->FlowControlMap) == UART_FLOW_CONTROL_HARDWARE) {
- Control |= EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE;
- } else {
- Control &= ~EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE;
- }
- //
- // Clear the bits that are not allowed to pass to SetControl
- //
- Control &= (EFI_SERIAL_REQUEST_TO_SEND | EFI_SERIAL_DATA_TERMINAL_READY |
- EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE | EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE |
- EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE);
- Status = SerialIo->SetControl (SerialIo, Control);
- }
- }
- }
- break;
- }
- }
-
- FreePool (OpenInfoBuffer);
- return Status;
- }
-
- if (RemainingDevicePath != NULL) {
- if (IsDevicePathEnd (RemainingDevicePath)) {
- //
- // If RemainingDevicePath is the End of Device Path Node,
- // skip enumerate any device and return EFI_SUCESSS
- //
- return EFI_SUCCESS;
- }
- }
-
- //
- // Initialize the serial device instance
- //
- SerialDevice = AllocateCopyPool (sizeof (SERIAL_DEV), &gSerialDevTempate);
- if (SerialDevice == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Error;
- }
-
- SerialDevice->SerialIo.Mode = &(SerialDevice->SerialMode);
- SerialDevice->IsaIo = IsaIo;
- SerialDevice->ParentDevicePath = ParentDevicePath;
- FlowControl = NULL;
- FlowControlMap = 0;
-
- //
- // Check if RemainingDevicePath is NULL,
- // if yes, use the values from the gSerialDevTempate as no remaining device path was
- // passed in.
- //
- if (RemainingDevicePath != NULL) {
- //
- // If RemainingDevicePath isn't NULL,
- // match the configuration of the RemainingDevicePath. IsHandleSupported()
- // already checked to make sure the RemainingDevicePath contains settings
- // that we can support.
- //
- CopyMem (&SerialDevice->UartDevicePath, RemainingDevicePath, sizeof (UART_DEVICE_PATH));
- FlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) NextDevicePathNode (RemainingDevicePath);
- if (IsUartFlowControlNode (FlowControl)) {
- FlowControlMap = ReadUnaligned32 (&FlowControl->FlowControlMap);
- } else {
- FlowControl = NULL;
- }
- }
-
- AddName (SerialDevice, IsaIo);
-
- for (Index = 0; SerialDevice->IsaIo->ResourceList->ResourceItem[Index].Type != EfiIsaAcpiResourceEndOfList; Index++) {
- if (SerialDevice->IsaIo->ResourceList->ResourceItem[Index].Type == EfiIsaAcpiResourceIo) {
- SerialDevice->BaseAddress = (UINT16) SerialDevice->IsaIo->ResourceList->ResourceItem[Index].StartRange;
- }
- }
-
- SerialDevice->HardwareFlowControl = (BOOLEAN) (FlowControlMap == UART_FLOW_CONTROL_HARDWARE);
-
- //
- // Report status code the serial present
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_P_PC_PRESENCE_DETECT | EFI_PERIPHERAL_SERIAL_PORT,
- ParentDevicePath
- );
-
- if (!IsaSerialPortPresent (SerialDevice)) {
- Status = EFI_DEVICE_ERROR;
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_ERROR_CODE,
- EFI_P_EC_NOT_DETECTED | EFI_PERIPHERAL_SERIAL_PORT,
- ParentDevicePath
- );
- goto Error;
- }
-
- //
- // Build the device path by appending the UART node to the ParentDevicePath.
- // The Uart setings are zero here, since SetAttribute() will update them to match
- // the default setings.
- //
- SerialDevice->DevicePath = AppendDevicePathNode (
- ParentDevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *) &SerialDevice->UartDevicePath
- );
- //
- // Only produce the Flow Control node when remaining device path has it
- //
- if (FlowControl != NULL) {
- TempDevicePath = SerialDevice->DevicePath;
- if (TempDevicePath != NULL) {
- SerialDevice->DevicePath = AppendDevicePathNode (
- TempDevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *) FlowControl
- );
- FreePool (TempDevicePath);
- }
- }
- if (SerialDevice->DevicePath == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Error;
- }
-
- //
- // Fill in Serial I/O Mode structure based on either the RemainingDevicePath or defaults.
- //
- SerialDevice->SerialMode.BaudRate = SerialDevice->UartDevicePath.BaudRate;
- SerialDevice->SerialMode.DataBits = SerialDevice->UartDevicePath.DataBits;
- SerialDevice->SerialMode.Parity = SerialDevice->UartDevicePath.Parity;
- SerialDevice->SerialMode.StopBits = SerialDevice->UartDevicePath.StopBits;
-
- //
- // Issue a reset to initialize the COM port
- //
- Status = SerialDevice->SerialIo.Reset (&SerialDevice->SerialIo);
- if (EFI_ERROR (Status)) {
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_ERROR_CODE,
- EFI_P_EC_CONTROLLER_ERROR | EFI_PERIPHERAL_SERIAL_PORT,
- ParentDevicePath
- );
- goto Error;
- }
- //
- // Install protocol interfaces for the serial device.
- //
- Status = gBS->InstallMultipleProtocolInterfaces (
- &SerialDevice->Handle,
- &gEfiDevicePathProtocolGuid,
- SerialDevice->DevicePath,
- &gEfiSerialIoProtocolGuid,
- &SerialDevice->SerialIo,
- NULL
- );
- if (EFI_ERROR (Status)) {
- goto Error;
- }
- //
- // Open For Child Device
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- (VOID **) &IsaIo,
- This->DriverBindingHandle,
- SerialDevice->Handle,
- EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
- );
-
-Error:
- if (EFI_ERROR (Status)) {
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- gBS->CloseProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- if (SerialDevice != NULL) {
- if (SerialDevice->DevicePath != NULL) {
- gBS->FreePool (SerialDevice->DevicePath);
- }
-
- FreeUnicodeStringTable (SerialDevice->ControllerNameTable);
- gBS->FreePool (SerialDevice);
- }
- }
-
- return Status;
-}
-
-/**
- Disconnect this driver with the controller, uninstall related protocol instance
-
- @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param Controller The handle of the controller to test.
- @param NumberOfChildren Number of child device.
- @param ChildHandleBuffer A pointer to the remaining portion of a device path.
-
- @retval EFI_SUCCESS Operation successfully
- @retval EFI_DEVICE_ERROR Cannot stop the driver successfully
-
-**/
-EFI_STATUS
-EFIAPI
-SerialControllerDriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- )
-
-{
- EFI_STATUS Status;
- UINTN Index;
- BOOLEAN AllChildrenStopped;
- EFI_SERIAL_IO_PROTOCOL *SerialIo;
- SERIAL_DEV *SerialDevice;
- EFI_ISA_IO_PROTOCOL *IsaIo;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
-
- Status = gBS->HandleProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &DevicePath
- );
-
- //
- // Report the status code disable the serial
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_P_PC_DISABLE | EFI_PERIPHERAL_SERIAL_PORT,
- DevicePath
- );
-
- //
- // Complete all outstanding transactions to Controller.
- // Don't allow any new transaction to Controller to be started.
- //
- if (NumberOfChildren == 0) {
- //
- // Close the bus driver
- //
- Status = gBS->CloseProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- Status = gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- return Status;
- }
-
- AllChildrenStopped = TRUE;
-
- for (Index = 0; Index < NumberOfChildren; Index++) {
-
- Status = gBS->OpenProtocol (
- ChildHandleBuffer[Index],
- &gEfiSerialIoProtocolGuid,
- (VOID **) &SerialIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (!EFI_ERROR (Status)) {
-
- SerialDevice = SERIAL_DEV_FROM_THIS (SerialIo);
-
- Status = gBS->CloseProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- This->DriverBindingHandle,
- ChildHandleBuffer[Index]
- );
-
- Status = gBS->UninstallMultipleProtocolInterfaces (
- ChildHandleBuffer[Index],
- &gEfiDevicePathProtocolGuid,
- SerialDevice->DevicePath,
- &gEfiSerialIoProtocolGuid,
- &SerialDevice->SerialIo,
- NULL
- );
- if (EFI_ERROR (Status)) {
- gBS->OpenProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- (VOID **) &IsaIo,
- This->DriverBindingHandle,
- ChildHandleBuffer[Index],
- EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
- );
- } else {
- if (SerialDevice->DevicePath != NULL) {
- gBS->FreePool (SerialDevice->DevicePath);
- }
-
- FreeUnicodeStringTable (SerialDevice->ControllerNameTable);
- gBS->FreePool (SerialDevice);
- }
- }
-
- if (EFI_ERROR (Status)) {
- AllChildrenStopped = FALSE;
- }
- }
-
- if (!AllChildrenStopped) {
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Detect whether specific FIFO is full or not.
-
- @param Fifo A pointer to the Data Structure SERIAL_DEV_FIFO
-
- @return whether specific FIFO is full or not
-
-**/
-BOOLEAN
-IsaSerialFifoFull (
- IN SERIAL_DEV_FIFO *Fifo
- )
-
-{
- if (Fifo->Surplus == 0) {
- return TRUE;
- }
-
- return FALSE;
-}
-
-/**
- Detect whether specific FIFO is empty or not.
-
- @param Fifo A pointer to the Data Structure SERIAL_DEV_FIFO
-
- @return whether specific FIFO is empty or not
-
-**/
-BOOLEAN
-IsaSerialFifoEmpty (
- IN SERIAL_DEV_FIFO *Fifo
- )
-
-{
- if (Fifo->Surplus == SERIAL_MAX_BUFFER_SIZE) {
- return TRUE;
- }
-
- return FALSE;
-}
-
-/**
- Add data to specific FIFO.
-
- @param Fifo A pointer to the Data Structure SERIAL_DEV_FIFO
- @param Data the data added to FIFO
-
- @retval EFI_SUCCESS Add data to specific FIFO successfully
- @retval EFI_OUT_OF_RESOURCE Failed to add data because FIFO is already full
-
-**/
-EFI_STATUS
-IsaSerialFifoAdd (
- IN SERIAL_DEV_FIFO *Fifo,
- IN UINT8 Data
- )
-
-{
- //
- // if FIFO full can not add data
- //
- if (IsaSerialFifoFull (Fifo)) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // FIFO is not full can add data
- //
- Fifo->Data[Fifo->Last] = Data;
- Fifo->Surplus--;
- Fifo->Last++;
- if (Fifo->Last == SERIAL_MAX_BUFFER_SIZE) {
- Fifo->Last = 0;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Remove data from specific FIFO.
-
- @param Fifo A pointer to the Data Structure SERIAL_DEV_FIFO
- @param Data the data removed from FIFO
-
- @retval EFI_SUCCESS Remove data from specific FIFO successfully
- @retval EFI_OUT_OF_RESOURCE Failed to remove data because FIFO is empty
-
-**/
-EFI_STATUS
-IsaSerialFifoRemove (
- IN SERIAL_DEV_FIFO *Fifo,
- OUT UINT8 *Data
- )
-
-{
- //
- // if FIFO is empty, no data can remove
- //
- if (IsaSerialFifoEmpty (Fifo)) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // FIFO is not empty, can remove data
- //
- *Data = Fifo->Data[Fifo->First];
- Fifo->Surplus++;
- Fifo->First++;
- if (Fifo->First == SERIAL_MAX_BUFFER_SIZE) {
- Fifo->First = 0;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Reads and writes all avaliable data.
-
- @param SerialDevice The device to flush
-
- @retval EFI_SUCCESS Data was read/written successfully.
- @retval EFI_OUT_OF_RESOURCE Failed because software receive FIFO is full. Note, when
- this happens, pending writes are not done.
-
-**/
-EFI_STATUS
-IsaSerialReceiveTransmit (
- IN SERIAL_DEV *SerialDevice
- )
-
-{
- SERIAL_PORT_LSR Lsr;
- UINT8 Data;
- BOOLEAN ReceiveFifoFull;
- SERIAL_PORT_MSR Msr;
- SERIAL_PORT_MCR Mcr;
- UINTN TimeOut;
-
- Data = 0;
-
- //
- // Begin the read or write
- //
- if (SerialDevice->SoftwareLoopbackEnable) {
- do {
- ReceiveFifoFull = IsaSerialFifoFull (&SerialDevice->Receive);
- if (!IsaSerialFifoEmpty (&SerialDevice->Transmit)) {
- IsaSerialFifoRemove (&SerialDevice->Transmit, &Data);
- if (ReceiveFifoFull) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- IsaSerialFifoAdd (&SerialDevice->Receive, Data);
- }
- } while (!IsaSerialFifoEmpty (&SerialDevice->Transmit));
- } else {
- ReceiveFifoFull = IsaSerialFifoFull (&SerialDevice->Receive);
- //
- // For full handshake flow control, tell the peer to send data
- // if receive buffer is available.
- //
- if (SerialDevice->HardwareFlowControl &&
- !FeaturePcdGet(PcdIsaBusSerialUseHalfHandshake)&&
- !ReceiveFifoFull
- ) {
- Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);
- Mcr.Bits.Rts = 1;
- WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);
- }
- do {
- Lsr.Data = READ_LSR (SerialDevice->IsaIo, SerialDevice->BaseAddress);
-
- //
- // Flush incomming data to prevent a an overrun during a long write
- //
- if ((Lsr.Bits.Dr == 1) && !ReceiveFifoFull) {
- ReceiveFifoFull = IsaSerialFifoFull (&SerialDevice->Receive);
- if (!ReceiveFifoFull) {
- if (Lsr.Bits.FIFOe == 1 || Lsr.Bits.Oe == 1 || Lsr.Bits.Pe == 1 || Lsr.Bits.Fe == 1 || Lsr.Bits.Bi == 1) {
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_ERROR_CODE,
- EFI_P_EC_INPUT_ERROR | EFI_PERIPHERAL_SERIAL_PORT,
- SerialDevice->DevicePath
- );
- if (Lsr.Bits.FIFOe == 1 || Lsr.Bits.Pe == 1|| Lsr.Bits.Fe == 1 || Lsr.Bits.Bi == 1) {
- Data = READ_RBR (SerialDevice->IsaIo, SerialDevice->BaseAddress);
- continue;
- }
- }
-
- Data = READ_RBR (SerialDevice->IsaIo, SerialDevice->BaseAddress);
-
- IsaSerialFifoAdd (&SerialDevice->Receive, Data);
-
- //
- // For full handshake flow control, if receive buffer full
- // tell the peer to stop sending data.
- //
- if (SerialDevice->HardwareFlowControl &&
- !FeaturePcdGet(PcdIsaBusSerialUseHalfHandshake) &&
- IsaSerialFifoFull (&SerialDevice->Receive)
- ) {
- Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);
- Mcr.Bits.Rts = 0;
- WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);
- }
-
-
- continue;
- } else {
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_P_SERIAL_PORT_PC_CLEAR_BUFFER | EFI_PERIPHERAL_SERIAL_PORT,
- SerialDevice->DevicePath
- );
- }
- }
- //
- // Do the write
- //
- if (Lsr.Bits.Thre == 1 && !IsaSerialFifoEmpty (&SerialDevice->Transmit)) {
- //
- // Make sure the transmit data will not be missed
- //
- if (SerialDevice->HardwareFlowControl) {
- //
- // For half handshake flow control assert RTS before sending.
- //
- if (FeaturePcdGet(PcdIsaBusSerialUseHalfHandshake)) {
- Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);
- Mcr.Bits.Rts= 0;
- WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);
- }
- //
- // Wait for CTS
- //
- TimeOut = 0;
- Msr.Data = READ_MSR (SerialDevice->IsaIo, SerialDevice->BaseAddress);
- while ((Msr.Bits.Dcd == 1) && ((Msr.Bits.Cts == 0) ^ FeaturePcdGet(PcdIsaBusSerialUseHalfHandshake))) {
- gBS->Stall (TIMEOUT_STALL_INTERVAL);
- TimeOut++;
- if (TimeOut > 5) {
- break;
- }
-
- Msr.Data = READ_MSR (SerialDevice->IsaIo, SerialDevice->BaseAddress);
- }
-
- if ((Msr.Bits.Dcd == 0) || ((Msr.Bits.Cts == 1) ^ FeaturePcdGet(PcdIsaBusSerialUseHalfHandshake))) {
- IsaSerialFifoRemove (&SerialDevice->Transmit, &Data);
- WRITE_THR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Data);
- }
-
- //
- // For half handshake flow control, tell DCE we are done.
- //
- if (FeaturePcdGet(PcdIsaBusSerialUseHalfHandshake)) {
- Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);
- Mcr.Bits.Rts = 1;
- WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);
- }
- } else {
- IsaSerialFifoRemove (&SerialDevice->Transmit, &Data);
- WRITE_THR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Data);
- }
- }
- } while (Lsr.Bits.Thre == 1 && !IsaSerialFifoEmpty (&SerialDevice->Transmit));
- }
-
- return EFI_SUCCESS;
-}
-
-//
-// Interface Functions
-//
-/**
- Reset serial device.
-
- @param This Pointer to EFI_SERIAL_IO_PROTOCOL
-
- @retval EFI_SUCCESS Reset successfully
- @retval EFI_DEVICE_ERROR Failed to reset
-
-**/
-EFI_STATUS
-EFIAPI
-IsaSerialReset (
- IN EFI_SERIAL_IO_PROTOCOL *This
- )
-{
- EFI_STATUS Status;
- SERIAL_DEV *SerialDevice;
- SERIAL_PORT_LCR Lcr;
- SERIAL_PORT_IER Ier;
- SERIAL_PORT_MCR Mcr;
- SERIAL_PORT_FCR Fcr;
- EFI_TPL Tpl;
- UINT32 Control;
-
- SerialDevice = SERIAL_DEV_FROM_THIS (This);
-
- //
- // Report the status code reset the serial
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_P_PC_RESET | EFI_PERIPHERAL_SERIAL_PORT,
- SerialDevice->DevicePath
- );
-
- Tpl = gBS->RaiseTPL (TPL_NOTIFY);
-
- //
- // Make sure DLAB is 0.
- //
- Lcr.Data = READ_LCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);
- Lcr.Bits.DLab = 0;
- WRITE_LCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Lcr.Data);
-
- //
- // Turn off all interrupts
- //
- Ier.Data = READ_IER (SerialDevice->IsaIo, SerialDevice->BaseAddress);
- Ier.Bits.Ravie = 0;
- Ier.Bits.Theie = 0;
- Ier.Bits.Rie = 0;
- Ier.Bits.Mie = 0;
- WRITE_IER (SerialDevice->IsaIo, SerialDevice->BaseAddress, Ier.Data);
-
- //
- // Disable the FIFO.
- //
- Fcr.Bits.TrFIFOE = 0;
- WRITE_FCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Fcr.Data);
-
- //
- // Turn off loopback and disable device interrupt.
- //
- Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);
- Mcr.Bits.Out1 = 0;
- Mcr.Bits.Out2 = 0;
- Mcr.Bits.Lme = 0;
- WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);
-
- //
- // Clear the scratch pad register
- //
- WRITE_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, 0);
-
- //
- // Go set the current attributes
- //
- Status = This->SetAttributes (
- This,
- This->Mode->BaudRate,
- This->Mode->ReceiveFifoDepth,
- This->Mode->Timeout,
- (EFI_PARITY_TYPE) This->Mode->Parity,
- (UINT8) This->Mode->DataBits,
- (EFI_STOP_BITS_TYPE) This->Mode->StopBits
- );
-
- if (EFI_ERROR (Status)) {
- gBS->RestoreTPL (Tpl);
- return EFI_DEVICE_ERROR;
- }
- //
- // Go set the current control bits
- //
- Control = 0;
- if (SerialDevice->HardwareFlowControl) {
- Control |= EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE;
- }
- if (SerialDevice->SoftwareLoopbackEnable) {
- Control |= EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE;
- }
- Status = This->SetControl (
- This,
- Control
- );
-
- if (EFI_ERROR (Status)) {
- gBS->RestoreTPL (Tpl);
- return EFI_DEVICE_ERROR;
- }
- //
- // for 16550A enable FIFO, 16550 disable FIFO
- //
- Fcr.Bits.TrFIFOE = 1;
- Fcr.Bits.ResetRF = 1;
- Fcr.Bits.ResetTF = 1;
- WRITE_FCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Fcr.Data);
-
- //
- // Reset the software FIFO
- //
- SerialDevice->Receive.First = 0;
- SerialDevice->Receive.Last = 0;
- SerialDevice->Receive.Surplus = SERIAL_MAX_BUFFER_SIZE;
- SerialDevice->Transmit.First = 0;
- SerialDevice->Transmit.Last = 0;
- SerialDevice->Transmit.Surplus = SERIAL_MAX_BUFFER_SIZE;
-
- gBS->RestoreTPL (Tpl);
-
- //
- // Device reset is complete
- //
- return EFI_SUCCESS;
-}
-
-/**
- Set new attributes to a serial device.
-
- @param This Pointer to EFI_SERIAL_IO_PROTOCOL
- @param BaudRate The baudrate of the serial device
- @param ReceiveFifoDepth The depth of receive FIFO buffer
- @param Timeout The request timeout for a single char
- @param Parity The type of parity used in serial device
- @param DataBits Number of databits used in serial device
- @param StopBits Number of stopbits used in serial device
-
- @retval EFI_SUCCESS The new attributes were set
- @retval EFI_INVALID_PARAMETERS One or more attributes have an unsupported value
- @retval EFI_UNSUPPORTED Data Bits can not set to 5 or 6
- @retval EFI_DEVICE_ERROR The serial device is not functioning correctly (no return)
-
-**/
-EFI_STATUS
-EFIAPI
-IsaSerialSetAttributes (
- IN EFI_SERIAL_IO_PROTOCOL *This,
- IN UINT64 BaudRate,
- IN UINT32 ReceiveFifoDepth,
- IN UINT32 Timeout,
- IN EFI_PARITY_TYPE Parity,
- IN UINT8 DataBits,
- IN EFI_STOP_BITS_TYPE StopBits
- )
-{
- EFI_STATUS Status;
- SERIAL_DEV *SerialDevice;
- UINT32 Divisor;
- UINT32 Remained;
- SERIAL_PORT_LCR Lcr;
- UART_DEVICE_PATH *Uart;
- EFI_TPL Tpl;
-
- SerialDevice = SERIAL_DEV_FROM_THIS (This);
-
- //
- // Check for default settings and fill in actual values.
- //
- if (BaudRate == 0) {
- BaudRate = PcdGet64 (PcdUartDefaultBaudRate);
- }
-
- if (ReceiveFifoDepth == 0) {
- ReceiveFifoDepth = SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH;
- }
-
- if (Timeout == 0) {
- Timeout = SERIAL_PORT_DEFAULT_TIMEOUT;
- }
-
- if (Parity == DefaultParity) {
- Parity = (EFI_PARITY_TYPE)PcdGet8 (PcdUartDefaultParity);
- }
-
- if (DataBits == 0) {
- DataBits = PcdGet8 (PcdUartDefaultDataBits);
- }
-
- if (StopBits == DefaultStopBits) {
- StopBits = (EFI_STOP_BITS_TYPE) PcdGet8 (PcdUartDefaultStopBits);
- }
- //
- // 5 and 6 data bits can not be verified on a 16550A UART
- // Return EFI_INVALID_PARAMETER if an attempt is made to use these settings.
- //
- if ((DataBits == 5) || (DataBits == 6)) {
- return EFI_INVALID_PARAMETER;
- }
- //
- // Make sure all parameters are valid
- //
- if ((BaudRate > SERIAL_PORT_MAX_BAUD_RATE) || (BaudRate < SERIAL_PORT_MIN_BAUD_RATE)) {
- return EFI_INVALID_PARAMETER;
- }
- //
- // 50,75,110,134,150,300,600,1200,1800,2000,2400,3600,4800,7200,9600,19200,
- // 38400,57600,115200
- //
- if (BaudRate < 75) {
- BaudRate = 50;
- } else if (BaudRate < 110) {
- BaudRate = 75;
- } else if (BaudRate < 134) {
- BaudRate = 110;
- } else if (BaudRate < 150) {
- BaudRate = 134;
- } else if (BaudRate < 300) {
- BaudRate = 150;
- } else if (BaudRate < 600) {
- BaudRate = 300;
- } else if (BaudRate < 1200) {
- BaudRate = 600;
- } else if (BaudRate < 1800) {
- BaudRate = 1200;
- } else if (BaudRate < 2000) {
- BaudRate = 1800;
- } else if (BaudRate < 2400) {
- BaudRate = 2000;
- } else if (BaudRate < 3600) {
- BaudRate = 2400;
- } else if (BaudRate < 4800) {
- BaudRate = 3600;
- } else if (BaudRate < 7200) {
- BaudRate = 4800;
- } else if (BaudRate < 9600) {
- BaudRate = 7200;
- } else if (BaudRate < 19200) {
- BaudRate = 9600;
- } else if (BaudRate < 38400) {
- BaudRate = 19200;
- } else if (BaudRate < 57600) {
- BaudRate = 38400;
- } else if (BaudRate < 115200) {
- BaudRate = 57600;
- } else if (BaudRate <= SERIAL_PORT_MAX_BAUD_RATE) {
- BaudRate = 115200;
- }
-
- if ((ReceiveFifoDepth < 1) || (ReceiveFifoDepth > SERIAL_PORT_MAX_RECEIVE_FIFO_DEPTH)) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((Timeout < SERIAL_PORT_MIN_TIMEOUT) || (Timeout > SERIAL_PORT_MAX_TIMEOUT)) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((Parity < NoParity) || (Parity > SpaceParity)) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((DataBits < 5) || (DataBits > 8)) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((StopBits < OneStopBit) || (StopBits > TwoStopBits)) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // for DataBits = 6,7,8, StopBits can not set OneFiveStopBits
- //
- if ((DataBits >= 6) && (DataBits <= 8) && (StopBits == OneFiveStopBits)) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Compute divisor use to program the baud rate using a round determination
- //
- Divisor = (UINT32) DivU64x32Remainder (
- PcdGet32 (PcdSerialClockRate),
- ((UINT32) BaudRate * 16),
- &Remained
- );
- if (Remained != 0) {
- Divisor += 1;
- }
-
- if ((Divisor == 0) || ((Divisor & 0xffff0000) != 0)) {
- return EFI_INVALID_PARAMETER;
- }
-
- Tpl = gBS->RaiseTPL (TPL_NOTIFY);
-
- //
- // Compute the actual baud rate that the serial port will be programmed for.
- //
- BaudRate = PcdGet32 (PcdSerialClockRate) / Divisor / 16;
-
- //
- // Put serial port on Divisor Latch Mode
- //
- Lcr.Data = READ_LCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);
- Lcr.Bits.DLab = 1;
- WRITE_LCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Lcr.Data);
-
- //
- // Write the divisor to the serial port
- //
- WRITE_DLL (SerialDevice->IsaIo, SerialDevice->BaseAddress, (UINT8) (Divisor & 0xff));
- WRITE_DLM (SerialDevice->IsaIo, SerialDevice->BaseAddress, (UINT8) ((Divisor >> 8) & 0xff));
-
- //
- // Put serial port back in normal mode and set remaining attributes.
- //
- Lcr.Bits.DLab = 0;
-
- switch (Parity) {
- case NoParity:
- Lcr.Bits.ParEn = 0;
- Lcr.Bits.EvenPar = 0;
- Lcr.Bits.SticPar = 0;
- break;
-
- case EvenParity:
- Lcr.Bits.ParEn = 1;
- Lcr.Bits.EvenPar = 1;
- Lcr.Bits.SticPar = 0;
- break;
-
- case OddParity:
- Lcr.Bits.ParEn = 1;
- Lcr.Bits.EvenPar = 0;
- Lcr.Bits.SticPar = 0;
- break;
-
- case SpaceParity:
- Lcr.Bits.ParEn = 1;
- Lcr.Bits.EvenPar = 1;
- Lcr.Bits.SticPar = 1;
- break;
-
- case MarkParity:
- Lcr.Bits.ParEn = 1;
- Lcr.Bits.EvenPar = 0;
- Lcr.Bits.SticPar = 1;
- break;
-
- default:
- break;
- }
-
- switch (StopBits) {
- case OneStopBit:
- Lcr.Bits.StopB = 0;
- break;
-
- case OneFiveStopBits:
- case TwoStopBits:
- Lcr.Bits.StopB = 1;
- break;
-
- default:
- break;
- }
- //
- // DataBits
- //
- Lcr.Bits.SerialDB = (UINT8) ((DataBits - 5) & 0x03);
- WRITE_LCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Lcr.Data);
-
- //
- // Set the Serial I/O mode
- //
- This->Mode->BaudRate = BaudRate;
- This->Mode->ReceiveFifoDepth = ReceiveFifoDepth;
- This->Mode->Timeout = Timeout;
- This->Mode->Parity = Parity;
- This->Mode->DataBits = DataBits;
- This->Mode->StopBits = StopBits;
-
- //
- // See if Device Path Node has actually changed
- //
- if (SerialDevice->UartDevicePath.BaudRate == BaudRate &&
- SerialDevice->UartDevicePath.DataBits == DataBits &&
- SerialDevice->UartDevicePath.Parity == Parity &&
- SerialDevice->UartDevicePath.StopBits == StopBits
- ) {
- gBS->RestoreTPL (Tpl);
- return EFI_SUCCESS;
- }
- //
- // Update the device path
- //
- SerialDevice->UartDevicePath.BaudRate = BaudRate;
- SerialDevice->UartDevicePath.DataBits = DataBits;
- SerialDevice->UartDevicePath.Parity = (UINT8) Parity;
- SerialDevice->UartDevicePath.StopBits = (UINT8) StopBits;
-
- Status = EFI_SUCCESS;
- if (SerialDevice->Handle != NULL) {
- Uart = (UART_DEVICE_PATH *) (
- (UINTN) SerialDevice->DevicePath
- + GetDevicePathSize (SerialDevice->ParentDevicePath)
- - END_DEVICE_PATH_LENGTH
- );
- CopyMem (Uart, &SerialDevice->UartDevicePath, sizeof (UART_DEVICE_PATH));
- Status = gBS->ReinstallProtocolInterface (
- SerialDevice->Handle,
- &gEfiDevicePathProtocolGuid,
- SerialDevice->DevicePath,
- SerialDevice->DevicePath
- );
- }
-
- gBS->RestoreTPL (Tpl);
-
- return Status;
-}
-
-/**
- Set Control Bits.
-
- @param This Pointer to EFI_SERIAL_IO_PROTOCOL
- @param Control Control bits that can be settable
-
- @retval EFI_SUCCESS New Control bits were set successfully
- @retval EFI_UNSUPPORTED The Control bits wanted to set are not supported
-
-**/
-EFI_STATUS
-EFIAPI
-IsaSerialSetControl (
- IN EFI_SERIAL_IO_PROTOCOL *This,
- IN UINT32 Control
- )
-{
- SERIAL_DEV *SerialDevice;
- SERIAL_PORT_MCR Mcr;
- EFI_TPL Tpl;
- UART_FLOW_CONTROL_DEVICE_PATH *FlowControl;
- EFI_STATUS Status;
-
- //
- // The control bits that can be set are :
- // EFI_SERIAL_DATA_TERMINAL_READY: 0x0001 // WO
- // EFI_SERIAL_REQUEST_TO_SEND: 0x0002 // WO
- // EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE: 0x1000 // RW
- // EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE: 0x2000 // RW
- // EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE: 0x4000 // RW
- //
- SerialDevice = SERIAL_DEV_FROM_THIS (This);
-
- //
- // first determine the parameter is invalid
- //
- if ((Control & (~(EFI_SERIAL_REQUEST_TO_SEND | EFI_SERIAL_DATA_TERMINAL_READY |
- EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE | EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE |
- EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE))) != 0) {
- return EFI_UNSUPPORTED;
- }
-
- Tpl = gBS->RaiseTPL (TPL_NOTIFY);
-
- Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);
- Mcr.Bits.DtrC = 0;
- Mcr.Bits.Rts = 0;
- Mcr.Bits.Lme = 0;
- SerialDevice->SoftwareLoopbackEnable = FALSE;
- SerialDevice->HardwareFlowControl = FALSE;
-
- if ((Control & EFI_SERIAL_DATA_TERMINAL_READY) == EFI_SERIAL_DATA_TERMINAL_READY) {
- Mcr.Bits.DtrC = 1;
- }
-
- if ((Control & EFI_SERIAL_REQUEST_TO_SEND) == EFI_SERIAL_REQUEST_TO_SEND) {
- Mcr.Bits.Rts = 1;
- }
-
- if ((Control & EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE) == EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE) {
- Mcr.Bits.Lme = 1;
- }
-
- if ((Control & EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE) == EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE) {
- SerialDevice->HardwareFlowControl = TRUE;
- }
-
- WRITE_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Mcr.Data);
-
- if ((Control & EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE) == EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE) {
- SerialDevice->SoftwareLoopbackEnable = TRUE;
- }
-
- Status = EFI_SUCCESS;
- if (SerialDevice->Handle != NULL) {
- FlowControl = (UART_FLOW_CONTROL_DEVICE_PATH *) (
- (UINTN) SerialDevice->DevicePath
- + GetDevicePathSize (SerialDevice->ParentDevicePath)
- - END_DEVICE_PATH_LENGTH
- + sizeof (UART_DEVICE_PATH)
- );
- if (IsUartFlowControlNode (FlowControl) &&
- ((ReadUnaligned32 (&FlowControl->FlowControlMap) == UART_FLOW_CONTROL_HARDWARE) ^ SerialDevice->HardwareFlowControl)) {
- //
- // Flow Control setting is changed, need to reinstall device path protocol
- //
- WriteUnaligned32 (&FlowControl->FlowControlMap, SerialDevice->HardwareFlowControl ? UART_FLOW_CONTROL_HARDWARE : 0);
- Status = gBS->ReinstallProtocolInterface (
- SerialDevice->Handle,
- &gEfiDevicePathProtocolGuid,
- SerialDevice->DevicePath,
- SerialDevice->DevicePath
- );
- }
- }
-
- gBS->RestoreTPL (Tpl);
-
- return Status;
-}
-
-/**
- Get ControlBits.
-
- @param This Pointer to EFI_SERIAL_IO_PROTOCOL
- @param Control Control signals of the serial device
-
- @retval EFI_SUCCESS Get Control signals successfully
-
-**/
-EFI_STATUS
-EFIAPI
-IsaSerialGetControl (
- IN EFI_SERIAL_IO_PROTOCOL *This,
- OUT UINT32 *Control
- )
-{
- SERIAL_DEV *SerialDevice;
- SERIAL_PORT_MSR Msr;
- SERIAL_PORT_MCR Mcr;
- EFI_TPL Tpl;
-
- Tpl = gBS->RaiseTPL (TPL_NOTIFY);
-
- SerialDevice = SERIAL_DEV_FROM_THIS (This);
-
- *Control = 0;
-
- //
- // Read the Modem Status Register
- //
- Msr.Data = READ_MSR (SerialDevice->IsaIo, SerialDevice->BaseAddress);
-
- if (Msr.Bits.Cts == 1) {
- *Control |= EFI_SERIAL_CLEAR_TO_SEND;
- }
-
- if (Msr.Bits.Dsr == 1) {
- *Control |= EFI_SERIAL_DATA_SET_READY;
- }
-
- if (Msr.Bits.Ri == 1) {
- *Control |= EFI_SERIAL_RING_INDICATE;
- }
-
- if (Msr.Bits.Dcd == 1) {
- *Control |= EFI_SERIAL_CARRIER_DETECT;
- }
- //
- // Read the Modem Control Register
- //
- Mcr.Data = READ_MCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);
-
- if (Mcr.Bits.DtrC == 1) {
- *Control |= EFI_SERIAL_DATA_TERMINAL_READY;
- }
-
- if (Mcr.Bits.Rts == 1) {
- *Control |= EFI_SERIAL_REQUEST_TO_SEND;
- }
-
- if (Mcr.Bits.Lme == 1) {
- *Control |= EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE;
- }
-
- if (SerialDevice->HardwareFlowControl) {
- *Control |= EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE;
- }
- //
- // See if the Transmit FIFO is empty
- //
- IsaSerialReceiveTransmit (SerialDevice);
-
- if (IsaSerialFifoEmpty (&SerialDevice->Transmit)) {
- *Control |= EFI_SERIAL_OUTPUT_BUFFER_EMPTY;
- }
- //
- // See if the Receive FIFO is empty.
- //
- IsaSerialReceiveTransmit (SerialDevice);
-
- if (IsaSerialFifoEmpty (&SerialDevice->Receive)) {
- *Control |= EFI_SERIAL_INPUT_BUFFER_EMPTY;
- }
-
- if (SerialDevice->SoftwareLoopbackEnable) {
- *Control |= EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE;
- }
-
- gBS->RestoreTPL (Tpl);
-
- return EFI_SUCCESS;
-}
-
-/**
- Write the specified number of bytes to serial device.
-
- @param This Pointer to EFI_SERIAL_IO_PROTOCOL
- @param BufferSize On input the size of Buffer, on output the amount of
- data actually written
- @param Buffer The buffer of data to write
-
- @retval EFI_SUCCESS The data were written successfully
- @retval EFI_DEVICE_ERROR The device reported an error
- @retval EFI_TIMEOUT The write operation was stopped due to timeout
-
-**/
-EFI_STATUS
-EFIAPI
-IsaSerialWrite (
- IN EFI_SERIAL_IO_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- IN VOID *Buffer
- )
-{
- SERIAL_DEV *SerialDevice;
- UINT8 *CharBuffer;
- UINT32 Index;
- UINTN Elapsed;
- UINTN ActualWrite;
- EFI_TPL Tpl;
- UINTN Timeout;
- UINTN BitsPerCharacter;
-
- SerialDevice = SERIAL_DEV_FROM_THIS (This);
- Elapsed = 0;
- ActualWrite = 0;
-
- if (*BufferSize == 0) {
- return EFI_SUCCESS;
- }
-
- if (Buffer == NULL) {
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_ERROR_CODE,
- EFI_P_EC_OUTPUT_ERROR | EFI_PERIPHERAL_SERIAL_PORT,
- SerialDevice->DevicePath
- );
-
- return EFI_DEVICE_ERROR;
- }
-
- Tpl = gBS->RaiseTPL (TPL_NOTIFY);
-
- CharBuffer = (UINT8 *) Buffer;
-
- //
- // Compute the number of bits in a single character. This is a start bit,
- // followed by the number of data bits, followed by the number of stop bits.
- // The number of stop bits is specified by an enumeration that includes
- // support for 1.5 stop bits. Treat 1.5 stop bits as 2 stop bits.
- //
- BitsPerCharacter =
- 1 +
- This->Mode->DataBits +
- ((This->Mode->StopBits == TwoStopBits) ? 2 : This->Mode->StopBits);
-
- //
- // Compute the timeout in microseconds to wait for a single byte to be
- // transmitted. The Mode structure contans a Timeout field that is the
- // maximum time to transmit or receive a character. However, many UARTs
- // have a FIFO for transmits, so the time required to add one new character
- // to the transmit FIFO may be the time required to flush a full FIFO. If
- // the Timeout in the Mode structure is smaller than the time required to
- // flush a full FIFO at the current baud rate, then use a timeout value that
- // is required to flush a full transmit FIFO.
- //
- Timeout = MAX (
- This->Mode->Timeout,
- (UINTN)DivU64x64Remainder (
- BitsPerCharacter * (SERIAL_PORT_MAX_RECEIVE_FIFO_DEPTH + 1) * 1000000,
- This->Mode->BaudRate,
- NULL
- )
- );
-
- for (Index = 0; Index < *BufferSize; Index++) {
- IsaSerialFifoAdd (&SerialDevice->Transmit, CharBuffer[Index]);
-
- while (IsaSerialReceiveTransmit (SerialDevice) != EFI_SUCCESS || !IsaSerialFifoEmpty (&SerialDevice->Transmit)) {
- //
- // Unsuccessful write so check if timeout has expired, if not,
- // stall for a bit, increment time elapsed, and try again
- //
- if (Elapsed >= Timeout) {
- *BufferSize = ActualWrite;
- gBS->RestoreTPL (Tpl);
- return EFI_TIMEOUT;
- }
-
- gBS->Stall (TIMEOUT_STALL_INTERVAL);
-
- Elapsed += TIMEOUT_STALL_INTERVAL;
- }
-
- ActualWrite++;
- //
- // Successful write so reset timeout
- //
- Elapsed = 0;
- }
-
- gBS->RestoreTPL (Tpl);
-
- return EFI_SUCCESS;
-}
-
-/**
- Read the specified number of bytes from serial device.
-
- @param This Pointer to EFI_SERIAL_IO_PROTOCOL
- @param BufferSize On input the size of Buffer, on output the amount of
- data returned in buffer
- @param Buffer The buffer to return the data into
-
- @retval EFI_SUCCESS The data were read successfully
- @retval EFI_DEVICE_ERROR The device reported an error
- @retval EFI_TIMEOUT The read operation was stopped due to timeout
-
-**/
-EFI_STATUS
-EFIAPI
-IsaSerialRead (
- IN EFI_SERIAL_IO_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
- )
-{
- SERIAL_DEV *SerialDevice;
- UINT32 Index;
- UINT8 *CharBuffer;
- UINTN Elapsed;
- EFI_STATUS Status;
- EFI_TPL Tpl;
-
- SerialDevice = SERIAL_DEV_FROM_THIS (This);
- Elapsed = 0;
-
- if (*BufferSize == 0) {
- return EFI_SUCCESS;
- }
-
- if (Buffer == NULL) {
- return EFI_DEVICE_ERROR;
- }
-
- Tpl = gBS->RaiseTPL (TPL_NOTIFY);
-
- Status = IsaSerialReceiveTransmit (SerialDevice);
-
- if (EFI_ERROR (Status)) {
- *BufferSize = 0;
-
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_ERROR_CODE,
- EFI_P_EC_INPUT_ERROR | EFI_PERIPHERAL_SERIAL_PORT,
- SerialDevice->DevicePath
- );
-
- gBS->RestoreTPL (Tpl);
-
- return EFI_DEVICE_ERROR;
- }
-
- CharBuffer = (UINT8 *) Buffer;
- for (Index = 0; Index < *BufferSize; Index++) {
- while (IsaSerialFifoRemove (&SerialDevice->Receive, &(CharBuffer[Index])) != EFI_SUCCESS) {
- //
- // Unsuccessful read so check if timeout has expired, if not,
- // stall for a bit, increment time elapsed, and try again
- // Need this time out to get conspliter to work.
- //
- if (Elapsed >= This->Mode->Timeout) {
- *BufferSize = Index;
- gBS->RestoreTPL (Tpl);
- return EFI_TIMEOUT;
- }
-
- gBS->Stall (TIMEOUT_STALL_INTERVAL);
- Elapsed += TIMEOUT_STALL_INTERVAL;
-
- Status = IsaSerialReceiveTransmit (SerialDevice);
- if (Status == EFI_DEVICE_ERROR) {
- *BufferSize = Index;
- gBS->RestoreTPL (Tpl);
- return EFI_DEVICE_ERROR;
- }
- }
- //
- // Successful read so reset timeout
- //
- Elapsed = 0;
- }
-
- IsaSerialReceiveTransmit (SerialDevice);
-
- gBS->RestoreTPL (Tpl);
-
- return EFI_SUCCESS;
-}
-
-/**
- Use scratchpad register to test if this serial port is present.
-
- @param SerialDevice Pointer to serial device structure
-
- @return if this serial port is present
-**/
-BOOLEAN
-IsaSerialPortPresent (
- IN SERIAL_DEV *SerialDevice
- )
-
-{
- UINT8 Temp;
- BOOLEAN Status;
-
- Status = TRUE;
-
- //
- // Save SCR reg
- //
- Temp = READ_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress);
- WRITE_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, 0xAA);
-
- if (READ_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress) != 0xAA) {
- Status = FALSE;
- }
-
- WRITE_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, 0x55);
-
- if (READ_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress) != 0x55) {
- Status = FALSE;
- }
- //
- // Restore SCR
- //
- WRITE_SCR (SerialDevice->IsaIo, SerialDevice->BaseAddress, Temp);
- return Status;
-}
-
-/**
- Use IsaIo protocol to read serial port.
-
- @param IsaIo Pointer to EFI_ISA_IO_PROTOCOL instance
- @param BaseAddress Serial port register group base address
- @param Offset Offset in register group
-
- @return Data read from serial port
-
-**/
-UINT8
-IsaSerialReadPort (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINT16 BaseAddress,
- IN UINT32 Offset
- )
-{
- UINT8 Data;
-
- //
- // Use IsaIo to access IO
- //
- IsaIo->Io.Read (
- IsaIo,
- EfiIsaIoWidthUint8,
- BaseAddress + Offset,
- 1,
- &Data
- );
- return Data;
-}
-
-/**
- Use IsaIo protocol to write serial port.
-
- @param IsaIo Pointer to EFI_ISA_IO_PROTOCOL instance
- @param BaseAddress Serial port register group base address
- @param Offset Offset in register group
- @param Data data which is to be written to some serial port register
-
-**/
-VOID
-IsaSerialWritePort (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINT16 BaseAddress,
- IN UINT32 Offset,
- IN UINT8 Data
- )
-{
- //
- // Use IsaIo to access IO
- //
- IsaIo->Io.Write (
- IsaIo,
- EfiIsaIoWidthUint8,
- BaseAddress + Offset,
- 1,
- &Data
- );
-}
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h b/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h deleted file mode 100644 index 9d50ca9e27..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h +++ /dev/null @@ -1,842 +0,0 @@ -/** @file
- Include for Serial Driver
-
-Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
-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.
-
-**/
-
-#ifndef _SERIAL_H_
-#define _SERIAL_H_
-
-
-#include <FrameworkDxe.h>
-
-#include <Protocol/IsaIo.h>
-#include <Protocol/SerialIo.h>
-#include <Protocol/DevicePath.h>
-
-#include <Library/DebugLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/UefiLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/ReportStatusCodeLib.h>
-#include <Library/PcdLib.h>
-
-//
-// Driver Binding Externs
-//
-extern EFI_DRIVER_BINDING_PROTOCOL gSerialControllerDriver;
-extern EFI_COMPONENT_NAME_PROTOCOL gIsaSerialComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gIsaSerialComponentName2;
-
-//
-// Internal Data Structures
-//
-#define SERIAL_DEV_SIGNATURE SIGNATURE_32 ('s', 'e', 'r', 'd')
-#define SERIAL_MAX_BUFFER_SIZE 16
-#define TIMEOUT_STALL_INTERVAL 10
-
-//
-// Name: SERIAL_DEV_FIFO
-// Purpose: To define Receive FIFO and Transmit FIFO
-// Context: Used by serial data transmit and receive
-// Fields:
-// First UINT32: The index of the first data in array Data[]
-// Last UINT32: The index, which you can put a new data into array Data[]
-// Surplus UINT32: Identify how many data you can put into array Data[]
-// Data[] UINT8 : An array, which used to store data
-//
-typedef struct {
- UINT32 First;
- UINT32 Last;
- UINT32 Surplus;
- UINT8 Data[SERIAL_MAX_BUFFER_SIZE];
-} SERIAL_DEV_FIFO;
-
-typedef enum {
- Uart8250 = 0,
- Uart16450 = 1,
- Uart16550 = 2,
- Uart16550A= 3
-} EFI_UART_TYPE;
-
-//
-// Name: SERIAL_DEV
-// Purpose: To provide device specific information
-// Context:
-// Fields:
-// Signature UINTN: The identity of the serial device
-// SerialIo SERIAL_IO_PROTOCOL: Serial I/O protocol interface
-// SerialMode SERIAL_IO_MODE:
-// DevicePath EFI_DEVICE_PATH_PROTOCOL *: Device path of the serial device
-// Handle EFI_HANDLE: The handle instance attached to serial device
-// BaseAddress UINT16: The base address of specific serial device
-// Receive SERIAL_DEV_FIFO: The FIFO used to store data,
-// which is received by UART
-// Transmit SERIAL_DEV_FIFO: The FIFO used to store data,
-// which you want to transmit by UART
-// SoftwareLoopbackEnable BOOLEAN:
-// Type EFI_UART_TYPE: Specify the UART type of certain serial device
-//
-typedef struct {
- UINTN Signature;
-
- EFI_HANDLE Handle;
- EFI_SERIAL_IO_PROTOCOL SerialIo;
- EFI_SERIAL_IO_MODE SerialMode;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
-
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
- UART_DEVICE_PATH UartDevicePath;
- EFI_ISA_IO_PROTOCOL *IsaIo;
-
- UINT16 BaseAddress;
- SERIAL_DEV_FIFO Receive;
- SERIAL_DEV_FIFO Transmit;
- BOOLEAN SoftwareLoopbackEnable;
- BOOLEAN HardwareFlowControl;
- EFI_UART_TYPE Type;
- EFI_UNICODE_STRING_TABLE *ControllerNameTable;
-} SERIAL_DEV;
-
-#define SERIAL_DEV_FROM_THIS(a) CR (a, SERIAL_DEV, SerialIo, SERIAL_DEV_SIGNATURE)
-
-//
-// Serial Driver Defaults
-//
-#define SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH 1
-#define SERIAL_PORT_DEFAULT_TIMEOUT 1000000
-#define SERIAL_PORT_SUPPORT_CONTROL_MASK (EFI_SERIAL_CLEAR_TO_SEND | \
- EFI_SERIAL_DATA_SET_READY | \
- EFI_SERIAL_RING_INDICATE | \
- EFI_SERIAL_CARRIER_DETECT | \
- EFI_SERIAL_REQUEST_TO_SEND | \
- EFI_SERIAL_DATA_TERMINAL_READY | \
- EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE | \
- EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE | \
- EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE | \
- EFI_SERIAL_OUTPUT_BUFFER_EMPTY | \
- EFI_SERIAL_INPUT_BUFFER_EMPTY)
-
-//
-// 115200 baud with rounding errors
-//
-#define SERIAL_PORT_MAX_BAUD_RATE 115400
-#define SERIAL_PORT_MIN_BAUD_RATE 50
-
-#define SERIAL_PORT_MAX_RECEIVE_FIFO_DEPTH 16
-#define SERIAL_PORT_MIN_TIMEOUT 1 // 1 uS
-#define SERIAL_PORT_MAX_TIMEOUT 100000000 // 100 seconds
-//
-// UART Registers
-//
-#define SERIAL_REGISTER_THR 0 // WO Transmit Holding Register
-#define SERIAL_REGISTER_RBR 0 // RO Receive Buffer Register
-#define SERIAL_REGISTER_DLL 0 // R/W Divisor Latch LSB
-#define SERIAL_REGISTER_DLM 1 // R/W Divisor Latch MSB
-#define SERIAL_REGISTER_IER 1 // R/W Interrupt Enable Register
-#define SERIAL_REGISTER_IIR 2 // RO Interrupt Identification Register
-#define SERIAL_REGISTER_FCR 2 // WO FIFO Cotrol Register
-#define SERIAL_REGISTER_LCR 3 // R/W Line Control Register
-#define SERIAL_REGISTER_MCR 4 // R/W Modem Control Register
-#define SERIAL_REGISTER_LSR 5 // R/W Line Status Register
-#define SERIAL_REGISTER_MSR 6 // R/W Modem Status Register
-#define SERIAL_REGISTER_SCR 7 // R/W Scratch Pad Register
-#pragma pack(1)
-//
-// Name: SERIAL_PORT_IER_BITS
-// Purpose: Define each bit in Interrupt Enable Register
-// Context:
-// Fields:
-// Ravie Bit0: Receiver Data Available Interrupt Enable
-// Theie Bit1: Transmistter Holding Register Empty Interrupt Enable
-// Rie Bit2: Receiver Interrupt Enable
-// Mie Bit3: Modem Interrupt Enable
-// Reserved Bit4-Bit7: Reserved
-//
-typedef struct {
- UINT8 Ravie : 1;
- UINT8 Theie : 1;
- UINT8 Rie : 1;
- UINT8 Mie : 1;
- UINT8 Reserved : 4;
-} SERIAL_PORT_IER_BITS;
-
-//
-// Name: SERIAL_PORT_IER
-// Purpose:
-// Context:
-// Fields:
-// Bits SERIAL_PORT_IER_BITS: Bits of the IER
-// Data UINT8: the value of the IER
-//
-typedef union {
- SERIAL_PORT_IER_BITS Bits;
- UINT8 Data;
-} SERIAL_PORT_IER;
-
-//
-// Name: SERIAL_PORT_FCR_BITS
-// Purpose: Define each bit in FIFO Control Register
-// Context:
-// Fields:
-// TrFIFOE Bit0: Transmit and Receive FIFO Enable
-// ResetRF Bit1: Reset Reciever FIFO
-// ResetTF Bit2: Reset Transmistter FIFO
-// Dms Bit3: DMA Mode Select
-// Reserved Bit4-Bit5: Reserved
-// Rtb Bit6-Bit7: Receive Trigger Bits
-//
-typedef struct {
- UINT8 TrFIFOE : 1;
- UINT8 ResetRF : 1;
- UINT8 ResetTF : 1;
- UINT8 Dms : 1;
- UINT8 Reserved : 2;
- UINT8 Rtb : 2;
-} SERIAL_PORT_FCR_BITS;
-
-//
-// Name: SERIAL_PORT_FCR
-// Purpose:
-// Context:
-// Fields:
-// Bits SERIAL_PORT_FCR_BITS: Bits of the FCR
-// Data UINT8: the value of the FCR
-//
-typedef union {
- SERIAL_PORT_FCR_BITS Bits;
- UINT8 Data;
-} SERIAL_PORT_FCR;
-
-//
-// Name: SERIAL_PORT_LCR_BITS
-// Purpose: Define each bit in Line Control Register
-// Context:
-// Fields:
-// SerialDB Bit0-Bit1: Number of Serial Data Bits
-// StopB Bit2: Number of Stop Bits
-// ParEn Bit3: Parity Enable
-// EvenPar Bit4: Even Parity Select
-// SticPar Bit5: Sticky Parity
-// BrCon Bit6: Break Control
-// DLab Bit7: Divisor Latch Access Bit
-//
-typedef struct {
- UINT8 SerialDB : 2;
- UINT8 StopB : 1;
- UINT8 ParEn : 1;
- UINT8 EvenPar : 1;
- UINT8 SticPar : 1;
- UINT8 BrCon : 1;
- UINT8 DLab : 1;
-} SERIAL_PORT_LCR_BITS;
-
-//
-// Name: SERIAL_PORT_LCR
-// Purpose:
-// Context:
-// Fields:
-// Bits SERIAL_PORT_LCR_BITS: Bits of the LCR
-// Data UINT8: the value of the LCR
-//
-typedef union {
- SERIAL_PORT_LCR_BITS Bits;
- UINT8 Data;
-} SERIAL_PORT_LCR;
-
-//
-// Name: SERIAL_PORT_MCR_BITS
-// Purpose: Define each bit in Modem Control Register
-// Context:
-// Fields:
-// DtrC Bit0: Data Terminal Ready Control
-// Rts Bit1: Request To Send Control
-// Out1 Bit2: Output1
-// Out2 Bit3: Output2, used to disable interrupt
-// Lme; Bit4: Loopback Mode Enable
-// Reserved Bit5-Bit7: Reserved
-//
-typedef struct {
- UINT8 DtrC : 1;
- UINT8 Rts : 1;
- UINT8 Out1 : 1;
- UINT8 Out2 : 1;
- UINT8 Lme : 1;
- UINT8 Reserved : 3;
-} SERIAL_PORT_MCR_BITS;
-
-//
-// Name: SERIAL_PORT_MCR
-// Purpose:
-// Context:
-// Fields:
-// Bits SERIAL_PORT_MCR_BITS: Bits of the MCR
-// Data UINT8: the value of the MCR
-//
-typedef union {
- SERIAL_PORT_MCR_BITS Bits;
- UINT8 Data;
-} SERIAL_PORT_MCR;
-
-//
-// Name: SERIAL_PORT_LSR_BITS
-// Purpose: Define each bit in Line Status Register
-// Context:
-// Fields:
-// Dr Bit0: Receiver Data Ready Status
-// Oe Bit1: Overrun Error Status
-// Pe Bit2: Parity Error Status
-// Fe Bit3: Framing Error Status
-// Bi Bit4: Break Interrupt Status
-// Thre Bit5: Transmistter Holding Register Status
-// Temt Bit6: Transmitter Empty Status
-// FIFOe Bit7: FIFO Error Status
-//
-typedef struct {
- UINT8 Dr : 1;
- UINT8 Oe : 1;
- UINT8 Pe : 1;
- UINT8 Fe : 1;
- UINT8 Bi : 1;
- UINT8 Thre : 1;
- UINT8 Temt : 1;
- UINT8 FIFOe : 1;
-} SERIAL_PORT_LSR_BITS;
-
-//
-// Name: SERIAL_PORT_LSR
-// Purpose:
-// Context:
-// Fields:
-// Bits SERIAL_PORT_LSR_BITS: Bits of the LSR
-// Data UINT8: the value of the LSR
-//
-typedef union {
- SERIAL_PORT_LSR_BITS Bits;
- UINT8 Data;
-} SERIAL_PORT_LSR;
-
-//
-// Name: SERIAL_PORT_MSR_BITS
-// Purpose: Define each bit in Modem Status Register
-// Context:
-// Fields:
-// DeltaCTS Bit0: Delta Clear To Send Status
-// DeltaDSR Bit1: Delta Data Set Ready Status
-// TrailingEdgeRI Bit2: Trailing Edge of Ring Indicator Status
-// DeltaDCD Bit3: Delta Data Carrier Detect Status
-// Cts Bit4: Clear To Send Status
-// Dsr Bit5: Data Set Ready Status
-// Ri Bit6: Ring Indicator Status
-// Dcd Bit7: Data Carrier Detect Status
-//
-typedef struct {
- UINT8 DeltaCTS : 1;
- UINT8 DeltaDSR : 1;
- UINT8 TrailingEdgeRI : 1;
- UINT8 DeltaDCD : 1;
- UINT8 Cts : 1;
- UINT8 Dsr : 1;
- UINT8 Ri : 1;
- UINT8 Dcd : 1;
-} SERIAL_PORT_MSR_BITS;
-
-//
-// Name: SERIAL_PORT_MSR
-// Purpose:
-// Context:
-// Fields:
-// Bits SERIAL_PORT_MSR_BITS: Bits of the MSR
-// Data UINT8: the value of the MSR
-//
-typedef union {
- SERIAL_PORT_MSR_BITS Bits;
- UINT8 Data;
-} SERIAL_PORT_MSR;
-
-#pragma pack()
-//
-// Define serial register I/O macros
-//
-#define READ_RBR(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_RBR)
-#define READ_DLL(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_DLL)
-#define READ_DLM(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_DLM)
-#define READ_IER(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_IER)
-#define READ_IIR(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_IIR)
-#define READ_LCR(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_LCR)
-#define READ_MCR(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_MCR)
-#define READ_LSR(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_LSR)
-#define READ_MSR(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_MSR)
-#define READ_SCR(IO, B) IsaSerialReadPort (IO, B, SERIAL_REGISTER_SCR)
-
-#define WRITE_THR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_THR, D)
-#define WRITE_DLL(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_DLL, D)
-#define WRITE_DLM(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_DLM, D)
-#define WRITE_IER(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_IER, D)
-#define WRITE_FCR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_FCR, D)
-#define WRITE_LCR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_LCR, D)
-#define WRITE_MCR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_MCR, D)
-#define WRITE_LSR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_LSR, D)
-#define WRITE_MSR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_MSR, D)
-#define WRITE_SCR(IO, B, D) IsaSerialWritePort (IO, B, SERIAL_REGISTER_SCR, D)
-
-//
-// Prototypes
-// Driver model protocol interface
-//
-/**
- Check to see if this driver supports the given controller
-
- @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param Controller The handle of the controller to test.
- @param RemainingDevicePath A pointer to the remaining portion of a device path.
-
- @return EFI_SUCCESS This driver can support the given controller
-
-**/
-EFI_STATUS
-EFIAPI
-SerialControllerDriverSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-/**
- Start to management the controller passed in
-
- @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param Controller The handle of the controller to test.
- @param RemainingDevicePath A pointer to the remaining portion of a device path.
-
- @return EFI_SUCCESS Driver is started successfully
-**/
-EFI_STATUS
-EFIAPI
-SerialControllerDriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-/**
- Disconnect this driver with the controller, uninstall related protocol instance
-
- @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param Controller The handle of the controller to test.
- @param NumberOfChildren Number of child device.
- @param ChildHandleBuffer A pointer to the remaining portion of a device path.
-
- @retval EFI_SUCCESS Operation successfully
- @retval EFI_DEVICE_ERROR Cannot stop the driver successfully
-
-**/
-EFI_STATUS
-EFIAPI
-SerialControllerDriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- );
-
-//
-// Serial I/O Protocol Interface
-//
-/**
- Reset serial device.
-
- @param This Pointer to EFI_SERIAL_IO_PROTOCOL
-
- @retval EFI_SUCCESS Reset successfully
- @retval EFI_DEVICE_ERROR Failed to reset
-
-**/
-EFI_STATUS
-EFIAPI
-IsaSerialReset (
- IN EFI_SERIAL_IO_PROTOCOL *This
- );
-
-/**
- Set new attributes to a serial device.
-
- @param This Pointer to EFI_SERIAL_IO_PROTOCOL
- @param BaudRate The baudrate of the serial device
- @param ReceiveFifoDepth The depth of receive FIFO buffer
- @param Timeout The request timeout for a single char
- @param Parity The type of parity used in serial device
- @param DataBits Number of databits used in serial device
- @param StopBits Number of stopbits used in serial device
-
- @retval EFI_SUCCESS The new attributes were set
- @retval EFI_INVALID_PARAMETERS One or more attributes have an unsupported value
- @retval EFI_UNSUPPORTED Data Bits can not set to 5 or 6
- @retval EFI_DEVICE_ERROR The serial device is not functioning correctly (no return)
-
-**/
-EFI_STATUS
-EFIAPI
-IsaSerialSetAttributes (
- IN EFI_SERIAL_IO_PROTOCOL *This,
- IN UINT64 BaudRate,
- IN UINT32 ReceiveFifoDepth,
- IN UINT32 Timeout,
- IN EFI_PARITY_TYPE Parity,
- IN UINT8 DataBits,
- IN EFI_STOP_BITS_TYPE StopBits
- );
-
-/**
- Set Control Bits.
-
- @param This Pointer to EFI_SERIAL_IO_PROTOCOL
- @param Control Control bits that can be settable
-
- @retval EFI_SUCCESS New Control bits were set successfully
- @retval EFI_UNSUPPORTED The Control bits wanted to set are not supported
-
-**/
-EFI_STATUS
-EFIAPI
-IsaSerialSetControl (
- IN EFI_SERIAL_IO_PROTOCOL *This,
- IN UINT32 Control
- );
-
-/**
- Get ControlBits.
-
- @param This Pointer to EFI_SERIAL_IO_PROTOCOL
- @param Control Control signals of the serial device
-
- @retval EFI_SUCCESS Get Control signals successfully
-
-**/
-EFI_STATUS
-EFIAPI
-IsaSerialGetControl (
- IN EFI_SERIAL_IO_PROTOCOL *This,
- OUT UINT32 *Control
- );
-
-/**
- Write the specified number of bytes to serial device.
-
- @param This Pointer to EFI_SERIAL_IO_PROTOCOL
- @param BufferSize On input the size of Buffer, on output the amount of
- data actually written
- @param Buffer The buffer of data to write
-
- @retval EFI_SUCCESS The data were written successfully
- @retval EFI_DEVICE_ERROR The device reported an error
- @retval EFI_TIMEOUT The write operation was stopped due to timeout
-
-**/
-EFI_STATUS
-EFIAPI
-IsaSerialWrite (
- IN EFI_SERIAL_IO_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- IN VOID *Buffer
- );
-
-/**
- Read the specified number of bytes from serial device.
-
- @param This Pointer to EFI_SERIAL_IO_PROTOCOL
- @param BufferSize On input the size of Buffer, on output the amount of
- data returned in buffer
- @param Buffer The buffer to return the data into
-
- @retval EFI_SUCCESS The data were read successfully
- @retval EFI_DEVICE_ERROR The device reported an error
- @retval EFI_TIMEOUT The read operation was stopped due to timeout
-
-**/
-EFI_STATUS
-EFIAPI
-IsaSerialRead (
- IN EFI_SERIAL_IO_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
- );
-
-//
-// Internal Functions
-//
-/**
- Use scratchpad register to test if this serial port is present.
-
- @param SerialDevice Pointer to serial device structure
-
- @return if this serial port is present
-**/
-BOOLEAN
-IsaSerialPortPresent (
- IN SERIAL_DEV *SerialDevice
- );
-
-/**
- Detect whether specific FIFO is full or not.
-
- @param Fifo A pointer to the Data Structure SERIAL_DEV_FIFO
-
- @return whether specific FIFO is full or not
-
-**/
-BOOLEAN
-IsaSerialFifoFull (
- IN SERIAL_DEV_FIFO *Fifo
- );
-
-/**
- Detect whether specific FIFO is empty or not.
-
- @param Fifo A pointer to the Data Structure SERIAL_DEV_FIFO
-
- @return whether specific FIFO is empty or not
-
-**/
-BOOLEAN
-IsaSerialFifoEmpty (
- IN SERIAL_DEV_FIFO *Fifo
- );
-
-/**
- Add data to specific FIFO.
-
- @param Fifo A pointer to the Data Structure SERIAL_DEV_FIFO
- @param Data the data added to FIFO
-
- @retval EFI_SUCCESS Add data to specific FIFO successfully
- @retval EFI_OUT_OF_RESOURCE Failed to add data because FIFO is already full
-
-**/
-EFI_STATUS
-IsaSerialFifoAdd (
- IN SERIAL_DEV_FIFO *Fifo,
- IN UINT8 Data
- );
-
-/**
- Remove data from specific FIFO.
-
- @param Fifo A pointer to the Data Structure SERIAL_DEV_FIFO
- @param Data the data removed from FIFO
-
- @retval EFI_SUCCESS Remove data from specific FIFO successfully
- @retval EFI_OUT_OF_RESOURCE Failed to remove data because FIFO is empty
-
-**/
-EFI_STATUS
-IsaSerialFifoRemove (
- IN SERIAL_DEV_FIFO *Fifo,
- OUT UINT8 *Data
- );
-
-/**
- Reads and writes all avaliable data.
-
- @param SerialDevice The device to flush
-
- @retval EFI_SUCCESS Data was read/written successfully.
- @retval EFI_OUT_OF_RESOURCE Failed because software receive FIFO is full. Note, when
- this happens, pending writes are not done.
-
-**/
-EFI_STATUS
-IsaSerialReceiveTransmit (
- IN SERIAL_DEV *SerialDevice
- );
-
-/**
- Use IsaIo protocol to read serial port.
-
- @param IsaIo Pointer to EFI_ISA_IO_PROTOCOL instance
- @param BaseAddress Serial port register group base address
- @param Offset Offset in register group
-
- @return Data read from serial port
-
-**/
-UINT8
-IsaSerialReadPort (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINT16 BaseAddress,
- IN UINT32 Offset
- );
-
-/**
- Use IsaIo protocol to write serial port.
-
- @param IsaIo Pointer to EFI_ISA_IO_PROTOCOL instance
- @param BaseAddress Serial port register group base address
- @param Offset Offset in register group
- @param Data data which is to be written to some serial port register
-
-**/
-VOID
-IsaSerialWritePort (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINT16 BaseAddress,
- IN UINT32 Offset,
- IN UINT8 Data
- );
-
-
-//
-// EFI Component Name Functions
-//
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
-
- @param DriverName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-IsaSerialComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- );
-
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param ControllerHandle[in] The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
-
- @param ChildHandle[in] The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
-
- @param ControllerName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
-
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
-
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-IsaSerialComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- );
-
-/**
- Add the component name for the serial io device
-
- @param SerialDevice A pointer to the SERIAL_DEV instance.
-
- @param IsaIo A pointer to the EFI_ISA_IO_PROTOCOL instance.
-
-**/
-VOID
-AddName (
- IN SERIAL_DEV *SerialDevice,
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- );
-
-#endif
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/ComponentName.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/ComponentName.c deleted file mode 100644 index e6c739e2ba..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/ComponentName.c +++ /dev/null @@ -1,372 +0,0 @@ -/** @file
- Routines related Component Name protocol.
-
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
-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 "Ps2Keyboard.h"
-
-//
-// EFI Component Name Functions
-//
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
-
- @param DriverName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-Ps2KeyboardComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- );
-
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param ControllerHandle[in] The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
-
- @param ChildHandle[in] The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
-
- @param ControllerName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
-
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
-
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-Ps2KeyboardComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- );
-
-
-//
-// EFI Component Name Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gPs2KeyboardComponentName = {
- Ps2KeyboardComponentNameGetDriverName,
- Ps2KeyboardComponentNameGetControllerName,
- "eng"
-};
-
-//
-// EFI Component Name 2 Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPs2KeyboardComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) Ps2KeyboardComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) Ps2KeyboardComponentNameGetControllerName,
- "en"
-};
-
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPs2KeyboardDriverNameTable[] = {
- {
- "eng;en",
- L"PS/2 Keyboard Driver"
- },
- {
- NULL,
- NULL
- }
-};
-
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
-
- @param DriverName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-Ps2KeyboardComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- )
-{
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mPs2KeyboardDriverNameTable,
- DriverName,
- (BOOLEAN)(This == &gPs2KeyboardComponentName)
- );
-}
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param ControllerHandle[in] The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
-
- @param ChildHandle[in] The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
-
- @param ControllerName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
-
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
-
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-Ps2KeyboardComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- )
-{
- EFI_STATUS Status;
- EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;
- KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
- EFI_ISA_IO_PROTOCOL *IsaIoProtocol;
-
- //
- // This is a device driver, so ChildHandle must be NULL.
- //
- if (ChildHandle != NULL) {
- return EFI_UNSUPPORTED;
- }
- //
- // Check Controller's handle
- //
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiIsaIoProtocolGuid,
- (VOID **) &IsaIoProtocol,
- gKeyboardControllerDriver.DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
-
- if (!EFI_ERROR (Status)) {
- gBS->CloseProtocol (
- ControllerHandle,
- &gEfiIsaIoProtocolGuid,
- gKeyboardControllerDriver.DriverBindingHandle,
- ControllerHandle
- );
-
- return EFI_UNSUPPORTED;
- }
-
- if (Status != EFI_ALREADY_STARTED) {
- return EFI_UNSUPPORTED;
- }
- //
- // Get the device context
- //
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiSimpleTextInProtocolGuid,
- (VOID **) &ConIn,
- gKeyboardControllerDriver.DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (ConIn);
-
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- ConsoleIn->ControllerNameTable,
- ControllerName,
- (BOOLEAN)(This == &gPs2KeyboardComponentName)
- );
-}
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c deleted file mode 100644 index b528b89ac4..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c +++ /dev/null @@ -1,1916 +0,0 @@ -/** @file
- Routines that access 8042 keyboard controller
-
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
-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 "Ps2Keyboard.h"
-
-struct {
- UINT8 ScanCode; ///< follows value defined in Scan Code Set1
- UINT16 EfiScanCode;
- CHAR16 UnicodeChar;
- CHAR16 ShiftUnicodeChar;
-}
-ConvertKeyboardScanCodeToEfiKey[] = {
-
- {
- 0x01, // Escape
- SCAN_ESC,
- 0x0000,
- 0x0000
- },
- {
- 0x02,
- SCAN_NULL,
- L'1',
- L'!'
- },
- {
- 0x03,
- SCAN_NULL,
- L'2',
- L'@'
- },
- {
- 0x04,
- SCAN_NULL,
- L'3',
- L'#'
- },
- {
- 0x05,
- SCAN_NULL,
- L'4',
- L'$'
- },
- {
- 0x06,
- SCAN_NULL,
- L'5',
- L'%'
- },
- {
- 0x07,
- SCAN_NULL,
- L'6',
- L'^'
- },
- {
- 0x08,
- SCAN_NULL,
- L'7',
- L'&'
- },
- {
- 0x09,
- SCAN_NULL,
- L'8',
- L'*'
- },
- {
- 0x0A,
- SCAN_NULL,
- L'9',
- L'('
- },
- {
- 0x0B,
- SCAN_NULL,
- L'0',
- L')'
- },
- {
- 0x0C,
- SCAN_NULL,
- L'-',
- L'_'
- },
- {
- 0x0D,
- SCAN_NULL,
- L'=',
- L'+'
- },
- {
- 0x0E, // BackSpace
- SCAN_NULL,
- 0x0008,
- 0x0008
- },
- {
- 0x0F, // Tab
- SCAN_NULL,
- 0x0009,
- 0x0009
- },
- {
- 0x10,
- SCAN_NULL,
- L'q',
- L'Q'
- },
- {
- 0x11,
- SCAN_NULL,
- L'w',
- L'W'
- },
- {
- 0x12,
- SCAN_NULL,
- L'e',
- L'E'
- },
- {
- 0x13,
- SCAN_NULL,
- L'r',
- L'R'
- },
- {
- 0x14,
- SCAN_NULL,
- L't',
- L'T'
- },
- {
- 0x15,
- SCAN_NULL,
- L'y',
- L'Y'
- },
- {
- 0x16,
- SCAN_NULL,
- L'u',
- L'U'
- },
- {
- 0x17,
- SCAN_NULL,
- L'i',
- L'I'
- },
- {
- 0x18,
- SCAN_NULL,
- L'o',
- L'O'
- },
- {
- 0x19,
- SCAN_NULL,
- L'p',
- L'P'
- },
- {
- 0x1a,
- SCAN_NULL,
- L'[',
- L'{'
- },
- {
- 0x1b,
- SCAN_NULL,
- L']',
- L'}'
- },
- {
- 0x1c, // Enter
- SCAN_NULL,
- 0x000d,
- 0x000d
- },
- {
- 0x1d,
- SCAN_NULL,
- 0x0000,
- 0x0000
- },
- {
- 0x1e,
- SCAN_NULL,
- L'a',
- L'A'
- },
- {
- 0x1f,
- SCAN_NULL,
- L's',
- L'S'
- },
- {
- 0x20,
- SCAN_NULL,
- L'd',
- L'D'
- },
- {
- 0x21,
- SCAN_NULL,
- L'f',
- L'F'
- },
- {
- 0x22,
- SCAN_NULL,
- L'g',
- L'G'
- },
- {
- 0x23,
- SCAN_NULL,
- L'h',
- L'H'
- },
- {
- 0x24,
- SCAN_NULL,
- L'j',
- L'J'
- },
- {
- 0x25,
- SCAN_NULL,
- L'k',
- L'K'
- },
- {
- 0x26,
- SCAN_NULL,
- L'l',
- L'L'
- },
- {
- 0x27,
- SCAN_NULL,
- L';',
- L':'
- },
- {
- 0x28,
- SCAN_NULL,
- L'\'',
- L'"'
- },
- {
- 0x29,
- SCAN_NULL,
- L'`',
- L'~'
- },
- {
- 0x2a, // Left Shift
- SCAN_NULL,
- 0x0000,
- 0x0000
- },
- {
- 0x2b,
- SCAN_NULL,
- L'\\',
- L'|'
- },
- {
- 0x2c,
- SCAN_NULL,
- L'z',
- L'Z'
- },
- {
- 0x2d,
- SCAN_NULL,
- L'x',
- L'X'
- },
- {
- 0x2e,
- SCAN_NULL,
- L'c',
- L'C'
- },
- {
- 0x2f,
- SCAN_NULL,
- L'v',
- L'V'
- },
- {
- 0x30,
- SCAN_NULL,
- L'b',
- L'B'
- },
- {
- 0x31,
- SCAN_NULL,
- L'n',
- L'N'
- },
- {
- 0x32,
- SCAN_NULL,
- L'm',
- L'M'
- },
- {
- 0x33,
- SCAN_NULL,
- L',',
- L'<'
- },
- {
- 0x34,
- SCAN_NULL,
- L'.',
- L'>'
- },
- {
- 0x35,
- SCAN_NULL,
- L'/',
- L'?'
- },
- {
- 0x36, //Right Shift
- SCAN_NULL,
- 0x0000,
- 0x0000
- },
- {
- 0x37, // Numeric Keypad *
- SCAN_NULL,
- L'*',
- L'*'
- },
- {
- 0x38, //Left Alt/Extended Right Alt
- SCAN_NULL,
- 0x0000,
- 0x0000
- },
- {
- 0x39,
- SCAN_NULL,
- L' ',
- L' '
- },
- {
- 0x3A, //CapsLock
- SCAN_NULL,
- 0x0000,
- 0x0000
- },
- {
- 0x3B,
- SCAN_F1,
- 0x0000,
- 0x0000
- },
- {
- 0x3C,
- SCAN_F2,
- 0x0000,
- 0x0000
- },
- {
- 0x3D,
- SCAN_F3,
- 0x0000,
- 0x0000
- },
- {
- 0x3E,
- SCAN_F4,
- 0x0000,
- 0x0000
- },
- {
- 0x3F,
- SCAN_F5,
- 0x0000,
- 0x0000
- },
- {
- 0x40,
- SCAN_F6,
- 0x0000,
- 0x0000
- },
- {
- 0x41,
- SCAN_F7,
- 0x0000,
- 0x0000
- },
- {
- 0x42,
- SCAN_F8,
- 0x0000,
- 0x0000
- },
- {
- 0x43,
- SCAN_F9,
- 0x0000,
- 0x0000
- },
- {
- 0x44,
- SCAN_F10,
- 0x0000,
- 0x0000
- },
- {
- 0x45, // NumLock
- SCAN_NULL,
- 0x0000,
- 0x0000
- },
- {
- 0x46, // ScrollLock
- SCAN_NULL,
- 0x0000,
- 0x0000
- },
- {
- 0x47,
- SCAN_HOME,
- L'7',
- L'7'
- },
- {
- 0x48,
- SCAN_UP,
- L'8',
- L'8'
- },
- {
- 0x49,
- SCAN_PAGE_UP,
- L'9',
- L'9'
- },
- {
- 0x4a,
- SCAN_NULL,
- L'-',
- L'-'
- },
- {
- 0x4b,
- SCAN_LEFT,
- L'4',
- L'4'
- },
- {
- 0x4c, // Numeric Keypad 5
- SCAN_NULL,
- L'5',
- L'5'
- },
- {
- 0x4d,
- SCAN_RIGHT,
- L'6',
- L'6'
- },
- {
- 0x4e,
- SCAN_NULL,
- L'+',
- L'+'
- },
- {
- 0x4f,
- SCAN_END,
- L'1',
- L'1'
- },
- {
- 0x50,
- SCAN_DOWN,
- L'2',
- L'2'
- },
- {
- 0x51,
- SCAN_PAGE_DOWN,
- L'3',
- L'3'
- },
- {
- 0x52,
- SCAN_INSERT,
- L'0',
- L'0'
- },
- {
- 0x53,
- SCAN_DELETE,
- L'.',
- L'.'
- },
- {
- 0x57,
- SCAN_F11,
- 0x0000,
- 0x0000
- },
- {
- 0x58,
- SCAN_F12,
- 0x0000,
- 0x0000
- },
- {
- 0x5B, //Left LOGO
- SCAN_NULL,
- 0x0000,
- 0x0000
- },
- {
- 0x5C, //Right LOGO
- SCAN_NULL,
- 0x0000,
- 0x0000
- },
- {
- 0x5D, //Menu key
- SCAN_NULL,
- 0x0000,
- 0x0000
- },
- {
- TABLE_END,
- TABLE_END,
- SCAN_NULL,
- SCAN_NULL
- },
-};
-
-//
-// The WaitForValue time out
-//
-UINTN mWaitForValueTimeOut = KEYBOARD_WAITFORVALUE_TIMEOUT;
-
-BOOLEAN mEnableMouseInterface;
-
-
-
-/**
- Return the count of scancode in the queue.
-
- @param Queue Pointer to instance of SCAN_CODE_QUEUE.
-
- @return Count of the scancode.
-**/
-UINTN
-GetScancodeBufCount (
- IN SCAN_CODE_QUEUE *Queue
- )
-{
- if (Queue->Head <= Queue->Tail) {
- return Queue->Tail - Queue->Head;
- } else {
- return Queue->Tail + KEYBOARD_SCAN_CODE_MAX_COUNT - Queue->Head;
- }
-}
-
-/**
- Read several bytes from the scancode buffer without removing them.
- This function is called to see if there are enough bytes of scancode
- representing a single key.
-
- @param Queue Pointer to instance of SCAN_CODE_QUEUE.
- @param Count Number of bytes to be read
- @param Buf Store the results
-
- @retval EFI_SUCCESS success to scan the keyboard code
- @retval EFI_NOT_READY invalid parameter
-**/
-EFI_STATUS
-GetScancodeBufHead (
- IN SCAN_CODE_QUEUE *Queue,
- IN UINTN Count,
- OUT UINT8 *Buf
- )
-{
- UINTN Index;
- UINTN Pos;
-
- //
- // check the valid range of parameter 'Count'
- //
- if (GetScancodeBufCount (Queue) < Count) {
- return EFI_NOT_READY;
- }
- //
- // retrieve the values
- //
- for (Index = 0, Pos = Queue->Head; Index < Count; Index++, Pos = (Pos + 1) % KEYBOARD_SCAN_CODE_MAX_COUNT) {
- Buf[Index] = Queue->Buffer[Pos];
- }
-
- return EFI_SUCCESS;
-}
-
-/**
-
- Read & remove several bytes from the scancode buffer.
- This function is usually called after GetScancodeBufHead()
-
- @param Queue Pointer to instance of SCAN_CODE_QUEUE.
- @param Count Number of bytes to be read
- @param Buf Store the results
-
- @retval EFI_SUCCESS success to scan the keyboard code
- @retval EFI_NOT_READY invalid parameter
-**/
-EFI_STATUS
-PopScancodeBufHead (
- IN SCAN_CODE_QUEUE *Queue,
- IN UINTN Count,
- OUT UINT8 *Buf OPTIONAL
- )
-{
- UINTN Index;
-
- //
- // Check the valid range of parameter 'Count'
- //
- if (GetScancodeBufCount (Queue) < Count) {
- return EFI_NOT_READY;
- }
- //
- // Retrieve and remove the values
- //
- for (Index = 0; Index < Count; Index++, Queue->Head = (Queue->Head + 1) % KEYBOARD_SCAN_CODE_MAX_COUNT) {
- if (Buf != NULL) {
- Buf[Index] = Queue->Buffer[Queue->Head];
- }
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Push one byte to the scancode buffer.
-
- @param Queue Pointer to instance of SCAN_CODE_QUEUE.
- @param Scancode The byte to push.
-**/
-VOID
-PushScancodeBufTail (
- IN SCAN_CODE_QUEUE *Queue,
- IN UINT8 Scancode
- )
-{
- if (GetScancodeBufCount (Queue) == KEYBOARD_SCAN_CODE_MAX_COUNT - 1) {
- PopScancodeBufHead (Queue, 1, NULL);
- }
-
- Queue->Buffer[Queue->Tail] = Scancode;
- Queue->Tail = (Queue->Tail + 1) % KEYBOARD_SCAN_CODE_MAX_COUNT;
-}
-
-/**
- Read data register .
-
- @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV
-
- @return return the value
-
-**/
-UINT8
-KeyReadDataRegister (
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
- )
-
-{
- EFI_ISA_IO_PROTOCOL *IsaIo;
- UINT8 Data;
-
- //
- // Use IsaIo protocol to perform IO operations
- //
- IsaIo = ConsoleIn->IsaIo;
-
- IsaIo->Io.Read (
- IsaIo,
- EfiIsaIoWidthUint8,
- ConsoleIn->DataRegisterAddress,
- 1,
- &Data
- );
-
- return Data;
-}
-
-/**
- Write data register.
-
- @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV
- @param Data value wanted to be written
-
-**/
-VOID
-KeyWriteDataRegister (
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
- IN UINT8 Data
- )
-{
- ConsoleIn->IsaIo->Io.Write (
- ConsoleIn->IsaIo,
- EfiIsaIoWidthUint8,
- ConsoleIn->DataRegisterAddress,
- 1,
- &Data
- );
-}
-
-/**
- Read status register.
-
- @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV
-
- @return value in status register
-
-**/
-UINT8
-KeyReadStatusRegister (
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
- )
-{
- UINT8 Data;
- ConsoleIn->IsaIo->Io.Read (
- ConsoleIn->IsaIo,
- EfiIsaIoWidthUint8,
- ConsoleIn->StatusRegisterAddress,
- 1,
- &Data
- );
- return Data;
-}
-
-/**
- Write command register .
-
- @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV
- @param Data The value wanted to be written
-
-**/
-VOID
-KeyWriteCommandRegister (
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
- IN UINT8 Data
- )
-{
- ConsoleIn->IsaIo->Io.Write (
- ConsoleIn->IsaIo,
- EfiIsaIoWidthUint8,
- ConsoleIn->CommandRegisterAddress,
- 1,
- &Data
- );
-}
-
-/**
- Display error message.
-
- @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV
- @param ErrMsg Unicode string of error message
-
-**/
-VOID
-KeyboardError (
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
- IN CHAR16 *ErrMsg
- )
-{
- ConsoleIn->KeyboardErr = TRUE;
-}
-
-/**
- Timer event handler: read a series of scancodes from 8042
- and put them into memory scancode buffer.
- it read as much scancodes to either fill
- the memory buffer or empty the keyboard buffer.
- It is registered as running under TPL_NOTIFY
-
- @param Event The timer event
- @param Context A KEYBOARD_CONSOLE_IN_DEV pointer
-
-**/
-VOID
-EFIAPI
-KeyboardTimerHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-
-{
- UINT8 Data;
- EFI_TPL OldTpl;
- KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
-
- ConsoleIn = (KEYBOARD_CONSOLE_IN_DEV *) Context;
-
- //
- // Enter critical section
- //
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
-
- if (((KEYBOARD_CONSOLE_IN_DEV *) Context)->KeyboardErr) {
- //
- // Leave critical section and return
- //
- gBS->RestoreTPL (OldTpl);
- return ;
- }
-
- //
- // To let KB driver support Hot plug, here should skip the 'resend' command for the case that
- // KB is not connected to system. If KB is not connected to system, driver will find there's something
- // error in the following code and wait for the input buffer empty, this waiting time shoulb be short enough since
- // this is a NOTIFY TPL period function, or the system performance will degrade hardly when KB is not connected.
- // Just skip the 'resend' process simply.
- //
-
- while ((KeyReadStatusRegister (ConsoleIn) & (KEYBOARD_STATUS_REGISTER_TRANSMIT_TIMEOUT|KEYBOARD_STATUS_REGISTER_HAS_OUTPUT_DATA)) ==
- KEYBOARD_STATUS_REGISTER_HAS_OUTPUT_DATA
- ) {
- //
- // Read one byte of the scan code and store it into the memory buffer
- //
- Data = KeyReadDataRegister (ConsoleIn);
- PushScancodeBufTail (&ConsoleIn->ScancodeQueue, Data);
- }
- KeyGetchar (ConsoleIn);
-
- //
- // Leave critical section and return
- //
- gBS->RestoreTPL (OldTpl);
-}
-
-/**
- Read key value .
-
- @param ConsoleIn - Pointer to instance of KEYBOARD_CONSOLE_IN_DEV
- @param Data - Pointer to outof buffer for keeping key value
-
- @retval EFI_TIMEOUT Status resigter time out
- @retval EFI_SUCCESS Success to read keyboard
-
-**/
-EFI_STATUS
-KeyboardRead (
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
- OUT UINT8 *Data
- )
-
-{
- UINT32 TimeOut;
- UINT32 RegFilled;
-
- TimeOut = 0;
- RegFilled = 0;
-
- //
- // wait till output buffer full then perform the read
- //
- for (TimeOut = 0; TimeOut < KEYBOARD_TIMEOUT; TimeOut += 30) {
- if (KeyReadStatusRegister (ConsoleIn) & KEYBOARD_STATUS_REGISTER_HAS_OUTPUT_DATA) {
- RegFilled = 1;
- *Data = KeyReadDataRegister (ConsoleIn);
- break;
- }
-
- MicroSecondDelay (30);
- }
-
- if (RegFilled == 0) {
- return EFI_TIMEOUT;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- write key to keyboard
-
- @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV
- @param Data value wanted to be written
-
- @retval EFI_TIMEOUT The input buffer register is full for putting new value util timeout
- @retval EFI_SUCCESS The new value is sucess put into input buffer register.
-
-**/
-EFI_STATUS
-KeyboardWrite (
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
- IN UINT8 Data
- )
-{
- UINT32 TimeOut;
- UINT32 RegEmptied;
-
- TimeOut = 0;
- RegEmptied = 0;
-
- //
- // wait for input buffer empty
- //
- for (TimeOut = 0; TimeOut < KEYBOARD_TIMEOUT; TimeOut += 30) {
- if ((KeyReadStatusRegister (ConsoleIn) & 0x02) == 0) {
- RegEmptied = 1;
- break;
- }
-
- MicroSecondDelay (30);
- }
-
- if (RegEmptied == 0) {
- return EFI_TIMEOUT;
- }
- //
- // Write it
- //
- KeyWriteDataRegister (ConsoleIn, Data);
-
- return EFI_SUCCESS;
-}
-
-/**
- Issue keyboard command.
-
- @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV
- @param Data The buff holding the command
-
- @retval EFI_TIMEOUT Keyboard is not ready to issuing
- @retval EFI_SUCCESS Success to issue keyboard command
-
-**/
-EFI_STATUS
-KeyboardCommand (
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
- IN UINT8 Data
- )
-{
- UINT32 TimeOut;
- UINT32 RegEmptied;
-
- TimeOut = 0;
- RegEmptied = 0;
-
- //
- // Wait For Input Buffer Empty
- //
- for (TimeOut = 0; TimeOut < KEYBOARD_TIMEOUT; TimeOut += 30) {
- if ((KeyReadStatusRegister (ConsoleIn) & 0x02) == 0) {
- RegEmptied = 1;
- break;
- }
-
- MicroSecondDelay (30);
- }
-
- if (RegEmptied == 0) {
- return EFI_TIMEOUT;
- }
- //
- // issue the command
- //
- KeyWriteCommandRegister (ConsoleIn, Data);
-
- //
- // Wait For Input Buffer Empty again
- //
- RegEmptied = 0;
- for (TimeOut = 0; TimeOut < KEYBOARD_TIMEOUT; TimeOut += 30) {
- if ((KeyReadStatusRegister (ConsoleIn) & 0x02) == 0) {
- RegEmptied = 1;
- break;
- }
-
- MicroSecondDelay (30);
- }
-
- if (RegEmptied == 0) {
- return EFI_TIMEOUT;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- wait for a specific value to be presented on
- 8042 Data register by keyboard and then read it,
- used in keyboard commands ack
-
- @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV
- @param Value the value wanted to be waited.
-
- @retval EFI_TIMEOUT Fail to get specific value in given time
- @retval EFI_SUCCESS Success to get specific value in given time.
-
-**/
-EFI_STATUS
-KeyboardWaitForValue (
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
- IN UINT8 Value
- )
-{
- UINT8 Data;
- UINT32 TimeOut;
- UINT32 SumTimeOut;
- UINT32 GotIt;
-
- GotIt = 0;
- TimeOut = 0;
- SumTimeOut = 0;
-
- //
- // Make sure the initial value of 'Data' is different from 'Value'
- //
- Data = 0;
- if (Data == Value) {
- Data = 1;
- }
- //
- // Read from 8042 (multiple times if needed)
- // until the expected value appears
- // use SumTimeOut to control the iteration
- //
- while (1) {
- //
- // Perform a read
- //
- for (TimeOut = 0; TimeOut < KEYBOARD_TIMEOUT; TimeOut += 30) {
- if (KeyReadStatusRegister (ConsoleIn) & 0x01) {
- Data = KeyReadDataRegister (ConsoleIn);
- break;
- }
-
- MicroSecondDelay (30);
- }
-
- SumTimeOut += TimeOut;
-
- if (Data == Value) {
- GotIt = 1;
- break;
- }
-
- if (SumTimeOut >= mWaitForValueTimeOut) {
- break;
- }
- }
- //
- // Check results
- //
- if (GotIt == 1) {
- return EFI_SUCCESS;
- } else {
- return EFI_TIMEOUT;
- }
-
-}
-
-/**
- Show keyboard status lights according to
- indicators in ConsoleIn.
-
- @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV
-
- @return status of updating keyboard register
-
-**/
-EFI_STATUS
-UpdateStatusLights (
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
- )
-{
- EFI_STATUS Status;
- UINT8 Command;
-
- //
- // Send keyboard command
- //
- Status = KeyboardWrite (ConsoleIn, 0xed);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- KeyboardWaitForValue (ConsoleIn, 0xfa);
-
- //
- // Light configuration
- //
- Command = 0;
- if (ConsoleIn->CapsLock) {
- Command |= 4;
- }
-
- if (ConsoleIn->NumLock) {
- Command |= 2;
- }
-
- if (ConsoleIn->ScrollLock) {
- Command |= 1;
- }
-
- Status = KeyboardWrite (ConsoleIn, Command);
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- KeyboardWaitForValue (ConsoleIn, 0xfa);
- return Status;
-}
-
-/**
- Get scancode from scancode buffer and translate into EFI-scancode and unicode defined by EFI spec.
-
- The function is always called in TPL_NOTIFY.
-
- @param ConsoleIn KEYBOARD_CONSOLE_IN_DEV instance pointer
-
-**/
-VOID
-KeyGetchar (
- IN OUT KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
- )
-{
- EFI_STATUS Status;
- UINT16 ScanCode;
- BOOLEAN Extend0;
- BOOLEAN Extend1;
- UINTN Index;
- EFI_KEY_DATA KeyData;
- LIST_ENTRY *Link;
- KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
- //
- // 3 bytes most
- //
- UINT8 ScancodeArr[3];
- UINT32 ScancodeArrPos;
-
- //
- // Check if there are enough bytes of scancode representing a single key
- // available in the buffer
- //
- while (TRUE) {
- Extend0 = FALSE;
- Extend1 = FALSE;
- ScancodeArrPos = 0;
- Status = GetScancodeBufHead (&ConsoleIn->ScancodeQueue, ScancodeArrPos + 1, ScancodeArr);
- if (EFI_ERROR (Status)) {
- return ;
- }
-
- if (ScancodeArr[ScancodeArrPos] == SCANCODE_EXTENDED0) {
- //
- // E0 to look ahead 2 bytes
- //
- Extend0 = TRUE;
- ScancodeArrPos = 1;
- Status = GetScancodeBufHead (&ConsoleIn->ScancodeQueue, ScancodeArrPos + 1, ScancodeArr);
- if (EFI_ERROR (Status)) {
- return ;
- }
- } else if (ScancodeArr[ScancodeArrPos] == SCANCODE_EXTENDED1) {
- //
- // E1 to look ahead 3 bytes
- //
- Extend1 = TRUE;
- ScancodeArrPos = 2;
- Status = GetScancodeBufHead (&ConsoleIn->ScancodeQueue, ScancodeArrPos + 1, ScancodeArr);
- if (EFI_ERROR (Status)) {
- return ;
- }
- }
- //
- // if we reach this position, scancodes for a key is in buffer now,pop them
- //
- Status = PopScancodeBufHead (&ConsoleIn->ScancodeQueue, ScancodeArrPos + 1, ScancodeArr);
- ASSERT_EFI_ERROR (Status);
-
- //
- // store the last available byte, this byte of scancode will be checked
- //
- ScanCode = ScancodeArr[ScancodeArrPos];
-
- if (!Extend1) {
- //
- // Check for special keys and update the driver state.
- //
- switch (ScanCode) {
-
- case SCANCODE_CTRL_MAKE:
- if (Extend0) {
- ConsoleIn->RightCtrl = TRUE;
- } else {
- ConsoleIn->LeftCtrl = TRUE;
- }
- break;
- case SCANCODE_CTRL_BREAK:
- if (Extend0) {
- ConsoleIn->RightCtrl = FALSE;
- } else {
- ConsoleIn->LeftCtrl = FALSE;
- }
- break;
-
- case SCANCODE_ALT_MAKE:
- if (Extend0) {
- ConsoleIn->RightAlt = TRUE;
- } else {
- ConsoleIn->LeftAlt = TRUE;
- }
- break;
- case SCANCODE_ALT_BREAK:
- if (Extend0) {
- ConsoleIn->RightAlt = FALSE;
- } else {
- ConsoleIn->LeftAlt = FALSE;
- }
- break;
-
- case SCANCODE_LEFT_SHIFT_MAKE:
- //
- // To avoid recognize PRNT_SCRN key as a L_SHIFT key
- // because PRNT_SCRN key generates E0 followed by L_SHIFT scan code.
- // If it the second byte of the PRNT_ScRN skip it.
- //
- if (!Extend0) {
- ConsoleIn->LeftShift = TRUE;
- break;
- }
- continue;
-
- case SCANCODE_LEFT_SHIFT_BREAK:
- if (!Extend0) {
- ConsoleIn->LeftShift = FALSE;
- }
- break;
-
- case SCANCODE_RIGHT_SHIFT_MAKE:
- ConsoleIn->RightShift = TRUE;
- break;
- case SCANCODE_RIGHT_SHIFT_BREAK:
- ConsoleIn->RightShift = FALSE;
- break;
-
- case SCANCODE_LEFT_LOGO_MAKE:
- ConsoleIn->LeftLogo = TRUE;
- break;
- case SCANCODE_LEFT_LOGO_BREAK:
- ConsoleIn->LeftLogo = FALSE;
- break;
-
- case SCANCODE_RIGHT_LOGO_MAKE:
- ConsoleIn->RightLogo = TRUE;
- break;
- case SCANCODE_RIGHT_LOGO_BREAK:
- ConsoleIn->RightLogo = FALSE;
- break;
-
- case SCANCODE_MENU_MAKE:
- ConsoleIn->Menu = TRUE;
- break;
- case SCANCODE_MENU_BREAK:
- ConsoleIn->Menu = FALSE;
- break;
-
- case SCANCODE_SYS_REQ_MAKE:
- if (Extend0) {
- ConsoleIn->SysReq = TRUE;
- }
- break;
- case SCANCODE_SYS_REQ_BREAK:
- if (Extend0) {
- ConsoleIn->SysReq = FALSE;
- }
- break;
-
- case SCANCODE_SYS_REQ_MAKE_WITH_ALT:
- ConsoleIn->SysReq = TRUE;
- break;
- case SCANCODE_SYS_REQ_BREAK_WITH_ALT:
- ConsoleIn->SysReq = FALSE;
- break;
-
- case SCANCODE_CAPS_LOCK_MAKE:
- ConsoleIn->CapsLock = (BOOLEAN)!ConsoleIn->CapsLock;
- UpdateStatusLights (ConsoleIn);
- break;
- case SCANCODE_NUM_LOCK_MAKE:
- ConsoleIn->NumLock = (BOOLEAN)!ConsoleIn->NumLock;
- UpdateStatusLights (ConsoleIn);
- break;
- case SCANCODE_SCROLL_LOCK_MAKE:
- if (!Extend0) {
- ConsoleIn->ScrollLock = (BOOLEAN)!ConsoleIn->ScrollLock;
- UpdateStatusLights (ConsoleIn);
- }
- break;
- }
- }
-
- //
- // If this is above the valid range, ignore it
- //
- if (ScanCode >= SCANCODE_MAX_MAKE) {
- continue;
- } else {
- break;
- }
- }
-
- //
- // Handle Ctrl+Alt+Del hotkey
- //
- if ((ConsoleIn->LeftCtrl || ConsoleIn->RightCtrl) &&
- (ConsoleIn->LeftAlt || ConsoleIn->RightAlt ) &&
- ScanCode == SCANCODE_DELETE_MAKE
- ) {
- gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);
- }
-
- //
- // Save the Shift/Toggle state
- //
- KeyData.KeyState.KeyShiftState = (UINT32) (EFI_SHIFT_STATE_VALID
- | (ConsoleIn->LeftCtrl ? EFI_LEFT_CONTROL_PRESSED : 0)
- | (ConsoleIn->RightCtrl ? EFI_RIGHT_CONTROL_PRESSED : 0)
- | (ConsoleIn->LeftAlt ? EFI_LEFT_ALT_PRESSED : 0)
- | (ConsoleIn->RightAlt ? EFI_RIGHT_ALT_PRESSED : 0)
- | (ConsoleIn->LeftShift ? EFI_LEFT_SHIFT_PRESSED : 0)
- | (ConsoleIn->RightShift ? EFI_RIGHT_SHIFT_PRESSED : 0)
- | (ConsoleIn->LeftLogo ? EFI_LEFT_LOGO_PRESSED : 0)
- | (ConsoleIn->RightLogo ? EFI_RIGHT_LOGO_PRESSED : 0)
- | (ConsoleIn->Menu ? EFI_MENU_KEY_PRESSED : 0)
- | (ConsoleIn->SysReq ? EFI_SYS_REQ_PRESSED : 0)
- );
- KeyData.KeyState.KeyToggleState = (EFI_KEY_TOGGLE_STATE) (EFI_TOGGLE_STATE_VALID
- | (ConsoleIn->CapsLock ? EFI_CAPS_LOCK_ACTIVE : 0)
- | (ConsoleIn->NumLock ? EFI_NUM_LOCK_ACTIVE : 0)
- | (ConsoleIn->ScrollLock ? EFI_SCROLL_LOCK_ACTIVE : 0)
- | (ConsoleIn->IsSupportPartialKey ? EFI_KEY_STATE_EXPOSED : 0)
- );
-
- KeyData.Key.ScanCode = SCAN_NULL;
- KeyData.Key.UnicodeChar = CHAR_NULL;
-
- //
- // Key Pad "/" shares the same scancode as that of "/" except Key Pad "/" has E0 prefix
- //
- if (Extend0 && ScanCode == 0x35) {
- KeyData.Key.UnicodeChar = L'/';
- KeyData.Key.ScanCode = SCAN_NULL;
-
- //
- // PAUSE shares the same scancode as that of NUM except PAUSE has E1 prefix
- //
- } else if (Extend1 && ScanCode == SCANCODE_NUM_LOCK_MAKE) {
- KeyData.Key.UnicodeChar = CHAR_NULL;
- KeyData.Key.ScanCode = SCAN_PAUSE;
-
- //
- // PAUSE shares the same scancode as that of SCROLL except PAUSE (CTRL pressed) has E0 prefix
- //
- } else if (Extend0 && ScanCode == SCANCODE_SCROLL_LOCK_MAKE) {
- KeyData.Key.UnicodeChar = CHAR_NULL;
- KeyData.Key.ScanCode = SCAN_PAUSE;
-
- //
- // PRNT_SCRN shares the same scancode as that of Key Pad "*" except PRNT_SCRN has E0 prefix
- //
- } else if (Extend0 && ScanCode == SCANCODE_SYS_REQ_MAKE) {
- KeyData.Key.UnicodeChar = CHAR_NULL;
- KeyData.Key.ScanCode = SCAN_NULL;
-
- //
- // Except the above special case, all others can be handled by convert table
- //
- } else {
- for (Index = 0; ConvertKeyboardScanCodeToEfiKey[Index].ScanCode != TABLE_END; Index++) {
- if (ScanCode == ConvertKeyboardScanCodeToEfiKey[Index].ScanCode) {
- KeyData.Key.ScanCode = ConvertKeyboardScanCodeToEfiKey[Index].EfiScanCode;
- KeyData.Key.UnicodeChar = ConvertKeyboardScanCodeToEfiKey[Index].UnicodeChar;
-
- if ((ConsoleIn->LeftShift || ConsoleIn->RightShift) &&
- (ConvertKeyboardScanCodeToEfiKey[Index].UnicodeChar != ConvertKeyboardScanCodeToEfiKey[Index].ShiftUnicodeChar)) {
- KeyData.Key.UnicodeChar = ConvertKeyboardScanCodeToEfiKey[Index].ShiftUnicodeChar;
- //
- // Need not return associated shift state if a class of printable characters that
- // are normally adjusted by shift modifiers. e.g. Shift Key + 'f' key = 'F'
- //
- KeyData.KeyState.KeyShiftState &= ~(EFI_LEFT_SHIFT_PRESSED | EFI_RIGHT_SHIFT_PRESSED);
- }
- //
- // alphabetic key is affected by CapsLock State
- //
- if (ConsoleIn->CapsLock) {
- if (KeyData.Key.UnicodeChar >= L'a' && KeyData.Key.UnicodeChar <= L'z') {
- KeyData.Key.UnicodeChar = (UINT16) (KeyData.Key.UnicodeChar - L'a' + L'A');
- } else if (KeyData.Key.UnicodeChar >= L'A' && KeyData.Key.UnicodeChar <= L'Z') {
- KeyData.Key.UnicodeChar = (UINT16) (KeyData.Key.UnicodeChar - L'A' + L'a');
- }
- }
- break;
- }
- }
- }
-
- //
- // distinguish numeric key pad keys' 'up symbol' and 'down symbol'
- //
- if (ScanCode >= 0x47 && ScanCode <= 0x53) {
- if (ConsoleIn->NumLock && !(ConsoleIn->LeftShift || ConsoleIn->RightShift) && !Extend0) {
- KeyData.Key.ScanCode = SCAN_NULL;
- } else if (ScanCode != 0x4a && ScanCode != 0x4e) {
- KeyData.Key.UnicodeChar = CHAR_NULL;
- }
- }
-
- //
- // If the key can not be converted then just return.
- //
- if (KeyData.Key.ScanCode == SCAN_NULL && KeyData.Key.UnicodeChar == CHAR_NULL) {
- if (!ConsoleIn->IsSupportPartialKey) {
- return ;
- }
- }
-
- //
- // Signal KeyNotify process event if this key pressed matches any key registered.
- //
- for (Link = GetFirstNode (&ConsoleIn->NotifyList); !IsNull (&ConsoleIn->NotifyList, Link); Link = GetNextNode (&ConsoleIn->NotifyList, Link)) {
- CurrentNotify = CR (
- Link,
- KEYBOARD_CONSOLE_IN_EX_NOTIFY,
- NotifyEntry,
- KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE
- );
- if (IsKeyRegistered (&CurrentNotify->KeyData, &KeyData)) {
- //
- // The key notification function needs to run at TPL_CALLBACK
- // while current TPL is TPL_NOTIFY. It will be invoked in
- // KeyNotifyProcessHandler() which runs at TPL_CALLBACK.
- //
- PushEfikeyBufTail (&ConsoleIn->EfiKeyQueueForNotify, &KeyData);
- gBS->SignalEvent (ConsoleIn->KeyNotifyProcessEvent);
- }
- }
-
- PushEfikeyBufTail (&ConsoleIn->EfiKeyQueue, &KeyData);
-}
-
-/**
- Perform 8042 controller and keyboard Initialization.
- If ExtendedVerification is TRUE, do additional test for
- the keyboard interface
-
- @param ConsoleIn - KEYBOARD_CONSOLE_IN_DEV instance pointer
- @param ExtendedVerification - indicates a thorough initialization
-
- @retval EFI_DEVICE_ERROR Fail to init keyboard
- @retval EFI_SUCCESS Success to init keyboard
-**/
-EFI_STATUS
-InitKeyboard (
- IN OUT KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
- IN BOOLEAN ExtendedVerification
- )
-{
- EFI_STATUS Status;
- EFI_STATUS Status1;
- UINT8 CommandByte;
- EFI_PS2_POLICY_PROTOCOL *Ps2Policy;
- UINT32 TryTime;
-
- Status = EFI_SUCCESS;
- mEnableMouseInterface = TRUE;
- TryTime = 0;
-
- //
- // Get Ps2 policy to set this
- //
- gBS->LocateProtocol (
- &gEfiPs2PolicyProtocolGuid,
- NULL,
- (VOID **) &Ps2Policy
- );
-
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_PC_CLEAR_BUFFER,
- ConsoleIn->DevicePath
- );
-
- //
- // Perform a read to cleanup the Status Register's
- // output buffer full bits within MAX TRY times
- //
- if ((KeyReadStatusRegister (ConsoleIn) & KEYBOARD_STATUS_REGISTER_HAS_OUTPUT_DATA) != 0) {
- while (!EFI_ERROR (Status) && TryTime < KEYBOARD_MAX_TRY) {
- Status = KeyboardRead (ConsoleIn, &CommandByte);
- TryTime ++;
- }
- //
- // Exceed the max try times. The device may be error.
- //
- if (TryTime == KEYBOARD_MAX_TRY) {
- Status = EFI_DEVICE_ERROR;
- goto Done;
- }
- }
- //
- // We should disable mouse interface during the initialization process
- // since mouse device output could block keyboard device output in the
- // 60H port of 8042 controller.
- //
- // So if we are not initializing 8042 controller for the
- // first time, we have to remember the previous mouse interface
- // enabling state
- //
- // Test the system flag in to determine whether this is the first
- // time initialization
- //
- if ((KeyReadStatusRegister (ConsoleIn) & KEYBOARD_STATUS_REGISTER_SYSTEM_FLAG) != 0) {
- if (!PcdGetBool (PcdFastPS2Detection)) {
- //
- // 8042 controller is already setup (by myself or by mouse driver):
- // See whether mouse interface is already enabled
- // which determines whether we should enable it later
- //
- //
- // Read the command byte of 8042 controller
- //
- Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_READ);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"\n\r");
- goto Done;
- }
-
- Status = KeyboardRead (ConsoleIn, &CommandByte);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"\n\r");
- goto Done;
- }
- //
- // Test the mouse enabling bit
- //
- if ((CommandByte & 0x20) != 0) {
- mEnableMouseInterface = FALSE;
- } else {
- mEnableMouseInterface = TRUE;
- }
- } else {
- mEnableMouseInterface = FALSE;
- }
- } else {
- //
- // 8042 controller is not setup yet:
- // 8042 controller selftest;
- // Don't enable mouse interface later.
- //
- //
- // Disable keyboard and mouse interfaces
- //
- if (!PcdGetBool (PcdFastPS2Detection)) {
- Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_DISABLE_KEYBOARD_INTERFACE);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"\n\r");
- goto Done;
- }
-
- Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_DISABLE_MOUSE_INTERFACE);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"\n\r");
- goto Done;
- }
-
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_PC_SELF_TEST,
- ConsoleIn->DevicePath
- );
- //
- // 8042 Controller Self Test
- //
- Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_CONTROLLER_SELF_TEST);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"8042 controller command write error!\n\r");
- goto Done;
- }
-
- Status = KeyboardWaitForValue (ConsoleIn, 0x55);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"8042 controller self test failed!\n\r");
- goto Done;
- }
- }
- //
- // Don't enable mouse interface later
- //
- mEnableMouseInterface = FALSE;
-
- }
-
- if (Ps2Policy != NULL) {
- Ps2Policy->Ps2InitHardware (ConsoleIn->Handle);
- }
- //
- // Write 8042 Command Byte, set System Flag
- // While at the same time:
- // 1. disable mouse interface,
- // 2. enable kbd interface,
- // 3. enable PC/XT kbd translation mode
- // 4. enable mouse and kbd interrupts
- //
- // ( Command Byte bits:
- // 7: Reserved
- // 6: PC/XT translation mode
- // 5: Disable Auxiliary device interface
- // 4: Disable keyboard interface
- // 3: Reserved
- // 2: System Flag
- // 1: Enable Auxiliary device interrupt
- // 0: Enable Keyboard interrupt )
- //
- Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_WRITE);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"8042 controller command write error!\n\r");
- goto Done;
- }
-
- Status = KeyboardWrite (ConsoleIn, 0x67);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"8042 controller data write error!\n\r");
- goto Done;
- }
-
- //
- // Clear Memory Scancode Buffer
- //
- ConsoleIn->ScancodeQueue.Head = 0;
- ConsoleIn->ScancodeQueue.Tail = 0;
- ConsoleIn->EfiKeyQueue.Head = 0;
- ConsoleIn->EfiKeyQueue.Tail = 0;
- ConsoleIn->EfiKeyQueueForNotify.Head = 0;
- ConsoleIn->EfiKeyQueueForNotify.Tail = 0;
-
- //
- // Reset the status indicators
- //
- ConsoleIn->CapsLock = FALSE;
- ConsoleIn->NumLock = FALSE;
- ConsoleIn->ScrollLock = FALSE;
- ConsoleIn->LeftCtrl = FALSE;
- ConsoleIn->RightCtrl = FALSE;
- ConsoleIn->LeftAlt = FALSE;
- ConsoleIn->RightAlt = FALSE;
- ConsoleIn->LeftShift = FALSE;
- ConsoleIn->RightShift = FALSE;
- ConsoleIn->LeftLogo = FALSE;
- ConsoleIn->RightLogo = FALSE;
- ConsoleIn->Menu = FALSE;
- ConsoleIn->SysReq = FALSE;
-
- ConsoleIn->IsSupportPartialKey = FALSE;
- //
- // For resetting keyboard is not mandatory before booting OS and sometimes keyboard responses very slow,
- // and to support KB hot plug, we need to let the InitKB succeed no matter whether there is a KB device connected
- // to system. So we only do the real resetting for keyboard when user asks and there is a real KB connected t system,
- // and normally during booting an OS, it's skipped.
- //
- if (ExtendedVerification && CheckKeyboardConnect (ConsoleIn)) {
- //
- // Additional verifications for keyboard interface
- //
- //
- // Keyboard Interface Test
- //
- Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_KEYBOARD_INTERFACE_SELF_TEST);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"8042 controller command write error!\n\r");
- goto Done;
- }
-
- Status = KeyboardWaitForValue (ConsoleIn, 0x00);
- if (EFI_ERROR (Status)) {
- KeyboardError (
- ConsoleIn,
- L"Some specific value not aquired from 8042 controller!\n\r"
- );
- goto Done;
- }
- //
- // Keyboard reset with a BAT(Basic Assurance Test)
- //
- Status = KeyboardWrite (ConsoleIn, KEYBOARD_8048_COMMAND_RESET);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"8042 controller data write error!\n\r");
- goto Done;
- }
-
- Status = KeyboardWaitForValue (ConsoleIn, KEYBOARD_8048_RETURN_8042_ACK);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"Some specific value not aquired from 8042 controller!\n\r");
- goto Done;
- }
- //
- // wait for BAT completion code
- //
- mWaitForValueTimeOut = KEYBOARD_BAT_TIMEOUT;
-
- Status = KeyboardWaitForValue (ConsoleIn, KEYBOARD_8048_RETURN_8042_BAT_SUCCESS);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"Keyboard self test failed!\n\r");
- goto Done;
- }
-
- mWaitForValueTimeOut = KEYBOARD_WAITFORVALUE_TIMEOUT;
-
- //
- // Set Keyboard to use Scan Code Set 2
- //
- Status = KeyboardWrite (ConsoleIn, KEYBOARD_8048_COMMAND_SELECT_SCAN_CODE_SET);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"8042 controller data write error!\n\r");
- goto Done;
- }
-
- Status = KeyboardWaitForValue (ConsoleIn, KEYBOARD_8048_RETURN_8042_ACK);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"Some specific value not aquired from 8042 controller!\n\r");
- goto Done;
- }
-
- Status = KeyboardWrite (ConsoleIn, 0x02);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"8042 controller data write error!!\n\r");
- goto Done;
- }
-
- Status = KeyboardWaitForValue (ConsoleIn, KEYBOARD_8048_RETURN_8042_ACK);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"Some specific value not aquired from 8042 controller!\n\r");
- goto Done;
- }
-
- //
- // Clear Keyboard Scancode Buffer
- //
- Status = KeyboardWrite (ConsoleIn, KEYBOARD_8048_COMMAND_CLEAR_OUTPUT_DATA);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"8042 controller data write error!\n\r");
- goto Done;
- }
-
- Status = KeyboardWaitForValue (ConsoleIn, KEYBOARD_8048_RETURN_8042_ACK);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"Some specific value not aquired from 8042 controller!\n\r");
- goto Done;
- }
- //
- if (Ps2Policy != NULL) {
- if ((Ps2Policy->KeyboardLight & EFI_KEYBOARD_CAPSLOCK) == EFI_KEYBOARD_CAPSLOCK) {
- ConsoleIn->CapsLock = TRUE;
- }
-
- if ((Ps2Policy->KeyboardLight & EFI_KEYBOARD_NUMLOCK) == EFI_KEYBOARD_NUMLOCK) {
- ConsoleIn->NumLock = TRUE;
- }
-
- if ((Ps2Policy->KeyboardLight & EFI_KEYBOARD_SCROLLLOCK) == EFI_KEYBOARD_SCROLLLOCK) {
- ConsoleIn->ScrollLock = TRUE;
- }
- }
- //
- // Update Keyboard Lights
- //
- Status = UpdateStatusLights (ConsoleIn);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"Update keyboard status lights error!\n\r");
- goto Done;
- }
- }
- //
- // At last, we can now enable the mouse interface if appropriate
- //
-Done:
-
- if (mEnableMouseInterface) {
- //
- // Enable mouse interface
- //
- Status1 = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_ENABLE_MOUSE_INTERFACE);
- if (EFI_ERROR (Status1)) {
- KeyboardError (ConsoleIn, L"8042 controller command write error!\n\r");
- return EFI_DEVICE_ERROR;
- }
- }
-
- if (!EFI_ERROR (Status)) {
- return EFI_SUCCESS;
- } else {
- return EFI_DEVICE_ERROR;
- }
-
-}
-
-/**
- Disable the keyboard interface of the 8042 controller.
-
- @param ConsoleIn The device instance
-
- @return status of issuing disable command
-
-**/
-EFI_STATUS
-DisableKeyboard (
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
- )
-{
- EFI_STATUS Status;
-
- //
- // Disable keyboard interface
- //
- Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_DISABLE_KEYBOARD_INTERFACE);
- if (EFI_ERROR (Status)) {
- KeyboardError (ConsoleIn, L"\n\r");
- return EFI_DEVICE_ERROR;
- }
-
- return Status;
-}
-
-/**
- Check whether there is Ps/2 Keyboard device in system by 0xF4 Keyboard Command
- If Keyboard receives 0xF4, it will respond with 'ACK'. If it doesn't respond, the device
- should not be in system.
-
- @param[in] ConsoleIn Keyboard Private Data Structure
-
- @retval TRUE Keyboard in System.
- @retval FALSE Keyboard not in System.
-**/
-BOOLEAN
-EFIAPI
-CheckKeyboardConnect (
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
- )
-{
- EFI_STATUS Status;
- UINTN WaitForValueTimeOutBcakup;
-
- //
- // enable keyboard itself and wait for its ack
- // If can't receive ack, Keyboard should not be connected.
- //
- if (!PcdGetBool (PcdFastPS2Detection)) {
- Status = KeyboardWrite (
- ConsoleIn,
- KEYBOARD_KBEN
- );
-
- if (EFI_ERROR (Status)) {
- return FALSE;
- }
- //
- // wait for 1s
- //
- WaitForValueTimeOutBcakup = mWaitForValueTimeOut;
- mWaitForValueTimeOut = KEYBOARD_WAITFORVALUE_TIMEOUT;
- Status = KeyboardWaitForValue (
- ConsoleIn,
- KEYBOARD_CMDECHO_ACK
- );
- mWaitForValueTimeOut = WaitForValueTimeOutBcakup;
-
- if (EFI_ERROR (Status)) {
- return FALSE;
- }
-
- return TRUE;
- } else {
- return TRUE;
- }
-}
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c deleted file mode 100644 index 5825a04c3e..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c +++ /dev/null @@ -1,732 +0,0 @@ -/** @file
- Routines implements SIMPLE_TEXT_IN protocol's interfaces based on 8042 interfaces
- provided by Ps2KbdCtrller.c.
-
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
-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 "Ps2Keyboard.h"
-
-/**
- Check whether the EFI key buffer is empty.
-
- @param Queue Pointer to instance of EFI_KEY_QUEUE.
-
- @retval TRUE The EFI key buffer is empty.
- @retval FALSE The EFI key buffer isn't empty.
-**/
-BOOLEAN
-IsEfikeyBufEmpty (
- IN EFI_KEY_QUEUE *Queue
- )
-{
- return (BOOLEAN) (Queue->Head == Queue->Tail);
-}
-
-/**
- Read & remove one key data from the EFI key buffer.
-
- @param Queue Pointer to instance of EFI_KEY_QUEUE.
- @param KeyData Receive the key data.
-
- @retval EFI_SUCCESS The key data is popped successfully.
- @retval EFI_NOT_READY There is no key data available.
-**/
-EFI_STATUS
-PopEfikeyBufHead (
- IN EFI_KEY_QUEUE *Queue,
- OUT EFI_KEY_DATA *KeyData OPTIONAL
- )
-{
- if (IsEfikeyBufEmpty (Queue)) {
- return EFI_NOT_READY;
- }
- //
- // Retrieve and remove the values
- //
- if (KeyData != NULL) {
- CopyMem (KeyData, &Queue->Buffer[Queue->Head], sizeof (EFI_KEY_DATA));
- }
- Queue->Head = (Queue->Head + 1) % KEYBOARD_EFI_KEY_MAX_COUNT;
- return EFI_SUCCESS;
-}
-
-/**
- Push one key data to the EFI key buffer.
-
- @param Queue Pointer to instance of EFI_KEY_QUEUE.
- @param KeyData The key data to push.
-**/
-VOID
-PushEfikeyBufTail (
- IN EFI_KEY_QUEUE *Queue,
- IN EFI_KEY_DATA *KeyData
- )
-{
- if ((Queue->Tail + 1) % KEYBOARD_EFI_KEY_MAX_COUNT == Queue->Head) {
- //
- // If Queue is full, pop the one from head.
- //
- PopEfikeyBufHead (Queue, NULL);
- }
- CopyMem (&Queue->Buffer[Queue->Tail], KeyData, sizeof (EFI_KEY_DATA));
- Queue->Tail = (Queue->Tail + 1) % KEYBOARD_EFI_KEY_MAX_COUNT;
-}
-
-/**
- Judge whether is a registed key
-
- @param RegsiteredData A pointer to a buffer that is filled in with the keystroke
- state data for the key that was registered.
- @param InputData A pointer to a buffer that is filled in with the keystroke
- state data for the key that was pressed.
-
- @retval TRUE Key be pressed matches a registered key.
- @retval FLASE Match failed.
-
-**/
-BOOLEAN
-IsKeyRegistered (
- IN EFI_KEY_DATA *RegsiteredData,
- IN EFI_KEY_DATA *InputData
- )
-
-{
- ASSERT (RegsiteredData != NULL && InputData != NULL);
-
- if ((RegsiteredData->Key.ScanCode != InputData->Key.ScanCode) ||
- (RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) {
- return FALSE;
- }
-
- //
- // Assume KeyShiftState/KeyToggleState = 0 in Registered key data means these state could be ignored.
- //
- if (RegsiteredData->KeyState.KeyShiftState != 0 &&
- RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState) {
- return FALSE;
- }
- if (RegsiteredData->KeyState.KeyToggleState != 0 &&
- RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState) {
- return FALSE;
- }
-
- return TRUE;
-
-}
-
-/**
- Reads the next keystroke from the input device. The WaitForKey Event can
- be used to test for existance of a keystroke via WaitForEvent () call.
-
- @param ConsoleInDev Ps2 Keyboard private structure
- @param KeyData A pointer to a buffer that is filled in with the keystroke
- state data for the key that was pressed.
-
-
- @retval EFI_SUCCESS The keystroke information was returned.
- @retval EFI_NOT_READY There was no keystroke data availiable.
- @retval EFI_DEVICE_ERROR The keystroke information was not returned due to
- hardware errors.
- @retval EFI_INVALID_PARAMETER KeyData is NULL.
-
-**/
-EFI_STATUS
-KeyboardReadKeyStrokeWorker (
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleInDev,
- OUT EFI_KEY_DATA *KeyData
- )
-
-{
- EFI_STATUS Status;
- EFI_TPL OldTpl;
-
- if (KeyData == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Enter critical section
- //
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
-
- KeyboardTimerHandler (NULL, ConsoleInDev);
-
- if (ConsoleInDev->KeyboardErr) {
- Status = EFI_DEVICE_ERROR;
- } else {
- Status = PopEfikeyBufHead (&ConsoleInDev->EfiKeyQueue, KeyData);
- }
-
- gBS->RestoreTPL (OldTpl);
- return Status;
-}
-
-/**
- Perform 8042 controller and keyboard initialization which implement SIMPLE_TEXT_IN.Reset()
-
- @param This Pointer to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL
- @param ExtendedVerification Indicate that the driver may perform a more
- exhaustive verification operation of the device during
- reset, now this par is ignored in this driver
-
-**/
-EFI_STATUS
-EFIAPI
-KeyboardEfiReset (
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- )
-{
- EFI_STATUS Status;
- KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
- EFI_TPL OldTpl;
-
- ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);
- if (ConsoleIn->KeyboardErr) {
- return EFI_DEVICE_ERROR;
- }
-
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_RESET,
- ConsoleIn->DevicePath
- );
-
- //
- // Enter critical section
- //
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
-
- //
- // Call InitKeyboard to initialize the keyboard
- //
- Status = InitKeyboard (ConsoleIn, ExtendedVerification);
- if (EFI_ERROR (Status)) {
- //
- // Leave critical section and return
- //
- gBS->RestoreTPL (OldTpl);
- return EFI_DEVICE_ERROR;
- }
-
- //
- // Leave critical section and return
- //
- gBS->RestoreTPL (OldTpl);
-
- //
- // Report the status If a stuck key was detected
- //
- if (KeyReadStatusRegister (ConsoleIn) & 0x01) {
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_EC_STUCK_KEY,
- ConsoleIn->DevicePath
- );
- }
- //
- // Report the status If keyboard is locked
- //
- if ((KeyReadStatusRegister (ConsoleIn) & 0x10) == 0) {
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- EFI_PERIPHERAL_KEYBOARD | EFI_P_KEYBOARD_EC_LOCKED,
- ConsoleIn->DevicePath
- );
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Retrieve key values for driver user which implement SIMPLE_TEXT_IN.ReadKeyStroke().
-
- @param This Pointer to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL
- @param Key The output buffer for key value
-
- @retval EFI_SUCCESS success to read key stroke
-**/
-EFI_STATUS
-EFIAPI
-KeyboardReadKeyStroke (
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- OUT EFI_INPUT_KEY *Key
- )
-{
- EFI_STATUS Status;
- KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
- EFI_KEY_DATA KeyData;
-
- ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);
-
- //
- // Considering if the partial keystroke is enabled, there maybe a partial
- // keystroke in the queue, so here skip the partial keystroke and get the
- // next key from the queue
- //
- while (1) {
- //
- // If there is no pending key, then return.
- //
- Status = KeyboardReadKeyStrokeWorker (ConsoleIn, &KeyData);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // If it is partial keystroke, skip it.
- //
- if (KeyData.Key.ScanCode == SCAN_NULL && KeyData.Key.UnicodeChar == CHAR_NULL) {
- continue;
- }
- //
- // Translate the CTRL-Alpha characters to their corresponding control value
- // (ctrl-a = 0x0001 through ctrl-Z = 0x001A)
- //
- if ((KeyData.KeyState.KeyShiftState & (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) {
- if (KeyData.Key.UnicodeChar >= L'a' && KeyData.Key.UnicodeChar <= L'z') {
- KeyData.Key.UnicodeChar = (CHAR16) (KeyData.Key.UnicodeChar - L'a' + 1);
- } else if (KeyData.Key.UnicodeChar >= L'A' && KeyData.Key.UnicodeChar <= L'Z') {
- KeyData.Key.UnicodeChar = (CHAR16) (KeyData.Key.UnicodeChar - L'A' + 1);
- }
- }
-
- CopyMem (Key, &KeyData.Key, sizeof (EFI_INPUT_KEY));
- return EFI_SUCCESS;
- }
-}
-
-/**
- Event notification function for SIMPLE_TEXT_IN.WaitForKey event
- Signal the event if there is key available
-
- @param Event the event object
- @param Context waitting context
-
-**/
-VOID
-EFIAPI
-KeyboardWaitForKey (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- EFI_TPL OldTpl;
- KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
- EFI_KEY_DATA KeyData;
-
- ConsoleIn = (KEYBOARD_CONSOLE_IN_DEV *) Context;
-
- //
- // Enter critical section
- //
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
-
- KeyboardTimerHandler (NULL, ConsoleIn);
-
- if (!ConsoleIn->KeyboardErr) {
- //
- // WaitforKey doesn't suppor the partial key.
- // Considering if the partial keystroke is enabled, there maybe a partial
- // keystroke in the queue, so here skip the partial keystroke and get the
- // next key from the queue
- //
- while (!IsEfikeyBufEmpty (&ConsoleIn->EfiKeyQueue)) {
- CopyMem (
- &KeyData,
- &(ConsoleIn->EfiKeyQueue.Buffer[ConsoleIn->EfiKeyQueue.Head]),
- sizeof (EFI_KEY_DATA)
- );
- if (KeyData.Key.ScanCode == SCAN_NULL && KeyData.Key.UnicodeChar == CHAR_NULL) {
- PopEfikeyBufHead (&ConsoleIn->EfiKeyQueue, &KeyData);
- continue;
- }
- //
- // if there is pending value key, signal the event.
- //
- gBS->SignalEvent (Event);
- break;
- }
- }
- //
- // Leave critical section and return
- //
- gBS->RestoreTPL (OldTpl);
-}
-
-/**
- Event notification function for SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx event
- Signal the event if there is key available
-
- @param Event event object
- @param Context waiting context
-
-**/
-VOID
-EFIAPI
-KeyboardWaitForKeyEx (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-
-{
- KeyboardWaitForKey (Event, Context);
-}
-
-/**
- Reset the input device and optionaly run diagnostics
-
- @param This Protocol instance pointer.
- @param ExtendedVerification Driver may perform diagnostics on reset.
-
- @retval EFI_SUCCESS The device was reset.
- @retval EFI_DEVICE_ERROR The device is not functioning properly and could
- not be reset.
-
-**/
-EFI_STATUS
-EFIAPI
-KeyboardEfiResetEx (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- )
-
-{
- KEYBOARD_CONSOLE_IN_DEV *ConsoleInDev;
-
- ConsoleInDev = TEXT_INPUT_EX_KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);
-
- return ConsoleInDev->ConIn.Reset (
- &ConsoleInDev->ConIn,
- ExtendedVerification
- );
-}
-
-/**
- Reads the next keystroke from the input device. The WaitForKey Event can
- be used to test for existance of a keystroke via WaitForEvent () call.
-
-
- @param This Protocol instance pointer.
- @param KeyData A pointer to a buffer that is filled in with the keystroke
- state data for the key that was pressed.
-
- @retval EFI_SUCCESS The keystroke information was returned.
- @retval EFI_NOT_READY There was no keystroke data availiable.
- @retval EFI_DEVICE_ERROR The keystroke information was not returned due to
- hardware errors.
- @retval EFI_INVALID_PARAMETER KeyData is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-KeyboardReadKeyStrokeEx (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- OUT EFI_KEY_DATA *KeyData
- )
-
-{
- KEYBOARD_CONSOLE_IN_DEV *ConsoleInDev;
-
- if (KeyData == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- ConsoleInDev = TEXT_INPUT_EX_KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);
- return KeyboardReadKeyStrokeWorker (ConsoleInDev, KeyData);
-}
-
-/**
- Set certain state for the input device.
-
- @param This Protocol instance pointer.
- @param KeyToggleState A pointer to the EFI_KEY_TOGGLE_STATE to set the
- state for the input device.
-
- @retval EFI_SUCCESS The device state was set successfully.
- @retval EFI_DEVICE_ERROR The device is not functioning correctly and could
- not have the setting adjusted.
- @retval EFI_UNSUPPORTED The device does not have the ability to set its state.
- @retval EFI_INVALID_PARAMETER KeyToggleState is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-KeyboardSetState (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- IN EFI_KEY_TOGGLE_STATE *KeyToggleState
- )
-
-{
- EFI_STATUS Status;
- KEYBOARD_CONSOLE_IN_DEV *ConsoleInDev;
- EFI_TPL OldTpl;
-
- if (KeyToggleState == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- ConsoleInDev = TEXT_INPUT_EX_KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);
-
- //
- // Enter critical section
- //
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
-
- if (ConsoleInDev->KeyboardErr) {
- Status = EFI_DEVICE_ERROR;
- goto Exit;
- }
-
- if ((*KeyToggleState & EFI_TOGGLE_STATE_VALID) != EFI_TOGGLE_STATE_VALID) {
- Status = EFI_UNSUPPORTED;
- goto Exit;
- }
-
- //
- // Update the status light
- //
- ConsoleInDev->ScrollLock = FALSE;
- ConsoleInDev->NumLock = FALSE;
- ConsoleInDev->CapsLock = FALSE;
- ConsoleInDev->IsSupportPartialKey = FALSE;
-
- if ((*KeyToggleState & EFI_SCROLL_LOCK_ACTIVE) == EFI_SCROLL_LOCK_ACTIVE) {
- ConsoleInDev->ScrollLock = TRUE;
- }
- if ((*KeyToggleState & EFI_NUM_LOCK_ACTIVE) == EFI_NUM_LOCK_ACTIVE) {
- ConsoleInDev->NumLock = TRUE;
- }
- if ((*KeyToggleState & EFI_CAPS_LOCK_ACTIVE) == EFI_CAPS_LOCK_ACTIVE) {
- ConsoleInDev->CapsLock = TRUE;
- }
- if ((*KeyToggleState & EFI_KEY_STATE_EXPOSED) == EFI_KEY_STATE_EXPOSED) {
- ConsoleInDev->IsSupportPartialKey = TRUE;
- }
-
- Status = UpdateStatusLights (ConsoleInDev);
- if (EFI_ERROR (Status)) {
- Status = EFI_DEVICE_ERROR;
- }
-
-Exit:
- //
- // Leave critical section and return
- //
- gBS->RestoreTPL (OldTpl);
-
- return Status;
-
-}
-
-/**
- Register a notification function for a particular keystroke for the input device.
-
- @param This Protocol instance pointer.
- @param KeyData A pointer to a buffer that is filled in with the keystroke
- information data for the key that was pressed.
- @param KeyNotificationFunction Points to the function to be called when the key
- sequence is typed specified by KeyData.
- @param NotifyHandle Points to the unique handle assigned to the registered notification.
-
- @retval EFI_SUCCESS The notification function was registered successfully.
- @retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data structures.
- @retval EFI_INVALID_PARAMETER KeyData or NotifyHandle or KeyNotificationFunction is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-KeyboardRegisterKeyNotify (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- IN EFI_KEY_DATA *KeyData,
- IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,
- OUT VOID **NotifyHandle
- )
-{
- EFI_STATUS Status;
- KEYBOARD_CONSOLE_IN_DEV *ConsoleInDev;
- EFI_TPL OldTpl;
- LIST_ENTRY *Link;
- KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
- KEYBOARD_CONSOLE_IN_EX_NOTIFY *NewNotify;
-
- if (KeyData == NULL || NotifyHandle == NULL || KeyNotificationFunction == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- ConsoleInDev = TEXT_INPUT_EX_KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);
-
- //
- // Enter critical section
- //
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
-
- //
- // Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
- //
- for (Link = ConsoleInDev->NotifyList.ForwardLink; Link != &ConsoleInDev->NotifyList; Link = Link->ForwardLink) {
- CurrentNotify = CR (
- Link,
- KEYBOARD_CONSOLE_IN_EX_NOTIFY,
- NotifyEntry,
- KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE
- );
- if (IsKeyRegistered (&CurrentNotify->KeyData, KeyData)) {
- if (CurrentNotify->KeyNotificationFn == KeyNotificationFunction) {
- *NotifyHandle = CurrentNotify;
- Status = EFI_SUCCESS;
- goto Exit;
- }
- }
- }
-
- //
- // Allocate resource to save the notification function
- //
- NewNotify = (KEYBOARD_CONSOLE_IN_EX_NOTIFY *) AllocateZeroPool (sizeof (KEYBOARD_CONSOLE_IN_EX_NOTIFY));
- if (NewNotify == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Exit;
- }
-
- NewNotify->Signature = KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE;
- NewNotify->KeyNotificationFn = KeyNotificationFunction;
- CopyMem (&NewNotify->KeyData, KeyData, sizeof (EFI_KEY_DATA));
- InsertTailList (&ConsoleInDev->NotifyList, &NewNotify->NotifyEntry);
-
- *NotifyHandle = NewNotify;
- Status = EFI_SUCCESS;
-
-Exit:
- //
- // Leave critical section and return
- //
- gBS->RestoreTPL (OldTpl);
- return Status;
-
-}
-
-/**
- Remove a registered notification function from a particular keystroke.
-
- @param This Protocol instance pointer.
- @param NotificationHandle The handle of the notification function being unregistered.
-
-
- @retval EFI_SUCCESS The notification function was unregistered successfully.
- @retval EFI_INVALID_PARAMETER The NotificationHandle is invalid.
-
-**/
-EFI_STATUS
-EFIAPI
-KeyboardUnregisterKeyNotify (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- IN VOID *NotificationHandle
- )
-{
- EFI_STATUS Status;
- KEYBOARD_CONSOLE_IN_DEV *ConsoleInDev;
- EFI_TPL OldTpl;
- LIST_ENTRY *Link;
- KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
-
- if (NotificationHandle == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- ConsoleInDev = TEXT_INPUT_EX_KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (This);
-
- //
- // Enter critical section
- //
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
-
- for (Link = ConsoleInDev->NotifyList.ForwardLink; Link != &ConsoleInDev->NotifyList; Link = Link->ForwardLink) {
- CurrentNotify = CR (
- Link,
- KEYBOARD_CONSOLE_IN_EX_NOTIFY,
- NotifyEntry,
- KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE
- );
- if (CurrentNotify == NotificationHandle) {
- //
- // Remove the notification function from NotifyList and free resources
- //
- RemoveEntryList (&CurrentNotify->NotifyEntry);
-
- gBS->FreePool (CurrentNotify);
- Status = EFI_SUCCESS;
- goto Exit;
- }
- }
-
- //
- // Can not find the specified Notification Handle
- //
- Status = EFI_INVALID_PARAMETER;
-Exit:
- //
- // Leave critical section and return
- //
- gBS->RestoreTPL (OldTpl);
- return Status;
-}
-
-/**
- Process key notify.
-
- @param Event Indicates the event that invoke this function.
- @param Context Indicates the calling context.
-**/
-VOID
-EFIAPI
-KeyNotifyProcessHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- EFI_STATUS Status;
- KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
- EFI_KEY_DATA KeyData;
- LIST_ENTRY *Link;
- LIST_ENTRY *NotifyList;
- KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
- EFI_TPL OldTpl;
-
- ConsoleIn = (KEYBOARD_CONSOLE_IN_DEV *) Context;
-
- //
- // Invoke notification functions.
- //
- NotifyList = &ConsoleIn->NotifyList;
- while (TRUE) {
- //
- // Enter critical section
- //
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
- Status = PopEfikeyBufHead (&ConsoleIn->EfiKeyQueueForNotify, &KeyData);
- //
- // Leave critical section
- //
- gBS->RestoreTPL (OldTpl);
- if (EFI_ERROR (Status)) {
- break;
- }
- for (Link = GetFirstNode (NotifyList); !IsNull (NotifyList, Link); Link = GetNextNode (NotifyList, Link)) {
- CurrentNotify = CR (Link, KEYBOARD_CONSOLE_IN_EX_NOTIFY, NotifyEntry, KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE);
- if (IsKeyRegistered (&CurrentNotify->KeyData, &KeyData)) {
- CurrentNotify->KeyNotificationFn (&KeyData);
- }
- }
- }
-}
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c deleted file mode 100644 index ff562b2698..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c +++ /dev/null @@ -1,663 +0,0 @@ -/** @file
-
- PS/2 Keyboard driver. Routines that interacts with callers,
- conforming to EFI driver model
-
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
-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 "Ps2Keyboard.h"
-
-//
-// Function prototypes
-//
-/**
- Test controller is a keyboard Controller.
-
- @param This Pointer of EFI_DRIVER_BINDING_PROTOCOL
- @param Controller driver's controller
- @param RemainingDevicePath children device path
-
- @retval EFI_UNSUPPORTED controller is not floppy disk
- @retval EFI_SUCCESS controller is floppy disk
-**/
-EFI_STATUS
-EFIAPI
-KbdControllerDriverSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-/**
- Create KEYBOARD_CONSOLE_IN_DEV instance on controller.
-
- @param This Pointer of EFI_DRIVER_BINDING_PROTOCOL
- @param Controller driver controller handle
- @param RemainingDevicePath Children's device path
-
- @retval whether success to create floppy control instance.
-**/
-EFI_STATUS
-EFIAPI
-KbdControllerDriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-/**
- Stop this driver on ControllerHandle. Support stopping any child handles
- created by this driver.
-
- @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
-
-**/
-EFI_STATUS
-EFIAPI
-KbdControllerDriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- );
-
-/**
- Free the waiting key notify list.
-
- @param ListHead Pointer to list head
-
- @retval EFI_INVALID_PARAMETER ListHead is NULL
- @retval EFI_SUCCESS Sucess to free NotifyList
-**/
-EFI_STATUS
-KbdFreeNotifyList (
- IN OUT LIST_ENTRY *ListHead
- );
-
-//
-// DriverBinding Protocol Instance
-//
-EFI_DRIVER_BINDING_PROTOCOL gKeyboardControllerDriver = {
- KbdControllerDriverSupported,
- KbdControllerDriverStart,
- KbdControllerDriverStop,
- 0xa,
- NULL,
- NULL
-};
-
-/**
- Test controller is a keyboard Controller.
-
- @param This Pointer of EFI_DRIVER_BINDING_PROTOCOL
- @param Controller driver's controller
- @param RemainingDevicePath children device path
-
- @retval EFI_UNSUPPORTED controller is not floppy disk
- @retval EFI_SUCCESS controller is floppy disk
-**/
-EFI_STATUS
-EFIAPI
-KbdControllerDriverSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- EFI_STATUS Status;
- EFI_ISA_IO_PROTOCOL *IsaIo;
-
- //
- // Open the IO Abstraction(s) needed to perform the supported test
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- (VOID **) &IsaIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Use the ISA I/O Protocol to see if Controller is the Keyboard controller
- //
- if (IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x303) || IsaIo->ResourceList->Device.UID != 0) {
- Status = EFI_UNSUPPORTED;
- }
- //
- // Close the I/O Abstraction(s) used to perform the supported test
- //
- gBS->CloseProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- return Status;
-}
-
-/**
- Create KEYBOARD_CONSOLE_IN_DEV instance on controller.
-
- @param This Pointer of EFI_DRIVER_BINDING_PROTOCOL
- @param Controller driver controller handle
- @param RemainingDevicePath Children's device path
-
- @retval whether success to create floppy control instance.
-**/
-EFI_STATUS
-EFIAPI
-KbdControllerDriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- EFI_STATUS Status;
- EFI_STATUS Status1;
- EFI_ISA_IO_PROTOCOL *IsaIo;
- KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
- UINT8 Data;
- EFI_STATUS_CODE_VALUE StatusCode;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
-
- StatusCode = 0;
-
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Report that the keyboard is being enabled
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_ENABLE,
- ParentDevicePath
- );
-
- //
- // Get the ISA I/O Protocol on Controller's handle
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- (VOID **) &IsaIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- return EFI_INVALID_PARAMETER;
- }
- //
- // Allocate private data
- //
- ConsoleIn = AllocateZeroPool (sizeof (KEYBOARD_CONSOLE_IN_DEV));
- if (ConsoleIn == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;
- goto ErrorExit;
- }
- //
- // Setup the device instance
- //
- ConsoleIn->Signature = KEYBOARD_CONSOLE_IN_DEV_SIGNATURE;
- ConsoleIn->Handle = Controller;
- (ConsoleIn->ConIn).Reset = KeyboardEfiReset;
- (ConsoleIn->ConIn).ReadKeyStroke = KeyboardReadKeyStroke;
- ConsoleIn->DataRegisterAddress = KEYBOARD_8042_DATA_REGISTER;
- ConsoleIn->StatusRegisterAddress = KEYBOARD_8042_STATUS_REGISTER;
- ConsoleIn->CommandRegisterAddress = KEYBOARD_8042_COMMAND_REGISTER;
- ConsoleIn->IsaIo = IsaIo;
- ConsoleIn->DevicePath = ParentDevicePath;
-
- ConsoleIn->ConInEx.Reset = KeyboardEfiResetEx;
- ConsoleIn->ConInEx.ReadKeyStrokeEx = KeyboardReadKeyStrokeEx;
- ConsoleIn->ConInEx.SetState = KeyboardSetState;
- ConsoleIn->ConInEx.RegisterKeyNotify = KeyboardRegisterKeyNotify;
- ConsoleIn->ConInEx.UnregisterKeyNotify = KeyboardUnregisterKeyNotify;
-
- InitializeListHead (&ConsoleIn->NotifyList);
-
- //
- // Fix for random hangs in System waiting for the Key if no KBC is present in BIOS.
- // When KBC decode (IO port 0x60/0x64 decode) is not enabled,
- // KeyboardRead will read back as 0xFF and return status is EFI_SUCCESS.
- // So instead we read status register to detect after read if KBC decode is enabled.
- //
-
- //
- // Return code is ignored on purpose.
- //
- if (!PcdGetBool (PcdFastPS2Detection)) {
- KeyboardRead (ConsoleIn, &Data);
- if ((KeyReadStatusRegister (ConsoleIn) & (KBC_PARE | KBC_TIM)) == (KBC_PARE | KBC_TIM)) {
- //
- // If nobody decodes KBC I/O port, it will read back as 0xFF.
- // Check the Time-Out and Parity bit to see if it has an active KBC in system
- //
- Status = EFI_DEVICE_ERROR;
- StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_NOT_DETECTED;
- goto ErrorExit;
- }
- }
-
- //
- // Setup the WaitForKey event
- //
- Status = gBS->CreateEvent (
- EVT_NOTIFY_WAIT,
- TPL_NOTIFY,
- KeyboardWaitForKey,
- ConsoleIn,
- &((ConsoleIn->ConIn).WaitForKey)
- );
- if (EFI_ERROR (Status)) {
- Status = EFI_OUT_OF_RESOURCES;
- StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;
- goto ErrorExit;
- }
- //
- // Setup the WaitForKeyEx event
- //
- Status = gBS->CreateEvent (
- EVT_NOTIFY_WAIT,
- TPL_NOTIFY,
- KeyboardWaitForKeyEx,
- ConsoleIn,
- &(ConsoleIn->ConInEx.WaitForKeyEx)
- );
- if (EFI_ERROR (Status)) {
- Status = EFI_OUT_OF_RESOURCES;
- StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;
- goto ErrorExit;
- }
-
- // Setup a periodic timer, used for reading keystrokes at a fixed interval
- //
- Status = gBS->CreateEvent (
- EVT_TIMER | EVT_NOTIFY_SIGNAL,
- TPL_NOTIFY,
- KeyboardTimerHandler,
- ConsoleIn,
- &ConsoleIn->TimerEvent
- );
- if (EFI_ERROR (Status)) {
- Status = EFI_OUT_OF_RESOURCES;
- StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;
- goto ErrorExit;
- }
-
- Status = gBS->SetTimer (
- ConsoleIn->TimerEvent,
- TimerPeriodic,
- KEYBOARD_TIMER_INTERVAL
- );
- if (EFI_ERROR (Status)) {
- Status = EFI_OUT_OF_RESOURCES;
- StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;
- goto ErrorExit;
- }
-
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- KeyNotifyProcessHandler,
- ConsoleIn,
- &ConsoleIn->KeyNotifyProcessEvent
- );
- if (EFI_ERROR (Status)) {
- Status = EFI_OUT_OF_RESOURCES;
- StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;
- goto ErrorExit;
- }
-
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_PRESENCE_DETECT,
- ParentDevicePath
- );
-
- //
- // Reset the keyboard device
- //
- Status = ConsoleIn->ConInEx.Reset (&ConsoleIn->ConInEx, FeaturePcdGet (PcdPs2KbdExtendedVerification));
- if (EFI_ERROR (Status)) {
- Status = EFI_DEVICE_ERROR;
- StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_NOT_DETECTED;
- goto ErrorExit;
- }
-
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_DETECTED,
- ParentDevicePath
- );
-
- ConsoleIn->ControllerNameTable = NULL;
- AddUnicodeString2 (
- "eng",
- gPs2KeyboardComponentName.SupportedLanguages,
- &ConsoleIn->ControllerNameTable,
- L"PS/2 Keyboard Device",
- TRUE
- );
- AddUnicodeString2 (
- "en",
- gPs2KeyboardComponentName2.SupportedLanguages,
- &ConsoleIn->ControllerNameTable,
- L"PS/2 Keyboard Device",
- FALSE
- );
-
-
- //
- // Install protocol interfaces for the keyboard device.
- //
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Controller,
- &gEfiSimpleTextInProtocolGuid,
- &ConsoleIn->ConIn,
- &gEfiSimpleTextInputExProtocolGuid,
- &ConsoleIn->ConInEx,
- NULL
- );
- if (EFI_ERROR (Status)) {
- StatusCode = EFI_PERIPHERAL_KEYBOARD | EFI_P_EC_CONTROLLER_ERROR;
- goto ErrorExit;
- }
-
- return Status;
-
-ErrorExit:
- //
- // Report error code
- //
- if (StatusCode != 0) {
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- StatusCode,
- ParentDevicePath
- );
- }
-
- if ((ConsoleIn != NULL) && (ConsoleIn->ConIn.WaitForKey != NULL)) {
- gBS->CloseEvent (ConsoleIn->ConIn.WaitForKey);
- }
-
- if ((ConsoleIn != NULL) && (ConsoleIn->TimerEvent != NULL)) {
- gBS->CloseEvent (ConsoleIn->TimerEvent);
- }
- if ((ConsoleIn != NULL) && (ConsoleIn->ConInEx.WaitForKeyEx != NULL)) {
- gBS->CloseEvent (ConsoleIn->ConInEx.WaitForKeyEx);
- }
- if ((ConsoleIn != NULL) && (ConsoleIn->KeyNotifyProcessEvent != NULL)) {
- gBS->CloseEvent (ConsoleIn->KeyNotifyProcessEvent);
- }
- KbdFreeNotifyList (&ConsoleIn->NotifyList);
- if ((ConsoleIn != NULL) && (ConsoleIn->ControllerNameTable != NULL)) {
- FreeUnicodeStringTable (ConsoleIn->ControllerNameTable);
- }
- //
- // Since there will be no timer handler for keyboard input any more,
- // exhaust input data just in case there is still keyboard data left
- //
- if (ConsoleIn != NULL) {
- Status1 = EFI_SUCCESS;
- while (!EFI_ERROR (Status1) && (Status != EFI_DEVICE_ERROR)) {
- Status1 = KeyboardRead (ConsoleIn, &Data);;
- }
- }
-
- if (ConsoleIn != NULL) {
- gBS->FreePool (ConsoleIn);
- }
-
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- gBS->CloseProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- return Status;
-}
-
-/**
- Stop this driver on ControllerHandle. Support stopping any child handles
- created by this driver.
-
- @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
-
-**/
-EFI_STATUS
-EFIAPI
-KbdControllerDriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- )
-{
- EFI_STATUS Status;
- EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;
- KEYBOARD_CONSOLE_IN_DEV *ConsoleIn;
- UINT8 Data;
-
- //
- // Disable Keyboard
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiSimpleTextInProtocolGuid,
- (VOID **) &ConIn,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiSimpleTextInputExProtocolGuid,
- NULL,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- ConsoleIn = KEYBOARD_CONSOLE_IN_DEV_FROM_THIS (ConIn);
-
- //
- // Report that the keyboard is being disabled
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_KEYBOARD | EFI_P_PC_DISABLE,
- ConsoleIn->DevicePath
- );
-
- if (ConsoleIn->TimerEvent != NULL) {
- gBS->CloseEvent (ConsoleIn->TimerEvent);
- ConsoleIn->TimerEvent = NULL;
- }
-
- //
- // Since there will be no timer handler for keyboard input any more,
- // exhaust input data just in case there is still keyboard data left
- //
- Status = EFI_SUCCESS;
- while (!EFI_ERROR (Status)) {
- Status = KeyboardRead (ConsoleIn, &Data);;
- }
- //
- // Uninstall the SimpleTextIn and SimpleTextInEx protocols
- //
- Status = gBS->UninstallMultipleProtocolInterfaces (
- Controller,
- &gEfiSimpleTextInProtocolGuid,
- &ConsoleIn->ConIn,
- &gEfiSimpleTextInputExProtocolGuid,
- &ConsoleIn->ConInEx,
- NULL
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- gBS->CloseProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- //
- // Free other resources
- //
- if ((ConsoleIn->ConIn).WaitForKey != NULL) {
- gBS->CloseEvent ((ConsoleIn->ConIn).WaitForKey);
- (ConsoleIn->ConIn).WaitForKey = NULL;
- }
- if (ConsoleIn->ConInEx.WaitForKeyEx != NULL) {
- gBS->CloseEvent (ConsoleIn->ConInEx.WaitForKeyEx);
- ConsoleIn->ConInEx.WaitForKeyEx = NULL;
- }
- if (ConsoleIn->KeyNotifyProcessEvent != NULL) {
- gBS->CloseEvent (ConsoleIn->KeyNotifyProcessEvent);
- ConsoleIn->KeyNotifyProcessEvent = NULL;
- }
- KbdFreeNotifyList (&ConsoleIn->NotifyList);
- FreeUnicodeStringTable (ConsoleIn->ControllerNameTable);
- gBS->FreePool (ConsoleIn);
-
- return EFI_SUCCESS;
-}
-
-/**
- Free the waiting key notify list.
-
- @param ListHead Pointer to list head
-
- @retval EFI_INVALID_PARAMETER ListHead is NULL
- @retval EFI_SUCCESS Sucess to free NotifyList
-**/
-EFI_STATUS
-KbdFreeNotifyList (
- IN OUT LIST_ENTRY *ListHead
- )
-{
- KEYBOARD_CONSOLE_IN_EX_NOTIFY *NotifyNode;
-
- if (ListHead == NULL) {
- return EFI_INVALID_PARAMETER;
- }
- while (!IsListEmpty (ListHead)) {
- NotifyNode = CR (
- ListHead->ForwardLink,
- KEYBOARD_CONSOLE_IN_EX_NOTIFY,
- NotifyEntry,
- KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE
- );
- RemoveEntryList (ListHead->ForwardLink);
- gBS->FreePool (NotifyNode);
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- The module Entry Point for module Ps2Keyboard.
-
- @param[in] ImageHandle The firmware allocated handle for the EFI image.
- @param[in] SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The entry point is executed successfully.
- @retval other Some error occurs when executing this entry point.
-
-**/
-EFI_STATUS
-EFIAPI
-InitializePs2Keyboard(
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- //
- // Install driver model protocol(s).
- //
- Status = EfiLibInstallDriverBindingComponentName2 (
- ImageHandle,
- SystemTable,
- &gKeyboardControllerDriver,
- ImageHandle,
- &gPs2KeyboardComponentName,
- &gPs2KeyboardComponentName2
- );
- ASSERT_EFI_ERROR (Status);
-
-
- return Status;
-}
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h deleted file mode 100644 index 82aa5a64fa..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h +++ /dev/null @@ -1,565 +0,0 @@ -/** @file
- PS/2 keyboard driver header file
-
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
-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.
-
-**/
-
-#ifndef _PS2KEYBOARD_H_
-#define _PS2KEYBOARD_H_
-
-#include <Uefi.h>
-
-#include <Protocol/SimpleTextIn.h>
-#include <Protocol/SimpleTextInEx.h>
-#include <Protocol/IsaIo.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/Ps2Policy.h>
-
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/UefiLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/ReportStatusCodeLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/TimerLib.h>
-#include <Library/PcdLib.h>
-
-//
-// Global Variables
-//
-extern EFI_DRIVER_BINDING_PROTOCOL gKeyboardControllerDriver;
-extern EFI_COMPONENT_NAME_PROTOCOL gPs2KeyboardComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gPs2KeyboardComponentName2;
-
-//
-// Driver Private Data
-//
-#define KEYBOARD_CONSOLE_IN_DEV_SIGNATURE SIGNATURE_32 ('k', 'k', 'e', 'y')
-#define KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('k', 'c', 'e', 'n')
-
-typedef struct _KEYBOARD_CONSOLE_IN_EX_NOTIFY {
- UINTN Signature;
- EFI_KEY_DATA KeyData;
- EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;
- LIST_ENTRY NotifyEntry;
-} KEYBOARD_CONSOLE_IN_EX_NOTIFY;
-
-#define KEYBOARD_SCAN_CODE_MAX_COUNT 32
-typedef struct {
- UINT8 Buffer[KEYBOARD_SCAN_CODE_MAX_COUNT];
- UINTN Head;
- UINTN Tail;
-} SCAN_CODE_QUEUE;
-
-#define KEYBOARD_EFI_KEY_MAX_COUNT 256
-typedef struct {
- EFI_KEY_DATA Buffer[KEYBOARD_EFI_KEY_MAX_COUNT];
- UINTN Head;
- UINTN Tail;
-} EFI_KEY_QUEUE;
-
-typedef struct {
- UINTN Signature;
-
- EFI_HANDLE Handle;
- EFI_SIMPLE_TEXT_INPUT_PROTOCOL ConIn;
- EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL ConInEx;
- EFI_ISA_IO_PROTOCOL *IsaIo;
-
- EFI_EVENT TimerEvent;
-
- UINT32 DataRegisterAddress;
- UINT32 StatusRegisterAddress;
- UINT32 CommandRegisterAddress;
-
- BOOLEAN LeftCtrl;
- BOOLEAN RightCtrl;
- BOOLEAN LeftAlt;
- BOOLEAN RightAlt;
- BOOLEAN LeftShift;
- BOOLEAN RightShift;
- BOOLEAN LeftLogo;
- BOOLEAN RightLogo;
- BOOLEAN Menu;
- BOOLEAN SysReq;
-
- BOOLEAN CapsLock;
- BOOLEAN NumLock;
- BOOLEAN ScrollLock;
-
- BOOLEAN IsSupportPartialKey;
- //
- // Queue storing key scancodes
- //
- SCAN_CODE_QUEUE ScancodeQueue;
- EFI_KEY_QUEUE EfiKeyQueue;
- EFI_KEY_QUEUE EfiKeyQueueForNotify;
-
- //
- // Error state
- //
- BOOLEAN KeyboardErr;
-
- EFI_UNICODE_STRING_TABLE *ControllerNameTable;
-
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- //
- // Notification Function List
- //
- LIST_ENTRY NotifyList;
- EFI_EVENT KeyNotifyProcessEvent;
-} KEYBOARD_CONSOLE_IN_DEV;
-
-#define KEYBOARD_CONSOLE_IN_DEV_FROM_THIS(a) CR (a, KEYBOARD_CONSOLE_IN_DEV, ConIn, KEYBOARD_CONSOLE_IN_DEV_SIGNATURE)
-#define TEXT_INPUT_EX_KEYBOARD_CONSOLE_IN_DEV_FROM_THIS(a) \
- CR (a, \
- KEYBOARD_CONSOLE_IN_DEV, \
- ConInEx, \
- KEYBOARD_CONSOLE_IN_DEV_SIGNATURE \
- )
-
-#define TABLE_END 0x0
-
-//
-// Driver entry point
-//
-/**
- The user Entry Point for module Ps2Keyboard. The user code starts with this function.
-
- @param[in] ImageHandle The firmware allocated handle for the EFI image.
- @param[in] SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The entry point is executed successfully.
- @retval other Some error occurs when executing this entry point.
-
-**/
-EFI_STATUS
-EFIAPI
-InstallPs2KeyboardDriver (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-#define KEYBOARD_8042_DATA_REGISTER 0x60
-#define KEYBOARD_8042_STATUS_REGISTER 0x64
-#define KEYBOARD_8042_COMMAND_REGISTER 0x64
-
-#define KEYBOARD_KBEN 0xF4
-#define KEYBOARD_CMDECHO_ACK 0xFA
-
-#define KEYBOARD_MAX_TRY 256 // 256
-#define KEYBOARD_TIMEOUT 65536 // 0.07s
-#define KEYBOARD_WAITFORVALUE_TIMEOUT 1000000 // 1s
-#define KEYBOARD_BAT_TIMEOUT 4000000 // 4s
-#define KEYBOARD_TIMER_INTERVAL 200000 // 0.02s
-#define SCANCODE_EXTENDED0 0xE0
-#define SCANCODE_EXTENDED1 0xE1
-#define SCANCODE_CTRL_MAKE 0x1D
-#define SCANCODE_CTRL_BREAK 0x9D
-#define SCANCODE_ALT_MAKE 0x38
-#define SCANCODE_ALT_BREAK 0xB8
-#define SCANCODE_LEFT_SHIFT_MAKE 0x2A
-#define SCANCODE_LEFT_SHIFT_BREAK 0xAA
-#define SCANCODE_RIGHT_SHIFT_MAKE 0x36
-#define SCANCODE_RIGHT_SHIFT_BREAK 0xB6
-#define SCANCODE_CAPS_LOCK_MAKE 0x3A
-#define SCANCODE_NUM_LOCK_MAKE 0x45
-#define SCANCODE_SCROLL_LOCK_MAKE 0x46
-#define SCANCODE_DELETE_MAKE 0x53
-#define SCANCODE_LEFT_LOGO_MAKE 0x5B //GUI key defined in Keyboard scan code
-#define SCANCODE_LEFT_LOGO_BREAK 0xDB
-#define SCANCODE_RIGHT_LOGO_MAKE 0x5C
-#define SCANCODE_RIGHT_LOGO_BREAK 0xDC
-#define SCANCODE_MENU_MAKE 0x5D //APPS key defined in Keyboard scan code
-#define SCANCODE_MENU_BREAK 0xDD
-#define SCANCODE_SYS_REQ_MAKE 0x37
-#define SCANCODE_SYS_REQ_BREAK 0xB7
-#define SCANCODE_SYS_REQ_MAKE_WITH_ALT 0x54
-#define SCANCODE_SYS_REQ_BREAK_WITH_ALT 0xD4
-
-#define SCANCODE_MAX_MAKE 0x60
-
-
-#define KEYBOARD_STATUS_REGISTER_HAS_OUTPUT_DATA BIT0 ///< 0 - Output register has no data; 1 - Output register has data
-#define KEYBOARD_STATUS_REGISTER_HAS_INPUT_DATA BIT1 ///< 0 - Input register has no data; 1 - Input register has data
-#define KEYBOARD_STATUS_REGISTER_SYSTEM_FLAG BIT2 ///< Set to 0 after power on reset
-#define KEYBOARD_STATUS_REGISTER_INPUT_DATA_TYPE BIT3 ///< 0 - Data in input register is data; 1 - Data in input register is command
-#define KEYBOARD_STATUS_REGISTER_ENABLE_FLAG BIT4 ///< 0 - Keyboard is disable; 1 - Keyboard is enable
-#define KEYBOARD_STATUS_REGISTER_TRANSMIT_TIMEOUT BIT5 ///< 0 - Transmit is complete without timeout; 1 - Transmit is timeout without complete
-#define KEYBOARD_STATUS_REGISTER_RECEIVE_TIMEOUT BIT6 ///< 0 - Receive is complete without timeout; 1 - Receive is timeout without complete
-#define KEYBOARD_STATUS_REGISTER_PARITY BIT7 ///< 0 - Odd parity; 1 - Even parity
-
-#define KEYBOARD_8042_COMMAND_READ 0x20
-#define KEYBOARD_8042_COMMAND_WRITE 0x60
-#define KEYBOARD_8042_COMMAND_DISABLE_MOUSE_INTERFACE 0xA7
-#define KEYBOARD_8042_COMMAND_ENABLE_MOUSE_INTERFACE 0xA8
-#define KEYBOARD_8042_COMMAND_CONTROLLER_SELF_TEST 0xAA
-#define KEYBOARD_8042_COMMAND_KEYBOARD_INTERFACE_SELF_TEST 0xAB
-#define KEYBOARD_8042_COMMAND_DISABLE_KEYBOARD_INTERFACE 0xAD
-
-#define KEYBOARD_8048_COMMAND_CLEAR_OUTPUT_DATA 0xF4
-#define KEYBOARD_8048_COMMAND_RESET 0xFF
-#define KEYBOARD_8048_COMMAND_SELECT_SCAN_CODE_SET 0xF0
-
-#define KEYBOARD_8048_RETURN_8042_BAT_SUCCESS 0xAA
-#define KEYBOARD_8048_RETURN_8042_BAT_ERROR 0xFC
-#define KEYBOARD_8048_RETURN_8042_ACK 0xFA
-
-
-//
-// Keyboard Controller Status
-//
-#define KBC_PARE 0x80 // Parity Error
-#define KBC_TIM 0x40 // General Time Out
-
-//
-// Other functions that are used among .c files
-//
-/**
- Show keyboard status lights according to
- indicators in ConsoleIn.
-
- @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV
-
- @return status
-
-**/
-EFI_STATUS
-UpdateStatusLights (
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
- );
-
-/**
- write key to keyboard.
-
- @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV
- @param Data value wanted to be written
-
- @retval EFI_TIMEOUT - GC_TODO: Add description for return value
- @retval EFI_SUCCESS - GC_TODO: Add description for return value
-
-**/
-EFI_STATUS
-KeyboardRead (
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
- OUT UINT8 *Data
- );
-
-/**
- Get scancode from scancode buffer and translate into EFI-scancode and unicode defined by EFI spec.
-
- The function is always called in TPL_NOTIFY.
-
- @param ConsoleIn KEYBOARD_CONSOLE_IN_DEV instance pointer
-
-**/
-VOID
-KeyGetchar (
- IN OUT KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
- );
-
-/**
- Process key notify.
-
- @param Event Indicates the event that invoke this function.
- @param Context Indicates the calling context.
-**/
-VOID
-EFIAPI
-KeyNotifyProcessHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
-
-/**
- Perform 8042 controller and keyboard Initialization.
- If ExtendedVerification is TRUE, do additional test for
- the keyboard interface
-
- @param ConsoleIn - KEYBOARD_CONSOLE_IN_DEV instance pointer
- @param ExtendedVerification - indicates a thorough initialization
-
- @retval EFI_DEVICE_ERROR Fail to init keyboard
- @retval EFI_SUCCESS Success to init keyboard
-**/
-EFI_STATUS
-InitKeyboard (
- IN OUT KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
- IN BOOLEAN ExtendedVerification
- );
-
-/**
- Disable the keyboard interface of the 8042 controller.
-
- @param ConsoleIn - the device instance
-
- @return status of issuing disable command
-
-**/
-EFI_STATUS
-DisableKeyboard (
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
- );
-
-/**
- Timer event handler: read a series of scancodes from 8042
- and put them into memory scancode buffer.
- it read as much scancodes to either fill
- the memory buffer or empty the keyboard buffer.
- It is registered as running under TPL_NOTIFY
-
- @param Event - The timer event
- @param Context - A KEYBOARD_CONSOLE_IN_DEV pointer
-
-**/
-VOID
-EFIAPI
-KeyboardTimerHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
-
-/**
- logic reset keyboard
- Implement SIMPLE_TEXT_IN.Reset()
- Perform 8042 controller and keyboard initialization
-
- @param This Pointer to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL
- @param ExtendedVerification Indicate that the driver may perform a more
- exhaustive verification operation of the device during
- reset, now this par is ignored in this driver
-
-**/
-EFI_STATUS
-EFIAPI
-KeyboardEfiReset (
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- );
-
-/**
- Implement SIMPLE_TEXT_IN.ReadKeyStroke().
- Retrieve key values for driver user.
-
- @param This Pointer to instance of EFI_SIMPLE_TEXT_INPUT_PROTOCOL
- @param Key The output buffer for key value
-
- @retval EFI_SUCCESS success to read key stroke
-**/
-EFI_STATUS
-EFIAPI
-KeyboardReadKeyStroke (
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- OUT EFI_INPUT_KEY *Key
- );
-
-/**
- Event notification function for SIMPLE_TEXT_IN.WaitForKey event
- Signal the event if there is key available
-
- @param Event the event object
- @param Context waitting context
-
-**/
-VOID
-EFIAPI
-KeyboardWaitForKey (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
-
-/**
- Read status register.
-
- @param ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV
-
- @return value in status register
-
-**/
-UINT8
-KeyReadStatusRegister (
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
- );
-
-/**
- Check whether there is Ps/2 Keyboard device in system by 0xF4 Keyboard Command
- If Keyboard receives 0xF4, it will respond with 'ACK'. If it doesn't respond, the device
- should not be in system.
-
- @param[in] ConsoleIn Pointer to instance of KEYBOARD_CONSOLE_IN_DEV
-
- @retval TRUE Keyboard in System.
- @retval FALSE Keyboard not in System.
-**/
-BOOLEAN
-EFIAPI
-CheckKeyboardConnect (
- IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
- );
-
-/**
- Event notification function for SIMPLE_TEXT_INPUT_EX_PROTOCOL.WaitForKeyEx event
- Signal the event if there is key available
-
- @param Event event object
- @param Context waiting context
-
-**/
-VOID
-EFIAPI
-KeyboardWaitForKeyEx (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
-
-//
-// Simple Text Input Ex protocol function prototypes
-//
-
-/**
- Reset the input device and optionaly run diagnostics
-
- @param This - Protocol instance pointer.
- @param ExtendedVerification - Driver may perform diagnostics on reset.
-
- @retval EFI_SUCCESS - The device was reset.
- @retval EFI_DEVICE_ERROR - The device is not functioning properly and could
- not be reset.
-
-**/
-EFI_STATUS
-EFIAPI
-KeyboardEfiResetEx (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- );
-
-/**
- Reads the next keystroke from the input device. The WaitForKey Event can
- be used to test for existance of a keystroke via WaitForEvent () call.
-
-
- @param This - Protocol instance pointer.
- @param KeyData - A pointer to a buffer that is filled in with the keystroke
- state data for the key that was pressed.
-
- @retval EFI_SUCCESS - The keystroke information was returned.
- @retval EFI_NOT_READY - There was no keystroke data availiable.
- @retval EFI_DEVICE_ERROR - The keystroke information was not returned due to
- hardware errors.
- @retval EFI_INVALID_PARAMETER - KeyData is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-KeyboardReadKeyStrokeEx (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- OUT EFI_KEY_DATA *KeyData
- );
-
-/**
- Set certain state for the input device.
-
- @param This - Protocol instance pointer.
- @param KeyToggleState - A pointer to the EFI_KEY_TOGGLE_STATE to set the
- state for the input device.
-
- @retval EFI_SUCCESS - The device state was set successfully.
- @retval EFI_DEVICE_ERROR - The device is not functioning correctly and could
- not have the setting adjusted.
- @retval EFI_UNSUPPORTED - The device does not have the ability to set its state.
- @retval EFI_INVALID_PARAMETER - KeyToggleState is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-KeyboardSetState (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- IN EFI_KEY_TOGGLE_STATE *KeyToggleState
- );
-
-/**
- Register a notification function for a particular keystroke for the input device.
-
- @param This - Protocol instance pointer.
- @param KeyData - A pointer to a buffer that is filled in with the keystroke
- information data for the key that was pressed.
- @param KeyNotificationFunction - Points to the function to be called when the key
- sequence is typed specified by KeyData.
- @param NotifyHandle - Points to the unique handle assigned to the registered notification.
-
- @retval EFI_SUCCESS - The notification function was registered successfully.
- @retval EFI_OUT_OF_RESOURCES - Unable to allocate resources for necesssary data structures.
- @retval EFI_INVALID_PARAMETER - KeyData or NotifyHandle is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-KeyboardRegisterKeyNotify (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- IN EFI_KEY_DATA *KeyData,
- IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,
- OUT VOID **NotifyHandle
- );
-
-/**
- Remove a registered notification function from a particular keystroke.
-
- @param This - Protocol instance pointer.
- @param NotificationHandle - The handle of the notification function being unregistered.
-
-
- @retval EFI_SUCCESS - The notification function was unregistered successfully.
- @retval EFI_INVALID_PARAMETER - The NotificationHandle is invalid.
- @retval EFI_NOT_FOUND - Can not find the matching entry in database.
-
-**/
-EFI_STATUS
-EFIAPI
-KeyboardUnregisterKeyNotify (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
- IN VOID *NotificationHandle
- );
-
-/**
- Push one key data to the EFI key buffer.
-
- @param Queue Pointer to instance of EFI_KEY_QUEUE.
- @param KeyData The key data to push.
-**/
-VOID
-PushEfikeyBufTail (
- IN EFI_KEY_QUEUE *Queue,
- IN EFI_KEY_DATA *KeyData
- );
-
-/**
- Judge whether is a registed key
-
- @param RegsiteredData A pointer to a buffer that is filled in with the keystroke
- state data for the key that was registered.
- @param InputData A pointer to a buffer that is filled in with the keystroke
- state data for the key that was pressed.
-
- @retval TRUE Key be pressed matches a registered key.
- @retval FLASE Match failed.
-
-**/
-BOOLEAN
-IsKeyRegistered (
- IN EFI_KEY_DATA *RegsiteredData,
- IN EFI_KEY_DATA *InputData
- );
-
-#endif
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.uni b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.uni deleted file mode 100644 index 9387a85fe4..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.uni +++ /dev/null @@ -1,23 +0,0 @@ -// /** @file
-// Ps2 Keyboard Driver.
-//
-// Ps2 Keyboard Driver for UEFI. The keyboard type implemented follows IBM
-// compatible PS2 protocol using Scan Code Set 1.
-//
-// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
-//
-// 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.
-//
-// **/
-
-
-#string STR_MODULE_ABSTRACT #language en-US "Ps2 Keyboard Driver"
-
-#string STR_MODULE_DESCRIPTION #language en-US "Ps2 Keyboard Driver for UEFI. The keyboard type implemented follows IBM compatible PS2 protocol using Scan Code Set 1."
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxeExtra.uni b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxeExtra.uni deleted file mode 100644 index b5356239e8..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxeExtra.uni +++ /dev/null @@ -1,20 +0,0 @@ -// /** @file
-// Ps2KeyboardDxe Localized Strings and Content
-//
-// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
-//
-// 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.
-//
-// **/
-
-#string STR_PROPERTIES_MODULE_NAME
-#language en-US
-"PS2 Keyboard DXE Driver"
-
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf b/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf deleted file mode 100644 index 9d72cebcb2..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf +++ /dev/null @@ -1,85 +0,0 @@ -## @file
-# Ps2 Keyboard Driver.
-#
-# Ps2 Keyboard Driver for UEFI. The keyboard type implemented follows IBM
-# compatible PS2 protocol using Scan Code Set 1.
-#
-# Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
-#
-# 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.
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = Ps2KeyboardDxe
- MODULE_UNI_FILE = Ps2KeyboardDxe.uni
- FILE_GUID = 3DC82376-637B-40a6-A8FC-A565417F2C38
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = InitializePs2Keyboard
-
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-# DRIVER_BINDING = gKeyboardControllerDriver;
-# COMPONENT_NAME = gPs2KeyboardComponentName;
-# COMPONENT_NAME2 = gPs2KeyboardComponentName2;
-#
-
-[Sources]
- ComponentName.c
- Ps2Keyboard.h
- Ps2KbdCtrller.c
- Ps2KbdTextIn.c
- Ps2Keyboard.c
-
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
-
-[LibraryClasses]
- MemoryAllocationLib
- UefiRuntimeServicesTableLib
- DebugLib
- ReportStatusCodeLib
- UefiBootServicesTableLib
- UefiLib
- UefiDriverEntryPoint
- BaseLib
- BaseMemoryLib
- TimerLib
- PcdLib
-
-[Protocols]
- gEfiSimpleTextInProtocolGuid ## BY_START
- gEfiSimpleTextInputExProtocolGuid ## BY_START
- gEfiPs2PolicyProtocolGuid ## SOMETIMES_CONSUMES
- gEfiIsaIoProtocolGuid ## TO_START
- gEfiDevicePathProtocolGuid ## TO_START
-
-[FeaturePcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdPs2KbdExtendedVerification ## CONSUMES
-
-[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdFastPS2Detection ## SOMETIMES_CONSUMES
-
-#
-# [Event]
-#
-# ##
-# # Timer event used to read key strokes at a regular interval.
-# #
-# EVENT_TYPE_PERIODIC_TIMER ## CONSUMES
-#
-
-[UserExtensions.TianoCore."ExtraFiles"]
- Ps2KeyboardDxeExtra.uni
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/CommPs2.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/CommPs2.c deleted file mode 100644 index 5aa17059a3..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/CommPs2.c +++ /dev/null @@ -1,923 +0,0 @@ -/** @file
- PS2 Mouse Communication Interface.
-
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
-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 "Ps2MouseAbsolutePointer.h"
-#include "CommPs2.h"
-
-UINT8 SampleRateTbl[MaxSampleRate] = { 0xa, 0x14, 0x28, 0x3c, 0x50, 0x64, 0xc8 };
-
-UINT8 ResolutionTbl[MaxResolution] = { 0, 1, 2, 3 };
-
-/**
- Issue self test command via IsaIo interface.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return EFI_SUCCESS Success to do keyboard self testing.
- @return others Fail to do keyboard self testing.
-**/
-EFI_STATUS
-KbcSelfTest (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- )
-{
- EFI_STATUS Status;
- UINT8 Data;
-
- //
- // Keyboard controller self test
- //
- Status = Out8042Command (IsaIo, SELF_TEST);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Read return code
- //
- Status = In8042Data (IsaIo, &Data);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if (Data != 0x55) {
- return EFI_DEVICE_ERROR;
- }
- //
- // Set system flag
- //
- Status = Out8042Command (IsaIo, READ_CMD_BYTE);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = In8042Data (IsaIo, &Data);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = Out8042Command (IsaIo, WRITE_CMD_BYTE);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Data |= CMD_SYS_FLAG;
- Status = Out8042Data (IsaIo, Data);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Issue command to enable keyboard AUX functionality.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-KbcEnableAux (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- )
-{
- //
- // Send 8042 enable mouse command
- //
- return Out8042Command (IsaIo, ENABLE_AUX);
-}
-
-/**
- Issue command to disable keyboard AUX functionality.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-KbcDisableAux (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- )
-{
- //
- // Send 8042 disable mouse command
- //
- return Out8042Command (IsaIo, DISABLE_AUX);
-}
-
-/**
- Issue command to enable keyboard.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-KbcEnableKb (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- )
-{
- //
- // Send 8042 enable keyboard command
- //
- return Out8042Command (IsaIo, ENABLE_KB);
-}
-
-/**
- Issue command to disable keyboard.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-KbcDisableKb (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- )
-{
- //
- // Send 8042 disable keyboard command
- //
- return Out8042Command (IsaIo, DISABLE_KB);
-}
-
-/**
- Issue command to check keyboard status.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param KeyboardEnable return whether keyboard is enable.
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-CheckKbStatus (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- OUT BOOLEAN *KeyboardEnable
- )
-{
- EFI_STATUS Status;
- UINT8 Data;
-
- //
- // Send command to read KBC command byte
- //
- Status = Out8042Command (IsaIo, READ_CMD_BYTE);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = In8042Data (IsaIo, &Data);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Check keyboard enable or not
- //
- if ((Data & CMD_KB_STS) == CMD_KB_DIS) {
- *KeyboardEnable = FALSE;
- } else {
- *KeyboardEnable = TRUE;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Issue command to reset keyboard.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-PS2MouseReset (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- )
-{
- EFI_STATUS Status;
- UINT8 Data;
-
- Status = Out8042AuxCommand (IsaIo, RESET_CMD, FALSE);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = In8042AuxData (IsaIo, &Data);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Check BAT Complete Code
- //
- if (Data != PS2MOUSE_BAT1) {
- return EFI_DEVICE_ERROR;
- }
-
- Status = In8042AuxData (IsaIo, &Data);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Check BAT Complete Code
- //
- if (Data != PS2MOUSE_BAT2) {
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Issue command to set mouse's sample rate
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param SampleRate value of sample rate
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-PS2MouseSetSampleRate (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN MOUSE_SR SampleRate
- )
-{
- EFI_STATUS Status;
-
- //
- // Send auxiliary command to set mouse sample rate
- //
- Status = Out8042AuxCommand (IsaIo, SETSR_CMD, FALSE);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = Out8042AuxData (IsaIo, SampleRateTbl[SampleRate]);
-
- return Status;
-}
-
-/**
- Issue command to set mouse's resolution.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Resolution value of resolution
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-PS2MouseSetResolution (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN MOUSE_RE Resolution
- )
-{
- EFI_STATUS Status;
-
- //
- // Send auxiliary command to set mouse resolution
- //
- Status = Out8042AuxCommand (IsaIo, SETRE_CMD, FALSE);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = Out8042AuxData (IsaIo, ResolutionTbl[Resolution]);
-
- return Status;
-}
-
-/**
- Issue command to set mouse's scaling.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Scaling value of scaling
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-PS2MouseSetScaling (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN MOUSE_SF Scaling
- )
-{
- UINT8 Command;
-
- Command = (UINT8) (Scaling == Scaling1 ? SETSF1_CMD : SETSF2_CMD);
-
- //
- // Send auxiliary command to set mouse scaling data
- //
- return Out8042AuxCommand (IsaIo, Command, FALSE);
-}
-
-/**
- Issue command to enable Ps2 mouse.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-PS2MouseEnable (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- )
-{
- //
- // Send auxiliary command to enable mouse
- //
- return Out8042AuxCommand (IsaIo, ENABLE_CMD, FALSE);
-}
-
-/**
- Get mouse packet . Only care first 3 bytes
-
- @param MouseAbsolutePointerDev Pointer to PS2 Absolute Pointer Simulation Device Private Data Structure
-
- @retval EFI_NOT_READY Mouse Device not ready to input data packet, or some error happened during getting the packet
- @retval EFI_SUCCESS The data packet is gotten successfully.
-
-**/
-EFI_STATUS
-PS2MouseGetPacket (
- PS2_MOUSE_ABSOLUTE_POINTER_DEV *MouseAbsolutePointerDev
- )
-
-{
- EFI_STATUS Status;
- BOOLEAN KeyboardEnable;
- UINT8 Packet[PS2_PACKET_LENGTH];
- UINT8 Data;
- UINTN Count;
- UINTN State;
- INT16 RelativeMovementX;
- INT16 RelativeMovementY;
- BOOLEAN LButton;
- BOOLEAN RButton;
-
- KeyboardEnable = FALSE;
- Count = 1;
- State = PS2_READ_BYTE_ONE;
-
- //
- // State machine to get mouse packet
- //
- while (1) {
-
- switch (State) {
- case PS2_READ_BYTE_ONE:
- //
- // Read mouse first byte data, if failed, immediately return
- //
- KbcDisableAux (MouseAbsolutePointerDev->IsaIo);
- Status = PS2MouseRead (MouseAbsolutePointerDev->IsaIo, &Data, &Count, State);
- if (EFI_ERROR (Status)) {
- KbcEnableAux (MouseAbsolutePointerDev->IsaIo);
- return EFI_NOT_READY;
- }
-
- if (Count != 1) {
- KbcEnableAux (MouseAbsolutePointerDev->IsaIo);
- return EFI_NOT_READY;
- }
-
- if (IS_PS2_SYNC_BYTE (Data)) {
- Packet[0] = Data;
- State = PS2_READ_DATA_BYTE;
-
- CheckKbStatus (MouseAbsolutePointerDev->IsaIo, &KeyboardEnable);
- KbcDisableKb (MouseAbsolutePointerDev->IsaIo);
- KbcEnableAux (MouseAbsolutePointerDev->IsaIo);
- }
- break;
-
- case PS2_READ_DATA_BYTE:
- Count = 2;
- Status = PS2MouseRead (MouseAbsolutePointerDev->IsaIo, (Packet + 1), &Count, State);
- if (EFI_ERROR (Status)) {
- if (KeyboardEnable) {
- KbcEnableKb (MouseAbsolutePointerDev->IsaIo);
- }
-
- return EFI_NOT_READY;
- }
-
- if (Count != 2) {
- if (KeyboardEnable) {
- KbcEnableKb (MouseAbsolutePointerDev->IsaIo);
- }
-
- return EFI_NOT_READY;
- }
-
- State = PS2_PROCESS_PACKET;
- break;
-
- case PS2_PROCESS_PACKET:
- if (KeyboardEnable) {
- KbcEnableKb (MouseAbsolutePointerDev->IsaIo);
- }
- //
- // Decode the packet
- //
- RelativeMovementX = Packet[1];
- RelativeMovementY = Packet[2];
- //
- // Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0
- // Byte 0 | Y overflow | X overflow | Y sign bit | X sign bit | Always 1 | Middle Btn | Right Btn | Left Btn
- // Byte 1 | 8 bit X Movement
- // Byte 2 | 8 bit Y Movement
- //
- // X sign bit + 8 bit X Movement : 9-bit signed twos complement integer that presents the relative displacement of the device in the X direction since the last data transmission.
- // Y sign bit + 8 bit Y Movement : Same as X sign bit + 8 bit X Movement.
- //
- //
- // First, Clear X and Y high 8 bits
- //
- RelativeMovementX = (INT16) (RelativeMovementX & 0xFF);
- RelativeMovementY = (INT16) (RelativeMovementY & 0xFF);
- //
- // Second, if the 9-bit signed twos complement integer is negative, set the high 8 bit 0xff
- //
- if ((Packet[0] & 0x10) != 0) {
- RelativeMovementX = (INT16) (RelativeMovementX | 0xFF00);
- }
- if ((Packet[0] & 0x20) != 0) {
- RelativeMovementY = (INT16) (RelativeMovementY | 0xFF00);
- }
-
-
- RButton = (UINT8) (Packet[0] & 0x2);
- LButton = (UINT8) (Packet[0] & 0x1);
-
- //
- // Update mouse state
- //
- MouseAbsolutePointerDev->State.CurrentX += RelativeMovementX;
- MouseAbsolutePointerDev->State.CurrentY -= RelativeMovementY;
- MouseAbsolutePointerDev->State.CurrentZ = 0;
- MouseAbsolutePointerDev->State.ActiveButtons = (UINT8) (LButton || RButton) & 0x3;
- MouseAbsolutePointerDev->StateChanged = TRUE;
-
- return EFI_SUCCESS;
- }
- }
-}
-
-/**
- Read data via IsaIo protocol with given number.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Buffer Buffer receive data of mouse
- @param BufSize The size of buffer
- @param State Check input or read data
-
- @return status of reading mouse data.
-**/
-EFI_STATUS
-PS2MouseRead (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- OUT VOID *Buffer,
- IN OUT UINTN *BufSize,
- IN UINTN State
- )
-{
- EFI_STATUS Status;
- UINTN BytesRead;
-
- Status = EFI_SUCCESS;
- BytesRead = 0;
-
- if (State == PS2_READ_BYTE_ONE) {
- //
- // Check input for mouse
- //
- Status = CheckForInput (IsaIo);
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
- }
-
- while (BytesRead < *BufSize) {
-
- Status = WaitOutputFull (IsaIo, TIMEOUT);
- if (EFI_ERROR (Status)) {
- break;
- }
-
- IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, Buffer);
-
- BytesRead++;
- Buffer = (UINT8 *) Buffer + 1;
- }
- //
- // Verify the correct number of bytes read
- //
- if (BytesRead == 0 || BytesRead != *BufSize) {
- Status = EFI_NOT_FOUND;
- }
-
- *BufSize = BytesRead;
- return Status;
-}
-
-//
-// 8042 I/O function
-//
-/**
- I/O work flow of outing 8042 command.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Command I/O command.
-
- @retval EFI_SUCCESS Success to execute I/O work flow
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-Out8042Command (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINT8 Command
- )
-{
- EFI_STATUS Status;
- UINT8 Data;
-
- //
- // Wait keyboard controller input buffer empty
- //
- Status = WaitInputEmpty (IsaIo, TIMEOUT);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Send command
- //
- Data = Command;
- IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);
-
- Status = WaitInputEmpty (IsaIo, TIMEOUT);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- I/O work flow of outing 8042 data.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Data Data value
-
- @retval EFI_SUCCESS Success to execute I/O work flow
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-Out8042Data (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINT8 Data
- )
-{
- EFI_STATUS Status;
- UINT8 Temp;
- //
- // Wait keyboard controller input buffer empty
- //
- Status = WaitInputEmpty (IsaIo, TIMEOUT);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Temp = Data;
- IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, &Temp);
-
- Status = WaitInputEmpty (IsaIo, TIMEOUT);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- I/O work flow of in 8042 data.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Data Data value
-
- @retval EFI_SUCCESS Success to execute I/O work flow
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-In8042Data (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN OUT UINT8 *Data
- )
-{
- UINTN Delay;
- UINT8 Temp;
-
- Delay = TIMEOUT / 50;
-
- do {
- IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Temp);
-
- //
- // Check keyboard controller status bit 0(output buffer status)
- //
- if ((Temp & KBC_OUTB) == KBC_OUTB) {
- break;
- }
-
- gBS->Stall (50);
- Delay--;
- } while (Delay != 0);
-
- if (Delay == 0) {
- return EFI_TIMEOUT;
- }
-
- IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, Data);
-
- return EFI_SUCCESS;
-}
-
-/**
- I/O work flow of outing 8042 Aux command.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Command Aux I/O command
- @param Resend Whether need resend the Aux command.
-
- @retval EFI_SUCCESS Success to execute I/O work flow
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-Out8042AuxCommand (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINT8 Command,
- IN BOOLEAN Resend
- )
-{
- EFI_STATUS Status;
- UINT8 Data;
-
- //
- // Wait keyboard controller input buffer empty
- //
- Status = WaitInputEmpty (IsaIo, TIMEOUT);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Send write to auxiliary device command
- //
- Data = WRITE_AUX_DEV;
- IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);
-
- Status = WaitInputEmpty (IsaIo, TIMEOUT);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Send auxiliary device command
- //
- IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, &Command);
-
- //
- // Read return code
- //
- Status = In8042AuxData (IsaIo, &Data);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if (Data == PS2_ACK) {
- //
- // Receive mouse acknowledge, command send success
- //
- return EFI_SUCCESS;
-
- } else if (Resend) {
- //
- // Resend fail
- //
- return EFI_DEVICE_ERROR;
-
- } else if (Data == PS2_RESEND) {
- //
- // Resend command
- //
- Status = Out8042AuxCommand (IsaIo, Command, TRUE);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- } else {
- //
- // Invalid return code
- //
- return EFI_DEVICE_ERROR;
-
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- I/O work flow of outing 8042 Aux data.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Data Buffer holding return value
-
- @retval EFI_SUCCESS Success to execute I/O work flow.
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-Out8042AuxData (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINT8 Data
- )
-{
- EFI_STATUS Status;
- UINT8 Temp;
- //
- // Wait keyboard controller input buffer empty
- //
- Status = WaitInputEmpty (IsaIo, TIMEOUT);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Send write to auxiliary device command
- //
- Temp = WRITE_AUX_DEV;
- IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Temp);
-
- Status = WaitInputEmpty (IsaIo, TIMEOUT);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Temp = Data;
- IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, &Temp);
-
- Status = WaitInputEmpty (IsaIo, TIMEOUT);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- I/O work flow of in 8042 Aux data.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Data Buffer holding return value.
-
- @retval EFI_SUCCESS Success to execute I/O work flow
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-In8042AuxData (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN OUT UINT8 *Data
- )
-{
- EFI_STATUS Status;
-
- //
- // wait for output data
- //
- Status = WaitOutputFull (IsaIo, BAT_TIMEOUT);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, Data);
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Check keyboard controller status, if it is output buffer full and for auxiliary device.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @retval EFI_SUCCESS Keyboard controller is ready
- @retval EFI_NOT_READY Keyboard controller is not ready
-**/
-EFI_STATUS
-CheckForInput (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- )
-{
- UINT8 Data;
-
- IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);
-
- //
- // Check keyboard controller status, if it is output buffer full and for auxiliary device
- //
- if ((Data & (KBC_OUTB | KBC_AUXB)) != (KBC_OUTB | KBC_AUXB)) {
- return EFI_NOT_READY;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- I/O work flow to wait input buffer empty in given time.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Timeout Wating time.
-
- @retval EFI_TIMEOUT if input is still not empty in given time.
- @retval EFI_SUCCESS input is empty.
-**/
-EFI_STATUS
-WaitInputEmpty (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINTN Timeout
- )
-{
- UINTN Delay;
- UINT8 Data;
-
- Delay = Timeout / 50;
-
- do {
- IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);
-
- //
- // Check keyboard controller status bit 1(input buffer status)
- //
- if ((Data & KBC_INPB) == 0) {
- break;
- }
-
- gBS->Stall (50);
- Delay--;
- } while (Delay != 0);
-
- if (Delay == 0) {
- return EFI_TIMEOUT;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- I/O work flow to wait output buffer full in given time.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Timeout given time
-
- @retval EFI_TIMEOUT output is not full in given time
- @retval EFI_SUCCESS output is full in given time.
-**/
-EFI_STATUS
-WaitOutputFull (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINTN Timeout
- )
-{
- UINTN Delay;
- UINT8 Data;
-
- Delay = Timeout / 50;
-
- do {
- IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);
-
- //
- // Check keyboard controller status bit 0(output buffer status)
- // & bit5(output buffer for auxiliary device)
- //
- if ((Data & (KBC_OUTB | KBC_AUXB)) == (KBC_OUTB | KBC_AUXB)) {
- break;
- }
-
- gBS->Stall (50);
- Delay--;
- } while (Delay != 0);
-
- if (Delay == 0) {
- return EFI_TIMEOUT;
- }
-
- return EFI_SUCCESS;
-}
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/CommPs2.h b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/CommPs2.h deleted file mode 100644 index 560389df47..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/CommPs2.h +++ /dev/null @@ -1,435 +0,0 @@ -/** @file
- Using PS2 Mouse to simulation Absolution Pointer Device.
-
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
-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.
-
-**/
-
-#ifndef __COMMPS2_H__
-#define __COMMPS2_H__
-
-#define PS2_PACKET_LENGTH 3
-#define PS2_SYNC_MASK 0xc
-#define PS2_SYNC_BYTE 0x8
-
-#define IS_PS2_SYNC_BYTE(byte) ((byte & PS2_SYNC_MASK) == PS2_SYNC_BYTE)
-
-#define PS2_READ_BYTE_ONE 0
-#define PS2_READ_DATA_BYTE 1
-#define PS2_PROCESS_PACKET 2
-
-#define TIMEOUT 50000
-#define BAT_TIMEOUT 500000
-
-//
-// 8042 I/O Port
-//
-#define KBC_DATA_PORT 0x60
-#define KBC_CMD_STS_PORT 0x64
-
-//
-// 8042 Command
-//
-#define READ_CMD_BYTE 0x20
-#define WRITE_CMD_BYTE 0x60
-#define DISABLE_AUX 0xa7
-#define ENABLE_AUX 0xa8
-#define SELF_TEST 0xaa
-#define DISABLE_KB 0xad
-#define ENABLE_KB 0xae
-#define WRITE_AUX_DEV 0xd4
-
-#define CMD_SYS_FLAG 0x04
-#define CMD_KB_STS 0x10
-#define CMD_KB_DIS 0x10
-#define CMD_KB_EN 0x0
-
-//
-// 8042 Auxiliary Device Command
-//
-#define SETSF1_CMD 0xe6
-#define SETSF2_CMD 0xe7
-#define SETRE_CMD 0xe8
-#define READ_CMD 0xeb
-#define SETRM_CMD 0xf0
-#define SETSR_CMD 0xf3
-#define ENABLE_CMD 0xf4
-#define DISABLE_CMD 0xf5
-#define RESET_CMD 0xff
-
-//
-// return code
-//
-#define PS2_ACK 0xfa
-#define PS2_RESEND 0xfe
-#define PS2MOUSE_BAT1 0xaa
-#define PS2MOUSE_BAT2 0x0
-
-//
-// Keyboard Controller Status
-//
-///
-/// Parity Error
-///
-#define KBC_PARE 0x80
-///
-/// General Time Out
-///
-#define KBC_TIM 0x40
-///
-/// Output buffer for auxiliary device (PS/2):
-/// 0 - Holds keyboard data
-/// 1 - Holds data for auxiliary device
-///
-#define KBC_AUXB 0x20
-///
-/// Keyboard lock status:
-/// 0 - keyboard locked
-/// 1 - keyboard free
-///
-#define KBC_KEYL 0x10
-///
-/// Command/Data:
-/// 0 - data byte written via port 60h
-/// 1 - command byte written via port 64h
-///
-#define KBC_CD 0x08
-///
-/// System Flag:
-/// 0 - power-on reset
-/// 1 - self-test successful
-///
-#define KBC_SYSF 0x04
-///
-/// Input Buffer Status :
-/// 0 - input buffer empty
-/// 1 - CPU data in input buffer
-///
-#define KBC_INPB 0x02
-///
-/// Output Buffer Status :
-/// 0 - output buffer empty
-/// 1 - keyboard controller data in output buffer
-///
-#define KBC_OUTB 0x01
-
-/**
- Issue self test command via IsaIo interface.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return EFI_SUCCESS Success to do keyboard self testing.
- @return others Fail to do keyboard self testing.
-**/
-EFI_STATUS
-KbcSelfTest (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- );
-
-/**
- Issue command to enable keyboard AUX functionality.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-KbcEnableAux (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- );
-
-/**
- Issue command to disable keyboard AUX functionality.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-KbcDisableAux (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- );
-
-/**
- Issue command to enable keyboard.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-KbcEnableKb (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- );
-
-/**
- Issue command to disable keyboard.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-KbcDisableKb (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- );
-
-/**
- Issue command to check keyboard status.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param KeyboardEnable return whether keyboard is enable.
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-CheckKbStatus (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- OUT BOOLEAN *KeyboardEnable
- );
-
-/**
- Issue command to reset keyboard.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-PS2MouseReset (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- );
-
-/**
- Issue command to set mouse's sample rate
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param SampleRate value of sample rate
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-PS2MouseSetSampleRate (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN MOUSE_SR SampleRate
- );
-
-/**
- Issue command to set mouse's resolution.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Resolution value of resolution
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-PS2MouseSetResolution (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN MOUSE_RE Resolution
- );
-
-/**
- Issue command to set mouse's scaling.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Scaling value of scaling
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-PS2MouseSetScaling (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN MOUSE_SF Scaling
- );
-
-/**
- Issue command to enable Ps2 mouse.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-PS2MouseEnable (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- );
-
-/**
- Get mouse packet . Only care first 3 bytes
-
- @param MouseAbsolutePointerDev Pointer to PS2 Absolute Pointer Simulation Device Private Data Structure
-
- @retval EFI_NOT_READY Mouse Device not ready to input data packet, or some error happened during getting the packet
- @retval EFI_SUCCESS The data packet is gotten successfully.
-
-**/
-EFI_STATUS
-PS2MouseGetPacket (
- PS2_MOUSE_ABSOLUTE_POINTER_DEV *MouseAbsolutePointerDev
- );
-
-/**
- Read data via IsaIo protocol with given number.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Buffer Buffer receive data of mouse
- @param BufSize The size of buffer
- @param State Check input or read data
-
- @return status of reading mouse data.
-**/
-EFI_STATUS
-PS2MouseRead (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- OUT VOID *Buffer,
- IN OUT UINTN *BufSize,
- IN UINTN State
- );
-
-//
-// 8042 I/O function
-//
-/**
- I/O work flow of outing 8042 command.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Command I/O command.
-
- @retval EFI_SUCCESS Success to execute I/O work flow
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-Out8042Command (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINT8 Command
- );
-
-/**
- I/O work flow of in 8042 data.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Data Data value
-
- @retval EFI_SUCCESS Success to execute I/O work flow
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-In8042Data (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN OUT UINT8 *Data
- );
-
-/**
- I/O work flow of outing 8042 data.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Data Data value
-
- @retval EFI_SUCCESS Success to execute I/O work flow
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-Out8042Data (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINT8 Data
- );
-
-/**
- I/O work flow of outing 8042 Aux command.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Command Aux I/O command
- @param Resend Whether need resend the Aux command.
-
- @retval EFI_SUCCESS Success to execute I/O work flow
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-Out8042AuxCommand (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINT8 Command,
- IN BOOLEAN Resend
- );
-
-/**
- I/O work flow of in 8042 Aux data.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Data Buffer holding return value.
-
- @retval EFI_SUCCESS Success to execute I/O work flow
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-In8042AuxData (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN OUT UINT8 *Data
- );
-
-/**
- I/O work flow of outing 8042 Aux data.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Data Buffer holding return value.
-
- @retval EFI_SUCCESS Success to execute I/O work flow
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-Out8042AuxData (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINT8 Data
- );
-
-/**
- Check keyboard controller status, if it is output buffer full and for auxiliary device.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @retval EFI_SUCCESS Keyboard controller is ready
- @retval EFI_NOT_READY Keyboard controller is not ready
-**/
-EFI_STATUS
-CheckForInput (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- );
-
-/**
- I/O work flow to wait input buffer empty in given time.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Timeout Wating time.
-
- @retval EFI_TIMEOUT if input is still not empty in given time.
- @retval EFI_SUCCESS input is empty.
-**/
-EFI_STATUS
-WaitInputEmpty (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINTN Timeout
- );
-
-/**
- I/O work flow to wait output buffer full in given time.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Timeout given time
-
- @retval EFI_TIMEOUT output is not full in given time
- @retval EFI_SUCCESS output is full in given time.
-**/
-EFI_STATUS
-WaitOutputFull (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINTN Timeout
- );
-
-#endif
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/ComponentName.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/ComponentName.c deleted file mode 100644 index 8fbef28985..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/ComponentName.c +++ /dev/null @@ -1,241 +0,0 @@ -/** @file
- UEFI Component Name(2) protocol implementation for Ps2 Absolute Pointer Simulation Dxe driver.
-
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
-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 "Ps2MouseAbsolutePointer.h"
-
-//
-// EFI Component Name Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gPs2MouseAbsolutePointerComponentName = {
- Ps2MouseAbsolutePointerComponentNameGetDriverName,
- Ps2MouseAbsolutePointerComponentNameGetControllerName,
- "eng"
-};
-
-//
-// EFI Component Name 2 Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPs2MouseAbsolutePointerComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) Ps2MouseAbsolutePointerComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) Ps2MouseAbsolutePointerComponentNameGetControllerName,
- "en"
-};
-
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPs2MouseAbsolutePointerDriverNameTable[] = {
- {
- "eng;en",
- L"faked PS/2 Touchpad Driver"
- },
- {
- NULL,
- NULL
- }
-};
-
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
-
- @param DriverName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-Ps2MouseAbsolutePointerComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- )
-{
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mPs2MouseAbsolutePointerDriverNameTable,
- DriverName,
- (BOOLEAN)(This == &gPs2MouseAbsolutePointerComponentName)
- );
-}
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param ControllerHandle[in] The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
-
- @param ChildHandle[in] The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
-
- @param ControllerName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
-
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
-
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-Ps2MouseAbsolutePointerComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- )
-{
- EFI_STATUS Status;
- EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointerProtocol;
- PS2_MOUSE_ABSOLUTE_POINTER_DEV *MouseAbsolutePointerDev;
- EFI_ISA_IO_PROTOCOL *IsaIoProtocol;
-
- //
- // This is a device driver, so ChildHandle must be NULL.
- //
- if (ChildHandle != NULL) {
- return EFI_UNSUPPORTED;
- }
- //
- // Check Controller's handle
- //
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiIsaIoProtocolGuid,
- (VOID **) &IsaIoProtocol,
- gPS2MouseAbsolutePointerDriver.DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (!EFI_ERROR (Status)) {
- gBS->CloseProtocol (
- ControllerHandle,
- &gEfiIsaIoProtocolGuid,
- gPS2MouseAbsolutePointerDriver.DriverBindingHandle,
- ControllerHandle
- );
-
- return EFI_UNSUPPORTED;
- }
-
- if (Status != EFI_ALREADY_STARTED) {
- return EFI_UNSUPPORTED;
- }
- //
- // Get the device context
- //
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiAbsolutePointerProtocolGuid,
- (VOID **) &AbsolutePointerProtocol,
- gPS2MouseAbsolutePointerDriver.DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- MouseAbsolutePointerDev = PS2_MOUSE_ABSOLUTE_POINTER_DEV_FROM_THIS (AbsolutePointerProtocol);
-
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- MouseAbsolutePointerDev->ControllerNameTable,
- ControllerName,
- (BOOLEAN)(This == &gPs2MouseAbsolutePointerComponentName)
- );
-}
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointer.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointer.c deleted file mode 100644 index bf8adfcb2f..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointer.c +++ /dev/null @@ -1,778 +0,0 @@ -/** @file
- A faked PS/2 Absolute Pointer driver. Routines that interacts with callers,
- conforming to EFI driver model
-
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
-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 "Ps2MouseAbsolutePointer.h"
-#include "CommPs2.h"
-
-//
-// DriverBinding Protocol Instance
-//
-EFI_DRIVER_BINDING_PROTOCOL gPS2MouseAbsolutePointerDriver = {
- PS2MouseAbsolutePointerDriverSupported,
- PS2MouseAbsolutePointerDriverStart,
- PS2MouseAbsolutePointerDriverStop,
- 0x1,
- NULL,
- NULL
-};
-
-/**
- Test to see if this driver supports ControllerHandle. Any ControllerHandle
- than contains a IsaIo protocol can be supported.
-
- @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.
-
- @retval EFI_SUCCESS This driver supports this device
- @retval EFI_ALREADY_STARTED This driver is already running on this device
- @retval other This driver does not support this device
-
-**/
-EFI_STATUS
-EFIAPI
-PS2MouseAbsolutePointerDriverSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- EFI_STATUS Status;
- EFI_ISA_IO_PROTOCOL *IsaIo;
-
- Status = EFI_SUCCESS;
-
- //
- // Open the IO Abstraction(s) needed to perform the supported test
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- (VOID **) &IsaIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Use the ISA I/O Protocol to see if Controller is the Mouse controller
- //
- switch (IsaIo->ResourceList->Device.HID) {
- case EISA_PNP_ID (0xF03):
- //
- // Microsoft PS/2 style mouse
- //
- case EISA_PNP_ID (0xF13):
- //
- // PS/2 Port for PS/2-style Mice
- //
- break;
-
- case EISA_PNP_ID (0x303):
- //
- // IBM Enhanced (101/102-key, PS/2 mouse support)
- //
- if (IsaIo->ResourceList->Device.UID == 1) {
- break;
- }
-
- default:
- Status = EFI_UNSUPPORTED;
- break;
- }
- //
- // Close the I/O Abstraction(s) used to perform the supported test
- //
- gBS->CloseProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- return Status;
-}
-
-/**
- Start this driver on ControllerHandle by opening a IsaIo protocol, creating
- PS2_MOUSE_ABSOLUTE_POINTER_DEV device and install gEfiAbsolutePointerProtocolGuid
- finally.
-
- @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
-
-**/
-EFI_STATUS
-EFIAPI
-PS2MouseAbsolutePointerDriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- EFI_STATUS Status;
- EFI_STATUS EmptyStatus;
- EFI_ISA_IO_PROTOCOL *IsaIo;
- PS2_MOUSE_ABSOLUTE_POINTER_DEV *MouseAbsolutePointerDev;
- UINT8 Data;
- EFI_TPL OldTpl;
- EFI_STATUS_CODE_VALUE StatusCode;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
-
- StatusCode = 0;
- MouseAbsolutePointerDev = NULL;
- IsaIo = NULL;
-
- //
- // Open the device path protocol
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Report that the keyboard is being enabled
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_MOUSE | EFI_P_PC_ENABLE,
- ParentDevicePath
- );
-
- //
- // Get the ISA I/O Protocol on Controller's handle
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- (VOID **) &IsaIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- return EFI_INVALID_PARAMETER;
- }
- //
- // Raise TPL to avoid keyboard operation impact
- //
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
-
- //
- // Allocate private data
- //
- MouseAbsolutePointerDev = AllocateZeroPool (sizeof (PS2_MOUSE_ABSOLUTE_POINTER_DEV));
- if (MouseAbsolutePointerDev == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ErrorExit;
- }
- //
- // Setup the device instance
- //
- MouseAbsolutePointerDev->Signature = PS2_MOUSE_ABSOLUTE_POINTER_DEV_SIGNATURE;
- MouseAbsolutePointerDev->Handle = Controller;
- MouseAbsolutePointerDev->SampleRate = SampleRate20;
- MouseAbsolutePointerDev->Resolution = MouseResolution4;
- MouseAbsolutePointerDev->Scaling = Scaling1;
- MouseAbsolutePointerDev->DataPackageSize = 3;
- MouseAbsolutePointerDev->IsaIo = IsaIo;
- MouseAbsolutePointerDev->DevicePath = ParentDevicePath;
-
- //
- // Resolution = 4 counts/mm
- //
- MouseAbsolutePointerDev->Mode.AbsoluteMaxX = 1024;
- MouseAbsolutePointerDev->Mode.AbsoluteMinX = 0;
- MouseAbsolutePointerDev->Mode.AbsoluteMaxY = 798;
- MouseAbsolutePointerDev->Mode.AbsoluteMinY = 0;
- MouseAbsolutePointerDev->Mode.AbsoluteMaxZ = 0;
- MouseAbsolutePointerDev->Mode.AbsoluteMinZ = 0;
- MouseAbsolutePointerDev->Mode.Attributes = 0x03;
-
- MouseAbsolutePointerDev->AbsolutePointerProtocol.Reset = MouseAbsolutePointerReset;
- MouseAbsolutePointerDev->AbsolutePointerProtocol.GetState = MouseAbsolutePointerGetState;
- MouseAbsolutePointerDev->AbsolutePointerProtocol.Mode = &(MouseAbsolutePointerDev->Mode);
-
- //
- // Initialize keyboard controller if necessary
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_MOUSE | EFI_P_MOUSE_PC_SELF_TEST,
- ParentDevicePath
- );
-
- IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);
- if ((Data & KBC_SYSF) != KBC_SYSF) {
- Status = KbcSelfTest (IsaIo);
- if (EFI_ERROR (Status)) {
- StatusCode = EFI_PERIPHERAL_MOUSE | EFI_P_EC_CONTROLLER_ERROR;
- goto ErrorExit;
- }
- }
-
- KbcEnableAux (IsaIo);
-
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_MOUSE | EFI_P_PC_PRESENCE_DETECT,
- ParentDevicePath
- );
-
- //
- // Reset the mouse
- //
- Status = MouseAbsolutePointerDev->AbsolutePointerProtocol.Reset (
- &MouseAbsolutePointerDev->AbsolutePointerProtocol,
- FeaturePcdGet (PcdPs2MouseExtendedVerification)
- );
- if (EFI_ERROR (Status)) {
- //
- // mouse not connected
- //
- Status = EFI_SUCCESS;
- StatusCode = EFI_PERIPHERAL_MOUSE | EFI_P_EC_NOT_DETECTED;
- goto ErrorExit;
- }
-
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_MOUSE | EFI_P_PC_DETECTED,
- ParentDevicePath
- );
-
- //
- // Setup the WaitForKey event
- //
- Status = gBS->CreateEvent (
- EVT_NOTIFY_WAIT,
- TPL_NOTIFY,
- MouseAbsolutePointerWaitForInput,
- MouseAbsolutePointerDev,
- &((MouseAbsolutePointerDev->AbsolutePointerProtocol).WaitForInput)
- );
- if (EFI_ERROR (Status)) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ErrorExit;
- }
- //
- // Setup a periodic timer, used to poll mouse state
- //
- Status = gBS->CreateEvent (
- EVT_TIMER | EVT_NOTIFY_SIGNAL,
- TPL_NOTIFY,
- PollMouseAbsolutePointer,
- MouseAbsolutePointerDev,
- &MouseAbsolutePointerDev->TimerEvent
- );
- if (EFI_ERROR (Status)) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ErrorExit;
- }
- //
- // Start timer to poll mouse (100 samples per second)
- //
- Status = gBS->SetTimer (MouseAbsolutePointerDev->TimerEvent, TimerPeriodic, 100000);
- if (EFI_ERROR (Status)) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ErrorExit;
- }
-
- MouseAbsolutePointerDev->ControllerNameTable = NULL;
- AddUnicodeString2 (
- "eng",
- gPs2MouseAbsolutePointerComponentName.SupportedLanguages,
- &MouseAbsolutePointerDev->ControllerNameTable,
- L"Faked PS/2 Touchpad Device",
- TRUE
- );
- AddUnicodeString2 (
- "en",
- gPs2MouseAbsolutePointerComponentName2.SupportedLanguages,
- &MouseAbsolutePointerDev->ControllerNameTable,
- L"Faked PS/2 Touchpad Device",
- FALSE
- );
-
-
- //
- // Install protocol interfaces for the mouse device.
- //
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Controller,
- &gEfiAbsolutePointerProtocolGuid,
- &MouseAbsolutePointerDev->AbsolutePointerProtocol,
- NULL
- );
- if (EFI_ERROR (Status)) {
- goto ErrorExit;
- }
-
- gBS->RestoreTPL (OldTpl);
-
- return Status;
-
-ErrorExit:
-
- KbcDisableAux (IsaIo);
-
- if (StatusCode != 0) {
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- StatusCode,
- ParentDevicePath
- );
- }
-
- if ((MouseAbsolutePointerDev != NULL) && (MouseAbsolutePointerDev->AbsolutePointerProtocol.WaitForInput != NULL)) {
- gBS->CloseEvent (MouseAbsolutePointerDev->AbsolutePointerProtocol.WaitForInput);
- }
-
- if ((MouseAbsolutePointerDev != NULL) && (MouseAbsolutePointerDev->TimerEvent != NULL)) {
- gBS->CloseEvent (MouseAbsolutePointerDev->TimerEvent);
- }
-
- if ((MouseAbsolutePointerDev != NULL) && (MouseAbsolutePointerDev->ControllerNameTable != NULL)) {
- FreeUnicodeStringTable (MouseAbsolutePointerDev->ControllerNameTable);
- }
- //
- // Since there will be no timer handler for mouse input any more,
- // exhaust input data just in case there is still mouse data left
- //
- EmptyStatus = EFI_SUCCESS;
- while (!EFI_ERROR (EmptyStatus)) {
- EmptyStatus = In8042Data (IsaIo, &Data);
- }
-
- if (MouseAbsolutePointerDev != NULL) {
- FreePool (MouseAbsolutePointerDev);
- }
-
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- gBS->CloseProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- gBS->RestoreTPL (OldTpl);
-
- return Status;
-}
-
-/**
- Stop this driver on ControllerHandle. Support stopping any child handles
- created by this driver.
-
- @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
-
-**/
-EFI_STATUS
-EFIAPI
-PS2MouseAbsolutePointerDriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- )
-{
- EFI_STATUS Status;
- EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointerProtocol;
- PS2_MOUSE_ABSOLUTE_POINTER_DEV *MouseAbsolutePointerDev;
- UINT8 Data;
-
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiAbsolutePointerProtocolGuid,
- (VOID **) &AbsolutePointerProtocol,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return EFI_SUCCESS;
- }
-
- MouseAbsolutePointerDev = PS2_MOUSE_ABSOLUTE_POINTER_DEV_FROM_THIS (AbsolutePointerProtocol);
-
- //
- // Report that the keyboard is being disabled
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_MOUSE | EFI_P_PC_DISABLE,
- MouseAbsolutePointerDev->DevicePath
- );
-
- Status = gBS->UninstallProtocolInterface (
- Controller,
- &gEfiAbsolutePointerProtocolGuid,
- &MouseAbsolutePointerDev->AbsolutePointerProtocol
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Cancel mouse data polling timer, close timer event
- //
- gBS->SetTimer (MouseAbsolutePointerDev->TimerEvent, TimerCancel, 0);
- gBS->CloseEvent (MouseAbsolutePointerDev->TimerEvent);
-
- //
- // Since there will be no timer handler for mouse input any more,
- // exhaust input data just in case there is still mouse data left
- //
- Status = EFI_SUCCESS;
- while (!EFI_ERROR (Status)) {
- Status = In8042Data (MouseAbsolutePointerDev->IsaIo, &Data);
- }
-
- gBS->CloseEvent (MouseAbsolutePointerDev->AbsolutePointerProtocol.WaitForInput);
- FreeUnicodeStringTable (MouseAbsolutePointerDev->ControllerNameTable);
- FreePool (MouseAbsolutePointerDev);
-
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- gBS->CloseProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- return EFI_SUCCESS;
-}
-
-/**
- Reset the Mouse and do BAT test for it, if ExtendedVerification is TRUE and there is a mouse device connected to system.
-
- @param This - Pointer of simple pointer Protocol.
- @param ExtendedVerification - Whether configure mouse parameters. True: do; FALSE: skip.
-
-
- @retval EFI_SUCCESS - The command byte is written successfully.
- @retval EFI_DEVICE_ERROR - Errors occurred during resetting keyboard.
-
-**/
-EFI_STATUS
-EFIAPI
-MouseAbsolutePointerReset (
- IN EFI_ABSOLUTE_POINTER_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- )
-{
- EFI_STATUS Status;
- PS2_MOUSE_ABSOLUTE_POINTER_DEV *MouseAbsolutePointerDev;
- EFI_TPL OldTpl;
- BOOLEAN KeyboardEnable;
- UINT8 Data;
-
- MouseAbsolutePointerDev = PS2_MOUSE_ABSOLUTE_POINTER_DEV_FROM_THIS (This);
-
- //
- // Report reset progress code
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_MOUSE | EFI_P_PC_RESET,
- MouseAbsolutePointerDev->DevicePath
- );
-
- KeyboardEnable = FALSE;
-
- //
- // Raise TPL to avoid keyboard operation impact
- //
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
-
- ZeroMem (&MouseAbsolutePointerDev->State, sizeof (EFI_ABSOLUTE_POINTER_STATE));
- MouseAbsolutePointerDev->StateChanged = FALSE;
-
- //
- // Exhaust input data
- //
- Status = EFI_SUCCESS;
- while (!EFI_ERROR (Status)) {
- Status = In8042Data (MouseAbsolutePointerDev->IsaIo, &Data);
- }
-
- CheckKbStatus (MouseAbsolutePointerDev->IsaIo, &KeyboardEnable);
-
- KbcDisableKb (MouseAbsolutePointerDev->IsaIo);
-
- MouseAbsolutePointerDev->IsaIo->Io.Read (MouseAbsolutePointerDev->IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);
-
- //
- // if there's data block on KBC data port, read it out
- //
- if ((Data & KBC_OUTB) == KBC_OUTB) {
- MouseAbsolutePointerDev->IsaIo->Io.Read (MouseAbsolutePointerDev->IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, &Data);
- }
-
- Status = EFI_SUCCESS;
- //
- // The PS2 mouse driver reset behavior is always successfully return no matter wheater or not there is mouse connected to system.
- // This behavior is needed by performance speed. The following mouse command only succeessfully finish when mouse device is
- // connected to system, so if PS2 mouse device not connect to system or user not ask for, we skip the mouse configuration and enabling
- //
- if (ExtendedVerification && CheckMouseAbsolutePointerConnect (MouseAbsolutePointerDev)) {
- //
- // Send mouse reset command and set mouse default configure
- //
- Status = PS2MouseReset (MouseAbsolutePointerDev->IsaIo);
- if (EFI_ERROR (Status)) {
- Status = EFI_DEVICE_ERROR;
- goto Exit;
- }
-
- Status = PS2MouseSetSampleRate (MouseAbsolutePointerDev->IsaIo, MouseAbsolutePointerDev->SampleRate);
- if (EFI_ERROR (Status)) {
- Status = EFI_DEVICE_ERROR;
- goto Exit;
- }
-
- Status = PS2MouseSetResolution (MouseAbsolutePointerDev->IsaIo, MouseAbsolutePointerDev->Resolution);
- if (EFI_ERROR (Status)) {
- Status = EFI_DEVICE_ERROR;
- goto Exit;
- }
-
- Status = PS2MouseSetScaling (MouseAbsolutePointerDev->IsaIo, MouseAbsolutePointerDev->Scaling);
- if (EFI_ERROR (Status)) {
- Status = EFI_DEVICE_ERROR;
- goto Exit;
- }
-
- Status = PS2MouseEnable (MouseAbsolutePointerDev->IsaIo);
- if (EFI_ERROR (Status)) {
- Status = EFI_DEVICE_ERROR;
- goto Exit;
- }
- }
-Exit:
- gBS->RestoreTPL (OldTpl);
-
- if (KeyboardEnable) {
- KbcEnableKb (MouseAbsolutePointerDev->IsaIo);
- }
-
- return Status;
-}
-
-/**
- Check whether there is Ps/2 mouse device in system
-
- @param MouseAbsolutePointerDev - Absolute Pointer Device Private Data Structure
-
- @retval TRUE - Keyboard in System.
- @retval FALSE - Keyboard not in System.
-
-**/
-BOOLEAN
-CheckMouseAbsolutePointerConnect (
- IN PS2_MOUSE_ABSOLUTE_POINTER_DEV *MouseAbsolutePointerDev
- )
-
-{
- EFI_STATUS Status;
-
- Status = PS2MouseEnable (MouseAbsolutePointerDev->IsaIo);
- if (!EFI_ERROR (Status)) {
- return TRUE;
- }
-
- return FALSE;
-}
-
-/**
- Get and Clear mouse status.
-
- @param This - Pointer of simple pointer Protocol.
- @param State - Output buffer holding status.
-
- @retval EFI_INVALID_PARAMETER Output buffer is invalid.
- @retval EFI_NOT_READY Mouse is not changed status yet.
- @retval EFI_SUCCESS Mouse status is changed and get successful.
-**/
-EFI_STATUS
-EFIAPI
-MouseAbsolutePointerGetState (
- IN EFI_ABSOLUTE_POINTER_PROTOCOL *This,
- IN OUT EFI_ABSOLUTE_POINTER_STATE *State
- )
-{
- PS2_MOUSE_ABSOLUTE_POINTER_DEV *MouseAbsolutePointerDev;
- EFI_TPL OldTpl;
-
- MouseAbsolutePointerDev = PS2_MOUSE_ABSOLUTE_POINTER_DEV_FROM_THIS (This);
-
- if (State == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (!MouseAbsolutePointerDev->StateChanged) {
- return EFI_NOT_READY;
- }
-
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
- CopyMem (State, &(MouseAbsolutePointerDev->State), sizeof (EFI_ABSOLUTE_POINTER_STATE));
-
- //
- // clear mouse state
- //
- MouseAbsolutePointerDev->State.CurrentX = 0;
- MouseAbsolutePointerDev->State.CurrentY = 0;
- MouseAbsolutePointerDev->State.CurrentZ = 0;
- MouseAbsolutePointerDev->State.ActiveButtons = 0x0;
- MouseAbsolutePointerDev->StateChanged = FALSE;
- gBS->RestoreTPL (OldTpl);
-
- return EFI_SUCCESS;
-}
-
-/**
-
- Event notification function for SIMPLE_POINTER.WaitForInput event.
- Signal the event if there is input from mouse.
-
- @param Event event object
- @param Context event context
-
-**/
-VOID
-EFIAPI
-MouseAbsolutePointerWaitForInput (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- PS2_MOUSE_ABSOLUTE_POINTER_DEV *MouseAbsolutePointerDev;
-
- MouseAbsolutePointerDev = (PS2_MOUSE_ABSOLUTE_POINTER_DEV *) Context;
-
- //
- // Someone is waiting on the mouse event, if there's
- // input from mouse, signal the event
- //
- if (MouseAbsolutePointerDev->StateChanged) {
- gBS->SignalEvent (Event);
- }
-
-}
-
-/**
- Event notification function for TimerEvent event.
- If mouse device is connected to system, try to get the mouse packet data.
-
- @param Event - TimerEvent in PS2_MOUSE_DEV
- @param Context - Pointer to PS2_MOUSE_DEV structure
-
-**/
-VOID
-EFIAPI
-PollMouseAbsolutePointer(
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-
-{
- PS2_MOUSE_ABSOLUTE_POINTER_DEV *MouseAbsolutePointerDev;
-
- MouseAbsolutePointerDev = (PS2_MOUSE_ABSOLUTE_POINTER_DEV *) Context;
-
- //
- // Polling mouse packet data
- //
- PS2MouseGetPacket (MouseAbsolutePointerDev);
-}
-
-/**
- The user Entry Point for module Ps2MouseAbsolutePointer. The user code starts with this function.
-
- @param[in] ImageHandle The firmware allocated handle for the EFI image.
- @param[in] SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The entry point is executed successfully.
- @retval other Some error occurs when executing this entry point.
-
-**/
-EFI_STATUS
-EFIAPI
-InitializePs2MouseAbsolutePointer(
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- //
- // Install driver model protocol(s).
- //
- Status = EfiLibInstallDriverBindingComponentName2 (
- ImageHandle,
- SystemTable,
- &gPS2MouseAbsolutePointerDriver,
- ImageHandle,
- &gPs2MouseAbsolutePointerComponentName,
- &gPs2MouseAbsolutePointerComponentName2
- );
- ASSERT_EFI_ERROR (Status);
-
-
- return Status;
-}
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointer.h b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointer.h deleted file mode 100644 index 8f959fdfe4..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointer.h +++ /dev/null @@ -1,400 +0,0 @@ -/** @file
- A Ps2MouseAbsolutePointer driver header file
-
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
-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.
-
-**/
-
-#ifndef __PS2MOUSEABSOLUTEPOINTER_H__
-#define __PS2MOUSEABSOLUTEPOINTER_H__
-
-#include <Uefi.h>
-
-#include <Protocol/AbsolutePointer.h>
-#include <Protocol/IsaIo.h>
-#include <Protocol/DevicePath.h>
-
-#include <Library/DebugLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/UefiLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/ReportStatusCodeLib.h>
-#include <Library/PcdLib.h>
-
-//
-// Global Variables
-//
-extern EFI_DRIVER_BINDING_PROTOCOL gPS2MouseAbsolutePointerDriver;
-extern EFI_COMPONENT_NAME_PROTOCOL gPs2MouseAbsolutePointerComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gPs2MouseAbsolutePointerComponentName2;
-
-//
-// PS/2 mouse sample rate
-//
-typedef enum {
- SampleRate10,
- SampleRate20,
- SampleRate40,
- SampleRate60,
- SampleRate80,
- SampleRate100,
- SampleRate200,
- MaxSampleRate
-} MOUSE_SR;
-
-//
-// PS/2 mouse resolution
-//
-typedef enum {
- MouseResolution1,
- MouseResolution2,
- MouseResolution4,
- MouseResolution8,
- MaxResolution
-} MOUSE_RE;
-
-//
-// PS/2 mouse scaling
-//
-typedef enum {
- Scaling1,
- Scaling2
-} MOUSE_SF;
-
-//
-// Driver Private Data
-//
-#define PS2_MOUSE_ABSOLUTE_POINTER_DEV_SIGNATURE SIGNATURE_32 ('p', '2', 's', 't')
-
-typedef struct {
- UINTN Signature;
-
- EFI_HANDLE Handle;
- EFI_ABSOLUTE_POINTER_PROTOCOL AbsolutePointerProtocol;
- EFI_ABSOLUTE_POINTER_STATE State;
- EFI_ABSOLUTE_POINTER_MODE Mode;
- BOOLEAN StateChanged;
-
- //
- // PS2 Mouse device specific information
- //
- MOUSE_SR SampleRate;
- MOUSE_RE Resolution;
- MOUSE_SF Scaling;
- UINT8 DataPackageSize;
-
- EFI_ISA_IO_PROTOCOL *IsaIo;
-
- EFI_EVENT TimerEvent;
-
- EFI_UNICODE_STRING_TABLE *ControllerNameTable;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
-} PS2_MOUSE_ABSOLUTE_POINTER_DEV;
-
-#define PS2_MOUSE_ABSOLUTE_POINTER_DEV_FROM_THIS(a) CR (a, PS2_MOUSE_ABSOLUTE_POINTER_DEV, AbsolutePointerProtocol, PS2_MOUSE_ABSOLUTE_POINTER_DEV_SIGNATURE)
-
-//
-// Function prototypes
-//
-/**
- Test to see if this driver supports ControllerHandle. Any ControllerHandle
- than contains a IsaIo protocol can be supported.
-
- @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.
-
- @retval EFI_SUCCESS This driver supports this device
- @retval EFI_ALREADY_STARTED This driver is already running on this device
- @retval other This driver does not support this device
-
-**/
-EFI_STATUS
-EFIAPI
-PS2MouseAbsolutePointerDriverSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-/**
- Start this driver on ControllerHandle by opening a IsaIo
- protocol, creating PS2_MOUSE_ABSOLUTE_POINTER_DEV device and install gEfiAbsolutePointerProtocolGuid
- finnally.
-
- @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
-
-**/
-EFI_STATUS
-EFIAPI
-PS2MouseAbsolutePointerDriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-/**
- Stop this driver on ControllerHandle. Support stopping any child handles
- created by this driver.
-
- @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
-
-**/
-EFI_STATUS
-EFIAPI
-PS2MouseAbsolutePointerDriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- );
-
-//
-// EFI Component Name Functions
-//
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
-
- @param DriverName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-Ps2MouseAbsolutePointerComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- );
-
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param ControllerHandle[in] The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
-
- @param ChildHandle[in] The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
-
- @param ControllerName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
-
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
-
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-Ps2MouseAbsolutePointerComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- );
-
-/**
- Reset the Mouse and do BAT test for it, if ExtendedVerification is TRUE and there is a mouse device connected to system.
-
- @param This - Pointer of simple pointer Protocol.
- @param ExtendedVerification - Whether configure mouse parameters. True: do; FALSE: skip.
-
-
- @retval EFI_SUCCESS - The command byte is written successfully.
- @retval EFI_DEVICE_ERROR - Errors occurred during resetting keyboard.
-
-**/
-EFI_STATUS
-EFIAPI
-MouseAbsolutePointerReset (
- IN EFI_ABSOLUTE_POINTER_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- );
-
-/**
- Get and Clear mouse status.
-
- @param This - Pointer of simple pointer Protocol.
- @param State - Output buffer holding status.
-
- @retval EFI_INVALID_PARAMETER Output buffer is invalid.
- @retval EFI_NOT_READY Mouse is not changed status yet.
- @retval EFI_SUCCESS Mouse status is changed and get successful.
-**/
-EFI_STATUS
-EFIAPI
-MouseAbsolutePointerGetState (
- IN EFI_ABSOLUTE_POINTER_PROTOCOL *This,
- IN OUT EFI_ABSOLUTE_POINTER_STATE *State
- );
-
-/**
-
- Event notification function for SIMPLE_POINTER.WaitForInput event.
- Signal the event if there is input from mouse.
-
- @param Event event object
- @param Context event context
-
-**/
-VOID
-EFIAPI
-MouseAbsolutePointerWaitForInput (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
-
-/**
- Event notification function for TimerEvent event.
- If mouse device is connected to system, try to get the mouse packet data.
-
- @param Event - TimerEvent in PS2_MOUSE_DEV
- @param Context - Pointer to PS2_MOUSE_DEV structure
-
-**/
-VOID
-EFIAPI
-PollMouseAbsolutePointer (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
-
-/**
- I/O work flow of in 8042 data.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Data Data value
-
- @retval EFI_SUCCESS Success to execute I/O work flow
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-In8042Data (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN OUT UINT8 *Data
- );
-
-/**
- Check whether there is Ps/2 mouse device in system
-
- @param MouseAbsolutePointerDev - Absolute Pointer Device Private Data Structure
-
- @retval TRUE - Keyboard in System.
- @retval FALSE - Keyboard not in System.
-
-**/
-BOOLEAN
-CheckMouseAbsolutePointerConnect (
- IN PS2_MOUSE_ABSOLUTE_POINTER_DEV *MouseAbsolutePointerDev
- );
-
-#endif
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointerDxe.inf b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointerDxe.inf deleted file mode 100644 index 48adde6f1d..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointerDxe.inf +++ /dev/null @@ -1,76 +0,0 @@ -## @file
-# PS2 Mouse driver providing absolute (touch pad) pointer support.
-#
-# This driver simulates a touch pad absolute pointing device using a standard
-# PS2 mouse as the input hardware.
-#
-# Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
-#
-# 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.
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = Ps2MouseAbsolutePointerDxe
- MODULE_UNI_FILE = Ps2MouseAbsolutePointerDxe.uni
- FILE_GUID = 2899C94A-1FB6-4b1a-B96B-8364975303E0
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = InitializePs2MouseAbsolutePointer
-
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-# DRIVER_BINDING = gPS2MouseAbsolutePointerDriver;
-# COMPONENT_NAME = gPs2MouseAbsolutePointerComponentName;
-# COMPONENT_NAME2 = gPs2MouseAbsolutePointerComponentName2;
-#
-
-[Sources]
- ComponentName.c
- CommPs2.h
- CommPs2.c
- Ps2MouseAbsolutePointer.h
- Ps2MouseAbsolutePointer.c
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
-
-[LibraryClasses]
- ReportStatusCodeLib
- UefiBootServicesTableLib
- MemoryAllocationLib
- BaseMemoryLib
- UefiLib
- UefiDriverEntryPoint
- DebugLib
- PcdLib
-
-[Protocols]
- gEfiIsaIoProtocolGuid ## TO_START
- gEfiAbsolutePointerProtocolGuid ## BY_START
- gEfiDevicePathProtocolGuid ## TO_START
-
-[FeaturePcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdPs2MouseExtendedVerification ## CONSUMES
-
-#
-# [Event]
-#
-# ##
-# # Timer event used to check the mouse state at a regular interval.
-# #
-# EVENT_TYPE_PERIODIC_TIMER ## CONSUMES
-#
-
-[UserExtensions.TianoCore."ExtraFiles"]
- Ps2MouseAbsolutePointerDxeExtra.uni
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointerDxe.uni b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointerDxe.uni deleted file mode 100644 index d12ca1ad1b..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointerDxe.uni +++ /dev/null @@ -1,23 +0,0 @@ -// /** @file
-// PS2 Mouse driver providing absolute (touch pad) pointer support.
-//
-// This driver simulates a touch pad absolute pointing device using a standard
-// PS2 mouse as the input hardware.
-//
-// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
-//
-// 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.
-//
-// **/
-
-
-#string STR_MODULE_ABSTRACT #language en-US "PS2 Mouse driver providing absolute (touch pad) pointer support"
-
-#string STR_MODULE_DESCRIPTION #language en-US "This driver simulates a touch pad absolute pointing device using a standard PS2 mouse as the input hardware."
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointerDxeExtra.uni b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointerDxeExtra.uni deleted file mode 100644 index 6577f74f77..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointerDxeExtra.uni +++ /dev/null @@ -1,20 +0,0 @@ -// /** @file
-// Ps2MouseAbsolutePointerDxe Localized Strings and Content
-//
-// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
-//
-// 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.
-//
-// **/
-
-#string STR_PROPERTIES_MODULE_NAME
-#language en-US
-"PS2 Tablet Pointer DXE Driver"
-
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/CommPs2.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/CommPs2.c deleted file mode 100644 index 27d378db22..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/CommPs2.c +++ /dev/null @@ -1,921 +0,0 @@ -/** @file
- PS2 Mouse Communication Interface.
-
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
-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 "Ps2Mouse.h"
-#include "CommPs2.h"
-
-UINT8 SampleRateTbl[MaxSampleRate] = { 0xa, 0x14, 0x28, 0x3c, 0x50, 0x64, 0xc8 };
-
-UINT8 ResolutionTbl[MaxResolution] = { 0, 1, 2, 3 };
-
-/**
- Issue self test command via IsaIo interface.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return EFI_SUCCESS Success to do keyboard self testing.
- @return others Fail to do keyboard self testing.
-**/
-EFI_STATUS
-KbcSelfTest (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- )
-{
- EFI_STATUS Status;
- UINT8 Data;
-
- //
- // Keyboard controller self test
- //
- Status = Out8042Command (IsaIo, SELF_TEST);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Read return code
- //
- Status = In8042Data (IsaIo, &Data);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if (Data != 0x55) {
- return EFI_DEVICE_ERROR;
- }
- //
- // Set system flag
- //
- Status = Out8042Command (IsaIo, READ_CMD_BYTE);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = In8042Data (IsaIo, &Data);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = Out8042Command (IsaIo, WRITE_CMD_BYTE);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Data |= CMD_SYS_FLAG;
- Status = Out8042Data (IsaIo, Data);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Issue command to enable keyboard AUX functionality.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-KbcEnableAux (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- )
-{
- //
- // Send 8042 enable mouse command
- //
- return Out8042Command (IsaIo, ENABLE_AUX);
-}
-
-/**
- Issue command to disable keyboard AUX functionality.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-KbcDisableAux (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- )
-{
- //
- // Send 8042 disable mouse command
- //
- return Out8042Command (IsaIo, DISABLE_AUX);
-}
-
-/**
- Issue command to enable keyboard.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-KbcEnableKb (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- )
-{
- //
- // Send 8042 enable keyboard command
- //
- return Out8042Command (IsaIo, ENABLE_KB);
-}
-
-/**
- Issue command to disable keyboard.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-KbcDisableKb (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- )
-{
- //
- // Send 8042 disable keyboard command
- //
- return Out8042Command (IsaIo, DISABLE_KB);
-}
-
-/**
- Issue command to check keyboard status.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param KeyboardEnable return whether keyboard is enable.
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-CheckKbStatus (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- OUT BOOLEAN *KeyboardEnable
- )
-{
- EFI_STATUS Status;
- UINT8 Data;
-
- //
- // Send command to read KBC command byte
- //
- Status = Out8042Command (IsaIo, READ_CMD_BYTE);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = In8042Data (IsaIo, &Data);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Check keyboard enable or not
- //
- if ((Data & CMD_KB_STS) == CMD_KB_DIS) {
- *KeyboardEnable = FALSE;
- } else {
- *KeyboardEnable = TRUE;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Issue command to reset keyboard.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-PS2MouseReset (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- )
-{
- EFI_STATUS Status;
- UINT8 Data;
-
- Status = Out8042AuxCommand (IsaIo, RESET_CMD, FALSE);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = In8042AuxData (IsaIo, &Data);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Check BAT Complete Code
- //
- if (Data != PS2MOUSE_BAT1) {
- return EFI_DEVICE_ERROR;
- }
-
- Status = In8042AuxData (IsaIo, &Data);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Check BAT Complete Code
- //
- if (Data != PS2MOUSE_BAT2) {
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Issue command to set mouse's sample rate
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param SampleRate value of sample rate
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-PS2MouseSetSampleRate (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN MOUSE_SR SampleRate
- )
-{
- EFI_STATUS Status;
-
- //
- // Send auxiliary command to set mouse sample rate
- //
- Status = Out8042AuxCommand (IsaIo, SETSR_CMD, FALSE);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = Out8042AuxData (IsaIo, SampleRateTbl[SampleRate]);
-
- return Status;
-}
-
-/**
- Issue command to set mouse's resolution.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Resolution value of resolution
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-PS2MouseSetResolution (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN MOUSE_RE Resolution
- )
-{
- EFI_STATUS Status;
-
- //
- // Send auxiliary command to set mouse resolution
- //
- Status = Out8042AuxCommand (IsaIo, SETRE_CMD, FALSE);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = Out8042AuxData (IsaIo, ResolutionTbl[Resolution]);
-
- return Status;
-}
-
-/**
- Issue command to set mouse's scaling.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Scaling value of scaling
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-PS2MouseSetScaling (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN MOUSE_SF Scaling
- )
-{
- UINT8 Command;
-
- Command = (UINT8) (Scaling == Scaling1 ? SETSF1_CMD : SETSF2_CMD);
-
- //
- // Send auxiliary command to set mouse scaling data
- //
- return Out8042AuxCommand (IsaIo, Command, FALSE);
-}
-
-/**
- Issue command to enable Ps2 mouse.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-PS2MouseEnable (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- )
-{
- //
- // Send auxiliary command to enable mouse
- //
- return Out8042AuxCommand (IsaIo, ENABLE_CMD, FALSE);
-}
-
-/**
- Get mouse packet . Only care first 3 bytes
-
- @param MouseDev Pointer of PS2 Mouse Private Data Structure
-
- @retval EFI_NOT_READY Mouse Device not ready to input data packet, or some error happened during getting the packet
- @retval EFI_SUCCESS The data packet is gotten successfully.
-
-**/
-EFI_STATUS
-PS2MouseGetPacket (
- PS2_MOUSE_DEV *MouseDev
- )
-
-{
- EFI_STATUS Status;
- BOOLEAN KeyboardEnable;
- UINT8 Packet[PS2_PACKET_LENGTH];
- UINT8 Data;
- UINTN Count;
- UINTN State;
- INT16 RelativeMovementX;
- INT16 RelativeMovementY;
- BOOLEAN LButton;
- BOOLEAN RButton;
-
- KeyboardEnable = FALSE;
- Count = 1;
- State = PS2_READ_BYTE_ONE;
-
- //
- // State machine to get mouse packet
- //
- while (1) {
-
- switch (State) {
- case PS2_READ_BYTE_ONE:
- //
- // Read mouse first byte data, if failed, immediately return
- //
- KbcDisableAux (MouseDev->IsaIo);
- Status = PS2MouseRead (MouseDev->IsaIo, &Data, &Count, State);
- if (EFI_ERROR (Status)) {
- KbcEnableAux (MouseDev->IsaIo);
- return EFI_NOT_READY;
- }
-
- if (Count != 1) {
- KbcEnableAux (MouseDev->IsaIo);
- return EFI_NOT_READY;
- }
-
- if (IS_PS2_SYNC_BYTE (Data)) {
- Packet[0] = Data;
- State = PS2_READ_DATA_BYTE;
-
- CheckKbStatus (MouseDev->IsaIo, &KeyboardEnable);
- KbcDisableKb (MouseDev->IsaIo);
- KbcEnableAux (MouseDev->IsaIo);
- }
- break;
-
- case PS2_READ_DATA_BYTE:
- Count = 2;
- Status = PS2MouseRead (MouseDev->IsaIo, (Packet + 1), &Count, State);
- if (EFI_ERROR (Status)) {
- if (KeyboardEnable) {
- KbcEnableKb (MouseDev->IsaIo);
- }
-
- return EFI_NOT_READY;
- }
-
- if (Count != 2) {
- if (KeyboardEnable) {
- KbcEnableKb (MouseDev->IsaIo);
- }
-
- return EFI_NOT_READY;
- }
-
- State = PS2_PROCESS_PACKET;
- break;
-
- case PS2_PROCESS_PACKET:
- if (KeyboardEnable) {
- KbcEnableKb (MouseDev->IsaIo);
- }
- //
- // Decode the packet
- //
- RelativeMovementX = Packet[1];
- RelativeMovementY = Packet[2];
- //
- // Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0
- // Byte 0 | Y overflow | X overflow | Y sign bit | X sign bit | Always 1 | Middle Btn | Right Btn | Left Btn
- // Byte 1 | 8 bit X Movement
- // Byte 2 | 8 bit Y Movement
- //
- // X sign bit + 8 bit X Movement : 9-bit signed twos complement integer that presents the relative displacement of the device in the X direction since the last data transmission.
- // Y sign bit + 8 bit Y Movement : Same as X sign bit + 8 bit X Movement.
- //
- //
- // First, Clear X and Y high 8 bits
- //
- RelativeMovementX = (INT16) (RelativeMovementX & 0xFF);
- RelativeMovementY = (INT16) (RelativeMovementY & 0xFF);
- //
- // Second, if the 9-bit signed twos complement integer is negative, set the high 8 bit 0xff
- //
- if ((Packet[0] & 0x10) != 0) {
- RelativeMovementX = (INT16) (RelativeMovementX | 0xFF00);
- }
- if ((Packet[0] & 0x20) != 0) {
- RelativeMovementY = (INT16) (RelativeMovementY | 0xFF00);
- }
-
-
- RButton = (UINT8) (Packet[0] & 0x2);
- LButton = (UINT8) (Packet[0] & 0x1);
-
- //
- // Update mouse state
- //
- MouseDev->State.RelativeMovementX += RelativeMovementX;
- MouseDev->State.RelativeMovementY -= RelativeMovementY;
- MouseDev->State.RightButton = (UINT8) (RButton ? TRUE : FALSE);
- MouseDev->State.LeftButton = (UINT8) (LButton ? TRUE : FALSE);
- MouseDev->StateChanged = TRUE;
-
- return EFI_SUCCESS;
- }
- }
-}
-
-/**
- Read data via IsaIo protocol with given number.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Buffer Buffer receive data of mouse
- @param BufSize The size of buffer
- @param State Check input or read data
-
- @return status of reading mouse data.
-**/
-EFI_STATUS
-PS2MouseRead (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- OUT VOID *Buffer,
- IN OUT UINTN *BufSize,
- IN UINTN State
- )
-{
- EFI_STATUS Status;
- UINTN BytesRead;
-
- Status = EFI_SUCCESS;
- BytesRead = 0;
-
- if (State == PS2_READ_BYTE_ONE) {
- //
- // Check input for mouse
- //
- Status = CheckForInput (IsaIo);
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
- }
-
- while (BytesRead < *BufSize) {
-
- Status = WaitOutputFull (IsaIo, TIMEOUT);
- if (EFI_ERROR (Status)) {
- break;
- }
-
- IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, Buffer);
-
- BytesRead++;
- Buffer = (UINT8 *) Buffer + 1;
- }
- //
- // Verify the correct number of bytes read
- //
- if (BytesRead == 0 || BytesRead != *BufSize) {
- Status = EFI_NOT_FOUND;
- }
-
- *BufSize = BytesRead;
- return Status;
-}
-//
-// 8042 I/O function
-//
-/**
- I/O work flow of outing 8042 command.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Command I/O command.
-
- @retval EFI_SUCCESS Success to execute I/O work flow
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-Out8042Command (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINT8 Command
- )
-{
- EFI_STATUS Status;
- UINT8 Data;
-
- //
- // Wait keyboard controller input buffer empty
- //
- Status = WaitInputEmpty (IsaIo, TIMEOUT);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Send command
- //
- Data = Command;
- IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);
-
- Status = WaitInputEmpty (IsaIo, TIMEOUT);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- I/O work flow of outing 8042 data.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Data Data value
-
- @retval EFI_SUCCESS Success to execute I/O work flow
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-Out8042Data (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINT8 Data
- )
-{
- EFI_STATUS Status;
- UINT8 Temp;
- //
- // Wait keyboard controller input buffer empty
- //
- Status = WaitInputEmpty (IsaIo, TIMEOUT);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Temp = Data;
- IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, &Temp);
-
- Status = WaitInputEmpty (IsaIo, TIMEOUT);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- I/O work flow of in 8042 data.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Data Data value
-
- @retval EFI_SUCCESS Success to execute I/O work flow
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-In8042Data (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN OUT UINT8 *Data
- )
-{
- UINTN Delay;
- UINT8 Temp;
-
- Delay = TIMEOUT / 50;
-
- do {
- IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Temp);
-
- //
- // Check keyboard controller status bit 0(output buffer status)
- //
- if ((Temp & KBC_OUTB) == KBC_OUTB) {
- break;
- }
-
- gBS->Stall (50);
- Delay--;
- } while (Delay != 0);
-
- if (Delay == 0) {
- return EFI_TIMEOUT;
- }
-
- IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, Data);
-
- return EFI_SUCCESS;
-}
-
-/**
- I/O work flow of outing 8042 Aux command.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Command Aux I/O command
- @param Resend Whether need resend the Aux command.
-
- @retval EFI_SUCCESS Success to execute I/O work flow
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-Out8042AuxCommand (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINT8 Command,
- IN BOOLEAN Resend
- )
-{
- EFI_STATUS Status;
- UINT8 Data;
-
- //
- // Wait keyboard controller input buffer empty
- //
- Status = WaitInputEmpty (IsaIo, TIMEOUT);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Send write to auxiliary device command
- //
- Data = WRITE_AUX_DEV;
- IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);
-
- Status = WaitInputEmpty (IsaIo, TIMEOUT);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Send auxiliary device command
- //
- IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, &Command);
-
- //
- // Read return code
- //
- Status = In8042AuxData (IsaIo, &Data);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if (Data == PS2_ACK) {
- //
- // Receive mouse acknowledge, command send success
- //
- return EFI_SUCCESS;
-
- } else if (Resend) {
- //
- // Resend fail
- //
- return EFI_DEVICE_ERROR;
-
- } else if (Data == PS2_RESEND) {
- //
- // Resend command
- //
- Status = Out8042AuxCommand (IsaIo, Command, TRUE);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- } else {
- //
- // Invalid return code
- //
- return EFI_DEVICE_ERROR;
-
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- I/O work flow of outing 8042 Aux data.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Data Buffer holding return value
-
- @retval EFI_SUCCESS Success to execute I/O work flow
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-Out8042AuxData (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINT8 Data
- )
-{
- EFI_STATUS Status;
- UINT8 Temp;
- //
- // Wait keyboard controller input buffer empty
- //
- Status = WaitInputEmpty (IsaIo, TIMEOUT);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Send write to auxiliary device command
- //
- Temp = WRITE_AUX_DEV;
- IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Temp);
-
- Status = WaitInputEmpty (IsaIo, TIMEOUT);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Temp = Data;
- IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, &Temp);
-
- Status = WaitInputEmpty (IsaIo, TIMEOUT);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- I/O work flow of in 8042 Aux data.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Data Buffer holding return value.
-
- @retval EFI_SUCCESS Success to execute I/O work flow
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-In8042AuxData (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN OUT UINT8 *Data
- )
-{
- EFI_STATUS Status;
-
- //
- // wait for output data
- //
- Status = WaitOutputFull (IsaIo, BAT_TIMEOUT);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, Data);
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Check keyboard controller status, if it is output buffer full and for auxiliary device.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @retval EFI_SUCCESS Keyboard controller is ready
- @retval EFI_NOT_READY Keyboard controller is not ready
-**/
-EFI_STATUS
-CheckForInput (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- )
-{
- UINT8 Data;
-
- IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);
-
- //
- // Check keyboard controller status, if it is output buffer full and for auxiliary device
- //
- if ((Data & (KBC_OUTB | KBC_AUXB)) != (KBC_OUTB | KBC_AUXB)) {
- return EFI_NOT_READY;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- I/O work flow to wait input buffer empty in given time.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Timeout Wating time.
-
- @retval EFI_TIMEOUT if input is still not empty in given time.
- @retval EFI_SUCCESS input is empty.
-**/
-EFI_STATUS
-WaitInputEmpty (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINTN Timeout
- )
-{
- UINTN Delay;
- UINT8 Data;
-
- Delay = Timeout / 50;
-
- do {
- IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);
-
- //
- // Check keyboard controller status bit 1(input buffer status)
- //
- if ((Data & KBC_INPB) == 0) {
- break;
- }
-
- gBS->Stall (50);
- Delay--;
- } while (Delay != 0);
-
- if (Delay == 0) {
- return EFI_TIMEOUT;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- I/O work flow to wait output buffer full in given time.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Timeout given time
-
- @retval EFI_TIMEOUT output is not full in given time
- @retval EFI_SUCCESS output is full in given time.
-**/
-EFI_STATUS
-WaitOutputFull (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINTN Timeout
- )
-{
- UINTN Delay;
- UINT8 Data;
-
- Delay = Timeout / 50;
-
- do {
- IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);
-
- //
- // Check keyboard controller status bit 0(output buffer status)
- // & bit5(output buffer for auxiliary device)
- //
- if ((Data & (KBC_OUTB | KBC_AUXB)) == (KBC_OUTB | KBC_AUXB)) {
- break;
- }
-
- gBS->Stall (50);
- Delay--;
- } while (Delay != 0);
-
- if (Delay == 0) {
- return EFI_TIMEOUT;
- }
-
- return EFI_SUCCESS;
-}
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/CommPs2.h b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/CommPs2.h deleted file mode 100644 index 6c0f8ac6a0..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/CommPs2.h +++ /dev/null @@ -1,435 +0,0 @@ -/** @file
- PS2 Mouse Communication Interface
-
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
-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.
-
-**/
-
-#ifndef _COMMPS2_H_
-#define _COMMPS2_H_
-
-#define PS2_PACKET_LENGTH 3
-#define PS2_SYNC_MASK 0xc
-#define PS2_SYNC_BYTE 0x8
-
-#define IS_PS2_SYNC_BYTE(byte) ((byte & PS2_SYNC_MASK) == PS2_SYNC_BYTE)
-
-#define PS2_READ_BYTE_ONE 0
-#define PS2_READ_DATA_BYTE 1
-#define PS2_PROCESS_PACKET 2
-
-#define TIMEOUT 50000
-#define BAT_TIMEOUT 500000
-
-//
-// 8042 I/O Port
-//
-#define KBC_DATA_PORT 0x60
-#define KBC_CMD_STS_PORT 0x64
-
-//
-// 8042 Command
-//
-#define READ_CMD_BYTE 0x20
-#define WRITE_CMD_BYTE 0x60
-#define DISABLE_AUX 0xa7
-#define ENABLE_AUX 0xa8
-#define SELF_TEST 0xaa
-#define DISABLE_KB 0xad
-#define ENABLE_KB 0xae
-#define WRITE_AUX_DEV 0xd4
-
-#define CMD_SYS_FLAG 0x04
-#define CMD_KB_STS 0x10
-#define CMD_KB_DIS 0x10
-#define CMD_KB_EN 0x0
-
-//
-// 8042 Auxiliary Device Command
-//
-#define SETSF1_CMD 0xe6
-#define SETSF2_CMD 0xe7
-#define SETRE_CMD 0xe8
-#define READ_CMD 0xeb
-#define SETRM_CMD 0xf0
-#define SETSR_CMD 0xf3
-#define ENABLE_CMD 0xf4
-#define DISABLE_CMD 0xf5
-#define RESET_CMD 0xff
-
-//
-// return code
-//
-#define PS2_ACK 0xfa
-#define PS2_RESEND 0xfe
-#define PS2MOUSE_BAT1 0xaa
-#define PS2MOUSE_BAT2 0x0
-
-//
-// Keyboard Controller Status
-//
-///
-/// Parity Error
-///
-#define KBC_PARE 0x80
-///
-/// General Time Out
-///
-#define KBC_TIM 0x40
-///
-/// Output buffer for auxiliary device (PS/2):
-/// 0 - Holds keyboard data
-/// 1 - Holds data for auxiliary device
-///
-#define KBC_AUXB 0x20
-///
-/// Keyboard lock status:
-/// 0 - keyboard locked
-/// 1 - keyboard free
-///
-#define KBC_KEYL 0x10
-///
-/// Command/Data:
-/// 0 - data byte written via port 60h
-/// 1 - command byte written via port 64h
-///
-#define KBC_CD 0x08
-///
-/// System Flag:
-/// 0 - power-on reset
-/// 1 - self-test successful
-///
-#define KBC_SYSF 0x04
-///
-/// Input Buffer Status :
-/// 0 - input buffer empty
-/// 1 - CPU data in input buffer
-///
-#define KBC_INPB 0x02
-///
-/// Output Buffer Status :
-/// 0 - output buffer empty
-/// 1 - keyboard controller data in output buffer
-///
-#define KBC_OUTB 0x01
-
-/**
- Issue self test command via IsaIo interface.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return EFI_SUCCESS Success to do keyboard self testing.
- @return others Fail to do keyboard self testing.
-**/
-EFI_STATUS
-KbcSelfTest (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- );
-
-/**
- Issue command to enable keyboard AUX functionality.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-KbcEnableAux (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- );
-
-/**
- Issue command to disable keyboard AUX functionality.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-KbcDisableAux (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- );
-
-/**
- Issue command to enable keyboard.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-KbcEnableKb (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- );
-
-/**
- Issue command to disable keyboard.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-KbcDisableKb (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- );
-
-/**
- Issue command to check keyboard status.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param KeyboardEnable return whether keyboard is enable.
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-CheckKbStatus (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- OUT BOOLEAN *KeyboardEnable
- );
-
-/**
- Issue command to reset keyboard.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-PS2MouseReset (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- );
-
-/**
- Issue command to set mouse's sample rate
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param SampleRate value of sample rate
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-PS2MouseSetSampleRate (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN MOUSE_SR SampleRate
- );
-
-/**
- Issue command to set mouse's resolution.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Resolution value of resolution
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-PS2MouseSetResolution (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN MOUSE_RE Resolution
- );
-
-/**
- Issue command to set mouse's scaling.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Scaling value of scaling
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-PS2MouseSetScaling (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN MOUSE_SF Scaling
- );
-
-/**
- Issue command to enable Ps2 mouse.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @return Status of command issuing.
-**/
-EFI_STATUS
-PS2MouseEnable (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- );
-
-/**
- Get mouse packet . Only care first 3 bytes
-
- @param MouseDev Pointer of PS2 Mouse Private Data Structure
-
- @retval EFI_NOT_READY Mouse Device not ready to input data packet, or some error happened during getting the packet
- @retval EFI_SUCCESS The data packet is gotten successfully.
-
-**/
-EFI_STATUS
-PS2MouseGetPacket (
- PS2_MOUSE_DEV *MouseDev
- );
-
-/**
- Read data via IsaIo protocol with given number.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Buffer Buffer receive data of mouse
- @param BufSize The size of buffer
- @param State Check input or read data
-
- @return status of reading mouse data.
-**/
-EFI_STATUS
-PS2MouseRead (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- OUT VOID *Buffer,
- IN OUT UINTN *BufSize,
- IN UINTN State
- );
-
-//
-// 8042 I/O function
-//
-/**
- I/O work flow of outing 8042 command.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Command I/O command.
-
- @retval EFI_SUCCESS Success to execute I/O work flow
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-Out8042Command (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINT8 Command
- );
-
-/**
- I/O work flow of in 8042 data.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Data Data value
-
- @retval EFI_SUCCESS Success to execute I/O work flow
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-In8042Data (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN OUT UINT8 *Data
- );
-
-/**
- I/O work flow of outing 8042 data.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Data Data value
-
- @retval EFI_SUCCESS Success to execute I/O work flow
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-Out8042Data (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINT8 Data
- );
-
-/**
- I/O work flow of outing 8042 Aux command.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Command Aux I/O command
- @param Resend Whether need resend the Aux command.
-
- @retval EFI_SUCCESS Success to execute I/O work flow
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-Out8042AuxCommand (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINT8 Command,
- IN BOOLEAN Resend
- );
-
-/**
- I/O work flow of in 8042 Aux data.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Data Buffer holding return value.
-
- @retval EFI_SUCCESS Success to execute I/O work flow
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-In8042AuxData (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN OUT UINT8 *Data
- );
-
-/**
- I/O work flow of outing 8042 Aux data.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Data Buffer holding return value
-
- @retval EFI_SUCCESS Success to execute I/O work flow
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-Out8042AuxData (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINT8 Data
- );
-
-/**
- Check keyboard controller status, if it is output buffer full and for auxiliary device.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
-
- @retval EFI_SUCCESS Keyboard controller is ready
- @retval EFI_NOT_READY Keyboard controller is not ready
-**/
-EFI_STATUS
-CheckForInput (
- IN EFI_ISA_IO_PROTOCOL *IsaIo
- );
-
-/**
- I/O work flow to wait input buffer empty in given time.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Timeout Wating time.
-
- @retval EFI_TIMEOUT if input is still not empty in given time.
- @retval EFI_SUCCESS input is empty.
-**/
-EFI_STATUS
-WaitInputEmpty (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINTN Timeout
- );
-
-/**
- I/O work flow to wait output buffer full in given time.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Timeout given time
-
- @retval EFI_TIMEOUT output is not full in given time
- @retval EFI_SUCCESS output is full in given time.
-**/
-EFI_STATUS
-WaitOutputFull (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN UINTN Timeout
- );
-
-#endif
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/ComponentName.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/ComponentName.c deleted file mode 100644 index 1c3e84ec6d..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/ComponentName.c +++ /dev/null @@ -1,241 +0,0 @@ -/** @file
- UEFI Component Name(2) protocol implementation for Ps2MouseDxe driver.
-
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
-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 "Ps2Mouse.h"
-
-//
-// EFI Component Name Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gPs2MouseComponentName = {
- Ps2MouseComponentNameGetDriverName,
- Ps2MouseComponentNameGetControllerName,
- "eng"
-};
-
-//
-// EFI Component Name 2 Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPs2MouseComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) Ps2MouseComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) Ps2MouseComponentNameGetControllerName,
- "en"
-};
-
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPs2MouseDriverNameTable[] = {
- {
- "eng;en",
- L"PS/2 Mouse Driver"
- },
- {
- NULL,
- NULL
- }
-};
-
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
-
- @param DriverName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-Ps2MouseComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- )
-{
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mPs2MouseDriverNameTable,
- DriverName,
- (BOOLEAN)(This == &gPs2MouseComponentName)
- );
-}
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param ControllerHandle[in] The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
-
- @param ChildHandle[in] The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
-
- @param ControllerName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
-
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
-
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-Ps2MouseComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- )
-{
- EFI_STATUS Status;
- EFI_SIMPLE_POINTER_PROTOCOL *SimplePointerProtocol;
- PS2_MOUSE_DEV *MouseDev;
- EFI_ISA_IO_PROTOCOL *IsaIoProtocol;
-
- //
- // This is a device driver, so ChildHandle must be NULL.
- //
- if (ChildHandle != NULL) {
- return EFI_UNSUPPORTED;
- }
- //
- // Check Controller's handle
- //
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiIsaIoProtocolGuid,
- (VOID **) &IsaIoProtocol,
- gPS2MouseDriver.DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (!EFI_ERROR (Status)) {
- gBS->CloseProtocol (
- ControllerHandle,
- &gEfiIsaIoProtocolGuid,
- gPS2MouseDriver.DriverBindingHandle,
- ControllerHandle
- );
-
- return EFI_UNSUPPORTED;
- }
-
- if (Status != EFI_ALREADY_STARTED) {
- return EFI_UNSUPPORTED;
- }
- //
- // Get the device context
- //
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiSimplePointerProtocolGuid,
- (VOID **) &SimplePointerProtocol,
- gPS2MouseDriver.DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- MouseDev = PS2_MOUSE_DEV_FROM_THIS (SimplePointerProtocol);
-
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- MouseDev->ControllerNameTable,
- ControllerName,
- (BOOLEAN)(This == &gPs2MouseComponentName)
- );
-}
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.c b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.c deleted file mode 100644 index 43fad21903..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.c +++ /dev/null @@ -1,792 +0,0 @@ -/** @file
- PS/2 Mouse driver. Routines that interacts with callers,
- conforming to EFI driver model.
-
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
-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 "Ps2Mouse.h"
-#include "CommPs2.h"
-
-///
-/// DriverBinding Protocol Instance
-///
-EFI_DRIVER_BINDING_PROTOCOL gPS2MouseDriver = {
- PS2MouseDriverSupported,
- PS2MouseDriverStart,
- PS2MouseDriverStop,
- 0xa,
- NULL,
- NULL
-};
-
-/**
- Test to see if this driver supports ControllerHandle. Any ControllerHandle
- than contains a IsaIo protocol can be supported.
-
- @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.
-
- @retval EFI_SUCCESS This driver supports this device
- @retval EFI_ALREADY_STARTED This driver is already running on this device
- @retval other This driver does not support this device
-
-**/
-EFI_STATUS
-EFIAPI
-PS2MouseDriverSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- EFI_STATUS Status;
- EFI_ISA_IO_PROTOCOL *IsaIo;
-
- Status = EFI_SUCCESS;
-
- //
- // Open the IO Abstraction(s) needed to perform the supported test
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- (VOID **) &IsaIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Use the ISA I/O Protocol to see if Controller is the Keyboard controller
- //
- switch (IsaIo->ResourceList->Device.HID) {
- case EISA_PNP_ID (0xF03):
- //
- // Microsoft PS/2 style mouse
- //
- case EISA_PNP_ID (0xF13):
- //
- // PS/2 Port for PS/2-style Mice
- //
- break;
-
- case EISA_PNP_ID (0x303):
- //
- // IBM Enhanced (101/102-key, PS/2 mouse support)
- //
- if (IsaIo->ResourceList->Device.UID == 1) {
- break;
- }
-
- default:
- Status = EFI_UNSUPPORTED;
- break;
- }
- //
- // Close the I/O Abstraction(s) used to perform the supported test
- //
- gBS->CloseProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- return Status;
-}
-
-/**
- Start this driver on ControllerHandle by opening a IsaIo protocol, creating
- PS2_MOUSE_ABSOLUTE_POINTER_DEV device and install gEfiAbsolutePointerProtocolGuid
- finally.
-
- @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
-
-**/
-EFI_STATUS
-EFIAPI
-PS2MouseDriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- EFI_STATUS Status;
- EFI_STATUS EmptyStatus;
- EFI_ISA_IO_PROTOCOL *IsaIo;
- PS2_MOUSE_DEV *MouseDev;
- UINT8 Data;
- EFI_TPL OldTpl;
- EFI_STATUS_CODE_VALUE StatusCode;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
-
- StatusCode = 0;
- MouseDev = NULL;
- IsaIo = NULL;
-
- //
- // Open the device path protocol
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // Report that the keyboard is being enabled
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_MOUSE | EFI_P_PC_ENABLE,
- ParentDevicePath
- );
-
- //
- // Get the ISA I/O Protocol on Controller's handle
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- (VOID **) &IsaIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- return EFI_INVALID_PARAMETER;
- }
- //
- // Raise TPL to avoid keyboard operation impact
- //
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
-
- //
- // Allocate private data
- //
- MouseDev = AllocateZeroPool (sizeof (PS2_MOUSE_DEV));
- if (MouseDev == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ErrorExit;
- }
- //
- // Setup the device instance
- //
- MouseDev->Signature = PS2_MOUSE_DEV_SIGNATURE;
- MouseDev->Handle = Controller;
- MouseDev->SampleRate = SampleRate20;
- MouseDev->Resolution = MouseResolution4;
- MouseDev->Scaling = Scaling1;
- MouseDev->DataPackageSize = 3;
- MouseDev->IsaIo = IsaIo;
- MouseDev->DevicePath = ParentDevicePath;
-
- //
- // Resolution = 4 counts/mm
- //
- MouseDev->Mode.ResolutionX = 4;
- MouseDev->Mode.ResolutionY = 4;
- MouseDev->Mode.LeftButton = TRUE;
- MouseDev->Mode.RightButton = TRUE;
-
- MouseDev->SimplePointerProtocol.Reset = MouseReset;
- MouseDev->SimplePointerProtocol.GetState = MouseGetState;
- MouseDev->SimplePointerProtocol.Mode = &(MouseDev->Mode);
-
- //
- // Initialize keyboard controller if necessary
- //
- IsaIo->Io.Read (IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);
- //
- // Fix for random hangs in System waiting for the Key if no KBC is present in BIOS.
- //
- if ((Data & (KBC_PARE | KBC_TIM)) == (KBC_PARE | KBC_TIM)) {
- //
- // If nobody decodes KBC I/O port, it will read back as 0xFF.
- // Check the Time-Out and Parity bit to see if it has an active KBC in system
- //
- Status = EFI_DEVICE_ERROR;
- StatusCode = EFI_PERIPHERAL_MOUSE | EFI_P_EC_NOT_DETECTED;
- goto ErrorExit;
- }
-
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_MOUSE | EFI_P_MOUSE_PC_SELF_TEST,
- ParentDevicePath
- );
-
- if ((Data & KBC_SYSF) != KBC_SYSF) {
- Status = KbcSelfTest (IsaIo);
- if (EFI_ERROR (Status)) {
- StatusCode = EFI_PERIPHERAL_MOUSE | EFI_P_EC_CONTROLLER_ERROR;
- goto ErrorExit;
- }
- }
-
- KbcEnableAux (IsaIo);
-
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_MOUSE | EFI_P_PC_PRESENCE_DETECT,
- ParentDevicePath
- );
-
- //
- // Reset the mouse
- //
- Status = MouseDev->SimplePointerProtocol.Reset (
- &MouseDev->SimplePointerProtocol,
- FeaturePcdGet (PcdPs2MouseExtendedVerification)
- );
- if (EFI_ERROR (Status)) {
- //
- // mouse not connected
- //
- Status = EFI_SUCCESS;
- StatusCode = EFI_PERIPHERAL_MOUSE | EFI_P_EC_NOT_DETECTED;
- goto ErrorExit;
- }
-
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_MOUSE | EFI_P_PC_DETECTED,
- ParentDevicePath
- );
-
- //
- // Setup the WaitForKey event
- //
- Status = gBS->CreateEvent (
- EVT_NOTIFY_WAIT,
- TPL_NOTIFY,
- MouseWaitForInput,
- MouseDev,
- &((MouseDev->SimplePointerProtocol).WaitForInput)
- );
- if (EFI_ERROR (Status)) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ErrorExit;
- }
- //
- // Setup a periodic timer, used to poll mouse state
- //
- Status = gBS->CreateEvent (
- EVT_TIMER | EVT_NOTIFY_SIGNAL,
- TPL_NOTIFY,
- PollMouse,
- MouseDev,
- &MouseDev->TimerEvent
- );
- if (EFI_ERROR (Status)) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ErrorExit;
- }
- //
- // Start timer to poll mouse (100 samples per second)
- //
- Status = gBS->SetTimer (MouseDev->TimerEvent, TimerPeriodic, 100000);
- if (EFI_ERROR (Status)) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ErrorExit;
- }
-
- MouseDev->ControllerNameTable = NULL;
- AddUnicodeString2 (
- "eng",
- gPs2MouseComponentName.SupportedLanguages,
- &MouseDev->ControllerNameTable,
- L"PS/2 Mouse Device",
- TRUE
- );
- AddUnicodeString2 (
- "en",
- gPs2MouseComponentName2.SupportedLanguages,
- &MouseDev->ControllerNameTable,
- L"PS/2 Mouse Device",
- FALSE
- );
-
-
- //
- // Install protocol interfaces for the mouse device.
- //
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Controller,
- &gEfiSimplePointerProtocolGuid,
- &MouseDev->SimplePointerProtocol,
- NULL
- );
- if (EFI_ERROR (Status)) {
- goto ErrorExit;
- }
-
- gBS->RestoreTPL (OldTpl);
-
- return Status;
-
-ErrorExit:
-
- if (Status != EFI_DEVICE_ERROR) {
- KbcDisableAux (IsaIo);
- }
-
- if (StatusCode != 0) {
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- StatusCode,
- ParentDevicePath
- );
- }
-
- if ((MouseDev != NULL) && (MouseDev->SimplePointerProtocol.WaitForInput != NULL)) {
- gBS->CloseEvent (MouseDev->SimplePointerProtocol.WaitForInput);
- }
-
- if ((MouseDev != NULL) && (MouseDev->TimerEvent != NULL)) {
- gBS->CloseEvent (MouseDev->TimerEvent);
- }
-
- if ((MouseDev != NULL) && (MouseDev->ControllerNameTable != NULL)) {
- FreeUnicodeStringTable (MouseDev->ControllerNameTable);
- }
-
- if (Status != EFI_DEVICE_ERROR) {
- //
- // Since there will be no timer handler for mouse input any more,
- // exhaust input data just in case there is still mouse data left
- //
- EmptyStatus = EFI_SUCCESS;
- while (!EFI_ERROR (EmptyStatus)) {
- EmptyStatus = In8042Data (IsaIo, &Data);
- }
- }
-
- if (MouseDev != NULL) {
- FreePool (MouseDev);
- }
-
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- gBS->CloseProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- gBS->RestoreTPL (OldTpl);
-
- return Status;
-}
-
-/**
- Stop this driver on ControllerHandle. Support stopping any child handles
- created by this driver.
-
- @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
-
-**/
-EFI_STATUS
-EFIAPI
-PS2MouseDriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- )
-{
- EFI_STATUS Status;
- EFI_SIMPLE_POINTER_PROTOCOL *SimplePointerProtocol;
- PS2_MOUSE_DEV *MouseDev;
- UINT8 Data;
-
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiSimplePointerProtocolGuid,
- (VOID **) &SimplePointerProtocol,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return EFI_SUCCESS;
- }
-
- MouseDev = PS2_MOUSE_DEV_FROM_THIS (SimplePointerProtocol);
-
- //
- // Report that the keyboard is being disabled
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_MOUSE | EFI_P_PC_DISABLE,
- MouseDev->DevicePath
- );
-
- Status = gBS->UninstallProtocolInterface (
- Controller,
- &gEfiSimplePointerProtocolGuid,
- &MouseDev->SimplePointerProtocol
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Cancel mouse data polling timer, close timer event
- //
- gBS->SetTimer (MouseDev->TimerEvent, TimerCancel, 0);
- gBS->CloseEvent (MouseDev->TimerEvent);
-
- //
- // Since there will be no timer handler for mouse input any more,
- // exhaust input data just in case there is still mouse data left
- //
- Status = EFI_SUCCESS;
- while (!EFI_ERROR (Status)) {
- Status = In8042Data (MouseDev->IsaIo, &Data);
- }
-
- gBS->CloseEvent (MouseDev->SimplePointerProtocol.WaitForInput);
- FreeUnicodeStringTable (MouseDev->ControllerNameTable);
- FreePool (MouseDev);
-
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- gBS->CloseProtocol (
- Controller,
- &gEfiIsaIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- return EFI_SUCCESS;
-}
-
-/**
- Reset the Mouse and do BAT test for it, if ExtendedVerification is TRUE and there is a mouse device connected to system
-
- @param This - Pointer of simple pointer Protocol.
- @param ExtendedVerification - Whether configure mouse parameters. True: do; FALSE: skip.
-
-
- @retval EFI_SUCCESS - The command byte is written successfully.
- @retval EFI_DEVICE_ERROR - Errors occurred during resetting keyboard.
-
-**/
-EFI_STATUS
-EFIAPI
-MouseReset (
- IN EFI_SIMPLE_POINTER_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- )
-{
- EFI_STATUS Status;
- PS2_MOUSE_DEV *MouseDev;
- EFI_TPL OldTpl;
- BOOLEAN KeyboardEnable;
- UINT8 Data;
-
- MouseDev = PS2_MOUSE_DEV_FROM_THIS (This);
-
- //
- // Report reset progress code
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- EFI_PERIPHERAL_MOUSE | EFI_P_PC_RESET,
- MouseDev->DevicePath
- );
-
- KeyboardEnable = FALSE;
-
- //
- // Raise TPL to avoid keyboard operation impact
- //
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
-
- ZeroMem (&MouseDev->State, sizeof (EFI_SIMPLE_POINTER_STATE));
- MouseDev->StateChanged = FALSE;
-
- //
- // Exhaust input data
- //
- Status = EFI_SUCCESS;
- while (!EFI_ERROR (Status)) {
- Status = In8042Data (MouseDev->IsaIo, &Data);
- }
-
- CheckKbStatus (MouseDev->IsaIo, &KeyboardEnable);
-
- KbcDisableKb (MouseDev->IsaIo);
-
- MouseDev->IsaIo->Io.Read (MouseDev->IsaIo, EfiIsaIoWidthUint8, KBC_CMD_STS_PORT, 1, &Data);
-
- //
- // if there's data block on KBC data port, read it out
- //
- if ((Data & KBC_OUTB) == KBC_OUTB) {
- MouseDev->IsaIo->Io.Read (MouseDev->IsaIo, EfiIsaIoWidthUint8, KBC_DATA_PORT, 1, &Data);
- }
-
- Status = EFI_SUCCESS;
- //
- // The PS2 mouse driver reset behavior is always successfully return no matter wheater or not there is mouse connected to system.
- // This behavior is needed by performance speed. The following mouse command only succeessfully finish when mouse device is
- // connected to system, so if PS2 mouse device not connect to system or user not ask for, we skip the mouse configuration and enabling
- //
- if (ExtendedVerification && CheckMouseConnect (MouseDev)) {
- //
- // Send mouse reset command and set mouse default configure
- //
- Status = PS2MouseReset (MouseDev->IsaIo);
- if (EFI_ERROR (Status)) {
- Status = EFI_DEVICE_ERROR;
- goto Exit;
- }
-
- Status = PS2MouseSetSampleRate (MouseDev->IsaIo, MouseDev->SampleRate);
- if (EFI_ERROR (Status)) {
- Status = EFI_DEVICE_ERROR;
- goto Exit;
- }
-
- Status = PS2MouseSetResolution (MouseDev->IsaIo, MouseDev->Resolution);
- if (EFI_ERROR (Status)) {
- Status = EFI_DEVICE_ERROR;
- goto Exit;
- }
-
- Status = PS2MouseSetScaling (MouseDev->IsaIo, MouseDev->Scaling);
- if (EFI_ERROR (Status)) {
- Status = EFI_DEVICE_ERROR;
- goto Exit;
- }
-
- Status = PS2MouseEnable (MouseDev->IsaIo);
- if (EFI_ERROR (Status)) {
- Status = EFI_DEVICE_ERROR;
- goto Exit;
- }
- }
-Exit:
- gBS->RestoreTPL (OldTpl);
-
- if (KeyboardEnable) {
- KbcEnableKb (MouseDev->IsaIo);
- }
-
- return Status;
-}
-
-/**
- Check whether there is Ps/2 mouse device in system
-
- @param MouseDev - Mouse Private Data Structure
-
- @retval TRUE - Keyboard in System.
- @retval FALSE - Keyboard not in System.
-
-**/
-BOOLEAN
-CheckMouseConnect (
- IN PS2_MOUSE_DEV *MouseDev
- )
-
-{
- EFI_STATUS Status;
-
- Status = PS2MouseEnable (MouseDev->IsaIo);
- if (!EFI_ERROR (Status)) {
- return TRUE;
- }
-
- return FALSE;
-}
-
-/**
- Get and Clear mouse status.
-
- @param This - Pointer of simple pointer Protocol.
- @param State - Output buffer holding status.
-
- @retval EFI_INVALID_PARAMETER Output buffer is invalid.
- @retval EFI_NOT_READY Mouse is not changed status yet.
- @retval EFI_SUCCESS Mouse status is changed and get successful.
-**/
-EFI_STATUS
-EFIAPI
-MouseGetState (
- IN EFI_SIMPLE_POINTER_PROTOCOL *This,
- IN OUT EFI_SIMPLE_POINTER_STATE *State
- )
-{
- PS2_MOUSE_DEV *MouseDev;
- EFI_TPL OldTpl;
-
- MouseDev = PS2_MOUSE_DEV_FROM_THIS (This);
-
- if (State == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (!MouseDev->StateChanged) {
- return EFI_NOT_READY;
- }
-
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
- CopyMem (State, &(MouseDev->State), sizeof (EFI_SIMPLE_POINTER_STATE));
-
- //
- // clear mouse state
- //
- MouseDev->State.RelativeMovementX = 0;
- MouseDev->State.RelativeMovementY = 0;
- MouseDev->State.RelativeMovementZ = 0;
- MouseDev->StateChanged = FALSE;
- gBS->RestoreTPL (OldTpl);
-
- return EFI_SUCCESS;
-}
-
-/**
-
- Event notification function for SIMPLE_POINTER.WaitForInput event.
- Signal the event if there is input from mouse.
-
- @param Event event object
- @param Context event context
-
-**/
-VOID
-EFIAPI
-MouseWaitForInput (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- PS2_MOUSE_DEV *MouseDev;
-
- MouseDev = (PS2_MOUSE_DEV *) Context;
-
- //
- // Someone is waiting on the mouse event, if there's
- // input from mouse, signal the event
- //
- if (MouseDev->StateChanged) {
- gBS->SignalEvent (Event);
- }
-
-}
-
-/**
- Event notification function for TimerEvent event.
- If mouse device is connected to system, try to get the mouse packet data.
-
- @param Event - TimerEvent in PS2_MOUSE_DEV
- @param Context - Pointer to PS2_MOUSE_DEV structure
-
-**/
-VOID
-EFIAPI
-PollMouse (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-
-{
- PS2_MOUSE_DEV *MouseDev;
-
- MouseDev = (PS2_MOUSE_DEV *) Context;
-
- //
- // Polling mouse packet data
- //
- PS2MouseGetPacket (MouseDev);
-}
-
-/**
- The user Entry Point for module Ps2Mouse. The user code starts with this function.
-
- @param[in] ImageHandle The firmware allocated handle for the EFI image.
- @param[in] SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The entry point is executed successfully.
- @retval other Some error occurs when executing this entry point.
-
-**/
-EFI_STATUS
-EFIAPI
-InitializePs2Mouse(
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- //
- // Install driver model protocol(s).
- //
- Status = EfiLibInstallDriverBindingComponentName2 (
- ImageHandle,
- SystemTable,
- &gPS2MouseDriver,
- ImageHandle,
- &gPs2MouseComponentName,
- &gPs2MouseComponentName2
- );
- ASSERT_EFI_ERROR (Status);
-
-
- return Status;
-}
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.h b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.h deleted file mode 100644 index 078cefa910..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.h +++ /dev/null @@ -1,400 +0,0 @@ -/** @file
- PS/2 Mouse driver header file.
-
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
-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.
-
-**/
-
-#ifndef _PS2MOUSE_H_
-#define _PS2MOUSE_H_
-
-#include <Uefi.h>
-
-#include <Protocol/SimplePointer.h>
-#include <Protocol/IsaIo.h>
-#include <Protocol/DevicePath.h>
-
-#include <Library/DebugLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/UefiLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/ReportStatusCodeLib.h>
-#include <Library/PcdLib.h>
-
-//
-// Global Variables
-//
-extern EFI_DRIVER_BINDING_PROTOCOL gPS2MouseDriver;
-extern EFI_COMPONENT_NAME_PROTOCOL gPs2MouseComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gPs2MouseComponentName2;
-
-//
-// PS/2 mouse sample rate
-//
-typedef enum {
- SampleRate10,
- SampleRate20,
- SampleRate40,
- SampleRate60,
- SampleRate80,
- SampleRate100,
- SampleRate200,
- MaxSampleRate
-} MOUSE_SR;
-
-//
-// PS/2 mouse resolution
-//
-typedef enum {
- MouseResolution1,
- MouseResolution2,
- MouseResolution4,
- MouseResolution8,
- MaxResolution
-} MOUSE_RE;
-
-//
-// PS/2 mouse scaling
-//
-typedef enum {
- Scaling1,
- Scaling2
-} MOUSE_SF;
-
-//
-// Driver Private Data
-//
-#define PS2_MOUSE_DEV_SIGNATURE SIGNATURE_32 ('p', 's', '2', 'm')
-
-typedef struct {
- UINTN Signature;
-
- EFI_HANDLE Handle;
- EFI_SIMPLE_POINTER_PROTOCOL SimplePointerProtocol;
- EFI_SIMPLE_POINTER_STATE State;
- EFI_SIMPLE_POINTER_MODE Mode;
- BOOLEAN StateChanged;
-
- //
- // PS2 Mouse device specific information
- //
- MOUSE_SR SampleRate;
- MOUSE_RE Resolution;
- MOUSE_SF Scaling;
- UINT8 DataPackageSize;
-
- EFI_ISA_IO_PROTOCOL *IsaIo;
-
- EFI_EVENT TimerEvent;
-
- EFI_UNICODE_STRING_TABLE *ControllerNameTable;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
-} PS2_MOUSE_DEV;
-
-#define PS2_MOUSE_DEV_FROM_THIS(a) CR (a, PS2_MOUSE_DEV, SimplePointerProtocol, PS2_MOUSE_DEV_SIGNATURE)
-
-//
-// Function prototypes
-//
-/**
- Test to see if this driver supports ControllerHandle. Any ControllerHandle
- than contains a IsaIo protocol can be supported.
-
- @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.
-
- @retval EFI_SUCCESS This driver supports this device
- @retval EFI_ALREADY_STARTED This driver is already running on this device
- @retval other This driver does not support this device
-
-**/
-EFI_STATUS
-EFIAPI
-PS2MouseDriverSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-/**
- Start this driver on ControllerHandle by opening a IsaIo
- protocol, creating PS2_MOUSE_ABSOLUTE_POINTER_DEV device and install gEfiAbsolutePointerProtocolGuid
- finnally.
-
- @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
-
-**/
-EFI_STATUS
-EFIAPI
-PS2MouseDriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-/**
- Stop this driver on ControllerHandle. Support stopping any child handles
- created by this driver.
-
- @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
-
-**/
-EFI_STATUS
-EFIAPI
-PS2MouseDriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- );
-
-//
-// EFI Component Name Functions
-//
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
-
- @param DriverName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-Ps2MouseComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- );
-
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param ControllerHandle[in] The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
-
- @param ChildHandle[in] The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
-
- @param ControllerName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
-
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
-
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-Ps2MouseComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- );
-
-/**
- Reset the Mouse and do BAT test for it, if ExtendedVerification is TRUE and there is a mouse device connected to system
-
- @param This - Pointer of simple pointer Protocol.
- @param ExtendedVerification - Whether configure mouse parameters. True: do; FALSE: skip.
-
-
- @retval EFI_SUCCESS - The command byte is written successfully.
- @retval EFI_DEVICE_ERROR - Errors occurred during resetting keyboard.
-
-**/
-EFI_STATUS
-EFIAPI
-MouseReset (
- IN EFI_SIMPLE_POINTER_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- );
-
-/**
- Get and Clear mouse status.
-
- @param This - Pointer of simple pointer Protocol.
- @param State - Output buffer holding status.
-
- @retval EFI_INVALID_PARAMETER Output buffer is invalid.
- @retval EFI_NOT_READY Mouse is not changed status yet.
- @retval EFI_SUCCESS Mouse status is changed and get successful.
-**/
-EFI_STATUS
-EFIAPI
-MouseGetState (
- IN EFI_SIMPLE_POINTER_PROTOCOL *This,
- IN OUT EFI_SIMPLE_POINTER_STATE *State
- );
-
-/**
-
- Event notification function for SIMPLE_POINTER.WaitForInput event.
- Signal the event if there is input from mouse.
-
- @param Event event object
- @param Context event context
-
-**/
-VOID
-EFIAPI
-MouseWaitForInput (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
-
-/**
- Event notification function for TimerEvent event.
- If mouse device is connected to system, try to get the mouse packet data.
-
- @param Event - TimerEvent in PS2_MOUSE_DEV
- @param Context - Pointer to PS2_MOUSE_DEV structure
-
-**/
-VOID
-EFIAPI
-PollMouse (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
-
-/**
- I/O work flow of in 8042 data.
-
- @param IsaIo Pointer to instance of EFI_ISA_IO_PROTOCOL
- @param Data Data value
-
- @retval EFI_SUCCESS Success to execute I/O work flow
- @retval EFI_TIMEOUT Keyboard controller time out.
-**/
-EFI_STATUS
-In8042Data (
- IN EFI_ISA_IO_PROTOCOL *IsaIo,
- IN OUT UINT8 *Data
- );
-
-/**
- Check whether there is Ps/2 mouse device in system
-
- @param MouseDev - Mouse Private Data Structure
-
- @retval TRUE - Keyboard in System.
- @retval FALSE - Keyboard not in System.
-
-**/
-BOOLEAN
-CheckMouseConnect (
- IN PS2_MOUSE_DEV *MouseDev
- );
-
-#endif
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxe.inf b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxe.inf deleted file mode 100644 index 876b09ff8e..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxe.inf +++ /dev/null @@ -1,75 +0,0 @@ -## @file
-# PS2 Mouse Driver.
-#
-# This dirver provides support for PS2 based mice.
-#
-# Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
-#
-# 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.
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = Ps2MouseDxe
- MODULE_UNI_FILE = Ps2MouseDxe.uni
- FILE_GUID = 202A2B0E-9A31-4812-B291-8747DF152439
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = InitializePs2Mouse
-
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-# DRIVER_BINDING = gPS2MouseDriver;
-# COMPONENT_NAME = gPs2MouseComponentName;
-# COMPONENT_NAME2 = gPs2MouseComponentName2;
-#
-
-[Sources]
- ComponentName.c
- CommPs2.h
- CommPs2.c
- Ps2Mouse.h
- Ps2Mouse.c
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
-
-[LibraryClasses]
- ReportStatusCodeLib
- UefiBootServicesTableLib
- MemoryAllocationLib
- BaseMemoryLib
- UefiLib
- UefiDriverEntryPoint
- DebugLib
- PcdLib
-
-[Protocols]
- gEfiIsaIoProtocolGuid ## TO_START
- gEfiSimplePointerProtocolGuid ## BY_START
- gEfiDevicePathProtocolGuid ## TO_START
-
-[FeaturePcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdPs2MouseExtendedVerification ## CONSUMES
-
-#
-# [Event]
-#
-# ##
-# # Timer event used to check the mouse state at a regular interval.
-# #
-# EVENT_TYPE_PERIODIC_TIMER ## CONSUMES
-#
-
-[UserExtensions.TianoCore."ExtraFiles"]
- Ps2MouseDxeExtra.uni
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxe.uni b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxe.uni deleted file mode 100644 index 2c3d4a2442..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxe.uni +++ /dev/null @@ -1,22 +0,0 @@ -// /** @file
-// PS2 Mouse Driver.
-//
-// This dirver provides support for PS2 based mice.
-//
-// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
-//
-// 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.
-//
-// **/
-
-
-#string STR_MODULE_ABSTRACT #language en-US "PS2 Mouse Driver"
-
-#string STR_MODULE_DESCRIPTION #language en-US "This driver provides support for PS2-based mice."
-
diff --git a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxeExtra.uni b/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxeExtra.uni deleted file mode 100644 index 851cf291f3..0000000000 --- a/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxeExtra.uni +++ /dev/null @@ -1,20 +0,0 @@ -// /** @file
-// Ps2MouseDxe Localized Strings and Content
-//
-// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
-//
-// 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.
-//
-// **/
-
-#string STR_PROPERTIES_MODULE_NAME
-#language en-US
-"PS2 Mouse DXE Driver"
-
-
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ata.c b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ata.c deleted file mode 100644 index c541eb8991..0000000000 --- a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ata.c +++ /dev/null @@ -1,2799 +0,0 @@ -/** @file
- This file contains all helper functions on the ATA command
-
- Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
- 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.
-
- @par Revision Reference:
- 2002-6: Add Atapi6 enhancement, support >120GB hard disk, including
- update - ATAIdentity() func
- update - AtaBlockIoReadBlocks() func
- update - AtaBlockIoWriteBlocks() func
- add - AtaAtapi6Identify() func
- add - AtaReadSectorsExt() func
- add - AtaWriteSectorsExt() func
- add - AtaPioDataInExt() func
- add - AtaPioDataOutExt() func
-
-**/
-
-#include "IdeBus.h"
-/**
- This function is called by ATAIdentify() to identity whether this disk
- supports ATA/ATAPI6 48bit addressing, ie support >120G capacity
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record
- all the information of the IDE device.
-
- @retval EFI_SUCCESS The disk specified by IdeDev is a Atapi6 supported one and
- 48-bit addressing must be used
- @retval EFI_UNSUPPORTED The disk dosn't not support Atapi6 or it supports but the
- capacity is below 120G, 48bit addressing is not needed
- @retval EFI_DEVICE_ERROR The identify data in IdeDev is incorrect
- @retval EFI_INVALID_PARAMETER The identify data in IdeDev is NULL.
-
- @note This function must be called after DEVICE_IDENTITY command has been
- successfully returned
-
-**/
-EFI_STATUS
-AtaAtapi6Identify (
- IN IDE_BLK_IO_DEV *IdeDev
- )
-{
- UINT8 Index;
- EFI_LBA TmpLba;
- EFI_LBA Capacity;
- EFI_IDENTIFY_DATA *Atapi6IdentifyStruct;
-
- if (IdeDev->IdData == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- Atapi6IdentifyStruct = IdeDev->IdData;
-
- if ((Atapi6IdentifyStruct->AtapiData.cmd_set_support_83 & (BIT15 | BIT14)) != 0x4000) {
- //
- // Per ATA-6 spec, word83: bit15 is zero and bit14 is one
- //
- return EFI_DEVICE_ERROR;
- }
-
- if ((Atapi6IdentifyStruct->AtapiData.cmd_set_support_83 & BIT10) == 0) {
- //
- // The device dosn't support 48 bit addressing
- //
- return EFI_UNSUPPORTED;
- }
-
- //
- // 48 bit address feature set is supported, get maximum capacity
- //
- Capacity = Atapi6IdentifyStruct->AtaData.maximum_lba_for_48bit_addressing[0];
- for (Index = 1; Index < 4; Index++) {
- //
- // Lower byte goes first: word[100] is the lowest word, word[103] is highest
- //
- TmpLba = Atapi6IdentifyStruct->AtaData.maximum_lba_for_48bit_addressing[Index];
- Capacity |= LShiftU64 (TmpLba, 16 * Index);
- }
-
- if (Capacity > MAX_28BIT_ADDRESSING_CAPACITY) {
- //
- // Capacity exceeds 120GB. 48-bit addressing is really needed
- //
- IdeDev->Type = Ide48bitAddressingHardDisk;
-
- //
- // Fill block media information:Media->LogicalPartition ,
- // Media->WriteCaching will be filledin the DiscoverIdeDevcie() function.
- //
- IdeDev->BlkIo.Media->IoAlign = 4;
- IdeDev->BlkIo.Media->MediaId = 1;
- IdeDev->BlkIo.Media->RemovableMedia = FALSE;
- IdeDev->BlkIo.Media->MediaPresent = TRUE;
- IdeDev->BlkIo.Media->ReadOnly = FALSE;
- IdeDev->BlkIo.Media->BlockSize = 0x200;
- IdeDev->BlkIo.Media->LastBlock = Capacity - 1;
-
- return EFI_SUCCESS;
- }
-
- return EFI_UNSUPPORTED;
-}
-/**
- Enable SMART of the disk if supported
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure,used to record
- all the information of the IDE device.
-**/
-VOID
-AtaSMARTSupport (
- IN IDE_BLK_IO_DEV *IdeDev
- )
-{
- EFI_STATUS Status;
- BOOLEAN SMARTSupported;
- UINT8 Device;
- EFI_IDENTIFY_DATA *TmpAtaIdentifyPointer;
- UINT8 DeviceSelect;
- UINT8 LBAMid;
- UINT8 LBAHigh;
-
- //
- // Detect if the device supports S.M.A.R.T.
- //
- if ((IdeDev->IdData->AtaData.command_set_supported_83 & 0xc000) != 0x4000) {
- //
- // Data in word 82 is not valid (bit15 shall be zero and bit14 shall be to one)
- //
- return ;
- } else {
- if ((IdeDev->IdData->AtaData.command_set_supported_82 & 0x0001) != 0x0001) {
- //
- // S.M.A.R.T is not supported by the device
- //
- SMARTSupported = FALSE;
- } else {
- SMARTSupported = TRUE;
- }
- }
-
- if (!SMARTSupported) {
- //
- // Report nonsupport status code
- //
- REPORT_STATUS_CODE (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_NOTSUPPORTED)
- );
- } else {
- //
- // Enable this feature
- //
- REPORT_STATUS_CODE (
- EFI_PROGRESS_CODE,
- (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_ENABLE)
- );
-
- Device = (UINT8) ((IdeDev->Device << 4) | 0xe0);
- Status = AtaNonDataCommandIn (
- IdeDev,
- ATA_CMD_SMART,
- Device,
- ATA_SMART_ENABLE_OPERATION,
- 0,
- 0,
- ATA_CONSTANT_4F,
- ATA_CONSTANT_C2
- );
- //
- // Detect if this feature is enabled
- //
- TmpAtaIdentifyPointer = (EFI_IDENTIFY_DATA *) AllocateZeroPool (sizeof (EFI_IDENTIFY_DATA));
- if (TmpAtaIdentifyPointer == NULL) {
- return;
- }
-
- DeviceSelect = (UINT8) ((IdeDev->Device) << 4);
- Status = AtaPioDataIn (
- IdeDev,
- (VOID *) TmpAtaIdentifyPointer,
- sizeof (EFI_IDENTIFY_DATA),
- ATA_CMD_IDENTIFY_DRIVE,
- DeviceSelect,
- 0,
- 0,
- 0,
- 0
- );
- if (EFI_ERROR (Status)) {
- gBS->FreePool (TmpAtaIdentifyPointer);
- return ;
- }
-
- //
- // Check if the feature is enabled
- //
- if ((TmpAtaIdentifyPointer->AtaData.command_set_feature_enb_85 & 0x0001) == 0x0001) {
- //
- // Read status data
- //
- AtaNonDataCommandIn (
- IdeDev,
- ATA_CMD_SMART,
- Device,
- ATA_SMART_RETURN_STATUS,
- 0,
- 0,
- ATA_CONSTANT_4F,
- ATA_CONSTANT_C2
- );
- LBAMid = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb);
- LBAHigh = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb);
-
- if ((LBAMid == 0x4f) && (LBAHigh == 0xc2)) {
- //
- // The threshold exceeded condition is not detected by the device
- //
- REPORT_STATUS_CODE (
- EFI_PROGRESS_CODE,
- (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_UNDERTHRESHOLD)
- );
-
- } else if ((LBAMid == 0xf4) && (LBAHigh == 0x2c)) {
- //
- // The threshold exceeded condition is detected by the device
- //
- REPORT_STATUS_CODE (
- EFI_PROGRESS_CODE,
- (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_OVERTHRESHOLD)
- );
- }
-
- } else {
- //
- // Report disabled status code
- //
- REPORT_STATUS_CODE (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_ATA_BUS_SMART_DISABLED)
- );
- }
-
- gBS->FreePool (TmpAtaIdentifyPointer);
- }
-
- return ;
-}
-/**
- Sends out an ATA Identify Command to the specified device.
-
- This function is called by DiscoverIdeDevice() during its device
- identification. It sends out the ATA Identify Command to the
- specified device. Only ATA device responses to this command. If
- the command succeeds, it returns the Identify data structure which
- contains information about the device. This function extracts the
- information it needs to fill the IDE_BLK_IO_DEV data structure,
- including device type, media block size, media capacity, and etc.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure,used to record
- all the information of the IDE device.
-
- @retval EFI_SUCCESS Identify ATA device successfully.
- @retval EFI_DEVICE_ERROR ATA Identify Device Command failed or device is not ATA device.
- @note parameter IdeDev will be updated in this function.
-
-**/
-EFI_STATUS
-ATAIdentify (
- IN IDE_BLK_IO_DEV *IdeDev
- )
-{
- EFI_STATUS Status;
- EFI_IDENTIFY_DATA *AtaIdentifyPointer;
- UINT32 Capacity;
- UINT8 DeviceSelect;
- UINTN Retry;
-
- //
- // AtaIdentifyPointer is used for accommodating returned IDENTIFY data of
- // the ATA Identify command
- //
- AtaIdentifyPointer = (EFI_IDENTIFY_DATA *) AllocateZeroPool (sizeof (EFI_IDENTIFY_DATA));
- if (AtaIdentifyPointer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- //
- // use ATA PIO Data In protocol to send ATA Identify command
- // and receive data from device
- //
- DeviceSelect = (UINT8) ((IdeDev->Device) << 4);
-
-
- Retry = 3;
- while (Retry > 0) {
- Status = AtaPioDataIn (
- IdeDev,
- (VOID *) AtaIdentifyPointer,
- sizeof (EFI_IDENTIFY_DATA),
- ATA_CMD_IDENTIFY_DRIVE,
- DeviceSelect,
- 0,
- 0,
- 0,
- 0
- );
- //
- // If ATA Identify command succeeds, then according to the received
- // IDENTIFY data,
- // identify the device type ( ATA or not ).
- // If ATA device, fill the information in IdeDev.
- // If not ATA device, return IDE_DEVICE_ERROR
- //
- if (!EFI_ERROR (Status)) {
-
- IdeDev->IdData = AtaIdentifyPointer;
-
- //
- // Print ATA Module Name
- //
- PrintAtaModuleName (IdeDev);
-
- //
- // bit 15 of pAtaIdentify->config is used to identify whether device is
- // ATA device or ATAPI device.
- // if 0, means ATA device; if 1, means ATAPI device.
- //
- if ((AtaIdentifyPointer->AtaData.config & 0x8000) == 0x00) {
- //
- // Detect if support S.M.A.R.T. If yes, enable it as default
- //
- AtaSMARTSupport (IdeDev);
-
- //
- // Check whether this device needs 48-bit addressing (ATAPI-6 ata device)
- //
- Status = AtaAtapi6Identify (IdeDev);
- if (!EFI_ERROR (Status)) {
- //
- // It's a disk with >120GB capacity, initialized in AtaAtapi6Identify()
- //
- return EFI_SUCCESS;
- } else if (Status == EFI_DEVICE_ERROR) {
- //
- // Some disk with big capacity (>200GB) is slow when being identified
- // and will return all zero for word83.
- // We try twice at first. If it fails, we do a SoftRest and try again.
- //
- Retry--;
- if (Retry == 1) {
- //
- // Do a SoftRest before the third attempt.
- //
- AtaSoftReset (IdeDev);
- }
- continue;
- }
- //
- // This is a hard disk <= 120GB capacity, treat it as normal hard disk
- //
- IdeDev->Type = IdeHardDisk;
-
- //
- // Block Media Information:
- // Media->LogicalPartition , Media->WriteCaching will be filled
- // in the DiscoverIdeDevcie() function.
- //
- IdeDev->BlkIo.Media->IoAlign = 4;
- IdeDev->BlkIo.Media->MediaId = 1;
- IdeDev->BlkIo.Media->RemovableMedia = FALSE;
- IdeDev->BlkIo.Media->MediaPresent = TRUE;
- IdeDev->BlkIo.Media->ReadOnly = FALSE;
- IdeDev->BlkIo.Media->BlockSize = 0x200;
-
- //
- // Calculate device capacity
- //
- Capacity = ((UINT32)AtaIdentifyPointer->AtaData.user_addressable_sectors_hi << 16) |
- AtaIdentifyPointer->AtaData.user_addressable_sectors_lo ;
- IdeDev->BlkIo.Media->LastBlock = Capacity - 1;
-
- return EFI_SUCCESS;
- }
-
- }
- break;
- }
-
- gBS->FreePool (AtaIdentifyPointer);
- //
- // Make sure the pIdData will not be freed again.
- //
- IdeDev->IdData = NULL;
-
- return EFI_DEVICE_ERROR;
-}
-
-/**
- This function is a helper function used to change the char order in a string. It
- is designed specially for the PrintAtaModuleName() function. After the IDE device
- is detected, the IDE driver gets the device module name by sending ATA command
- called ATA Identify Command or ATAPI Identify Command to the specified IDE device.
- The module name returned is a string of ASCII characters: the first character is bit8--bit15
- of the first word, the second character is BIT0--bit7 of the first word and so on. Thus
- the string can not be print directly before it is preprocessed by this func to change
- the order of characters in each word in the string.
-
- @param Destination Indicates the destination string.
- @param Source Indicates the source string.
- @param Size the length of the string
-**/
-VOID
-SwapStringChars (
- IN CHAR8 *Destination,
- IN CHAR8 *Source,
- IN UINT32 Size
- )
-{
- UINT32 Index;
- CHAR8 Temp;
-
- for (Index = 0; Index < Size; Index += 2) {
-
- Temp = Source[Index + 1];
- Destination[Index + 1] = Source[Index];
- Destination[Index] = Temp;
- }
-}
-/**
- This function is called by ATAIdentify() or ATAPIIdentify() to print device's module name.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record
- all the information of the IDE device.
-**/
-VOID
-PrintAtaModuleName (
- IN IDE_BLK_IO_DEV *IdeDev
- )
-{
- if (IdeDev->IdData == NULL) {
- return ;
- }
-
- SwapStringChars (IdeDev->ModelName, IdeDev->IdData->AtaData.ModelName, 40);
- IdeDev->ModelName[40] = 0x00;
-}
-
-/**
- This function is used to send out ATA commands conforms to the PIO Data In Protocol.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record
- all the information of the IDE device.
- @param Buffer buffer contained data transferred from device to host.
- @param ByteCount data size in byte unit of the buffer.
- @param AtaCommand value of the Command Register
- @param Head value of the Head/Device Register
- @param SectorCount value of the Sector Count Register
- @param SectorNumber value of the Sector Number Register
- @param CylinderLsb value of the low byte of the Cylinder Register
- @param CylinderMsb value of the high byte of the Cylinder Register
-
- @retval EFI_SUCCESS send out the ATA command and device send required data successfully.
- @retval EFI_DEVICE_ERROR command sent failed.
-
-**/
-EFI_STATUS
-AtaPioDataIn (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN VOID *Buffer,
- IN UINT32 ByteCount,
- IN UINT8 AtaCommand,
- IN UINT8 Head,
- IN UINT8 SectorCount,
- IN UINT8 SectorNumber,
- IN UINT8 CylinderLsb,
- IN UINT8 CylinderMsb
- )
-{
- UINTN WordCount;
- UINTN Increment;
- UINT16 *Buffer16;
- EFI_STATUS Status;
-
- Status = WaitForBSYClear (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // e0:1110,0000-- bit7 and bit5 are reserved bits.
- // bit6 set means LBA mode
- //
- IDEWritePortB (
- IdeDev->PciIo,
- IdeDev->IoPort->Head,
- (UINT8) ((IdeDev->Device << 4) | 0xe0 | Head)
- );
-
- //
- // All ATAPI device's ATA commands can be issued regardless of the
- // state of the DRDY
- //
- if (IdeDev->Type == IdeHardDisk) {
-
- Status = DRDYReady (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
- }
- //
- // set all the command parameters
- // Before write to all the following registers, BSY and DRQ must be 0.
- //
- Status = DRQClear2 (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- if (AtaCommand == ATA_CMD_SET_FEATURES) {
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Feature, 0x03);
- }
-
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorCount, SectorCount);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorNumber, SectorNumber);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb, CylinderLsb);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb, CylinderMsb);
-
- //
- // send command via Command Register
- //
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, AtaCommand);
-
- Buffer16 = (UINT16 *) Buffer;
-
- //
- // According to PIO data in protocol, host can perform a series of reads to
- // the data register after each time device set DRQ ready;
- // The data size of "a series of read" is command specific.
- // For most ATA command, data size received from device will not exceed
- // 1 sector, hence the data size for "a series of read" can be the whole data
- // size of one command request.
- // For ATA command such as Read Sector command, the data size of one ATA
- // command request is often larger than 1 sector, according to the
- // Read Sector command, the data size of "a series of read" is exactly 1
- // sector.
- // Here for simplification reason, we specify the data size for
- // "a series of read" to 1 sector (256 words) if data size of one ATA command
- // request is larger than 256 words.
- //
- Increment = 256;
-
- //
- // used to record bytes of currently transfered data
- //
- WordCount = 0;
-
- while (WordCount < ByteCount / 2) {
- //
- // Poll DRQ bit set, data transfer can be performed only when DRQ is ready.
- //
- Status = DRQReady2 (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- Status = CheckErrorStatus (IdeDev);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // Get the byte count for one series of read
- //
- if ((WordCount + Increment) > ByteCount / 2) {
- Increment = ByteCount / 2 - WordCount;
- }
-
- IDEReadPortWMultiple (
- IdeDev->PciIo,
- IdeDev->IoPort->Data,
- Increment,
- Buffer16
- );
-
- WordCount += Increment;
- Buffer16 += Increment;
-
- }
-
- DRQClear (IdeDev, ATATIMEOUT);
-
- return CheckErrorStatus (IdeDev);
-}
-
-/**
- This function is used to send out ATA commands conforms to the
- PIO Data Out Protocol.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
- @param *Buffer buffer contained data transferred from host to device.
- @param ByteCount data size in byte unit of the buffer.
- @param AtaCommand value of the Command Register
- @param Head value of the Head/Device Register
- @param SectorCount value of the Sector Count Register
- @param SectorNumber value of the Sector Number Register
- @param CylinderLsb value of the low byte of the Cylinder Register
- @param CylinderMsb value of the high byte of the Cylinder Register
-
- @retval EFI_SUCCESS send out the ATA command and device received required
- data successfully.
- @retval EFI_DEVICE_ERROR command sent failed.
-
-**/
-EFI_STATUS
-AtaPioDataOut (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN VOID *Buffer,
- IN UINT32 ByteCount,
- IN UINT8 AtaCommand,
- IN UINT8 Head,
- IN UINT8 SectorCount,
- IN UINT8 SectorNumber,
- IN UINT8 CylinderLsb,
- IN UINT8 CylinderMsb
- )
-{
- UINTN WordCount;
- UINTN Increment;
- UINT16 *Buffer16;
- EFI_STATUS Status;
-
- Status = WaitForBSYClear (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // select device via Head/Device register.
- // Before write Head/Device register, BSY and DRQ must be 0.
- //
- Status = DRQClear2 (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // e0:1110,0000-- bit7 and bit5 are reserved bits.
- // bit6 set means LBA mode
- //
- IDEWritePortB (
- IdeDev->PciIo,
- IdeDev->IoPort->Head,
- (UINT8) ((IdeDev->Device << 4) | 0xe0 | Head)
- );
-
- Status = DRDYReady (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // set all the command parameters
- // Before write to all the following registers, BSY and DRQ must be 0.
- //
- Status = DRQClear2 (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorCount, SectorCount);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorNumber, SectorNumber);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb, CylinderLsb);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb, CylinderMsb);
-
- //
- // send command via Command Register
- //
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, AtaCommand);
-
- Buffer16 = (UINT16 *) Buffer;
-
- //
- // According to PIO data out protocol, host can perform a series of
- // writes to the data register after each time device set DRQ ready;
- // The data size of "a series of read" is command specific.
- // For most ATA command, data size written to device will not exceed 1 sector,
- // hence the data size for "a series of write" can be the data size of one
- // command request.
- // For ATA command such as Write Sector command, the data size of one
- // ATA command request is often larger than 1 sector, according to the
- // Write Sector command, the data size of "a series of read" is exactly
- // 1 sector.
- // Here for simplification reason, we specify the data size for
- // "a series of write" to 1 sector (256 words) if data size of one ATA command
- // request is larger than 256 words.
- //
- Increment = 256;
- WordCount = 0;
-
- while (WordCount < ByteCount / 2) {
-
- //
- // DRQReady2-- read Alternate Status Register to determine the DRQ bit
- // data transfer can be performed only when DRQ is ready.
- //
- Status = DRQReady2 (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- Status = CheckErrorStatus (IdeDev);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // Check the remaining byte count is less than 512 bytes
- //
- if ((WordCount + Increment) > ByteCount / 2) {
- Increment = ByteCount / 2 - WordCount;
- }
- //
- // perform a series of write without check DRQ ready
- //
-
- IDEWritePortWMultiple (
- IdeDev->PciIo,
- IdeDev->IoPort->Data,
- Increment,
- Buffer16
- );
- WordCount += Increment;
- Buffer16 += Increment;
-
- }
-
- DRQClear (IdeDev, ATATIMEOUT);
-
- return CheckErrorStatus (IdeDev);
-}
-
-/**
- This function is used to analyze the Status Register and print out
- some debug information and if there is ERR bit set in the Status
- Register, the Error Register's value is also be parsed and print out.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to
- record all the information of the IDE device.
-
- @retval EFI_SUCCESS No err information in the Status Register.
- @retval EFI_DEVICE_ERROR Any err information in the Status Register.
-
-**/
-EFI_STATUS
-CheckErrorStatus (
- IN IDE_BLK_IO_DEV *IdeDev
- )
-{
- UINT8 StatusRegister;
- UINT8 ErrorRegister;
-
- StatusRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Status);
-
- DEBUG_CODE_BEGIN ();
-
- if ((StatusRegister & ATA_STSREG_DWF) != 0) {
- DEBUG (
- (EFI_D_BLKIO,
- "CheckErrorStatus()-- %02x : Error : Write Fault\n",
- StatusRegister)
- );
- }
-
- if ((StatusRegister & ATA_STSREG_CORR) != 0) {
- DEBUG (
- (EFI_D_BLKIO,
- "CheckErrorStatus()-- %02x : Error : Corrected Data\n",
- StatusRegister)
- );
- }
-
- if ((StatusRegister & ATA_STSREG_ERR) != 0) {
- ErrorRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Error);
-
- if ((ErrorRegister & ATA_ERRREG_BBK) != 0) {
- DEBUG (
- (EFI_D_BLKIO,
- "CheckErrorStatus()-- %02x : Error : Bad Block Detected\n",
- ErrorRegister)
- );
- }
-
- if ((ErrorRegister & ATA_ERRREG_UNC) != 0) {
- DEBUG (
- (EFI_D_BLKIO,
- "CheckErrorStatus()-- %02x : Error : Uncorrectable Data\n",
- ErrorRegister)
- );
- }
-
- if ((ErrorRegister & ATA_ERRREG_MC) != 0) {
- DEBUG (
- (EFI_D_BLKIO,
- "CheckErrorStatus()-- %02x : Error : Media Change\n",
- ErrorRegister)
- );
- }
-
- if ((ErrorRegister & ATA_ERRREG_ABRT) != 0) {
- DEBUG (
- (EFI_D_BLKIO,
- "CheckErrorStatus()-- %02x : Error : Abort\n",
- ErrorRegister)
- );
- }
-
- if ((ErrorRegister & ATA_ERRREG_TK0NF) != 0) {
- DEBUG (
- (EFI_D_BLKIO,
- "CheckErrorStatus()-- %02x : Error : Track 0 Not Found\n",
- ErrorRegister)
- );
- }
-
- if ((ErrorRegister & ATA_ERRREG_AMNF) != 0) {
- DEBUG (
- (EFI_D_BLKIO,
- "CheckErrorStatus()-- %02x : Error : Address Mark Not Found\n",
- ErrorRegister)
- );
- }
- }
-
- DEBUG_CODE_END ();
-
- if ((StatusRegister & (ATA_STSREG_ERR | ATA_STSREG_DWF | ATA_STSREG_CORR)) == 0) {
- return EFI_SUCCESS;
- }
-
- return EFI_DEVICE_ERROR;
-
-}
-
-/**
- This function is called by the AtaBlkIoReadBlocks() to perform reading from
- media in block unit.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record
- all the information of the IDE device.
- @param DataBuffer A pointer to the destination buffer for the data.
- @param Lba The starting logical block address to read from on the device media.
- @param NumberOfBlocks The number of transfer data blocks.
-
- @return status is fully dependent on the return status of AtaPioDataIn() function.
-
-**/
-EFI_STATUS
-AtaReadSectors (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN VOID *DataBuffer,
- IN EFI_LBA Lba,
- IN UINTN NumberOfBlocks
- )
-{
- EFI_STATUS Status;
- UINTN BlocksRemaining;
- UINT32 Lba32;
- UINT8 Lba0;
- UINT8 Lba1;
- UINT8 Lba2;
- UINT8 Lba3;
- UINT8 AtaCommand;
- UINT8 SectorCount8;
- UINT16 SectorCount;
- UINTN ByteCount;
- VOID *Buffer;
-
- Buffer = DataBuffer;
-
- //
- // Using ATA Read Sector(s) command (opcode=0x20) with PIO DATA IN protocol
- //
- AtaCommand = ATA_CMD_READ_SECTORS;
-
-
- BlocksRemaining = NumberOfBlocks;
-
- Lba32 = (UINT32) Lba;
-
- Status = EFI_SUCCESS;
-
- while (BlocksRemaining > 0) {
-
- //
- // in ATA-3 spec, LBA is in 28 bit width
- //
- Lba0 = (UINT8) Lba32;
- Lba1 = (UINT8) (Lba32 >> 8);
- Lba2 = (UINT8) (Lba32 >> 16);
- //
- // low 4 bit of Lba3 stands for LBA bit24~bit27.
- //
- Lba3 = (UINT8) ((Lba32 >> 24) & 0x0f);
-
- if (BlocksRemaining >= 0x100) {
-
- //
- // SectorCount8 is sent to Sector Count register, 0x00 means 256
- // sectors to be read
- //
- SectorCount8 = 0x00;
- //
- // SectorCount is used to record the number of sectors to be read
- //
- SectorCount = 256;
- } else {
-
- SectorCount8 = (UINT8) BlocksRemaining;
- SectorCount = (UINT16) BlocksRemaining;
- }
-
- //
- // ByteCount is the number of bytes that will be read
- //
- ByteCount = SectorCount * (IdeDev->BlkIo.Media->BlockSize);
-
- //
- // call AtaPioDataIn() to send Read Sector Command and receive data read
- //
- Status = AtaPioDataIn (
- IdeDev,
- Buffer,
- (UINT32) ByteCount,
- AtaCommand,
- Lba3,
- SectorCount8,
- Lba0,
- Lba1,
- Lba2
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Lba32 += SectorCount;
- Buffer = ((UINT8 *) Buffer + ByteCount);
- BlocksRemaining -= SectorCount;
- }
-
- return Status;
-}
-
-/**
- This function is called by the AtaBlkIoWriteBlocks() to perform writing onto
- media in block unit.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure,used to record
- all the information of the IDE device.
- @param BufferData A pointer to the source buffer for the data.
- @param Lba The starting logical block address to write onto the device media.
- @param NumberOfBlocks The number of transfer data blocks.
-
- @return status is fully dependent on the return status of AtaPioDataIn() function.
-
-**/
-EFI_STATUS
-AtaWriteSectors (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN VOID *BufferData,
- IN EFI_LBA Lba,
- IN UINTN NumberOfBlocks
- )
-{
- EFI_STATUS Status;
- UINTN BlocksRemaining;
- UINT32 Lba32;
- UINT8 Lba0;
- UINT8 Lba1;
- UINT8 Lba2;
- UINT8 Lba3;
- UINT8 AtaCommand;
- UINT8 SectorCount8;
- UINT16 SectorCount;
- UINTN ByteCount;
- VOID *Buffer;
-
- Buffer = BufferData;
-
- //
- // Using Write Sector(s) command (opcode=0x30) with PIO DATA OUT protocol
- //
- AtaCommand = ATA_CMD_WRITE_SECTORS;
-
- BlocksRemaining = NumberOfBlocks;
-
- Lba32 = (UINT32) Lba;
-
- Status = EFI_SUCCESS;
-
- while (BlocksRemaining > 0) {
-
- Lba0 = (UINT8) Lba32;
- Lba1 = (UINT8) (Lba32 >> 8);
- Lba2 = (UINT8) (Lba32 >> 16);
- Lba3 = (UINT8) ((Lba32 >> 24) & 0x0f);
-
- if (BlocksRemaining >= 0x100) {
-
- //
- // SectorCount8 is sent to Sector Count register, 0x00 means 256 sectors
- // to be written
- //
- SectorCount8 = 0x00;
- //
- // SectorCount is used to record the number of sectors to be written
- //
- SectorCount = 256;
- } else {
-
- SectorCount8 = (UINT8) BlocksRemaining;
- SectorCount = (UINT16) BlocksRemaining;
- }
-
- ByteCount = SectorCount * (IdeDev->BlkIo.Media->BlockSize);
-
- Status = AtaPioDataOut (
- IdeDev,
- Buffer,
- (UINT32) ByteCount,
- AtaCommand,
- Lba3,
- SectorCount8,
- Lba0,
- Lba1,
- Lba2
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Lba32 += SectorCount;
- Buffer = ((UINT8 *) Buffer + ByteCount);
- BlocksRemaining -= SectorCount;
- }
-
- return Status;
-}
-/**
- This function is used to implement the Soft Reset on the specified device. But,
- the ATA Soft Reset mechanism is so strong a reset method that it will force
- resetting on both devices connected to the same cable.
-
- It is called by IdeBlkIoReset(), a interface function of Block
- I/O protocol.
-
- This function can also be used by the ATAPI device to perform reset when
- ATAPI Reset command is failed.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record
- all the information of the IDE device.
- @retval EFI_SUCCESS Soft reset completes successfully.
- @retval EFI_DEVICE_ERROR Any step during the reset process is failed.
-
- @note The registers initial values after ATA soft reset are different
- to the ATA device and ATAPI device.
-**/
-EFI_STATUS
-AtaSoftReset (
- IN IDE_BLK_IO_DEV *IdeDev
- )
-{
-
- UINT8 DeviceControl;
-
- DeviceControl = 0;
- //
- // set SRST bit to initiate soft reset
- //
- DeviceControl |= ATA_CTLREG_SRST;
-
- //
- // disable Interrupt
- //
- DeviceControl |= BIT1;
-
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Alt.DeviceControl, DeviceControl);
-
- //
- // SRST should assert for at least 5 us, we use 10 us for
- // better compatibility
- //
- gBS->Stall (10);
-
- //
- // Enable interrupt to support UDMA, and clear SRST bit
- //
- DeviceControl = 0;
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Alt.DeviceControl, DeviceControl);
-
- //
- // Wait for at least 2 ms to check BSY status, we use 10 ms
- // for better compatibility
- //
- gBS->Stall(10000);
- //
- // slave device needs at most 31s to clear BSY
- //
- if (WaitForBSYClear (IdeDev, 31000) == EFI_TIMEOUT) {
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-/**
- This function is used to send out ATA commands conforms to the PIO Data In
- Protocol, supporting ATA/ATAPI-6 standard
-
- Comparing with ATA-3 data in protocol, we have two differents here:
- 1. Do NOT wait for DRQ clear before sending command into IDE device.(the
- wait will frequently fail... cause writing function return error)
-
- 2. Do NOT wait for DRQ clear after all data readed.(the wait greatly
- slow down writing performance by 100 times!)
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
- @param Buffer buffer contained data transferred from device to host.
- @param ByteCount data size in byte unit of the buffer.
- @param AtaCommand value of the Command Register
- @param StartLba the start LBA of this transaction
- @param SectorCount the count of sectors to be transfered
-
- @retval EFI_SUCCESS send out the ATA command and device send required data successfully.
- @retval EFI_DEVICE_ERROR command sent failed.
-
-**/
-EFI_STATUS
-AtaPioDataInExt (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN OUT VOID *Buffer,
- IN UINT32 ByteCount,
- IN UINT8 AtaCommand,
- IN EFI_LBA StartLba,
- IN UINT16 SectorCount
- )
-{
- UINT8 DevSel;
- UINT8 SectorCount8;
- UINT8 LbaLow;
- UINT8 LbaMid;
- UINT8 LbaHigh;
- UINTN WordCount;
- UINTN Increment;
- UINT16 *Buffer16;
- EFI_STATUS Status;
-
- Status = WaitForBSYClear (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // Select device, set bit6 as 1 to indicate LBA mode is used
- //
- DevSel = (UINT8) (IdeDev->Device << 4);
- DevSel |= 0x40;
- IDEWritePortB (
- IdeDev->PciIo,
- IdeDev->IoPort->Head,
- DevSel
- );
-
- //
- // Wait for DRDY singnal asserting. ATAPI device needn't wait
- //
- if ( (IdeDev->Type == IdeHardDisk) ||
- (IdeDev->Type == Ide48bitAddressingHardDisk)) {
-
- Status = DRDYReady (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
- }
-
- //
- // Fill feature register if needed
- //
- if (AtaCommand == ATA_CMD_SET_FEATURES) {
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Feature, 0x03);
- }
-
- //
- // Fill the sector count register, which is a two-byte FIFO. Need write twice.
- //
- SectorCount8 = (UINT8) (SectorCount >> 8);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorCount, SectorCount8);
-
- SectorCount8 = (UINT8) SectorCount;
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorCount, SectorCount8);
-
- //
- // Fill the start LBA registers, which are also two-byte FIFO
- //
- LbaLow = (UINT8) RShiftU64 (StartLba, 24);
- LbaMid = (UINT8) RShiftU64 (StartLba, 32);
- LbaHigh = (UINT8) RShiftU64 (StartLba, 40);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorNumber, LbaLow);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb, LbaMid);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb, LbaHigh);
-
- LbaLow = (UINT8) StartLba;
- LbaMid = (UINT8) RShiftU64 (StartLba, 8);
- LbaHigh = (UINT8) RShiftU64 (StartLba, 16);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorNumber, LbaLow);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb, LbaMid);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb, LbaHigh);
-
- //
- // Send command via Command Register, invoking the processing of this command
- //
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, AtaCommand);
-
- Buffer16 = (UINT16 *) Buffer;
-
- //
- // According to PIO data in protocol, host can perform a series of reads to
- // the data register after each time device set DRQ ready;
- //
-
- //
- // 256 words
- //
- Increment = 256;
-
- //
- // used to record bytes of currently transfered data
- //
- WordCount = 0;
-
- while (WordCount < ByteCount / 2) {
- //
- // Poll DRQ bit set, data transfer can be performed only when DRQ is ready.
- //
- Status = DRQReady2 (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- Status = CheckErrorStatus (IdeDev);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // Get the byte count for one series of read
- //
- if ((WordCount + Increment) > ByteCount / 2) {
- Increment = ByteCount / 2 - WordCount;
- }
-
- IDEReadPortWMultiple (
- IdeDev->PciIo,
- IdeDev->IoPort->Data,
- Increment,
- Buffer16
- );
-
- WordCount += Increment;
- Buffer16 += Increment;
-
- }
-
- return CheckErrorStatus (IdeDev);
-}
-/**
- Send ATA Ext command into device with NON_DATA protocol.
-
- @param IdeDev Standard IDE device private data structure
- @param AtaCommand The ATA command to be sent
- @param Device The value in Device register
- @param Feature The value in Feature register
- @param SectorCount The value in SectorCount register
- @param LbaAddress The LBA address in 48-bit mode
-
- @retval EFI_SUCCESS Reading succeed
- @retval EFI_DEVICE_ERROR Error executing commands on this device.
-
-**/
-EFI_STATUS
-AtaCommandIssueExt (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN UINT8 AtaCommand,
- IN UINT8 Device,
- IN UINT16 Feature,
- IN UINT16 SectorCount,
- IN EFI_LBA LbaAddress
- )
-{
- EFI_STATUS Status;
- UINT8 SectorCount8;
- UINT8 Feature8;
- UINT8 LbaLow;
- UINT8 LbaMid;
- UINT8 LbaHigh;
-
- Status = WaitForBSYClear (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // Select device (bit4), set LBA mode(bit6) (use 0xe0 for compatibility)
- //
- IDEWritePortB (
- IdeDev->PciIo,
- IdeDev->IoPort->Head,
- (UINT8) ((IdeDev->Device << 4) | 0xe0)
- );
-
- //
- // ATA commands for ATA device must be issued when DRDY is set
- //
- Status = DRDYReady (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // Pass parameter into device register block
- //
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Head, Device);
-
- //
- // Fill the feature register, which is a two-byte FIFO. Need write twice.
- //
- Feature8 = (UINT8) (Feature >> 8);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Feature, Feature8);
-
- Feature8 = (UINT8) Feature;
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Feature, Feature8);
-
- //
- // Fill the sector count register, which is a two-byte FIFO. Need write twice.
- //
- SectorCount8 = (UINT8) (SectorCount >> 8);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorCount, SectorCount8);
-
- SectorCount8 = (UINT8) SectorCount;
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorCount, SectorCount8);
-
- //
- // Fill the start LBA registers, which are also two-byte FIFO
- //
- LbaLow = (UINT8) RShiftU64 (LbaAddress, 24);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorNumber, LbaLow);
- LbaLow = (UINT8) LbaAddress;
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorNumber, LbaLow);
-
- LbaMid = (UINT8) RShiftU64 (LbaAddress, 32);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb, LbaMid);
- LbaMid = (UINT8) RShiftU64 (LbaAddress, 8);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb, LbaMid);
-
- LbaHigh = (UINT8) RShiftU64 (LbaAddress, 40);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb, LbaHigh);
- LbaHigh = (UINT8) RShiftU64 (LbaAddress, 16);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb, LbaHigh);
-
- //
- // Work around for Segate 160G disk writing
- //
- gBS->Stall (1800);
-
- //
- // Send command via Command Register
- //
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, AtaCommand);
-
- //
- // Stall at least 400ns
- //
- gBS->Stall (100);
-
- return EFI_SUCCESS;
-}
-/**
- Send ATA Ext command into device with NON_DATA protocol
-
- @param IdeDev Standard IDE device private data structure
- @param AtaCommand The ATA command to be sent
- @param Device The value in Device register
- @param Feature The value in Feature register
- @param SectorCount The value in SectorCount register
- @param LbaAddress The LBA address in 48-bit mode
-
- @retval EFI_SUCCESS Reading succeed
- @retval EFI_DEVICE_ERROR Error executing commands on this device.
-
-**/
-EFI_STATUS
-AtaCommandIssue (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN UINT8 AtaCommand,
- IN UINT8 Device,
- IN UINT16 Feature,
- IN UINT16 SectorCount,
- IN EFI_LBA LbaAddress
- )
-{
- EFI_STATUS Status;
- UINT8 SectorCount8;
- UINT8 Feature8;
- UINT8 Lba0;
- UINT8 Lba1;
- UINT8 Lba2;
- UINT8 Lba3;
-
- Status = WaitForBSYClear (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // Select device (bit4), set LBA mode(bit6) (use 0xe0 for compatibility)
- //
- IDEWritePortB (
- IdeDev->PciIo,
- IdeDev->IoPort->Head,
- (UINT8) ((IdeDev->Device << 4) | 0xe0)
- );
-
- //
- // ATA commands for ATA device must be issued when DRDY is set
- //
- Status = DRDYReady (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- Lba0 = (UINT8) LbaAddress;
- Lba1 = (UINT8) RShiftU64 (LbaAddress, 8);
- Lba2 = (UINT8) RShiftU64 (LbaAddress, 16);
- Lba3 = (UINT8) RShiftU64 (LbaAddress, 24);
- Device = (UINT8) (Device | Lba3);
-
- //
- // Pass parameter into device register block
- //
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Head, Device);
-
- //
- // Fill the feature register, which is a two-byte FIFO. Need write twice.
- //
- Feature8 = (UINT8) Feature;
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Feature, Feature8);
-
- //
- // Fill the sector count register, which is a two-byte FIFO. Need write twice.
- //
- SectorCount8 = (UINT8) SectorCount;
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorCount, SectorCount8);
-
- //
- // Fill the start LBA registers, which are also two-byte FIFO
- //
-
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorNumber, Lba0);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb, Lba1);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb, Lba2);
-
- //
- // Send command via Command Register
- //
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, AtaCommand);
-
- //
- // Stall at least 400ns
- //
- gBS->Stall (100);
-
- return EFI_SUCCESS;
-}
-/**
- Perform an ATA Udma operation (Read, ReadExt, Write, WriteExt).
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
- @param DataBuffer A pointer to the source buffer for the data.
- @param StartLba The starting logical block address to write to
- on the device media.
- @param NumberOfBlocks The number of transfer data blocks.
- @param UdmaOp The perform operations could be AtaUdmaReadOp, AtaUdmaReadExOp,
- AtaUdmaWriteOp, AtaUdmaWriteExOp
-
- @retval EFI_SUCCESS the operation is successful.
- @retval EFI_OUT_OF_RESOURCES Build PRD table failed
- @retval EFI_UNSUPPORTED Unknown channel or operations command
- @retval EFI_DEVICE_ERROR Ata command execute failed
-
-**/
-EFI_STATUS
-DoAtaUdma (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN VOID *DataBuffer,
- IN EFI_LBA StartLba,
- IN UINTN NumberOfBlocks,
- IN ATA_UDMA_OPERATION UdmaOp
- )
-{
- IDE_DMA_PRD *PrdAddr;
- IDE_DMA_PRD *UsedPrdAddr;
- IDE_DMA_PRD *TempPrdAddr;
- UINT8 RegisterValue;
- UINT8 Device;
- UINT64 IoPortForBmic;
- UINT64 IoPortForBmis;
- UINT64 IoPortForBmid;
- EFI_STATUS Status;
- UINTN PrdTableNum;
- UINTN ByteCount;
- UINTN ByteAvailable;
- UINT8 *PrdBuffer;
- UINTN RemainBlockNum;
- UINT8 DeviceControl;
- UINT32 Count;
- UINTN PageCount;
- VOID *Map;
- VOID *MemPage;
- EFI_PHYSICAL_ADDRESS DeviceAddress;
- UINTN MaxDmaCommandSectors;
- EFI_PCI_IO_PROTOCOL_OPERATION PciIoProtocolOp;
- UINT8 AtaCommand;
-
- switch (UdmaOp) {
- case AtaUdmaReadOp:
- MaxDmaCommandSectors = ATAPI_MAX_DMA_CMD_SECTORS;
- PciIoProtocolOp = EfiPciIoOperationBusMasterWrite;
- AtaCommand = ATA_CMD_READ_DMA;
- break;
- case AtaUdmaReadExtOp:
- MaxDmaCommandSectors = ATAPI_MAX_DMA_EXT_CMD_SECTORS;
- PciIoProtocolOp = EfiPciIoOperationBusMasterWrite;
- AtaCommand = ATA_CMD_READ_DMA_EXT;
- break;
- case AtaUdmaWriteOp:
- MaxDmaCommandSectors = ATAPI_MAX_DMA_CMD_SECTORS;
- PciIoProtocolOp = EfiPciIoOperationBusMasterRead;
- AtaCommand = ATA_CMD_WRITE_DMA;
- break;
- case AtaUdmaWriteExtOp:
- MaxDmaCommandSectors = ATAPI_MAX_DMA_EXT_CMD_SECTORS;
- PciIoProtocolOp = EfiPciIoOperationBusMasterRead;
- AtaCommand = ATA_CMD_WRITE_DMA_EXT;
- break;
- default:
- return EFI_UNSUPPORTED;
- break;
- }
-
- //
- // Select device
- //
- Device = (UINT8) ((IdeDev->Device << 4) | 0xe0);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Head, Device);
-
- //
- // Enable interrupt to support UDMA
- //
- DeviceControl = 0;
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Alt.DeviceControl, DeviceControl);
-
- if (IdePrimary == IdeDev->Channel) {
- IoPortForBmic = IdeDev->IoPort->BusMasterBaseAddr + BMICP_OFFSET;
- IoPortForBmis = IdeDev->IoPort->BusMasterBaseAddr + BMISP_OFFSET;
- IoPortForBmid = IdeDev->IoPort->BusMasterBaseAddr + BMIDP_OFFSET;
- } else {
- if (IdeSecondary == IdeDev->Channel) {
- IoPortForBmic = IdeDev->IoPort->BusMasterBaseAddr + BMICS_OFFSET;
- IoPortForBmis = IdeDev->IoPort->BusMasterBaseAddr + BMISS_OFFSET;
- IoPortForBmid = IdeDev->IoPort->BusMasterBaseAddr + BMIDS_OFFSET;
- } else {
- return EFI_UNSUPPORTED;
- }
- }
-
- //
- // Read BMIS register and clear ERROR and INTR bit
- //
- IdeDev->PciIo->Io.Read (
- IdeDev->PciIo,
- EfiPciIoWidthUint8,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- IoPortForBmis,
- 1,
- &RegisterValue
- );
-
- RegisterValue |= (BMIS_INTERRUPT | BMIS_ERROR);
-
- IdeDev->PciIo->Io.Write (
- IdeDev->PciIo,
- EfiPciIoWidthUint8,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- IoPortForBmis,
- 1,
- &RegisterValue
- );
-
- Status = EFI_SUCCESS;
-
- RemainBlockNum = NumberOfBlocks;
- while (RemainBlockNum > 0) {
-
- if (RemainBlockNum >= MaxDmaCommandSectors) {
- //
- // SectorCount is used to record the number of sectors to be read
- // Max 65536 sectors can be transfered at a time.
- //
- NumberOfBlocks = MaxDmaCommandSectors;
- RemainBlockNum -= MaxDmaCommandSectors;
- } else {
- NumberOfBlocks = (UINT16) RemainBlockNum;
- RemainBlockNum = 0;
- }
-
- //
- // Calculate the number of PRD table to make sure the memory region
- // not cross 64K boundary
- //
- ByteCount = NumberOfBlocks * IdeDev->BlkIo.Media->BlockSize;
- PrdTableNum = ((ByteCount >> 16) + 1) + 1;
-
- //
- // Build PRD table
- //
- PageCount = EFI_SIZE_TO_PAGES (2 * PrdTableNum * sizeof (IDE_DMA_PRD));
- Status = IdeDev->PciIo->AllocateBuffer (
- IdeDev->PciIo,
- AllocateAnyPages,
- EfiBootServicesData,
- PageCount,
- &MemPage,
- 0
- );
- if (EFI_ERROR (Status)) {
- return EFI_OUT_OF_RESOURCES;
- }
- ZeroMem ((VOID *) ((UINTN) MemPage), EFI_PAGES_TO_SIZE (PageCount));
-
- PrdAddr = (IDE_DMA_PRD *) ((UINTN) MemPage);
- //
- // To make sure PRD is allocated in one 64K page
- //
- if (((UINTN) PrdAddr & 0x0FFFF) > (((UINTN) PrdAddr + PrdTableNum * sizeof (IDE_DMA_PRD) - 1) & 0x0FFFF)) {
- UsedPrdAddr = (IDE_DMA_PRD *) ((UINTN) ((UINT8 *) PrdAddr + 0x10000) & 0xFFFF0000);
- } else {
- if ((UINTN) PrdAddr & 0x03) {
- UsedPrdAddr = (IDE_DMA_PRD *) ((UINTN) ((UINT8 *) PrdAddr + 0x04) & 0xFFFFFFFC);
- } else {
- UsedPrdAddr = PrdAddr;
- }
- }
-
- //
- // Build the PRD table
- //
- Status = IdeDev->PciIo->Map (
- IdeDev->PciIo,
- PciIoProtocolOp,
- DataBuffer,
- &ByteCount,
- &DeviceAddress,
- &Map
- );
- if (EFI_ERROR (Status)) {
- IdeDev->PciIo->FreeBuffer (IdeDev->PciIo, PageCount, MemPage);
- return EFI_OUT_OF_RESOURCES;
- }
- PrdBuffer = (VOID *) ((UINTN) DeviceAddress);
- TempPrdAddr = UsedPrdAddr;
- while (TRUE) {
-
- ByteAvailable = 0x10000 - ((UINTN) PrdBuffer & 0xFFFF);
-
- if (ByteCount <= ByteAvailable) {
- TempPrdAddr->RegionBaseAddr = (UINT32) ((UINTN) PrdBuffer);
- TempPrdAddr->ByteCount = (UINT16) ByteCount;
- TempPrdAddr->EndOfTable = 0x8000;
- break;
- }
-
- TempPrdAddr->RegionBaseAddr = (UINT32) ((UINTN) PrdBuffer);
- TempPrdAddr->ByteCount = (UINT16) ByteAvailable;
-
- ByteCount -= ByteAvailable;
- PrdBuffer += ByteAvailable;
- TempPrdAddr++;
- }
-
- //
- // Set the base address to BMID register
- //
- IdeDev->PciIo->Io.Write (
- IdeDev->PciIo,
- EfiPciIoWidthUint32,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- IoPortForBmid,
- 1,
- &UsedPrdAddr
- );
-
- //
- // Set BMIC register to identify the operation direction
- //
- IdeDev->PciIo->Io.Read (
- IdeDev->PciIo,
- EfiPciIoWidthUint8,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- IoPortForBmic,
- 1,
- &RegisterValue
- );
-
- if (UdmaOp == AtaUdmaReadExtOp || UdmaOp == AtaUdmaReadOp) {
- RegisterValue |= BMIC_NREAD;
- } else {
- RegisterValue &= ~((UINT8) BMIC_NREAD);
- }
-
- IdeDev->PciIo->Io.Write (
- IdeDev->PciIo,
- EfiPciIoWidthUint8,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- IoPortForBmic,
- 1,
- &RegisterValue
- );
-
- if (UdmaOp == AtaUdmaWriteExtOp || UdmaOp == AtaUdmaReadExtOp) {
- Status = AtaCommandIssueExt (
- IdeDev,
- AtaCommand,
- Device,
- 0,
- (UINT16) NumberOfBlocks,
- StartLba
- );
- } else {
- Status = AtaCommandIssue (
- IdeDev,
- AtaCommand,
- Device,
- 0,
- (UINT16) NumberOfBlocks,
- StartLba
- );
- }
-
- if (EFI_ERROR (Status)) {
- IdeDev->PciIo->FreeBuffer (IdeDev->PciIo, PageCount, MemPage);
- IdeDev->PciIo->Unmap (IdeDev->PciIo, Map);
- return EFI_DEVICE_ERROR;
- }
-
- //
- // Set START bit of BMIC register
- //
- IdeDev->PciIo->Io.Read (
- IdeDev->PciIo,
- EfiPciIoWidthUint8,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- IoPortForBmic,
- 1,
- &RegisterValue
- );
-
- RegisterValue |= BMIC_START;
-
- IdeDev->PciIo->Io.Write (
- IdeDev->PciIo,
- EfiPciIoWidthUint8,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- IoPortForBmic,
- 1,
- &RegisterValue
- );
-
- //
- // Check the INTERRUPT and ERROR bit of BMIS
- // Max transfer number of sectors for one command is 65536(32Mbyte),
- // it will cost 1 second to transfer these data in UDMA mode 2(33.3MBps).
- // So set the variable Count to 2000, for about 2 second timeout time.
- //
- Status = EFI_SUCCESS;
- Count = 2000;
- while (TRUE) {
-
- IdeDev->PciIo->Io.Read (
- IdeDev->PciIo,
- EfiPciIoWidthUint8,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- IoPortForBmis,
- 1,
- &RegisterValue
- );
- if (((RegisterValue & (BMIS_INTERRUPT | BMIS_ERROR)) != 0) || (Count == 0)) {
- if (((RegisterValue & BMIS_ERROR) != 0) || (Count == 0)) {
- Status = EFI_DEVICE_ERROR;
- break;
- }
- break;
- }
-
- gBS->Stall (1000);
- Count --;
- }
-
- IdeDev->PciIo->FreeBuffer (IdeDev->PciIo, PageCount, MemPage);
- IdeDev->PciIo->Unmap (IdeDev->PciIo, Map);
- //
- // Read BMIS register and clear ERROR and INTR bit
- //
- IdeDev->PciIo->Io.Read (
- IdeDev->PciIo,
- EfiPciIoWidthUint8,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- IoPortForBmis,
- 1,
- &RegisterValue
- );
-
- RegisterValue |= (BMIS_INTERRUPT | BMIS_ERROR);
-
- IdeDev->PciIo->Io.Write (
- IdeDev->PciIo,
- EfiPciIoWidthUint8,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- IoPortForBmis,
- 1,
- &RegisterValue
- );
- //
- // Read Status Register of IDE device to clear interrupt
- //
- RegisterValue = IDEReadPortB(IdeDev->PciIo,IdeDev->IoPort->Reg.Status);
- //
- // Clear START bit of BMIC register
- //
- IdeDev->PciIo->Io.Read (
- IdeDev->PciIo,
- EfiPciIoWidthUint8,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- IoPortForBmic,
- 1,
- &RegisterValue
- );
-
- RegisterValue &= ~((UINT8) BMIC_START);
-
- IdeDev->PciIo->Io.Write (
- IdeDev->PciIo,
- EfiPciIoWidthUint8,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- IoPortForBmic,
- 1,
- &RegisterValue
- );
-
- if ((RegisterValue & BMIS_ERROR) != 0) {
- return EFI_DEVICE_ERROR;
- }
-
- if (EFI_ERROR (Status)) {
- break;
- }
- DataBuffer = (UINT8 *) DataBuffer + NumberOfBlocks * IdeDev->BlkIo.Media->BlockSize;
- StartLba += NumberOfBlocks;
- }
-
- //
- // Disable interrupt of Select device
- //
- IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Alt.DeviceControl);
- DeviceControl |= ATA_CTLREG_IEN_L;
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Alt.DeviceControl, DeviceControl);
-
- return Status;
-}
-
-
-/**
- This function is called by the AtaBlkIoReadBlocks() to perform reading from
- media in block unit. The function has been enhanced to support >120GB access
- and transfer at most 65536 blocks per command
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record
- all the information of the IDE device.
- @param DataBuffer A pointer to the destination buffer for the data.
- @param StartLba The starting logical block address to read from on the device media.
- @param NumberOfBlocks The number of transfer data blocks.
-
- @return status depends on the function DoAtaUdma() returns.
-**/
-EFI_STATUS
-AtaUdmaReadExt (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN VOID *DataBuffer,
- IN EFI_LBA StartLba,
- IN UINTN NumberOfBlocks
- )
-{
- return DoAtaUdma (IdeDev, DataBuffer, StartLba, NumberOfBlocks, AtaUdmaReadExtOp);
-}
-/**
- This function is called by the AtaBlkIoReadBlocks() to perform
- reading from media in block unit. The function has been enhanced to
- support >120GB access and transfer at most 65536 blocks per command
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record
- all the information of the IDE device.
- @param DataBuffer A pointer to the destination buffer for the data.
- @param StartLba The starting logical block address to read from
- on the device media.
- @param NumberOfBlocks The number of transfer data blocks.
-
- @return status depends on the function DoAtaUdma() returns.
-**/
-EFI_STATUS
-AtaUdmaRead (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN VOID *DataBuffer,
- IN EFI_LBA StartLba,
- IN UINTN NumberOfBlocks
- )
-{
- return DoAtaUdma (IdeDev, DataBuffer, StartLba, NumberOfBlocks, AtaUdmaReadOp);
-}
-
-/**
- This function is called by the AtaBlkIoReadBlocks() to perform
- reading from media in block unit. The function has been enhanced to
- support >120GB access and transfer at most 65536 blocks per command
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record
- all the information of the IDE device.
- @param DataBuffer A pointer to the destination buffer for the data.
- @param StartLba The starting logical block address to read from on the device media.
- @param NumberOfBlocks The number of transfer data blocks.
-
- @return status is fully dependent on the return status of AtaPioDataInExt() function.
-**/
-EFI_STATUS
-AtaReadSectorsExt (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN VOID *DataBuffer,
- IN EFI_LBA StartLba,
- IN UINTN NumberOfBlocks
- )
-{
- EFI_STATUS Status;
- UINTN BlocksRemaining;
- EFI_LBA Lba64;
- UINT8 AtaCommand;
- UINT16 SectorCount;
- UINT32 ByteCount;
- VOID *Buffer;
-
- //
- // Using ATA "Read Sectors Ext" command(opcode=0x24) with PIO DATA IN protocol
- //
- AtaCommand = ATA_CMD_READ_SECTORS_EXT;
- Buffer = DataBuffer;
- BlocksRemaining = NumberOfBlocks;
- Lba64 = StartLba;
- Status = EFI_SUCCESS;
-
- while (BlocksRemaining > 0) {
-
- if (BlocksRemaining >= 0x10000) {
- //
- // SectorCount is used to record the number of sectors to be read
- // Max 65536 sectors can be transfered at a time.
- //
- SectorCount = 0xffff;
- } else {
- SectorCount = (UINT16) BlocksRemaining;
- }
-
- //
- // ByteCount is the number of bytes that will be read
- //
- ByteCount = SectorCount * (IdeDev->BlkIo.Media->BlockSize);
-
- //
- // call AtaPioDataInExt() to send Read Sector Command and receive data read
- //
- Status = AtaPioDataInExt (
- IdeDev,
- Buffer,
- ByteCount,
- AtaCommand,
- Lba64,
- SectorCount
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Lba64 += SectorCount;
- Buffer = ((UINT8 *) Buffer + ByteCount);
- BlocksRemaining -= SectorCount;
- }
-
- return Status;
-}
-/**
- This function is the ATA implementation for ReadBlocks in the
- Block I/O Protocol interface.
-
- @param IdeBlkIoDevice Indicates the calling context.
- @param MediaId The media id that the read request is for.
- @param Lba The starting logical block address to read from on the device.
- @param BufferSize The size of the Buffer in bytes. This must be a multiple
- of the intrinsic block size of the device.
-
- @param Buffer A pointer to the destination buffer for the data. The caller
- is responsible for either having implicit or explicit ownership
- of the memory that data is read into.
-
- @retval EFI_SUCCESS Read Blocks successfully.
- @retval EFI_DEVICE_ERROR Read Blocks failed.
- @retval EFI_NO_MEDIA There is no media in the device.
- @retval EFI_MEDIA_CHANGE The MediaId is not for the current media.
- @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
- intrinsic block size of the device.
- @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
- or the data buffer is not valid.
-
- @note If Read Block error because of device error, this function will call
- AtaSoftReset() function to reset device.
-
-**/
-EFI_STATUS
-AtaBlkIoReadBlocks (
- IN IDE_BLK_IO_DEV *IdeBlkIoDevice,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- )
-{
- EFI_BLOCK_IO_MEDIA *Media;
- UINTN BlockSize;
- UINTN NumberOfBlocks;
- EFI_STATUS Status;
-
- if (Buffer == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (BufferSize == 0) {
- return EFI_SUCCESS;
- }
-
- Status = EFI_SUCCESS;
-
- //
- // Get the intrinsic block size
- //
- Media = IdeBlkIoDevice->BlkIo.Media;
- BlockSize = Media->BlockSize;
-
- NumberOfBlocks = BufferSize / BlockSize;
-
- if (MediaId != Media->MediaId) {
- return EFI_MEDIA_CHANGED;
- }
-
- if (BufferSize % BlockSize != 0) {
- return EFI_BAD_BUFFER_SIZE;
- }
-
- if (!(Media->MediaPresent)) {
- return EFI_NO_MEDIA;
- }
-
- if (Lba > Media->LastBlock) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((Lba + NumberOfBlocks - 1) > Media->LastBlock) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((Media->IoAlign > 1) && (((UINTN) Buffer & (Media->IoAlign - 1)) != 0)) {
- return EFI_INVALID_PARAMETER;
- }
-
- Status = EFI_SUCCESS;
- if (IdeBlkIoDevice->Type == Ide48bitAddressingHardDisk) {
- //
- // For ATA/ATAPI-6 device(capcity > 120GB), use ATA-6 read block mechanism
- //
- if (IdeBlkIoDevice->UdmaMode.Valid) {
- Status = AtaUdmaReadExt (IdeBlkIoDevice, Buffer, Lba, NumberOfBlocks);
- } else {
- Status = AtaReadSectorsExt (IdeBlkIoDevice, Buffer, Lba, NumberOfBlocks);
- }
- } else {
- //
- // For ATA-3 compatible device, use ATA-3 read block mechanism
- //
- if (IdeBlkIoDevice->UdmaMode.Valid) {
- Status = AtaUdmaRead (IdeBlkIoDevice, Buffer, Lba, NumberOfBlocks);
- } else {
- Status = AtaReadSectors (IdeBlkIoDevice, Buffer, Lba, NumberOfBlocks);
- }
- }
-
- if (EFI_ERROR (Status)) {
- AtaSoftReset (IdeBlkIoDevice);
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-
-}
-/**
- This function is used to send out ATA commands conforms to the
- PIO Data Out Protocol, supporting ATA/ATAPI-6 standard
-
- Comparing with ATA-3 data out protocol, we have two differents here:<BR>
- 1. Do NOT wait for DRQ clear before sending command into IDE device.(the
- wait will frequently fail... cause writing function return error)
-
- 2. Do NOT wait for DRQ clear after all data readed.(the wait greatly
- slow down writing performance by 100 times!)
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
- @param Buffer buffer contained data transferred from host to device.
- @param ByteCount data size in byte unit of the buffer.
- @param AtaCommand value of the Command Register
- @param StartLba the start LBA of this transaction
- @param SectorCount the count of sectors to be transfered
-
- @retval EFI_SUCCESS send out the ATA command and device receive required
- data successfully.
- @retval EFI_DEVICE_ERROR command sent failed.
-
-**/
-EFI_STATUS
-AtaPioDataOutExt (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN VOID *Buffer,
- IN UINT32 ByteCount,
- IN UINT8 AtaCommand,
- IN EFI_LBA StartLba,
- IN UINT16 SectorCount
- )
-{
- UINT8 DevSel;
- UINT8 SectorCount8;
- UINT8 LbaLow;
- UINT8 LbaMid;
- UINT8 LbaHigh;
- UINTN WordCount;
- UINTN Increment;
- UINT16 *Buffer16;
- EFI_STATUS Status;
-
- Status = WaitForBSYClear (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // Select device. Set bit6 as 1 to indicate LBA mode is used
- //
- DevSel = (UINT8) (IdeDev->Device << 4);
- DevSel |= 0x40;
- IDEWritePortB (
- IdeDev->PciIo,
- IdeDev->IoPort->Head,
- DevSel
- );
-
- //
- // Wait for DRDY singnal asserting.
- //
- Status = DRDYReady (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // Fill feature register if needed
- //
- if (AtaCommand == ATA_CMD_SET_FEATURES) {
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Feature, 0x03);
- }
-
- //
- // Fill the sector count register, which is a two-byte FIFO. Need write twice.
- //
- SectorCount8 = (UINT8) (SectorCount >> 8);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorCount, SectorCount8);
-
- SectorCount8 = (UINT8) SectorCount;
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorCount, SectorCount8);
-
- //
- // Fill the start LBA registers, which are also two-byte FIFO
- //
- LbaLow = (UINT8) RShiftU64 (StartLba, 24);
- LbaMid = (UINT8) RShiftU64 (StartLba, 32);
- LbaHigh = (UINT8) RShiftU64 (StartLba, 40);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorNumber, LbaLow);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb, LbaMid);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb, LbaHigh);
-
- LbaLow = (UINT8) StartLba;
- LbaMid = (UINT8) RShiftU64 (StartLba, 8);
- LbaHigh = (UINT8) RShiftU64 (StartLba, 16);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorNumber, LbaLow);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb, LbaMid);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb, LbaHigh);
-
- //
- // Send command via Command Register, invoking the processing of this command
- //
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, AtaCommand);
-
- Buffer16 = (UINT16 *) Buffer;
-
- //
- // According to PIO Data Out protocol, host can perform a series of writes to
- // the data register after each time device set DRQ ready;
- //
- Increment = 256;
-
- //
- // used to record bytes of currently transfered data
- //
- WordCount = 0;
-
- while (WordCount < ByteCount / 2) {
- //
- // Poll DRQ bit set, data transfer can be performed only when DRQ is ready.
- //
- Status = DRQReady2 (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- Status = CheckErrorStatus (IdeDev);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // Write data into device by one series of writing to data register
- //
- if ((WordCount + Increment) > ByteCount / 2) {
- Increment = ByteCount / 2 - WordCount;
- }
-
- IDEWritePortWMultiple (
- IdeDev->PciIo,
- IdeDev->IoPort->Data,
- Increment,
- Buffer16
- );
-
- WordCount += Increment;
- Buffer16 += Increment;
-
- }
- return CheckErrorStatus (IdeDev);
-}
-/**
- This function is called by the AtaBlkIoWriteBlocks() to perform
- writing to media in block unit. The function has been enhanced to
- support >120GB access and transfer at most 65536 blocks per command
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
- @param DataBuffer A pointer to the source buffer for the data.
- @param StartLba The starting logical block address to write to
- on the device media.
- @param NumberOfBlocks The number of transfer data blocks.
-
- @return status depends on the function DoAtaUdma() returns.
-**/
-EFI_STATUS
-AtaUdmaWriteExt (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN VOID *DataBuffer,
- IN EFI_LBA StartLba,
- IN UINTN NumberOfBlocks
- )
-{
- return DoAtaUdma (IdeDev, DataBuffer, StartLba, NumberOfBlocks, AtaUdmaWriteExtOp);
-}
-
-/**
- This function is called by the AtaBlkIoWriteBlocks() to perform
- writing to media in block unit.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
- @param DataBuffer A pointer to the source buffer for the data.
- @param StartLba The starting logical block address to write to
- on the device media.
- @param NumberOfBlocks The number of transfer data blocks.
-
- @return status depends on the function DoAtaUdma() returns.
-**/
-EFI_STATUS
-AtaUdmaWrite (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN VOID *DataBuffer,
- IN EFI_LBA StartLba,
- IN UINTN NumberOfBlocks
- )
-{
- return DoAtaUdma (IdeDev, DataBuffer, StartLba, NumberOfBlocks, AtaUdmaWriteOp);
-}
-/**
- This function is called by the AtaBlkIoWriteBlocks() to perform
- writing onto media in block unit. The function has been enhanced to
- support >120GB access and transfer at most 65536 blocks per command
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure,used
- to record all the information of the IDE device.
- @param DataBuffer A pointer to the source buffer for the data.
- @param StartLba The starting logical block address to write onto the device
- media.
- @param NumberOfBlocks The number of transfer data blocks.
-
- @return status is fully dependent on the return status of AtaPioDataOutExt() function.
-**/
-EFI_STATUS
-AtaWriteSectorsExt (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN VOID *DataBuffer,
- IN EFI_LBA StartLba,
- IN UINTN NumberOfBlocks
- )
-{
- EFI_STATUS Status;
- EFI_LBA Lba64;
- UINTN BlocksRemaining;
- UINT8 AtaCommand;
- UINT16 SectorCount;
- UINT32 ByteCount;
- VOID *Buffer;
-
- //
- // Using ATA "Write Sectors Ext" cmd(opcode=0x24) with PIO DATA OUT protocol
- //
- AtaCommand = ATA_CMD_WRITE_SECTORS_EXT;
- Lba64 = StartLba;
- Buffer = DataBuffer;
- BlocksRemaining = NumberOfBlocks;
-
- Status = EFI_SUCCESS;
-
- while (BlocksRemaining > 0) {
-
- if (BlocksRemaining >= 0x10000) {
- //
- // SectorCount is used to record the number of sectors to be written.
- // Max 65536 sectors can be transfered at a time.
- //
- SectorCount = 0xffff;
- } else {
- SectorCount = (UINT16) BlocksRemaining;
- }
-
- //
- // ByteCount is the number of bytes that will be written
- //
- ByteCount = SectorCount * (IdeDev->BlkIo.Media->BlockSize);
-
- //
- // Call AtaPioDataOutExt() to send "Write Sectors Ext" Command
- //
- Status = AtaPioDataOutExt (
- IdeDev,
- Buffer,
- ByteCount,
- AtaCommand,
- Lba64,
- SectorCount
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Lba64 += SectorCount;
- Buffer = ((UINT8 *) Buffer + ByteCount);
- BlocksRemaining -= SectorCount;
- }
-
- return Status;
-}
-/**
- This function is the ATA implementation for WriteBlocks in the
- Block I/O Protocol interface.
-
- @param IdeBlkIoDevice Indicates the calling context.
- @param MediaId The media id that the write request is for.
- @param Lba The starting logical block address to write onto the device.
- @param BufferSize The size of the Buffer in bytes. This must be a multiple
- of the intrinsic block size of the device.
- @param Buffer A pointer to the source buffer for the data.The caller
- is responsible for either having implicit or explicit
- ownership of the memory that data is written from.
-
- @retval EFI_SUCCESS Write Blocks successfully.
- @retval EFI_DEVICE_ERROR Write Blocks failed.
- @retval EFI_NO_MEDIA There is no media in the device.
- @retval EFI_MEDIA_CHANGE The MediaId is not for the current media.
-
- @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
- intrinsic block size of the device.
- @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
- or the data buffer is not valid.
-
- @note If Write Block error because of device error, this function will call
- AtaSoftReset() function to reset device.
-**/
-EFI_STATUS
-AtaBlkIoWriteBlocks (
- IN IDE_BLK_IO_DEV *IdeBlkIoDevice,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- )
-{
-
- EFI_BLOCK_IO_MEDIA *Media;
- UINTN BlockSize;
- UINTN NumberOfBlocks;
- EFI_STATUS Status;
-
- if (Buffer == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (BufferSize == 0) {
- return EFI_SUCCESS;
- }
-
- Status = EFI_SUCCESS;
-
- //
- // Get the intrinsic block size
- //
- Media = IdeBlkIoDevice->BlkIo.Media;
- BlockSize = Media->BlockSize;
- NumberOfBlocks = BufferSize / BlockSize;
-
- if (MediaId != Media->MediaId) {
- return EFI_MEDIA_CHANGED;
- }
-
- if (BufferSize % BlockSize != 0) {
- return EFI_BAD_BUFFER_SIZE;
- }
-
- if (Lba > Media->LastBlock) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((Lba + NumberOfBlocks - 1) > Media->LastBlock) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((Media->IoAlign > 1) && (((UINTN) Buffer & (Media->IoAlign - 1)) != 0)) {
- return EFI_INVALID_PARAMETER;
- }
-
- Status = EFI_SUCCESS;
- if (IdeBlkIoDevice->Type == Ide48bitAddressingHardDisk) {
- //
- // For ATA/ATAPI-6 device(capcity > 120GB), use ATA-6 write block mechanism
- //
- if (IdeBlkIoDevice->UdmaMode.Valid) {
- Status = AtaUdmaWriteExt (IdeBlkIoDevice, Buffer, Lba, NumberOfBlocks);
- } else {
- Status = AtaWriteSectorsExt (IdeBlkIoDevice, Buffer, Lba, NumberOfBlocks);
- }
- } else {
- //
- // For ATA-3 compatible device, use ATA-3 write block mechanism
- //
- if (IdeBlkIoDevice->UdmaMode.Valid) {
- Status = AtaUdmaWrite (IdeBlkIoDevice, Buffer, Lba, NumberOfBlocks);
- } else {
- Status = AtaWriteSectors (IdeBlkIoDevice, Buffer, Lba, NumberOfBlocks);
- }
- }
-
- if (EFI_ERROR (Status)) {
- AtaSoftReset (IdeBlkIoDevice);
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-/**
- Enable Long Physical Sector Feature for ATA device.
-
- @param IdeDev The IDE device data
-
- @retval EFI_SUCCESS The ATA device supports Long Physical Sector feature
- and corresponding fields in BlockIo structure is updated.
- @retval EFI_UNSUPPORTED The device is not ATA device or Long Physical Sector
- feature is not supported.
-**/
-EFI_STATUS
-AtaEnableLongPhysicalSector (
- IN IDE_BLK_IO_DEV *IdeDev
- )
-{
- EFI_ATA_IDENTIFY_DATA *AtaIdentifyData;
- UINT16 PhyLogicSectorSupport;
-
- ASSERT (IdeDev->IdData != NULL);
- //
- // Only valid for ATA device
- //
- AtaIdentifyData = (EFI_ATA_IDENTIFY_DATA *) &IdeDev->IdData->AtaData;
- if ((AtaIdentifyData->config & 0x8000) != 0) {
- return EFI_UNSUPPORTED;
- }
- PhyLogicSectorSupport = AtaIdentifyData->phy_logic_sector_support;
- //
- // Check whether Long Physical Sector Feature is supported
- //
- if ((PhyLogicSectorSupport & 0xc000) == 0x4000) {
- IdeDev->BlkIo.Media->LogicalBlocksPerPhysicalBlock = 1;
- IdeDev->BlkIo.Media->LowestAlignedLba = 0;
- //
- // Check whether one physical block contains multiple physical blocks
- //
- if ((PhyLogicSectorSupport & 0x2000) != 0) {
- IdeDev->BlkIo.Media->LogicalBlocksPerPhysicalBlock =
- (UINT32) (1 << (PhyLogicSectorSupport & 0x000f));
- //
- // Check lowest alignment of logical blocks within physical block
- //
- if ((AtaIdentifyData->alignment_logic_in_phy_blocks & 0xc000) == 0x4000) {
- IdeDev->BlkIo.Media->LowestAlignedLba =
- (EFI_LBA) ((IdeDev->BlkIo.Media->LogicalBlocksPerPhysicalBlock - ((UINT32)AtaIdentifyData->alignment_logic_in_phy_blocks & 0x3fff)) %
- IdeDev->BlkIo.Media->LogicalBlocksPerPhysicalBlock);
- }
- }
- //
- // Check logical block size
- //
- IdeDev->BlkIo.Media->BlockSize = 0x200;
- if ((PhyLogicSectorSupport & 0x1000) != 0) {
- IdeDev->BlkIo.Media->BlockSize = (UINT32) (
- ((AtaIdentifyData->logic_sector_size_hi << 16) |
- AtaIdentifyData->logic_sector_size_lo) * sizeof (UINT16)
- );
- }
- return EFI_SUCCESS;
- } else {
- return EFI_UNSUPPORTED;
- }
-}
-/**
- Send ATA command into device with NON_DATA protocol
-
- @param IdeDev Standard IDE device private data structure
- @param AtaCommand The ATA command to be sent
- @param Device The value in Device register
- @param Feature The value in Feature register
- @param SectorCount The value in SectorCount register
- @param LbaLow The value in LBA_LOW register
- @param LbaMiddle The value in LBA_MIDDLE register
- @param LbaHigh The value in LBA_HIGH register
-
- @retval EFI_SUCCESS Reading succeed
- @retval EFI_ABORTED Command failed
- @retval EFI_DEVICE_ERROR Device status error.
-
-**/
-EFI_STATUS
-AtaNonDataCommandIn (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN UINT8 AtaCommand,
- IN UINT8 Device,
- IN UINT8 Feature,
- IN UINT8 SectorCount,
- IN UINT8 LbaLow,
- IN UINT8 LbaMiddle,
- IN UINT8 LbaHigh
- )
-{
- EFI_STATUS Status;
- UINT8 StatusRegister;
-
- Status = WaitForBSYClear (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // Select device (bit4), set Lba mode(bit6) (use 0xe0 for compatibility)
- //
- IDEWritePortB (
- IdeDev->PciIo,
- IdeDev->IoPort->Head,
- (UINT8) ((IdeDev->Device << 4) | 0xe0)
- );
-
- //
- // ATA commands for ATA device must be issued when DRDY is set
- //
- Status = DRDYReady (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // Pass parameter into device register block
- //
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Head, Device);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Feature, Feature);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorCount, SectorCount);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorNumber, LbaLow);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb, LbaMiddle);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb, LbaHigh);
-
- //
- // Send command via Command Register
- //
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, AtaCommand);
-
- //
- // Wait for command completion
- // For ATAPI_SMART_CMD, we may need more timeout to let device
- // adjust internal states.
- //
- if (AtaCommand == ATA_CMD_SMART) {
- Status = WaitForBSYClear (IdeDev, ATASMARTTIMEOUT);
- } else {
- Status = WaitForBSYClear (IdeDev, ATATIMEOUT);
- }
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- StatusRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Status);
- if ((StatusRegister & ATA_STSREG_ERR) == ATA_STSREG_ERR) {
- //
- // Failed to execute command, abort operation
- //
- return EFI_ABORTED;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Send ATA Ext command into device with NON_DATA protocol
-
- @param IdeDev Standard IDE device private data structure
- @param AtaCommand The ATA command to be sent
- @param Device The value in Device register
- @param Feature The value in Feature register
- @param SectorCount The value in SectorCount register
- @param LbaAddress The LBA address in 48-bit mode
-
- @retval EFI_SUCCESS Reading succeed
- @retval EFI_ABORTED Command failed
- @retval EFI_DEVICE_ERROR Device status error.
-
-**/
-EFI_STATUS
-AtaNonDataCommandInExt (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN UINT8 AtaCommand,
- IN UINT8 Device,
- IN UINT16 Feature,
- IN UINT16 SectorCount,
- IN EFI_LBA LbaAddress
- )
-{
- EFI_STATUS Status;
- UINT8 StatusRegister;
- UINT8 SectorCount8;
- UINT8 Feature8;
- UINT8 LbaLow;
- UINT8 LbaMid;
- UINT8 LbaHigh;
-
- Status = WaitForBSYClear (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // Select device (bit4), set LBA mode(bit6) (use 0xe0 for compatibility)
- //
- IDEWritePortB (
- IdeDev->PciIo,
- IdeDev->IoPort->Head,
- (UINT8) ((IdeDev->Device << 4) | 0xe0)
- );
-
- //
- // ATA commands for ATA device must be issued when DRDY is set
- //
- Status = DRDYReady (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // Pass parameter into device register block
- //
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Head, Device);
-
- //
- // Fill the feature register, which is a two-byte FIFO. Need write twice.
- //
- Feature8 = (UINT8) (Feature >> 8);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Feature, Feature8);
-
- Feature8 = (UINT8) Feature;
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Feature, Feature8);
-
- //
- // Fill the sector count register, which is a two-byte FIFO. Need write twice.
- //
- SectorCount8 = (UINT8) (SectorCount >> 8);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorCount, SectorCount8);
-
- SectorCount8 = (UINT8) SectorCount;
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorCount, SectorCount8);
-
- //
- // Fill the start LBA registers, which are also two-byte FIFO
- //
- LbaLow = (UINT8) RShiftU64 (LbaAddress, 24);
- LbaMid = (UINT8) RShiftU64 (LbaAddress, 32);
- LbaHigh = (UINT8) RShiftU64 (LbaAddress, 40);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorNumber, LbaLow);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb, LbaMid);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb, LbaHigh);
-
- LbaLow = (UINT8) LbaAddress;
- LbaMid = (UINT8) RShiftU64 (LbaAddress, 8);
- LbaHigh = (UINT8) RShiftU64 (LbaAddress, 16);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->SectorNumber, LbaLow);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb, LbaMid);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb, LbaHigh);
-
- //
- // Send command via Command Register
- //
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, AtaCommand);
-
- //
- // Wait for command completion
- //
- Status = WaitForBSYClear (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- StatusRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Status);
- if ((StatusRegister & ATA_STSREG_ERR) == ATA_STSREG_ERR) {
- //
- // Failed to execute command, abort operation
- //
- return EFI_ABORTED;
- }
-
- return EFI_SUCCESS;
-}
-
-
-
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Atapi.c b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Atapi.c deleted file mode 100644 index c641dc5714..0000000000 --- a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Atapi.c +++ /dev/null @@ -1,1952 +0,0 @@ -/** @file
- This file contains all helper functions on the ATAPI command
-
- Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
- 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 "IdeBus.h"
-
-/**
- This function is used to get the current status of the media residing
- in the LS-120 drive or ZIP drive. The media status is returned in the
- Error Status.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
-
- @retval EFI_SUCCESS The media status is achieved successfully and the media
- can be read/written.
- @retval EFI_DEVICE_ERROR Get Media Status Command is failed.
- @retval EFI_NO_MEDIA There is no media in the drive.
- @retval EFI_WRITE_PROTECTED The media is writing protected.
-
- @note This function must be called after the LS120EnableMediaStatus()
- with second parameter set to TRUE
- (means enable media status notification) is called.
-**/
-EFI_STATUS
-LS120GetMediaStatus (
- IN IDE_BLK_IO_DEV *IdeDev
- )
-{
- UINT8 DeviceSelect;
- UINT8 StatusValue;
- EFI_STATUS EfiStatus;
- //
- // Poll Alternate Register for BSY clear within timeout.
- //
- EfiStatus = WaitForBSYClear2 (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (EfiStatus)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // Select device via Device/Head Register.
- //
- DeviceSelect = (UINT8) ((IdeDev->Device) << 4 | 0xe0);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Head, DeviceSelect);
-
- //
- // Poll Alternate Register for DRDY set within timeout.
- // After device is selected, DRDY set indicates the device is ready to
- // accept command.
- //
- EfiStatus = DRDYReady2 (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (EfiStatus)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // Get Media Status Command is sent
- //
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, 0xDA);
-
- //
- // BSY bit will clear after command is complete.
- //
- EfiStatus = WaitForBSYClear2 (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (EfiStatus)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // the media status is returned by the command in the ERROR register
- //
- StatusValue = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Error);
-
- if ((StatusValue & BIT1) != 0) {
- return EFI_NO_MEDIA;
- }
-
- if ((StatusValue & BIT6) != 0) {
- return EFI_WRITE_PROTECTED;
- } else {
- return EFI_SUCCESS;
- }
-}
-/**
- This function is used to send Enable Media Status Notification Command
- or Disable Media Status Notification Command.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
-
- @param Enable a flag that indicates whether enable or disable media
- status notification.
- @retval EFI_SUCCESS If command completes successfully.
- @retval EFI_DEVICE_ERROR If command failed.
-**/
-EFI_STATUS
-LS120EnableMediaStatus (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN BOOLEAN Enable
- )
-{
- UINT8 DeviceSelect;
- EFI_STATUS Status;
-
- //
- // Poll Alternate Register for BSY clear within timeout.
- //
- Status = WaitForBSYClear2 (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // Select device via Device/Head Register.
- //
- DeviceSelect = (UINT8) ((IdeDev->Device) << 4 | 0xe0);
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Head, DeviceSelect);
-
- //
- // Poll Alternate Register for DRDY set within timeout.
- // After device is selected, DRDY set indicates the device is ready to
- // accept command.
- //
- Status = DRDYReady2 (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- if (Enable) {
- //
- // 0x95: Enable media status notification
- //
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Feature, 0x95);
- } else {
- //
- // 0x31: Disable media status notification
- //
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Feature, 0x31);
- }
- //
- // Set Feature Command is sent
- //
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, 0xEF);
-
- //
- // BSY bit will clear after command is complete.
- //
- Status = WaitForBSYClear (IdeDev, ATATIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-/**
- This function reads the pending data in the device.
-
- @param IdeDev Indicates the calling context.
-
- @retval EFI_SUCCESS Successfully read.
- @retval EFI_NOT_READY The BSY is set avoiding reading.
-
-**/
-EFI_STATUS
-AtapiReadPendingData (
- IN IDE_BLK_IO_DEV *IdeDev
- )
-{
- UINT8 AltRegister;
- UINT16 TempWordBuffer;
-
- AltRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Alt.AltStatus);
- if ((AltRegister & ATA_STSREG_BSY) == ATA_STSREG_BSY) {
- return EFI_NOT_READY;
- }
- if ((AltRegister & (ATA_STSREG_BSY | ATA_STSREG_DRQ)) == ATA_STSREG_DRQ) {
- TempWordBuffer = IDEReadPortB (IdeDev->PciIo,IdeDev->IoPort->Alt.AltStatus);
- while ((TempWordBuffer & (ATA_STSREG_BSY | ATA_STSREG_DRQ)) == ATA_STSREG_DRQ) {
- IDEReadPortWMultiple (
- IdeDev->PciIo,
- IdeDev->IoPort->Data,
- 1,
- &TempWordBuffer
- );
- TempWordBuffer = IDEReadPortB (IdeDev->PciIo,IdeDev->IoPort->Alt.AltStatus);
- }
- }
- return EFI_SUCCESS;
-}
-
-/**
- This function is called by either AtapiPacketCommandIn() or AtapiPacketCommandOut().
- It is used to transfer data between host and device. The data direction is specified
- by the fourth parameter.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record
- all the information of the IDE device.
- @param Buffer buffer contained data transferred between host and device.
- @param ByteCount data size in byte unit of the buffer.
- @param Read flag used to determine the data transfer direction.
- Read equals 1, means data transferred from device to host;
- Read equals 0, means data transferred from host to device.
- @param TimeOut timeout value for wait DRQ ready before each data stream's transfer.
-
- @retval EFI_SUCCESS data is transferred successfully.
- @retval EFI_DEVICE_ERROR the device failed to transfer data.
-**/
-EFI_STATUS
-PioReadWriteData (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN UINT16 *Buffer,
- IN UINT32 ByteCount,
- IN BOOLEAN Read,
- IN UINTN TimeOut
- )
-{
- //
- // required transfer data in word unit.
- //
- UINT32 RequiredWordCount;
-
- //
- // actual transfer data in word unit.
- //
- UINT32 ActualWordCount;
- UINT32 WordCount;
- EFI_STATUS Status;
- UINT16 *PtrBuffer;
-
- //
- // No data transfer is premitted.
- //
- if (ByteCount == 0) {
- return EFI_SUCCESS;
- }
- //
- // for performance, we assert the ByteCount is an even number
- // which is actually a resonable assumption
- ASSERT((ByteCount%2) == 0);
-
- PtrBuffer = Buffer;
- RequiredWordCount = ByteCount / 2;
- //
- // ActuralWordCount means the word count of data really transferred.
- //
- ActualWordCount = 0;
-
- while (ActualWordCount < RequiredWordCount) {
-
- //
- // before each data transfer stream, the host should poll DRQ bit ready,
- // to see whether indicates device is ready to transfer data.
- //
- Status = DRQReady2 (IdeDev, TimeOut);
- if (EFI_ERROR (Status)) {
- return CheckErrorStatus (IdeDev);
- }
-
- //
- // read Status Register will clear interrupt
- //
- IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Status);
-
- //
- // get current data transfer size from Cylinder Registers.
- //
- WordCount = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->CylinderMsb) << 8;
- WordCount = WordCount | IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->CylinderLsb);
- WordCount = WordCount & 0xffff;
- WordCount /= 2;
-
- WordCount = MIN (WordCount, (RequiredWordCount - ActualWordCount));
-
- if (Read) {
- IDEReadPortWMultiple (
- IdeDev->PciIo,
- IdeDev->IoPort->Data,
- WordCount,
- PtrBuffer
- );
- } else {
- IDEWritePortWMultiple (
- IdeDev->PciIo,
- IdeDev->IoPort->Data,
- WordCount,
- PtrBuffer
- );
- }
-
- PtrBuffer += WordCount;
- ActualWordCount += WordCount;
- }
-
- if (Read) {
- //
- // In the case where the drive wants to send more data than we need to read,
- // the DRQ bit will be set and cause delays from DRQClear2().
- // We need to read data from the drive until it clears DRQ so we can move on.
- //
- AtapiReadPendingData (IdeDev);
- }
-
- //
- // After data transfer is completed, normally, DRQ bit should clear.
- //
- Status = DRQClear2 (IdeDev, ATAPITIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // read status register to check whether error happens.
- //
- return CheckErrorStatus (IdeDev);
-}
-
-/**
- This function is used to send out ATAPI commands conforms to the Packet Command
- with PIO Data In Protocol.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
- @param Packet pointer pointing to ATAPI_PACKET_COMMAND data structure
- which contains the contents of the command.
- @param Buffer buffer contained data transferred from device to host.
- @param ByteCount data size in byte unit of the buffer.
- @param TimeOut this parameter is used to specify the timeout value for the
- PioReadWriteData() function.
-
- @retval EFI_SUCCESS send out the ATAPI packet command successfully
- and device sends data successfully.
- @retval EFI_DEVICE_ERROR the device failed to send data.
-
-**/
-EFI_STATUS
-AtapiPacketCommandIn (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN ATAPI_PACKET_COMMAND *Packet,
- IN UINT16 *Buffer,
- IN UINT32 ByteCount,
- IN UINTN TimeOut
- )
-{
- UINT16 *CommandIndex;
- EFI_STATUS Status;
- UINT32 Count;
-
- //
- // Set all the command parameters by fill related registers.
- // Before write to all the following registers, BSY and DRQ must be 0.
- //
- Status = DRQClear2 (IdeDev, ATAPITIMEOUT);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Select device via Device/Head Register.
- //
- IDEWritePortB (
- IdeDev->PciIo,
- IdeDev->IoPort->Head,
- (UINT8) ((IdeDev->Device << 4) | ATA_DEFAULT_CMD) // DEFAULT_CMD: 0xa0 (1010,0000)
- );
-
- //
- // No OVL; No DMA
- //
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Feature, 0x00);
-
- //
- // set the transfersize to ATAPI_MAX_BYTE_COUNT to let the device
- // determine how many data should be transferred.
- //
- IDEWritePortB (
- IdeDev->PciIo,
- IdeDev->IoPort->CylinderLsb,
- (UINT8) (ATAPI_MAX_BYTE_COUNT & 0x00ff)
- );
- IDEWritePortB (
- IdeDev->PciIo,
- IdeDev->IoPort->CylinderMsb,
- (UINT8) (ATAPI_MAX_BYTE_COUNT >> 8)
- );
-
- //
- // ATA_DEFAULT_CTL:0x0a (0000,1010)
- // Disable interrupt
- //
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Alt.DeviceControl, ATA_DEFAULT_CTL);
-
- //
- // Send Packet command to inform device
- // that the following data bytes are command packet.
- //
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, ATA_CMD_PACKET);
-
- Status = DRQReady (IdeDev, ATAPITIMEOUT);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Send out command packet
- //
- CommandIndex = Packet->Data16;
- for (Count = 0; Count < 6; Count++, CommandIndex++) {
-
- IDEWritePortW (IdeDev->PciIo, IdeDev->IoPort->Data, *CommandIndex);
- gBS->Stall (10);
- }
-
- //
- // call PioReadWriteData() function to get
- // requested transfer data form device.
- //
- return PioReadWriteData (IdeDev, Buffer, ByteCount, 1, TimeOut);
-}
-/**
- This function is used to send out ATAPI commands conforms to the Packet Command
- with PIO Data Out Protocol.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
- @param Packet pointer pointing to ATAPI_PACKET_COMMAND data structure
- which contains the contents of the command.
- @param Buffer buffer contained data transferred from host to device.
- @param ByteCount data size in byte unit of the buffer.
- @param TimeOut this parameter is used to specify the timeout value
- for the PioReadWriteData() function.
- @retval EFI_SUCCESS send out the ATAPI packet command successfully
- and device received data successfully.
- @retval EFI_DEVICE_ERROR the device failed to send data.
-
-**/
-EFI_STATUS
-AtapiPacketCommandOut (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN ATAPI_PACKET_COMMAND *Packet,
- IN UINT16 *Buffer,
- IN UINT32 ByteCount,
- IN UINTN TimeOut
- )
-{
- UINT16 *CommandIndex;
- EFI_STATUS Status;
- UINT32 Count;
-
- //
- // set all the command parameters
- // Before write to all the following registers, BSY and DRQ must be 0.
- //
- Status = DRQClear2 (IdeDev, ATAPITIMEOUT);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Select device via Device/Head Register.
- //
- IDEWritePortB (
- IdeDev->PciIo,
- IdeDev->IoPort->Head,
- (UINT8) ((IdeDev->Device << 4) | ATA_DEFAULT_CMD) // ATA_DEFAULT_CMD: 0xa0 (1010,0000)
- );
-
- //
- // No OVL; No DMA
- //
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Feature, 0x00);
-
- //
- // set the transfersize to ATAPI_MAX_BYTE_COUNT to
- // let the device determine how many data should be transferred.
- //
- IDEWritePortB (
- IdeDev->PciIo,
- IdeDev->IoPort->CylinderLsb,
- (UINT8) (ATAPI_MAX_BYTE_COUNT & 0x00ff)
- );
- IDEWritePortB (
- IdeDev->PciIo,
- IdeDev->IoPort->CylinderMsb,
- (UINT8) (ATAPI_MAX_BYTE_COUNT >> 8)
- );
-
- //
- // DEFAULT_CTL:0x0a (0000,1010)
- // Disable interrupt
- //
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Alt.DeviceControl, ATA_DEFAULT_CTL);
-
- //
- // Send Packet command to inform device
- // that the following data bytes are command packet.
- //
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, ATA_CMD_PACKET);
-
- Status = DRQReady2 (IdeDev, ATAPITIMEOUT);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Send out command packet
- //
- CommandIndex = Packet->Data16;
- for (Count = 0; Count < 6; Count++, CommandIndex++) {
- IDEWritePortW (IdeDev->PciIo, IdeDev->IoPort->Data, *CommandIndex);
- gBS->Stall (10);
- }
-
- //
- // call PioReadWriteData() function to send requested transfer data to device.
- //
- return PioReadWriteData (IdeDev, Buffer, ByteCount, 0, TimeOut);
-}
-/**
- Sends out ATAPI Inquiry Packet Command to the specified device. This command will
- return INQUIRY data of the device.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
-
- @retval EFI_SUCCESS Inquiry command completes successfully.
- @retval EFI_DEVICE_ERROR Inquiry command failed.
-
- @note Parameter "IdeDev" will be updated in this function.
-
-**/
-EFI_STATUS
-AtapiInquiry (
- IN IDE_BLK_IO_DEV *IdeDev
- )
-{
- ATAPI_PACKET_COMMAND Packet;
- EFI_STATUS Status;
- ATAPI_INQUIRY_DATA *InquiryData;
-
- //
- // prepare command packet for the ATAPI Inquiry Packet Command.
- //
- ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));
- Packet.Inquiry.opcode = ATA_CMD_INQUIRY;
- Packet.Inquiry.page_code = 0;
- Packet.Inquiry.allocation_length = (UINT8) sizeof (ATAPI_INQUIRY_DATA);
-
- InquiryData = AllocatePool (sizeof (ATAPI_INQUIRY_DATA));
- if (InquiryData == NULL) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // Send command packet and get requested Inquiry data.
- //
- Status = AtapiPacketCommandIn (
- IdeDev,
- &Packet,
- (UINT16 *) InquiryData,
- sizeof (ATAPI_INQUIRY_DATA),
- ATAPITIMEOUT
- );
- if (EFI_ERROR (Status)) {
- gBS->FreePool (InquiryData);
- return EFI_DEVICE_ERROR;
- }
-
- IdeDev->InquiryData = InquiryData;
-
- return EFI_SUCCESS;
-}
-/**
- This function is called by DiscoverIdeDevice() during its device
- identification.
- Its main purpose is to get enough information for the device media
- to fill in the Media data structure of the Block I/O Protocol interface.
-
- There are 5 steps to reach such objective:
- 1. Sends out the ATAPI Identify Command to the specified device.
- Only ATAPI device responses to this command. If the command succeeds,
- it returns the Identify data structure which filled with information
- about the device. Since the ATAPI device contains removable media,
- the only meaningful information is the device module name.
- 2. Sends out ATAPI Inquiry Packet Command to the specified device.
- This command will return inquiry data of the device, which contains
- the device type information.
- 3. Allocate sense data space for future use. We don't detect the media
- presence here to improvement boot performance, especially when CD
- media is present. The media detection will be performed just before
- each BLK_IO read/write
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
-
- @retval EFI_SUCCESS Identify ATAPI device successfully.
- @retval EFI_DEVICE_ERROR ATAPI Identify Device Command failed or device type
- is not supported by this IDE driver.
- @retval EFI_OUT_OF_RESOURCES Allocate memory for sense data failed
-
- @note Parameter "IdeDev" will be updated in this function.
-**/
-EFI_STATUS
-ATAPIIdentify (
- IN IDE_BLK_IO_DEV *IdeDev
- )
-{
- EFI_IDENTIFY_DATA *AtapiIdentifyPointer;
- UINT8 DeviceSelect;
- EFI_STATUS Status;
-
- //
- // device select bit
- //
- DeviceSelect = (UINT8) ((IdeDev->Device) << 4);
-
- AtapiIdentifyPointer = AllocatePool (sizeof (EFI_IDENTIFY_DATA));
- if (AtapiIdentifyPointer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // Send ATAPI Identify Command to get IDENTIFY data.
- //
- Status = AtaPioDataIn (
- IdeDev,
- (VOID *) AtapiIdentifyPointer,
- sizeof (EFI_IDENTIFY_DATA),
- ATA_CMD_IDENTIFY_DEVICE,
- DeviceSelect,
- 0,
- 0,
- 0,
- 0
- );
-
- if (EFI_ERROR (Status)) {
- gBS->FreePool (AtapiIdentifyPointer);
- return EFI_DEVICE_ERROR;
- }
-
- IdeDev->IdData = AtapiIdentifyPointer;
- PrintAtaModuleName (IdeDev);
-
- //
- // Send ATAPI Inquiry Packet Command to get INQUIRY data.
- //
- Status = AtapiInquiry (IdeDev);
- if (EFI_ERROR (Status)) {
- gBS->FreePool (IdeDev->IdData);
- //
- // Make sure the pIdData will not be freed again.
- //
- IdeDev->IdData = NULL;
- return EFI_DEVICE_ERROR;
- }
- //
- // Get media removable info from INQUIRY data.
- //
- IdeDev->BlkIo.Media->RemovableMedia = (UINT8) ((IdeDev->InquiryData->RMB & 0x80) == 0x80);
-
- //
- // Identify device type via INQUIRY data.
- //
- switch (IdeDev->InquiryData->peripheral_type & 0x1f) {
-
- //
- // Magnetic Disk
- //
- case 0x00:
-
- //
- // device is LS120 or ZIP drive.
- //
- IdeDev->Type = IdeMagnetic;
-
- IdeDev->BlkIo.Media->MediaId = 0;
- //
- // Give initial value
- //
- IdeDev->BlkIo.Media->MediaPresent = FALSE;
-
- IdeDev->BlkIo.Media->LastBlock = 0;
- IdeDev->BlkIo.Media->BlockSize = 0x200;
- break;
-
- //
- // CD-ROM
- //
- case 0x05:
-
- IdeDev->Type = IdeCdRom;
- IdeDev->BlkIo.Media->MediaId = 0;
- //
- // Give initial value
- //
- IdeDev->BlkIo.Media->MediaPresent = FALSE;
-
- IdeDev->BlkIo.Media->LastBlock = 0;
- IdeDev->BlkIo.Media->BlockSize = 0x800;
- IdeDev->BlkIo.Media->ReadOnly = TRUE;
- break;
-
- //
- // Tape
- //
- case 0x01:
-
- //
- // WORM
- //
- case 0x04:
-
- //
- // Optical
- //
- case 0x07:
-
- default:
- IdeDev->Type = IdeUnknown;
- gBS->FreePool (IdeDev->IdData);
- gBS->FreePool (IdeDev->InquiryData);
- //
- // Make sure the pIdData and pInquiryData will not be freed again.
- //
- IdeDev->IdData = NULL;
- IdeDev->InquiryData = NULL;
- return EFI_DEVICE_ERROR;
- }
-
- //
- // original sense data numbers
- //
- IdeDev->SenseDataNumber = 20;
-
- IdeDev->SenseData = AllocatePool (IdeDev->SenseDataNumber * sizeof (ATAPI_REQUEST_SENSE_DATA));
- if (IdeDev->SenseData == NULL) {
- gBS->FreePool (IdeDev->IdData);
- gBS->FreePool (IdeDev->InquiryData);
- //
- // Make sure the pIdData and pInquiryData will not be freed again.
- //
- IdeDev->IdData = NULL;
- IdeDev->InquiryData = NULL;
- return EFI_OUT_OF_RESOURCES;
- }
-
- return EFI_SUCCESS;
-}
-/**
- Sends out ATAPI Request Sense Packet Command to the specified device. This command
- will return all the current Sense data in the device. This function will pack
- all the Sense data in one single buffer.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
- @param SenseCounts allocated in this function, and freed by the calling function.
- This buffer is used to accommodate all the sense data returned
- by the device.
-
- @retval EFI_SUCCESS Request Sense command completes successfully.
- @retval EFI_DEVICE_ERROR Request Sense command failed.
-**/
-EFI_STATUS
-AtapiRequestSense (
- IN IDE_BLK_IO_DEV *IdeDev,
- OUT UINTN *SenseCounts
- )
-{
- EFI_STATUS Status;
- ATAPI_REQUEST_SENSE_DATA *Sense;
- UINT16 *Ptr;
- BOOLEAN FetchSenseData;
- ATAPI_PACKET_COMMAND Packet;
-
- *SenseCounts = 0;
-
- ZeroMem (IdeDev->SenseData, sizeof (ATAPI_REQUEST_SENSE_DATA) * (IdeDev->SenseDataNumber));
- //
- // fill command packet for Request Sense Packet Command
- //
- ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));
- Packet.RequestSence.opcode = ATA_CMD_REQUEST_SENSE;
- Packet.RequestSence.allocation_length = (UINT8) sizeof (ATAPI_REQUEST_SENSE_DATA);
-
- //
- // initialize pointer
- //
- Ptr = (UINT16 *) IdeDev->SenseData;
- //
- // request sense data from device continuously until no sense data
- // exists in the device.
- //
- for (FetchSenseData = TRUE; FetchSenseData;) {
-
- Sense = (ATAPI_REQUEST_SENSE_DATA *) Ptr;
-
- //
- // send out Request Sense Packet Command and get one Sense data form device
- //
- Status = AtapiPacketCommandIn (
- IdeDev,
- &Packet,
- Ptr,
- sizeof (ATAPI_REQUEST_SENSE_DATA),
- ATAPITIMEOUT
- );
- //
- // failed to get Sense data
- //
- if (EFI_ERROR (Status)) {
- if (*SenseCounts == 0) {
- return EFI_DEVICE_ERROR;
- } else {
- return EFI_SUCCESS;
- }
- }
-
- (*SenseCounts)++;
- //
- // We limit MAX sense data count to 20 in order to avoid dead loop. Some
- // incompatible ATAPI devices don't retrive NO_SENSE when there is no media.
- // In this case, dead loop occurs if we don't have a gatekeeper. 20 is
- // supposed to be large enough for any ATAPI device.
- //
- if ((Sense->sense_key != ATA_SK_NO_SENSE) && ((*SenseCounts) < 20)) {
- //
- // Ptr is word-based pointer
- //
- Ptr += (sizeof (ATAPI_REQUEST_SENSE_DATA) + 1) >> 1;
-
- } else {
- //
- // when no sense key, skip out the loop
- //
- FetchSenseData = FALSE;
- }
- }
-
- return EFI_SUCCESS;
-}
-/**
- This function is used to parse sense data. Only the first sense data is honoured
-
- @param IdeDev Indicates the calling context.
- @param SenseCount Count of sense data.
- @param Result The parsed result.
-
- @retval EFI_SUCCESS Successfully parsed.
- @retval EFI_INVALID_PARAMETER Count of sense data is zero.
-
-**/
-EFI_STATUS
-ParseSenseData (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN UINTN SenseCount,
- OUT SENSE_RESULT *Result
- )
-{
- ATAPI_REQUEST_SENSE_DATA *SenseData;
-
- if (SenseCount == 0) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Only use the first sense data
- //
- SenseData = IdeDev->SenseData;
- *Result = SenseOtherSense;
-
- switch (SenseData->sense_key) {
- case ATA_SK_NO_SENSE:
- *Result = SenseNoSenseKey;
- break;
- case ATA_SK_NOT_READY:
- switch (SenseData->addnl_sense_code) {
- case ATA_ASC_NO_MEDIA:
- *Result = SenseNoMedia;
- break;
- case ATA_ASC_MEDIA_UPSIDE_DOWN:
- *Result = SenseMediaError;
- break;
- case ATA_ASC_NOT_READY:
- if (SenseData->addnl_sense_code_qualifier == ATA_ASCQ_IN_PROGRESS) {
- *Result = SenseDeviceNotReadyNeedRetry;
- } else {
- *Result = SenseDeviceNotReadyNoRetry;
- }
- break;
- }
- break;
- case ATA_SK_UNIT_ATTENTION:
- if (SenseData->addnl_sense_code == ATA_ASC_MEDIA_CHANGE) {
- *Result = SenseMediaChange;
- }
- break;
- case ATA_SK_MEDIUM_ERROR:
- switch (SenseData->addnl_sense_code) {
- case ATA_ASC_MEDIA_ERR1:
- case ATA_ASC_MEDIA_ERR2:
- case ATA_ASC_MEDIA_ERR3:
- case ATA_ASC_MEDIA_ERR4:
- *Result = SenseMediaError;
- break;
- }
- break;
- default:
- break;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Sends out ATAPI Test Unit Ready Packet Command to the specified device
- to find out whether device is accessible.
-
- @param IdeDev Pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
- @param SResult Sense result for this packet command.
-
- @retval EFI_SUCCESS Device is accessible.
- @retval EFI_DEVICE_ERROR Device is not accessible.
-
-**/
-EFI_STATUS
-AtapiTestUnitReady (
- IN IDE_BLK_IO_DEV *IdeDev,
- OUT SENSE_RESULT *SResult
- )
-{
- ATAPI_PACKET_COMMAND Packet;
- EFI_STATUS Status;
- UINTN SenseCount;
-
- //
- // fill command packet
- //
- ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));
- Packet.TestUnitReady.opcode = ATA_CMD_TEST_UNIT_READY;
-
- //
- // send command packet
- //
- Status = AtapiPacketCommandIn (IdeDev, &Packet, NULL, 0, ATAPITIMEOUT);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = AtapiRequestSense (IdeDev, &SenseCount);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- ParseSenseData (IdeDev, SenseCount, SResult);
- return EFI_SUCCESS;
-}
-
-
-/**
- Sends out ATAPI Read Capacity Packet Command to the specified device.
- This command will return the information regarding the capacity of the
- media in the device.
-
- Current device status will impact device's response to the Read Capacity
- Command. For example, if the device once reset, the Read Capacity
- Command will fail. The Sense data record the current device status, so
- if the Read Capacity Command failed, the Sense data must be requested
- and be analyzed to determine if the Read Capacity Command should retry.
-
- @param IdeDev Pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
- @param SResult Sense result for this packet command
-
- @retval EFI_SUCCESS Read Capacity Command finally completes successfully.
- @retval EFI_DEVICE_ERROR Read Capacity Command failed because of device error.
- @retval EFI_NOT_READY Operation succeeds but returned capacity is 0
-
- @note Parameter "IdeDev" will be updated in this function.
-
-
-**/
-EFI_STATUS
-AtapiReadCapacity (
- IN IDE_BLK_IO_DEV *IdeDev,
- OUT SENSE_RESULT *SResult
- )
-{
- //
- // status returned by Read Capacity Packet Command
- //
- EFI_STATUS Status;
- EFI_STATUS SenseStatus;
- ATAPI_PACKET_COMMAND Packet;
- UINTN SenseCount;
-
- //
- // used for capacity data returned from ATAPI device
- //
- ATAPI_READ_CAPACITY_DATA Data;
- ATAPI_READ_FORMAT_CAPACITY_DATA FormatData;
-
- ZeroMem (&Data, sizeof (Data));
- ZeroMem (&FormatData, sizeof (FormatData));
-
- if (IdeDev->Type == IdeCdRom) {
-
- ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));
- Packet.Inquiry.opcode = ATA_CMD_READ_CAPACITY;
- Status = AtapiPacketCommandIn (
- IdeDev,
- &Packet,
- (UINT16 *) &Data,
- sizeof (ATAPI_READ_CAPACITY_DATA),
- ATAPITIMEOUT
- );
-
- } else {
- //
- // Type == IdeMagnetic
- //
- ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));
- Packet.ReadFormatCapacity.opcode = ATA_CMD_READ_FORMAT_CAPACITY;
- Packet.ReadFormatCapacity.allocation_length_lo = 12;
- Status = AtapiPacketCommandIn (
- IdeDev,
- &Packet,
- (UINT16 *) &FormatData,
- sizeof (ATAPI_READ_FORMAT_CAPACITY_DATA),
- ATAPITIMEOUT
- );
- }
-
- if (Status == EFI_TIMEOUT) {
- return Status;
- }
-
- SenseStatus = AtapiRequestSense (IdeDev, &SenseCount);
-
- if (!EFI_ERROR (SenseStatus)) {
- ParseSenseData (IdeDev, SenseCount, SResult);
-
- if (!EFI_ERROR (Status) && *SResult == SenseNoSenseKey) {
- if (IdeDev->Type == IdeCdRom) {
-
- IdeDev->BlkIo.Media->LastBlock = ((UINT32) Data.LastLba3 << 24) |
- (Data.LastLba2 << 16) |
- (Data.LastLba1 << 8) |
- Data.LastLba0;
-
- IdeDev->BlkIo.Media->MediaPresent = TRUE;
-
- IdeDev->BlkIo.Media->ReadOnly = TRUE;
-
- //
- // Because the user data portion in the sector of the Data CD supported
- // is always 0x800
- //
- IdeDev->BlkIo.Media->BlockSize = 0x800;
- }
-
- if (IdeDev->Type == IdeMagnetic) {
-
- if (FormatData.DesCode == 3) {
- IdeDev->BlkIo.Media->MediaPresent = FALSE;
- IdeDev->BlkIo.Media->LastBlock = 0;
- } else {
-
- IdeDev->BlkIo.Media->LastBlock = ((UINT32) FormatData.LastLba3 << 24) |
- (FormatData.LastLba2 << 16) |
- (FormatData.LastLba1 << 8) |
- FormatData.LastLba0;
- if (IdeDev->BlkIo.Media->LastBlock != 0) {
- IdeDev->BlkIo.Media->LastBlock--;
-
- IdeDev->BlkIo.Media->BlockSize = (FormatData.BlockSize2 << 16) |
- (FormatData.BlockSize1 << 8) |
- FormatData.BlockSize0;
-
- IdeDev->BlkIo.Media->MediaPresent = TRUE;
- } else {
- IdeDev->BlkIo.Media->MediaPresent = FALSE;
- //
- // Return EFI_NOT_READY operation succeeds but returned capacity is 0
- //
- return EFI_NOT_READY;
- }
-
- IdeDev->BlkIo.Media->BlockSize = 0x200;
-
- }
- }
- }
-
- return EFI_SUCCESS;
-
- } else {
- return EFI_DEVICE_ERROR;
- }
-}
-/**
- This function is used to test the current media write-protected or not residing
- in the LS-120 drive or ZIP drive.
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
- @param WriteProtected if True, current media is write protected.
- if FALSE, current media is writable
-
- @retval EFI_SUCCESS The media write-protected status is achieved successfully
- @retval EFI_DEVICE_ERROR Get Media Status Command is failed.
-**/
-EFI_STATUS
-IsLS120orZipWriteProtected (
- IN IDE_BLK_IO_DEV *IdeDev,
- OUT BOOLEAN *WriteProtected
- )
-{
- EFI_STATUS Status;
-
- *WriteProtected = FALSE;
-
- Status = LS120EnableMediaStatus (IdeDev, TRUE);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // the Get Media Status Command is only valid
- // if a Set Features/Enable Media Status Command has been priviously issued.
- //
- if (LS120GetMediaStatus (IdeDev) == EFI_WRITE_PROTECTED) {
-
- *WriteProtected = TRUE;
- } else {
-
- *WriteProtected = FALSE;
- }
-
- //
- // After Get Media Status Command completes,
- // Set Features/Disable Media Command should be sent.
- //
- Status = LS120EnableMediaStatus (IdeDev, FALSE);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Used before read/write blocks from/to ATAPI device media. Since ATAPI device
- media is removable, it is necessary to detect whether media is present and
- get current present media's information, and if media has been changed, Block
- I/O Protocol need to be reinstalled.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
- @param MediaChange return value that indicates if the media of the device has been
- changed.
-
- @retval EFI_SUCCESS media found successfully.
- @retval EFI_DEVICE_ERROR any error encounters during media detection.
- @retval EFI_NO_MEDIA media not found.
-
- @note
- parameter IdeDev may be updated in this function.
-
-**/
-EFI_STATUS
-AtapiDetectMedia (
- IN IDE_BLK_IO_DEV *IdeDev,
- OUT BOOLEAN *MediaChange
- )
-{
- EFI_STATUS Status;
- EFI_STATUS CleanStateStatus;
- EFI_BLOCK_IO_MEDIA OldMediaInfo;
- UINTN RetryTimes;
- UINTN RetryNotReady;
- SENSE_RESULT SResult;
- BOOLEAN WriteProtected;
-
- CopyMem (&OldMediaInfo, IdeDev->BlkIo.Media, sizeof (EFI_BLOCK_IO_MEDIA));
- *MediaChange = FALSE;
- //
- // Retry for SenseDeviceNotReadyNeedRetry.
- // Each retry takes 1s and we limit the upper boundary to
- // 120 times about 2 min.
- //
- RetryNotReady = 120;
-
- //
- // Do Test Unit Ready
- //
- DoTUR:
- //
- // Retry 5 times
- //
- RetryTimes = 5;
- while (RetryTimes != 0) {
-
- Status = AtapiTestUnitReady (IdeDev, &SResult);
-
- if (EFI_ERROR (Status)) {
- //
- // Test Unit Ready error without sense data.
- // For some devices, this means there's extra data
- // that has not been read, so we read these extra
- // data out before going on.
- //
- CleanStateStatus = AtapiReadPendingData (IdeDev);
- if (EFI_ERROR (CleanStateStatus)) {
- //
- // Busy wait failed, try again
- //
- RetryTimes--;
- }
- //
- // Try again without counting down RetryTimes
- //
- continue;
- } else {
- switch (SResult) {
- case SenseNoSenseKey:
- if (IdeDev->BlkIo.Media->MediaPresent) {
- goto Done;
- } else {
- //
- // Media present but the internal structure need refreshed.
- // Try Read Capacity
- //
- goto DoRC;
- }
- break;
-
- case SenseDeviceNotReadyNeedRetry:
- if (--RetryNotReady == 0) {
- return EFI_DEVICE_ERROR;
- }
- gBS->Stall (1000 * STALL_1_MILLI_SECOND);
- continue;
- break;
-
- case SenseNoMedia:
- IdeDev->BlkIo.Media->MediaPresent = FALSE;
- IdeDev->BlkIo.Media->LastBlock = 0;
- goto Done;
- break;
-
- case SenseDeviceNotReadyNoRetry:
- case SenseMediaError:
- return EFI_DEVICE_ERROR;
-
- case SenseMediaChange:
- IdeDev->BlkIo.Media->MediaId++;
- goto DoRC;
- break;
-
- default:
- RetryTimes--;
- break;
- }
- }
- }
-
- return EFI_DEVICE_ERROR;
-
- //
- // Do Read Capacity
- //
- DoRC:
- RetryTimes = 5;
-
- while (RetryTimes != 0) {
-
- Status = AtapiReadCapacity (IdeDev, &SResult);
-
- if (EFI_ERROR (Status)) {
- RetryTimes--;
- continue;
- } else {
- switch (SResult) {
- case SenseNoSenseKey:
- goto Done;
- break;
-
- case SenseDeviceNotReadyNeedRetry:
- //
- // We use Test Unit Ready to retry which
- // is faster.
- //
- goto DoTUR;
- break;
-
- case SenseNoMedia:
- IdeDev->BlkIo.Media->MediaPresent = FALSE;
- IdeDev->BlkIo.Media->LastBlock = 0;
- goto Done;
- break;
-
- case SenseDeviceNotReadyNoRetry:
- case SenseMediaError:
- return EFI_DEVICE_ERROR;
-
- case SenseMediaChange:
- IdeDev->BlkIo.Media->MediaId++;
- continue;
- break;
-
- default:
- RetryTimes--;
- break;
- }
- }
- }
-
- return EFI_DEVICE_ERROR;
-
- Done:
- //
- // the following code is to check the write-protected for LS120 media
- //
- if ((IdeDev->BlkIo.Media->MediaPresent) && (IdeDev->Type == IdeMagnetic)) {
-
- Status = IsLS120orZipWriteProtected (IdeDev, &WriteProtected);
- if (!EFI_ERROR (Status)) {
-
- if (WriteProtected) {
-
- IdeDev->BlkIo.Media->ReadOnly = TRUE;
- } else {
-
- IdeDev->BlkIo.Media->ReadOnly = FALSE;
- }
-
- }
- }
-
- if (IdeDev->BlkIo.Media->MediaId != OldMediaInfo.MediaId) {
- //
- // Media change information got from the device
- //
- *MediaChange = TRUE;
- }
-
- if (IdeDev->BlkIo.Media->ReadOnly != OldMediaInfo.ReadOnly) {
- *MediaChange = TRUE;
- IdeDev->BlkIo.Media->MediaId += 1;
- }
-
- if (IdeDev->BlkIo.Media->BlockSize != OldMediaInfo.BlockSize) {
- *MediaChange = TRUE;
- IdeDev->BlkIo.Media->MediaId += 1;
- }
-
- if (IdeDev->BlkIo.Media->LastBlock != OldMediaInfo.LastBlock) {
- *MediaChange = TRUE;
- IdeDev->BlkIo.Media->MediaId += 1;
- }
-
- if (IdeDev->BlkIo.Media->MediaPresent != OldMediaInfo.MediaPresent) {
- if (IdeDev->BlkIo.Media->MediaPresent) {
- //
- // when change from no media to media present, reset the MediaId to 1.
- //
- IdeDev->BlkIo.Media->MediaId = 1;
- } else {
- //
- // when no media, reset the MediaId to zero.
- //
- IdeDev->BlkIo.Media->MediaId = 0;
- }
-
- *MediaChange = TRUE;
- }
-
- //
- // if any change on current existing media,
- // the Block I/O protocol need to be reinstalled.
- //
- if (*MediaChange) {
- gBS->ReinstallProtocolInterface (
- IdeDev->Handle,
- &gEfiBlockIoProtocolGuid,
- &IdeDev->BlkIo,
- &IdeDev->BlkIo
- );
- }
-
- if (IdeDev->BlkIo.Media->MediaPresent) {
- return EFI_SUCCESS;
- } else {
- return EFI_NO_MEDIA;
- }
-}
-
-/**
- This function is called by the AtapiBlkIoReadBlocks() to perform
- read from media in block unit.
-
- The main command used to access media here is READ(10) Command.
- READ(10) Command requests that the ATAPI device media transfer
- specified data to the host. Data is transferred in block(sector)
- unit. The maximum number of blocks that can be transferred once is
- 65536. This is the main difference between READ(10) and READ(12)
- Command. The maximum number of blocks in READ(12) is 2 power 32.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
- @param Buffer A pointer to the destination buffer for the data.
- @param Lba The starting logical block address to read from on the
- device media.
- @param NumberOfBlocks The number of transfer data blocks.
-
- @return status is fully dependent on the return status of AtapiPacketCommandIn() function.
-
-**/
-EFI_STATUS
-AtapiReadSectors (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN VOID *Buffer,
- IN EFI_LBA Lba,
- IN UINTN NumberOfBlocks
- )
-{
-
- ATAPI_PACKET_COMMAND Packet;
- ATAPI_READ10_CMD *Read10Packet;
- EFI_STATUS Status;
- UINTN BlocksRemaining;
- UINT32 Lba32;
- UINT32 BlockSize;
- UINT32 ByteCount;
- UINT16 SectorCount;
- VOID *PtrBuffer;
- UINT16 MaxBlock;
- UINTN TimeOut;
-
- //
- // fill command packet for Read(10) command
- //
- ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));
- Read10Packet = &Packet.Read10;
- Lba32 = (UINT32) Lba;
- PtrBuffer = Buffer;
-
- BlockSize = IdeDev->BlkIo.Media->BlockSize;
-
- //
- // limit the data bytes that can be transferred by one Read(10) Command
- //
- MaxBlock = 65535;
-
- BlocksRemaining = NumberOfBlocks;
-
- Status = EFI_SUCCESS;
- while (BlocksRemaining > 0) {
-
- if (BlocksRemaining <= MaxBlock) {
-
- SectorCount = (UINT16) BlocksRemaining;
- } else {
-
- SectorCount = MaxBlock;
- }
-
- //
- // fill the Packet data structure
- //
-
- Read10Packet->opcode = ATA_CMD_READ_10;
-
- //
- // Lba0 ~ Lba3 specify the start logical block address of the data transfer.
- // Lba0 is MSB, Lba3 is LSB
- //
- Read10Packet->Lba3 = (UINT8) (Lba32 & 0xff);
- Read10Packet->Lba2 = (UINT8) (Lba32 >> 8);
- Read10Packet->Lba1 = (UINT8) (Lba32 >> 16);
- Read10Packet->Lba0 = (UINT8) (Lba32 >> 24);
-
- //
- // TranLen0 ~ TranLen1 specify the transfer length in block unit.
- // TranLen0 is MSB, TranLen is LSB
- //
- Read10Packet->TranLen1 = (UINT8) (SectorCount & 0xff);
- Read10Packet->TranLen0 = (UINT8) (SectorCount >> 8);
-
- ByteCount = SectorCount * BlockSize;
-
- if (IdeDev->Type == IdeCdRom) {
- TimeOut = CDROMLONGTIMEOUT;
- } else {
- TimeOut = ATAPILONGTIMEOUT;
- }
-
- Status = AtapiPacketCommandIn (
- IdeDev,
- &Packet,
- (UINT16 *) PtrBuffer,
- ByteCount,
- TimeOut
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Lba32 += SectorCount;
- PtrBuffer = (UINT8 *) PtrBuffer + SectorCount * BlockSize;
- BlocksRemaining -= SectorCount;
- }
-
- return Status;
-}
-
-/**
- This function is called by the AtapiBlkIoWriteBlocks() to perform
- write onto media in block unit.
- The main command used to access media here is Write(10) Command.
- Write(10) Command requests that the ATAPI device media transfer
- specified data to the host. Data is transferred in block (sector)
- unit. The maximum number of blocks that can be transferred once is
- 65536.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
- @param Buffer A pointer to the source buffer for the data.
- @param Lba The starting logical block address to write onto
- the device media.
- @param NumberOfBlocks The number of transfer data blocks.
-
- @return status is fully dependent on the return status of AtapiPacketCommandOut() function.
-
-**/
-EFI_STATUS
-AtapiWriteSectors (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN VOID *Buffer,
- IN EFI_LBA Lba,
- IN UINTN NumberOfBlocks
- )
-{
-
- ATAPI_PACKET_COMMAND Packet;
- ATAPI_READ10_CMD *Read10Packet;
-
- EFI_STATUS Status;
- UINTN BlocksRemaining;
- UINT32 Lba32;
- UINT32 BlockSize;
- UINT32 ByteCount;
- UINT16 SectorCount;
- VOID *PtrBuffer;
- UINT16 MaxBlock;
-
- //
- // fill command packet for Write(10) command
- // Write(10) command packet has the same data structure as
- // Read(10) command packet,
- // so here use the Read10Packet data structure
- // for the Write(10) command packet.
- //
- ZeroMem (&Packet, sizeof (ATAPI_PACKET_COMMAND));
- Read10Packet = &Packet.Read10;
-
- Lba32 = (UINT32) Lba;
- PtrBuffer = Buffer;
-
- BlockSize = IdeDev->BlkIo.Media->BlockSize;
-
- //
- // limit the data bytes that can be transferred by one Read(10) Command
- //
- MaxBlock = (UINT16) (65536 / BlockSize);
-
- BlocksRemaining = NumberOfBlocks;
-
- Status = EFI_SUCCESS;
- while (BlocksRemaining > 0) {
-
- if (BlocksRemaining >= MaxBlock) {
- SectorCount = MaxBlock;
- } else {
- SectorCount = (UINT16) BlocksRemaining;
- }
-
- //
- // Command code is WRITE_10.
- //
- Read10Packet->opcode = ATA_CMD_WRITE_10;
-
- //
- // Lba0 ~ Lba3 specify the start logical block address of the data transfer.
- // Lba0 is MSB, Lba3 is LSB
- //
- Read10Packet->Lba3 = (UINT8) (Lba32 & 0xff);
- Read10Packet->Lba2 = (UINT8) (Lba32 >> 8);
- Read10Packet->Lba1 = (UINT8) (Lba32 >> 16);
- Read10Packet->Lba0 = (UINT8) (Lba32 >> 24);
-
- //
- // TranLen0 ~ TranLen1 specify the transfer length in block unit.
- // TranLen0 is MSB, TranLen is LSB
- //
- Read10Packet->TranLen1 = (UINT8) (SectorCount & 0xff);
- Read10Packet->TranLen0 = (UINT8) (SectorCount >> 8);
-
- ByteCount = SectorCount * BlockSize;
-
- Status = AtapiPacketCommandOut (
- IdeDev,
- &Packet,
- (UINT16 *) PtrBuffer,
- ByteCount,
- ATAPILONGTIMEOUT
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Lba32 += SectorCount;
- PtrBuffer = ((UINT8 *) PtrBuffer + SectorCount * BlockSize);
- BlocksRemaining -= SectorCount;
- }
-
- return Status;
-}
-/**
- This function is used to implement the Soft Reset on the specified
- ATAPI device. Different from the AtaSoftReset(), here reset is a ATA
- Soft Reset Command special for ATAPI device, and it only take effects
- on the specified ATAPI device, not on the whole IDE bus.
- Since the ATAPI soft reset is needed when device is in exceptional
- condition (such as BSY bit is always set ), I think the Soft Reset
- command should be sent without waiting for the BSY clear and DRDY
- set.
- This function is called by IdeBlkIoReset(),
- a interface function of Block I/O protocol.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
-
- @retval EFI_SUCCESS Soft reset completes successfully.
- @retval EFI_DEVICE_ERROR Any step during the reset process is failed.
-
-**/
-EFI_STATUS
-AtapiSoftReset (
- IN IDE_BLK_IO_DEV *IdeDev
- )
-{
- UINT8 Command;
- UINT8 DeviceSelect;
- EFI_STATUS Status;
-
- //
- // for ATAPI device, no need to wait DRDY ready after device selecting.
- // (bit7 and bit5 are both set to 1 for backward compatibility)
- //
- DeviceSelect = (UINT8) (((BIT7 | BIT5) | (IdeDev->Device << 4)));
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Head, DeviceSelect);
-
- Command = ATA_CMD_SOFT_RESET;
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, Command);
-
- //
- // BSY cleared is the only status return to the host by the device
- // when reset is completed.
- // slave device needs at most 31s to clear BSY
- //
- Status = WaitForBSYClear (IdeDev, 31000);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // stall 5 seconds to make the device status stable
- //
- gBS->Stall (5000000);
-
- return EFI_SUCCESS;
-}
-
-/**
- This function is the ATAPI implementation for ReadBlocks in the
- Block I/O Protocol interface.
-
- @param IdeBlkIoDevice Indicates the calling context.
- @param MediaId The media id that the read request is for.
- @param Lba The starting logical block address to read from on the device.
- @param BufferSize The size of the Buffer in bytes. This must be a multiple
- of the intrinsic block size of the device.
- @param Buffer A pointer to the destination buffer for the data. The caller
- is responsible for either having implicit or explicit
- ownership of the memory that data is read into.
-
- @retval EFI_SUCCESS Read Blocks successfully.
- @retval EFI_DEVICE_ERROR Read Blocks failed.
- @retval EFI_NO_MEDIA There is no media in the device.
- @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
- @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
- intrinsic block size of the device.
- @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
- or the data buffer is not valid.
-**/
-EFI_STATUS
-AtapiBlkIoReadBlocks (
- IN IDE_BLK_IO_DEV *IdeBlkIoDevice,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- )
-{
- EFI_BLOCK_IO_MEDIA *Media;
- UINTN BlockSize;
- UINTN NumberOfBlocks;
- EFI_STATUS Status;
-
- BOOLEAN MediaChange;
-
- if (Buffer == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (BufferSize == 0) {
- return EFI_SUCCESS;
- }
-
- //
- // ATAPI device media is removable, so it is a must
- // to detect media first before read operation
- //
- MediaChange = FALSE;
- Status = AtapiDetectMedia (IdeBlkIoDevice, &MediaChange);
- if (EFI_ERROR (Status)) {
-
- if (IdeBlkIoDevice->Cache != NULL) {
- gBS->FreePool (IdeBlkIoDevice->Cache);
- IdeBlkIoDevice->Cache = NULL;
- }
-
- return Status;
- }
- //
- // Get the intrinsic block size
- //
- Media = IdeBlkIoDevice->BlkIo.Media;
- BlockSize = Media->BlockSize;
-
- NumberOfBlocks = BufferSize / BlockSize;
-
- if (!(Media->MediaPresent)) {
-
- if (IdeBlkIoDevice->Cache != NULL) {
- gBS->FreePool (IdeBlkIoDevice->Cache);
- IdeBlkIoDevice->Cache = NULL;
- }
- return EFI_NO_MEDIA;
-
- }
-
- if ((MediaId != Media->MediaId) || MediaChange) {
-
- if (IdeBlkIoDevice->Cache != NULL) {
- gBS->FreePool (IdeBlkIoDevice->Cache);
- IdeBlkIoDevice->Cache = NULL;
- }
- return EFI_MEDIA_CHANGED;
- }
-
- if (BufferSize % BlockSize != 0) {
- return EFI_BAD_BUFFER_SIZE;
- }
-
- if (Lba > Media->LastBlock) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((Lba + NumberOfBlocks - 1) > Media->LastBlock) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((Media->IoAlign > 1) && (((UINTN) Buffer & (Media->IoAlign - 1)) != 0)) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // if all the parameters are valid, then perform read sectors command
- // to transfer data from device to host.
- //
- Status = AtapiReadSectors (IdeBlkIoDevice, Buffer, Lba, NumberOfBlocks);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // Read blocks succeeded
- //
-
- //
- // save the first block to the cache for performance
- //
- if (Lba == 0 && (IdeBlkIoDevice->Cache == NULL)) {
- IdeBlkIoDevice->Cache = AllocatePool (BlockSize);
- if (IdeBlkIoDevice->Cache!= NULL) {
- CopyMem ((UINT8 *) IdeBlkIoDevice->Cache, (UINT8 *) Buffer, BlockSize);
- }
- }
-
- return EFI_SUCCESS;
-
-}
-/**
- This function is the ATAPI implementation for WriteBlocks in the
- Block I/O Protocol interface.
-
- @param IdeBlkIoDevice Indicates the calling context.
- @param MediaId The media id that the write request is for.
- @param Lba The starting logical block address to write onto the device.
- @param BufferSize The size of the Buffer in bytes. This must be a multiple
- of the intrinsic block size of the device.
- @param Buffer A pointer to the source buffer for the data. The caller
- is responsible for either having implicit or explicit ownership
- of the memory that data is written from.
-
- @retval EFI_SUCCESS Write Blocks successfully.
- @retval EFI_DEVICE_ERROR Write Blocks failed.
- @retval EFI_NO_MEDIA There is no media in the device.
- @retval EFI_MEDIA_CHANGE The MediaId is not for the current media.
- @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
- intrinsic block size of the device.
- @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
- or the data buffer is not valid.
-
- @retval EFI_WRITE_PROTECTED The write protected is enabled or the media does not support write
-**/
-EFI_STATUS
-AtapiBlkIoWriteBlocks (
- IN IDE_BLK_IO_DEV *IdeBlkIoDevice,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- )
-{
-
- EFI_BLOCK_IO_MEDIA *Media;
- UINTN BlockSize;
- UINTN NumberOfBlocks;
- EFI_STATUS Status;
- BOOLEAN MediaChange;
-
- if (Lba == 0 && IdeBlkIoDevice->Cache != NULL) {
- gBS->FreePool (IdeBlkIoDevice->Cache);
- IdeBlkIoDevice->Cache = NULL;
- }
-
- if (Buffer == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (BufferSize == 0) {
- return EFI_SUCCESS;
- }
-
- //
- // ATAPI device media is removable,
- // so it is a must to detect media first before write operation
- //
- MediaChange = FALSE;
- Status = AtapiDetectMedia (IdeBlkIoDevice, &MediaChange);
- if (EFI_ERROR (Status)) {
-
- if (Lba == 0 && IdeBlkIoDevice->Cache != NULL) {
- gBS->FreePool (IdeBlkIoDevice->Cache);
- IdeBlkIoDevice->Cache = NULL;
- }
- return Status;
- }
-
- //
- // Get the intrinsic block size
- //
- Media = IdeBlkIoDevice->BlkIo.Media;
- BlockSize = Media->BlockSize;
- NumberOfBlocks = BufferSize / BlockSize;
-
- if (!(Media->MediaPresent)) {
-
- if (Lba == 0 && IdeBlkIoDevice->Cache != NULL) {
- gBS->FreePool (IdeBlkIoDevice->Cache);
- IdeBlkIoDevice->Cache = NULL;
- }
- return EFI_NO_MEDIA;
- }
-
- if ((MediaId != Media->MediaId) || MediaChange) {
-
- if (Lba == 0 && IdeBlkIoDevice->Cache != NULL) {
- gBS->FreePool (IdeBlkIoDevice->Cache);
- IdeBlkIoDevice->Cache = NULL;
- }
- return EFI_MEDIA_CHANGED;
- }
-
- if (Media->ReadOnly) {
- return EFI_WRITE_PROTECTED;
- }
-
- if (BufferSize % BlockSize != 0) {
- return EFI_BAD_BUFFER_SIZE;
- }
-
- if (Lba > Media->LastBlock) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((Lba + NumberOfBlocks - 1) > Media->LastBlock) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((Media->IoAlign > 1) && (((UINTN) Buffer & (Media->IoAlign - 1)) != 0)) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // if all the parameters are valid,
- // then perform write sectors command to transfer data from host to device.
- //
- Status = AtapiWriteSectors (IdeBlkIoDevice, Buffer, Lba, NumberOfBlocks);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-
-}
-
-
-
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/ComponentName.c b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/ComponentName.c deleted file mode 100644 index 5e376d72d7..0000000000 --- a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/ComponentName.c +++ /dev/null @@ -1,278 +0,0 @@ -/** @file
- UEFI Component Name(2) protocol implementation for ConPlatform driver.
-
- Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
- 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 "IdeBus.h"
-
-//
-// EFI Component Name Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIDEBusComponentName = {
- IDEBusComponentNameGetDriverName,
- IDEBusComponentNameGetControllerName,
- "eng"
-};
-
-//
-// EFI Component Name 2 Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIDEBusComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IDEBusComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IDEBusComponentNameGetControllerName,
- "en"
-};
-
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIDEBusDriverNameTable[] = {
- { "eng;en", (CHAR16 *) L"PCI IDE/ATAPI Bus Driver" },
- { NULL , NULL }
-};
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIDEBusControllerNameTable[] = {
- { "eng;en", (CHAR16 *) L"PCI IDE/ATAPI Controller" },
- { NULL , NULL }
-};
-
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
-
- @param DriverName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-IDEBusComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- )
-{
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mIDEBusDriverNameTable,
- DriverName,
- (BOOLEAN)(This == &gIDEBusComponentName)
- );
-}
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param ControllerHandle[in] The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
-
- @param ChildHandle[in] The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
-
- @param ControllerName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
-
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
-
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-IDEBusComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- )
-{
- EFI_STATUS Status;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
- IDE_BLK_IO_DEV *IdeBlkIoDevice;
-
- //
- // Make sure this driver is currently managing ControllHandle
- //
- Status = EfiTestManagedDevice (
- ControllerHandle,
- gIDEBusDriverBinding.DriverBindingHandle,
- &gEfiIdeControllerInitProtocolGuid
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if (ChildHandle == NULL) {
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mIDEBusControllerNameTable,
- ControllerName,
- (BOOLEAN)(This == &gIDEBusComponentName)
- );
- }
-
- Status = EfiTestChildHandle (
- ControllerHandle,
- ChildHandle,
- &gEfiPciIoProtocolGuid
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Get the child context
- //
- Status = gBS->OpenProtocol (
- ChildHandle,
- &gEfiBlockIoProtocolGuid,
- (VOID **) &BlockIo,
- gIDEBusDriverBinding.DriverBindingHandle,
- ChildHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return EFI_UNSUPPORTED;
- }
-
- IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_THIS (BlockIo);
-
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- IdeBlkIoDevice->ControllerNameTable,
- ControllerName,
- (BOOLEAN)(This == &gIDEBusComponentName)
- );
-}
-
-/**
- Add the component name for the IDE/ATAPI device
-
- @param IdeBlkIoDevicePtr A pointer to the IDE_BLK_IO_DEV instance.
-
-**/
-VOID
-AddName (
- IN IDE_BLK_IO_DEV *IdeBlkIoDevicePtr
- )
-{
- UINTN StringIndex;
- CHAR16 ModelName[41];
-
- //
- // Add Component Name for the IDE/ATAPI device that was discovered.
- //
- IdeBlkIoDevicePtr->ControllerNameTable = NULL;
- for (StringIndex = 0; StringIndex < 41; StringIndex++) {
- ModelName[StringIndex] = IdeBlkIoDevicePtr->ModelName[StringIndex];
- }
-
- AddUnicodeString2 (
- "eng",
- gIDEBusComponentName.SupportedLanguages,
- &IdeBlkIoDevicePtr->ControllerNameTable,
- ModelName,
- TRUE
- );
- AddUnicodeString2 (
- "en",
- gIDEBusComponentName2.SupportedLanguages,
- &IdeBlkIoDevicePtr->ControllerNameTable,
- ModelName,
- FALSE
- );
-
-}
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/ComponentName.h b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/ComponentName.h deleted file mode 100644 index 9a911a5ec9..0000000000 --- a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/ComponentName.h +++ /dev/null @@ -1,166 +0,0 @@ -/** @file
-
- UEFI Component Name(2) protocol implementation header file for IDE Bus driver.
-
- Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
- 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.
-
-**/
-
-#ifndef _IDE_BUS_COMPONENT_NAME_H_
-#define _IDE_BUS_COMPONENT_NAME_H_
-
-#define ADD_IDE_ATAPI_NAME(x) AddName ((x));
-
-extern EFI_COMPONENT_NAME_PROTOCOL gIDEBusComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gIDEBusComponentName2;
-
-
-//
-// EFI Component Name Functions
-//
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
-
- @param DriverName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-IDEBusComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- );
-
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param ControllerHandle[in] The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
-
- @param ChildHandle[in] The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
-
- @param ControllerName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
-
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
-
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-IDEBusComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- );
-
-
-/**
- Add the component name for the IDE/ATAPI device
-
- @param IdeBlkIoDevicePtr A pointer to the IDE_BLK_IO_DEV instance.
-
-**/
-VOID
-AddName (
- IN IDE_BLK_IO_DEV *IdeBlkIoDevicePtr
- );
-
-#endif
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/DriverConfiguration.c b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/DriverConfiguration.c deleted file mode 100644 index 999e20e016..0000000000 --- a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/DriverConfiguration.c +++ /dev/null @@ -1,292 +0,0 @@ -/** @file
- Implementation of UEFI Driver Configuration Protocol for IDE bus driver which
- provides ability to set IDE bus controller specific options.
-
- Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
- 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 "IdeBus.h"
-
-CHAR16 *OptionString[4] = {
- L"Enable Primary Master (Y/N)? -->",
- L"Enable Primary Slave (Y/N)? -->",
- L"Enable Secondary Master (Y/N)? -->",
- L"Enable Secondary Slave (Y/N)? -->"
-};
-
-//
-// EFI Driver Configuration Protocol
-//
-EFI_DRIVER_CONFIGURATION_PROTOCOL gIDEBusDriverConfiguration = {
- IDEBusDriverConfigurationSetOptions,
- IDEBusDriverConfigurationOptionsValid,
- IDEBusDriverConfigurationForceDefaults,
- "eng"
-};
-
-/**
- Interprete keyboard input.
-
- @retval EFI_ABORTED Get an 'ESC' key inputed.
- @retval EFI_SUCCESS Get an 'Y' or 'y' inputed.
- @retval EFI_NOT_FOUND Get an 'N' or 'n' inputed..
-
-**/
-EFI_STATUS
-GetResponse (
- VOID
- )
-{
- EFI_STATUS Status;
- EFI_INPUT_KEY Key;
-
- while (TRUE) {
- Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
- if (!EFI_ERROR (Status)) {
- if (Key.ScanCode == SCAN_ESC) {
- return EFI_ABORTED;
- }
-
- switch (Key.UnicodeChar) {
-
- //
- // fall through
- //
- case L'y':
- case L'Y':
- gST->ConOut->OutputString (gST->ConOut, L"Y\n");
- return EFI_SUCCESS;
-
- //
- // fall through
- //
- case L'n':
- case L'N':
- gST->ConOut->OutputString (gST->ConOut, L"N\n");
- return EFI_NOT_FOUND;
- }
-
- }
- }
-}
-
-/**
- Allows the user to set controller specific options for a controller that a
- driver is currently managing.
-
- @param This A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.
- @param ControllerHandle The handle of the controller to set options on.
- @param ChildHandle The handle of the child controller to set options on.
- This is an optional parameter that may be NULL.
- It will be NULL for device drivers, and for a bus drivers
- that wish to set options for the bus controller.
- It will not be NULL for a bus driver that wishes to set
- options for one of its child controllers.
- @param Language A pointer to a three character ISO 639-2 language identifier.
- This is the language of the user interface that should be presented
- to the user, and it must match one of the languages specified in
- SupportedLanguages. The number of languages supported by a driver is up to
- the driver writer.
- @param ActionRequired A pointer to the action that the calling agent is required
- to perform when this function returns.
-
-
- @retval EFI_SUCCESS The driver specified by This successfully set the configuration
- options for the controller specified by ControllerHandle..
- @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
- @retval EFI_INVALID_PARAMETER ActionRequired is NULL.
- @retval EFI_UNSUPPORTED The driver specified by This does not support setting configuration options for
- the controller specified by ControllerHandle and ChildHandle.
- @retval EFI_UNSUPPORTED The driver specified by This does not support the language specified by Language.
- @retval EFI_DEVICE_ERROR A device error occurred while attempt to set the configuration options for the
- controller specified by ControllerHandle and ChildHandle.
- @retval EFI_OUT_RESOURCES There are not enough resources available to set the configuration options for the
- controller specified by ControllerHandle and ChildHandle
-**/
-EFI_STATUS
-EFIAPI
-IDEBusDriverConfigurationSetOptions (
- IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired
- )
-{
- EFI_STATUS Status;
- UINT8 Value;
- UINT8 NewValue;
- UINTN DataSize;
- UINTN Index;
-
- if (ChildHandle != NULL) {
- return EFI_UNSUPPORTED;
- }
-
- *ActionRequired = EfiDriverConfigurationActionNone;
-
- DataSize = sizeof (Value);
- Status = gRT->GetVariable (
- L"Configuration",
- &gEfiCallerIdGuid,
- NULL,
- &DataSize,
- &Value
- );
-
- gST->ConOut->OutputString (gST->ConOut, L"IDE Bus Driver Configuration\n");
- gST->ConOut->OutputString (gST->ConOut, L"===============================\n");
-
- NewValue = 0;
- for (Index = 0; Index < 4; Index++) {
- gST->ConOut->OutputString (gST->ConOut, OptionString[Index]);
-
- Status = GetResponse ();
- if (Status == EFI_ABORTED) {
- return EFI_SUCCESS;
- }
-
- if (!EFI_ERROR (Status)) {
- NewValue = (UINT8) (NewValue | (1 << Index));
- }
- }
-
- if (EFI_ERROR (Status) || (NewValue != Value)) {
- gRT->SetVariable (
- L"Configuration",
- &gEfiCallerIdGuid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
- sizeof (NewValue),
- &NewValue
- );
-
- *ActionRequired = EfiDriverConfigurationActionRestartController;
- } else {
- *ActionRequired = EfiDriverConfigurationActionNone;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Tests to see if a controller's current configuration options are valid.
-
- @param This A pointer to the EFI_DRIVER_CONFIGURATION_PROTOCOL instance.
- @param ControllerHandle The handle of the controller to test if it's current configuration options
- are valid.
- @param ChildHandle The handle of the child controller to test if it's current configuration
- options are valid. This is an optional parameter that may be NULL. It will
- be NULL for device drivers. It will also be NULL for a bus drivers that
- wish to test the configuration options for the bus controller. It will
- not be NULL for a bus driver that wishes to test configuration options for
- one of its child controllers.
- @retval EFI_SUCCESS The controller specified by ControllerHandle and ChildHandle that is being
- managed by the driver specified by This has a valid set of configuration
- options.
- @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
- @retval EFI_UNSUPPORTED The driver specified by This is not currently managing the controller
- specified by ControllerHandle and ChildHandle.
- @retval EFI_DEVICE_ERROR The controller specified by ControllerHandle and ChildHandle that is being
- managed by the driver specified by This has an invalid set of configuration
- options.
-**/
-EFI_STATUS
-EFIAPI
-IDEBusDriverConfigurationOptionsValid (
- IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL
- )
-{
- EFI_STATUS Status;
- UINT8 Value;
- UINTN DataSize;
-
- if (ChildHandle != NULL) {
- return EFI_UNSUPPORTED;
- }
-
- DataSize = sizeof (Value);
- Status = gRT->GetVariable (
- L"Configuration",
- &gEfiCallerIdGuid,
- NULL,
- &DataSize,
- &Value
- );
- if (EFI_ERROR (Status) || Value > 0x0f) {
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-/**
- Forces a driver to set the default configuration options for a controller.
-
- @param This A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.
- @param ControllerHandle The handle of the controller to force default configuration options on.
- @param ChildHandle The handle of the child controller to force default configuration
- options on This is an optional parameter that may be NULL. It
- will be NULL for device drivers. It will also be NULL for a bus
- drivers that wish to force default configuration options for the bus
- controller. It will not be NULL for a bus driver that wishes to force
- default configuration options for one of its child controllers.
- @param DefaultType The type of default configuration options to force on the controller
- specified by ControllerHandle and ChildHandle.
- @param ActionRequired A pointer to the action that the calling agent is required to perform
- when this function returns.
-
- @retval EFI_SUCCESS The driver specified by This successfully forced the
- default configuration options on the controller specified by
- ControllerHandle and ChildHandle.
- @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
- @retval EFI_INVALID_PARAMETER ActionRequired is NULL.
- @retval EFI_UNSUPPORTED The driver specified by This does not support forcing the default
- configuration options on the controller specified by ControllerHandle
- and ChildHandle.
- @retval EFI_UNSUPPORTED The driver specified by This does not support the configuration type
- specified by DefaultType.
- @retval EFI_DEVICE_ERROR A device error occurred while attempt to force the default configuration
- options on the controller specified by ControllerHandle and ChildHandle.
- @retval EFI_OUT_RESOURCES There are not enough resources available to force the default configuration
- options on the controller specified by ControllerHandle and ChildHandle.
-**/
-EFI_STATUS
-EFIAPI
-IDEBusDriverConfigurationForceDefaults (
- IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN UINT32 DefaultType,
- OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired
- )
-{
- UINT8 Value;
-
- if (ChildHandle != NULL) {
- return EFI_UNSUPPORTED;
- }
-
- Value = 0x0f;
- gRT->SetVariable (
- L"Configuration",
- &gEfiCallerIdGuid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
- sizeof (Value),
- &Value
- );
- *ActionRequired = EfiDriverConfigurationActionRestartController;
- return EFI_SUCCESS;
-}
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/DriverDiagnostics.c b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/DriverDiagnostics.c deleted file mode 100644 index 73435dd7ac..0000000000 --- a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/DriverDiagnostics.c +++ /dev/null @@ -1,245 +0,0 @@ -/** @file
- Implementation of UEFI driver Dialnostics protocol which to perform diagnostic on the IDE
- Bus controller.
-
- Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
- 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 "IdeBus.h"
-
-#define IDE_BUS_DIAGNOSTIC_ERROR L"PCI IDE/ATAPI Driver Diagnostics Failed"
-
-//
-// EFI Driver Diagnostics Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_DRIVER_DIAGNOSTICS_PROTOCOL gIDEBusDriverDiagnostics = {
- IDEBusDriverDiagnosticsRunDiagnostics,
- "eng"
-};
-
-//
-// EFI Driver Diagnostics 2 Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gIDEBusDriverDiagnostics2 = {
- (EFI_DRIVER_DIAGNOSTICS2_RUN_DIAGNOSTICS) IDEBusDriverDiagnosticsRunDiagnostics,
- "en"
-};
-
-/**
- Runs diagnostics on a controller.
-
- @param This A pointer to the EFI_DRIVER_DIAGNOSTICS_PROTOCOLinstance.
- @param ControllerHandle The handle of the controller to run diagnostics on.
- @param ChildHandle The handle of the child controller to run diagnostics on
- This is an optional parameter that may be NULL. It will
- be NULL for device drivers. It will also be NULL for a
- bus drivers that wish to run diagnostics on the bus controller.
- It will not be NULL for a bus driver that wishes to run
- diagnostics on one of its child controllers.
- @param DiagnosticType Indicates type of diagnostics to perform on the controller
- specified by ControllerHandle and ChildHandle.
- @param Language A pointer to a three character ISO 639-2 language identifier.
- This is the language in which the optional error message should
- be returned in Buffer, and it must match one of the languages
- specified in SupportedLanguages. The number of languages supported by
- a driver is up to the driver writer.
- @param ErrorType A GUID that defines the format of the data returned in Buffer.
- @param BufferSize The size, in bytes, of the data returned in Buffer.
- @param Buffer A buffer that contains a Null-terminated Unicode string
- plus some additional data whose format is defined by ErrorType.
- Buffer is allocated by this function with AllocatePool(), and
- it is the caller's responsibility to free it with a call to FreePool().
-
- @retval EFI_SUCCESS The controller specified by ControllerHandle and ChildHandle passed
- the diagnostic.
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
- @retval EFI_INVALID_PARAMETER Language is NULL.
- @retval EFI_INVALID_PARAMETER ErrorType is NULL.
- @retval EFI_INVALID_PARAMETER BufferType is NULL.
- @retval EFI_INVALID_PARAMETER Buffer is NULL.
- @retval EFI_UNSUPPORTED The driver specified by This does not support running
- diagnostics for the controller specified by ControllerHandle
- and ChildHandle.
- @retval EFI_UNSUPPORTED The driver specified by This does not support the
- type of diagnostic specified by DiagnosticType.
- @retval EFI_UNSUPPORTED The driver specified by This does not support the language
- specified by Language.
- @retval EFI_OUT_OF_RESOURCES There are not enough resources available to complete the
- diagnostics.
- @retval EFI_OUT_OF_RESOURCES There are not enough resources available to return the
- status information in ErrorType, BufferSize,and Buffer.
- @retval EFI_DEVICE_ERROR The controller specified by ControllerHandle and ChildHandle
- did not pass the diagnostic.
-**/
-EFI_STATUS
-EFIAPI
-IDEBusDriverDiagnosticsRunDiagnostics (
- IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType,
- IN CHAR8 *Language,
- OUT EFI_GUID **ErrorType,
- OUT UINTN *BufferSize,
- OUT CHAR16 **Buffer
- )
-{
- EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL *PciIo;
- EFI_BLOCK_IO_PROTOCOL *BlkIo;
- IDE_BLK_IO_DEV *IdeBlkIoDevice;
- UINT32 VendorDeviceId;
- VOID *BlockBuffer;
- CHAR8 *SupportedLanguages;
- BOOLEAN Iso639Language;
- BOOLEAN Found;
- UINTN Index;
-
- if (Language == NULL ||
- ErrorType == NULL ||
- Buffer == NULL ||
- ControllerHandle == NULL ||
- BufferSize == NULL) {
-
- return EFI_INVALID_PARAMETER;
- }
-
- SupportedLanguages = This->SupportedLanguages;
- Iso639Language = (BOOLEAN)(This == &gIDEBusDriverDiagnostics);
- //
- // Make sure Language is in the set of Supported Languages
- //
- Found = FALSE;
- while (*SupportedLanguages != 0) {
- if (Iso639Language) {
- if (CompareMem (Language, SupportedLanguages, 3) == 0) {
- Found = TRUE;
- break;
- }
- SupportedLanguages += 3;
- } else {
- for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++);
- if ((AsciiStrnCmp(SupportedLanguages, Language, Index) == 0) && (Language[Index] == 0)) {
- Found = TRUE;
- break;
- }
- SupportedLanguages += Index;
- for (; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++);
- }
- }
- //
- // If Language is not a member of SupportedLanguages, then return EFI_UNSUPPORTED
- //
- if (!Found) {
- return EFI_UNSUPPORTED;
- }
-
- *ErrorType = NULL;
- *BufferSize = 0;
-
- if (ChildHandle == NULL) {
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiCallerIdGuid,
- NULL,
- gIDEBusDriverBinding.DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = gBS->OpenProtocol (
- ControllerHandle,
- &gEfiPciIoProtocolGuid,
- (VOID **) &PciIo,
- gIDEBusDriverBinding.DriverBindingHandle,
- ControllerHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
-
- //
- // Use services of PCI I/O Protocol to test the PCI IDE/ATAPI Controller
- // The following test simply reads the Device ID and Vendor ID.
- // It should never fail. A real test would perform more advanced
- // diagnostics.
- //
-
- Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, 0, 1, &VendorDeviceId);
- if (EFI_ERROR (Status) || VendorDeviceId == 0xffffffff) {
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
- }
-
- Status = gBS->OpenProtocol (
- ChildHandle,
- &gEfiBlockIoProtocolGuid,
- (VOID **) &BlkIo,
- gIDEBusDriverBinding.DriverBindingHandle,
- ChildHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_THIS (BlkIo);
-
- //
- // Use services available from IdeBlkIoDevice to test the IDE/ATAPI device
- //
- Status = gBS->AllocatePool (
- EfiBootServicesData,
- IdeBlkIoDevice->BlkMedia.BlockSize,
- (VOID **) &BlockBuffer
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = IdeBlkIoDevice->BlkIo.ReadBlocks (
- &IdeBlkIoDevice->BlkIo,
- IdeBlkIoDevice->BlkMedia.MediaId,
- 0,
- IdeBlkIoDevice->BlkMedia.BlockSize,
- BlockBuffer
- );
-
- if (EFI_ERROR (Status)) {
- *ErrorType = &gEfiCallerIdGuid;
- *BufferSize = sizeof (IDE_BUS_DIAGNOSTIC_ERROR);
-
- Status = gBS->AllocatePool (
- EfiBootServicesData,
- (UINTN) (*BufferSize),
- (VOID **) Buffer
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- CopyMem (*Buffer, IDE_BUS_DIAGNOSTIC_ERROR, *BufferSize);
-
- Status = EFI_DEVICE_ERROR;
- }
-
- gBS->FreePool (BlockBuffer);
-
- return Status;
-}
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.c b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.c deleted file mode 100644 index ffc818036a..0000000000 --- a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.c +++ /dev/null @@ -1,1330 +0,0 @@ -/** @file
- The file ontaining the helper functions implement of the Ide Bus driver
-
- Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
- 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 "IdeBus.h"
-
-BOOLEAN ChannelDeviceDetected = FALSE;
-BOOLEAN SlaveDeviceExist = FALSE;
-UINT8 SlaveDeviceType = INVALID_DEVICE_TYPE;
-BOOLEAN MasterDeviceExist = FALSE;
-UINT8 MasterDeviceType = INVALID_DEVICE_TYPE;
-
-/**
- read a one-byte data from a IDE port.
-
- @param PciIo The PCI IO protocol instance
- @param Port the IDE Port number
-
- @return the one-byte data read from IDE port
-**/
-UINT8
-IDEReadPortB (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT16 Port
- )
-{
- UINT8 Data;
-
- Data = 0;
- //
- // perform 1-byte data read from register
- //
- PciIo->Io.Read (
- PciIo,
- EfiPciIoWidthUint8,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- (UINT64) Port,
- 1,
- &Data
- );
- return Data;
-}
-/**
- Reads multiple words of data from the IDE data port.
- Call the IO abstraction once to do the complete read,
- not one word at a time
-
- @param PciIo Pointer to the EFI_PCI_IO instance
- @param Port IO port to read
- @param Count No. of UINT16's to read
- @param Buffer Pointer to the data buffer for read
-
-**/
-VOID
-IDEReadPortWMultiple (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT16 Port,
- IN UINTN Count,
- OUT VOID *Buffer
- )
-{
- UINT16 *AlignedBuffer;
- UINT16 *WorkingBuffer;
- UINTN Size;
-
- //
- // Prepare an 16-bit alligned working buffer. CpuIo will return failure and
- // not perform actual I/O operations if buffer pointer passed in is not at
- // natural boundary. The "Buffer" argument is passed in by user and may not
- // at 16-bit natural boundary.
- //
- Size = sizeof (UINT16) * Count;
-
- gBS->AllocatePool (
- EfiBootServicesData,
- Size + 1,
- (VOID**)&WorkingBuffer
- );
-
- AlignedBuffer = (UINT16 *) ((UINTN)(((UINTN) WorkingBuffer + 0x1) & (~0x1)));
-
- //
- // Perform UINT16 data read from FIFO
- //
- PciIo->Io.Read (
- PciIo,
- EfiPciIoWidthFifoUint16,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- (UINT64) Port,
- Count,
- (UINT16*)AlignedBuffer
- );
-
- //
- // Copy data to user buffer
- //
- CopyMem (Buffer, (UINT16*)AlignedBuffer, Size);
- gBS->FreePool (WorkingBuffer);
-}
-
-/**
- write a 1-byte data to a specific IDE port.
-
- @param PciIo PCI IO protocol instance
- @param Port The IDE port to be writen
- @param Data The data to write to the port
-**/
-VOID
-IDEWritePortB (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT16 Port,
- IN UINT8 Data
- )
-{
- //
- // perform 1-byte data write to register
- //
- PciIo->Io.Write (
- PciIo,
- EfiPciIoWidthUint8,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- (UINT64) Port,
- 1,
- &Data
- );
-
-}
-
-/**
- write a 1-word data to a specific IDE port.
-
- @param PciIo PCI IO protocol instance
- @param Port The IDE port to be writen
- @param Data The data to write to the port
-**/
-VOID
-IDEWritePortW (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT16 Port,
- IN UINT16 Data
- )
-{
- //
- // perform 1-word data write to register
- //
- PciIo->Io.Write (
- PciIo,
- EfiPciIoWidthUint16,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- (UINT64) Port,
- 1,
- &Data
- );
-}
-
-/**
- Write multiple words of data to the IDE data port.
- Call the IO abstraction once to do the complete read,
- not one word at a time
-
- @param PciIo Pointer to the EFI_PCI_IO instance
- @param Port IO port to read
- @param Count No. of UINT16's to read
- @param Buffer Pointer to the data buffer for read
-
-**/
-VOID
-IDEWritePortWMultiple (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT16 Port,
- IN UINTN Count,
- IN VOID *Buffer
- )
-{
- UINT16 *AlignedBuffer;
- UINT32 *WorkingBuffer;
- UINTN Size;
-
- //
- // Prepare an 16-bit alligned working buffer. CpuIo will return failure and
- // not perform actual I/O operations if buffer pointer passed in is not at
- // natural boundary. The "Buffer" argument is passed in by user and may not
- // at 16-bit natural boundary.
- //
- Size = sizeof (UINT16) * Count;
-
- gBS->AllocatePool (
- EfiBootServicesData,
- Size + 1,
- (VOID **) &WorkingBuffer
- );
-
- AlignedBuffer = (UINT16 *) ((UINTN)(((UINTN) WorkingBuffer + 0x1) & (~0x1)));
-
- //
- // Copy data from user buffer to working buffer
- //
- CopyMem ((UINT16 *) AlignedBuffer, Buffer, Size);
-
- //
- // perform UINT16 data write to the FIFO
- //
- PciIo->Io.Write (
- PciIo,
- EfiPciIoWidthFifoUint16,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- (UINT64) Port,
- Count,
- (UINT16 *) AlignedBuffer
- );
-
- gBS->FreePool (WorkingBuffer);
-}
-/**
- Get IDE IO port registers' base addresses by mode. In 'Compatibility' mode,
- use fixed addresses. In Native-PCI mode, get base addresses from BARs in
- the PCI IDE controller's Configuration Space.
-
- The steps to get IDE IO port registers' base addresses for each channel
- as follows:
-
- 1. Examine the Programming Interface byte of the Class Code fields in PCI IDE
- controller's Configuration Space to determine the operating mode.
-
- 2. a) In 'Compatibility' mode, use fixed addresses shown in the Table 1 below.
- <pre>
- ___________________________________________
- | | Command Block | Control Block |
- | Channel | Registers | Registers |
- |___________|_______________|_______________|
- | Primary | 1F0h - 1F7h | 3F6h - 3F7h |
- |___________|_______________|_______________|
- | Secondary | 170h - 177h | 376h - 377h |
- |___________|_______________|_______________|
-
- Table 1. Compatibility resource mappings
- </pre>
-
- b) In Native-PCI mode, IDE registers are mapped into IO space using the BARs
- in IDE controller's PCI Configuration Space, shown in the Table 2 below.
- <pre>
- ___________________________________________________
- | | Command Block | Control Block |
- | Channel | Registers | Registers |
- |___________|___________________|___________________|
- | Primary | BAR at offset 0x10| BAR at offset 0x14|
- |___________|___________________|___________________|
- | Secondary | BAR at offset 0x18| BAR at offset 0x1C|
- |___________|___________________|___________________|
-
- Table 2. BARs for Register Mapping
- </pre>
- @note Refer to Intel ICH4 datasheet, Control Block Offset: 03F4h for
- primary, 0374h for secondary. So 2 bytes extra offset should be
- added to the base addresses read from BARs.
-
- For more details, please refer to PCI IDE Controller Specification and Intel
- ICH4 Datasheet.
-
- @param PciIo Pointer to the EFI_PCI_IO_PROTOCOL instance
- @param IdeRegsBaseAddr Pointer to IDE_REGISTERS_BASE_ADDR to
- receive IDE IO port registers' base addresses
-
- @retval EFI_UNSUPPORTED return this value when the BARs is not IO type
- @retval EFI_SUCCESS Get the Base address successfully
- @retval other read the pci configureation data error
-
-**/
-EFI_STATUS
-GetIdeRegistersBaseAddr (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- OUT IDE_REGISTERS_BASE_ADDR *IdeRegsBaseAddr
- )
-{
- EFI_STATUS Status;
- PCI_TYPE00 PciData;
-
- Status = PciIo->Pci.Read (
- PciIo,
- EfiPciIoWidthUint8,
- 0,
- sizeof (PciData),
- &PciData
- );
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if ((PciData.Hdr.ClassCode[0] & IDE_PRIMARY_OPERATING_MODE) == 0) {
- IdeRegsBaseAddr[IdePrimary].CommandBlockBaseAddr = 0x1f0;
- IdeRegsBaseAddr[IdePrimary].ControlBlockBaseAddr = 0x3f6;
- IdeRegsBaseAddr[IdePrimary].BusMasterBaseAddr =
- (UINT16)((PciData.Device.Bar[4] & 0x0000fff0));
- } else {
- //
- // The BARs should be of IO type
- //
- if ((PciData.Device.Bar[0] & BIT0) == 0 ||
- (PciData.Device.Bar[1] & BIT0) == 0) {
- return EFI_UNSUPPORTED;
- }
-
- IdeRegsBaseAddr[IdePrimary].CommandBlockBaseAddr =
- (UINT16) (PciData.Device.Bar[0] & 0x0000fff8);
- IdeRegsBaseAddr[IdePrimary].ControlBlockBaseAddr =
- (UINT16) ((PciData.Device.Bar[1] & 0x0000fffc) + 2);
- IdeRegsBaseAddr[IdePrimary].BusMasterBaseAddr =
- (UINT16) ((PciData.Device.Bar[4] & 0x0000fff0));
- }
-
- if ((PciData.Hdr.ClassCode[0] & IDE_SECONDARY_OPERATING_MODE) == 0) {
- IdeRegsBaseAddr[IdeSecondary].CommandBlockBaseAddr = 0x170;
- IdeRegsBaseAddr[IdeSecondary].ControlBlockBaseAddr = 0x376;
- IdeRegsBaseAddr[IdeSecondary].BusMasterBaseAddr =
- (UINT16) ((PciData.Device.Bar[4] & 0x0000fff0));
- } else {
- //
- // The BARs should be of IO type
- //
- if ((PciData.Device.Bar[2] & BIT0) == 0 ||
- (PciData.Device.Bar[3] & BIT0) == 0) {
- return EFI_UNSUPPORTED;
- }
-
- IdeRegsBaseAddr[IdeSecondary].CommandBlockBaseAddr =
- (UINT16) (PciData.Device.Bar[2] & 0x0000fff8);
- IdeRegsBaseAddr[IdeSecondary].ControlBlockBaseAddr =
- (UINT16) ((PciData.Device.Bar[3] & 0x0000fffc) + 2);
- IdeRegsBaseAddr[IdeSecondary].BusMasterBaseAddr =
- (UINT16) ((PciData.Device.Bar[4] & 0x0000fff0));
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- This function is used to requery IDE resources. The IDE controller will
- probably switch between native and legacy modes during the EFI->CSM->OS
- transfer. We do this everytime before an BlkIo operation to ensure its
- succeess.
-
- @param IdeDev The BLK_IO private data which specifies the IDE device
-
- @retval EFI_INVALID_PARAMETER return this value when the channel is invalid
- @retval EFI_SUCCESS reassign the IDE IO resource successfully
- @retval other get the IDE current base address effor
-
-**/
-EFI_STATUS
-ReassignIdeResources (
- IN IDE_BLK_IO_DEV *IdeDev
- )
-{
- EFI_STATUS Status;
- IDE_REGISTERS_BASE_ADDR IdeRegsBaseAddr[IdeMaxChannel];
- UINT16 CommandBlockBaseAddr;
- UINT16 ControlBlockBaseAddr;
-
- if (IdeDev->Channel >= IdeMaxChannel) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Requery IDE IO port registers' base addresses in case of the switch of
- // native and legacy modes
- //
- Status = GetIdeRegistersBaseAddr (IdeDev->PciIo, IdeRegsBaseAddr);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- ZeroMem (IdeDev->IoPort, sizeof (IDE_BASE_REGISTERS));
- CommandBlockBaseAddr = IdeRegsBaseAddr[IdeDev->Channel].CommandBlockBaseAddr;
- ControlBlockBaseAddr = IdeRegsBaseAddr[IdeDev->Channel].ControlBlockBaseAddr;
-
- IdeDev->IoPort->Data = CommandBlockBaseAddr;
- (*(UINT16 *) &IdeDev->IoPort->Reg1) = (UINT16) (CommandBlockBaseAddr + 0x01);
- IdeDev->IoPort->SectorCount = (UINT16) (CommandBlockBaseAddr + 0x02);
- IdeDev->IoPort->SectorNumber = (UINT16) (CommandBlockBaseAddr + 0x03);
- IdeDev->IoPort->CylinderLsb = (UINT16) (CommandBlockBaseAddr + 0x04);
- IdeDev->IoPort->CylinderMsb = (UINT16) (CommandBlockBaseAddr + 0x05);
- IdeDev->IoPort->Head = (UINT16) (CommandBlockBaseAddr + 0x06);
-
- (*(UINT16 *) &IdeDev->IoPort->Reg) = (UINT16) (CommandBlockBaseAddr + 0x07);
- (*(UINT16 *) &IdeDev->IoPort->Alt) = ControlBlockBaseAddr;
- IdeDev->IoPort->DriveAddress = (UINT16) (ControlBlockBaseAddr + 0x01);
- IdeDev->IoPort->MasterSlave = (UINT16) ((IdeDev->Device == IdeMaster) ? 1 : 0);
-
- IdeDev->IoPort->BusMasterBaseAddr = IdeRegsBaseAddr[IdeDev->Channel].BusMasterBaseAddr;
- return EFI_SUCCESS;
-}
-
-/**
- This function is called by DiscoverIdeDevice(). It is used for detect
- whether the IDE device exists in the specified Channel as the specified
- Device Number.
-
- There is two IDE channels: one is Primary Channel, the other is
- Secondary Channel.(Channel is the logical name for the physical "Cable".)
- Different channel has different register group.
-
- On each IDE channel, at most two IDE devices attach,
- one is called Device 0 (Master device), the other is called Device 1
- (Slave device). The devices on the same channel co-use the same register
- group, so before sending out a command for a specified device via command
- register, it is a must to select the current device to accept the command
- by set the device number in the Head/Device Register.
-
- @param IdeDev pointer to IDE_BLK_IO_DEV data structure, used to record all the
- information of the IDE device.
-
- @retval EFI_SUCCESS successfully detects device.
-
- @retval other any failure during detection process will return this value.
-
-**/
-EFI_STATUS
-DetectIDEController (
- IN IDE_BLK_IO_DEV *IdeDev
- )
-{
- EFI_STATUS Status;
- UINT8 SectorCountReg;
- UINT8 LBALowReg;
- UINT8 LBAMidReg;
- UINT8 LBAHighReg;
- UINT8 InitStatusReg;
- UINT8 StatusReg;
-
- //
- // Select slave device
- //
- IDEWritePortB (
- IdeDev->PciIo,
- IdeDev->IoPort->Head,
- (UINT8) ((1 << 4) | 0xe0)
- );
- gBS->Stall (100);
-
- //
- // Save the init slave status register
- //
- InitStatusReg = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Status);
-
- //
- // Select Master back
- //
- IDEWritePortB (
- IdeDev->PciIo,
- IdeDev->IoPort->Head,
- (UINT8) ((0 << 4) | 0xe0)
- );
- gBS->Stall (100);
-
- //
- // Send ATA Device Execut Diagnostic command.
- // This command should work no matter DRDY is ready or not
- //
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Command, 0x90);
-
- Status = WaitForBSYClear (IdeDev, 3500);
- if (EFI_ERROR (Status)) {
- DEBUG((EFI_D_ERROR, "New detecting method: Send Execute Diagnostic Command: WaitForBSYClear: Status: %d\n", Status));
- return Status;
- }
- //
- // Read device signature
- //
- //
- // Select Master
- //
- IDEWritePortB (
- IdeDev->PciIo,
- IdeDev->IoPort->Head,
- (UINT8) ((0 << 4) | 0xe0)
- );
- gBS->Stall (100);
- SectorCountReg = IDEReadPortB (
- IdeDev->PciIo,
- IdeDev->IoPort->SectorCount
- );
- LBALowReg = IDEReadPortB (
- IdeDev->PciIo,
- IdeDev->IoPort->SectorNumber
- );
- LBAMidReg = IDEReadPortB (
- IdeDev->PciIo,
- IdeDev->IoPort->CylinderLsb
- );
- LBAHighReg = IDEReadPortB (
- IdeDev->PciIo,
- IdeDev->IoPort->CylinderMsb
- );
- if ((SectorCountReg == 0x1) &&
- (LBALowReg == 0x1) &&
- (LBAMidReg == 0x0) &&
- (LBAHighReg == 0x0)) {
- MasterDeviceExist = TRUE;
- MasterDeviceType = ATA_DEVICE_TYPE;
- } else {
- if ((LBAMidReg == 0x14) &&
- (LBAHighReg == 0xeb)) {
- MasterDeviceExist = TRUE;
- MasterDeviceType = ATAPI_DEVICE_TYPE;
- }
- }
-
- //
- // For some Hard Drive, it takes some time to get
- // the right signature when operating in single slave mode.
- // We stall 20ms to work around this.
- //
- if (!MasterDeviceExist) {
- gBS->Stall (20000);
- }
-
- //
- // Select Slave
- //
- IDEWritePortB (
- IdeDev->PciIo,
- IdeDev->IoPort->Head,
- (UINT8) ((1 << 4) | 0xe0)
- );
- gBS->Stall (100);
- SectorCountReg = IDEReadPortB (
- IdeDev->PciIo,
- IdeDev->IoPort->SectorCount
- );
- LBALowReg = IDEReadPortB (
- IdeDev->PciIo,
- IdeDev->IoPort->SectorNumber
- );
- LBAMidReg = IDEReadPortB (
- IdeDev->PciIo,
- IdeDev->IoPort->CylinderLsb
- );
- LBAHighReg = IDEReadPortB (
- IdeDev->PciIo,
- IdeDev->IoPort->CylinderMsb
- );
- StatusReg = IDEReadPortB (
- IdeDev->PciIo,
- IdeDev->IoPort->Reg.Status
- );
- if ((SectorCountReg == 0x1) &&
- (LBALowReg == 0x1) &&
- (LBAMidReg == 0x0) &&
- (LBAHighReg == 0x0)) {
- SlaveDeviceExist = TRUE;
- SlaveDeviceType = ATA_DEVICE_TYPE;
- } else {
- if ((LBAMidReg == 0x14) &&
- (LBAHighReg == 0xeb)) {
- SlaveDeviceExist = TRUE;
- SlaveDeviceType = ATAPI_DEVICE_TYPE;
- }
- }
-
- //
- // When single master is plugged, slave device
- // will be wrongly detected. Here's the workaround
- // for ATA devices by detecting DRY bit in status
- // register.
- // NOTE: This workaround doesn't apply to ATAPI.
- //
- if (MasterDeviceExist && SlaveDeviceExist &&
- (StatusReg & ATA_STSREG_DRDY) == 0 &&
- (InitStatusReg & ATA_STSREG_DRDY) == 0 &&
- MasterDeviceType == SlaveDeviceType &&
- SlaveDeviceType != ATAPI_DEVICE_TYPE) {
- SlaveDeviceExist = FALSE;
- }
-
- //
- // Indicate this channel has been detected
- //
- ChannelDeviceDetected = TRUE;
- return EFI_SUCCESS;
-}
-/**
- Detect if there is disk attached to this port
-
- @param IdeDev The BLK_IO private data which specifies the IDE device.
-
- @retval EFI_NOT_FOUND The device or channel is not found
- @retval EFI_SUCCESS The device is found
-
-**/
-EFI_STATUS
-DiscoverIdeDevice (
- IN IDE_BLK_IO_DEV *IdeDev
- )
-{
- EFI_STATUS Status;
- EFI_STATUS LongPhyStatus;
-
- //
- // If a channel has not been checked, check it now. Then set it to "checked" state
- // After this step, all devices in this channel have been checked.
- //
- if (!ChannelDeviceDetected) {
- Status = DetectIDEController (IdeDev);
- if (EFI_ERROR (Status)) {
- return EFI_NOT_FOUND;
- }
- }
-
- Status = EFI_NOT_FOUND;
-
- //
- // Device exists. test if it is an ATA device.
- // Prefer the result from DetectIDEController,
- // if failed, try another device type to handle
- // devices that not follow the spec.
- //
- if ((IdeDev->Device == IdeMaster) && (MasterDeviceExist)) {
- if (MasterDeviceType == ATA_DEVICE_TYPE) {
- Status = ATAIdentify (IdeDev);
- if (EFI_ERROR (Status)) {
- Status = ATAPIIdentify (IdeDev);
- if (!EFI_ERROR (Status)) {
- MasterDeviceType = ATAPI_DEVICE_TYPE;
- }
- }
- } else {
- Status = ATAPIIdentify (IdeDev);
- if (EFI_ERROR (Status)) {
- Status = ATAIdentify (IdeDev);
- if (!EFI_ERROR (Status)) {
- MasterDeviceType = ATA_DEVICE_TYPE;
- }
- }
- }
- }
- if ((IdeDev->Device == IdeSlave) && (SlaveDeviceExist)) {
- if (SlaveDeviceType == ATA_DEVICE_TYPE) {
- Status = ATAIdentify (IdeDev);
- if (EFI_ERROR (Status)) {
- Status = ATAPIIdentify (IdeDev);
- if (!EFI_ERROR (Status)) {
- SlaveDeviceType = ATAPI_DEVICE_TYPE;
- }
- }
- } else {
- Status = ATAPIIdentify (IdeDev);
- if (EFI_ERROR (Status)) {
- Status = ATAIdentify (IdeDev);
- if (!EFI_ERROR (Status)) {
- SlaveDeviceType = ATA_DEVICE_TYPE;
- }
- }
- }
- }
- if (EFI_ERROR (Status)) {
- return EFI_NOT_FOUND;
- }
- //
- // Init Block I/O interface
- //
- LongPhyStatus = AtaEnableLongPhysicalSector (IdeDev);
- if (!EFI_ERROR (LongPhyStatus)) {
- IdeDev->BlkIo.Revision = EFI_BLOCK_IO_PROTOCOL_REVISION2;
- } else {
- IdeDev->BlkIo.Revision = EFI_BLOCK_IO_PROTOCOL_REVISION;
- }
- IdeDev->BlkIo.Reset = IDEBlkIoReset;
- IdeDev->BlkIo.ReadBlocks = IDEBlkIoReadBlocks;
- IdeDev->BlkIo.WriteBlocks = IDEBlkIoWriteBlocks;
- IdeDev->BlkIo.FlushBlocks = IDEBlkIoFlushBlocks;
-
- IdeDev->BlkMedia.LogicalPartition = FALSE;
- IdeDev->BlkMedia.WriteCaching = FALSE;
-
- //
- // Init Disk Info interface
- //
- gBS->CopyMem (&IdeDev->DiskInfo.Interface, &gEfiDiskInfoIdeInterfaceGuid, sizeof (EFI_GUID));
- IdeDev->DiskInfo.Inquiry = IDEDiskInfoInquiry;
- IdeDev->DiskInfo.Identify = IDEDiskInfoIdentify;
- IdeDev->DiskInfo.SenseData = IDEDiskInfoSenseData;
- IdeDev->DiskInfo.WhichIde = IDEDiskInfoWhichIde;
-
- return EFI_SUCCESS;
-}
-
-/**
- This interface is used to initialize all state data related to the detection of one
- channel.
-**/
-VOID
-InitializeIDEChannelData (
- VOID
- )
-{
- ChannelDeviceDetected = FALSE;
- MasterDeviceExist = FALSE;
- MasterDeviceType = 0xff;
- SlaveDeviceExist = FALSE;
- SlaveDeviceType = 0xff;
-}
-/**
- This function is used to poll for the DRQ bit clear in the Status
- Register. DRQ is cleared when the device is finished transferring data.
- So this function is called after data transfer is finished.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
- @param TimeoutInMilliSeconds used to designate the timeout for the DRQ clear.
-
- @retval EFI_SUCCESS DRQ bit clear within the time out.
-
- @retval EFI_TIMEOUT DRQ bit not clear within the time out.
-
- @note
- Read Status Register will clear interrupt status.
-
-**/
-EFI_STATUS
-DRQClear (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN UINTN TimeoutInMilliSeconds
- )
-{
- UINT32 Delay;
- UINT8 StatusRegister;
- UINT8 ErrorRegister;
-
- Delay = (UINT32) (((TimeoutInMilliSeconds * STALL_1_MILLI_SECOND) / 30) + 1);
- do {
-
- StatusRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Status);
-
- //
- // wait for BSY == 0 and DRQ == 0
- //
- if ((StatusRegister & (ATA_STSREG_DRQ | ATA_STSREG_BSY)) == 0) {
- break;
- }
-
- if ((StatusRegister & (ATA_STSREG_BSY | ATA_STSREG_ERR)) == ATA_STSREG_ERR) {
-
- ErrorRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Error);
- if ((ErrorRegister & ATA_ERRREG_ABRT) == ATA_ERRREG_ABRT) {
- return EFI_ABORTED;
- }
- }
-
- //
- // Stall for 30 us
- //
- gBS->Stall (30);
-
- Delay--;
-
- } while (Delay > 0);
-
- if (Delay == 0) {
- return EFI_TIMEOUT;
- }
-
- return EFI_SUCCESS;
-}
-/**
- This function is used to poll for the DRQ bit clear in the Alternate
- Status Register. DRQ is cleared when the device is finished
- transferring data. So this function is called after data transfer
- is finished.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
-
- @param TimeoutInMilliSeconds used to designate the timeout for the DRQ clear.
-
- @retval EFI_SUCCESS DRQ bit clear within the time out.
-
- @retval EFI_TIMEOUT DRQ bit not clear within the time out.
- @note Read Alternate Status Register will not clear interrupt status.
-
-**/
-EFI_STATUS
-DRQClear2 (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN UINTN TimeoutInMilliSeconds
- )
-{
- UINT32 Delay;
- UINT8 AltRegister;
- UINT8 ErrorRegister;
-
- Delay = (UINT32) (((TimeoutInMilliSeconds * STALL_1_MILLI_SECOND) / 30) + 1);
- do {
-
- AltRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Alt.AltStatus);
-
- //
- // wait for BSY == 0 and DRQ == 0
- //
- if ((AltRegister & (ATA_STSREG_DRQ | ATA_STSREG_BSY)) == 0) {
- break;
- }
-
- if ((AltRegister & (ATA_STSREG_BSY | ATA_STSREG_ERR)) == ATA_STSREG_ERR) {
-
- ErrorRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Error);
- if ((ErrorRegister & ATA_ERRREG_ABRT) == ATA_ERRREG_ABRT) {
- return EFI_ABORTED;
- }
- }
-
- //
- // Stall for 30 us
- //
- gBS->Stall (30);
-
- Delay--;
-
- } while (Delay > 0);
-
- if (Delay == 0) {
- return EFI_TIMEOUT;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- This function is used to poll for the DRQ bit set in the
- Status Register.
- DRQ is set when the device is ready to transfer data. So this function
- is called after the command is sent to the device and before required
- data is transferred.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure,used to
- record all the information of the IDE device.
- @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.
-
- @retval EFI_SUCCESS DRQ bit set within the time out.
- @retval EFI_TIMEOUT DRQ bit not set within the time out.
- @retval EFI_ABORTED DRQ bit not set caused by the command abort.
-
- @note Read Status Register will clear interrupt status.
-
-**/
-EFI_STATUS
-DRQReady (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN UINTN TimeoutInMilliSeconds
- )
-{
- UINT32 Delay;
- UINT8 StatusRegister;
- UINT8 ErrorRegister;
-
- Delay = (UINT32) (((TimeoutInMilliSeconds * STALL_1_MILLI_SECOND) / 30) + 1);
- do {
- //
- // read Status Register will clear interrupt
- //
- StatusRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Status);
-
- //
- // BSY==0,DRQ==1
- //
- if ((StatusRegister & (ATA_STSREG_BSY | ATA_STSREG_DRQ)) == ATA_STSREG_DRQ) {
- break;
- }
-
- if ((StatusRegister & (ATA_STSREG_BSY | ATA_STSREG_ERR)) == ATA_STSREG_ERR) {
-
- ErrorRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Error);
- if ((ErrorRegister & ATA_ERRREG_ABRT) == ATA_ERRREG_ABRT) {
- return EFI_ABORTED;
- }
- }
-
- //
- // Stall for 30 us
- //
- gBS->Stall (30);
-
- Delay--;
- } while (Delay > 0);
-
- if (Delay == 0) {
- return EFI_TIMEOUT;
- }
-
- return EFI_SUCCESS;
-}
-/**
- This function is used to poll for the DRQ bit set in the Alternate Status Register.
- DRQ is set when the device is ready to transfer data. So this function is called after
- the command is sent to the device and before required data is transferred.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to
- record all the information of the IDE device.
-
- @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.
-
- @retval EFI_SUCCESS DRQ bit set within the time out.
- @retval EFI_TIMEOUT DRQ bit not set within the time out.
- @retval EFI_ABORTED DRQ bit not set caused by the command abort.
- @note Read Alternate Status Register will not clear interrupt status.
-
-**/
-EFI_STATUS
-DRQReady2 (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN UINTN TimeoutInMilliSeconds
- )
-{
- UINT32 Delay;
- UINT8 AltRegister;
- UINT8 ErrorRegister;
-
- Delay = (UINT32) (((TimeoutInMilliSeconds * STALL_1_MILLI_SECOND) / 30) + 1);
-
- do {
- //
- // Read Alternate Status Register will not clear interrupt status
- //
- AltRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Alt.AltStatus);
- //
- // BSY == 0 , DRQ == 1
- //
- if ((AltRegister & (ATA_STSREG_BSY | ATA_STSREG_DRQ)) == ATA_STSREG_DRQ) {
- break;
- }
-
- if ((AltRegister & (ATA_STSREG_BSY | ATA_STSREG_ERR)) == ATA_STSREG_ERR) {
-
- ErrorRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Error);
- if ((ErrorRegister & ATA_ERRREG_ABRT) == ATA_ERRREG_ABRT) {
- return EFI_ABORTED;
- }
- }
-
- //
- // Stall for 30 us
- //
- gBS->Stall (30);
-
- Delay--;
- } while (Delay > 0);
-
- if (Delay == 0) {
- return EFI_TIMEOUT;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- This function is used to poll for the BSY bit clear in the Status Register. BSY
- is clear when the device is not busy. Every command must be sent after device is not busy.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
- @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.
-
- @retval EFI_SUCCESS BSY bit clear within the time out.
- @retval EFI_TIMEOUT BSY bit not clear within the time out.
-
- @note Read Status Register will clear interrupt status.
-**/
-EFI_STATUS
-WaitForBSYClear (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN UINTN TimeoutInMilliSeconds
- )
-{
- UINT32 Delay;
- UINT8 StatusRegister;
-
- Delay = (UINT32) (((TimeoutInMilliSeconds * STALL_1_MILLI_SECOND) / 30) + 1);
- do {
-
- StatusRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Status);
- if ((StatusRegister & ATA_STSREG_BSY) == 0x00) {
- break;
- }
-
- //
- // Stall for 30 us
- //
- gBS->Stall (30);
-
- Delay--;
-
- } while (Delay > 0);
-
- if (Delay == 0) {
- return EFI_TIMEOUT;
- }
-
- return EFI_SUCCESS;
-}
-/**
- This function is used to poll for the BSY bit clear in the Alternate Status Register.
- BSY is clear when the device is not busy. Every command must be sent after device is
- not busy.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record
- all the information of the IDE device.
- @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.
-
- @retval EFI_SUCCESS BSY bit clear within the time out.
- @retval EFI_TIMEOUT BSY bit not clear within the time out.
- @note Read Alternate Status Register will not clear interrupt status.
-
-**/
-EFI_STATUS
-WaitForBSYClear2 (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN UINTN TimeoutInMilliSeconds
- )
-{
- UINT32 Delay;
- UINT8 AltRegister;
-
- Delay = (UINT32) (((TimeoutInMilliSeconds * STALL_1_MILLI_SECOND) / 30) + 1);
- do {
- AltRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Alt.AltStatus);
- if ((AltRegister & ATA_STSREG_BSY) == 0x00) {
- break;
- }
-
- gBS->Stall (30);
-
- Delay--;
-
- } while (Delay > 0);
-
- if (Delay == 0) {
- return EFI_TIMEOUT;
- }
-
- return EFI_SUCCESS;
-}
-/**
- This function is used to poll for the DRDY bit set in the Status Register. DRDY
- bit is set when the device is ready to accept command. Most ATA commands must be
- sent after DRDY set except the ATAPI Packet Command.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
- @param DelayInMilliSeconds used to designate the timeout for the DRQ ready.
-
- @retval EFI_SUCCESS DRDY bit set within the time out.
- @retval EFI_TIMEOUT DRDY bit not set within the time out.
-
- @note Read Status Register will clear interrupt status.
-**/
-EFI_STATUS
-DRDYReady (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN UINTN DelayInMilliSeconds
- )
-{
- UINT32 Delay;
- UINT8 StatusRegister;
- UINT8 ErrorRegister;
-
- Delay = (UINT32) (((DelayInMilliSeconds * STALL_1_MILLI_SECOND) / 30) + 1);
- do {
- StatusRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg.Status);
- //
- // BSY == 0 , DRDY == 1
- //
- if ((StatusRegister & (ATA_STSREG_DRDY | ATA_STSREG_BSY)) == ATA_STSREG_DRDY) {
- break;
- }
-
- if ((StatusRegister & (ATA_STSREG_BSY | ATA_STSREG_ERR)) == ATA_STSREG_ERR) {
-
- ErrorRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Error);
- if ((ErrorRegister & ATA_ERRREG_ABRT) == ATA_ERRREG_ABRT) {
- return EFI_ABORTED;
- }
- }
-
- gBS->Stall (30);
-
- Delay--;
- } while (Delay > 0);
-
- if (Delay == 0) {
- return EFI_TIMEOUT;
- }
-
- return EFI_SUCCESS;
-}
-/**
- This function is used to poll for the DRDY bit set in the Alternate Status Register.
- DRDY bit is set when the device is ready to accept command. Most ATA commands must
- be sent after DRDY set except the ATAPI Packet Command.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
- @param DelayInMilliSeconds used to designate the timeout for the DRQ ready.
-
- @retval EFI_SUCCESS DRDY bit set within the time out.
- @retval EFI_TIMEOUT DRDY bit not set within the time out.
-
- @note Read Alternate Status Register will clear interrupt status.
-
-**/
-EFI_STATUS
-DRDYReady2 (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN UINTN DelayInMilliSeconds
- )
-{
- UINT32 Delay;
- UINT8 AltRegister;
- UINT8 ErrorRegister;
-
- Delay = (UINT32) (((DelayInMilliSeconds * STALL_1_MILLI_SECOND) / 30) + 1);
- do {
- AltRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Alt.AltStatus);
- //
- // BSY == 0 , DRDY == 1
- //
- if ((AltRegister & (ATA_STSREG_DRDY | ATA_STSREG_BSY)) == ATA_STSREG_DRDY) {
- break;
- }
-
- if ((AltRegister & (ATA_STSREG_BSY | ATA_STSREG_ERR)) == ATA_STSREG_ERR) {
-
- ErrorRegister = IDEReadPortB (IdeDev->PciIo, IdeDev->IoPort->Reg1.Error);
- if ((ErrorRegister & ATA_ERRREG_ABRT) == ATA_ERRREG_ABRT) {
- return EFI_ABORTED;
- }
- }
-
- gBS->Stall (30);
-
- Delay--;
- } while (Delay > 0);
-
- if (Delay == 0) {
- return EFI_TIMEOUT;
- }
-
- return EFI_SUCCESS;
-}
-/**
- Release resources of an IDE device before stopping it.
-
- @param IdeBlkIoDevice Standard IDE device private data structure
-
-**/
-VOID
-ReleaseIdeResources (
- IN IDE_BLK_IO_DEV *IdeBlkIoDevice
- )
-{
- if (IdeBlkIoDevice == NULL) {
- return ;
- }
-
- //
- // Release all the resourses occupied by the IDE_BLK_IO_DEV
- //
-
- if (IdeBlkIoDevice->SenseData != NULL) {
- gBS->FreePool (IdeBlkIoDevice->SenseData);
- IdeBlkIoDevice->SenseData = NULL;
- }
-
- if (IdeBlkIoDevice->Cache != NULL) {
- gBS->FreePool (IdeBlkIoDevice->Cache);
- IdeBlkIoDevice->Cache = NULL;
- }
-
- if (IdeBlkIoDevice->IdData != NULL) {
- gBS->FreePool (IdeBlkIoDevice->IdData);
- IdeBlkIoDevice->IdData = NULL;
- }
-
- if (IdeBlkIoDevice->InquiryData != NULL) {
- gBS->FreePool (IdeBlkIoDevice->InquiryData);
- IdeBlkIoDevice->InquiryData = NULL;
- }
-
- if (IdeBlkIoDevice->ControllerNameTable != NULL) {
- FreeUnicodeStringTable (IdeBlkIoDevice->ControllerNameTable);
- IdeBlkIoDevice->ControllerNameTable = NULL;
- }
-
- if (IdeBlkIoDevice->IoPort != NULL) {
- gBS->FreePool (IdeBlkIoDevice->IoPort);
- }
-
- if (IdeBlkIoDevice->DevicePath != NULL) {
- gBS->FreePool (IdeBlkIoDevice->DevicePath);
- }
-
- if (IdeBlkIoDevice->ExitBootServiceEvent != NULL) {
- gBS->CloseEvent (IdeBlkIoDevice->ExitBootServiceEvent);
- IdeBlkIoDevice->ExitBootServiceEvent = NULL;
- }
-
- gBS->FreePool (IdeBlkIoDevice);
- IdeBlkIoDevice = NULL;
-
- return ;
-}
-/**
- Set the calculated Best transfer mode to a detected device.
-
- @param IdeDev Standard IDE device private data structure
- @param TransferMode The device transfer mode to be set
- @return Set transfer mode Command execute status.
-
-**/
-EFI_STATUS
-SetDeviceTransferMode (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN ATA_TRANSFER_MODE *TransferMode
- )
-{
- EFI_STATUS Status;
- UINT8 DeviceSelect;
- UINT8 SectorCount;
-
- DeviceSelect = 0;
- DeviceSelect = (UINT8) ((IdeDev->Device) << 4);
- SectorCount = *((UINT8 *) TransferMode);
-
- //
- // Send SET FEATURE command (sub command 0x03) to set pio mode.
- //
- Status = AtaNonDataCommandIn (
- IdeDev,
- ATA_CMD_SET_FEATURES,
- DeviceSelect,
- 0x03,
- SectorCount,
- 0,
- 0,
- 0
- );
-
- return Status;
-}
-/**
- Set drive parameters for devices not support PACKETS command.
-
- @param IdeDev Standard IDE device private data structure
- @param DriveParameters The device parameters to be set into the disk
- @return SetParameters Command execute status.
-
-**/
-EFI_STATUS
-SetDriveParameters (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN ATA_DRIVE_PARMS *DriveParameters
- )
-{
- EFI_STATUS Status;
- UINT8 DeviceSelect;
-
- DeviceSelect = 0;
- DeviceSelect = (UINT8) ((IdeDev->Device) << 4);
-
- //
- // Send Init drive parameters
- //
- Status = AtaNonDataCommandIn (
- IdeDev,
- ATA_CMD_INIT_DRIVE_PARAM,
- (UINT8) (DeviceSelect + DriveParameters->Heads),
- 0,
- DriveParameters->Sector,
- 0,
- 0,
- 0
- );
-
- //
- // Send Set Multiple parameters
- //
- Status = AtaNonDataCommandIn (
- IdeDev,
- ATA_CMD_SET_MULTIPLE_MODE,
- DeviceSelect,
- 0,
- DriveParameters->MultipleSector,
- 0,
- 0,
- 0
- );
- return Status;
-}
-
-/**
- Enable Interrupt on IDE controller.
-
- @param IdeDev Standard IDE device private data structure
-
- @retval EFI_SUCCESS Enable Interrupt successfully
-**/
-EFI_STATUS
-EnableInterrupt (
- IN IDE_BLK_IO_DEV *IdeDev
- )
-{
- UINT8 DeviceControl;
-
- //
- // Enable interrupt for DMA operation
- //
- DeviceControl = 0;
- IDEWritePortB (IdeDev->PciIo, IdeDev->IoPort->Alt.DeviceControl, DeviceControl);
-
- return EFI_SUCCESS;
-}
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.h b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.h deleted file mode 100644 index 2b7e6ea5eb..0000000000 --- a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.h +++ /dev/null @@ -1,835 +0,0 @@ -/** @file
- Header file for IDE Bus Driver, containing the helper functions'
- prototype.
-
- Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
- 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.
-
- @par Revision Reference:
- 2002-6: Add Atapi6 enhancement, support >120GB hard disk, including
- Add - IDEBlkIoReadBlocksExt() func definition
- Add - IDEBlkIoWriteBlocksExt() func definition
-
-**/
-
-#ifndef _IDE_H_
-#define _IDE_H_
-
-//
-// Helper functions Prototype
-//
-/**
- read a one-byte data from a IDE port.
-
- @param PciIo The PCI IO protocol instance
- @param Port the IDE Port number
-
- return the one-byte data read from IDE port
-**/
-UINT8
-IDEReadPortB (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT16 Port
- );
-
-/**
- Reads multiple words of data from the IDE data port.
- Call the IO abstraction once to do the complete read,
- not one word at a time.
-
- @param PciIo Pointer to the EFI_PCI_IO instance
- @param Port IO port to read
- @param Count No. of UINT16's to read
- @param Buffer Pointer to the data buffer for read
-
-**/
-VOID
-IDEReadPortWMultiple (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT16 Port,
- IN UINTN Count,
- OUT VOID *Buffer
- );
-
-/**
- write a 1-byte data to a specific IDE port.
-
- @param PciIo PCI IO protocol instance
- @param Port The IDE port to be writen
- @param Data The data to write to the port
-**/
-VOID
-IDEWritePortB (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT16 Port,
- IN UINT8 Data
- );
-
-/**
- write a 1-word data to a specific IDE port.
-
- @param PciIo PCI IO protocol instance
- @param Port The IDE port to be writen
- @param Data The data to write to the port
-**/
-VOID
-IDEWritePortW (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT16 Port,
- IN UINT16 Data
- );
-
-/**
- Write multiple words of data to the IDE data port.
- Call the IO abstraction once to do the complete read,
- not one word at a time.
-
- @param PciIo Pointer to the EFI_PCI_IO instance
- @param Port IO port to read
- @param Count No. of UINT16's to read
- @param Buffer Pointer to the data buffer for read
-
-**/
-VOID
-IDEWritePortWMultiple (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- IN UINT16 Port,
- IN UINTN Count,
- IN VOID *Buffer
- );
-
-/**
- Get IDE IO port registers' base addresses by mode. In 'Compatibility' mode,
- use fixed addresses. In Native-PCI mode, get base addresses from BARs in
- the PCI IDE controller's Configuration Space.
-
- The steps to get IDE IO port registers' base addresses for each channel
- as follows:
-
- 1. Examine the Programming Interface byte of the Class Code fields in PCI IDE
- controller's Configuration Space to determine the operating mode.
-
- 2. a) In 'Compatibility' mode, use fixed addresses shown in the Table 1 below.
- <pre>
- ___________________________________________
- | | Command Block | Control Block |
- | Channel | Registers | Registers |
- |___________|_______________|_______________|
- | Primary | 1F0h - 1F7h | 3F6h - 3F7h |
- |___________|_______________|_______________|
- | Secondary | 170h - 177h | 376h - 377h |
- |___________|_______________|_______________|
-
- Table 1. Compatibility resource mappings
- </pre>
-
- b) In Native-PCI mode, IDE registers are mapped into IO space using the BARs
- in IDE controller's PCI Configuration Space, shown in the Table 2 below.
- <pre>
- ___________________________________________________
- | | Command Block | Control Block |
- | Channel | Registers | Registers |
- |___________|___________________|___________________|
- | Primary | BAR at offset 0x10| BAR at offset 0x14|
- |___________|___________________|___________________|
- | Secondary | BAR at offset 0x18| BAR at offset 0x1C|
- |___________|___________________|___________________|
-
- Table 2. BARs for Register Mapping
- </pre>
- @note Refer to Intel ICH4 datasheet, Control Block Offset: 03F4h for
- primary, 0374h for secondary. So 2 bytes extra offset should be
- added to the base addresses read from BARs.
-
- For more details, please refer to PCI IDE Controller Specification and Intel
- ICH4 Datasheet.
-
- @param PciIo Pointer to the EFI_PCI_IO_PROTOCOL instance
- @param IdeRegsBaseAddr Pointer to IDE_REGISTERS_BASE_ADDR to
- receive IDE IO port registers' base addresses
-
- @retval EFI_UNSUPPORTED return this value when the BARs is not IO type
- @retval EFI_SUCCESS Get the Base address successfully
- @retval other read the pci configureation data error
-
-**/
-EFI_STATUS
-GetIdeRegistersBaseAddr (
- IN EFI_PCI_IO_PROTOCOL *PciIo,
- OUT IDE_REGISTERS_BASE_ADDR *IdeRegsBaseAddr
- );
-
-/**
- This function is used to requery IDE resources. The IDE controller will
- probably switch between native and legacy modes during the EFI->CSM->OS
- transfer. We do this everytime before an BlkIo operation to ensure its
- succeess.
-
- @param IdeDev The BLK_IO private data which specifies the IDE device
-
- @retval EFI_INVALID_PARAMETER return this value when the channel is invalid
- @retval EFI_SUCCESS reassign the IDE IO resource successfully
- @retval other get the IDE current base address effor
-
-**/
-EFI_STATUS
-ReassignIdeResources (
- IN IDE_BLK_IO_DEV *IdeDev
- );
-
-/**
- Detect if there is disk attached to this port.
-
- @param IdeDev The BLK_IO private data which specifies the IDE device.
-
- @retval EFI_NOT_FOUND The device or channel is not found
- @retval EFI_SUCCESS The device is found
-
-**/
-EFI_STATUS
-DiscoverIdeDevice (
- IN IDE_BLK_IO_DEV *IdeDev
- );
-
-/**
- This interface is used to initialize all state data related to the
- detection of one channel.
-
-**/
-VOID
-InitializeIDEChannelData (
- VOID
- );
-
-/**
- This function is used to poll for the DRQ bit clear in the Status
- Register. DRQ is cleared when the device is finished transferring data.
- So this function is called after data transfer is finished.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
- @param TimeoutInMilliSeconds used to designate the timeout for the DRQ clear.
-
- @retval EFI_SUCCESS DRQ bit clear within the time out.
-
- @retval EFI_TIMEOUT DRQ bit not clear within the time out.
-
- @note
- Read Status Register will clear interrupt status.
-
-**/
-EFI_STATUS
-DRQClear (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN UINTN TimeoutInMilliSeconds
- );
-
-/**
- This function is used to poll for the DRQ bit clear in the Alternate
- Status Register. DRQ is cleared when the device is finished
- transferring data. So this function is called after data transfer
- is finished.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
-
- @param TimeoutInMilliSeconds used to designate the timeout for the DRQ clear.
-
- @retval EFI_SUCCESS DRQ bit clear within the time out.
-
- @retval EFI_TIMEOUT DRQ bit not clear within the time out.
- @note
- Read Alternate Status Register will not clear interrupt status.
-
-**/
-EFI_STATUS
-DRQClear2 (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN UINTN TimeoutInMilliSeconds
- );
-
-/**
- This function is used to poll for the DRQ bit set in the
- Status Register.
- DRQ is set when the device is ready to transfer data. So this function
- is called after the command is sent to the device and before required
- data is transferred.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure,used to
- record all the information of the IDE device.
- @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.
-
- @retval EFI_SUCCESS DRQ bit set within the time out.
- @retval EFI_TIMEOUT DRQ bit not set within the time out.
- @retval EFI_ABORTED DRQ bit not set caused by the command abort.
-
- @note Read Status Register will clear interrupt status.
-
-**/
-EFI_STATUS
-DRQReady (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN UINTN TimeoutInMilliSeconds
- );
-
-/**
- This function is used to poll for the DRQ bit set in the Alternate Status Register.
- DRQ is set when the device is ready to transfer data. So this function is called after
- the command is sent to the device and before required data is transferred.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to
- record all the information of the IDE device.
-
- @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.
-
- @retval EFI_SUCCESS DRQ bit set within the time out.
- @retval EFI_TIMEOUT DRQ bit not set within the time out.
- @retval EFI_ABORTED DRQ bit not set caused by the command abort.
- @note Read Alternate Status Register will not clear interrupt status.
-
-**/
-EFI_STATUS
-DRQReady2 (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN UINTN TimeoutInMilliSeconds
- );
-
-/**
- This function is used to poll for the BSY bit clear in the Status Register. BSY
- is clear when the device is not busy. Every command must be sent after device is not busy.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
- @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.
-
- @retval EFI_SUCCESS BSY bit clear within the time out.
- @retval EFI_TIMEOUT BSY bit not clear within the time out.
-
- @note Read Status Register will clear interrupt status.
-**/
-EFI_STATUS
-WaitForBSYClear (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN UINTN TimeoutInMilliSeconds
- );
-
-/**
- This function is used to poll for the BSY bit clear in the Alternate Status Register.
- BSY is clear when the device is not busy. Every command must be sent after device is
- not busy.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record
- all the information of the IDE device.
- @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.
-
- @retval EFI_SUCCESS BSY bit clear within the time out.
- @retval EFI_TIMEOUT BSY bit not clear within the time out.
- @note Read Alternate Status Register will not clear interrupt status.
-
-**/
-EFI_STATUS
-WaitForBSYClear2 (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN UINTN TimeoutInMilliSeconds
- );
-
-/**
- This function is used to poll for the DRDY bit set in the Status Register. DRDY
- bit is set when the device is ready to accept command. Most ATA commands must be
- sent after DRDY set except the ATAPI Packet Command.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
- @param DelayInMilliSeconds used to designate the timeout for the DRQ ready.
-
- @retval EFI_SUCCESS DRDY bit set within the time out.
- @retval EFI_TIMEOUT DRDY bit not set within the time out.
-
- @note Read Status Register will clear interrupt status.
-**/
-EFI_STATUS
-DRDYReady (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN UINTN DelayInMilliSeconds
- );
-
-/**
- This function is used to poll for the DRDY bit set in the Alternate Status Register.
- DRDY bit is set when the device is ready to accept command. Most ATA commands must
- be sent after DRDY set except the ATAPI Packet Command.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
- @param DelayInMilliSeconds used to designate the timeout for the DRQ ready.
-
- @retval EFI_SUCCESS DRDY bit set within the time out.
- @retval EFI_TIMEOUT DRDY bit not set within the time out.
-
- @note Read Alternate Status Register will clear interrupt status.
-
-**/
-EFI_STATUS
-DRDYReady2 (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN UINTN DelayInMilliSeconds
- );
-
-//
-// ATA device functions' prototype
-//
-/**
- Sends out an ATA Identify Command to the specified device.
-
- This function is called by DiscoverIdeDevice() during its device
- identification. It sends out the ATA Identify Command to the
- specified device. Only ATA device responses to this command. If
- the command succeeds, it returns the Identify data structure which
- contains information about the device. This function extracts the
- information it needs to fill the IDE_BLK_IO_DEV data structure,
- including device type, media block size, media capacity, and etc.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure,used to record
- all the information of the IDE device.
-
- @retval EFI_SUCCESS Identify ATA device successfully.
- @retval EFI_DEVICE_ERROR ATA Identify Device Command failed or device is not ATA device.
- @note parameter IdeDev will be updated in this function.
-
-**/
-EFI_STATUS
-ATAIdentify (
- IN IDE_BLK_IO_DEV *IdeDev
- );
-
-/**
- This function is called by ATAIdentify() or ATAPIIdentify() to print device's module name.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record
- all the information of the IDE device.
-**/
-VOID
-PrintAtaModuleName (
- IN IDE_BLK_IO_DEV *IdeDev
- );
-/**
- This function is used to send out ATA commands conforms to the PIO Data In Protocol.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record
- all the information of the IDE device.
- @param Buffer buffer contained data transferred from device to host.
- @param ByteCount data size in byte unit of the buffer.
- @param AtaCommand value of the Command Register
- @param Head value of the Head/Device Register
- @param SectorCount value of the Sector Count Register
- @param SectorNumber value of the Sector Number Register
- @param CylinderLsb value of the low byte of the Cylinder Register
- @param CylinderMsb value of the high byte of the Cylinder Register
-
- @retval EFI_SUCCESS send out the ATA command and device send required data successfully.
- @retval EFI_DEVICE_ERROR command sent failed.
-
-**/
-EFI_STATUS
-AtaPioDataIn (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN VOID *Buffer,
- IN UINT32 ByteCount,
- IN UINT8 AtaCommand,
- IN UINT8 Head,
- IN UINT8 SectorCount,
- IN UINT8 SectorNumber,
- IN UINT8 CylinderLsb,
- IN UINT8 CylinderMsb
- );
-
-/**
- This function is used to send out ATA commands conforms to the
- PIO Data Out Protocol.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
- @param *Buffer buffer contained data transferred from host to device.
- @param ByteCount data size in byte unit of the buffer.
- @param AtaCommand value of the Command Register
- @param Head value of the Head/Device Register
- @param SectorCount value of the Sector Count Register
- @param SectorNumber value of the Sector Number Register
- @param CylinderLsb value of the low byte of the Cylinder Register
- @param CylinderMsb value of the high byte of the Cylinder Register
-
- @retval EFI_SUCCESS send out the ATA command and device received required
- data successfully.
- @retval EFI_DEVICE_ERROR command sent failed.
-
-**/
-EFI_STATUS
-AtaPioDataOut (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN VOID *Buffer,
- IN UINT32 ByteCount,
- IN UINT8 AtaCommand,
- IN UINT8 Head,
- IN UINT8 SectorCount,
- IN UINT8 SectorNumber,
- IN UINT8 CylinderLsb,
- IN UINT8 CylinderMsb
- );
-
-/**
- This function is used to analyze the Status Register and print out
- some debug information and if there is ERR bit set in the Status
- Register, the Error Register's value is also be parsed and print out.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to
- record all the information of the IDE device.
-
- @retval EFI_SUCCESS No err information in the Status Register.
- @retval EFI_DEVICE_ERROR Any err information in the Status Register.
-
-**/
-EFI_STATUS
-CheckErrorStatus (
- IN IDE_BLK_IO_DEV *IdeDev
- );
-
-/**
- This function is used to implement the Soft Reset on the specified device. But,
- the ATA Soft Reset mechanism is so strong a reset method that it will force
- resetting on both devices connected to the same cable.
-
- It is called by IdeBlkIoReset(), a interface function of Block
- I/O protocol.
-
- This function can also be used by the ATAPI device to perform reset when
- ATAPI Reset command is failed.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record
- all the information of the IDE device.
- @retval EFI_SUCCESS Soft reset completes successfully.
- @retval EFI_DEVICE_ERROR Any step during the reset process is failed.
-
- @note The registers initial values after ATA soft reset are different
- to the ATA device and ATAPI device.
-**/
-EFI_STATUS
-AtaSoftReset (
- IN IDE_BLK_IO_DEV *IdeDev
- );
-
-/**
- This function is the ATA implementation for ReadBlocks in the
- Block I/O Protocol interface.
-
- @param IdeBlkIoDevice Indicates the calling context.
- @param MediaId The media id that the read request is for.
- @param Lba The starting logical block address to read from on the device.
- @param BufferSize The size of the Buffer in bytes. This must be a multiple
- of the intrinsic block size of the device.
-
- @param Buffer A pointer to the destination buffer for the data. The caller
- is responsible for either having implicit or explicit ownership
- of the memory that data is read into.
-
- @retval EFI_SUCCESS Read Blocks successfully.
- @retval EFI_DEVICE_ERROR Read Blocks failed.
- @retval EFI_NO_MEDIA There is no media in the device.
- @retval EFI_MEDIA_CHANGE The MediaId is not for the current media.
- @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
- intrinsic block size of the device.
- @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
- or the data buffer is not valid.
-
- @note If Read Block error because of device error, this function will call
- AtaSoftReset() function to reset device.
-
-**/
-EFI_STATUS
-AtaBlkIoReadBlocks (
- IN IDE_BLK_IO_DEV *IdeBlkIoDevice,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- );
-
-/**
- This function is the ATA implementation for WriteBlocks in the
- Block I/O Protocol interface.
-
- @param IdeBlkIoDevice Indicates the calling context.
- @param MediaId The media id that the write request is for.
- @param Lba The starting logical block address to write onto the device.
- @param BufferSize The size of the Buffer in bytes. This must be a multiple
- of the intrinsic block size of the device.
- @param Buffer A pointer to the source buffer for the data.The caller
- is responsible for either having implicit or explicit
- ownership of the memory that data is written from.
-
- @retval EFI_SUCCESS Write Blocks successfully.
- @retval EFI_DEVICE_ERROR Write Blocks failed.
- @retval EFI_NO_MEDIA There is no media in the device.
- @retval EFI_MEDIA_CHANGE The MediaId is not for the current media.
-
- @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
- intrinsic block size of the device.
- @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
- or the data buffer is not valid.
-
- @note If Write Block error because of device error, this function will call
- AtaSoftReset() function to reset device.
-**/
-EFI_STATUS
-AtaBlkIoWriteBlocks (
- IN IDE_BLK_IO_DEV *IdeBlkIoDevice,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- );
-
-/**
- This function is called by DiscoverIdeDevice() during its device
- identification.
- Its main purpose is to get enough information for the device media
- to fill in the Media data structure of the Block I/O Protocol interface.
-
- There are 5 steps to reach such objective:
- 1. Sends out the ATAPI Identify Command to the specified device.
- Only ATAPI device responses to this command. If the command succeeds,
- it returns the Identify data structure which filled with information
- about the device. Since the ATAPI device contains removable media,
- the only meaningful information is the device module name.
- 2. Sends out ATAPI Inquiry Packet Command to the specified device.
- This command will return inquiry data of the device, which contains
- the device type information.
- 3. Allocate sense data space for future use. We don't detect the media
- presence here to improvement boot performance, especially when CD
- media is present. The media detection will be performed just before
- each BLK_IO read/write
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
-
- @retval EFI_SUCCESS Identify ATAPI device successfully.
- @retval EFI_DEVICE_ERROR ATAPI Identify Device Command failed or device type
- is not supported by this IDE driver.
- @retval EFI_OUT_OF_RESOURCES Allocate memory for sense data failed
-
- @note Parameter "IdeDev" will be updated in this function.
-**/
-EFI_STATUS
-ATAPIIdentify (
- IN IDE_BLK_IO_DEV *IdeDev
- );
-
-/**
- This function is used to implement the Soft Reset on the specified
- ATAPI device. Different from the AtaSoftReset(), here reset is a ATA
- Soft Reset Command special for ATAPI device, and it only take effects
- on the specified ATAPI device, not on the whole IDE bus.
- Since the ATAPI soft reset is needed when device is in exceptional
- condition (such as BSY bit is always set ), I think the Soft Reset
- command should be sent without waiting for the BSY clear and DRDY
- set.
- This function is called by IdeBlkIoReset(),
- a interface function of Block I/O protocol.
-
- @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
- to record all the information of the IDE device.
-
- @retval EFI_SUCCESS Soft reset completes successfully.
- @retval EFI_DEVICE_ERROR Any step during the reset process is failed.
-
-**/
-EFI_STATUS
-AtapiSoftReset (
- IN IDE_BLK_IO_DEV *IdeDev
- );
-
-/**
- This function is the ATAPI implementation for ReadBlocks in the
- Block I/O Protocol interface.
-
- @param IdeBlkIoDevice Indicates the calling context.
- @param MediaId The media id that the read request is for.
- @param Lba The starting logical block address to read from on the device.
- @param BufferSize The size of the Buffer in bytes. This must be a multiple
- of the intrinsic block size of the device.
- @param Buffer A pointer to the destination buffer for the data. The caller
- is responsible for either having implicit or explicit
- ownership of the memory that data is read into.
-
- @retval EFI_SUCCESS Read Blocks successfully.
- @retval EFI_DEVICE_ERROR Read Blocks failed.
- @retval EFI_NO_MEDIA There is no media in the device.
- @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
- @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
- intrinsic block size of the device.
- @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
- or the data buffer is not valid.
-**/
-EFI_STATUS
-AtapiBlkIoReadBlocks (
- IN IDE_BLK_IO_DEV *IdeBlkIoDevice,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- );
-
-/**
- This function is the ATAPI implementation for WriteBlocks in the
- Block I/O Protocol interface.
-
- @param IdeBlkIoDevice Indicates the calling context.
- @param MediaId The media id that the write request is for.
- @param Lba The starting logical block address to write onto the device.
- @param BufferSize The size of the Buffer in bytes. This must be a multiple
- of the intrinsic block size of the device.
- @param Buffer A pointer to the source buffer for the data. The caller
- is responsible for either having implicit or explicit ownership
- of the memory that data is written from.
-
- @retval EFI_SUCCESS Write Blocks successfully.
- @retval EFI_DEVICE_ERROR Write Blocks failed.
- @retval EFI_NO_MEDIA There is no media in the device.
- @retval EFI_MEDIA_CHANGE The MediaId is not for the current media.
- @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
- intrinsic block size of the device.
- @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
- or the data buffer is not valid.
-
- @retval EFI_WRITE_PROTECTED The write protected is enabled or the media does not support write
-**/
-EFI_STATUS
-AtapiBlkIoWriteBlocks (
- IN IDE_BLK_IO_DEV *IdeBlkIoDevice,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- );
-
-/**
- Release resources of an IDE device before stopping it.
-
- @param IdeBlkIoDevice Standard IDE device private data structure
-
-**/
-VOID
-ReleaseIdeResources (
- IN IDE_BLK_IO_DEV *IdeBlkIoDevice
- );
-
-/**
- Set the calculated Best transfer mode to a detected device
-
- @param IdeDev Standard IDE device private data structure
- @param TransferMode The device transfer mode to be set
- @return Set transfer mode Command execute status.
-**/
-EFI_STATUS
-SetDeviceTransferMode (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN ATA_TRANSFER_MODE *TransferMode
- );
-/**
- Send ATA command into device with NON_DATA protocol.
-
- @param IdeDev Standard IDE device private data structure
- @param AtaCommand The ATA command to be sent
- @param Device The value in Device register
- @param Feature The value in Feature register
- @param SectorCount The value in SectorCount register
- @param LbaLow The value in LBA_LOW register
- @param LbaMiddle The value in LBA_MIDDLE register
- @param LbaHigh The value in LBA_HIGH register
-
- @retval EFI_SUCCESS Reading succeed
- @retval EFI_ABORTED Command failed
- @retval EFI_DEVICE_ERROR Device status error.
-
-**/
-EFI_STATUS
-AtaNonDataCommandIn (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN UINT8 AtaCommand,
- IN UINT8 Device,
- IN UINT8 Feature,
- IN UINT8 SectorCount,
- IN UINT8 LbaLow,
- IN UINT8 LbaMiddle,
- IN UINT8 LbaHigh
- );
-
-/**
- Send ATA Ext command into device with NON_DATA protocol.
-
- @param IdeDev Standard IDE device private data structure
- @param AtaCommand The ATA command to be sent
- @param Device The value in Device register
- @param Feature The value in Feature register
- @param SectorCount The value in SectorCount register
- @param LbaAddress The Lba address in 48-bit mode
-
- @retval EFI_SUCCESS Reading succeed
- @retval EFI_ABORTED Command failed
- @retval EFI_DEVICE_ERROR Device status error.
-
-**/
-EFI_STATUS
-AtaNonDataCommandInExt (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN UINT8 AtaCommand,
- IN UINT8 Device,
- IN UINT16 Feature,
- IN UINT16 SectorCount,
- IN EFI_LBA LbaAddress
- );
-/**
- Enable Long Physical Sector Feature for ATA device.
-
- @param IdeDev The IDE device data
-
- @retval EFI_SUCCESS The ATA device supports Long Physical Sector feature
- and corresponding fields in BlockIo structure is updated.
- @retval EFI_UNSUPPORTED The device is not ATA device or Long Physical Sector
- feature is not supported.
-**/
-EFI_STATUS
-AtaEnableLongPhysicalSector (
- IN IDE_BLK_IO_DEV *IdeDev
- );
-
-/**
- Set drive parameters for devices not support PACKETS command.
-
- @param IdeDev Standard IDE device private data structure
- @param DriveParameters The device parameters to be set into the disk
- @return SetParameters Command execute status.
-
-**/
-EFI_STATUS
-SetDriveParameters (
- IN IDE_BLK_IO_DEV *IdeDev,
- IN ATA_DRIVE_PARMS *DriveParameters
- );
-
-/**
- Enable Interrupt on IDE controller.
-
- @param IdeDev Standard IDE device private data structure
-
- @retval EFI_SUCCESS Enable Interrupt successfully
-**/
-EFI_STATUS
-EnableInterrupt (
- IN IDE_BLK_IO_DEV *IdeDev
- );
-#endif
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.c b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.c deleted file mode 100644 index 82fd44f17d..0000000000 --- a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.c +++ /dev/null @@ -1,1571 +0,0 @@ -/** @file
- This file implement UEFI driver for IDE Bus which includes device identification,
- Child device(Disk, CDROM, etc) enumeration and child handler installation, and
- driver stop.
-
- Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
- 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.
-
- @par Revision Reference:
- This module is modified from DXE\IDE module for Ide Contriller Init support
-
-**/
-
-#include "IdeBus.h"
-
-#define PCI_CLASS_MASS_STORAGE 0x01
-#define PCI_SUB_CLASS_IDE 0x01
-
-
-//
-// IDE Bus Driver Binding Protocol Instance
-//
-EFI_DRIVER_BINDING_PROTOCOL gIDEBusDriverBinding = {
- IDEBusDriverBindingSupported,
- IDEBusDriverBindingStart,
- IDEBusDriverBindingStop,
- 0xa,
- NULL,
- NULL
-};
-/**
- Deregister an IDE device and free resources
-
- @param This Protocol instance pointer.
- @param Controller Ide device handle
- @param Handle Handle of device to deregister driver on
-
- @retval EFI_SUCCESS Deregiter a specific IDE device successfully
-
-
-**/
-EFI_STATUS
-DeRegisterIdeDevice (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_HANDLE Handle
- )
-{
- EFI_STATUS Status;
- EFI_BLOCK_IO_PROTOCOL *BlkIo;
- IDE_BLK_IO_DEV *IdeBlkIoDevice;
- EFI_PCI_IO_PROTOCOL *PciIo;
- UINTN Index;
-
- Status = gBS->OpenProtocol (
- Handle,
- &gEfiBlockIoProtocolGuid,
- (VOID **) &BlkIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_THIS (BlkIo);
-
- //
- // Report Status code: Device disabled
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- (EFI_IO_BUS_ATA_ATAPI | EFI_P_PC_DISABLE),
- IdeBlkIoDevice->DevicePath
- );
-
- //
- // Close the child handle
- //
- Status = gBS->CloseProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle,
- Handle
- );
-
- Status = gBS->UninstallMultipleProtocolInterfaces (
- Handle,
- &gEfiDevicePathProtocolGuid,
- IdeBlkIoDevice->DevicePath,
- &gEfiBlockIoProtocolGuid,
- &IdeBlkIoDevice->BlkIo,
- &gEfiDiskInfoProtocolGuid,
- &IdeBlkIoDevice->DiskInfo,
- NULL
- );
-
- if (EFI_ERROR (Status)) {
- gBS->OpenProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- (VOID **) &PciIo,
- This->DriverBindingHandle,
- Handle,
- EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
- );
- return Status;
- }
-
- //
- // Release allocated resources
- //
- Index = IdeBlkIoDevice->Channel * 2 + IdeBlkIoDevice->Device;
- if (Index < MAX_IDE_DEVICE) {
- IdeBlkIoDevice->IdeBusDriverPrivateData->HaveScannedDevice[Index] = FALSE;
- }
- ReleaseIdeResources (IdeBlkIoDevice);
-
- return EFI_SUCCESS;
-}
-/**
- Supported function of Driver Binding protocol for this driver.
-
- @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param ControllerHandle The handle of the controller to test.
- @param RemainingDevicePath A pointer to the remaining portion of a device path.
-
- @retval EFI_SUCCESS Driver loaded.
- @retval other Driver not loaded.
-
-**/
-EFI_STATUS
-EFIAPI
-IDEBusDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
- EFI_DEV_PATH *Node;
- EFI_IDE_CONTROLLER_INIT_PROTOCOL *IdeInit;
- EFI_PCI_IO_PROTOCOL *PciIo;
- PCI_TYPE00 PciData;
-
- if (RemainingDevicePath != NULL) {
- Node = (EFI_DEV_PATH *) RemainingDevicePath;
- //
- // Check if RemainingDevicePath is the End of Device Path Node,
- // if yes, go on checking other conditions
- //
- if (!IsDevicePathEnd (Node)) {
- //
- // If RemainingDevicePath isn't the End of Device Path Node,
- // check its validation
- //
- if (Node->DevPath.Type != MESSAGING_DEVICE_PATH ||
- Node->DevPath.SubType != MSG_ATAPI_DP ||
- DevicePathNodeLength(&Node->DevPath) != sizeof(ATAPI_DEVICE_PATH)) {
- return EFI_UNSUPPORTED;
- }
- }
- }
-
- //
- // Verify the Ide Controller Init Protocol, which installed by the
- // IdeController module.
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiIdeControllerInitProtocolGuid,
- (VOID **) &IdeInit,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
-
- if (Status == EFI_ALREADY_STARTED) {
- return EFI_SUCCESS;
- }
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Close the I/O Abstraction(s) used to perform the supported test
- //
- gBS->CloseProtocol (
- Controller,
- &gEfiIdeControllerInitProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- //
- // Open the EFI Device Path protocol needed to perform the supported test
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (Status == EFI_ALREADY_STARTED) {
- return EFI_SUCCESS;
- }
-
- //
- // Close protocol, don't use device path protocol in the Support() function
- //
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- //
- // Get the EfiPciIoProtocol
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- (VOID **) &PciIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Now further check the PCI header: Base class (offset 0x0B) and
- // Sub Class (offset 0x0A). This controller should be an IDE controller
- //
- Status = PciIo->Pci.Read (
- PciIo,
- EfiPciIoWidthUint8,
- 0,
- sizeof (PciData),
- &PciData
- );
-
- if (!EFI_ERROR (Status)) {
- //
- // Examine if it is IDE mode by class code
- //
- if ((PciData.Hdr.ClassCode[2] != PCI_CLASS_MASS_STORAGE) || (PciData.Hdr.ClassCode[1] != PCI_SUB_CLASS_IDE)) {
- Status = EFI_UNSUPPORTED;
- } else {
- Status = EFI_SUCCESS;
- }
- }
-
- return Status;
-}
-
-
-/**
- Start function of Driver binding protocol which start this driver on Controller
- by detecting all disks and installing BlockIo protocol on them.
-
- @param This Protocol instance pointer.
- @param Controller Handle of device to bind driver to.
- @param RemainingDevicePath produce all possible children.
-
- @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.
-
-**/
-EFI_STATUS
-EFIAPI
-IDEBusDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- EFI_STATUS Status;
- EFI_STATUS SavedStatus;
- EFI_PCI_IO_PROTOCOL *PciIo;
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
- EFI_DEV_PATH *Node;
- UINT8 IdeChannel;
- UINT8 BeginningIdeChannel;
- UINT8 EndIdeChannel;
- UINT8 IdeDevice;
- UINT8 BeginningIdeDevice;
- UINT8 EndIdeDevice;
- IDE_BLK_IO_DEV *IdeBlkIoDevice[IdeMaxChannel][IdeMaxDevice];
- IDE_BLK_IO_DEV *IdeBlkIoDevicePtr;
- IDE_REGISTERS_BASE_ADDR IdeRegsBaseAddr[IdeMaxChannel];
- ATA_TRANSFER_MODE TransferMode;
- ATA_DRIVE_PARMS DriveParameters;
- EFI_DEV_PATH NewNode;
- UINT8 ConfigurationOptions;
- UINT16 CommandBlockBaseAddr;
- UINT16 ControlBlockBaseAddr;
- UINTN DataSize;
- IDE_BUS_DRIVER_PRIVATE_DATA *IdeBusDriverPrivateData;
- UINT64 Supports;
-
- //
- // Local variables declaration for IdeControllerInit support
- //
- EFI_IDE_CONTROLLER_INIT_PROTOCOL *IdeInit;
- BOOLEAN EnumAll;
- BOOLEAN ChannelEnabled;
- UINT8 MaxDevices;
- EFI_IDENTIFY_DATA IdentifyData;
- EFI_ATA_COLLECTIVE_MODE *SupportedModes;
-
- IdeBusDriverPrivateData = NULL;
- SupportedModes = NULL;
-
- //
- // Perform IdeBus initialization
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- (VOID **) &ParentDevicePath,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if ((EFI_ERROR (Status)) && (Status != EFI_ALREADY_STARTED)) {
- return Status;
- }
-
- //
- // Now open the IDE_CONTROLLER_INIT protocol. Step7.1
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiIdeControllerInitProtocolGuid,
- (VOID **) &IdeInit,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
-
- //
- // The following OpenProtocol function with _GET_PROTOCOL attribute and
- // will not return EFI_ALREADY_STARTED, so save it for now
- //
- SavedStatus = Status;
-
- if ((EFI_ERROR (Status)) && (Status != EFI_ALREADY_STARTED)) {
- DEBUG ((EFI_D_ERROR, "Open Init, Status=%x", Status));
- //
- // open protocol is not SUCCESS or not ALREADY_STARTED, error exit
- //
- goto ErrorExit;
- }
-
- //
- // Save Enumall. Step7.2
- //
- EnumAll = IdeInit->EnumAll;
-
- //
- // Consume PCI I/O protocol. Note that the OpenProtocol with _GET_PROTOCOL
- // attribute will not return EFI_ALREADY_STARTED
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- (VOID **) &PciIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Open PciIo, Status=%x", Status));
- goto ErrorExit;
- }
-
- //
- // We must check EFI_ALREADY_STARTED because many ATAPI devices are removable
- //
- if (SavedStatus != EFI_ALREADY_STARTED) {
- IdeBusDriverPrivateData = AllocatePool (sizeof (IDE_BUS_DRIVER_PRIVATE_DATA));
- if (IdeBusDriverPrivateData == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto ErrorExit;
- }
-
- ZeroMem (IdeBusDriverPrivateData, sizeof (IDE_BUS_DRIVER_PRIVATE_DATA));
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Controller,
- &gEfiCallerIdGuid,
- IdeBusDriverPrivateData,
- NULL
- );
- if (EFI_ERROR (Status)) {
- goto ErrorExit;
- }
-
- } else {
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiCallerIdGuid,
- (VOID **) &IdeBusDriverPrivateData,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- IdeBusDriverPrivateData = NULL;
- goto ErrorExit;
- }
- }
-
- Status = PciIo->Attributes (
- PciIo,
- EfiPciIoAttributeOperationSupported,
- 0,
- &Supports
- );
- if (!EFI_ERROR (Status)) {
- Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;
- Status = PciIo->Attributes (
- PciIo,
- EfiPciIoAttributeOperationEnable,
- Supports,
- NULL
- );
- }
-
- if (EFI_ERROR (Status)) {
- goto ErrorExit;
- }
-
- //
- // Read the environment variable that contains the IDEBus Driver's
- // Config options that were set by the Driver Configuration Protocol
- //
- DataSize = sizeof (ConfigurationOptions);
- Status = gRT->GetVariable (
- (CHAR16 *) L"Configuration",
- &gEfiCallerIdGuid,
- NULL,
- &DataSize,
- &ConfigurationOptions
- );
- if (EFI_ERROR (Status)) {
- ConfigurationOptions = 0x0f;
- }
-
- if (EnumAll || RemainingDevicePath == NULL) {
- //
- // If IdeInit->EnumAll is TRUE or RemainingDevicePath is NULL,
- // must enumerate all IDE devices anyway
- //
- BeginningIdeChannel = IdePrimary;
- EndIdeChannel = IdeSecondary;
- BeginningIdeDevice = IdeMaster;
- EndIdeDevice = IdeSlave;
-
- } else if (!IsDevicePathEnd (RemainingDevicePath)) {
- //
- // If RemainingDevicePath isn't the End of Device Path Node,
- // only scan the specified device by RemainingDevicePath
- //
- Node = (EFI_DEV_PATH *) RemainingDevicePath;
- BeginningIdeChannel = Node->Atapi.PrimarySecondary;
- EndIdeChannel = BeginningIdeChannel;
- BeginningIdeDevice = Node->Atapi.SlaveMaster;
- EndIdeDevice = BeginningIdeDevice;
- if (BeginningIdeChannel >= IdeMaxChannel || EndIdeChannel >= IdeMaxChannel) {
- Status = EFI_INVALID_PARAMETER;
- goto ErrorExit;
- }
- if (BeginningIdeDevice >= IdeMaxDevice|| EndIdeDevice >= IdeMaxDevice) {
- Status = EFI_INVALID_PARAMETER;
- goto ErrorExit;
- }
-
- } else {
- //
- // If RemainingDevicePath is the End of Device Path Node,
- // skip enumerate any device and return EFI_SUCESSS
- //
- BeginningIdeChannel = IdeMaxChannel;
- EndIdeChannel = IdeMaxChannel - 1;
- BeginningIdeDevice = IdeMaxDevice;
- EndIdeDevice = IdeMaxDevice - 1;
- }
-
- //
- // Obtain IDE IO port registers' base addresses
- //
- Status = GetIdeRegistersBaseAddr (PciIo, IdeRegsBaseAddr);
- if (EFI_ERROR (Status)) {
- goto ErrorExit;
- }
-
- //
- // Report status code: begin IdeBus initialization
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_PC_RESET),
- ParentDevicePath
- );
-
- //
- // Strictly follow the enumeration based on IDE_CONTROLLER_INIT protocol
- //
- for (IdeChannel = BeginningIdeChannel; IdeChannel <= EndIdeChannel; IdeChannel++) {
-
- IdeInit->NotifyPhase (IdeInit, EfiIdeBeforeChannelEnumeration, IdeChannel);
-
- //
- // now obtain channel information fron IdeControllerInit protocol. Step9
- //
- Status = IdeInit->GetChannelInfo (
- IdeInit,
- IdeChannel,
- &ChannelEnabled,
- &MaxDevices
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "[GetChannel, Status=%x]", Status));
- continue;
- }
-
- if (!ChannelEnabled) {
- continue;
- }
-
- EndIdeDevice = (UINT8) MIN ((MaxDevices - 1), EndIdeDevice);
- ASSERT (EndIdeDevice < IdeMaxDevice);
- //
- // Now inform the IDE Controller Init Module. Sept10
- //
- IdeInit->NotifyPhase (IdeInit, EfiIdeBeforeChannelReset, IdeChannel);
-
- //
- // No reset channel function implemented. Sept11
- //
- IdeInit->NotifyPhase (IdeInit, EfiIdeAfterChannelReset, IdeChannel);
-
- //
- // Step13
- //
- IdeInit->NotifyPhase (
- IdeInit,
- EfiIdeBusBeforeDevicePresenceDetection,
- IdeChannel
- );
-
- //
- // Prepare to detect IDE device of this channel
- //
- InitializeIDEChannelData ();
-
- //
- // -- 1st inner loop --- Master/Slave ------------ Step14
- //
- for (IdeDevice = BeginningIdeDevice; IdeDevice <= EndIdeDevice; IdeDevice++) {
- //
- // Check whether the configuration options allow this device
- //
- if ((ConfigurationOptions & (1 << (IdeChannel * 2 + IdeDevice))) == 0) {
- continue;
- }
-
- //
- // The device has been scanned in another Start(), No need to scan it again
- // for perf optimization.
- //
- if (IdeBusDriverPrivateData->HaveScannedDevice[IdeChannel * 2 + IdeDevice]) {
- continue;
- }
-
- //
- // create child handle for the detected device.
- //
- IdeBlkIoDevice[IdeChannel][IdeDevice] = AllocatePool (sizeof (IDE_BLK_IO_DEV));
- if (IdeBlkIoDevice[IdeChannel][IdeDevice] == NULL) {
- continue;
- }
-
- IdeBlkIoDevicePtr = IdeBlkIoDevice[IdeChannel][IdeDevice];
-
- ZeroMem (IdeBlkIoDevicePtr, sizeof (IDE_BLK_IO_DEV));
-
- IdeBlkIoDevicePtr->Signature = IDE_BLK_IO_DEV_SIGNATURE;
- IdeBlkIoDevicePtr->Channel = (EFI_IDE_CHANNEL) IdeChannel;
- IdeBlkIoDevicePtr->Device = (EFI_IDE_DEVICE) IdeDevice;
-
- //
- // initialize Block IO interface's Media pointer
- //
- IdeBlkIoDevicePtr->BlkIo.Media = &IdeBlkIoDevicePtr->BlkMedia;
-
- //
- // Initialize IDE IO port addresses, including Command Block registers
- // and Control Block registers
- //
- IdeBlkIoDevicePtr->IoPort = AllocatePool (sizeof (IDE_BASE_REGISTERS));
- if (IdeBlkIoDevicePtr->IoPort == NULL) {
- continue;
- }
-
- ZeroMem (IdeBlkIoDevicePtr->IoPort, sizeof (IDE_BASE_REGISTERS));
- CommandBlockBaseAddr = IdeRegsBaseAddr[IdeChannel].CommandBlockBaseAddr;
- ControlBlockBaseAddr = IdeRegsBaseAddr[IdeChannel].ControlBlockBaseAddr;
-
- IdeBlkIoDevicePtr->IoPort->Data = CommandBlockBaseAddr;
- (*(UINT16 *) &IdeBlkIoDevicePtr->IoPort->Reg1) = (UINT16) (CommandBlockBaseAddr + 0x01);
- IdeBlkIoDevicePtr->IoPort->SectorCount = (UINT16) (CommandBlockBaseAddr + 0x02);
- IdeBlkIoDevicePtr->IoPort->SectorNumber = (UINT16) (CommandBlockBaseAddr + 0x03);
- IdeBlkIoDevicePtr->IoPort->CylinderLsb = (UINT16) (CommandBlockBaseAddr + 0x04);
- IdeBlkIoDevicePtr->IoPort->CylinderMsb = (UINT16) (CommandBlockBaseAddr + 0x05);
- IdeBlkIoDevicePtr->IoPort->Head = (UINT16) (CommandBlockBaseAddr + 0x06);
- (*(UINT16 *) &IdeBlkIoDevicePtr->IoPort->Reg) = (UINT16) (CommandBlockBaseAddr + 0x07);
-
- (*(UINT16 *) &IdeBlkIoDevicePtr->IoPort->Alt) = ControlBlockBaseAddr;
- IdeBlkIoDevicePtr->IoPort->DriveAddress = (UINT16) (ControlBlockBaseAddr + 0x01);
-
- IdeBlkIoDevicePtr->IoPort->MasterSlave = (UINT16) ((IdeDevice == IdeMaster) ? 1 : 0);
-
- IdeBlkIoDevicePtr->PciIo = PciIo;
- IdeBlkIoDevicePtr->IdeBusDriverPrivateData = IdeBusDriverPrivateData;
- IdeBlkIoDevicePtr->IoPort->BusMasterBaseAddr = IdeRegsBaseAddr[IdeChannel].BusMasterBaseAddr;
-
- //
- // Report Status code: is about to detect IDE drive
- //
- REPORT_STATUS_CODE_EX (
- EFI_PROGRESS_CODE,
- (EFI_IO_BUS_ATA_ATAPI | EFI_P_PC_PRESENCE_DETECT),
- 0,
- &gEfiCallerIdGuid,
- NULL,
- NULL,
- 0
- );
-
- //
- // Discover device, now!
- //
- PERF_START (NULL, "DiscoverIdeDevice", "IDE", 0);
- Status = DiscoverIdeDevice (IdeBlkIoDevicePtr);
- PERF_END (NULL, "DiscoverIdeDevice", "IDE", 0);
-
- IdeBusDriverPrivateData->HaveScannedDevice[IdeChannel * 2 + IdeDevice] = TRUE;
- IdeBusDriverPrivateData->DeviceProcessed[IdeChannel * 2 + IdeDevice] = FALSE;
-
- if (!EFI_ERROR (Status)) {
- //
- // Set Device Path
- //
- ZeroMem (&NewNode, sizeof (NewNode));
- NewNode.DevPath.Type = MESSAGING_DEVICE_PATH;
- NewNode.DevPath.SubType = MSG_ATAPI_DP;
- SetDevicePathNodeLength (&NewNode.DevPath, sizeof (ATAPI_DEVICE_PATH));
-
- NewNode.Atapi.PrimarySecondary = (UINT8) IdeBlkIoDevicePtr->Channel;
- NewNode.Atapi.SlaveMaster = (UINT8) IdeBlkIoDevicePtr->Device;
- NewNode.Atapi.Lun = IdeBlkIoDevicePtr->Lun;
- IdeBlkIoDevicePtr->DevicePath = AppendDevicePathNode (
- ParentDevicePath,
- &NewNode.DevPath
- );
- if (IdeBlkIoDevicePtr->DevicePath == NULL) {
- ReleaseIdeResources (IdeBlkIoDevicePtr);
- continue;
- }
-
- //
- // Submit identify data to IDE controller init driver
- //
- CopyMem (&IdentifyData, IdeBlkIoDevicePtr->IdData, sizeof (IdentifyData));
- IdeBusDriverPrivateData->DeviceFound[IdeChannel * 2 + IdeDevice] = TRUE;
- IdeInit->SubmitData (IdeInit, IdeChannel, IdeDevice, &IdentifyData);
- } else {
- //
- // Device detection failed
- //
- IdeBusDriverPrivateData->DeviceFound[IdeChannel * 2 + IdeDevice] = FALSE;
- IdeInit->SubmitData (IdeInit, IdeChannel, IdeDevice, NULL);
- ReleaseIdeResources (IdeBlkIoDevicePtr);
- IdeBlkIoDevicePtr = NULL;
- }
- //
- // end of 1st inner loop ---
- //
- }
- //
- // end of 1st outer loop =========
- //
- }
-
- //
- // = 2nd outer loop == Primary/Secondary =================
- //
- for (IdeChannel = BeginningIdeChannel; IdeChannel <= EndIdeChannel; IdeChannel++) {
-
- //
- // -- 2nd inner loop --- Master/Slave --------
- //
- for (IdeDevice = BeginningIdeDevice; IdeDevice <= EndIdeDevice; IdeDevice++) {
-
- ASSERT (IdeChannel * 2 + IdeDevice < MAX_IDE_DEVICE);
- if (IdeBusDriverPrivateData->DeviceProcessed[IdeChannel * 2 + IdeDevice]) {
- continue;
- }
-
- if (!IdeBusDriverPrivateData->DeviceFound[IdeChannel * 2 + IdeDevice]) {
- continue;
- }
-
- Status = IdeInit->CalculateMode (
- IdeInit,
- IdeChannel,
- IdeDevice,
- &SupportedModes
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "[bStStp20S=%x]", Status));
- continue;
- }
-
- ASSERT (IdeChannel < IdeMaxChannel && IdeDevice < IdeMaxDevice);
- IdeBlkIoDevicePtr = IdeBlkIoDevice[IdeChannel][IdeDevice];
-
- //
- // Set best supported PIO mode on this IDE device
- //
- if (SupportedModes->PioMode.Mode <= AtaPioMode2) {
- TransferMode.ModeCategory = ATA_MODE_CATEGORY_DEFAULT_PIO;
- } else {
- TransferMode.ModeCategory = ATA_MODE_CATEGORY_FLOW_PIO;
- }
-
- TransferMode.ModeNumber = (UINT8) (SupportedModes->PioMode.Mode);
-
- if (SupportedModes->ExtModeCount == 0){
- Status = SetDeviceTransferMode (IdeBlkIoDevicePtr, &TransferMode);
-
- if (EFI_ERROR (Status)) {
- IdeBusDriverPrivateData->DeviceFound[IdeChannel * 2 + IdeDevice] = FALSE;
- ReleaseIdeResources (IdeBlkIoDevicePtr);
- IdeBlkIoDevicePtr = NULL;
- continue;
- }
- }
-
- //
- // Set supported DMA mode on this IDE device. Note that UDMA & MDMA cann't
- // be set together. Only one DMA mode can be set to a device. If setting
- // DMA mode operation fails, we can continue moving on because we only use
- // PIO mode at boot time. DMA modes are used by certain kind of OS booting
- //
- if (SupportedModes->UdmaMode.Valid) {
-
- TransferMode.ModeCategory = ATA_MODE_CATEGORY_UDMA;
- TransferMode.ModeNumber = (UINT8) (SupportedModes->UdmaMode.Mode);
- Status = SetDeviceTransferMode (IdeBlkIoDevicePtr, &TransferMode);
-
- if (EFI_ERROR (Status)) {
- IdeBusDriverPrivateData->DeviceFound[IdeChannel * 2 + IdeDevice] = FALSE;
- ReleaseIdeResources (IdeBlkIoDevicePtr);
- IdeBlkIoDevicePtr = NULL;
- continue;
- }
- //
- // Record Udma Mode
- //
- IdeBlkIoDevicePtr->UdmaMode.Valid = TRUE;
- IdeBlkIoDevicePtr->UdmaMode.Mode = SupportedModes->UdmaMode.Mode;
- EnableInterrupt (IdeBlkIoDevicePtr);
- } else if (SupportedModes->MultiWordDmaMode.Valid) {
-
- TransferMode.ModeCategory = ATA_MODE_CATEGORY_MDMA;
- TransferMode.ModeNumber = (UINT8) SupportedModes->MultiWordDmaMode.Mode;
- Status = SetDeviceTransferMode (IdeBlkIoDevicePtr, &TransferMode);
-
- if (EFI_ERROR (Status)) {
- IdeBusDriverPrivateData->DeviceFound[IdeChannel * 2 + IdeDevice] = FALSE;
- ReleaseIdeResources (IdeBlkIoDevicePtr);
- IdeBlkIoDevicePtr = NULL;
- continue;
- }
-
- EnableInterrupt (IdeBlkIoDevicePtr);
- }
- //
- // Init driver parameters
- //
- DriveParameters.Sector = (UINT8) ((ATA5_IDENTIFY_DATA *) IdeBlkIoDevicePtr->IdData)->sectors_per_track;
- DriveParameters.Heads = (UINT8) (((ATA5_IDENTIFY_DATA *) IdeBlkIoDevicePtr->IdData)->heads - 1);
- DriveParameters.MultipleSector = (UINT8) IdeBlkIoDevicePtr->IdData->AtaData.multi_sector_cmd_max_sct_cnt;
- //
- // Set Parameters for the device:
- // 1) Init
- // 2) Establish the block count for READ/WRITE MULTIPLE (EXT) command
- //
- if ((IdeBlkIoDevicePtr->Type == IdeHardDisk) || (IdeBlkIoDevicePtr->Type == Ide48bitAddressingHardDisk)) {
- Status = SetDriveParameters (IdeBlkIoDevicePtr, &DriveParameters);
- }
-
- //
- // Record PIO mode used in private data
- //
- IdeBlkIoDevicePtr->PioMode = (ATA_PIO_MODE) SupportedModes->PioMode.Mode;
-
- //
- // Set IDE controller Timing Blocks in the PCI Configuration Space
- //
- IdeInit->SetTiming (IdeInit, IdeChannel, IdeDevice, SupportedModes);
-
- //
- // Add Component Name for the IDE/ATAPI device that was discovered.
- //
- IdeBlkIoDevicePtr->ControllerNameTable = NULL;
- ADD_IDE_ATAPI_NAME (IdeBlkIoDevicePtr);
-
- Status = gBS->InstallMultipleProtocolInterfaces (
- &IdeBlkIoDevicePtr->Handle,
- &gEfiDevicePathProtocolGuid,
- IdeBlkIoDevicePtr->DevicePath,
- &gEfiBlockIoProtocolGuid,
- &IdeBlkIoDevicePtr->BlkIo,
- &gEfiDiskInfoProtocolGuid,
- &IdeBlkIoDevicePtr->DiskInfo,
- NULL
- );
-
- if (EFI_ERROR (Status)) {
- ReleaseIdeResources (IdeBlkIoDevicePtr);
- }
-
- gBS->OpenProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- (VOID **) &PciIo,
- This->DriverBindingHandle,
- IdeBlkIoDevicePtr->Handle,
- EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
- );
-
- IdeBusDriverPrivateData->DeviceProcessed[IdeChannel * 2 + IdeDevice] = TRUE;
-
- //
- // Report status code: device eanbled!
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_PROGRESS_CODE,
- (EFI_IO_BUS_ATA_ATAPI | EFI_P_PC_ENABLE),
- IdeBlkIoDevicePtr->DevicePath
- );
-
- //
- // Create event to clear pending IDE interrupt
- //
- Status = gBS->CreateEventEx (
- EVT_NOTIFY_SIGNAL,
- TPL_NOTIFY,
- ClearInterrupt,
- IdeBlkIoDevicePtr,
- &gEfiEventExitBootServicesGuid,
- &IdeBlkIoDevicePtr->ExitBootServiceEvent
- );
-
- //
- // end of 2nd inner loop ----
- //
- }
- //
- // end of 2nd outer loop ==========
- //
- }
-
- //
- // All configurations done! Notify IdeController to do post initialization
- // work such as saving IDE controller PCI settings for S3 resume
- //
- IdeInit->NotifyPhase (IdeInit, EfiIdeBusPhaseMaximum, 0);
-
- if (SupportedModes != NULL) {
- FreePool (SupportedModes);
- }
-
- PERF_START (NULL, "Finish IDE detection", "IDE", 1);
- PERF_END (NULL, "Finish IDE detection", "IDE", 0);
-
- return EFI_SUCCESS;
-
-ErrorExit:
-
- //
- // Report error code: controller error
- //
- REPORT_STATUS_CODE_WITH_DEVICE_PATH (
- EFI_ERROR_CODE | EFI_ERROR_MINOR,
- (EFI_IO_BUS_ATA_ATAPI | EFI_IOB_EC_CONTROLLER_ERROR),
- ParentDevicePath
- );
-
- gBS->CloseProtocol (
- Controller,
- &gEfiIdeControllerInitProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- gBS->UninstallMultipleProtocolInterfaces (
- Controller,
- &gEfiCallerIdGuid,
- IdeBusDriverPrivateData,
- NULL
- );
-
- if (IdeBusDriverPrivateData != NULL) {
- gBS->FreePool (IdeBusDriverPrivateData);
- }
-
- if (SupportedModes != NULL) {
- gBS->FreePool (SupportedModes);
- }
-
- gBS->CloseProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- return Status;
-
-}
-/**
- Stop function of Driver Binding Protocol which is to stop the driver on Controller Handle and all
- child handle attached to the controller handle if there are.
-
- @param This Protocol instance pointer.
- @param Controller Handle of device to stop driver on
- @param NumberOfChildren Not used
- @param ChildHandleBuffer Not used
-
- @retval EFI_SUCCESS This driver is removed DeviceHandle
- @retval other This driver was not removed from this device
-
-**/
-EFI_STATUS
-EFIAPI
-IDEBusDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- )
-{
- EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL *PciIo;
- BOOLEAN AllChildrenStopped;
- UINTN Index;
- IDE_BUS_DRIVER_PRIVATE_DATA *IdeBusDriverPrivateData;
- UINT64 Supports;
-
- IdeBusDriverPrivateData = NULL;
-
- if (NumberOfChildren == 0) {
-
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- (VOID **) &PciIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (!EFI_ERROR (Status)) {
- Status = PciIo->Attributes (
- PciIo,
- EfiPciIoAttributeOperationSupported,
- 0,
- &Supports
- );
- if (!EFI_ERROR (Status)) {
- Supports &= (UINT64)(EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO | EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO | EFI_PCI_DEVICE_ENABLE);
- PciIo->Attributes (
- PciIo,
- EfiPciIoAttributeOperationDisable,
- Supports,
- NULL
- );
- }
- }
-
- gBS->OpenProtocol (
- Controller,
- &gEfiCallerIdGuid,
- (VOID **) &IdeBusDriverPrivateData,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
-
- gBS->UninstallMultipleProtocolInterfaces (
- Controller,
- &gEfiCallerIdGuid,
- IdeBusDriverPrivateData,
- NULL
- );
-
- if (IdeBusDriverPrivateData != NULL) {
- gBS->FreePool (IdeBusDriverPrivateData);
- }
- //
- // Close the bus driver
- //
- gBS->CloseProtocol (
- Controller,
- &gEfiIdeControllerInitProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- gBS->CloseProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- return EFI_SUCCESS;
- }
-
- AllChildrenStopped = TRUE;
-
- for (Index = 0; Index < NumberOfChildren; Index++) {
-
- Status = DeRegisterIdeDevice (This, Controller, ChildHandleBuffer[Index]);
-
- if (EFI_ERROR (Status)) {
- AllChildrenStopped = FALSE;
- }
- }
-
- if (!AllChildrenStopped) {
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- issue ATA or ATAPI command to reset a block IO device.
- @param This Block IO protocol instance pointer.
- @param ExtendedVerification If FALSE,for ATAPI device, driver will only invoke ATAPI reset method
- If TRUE, for ATAPI device, driver need invoke ATA reset method after
- invoke ATAPI reset method
-
- @retval EFI_DEVICE_ERROR When the device is neighther ATA device or ATAPI device.
- @retval EFI_SUCCESS The device reset successfully
-
-**/
-EFI_STATUS
-EFIAPI
-IDEBlkIoReset (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- )
-{
- IDE_BLK_IO_DEV *IdeBlkIoDevice;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
-
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
-
- IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_THIS (This);
- //
- // Requery IDE IO resources in case of the switch of native and legacy modes
- //
- ReassignIdeResources (IdeBlkIoDevice);
-
- //
- // for ATA device, using ATA reset method
- //
- if (IdeBlkIoDevice->Type == IdeHardDisk ||
- IdeBlkIoDevice->Type == Ide48bitAddressingHardDisk) {
- Status = AtaSoftReset (IdeBlkIoDevice);
- goto Done;
- }
-
- if (IdeBlkIoDevice->Type == IdeUnknown) {
- Status = EFI_DEVICE_ERROR;
- goto Done;
- }
-
- //
- // for ATAPI device, using ATAPI reset method
- //
- Status = AtapiSoftReset (IdeBlkIoDevice);
- if (ExtendedVerification) {
- Status = AtaSoftReset (IdeBlkIoDevice);
- }
-
-Done:
- gBS->RestoreTPL (OldTpl);
- return Status;
-}
-
-/**
- Read data from a block IO device
-
- @param This Block IO protocol instance pointer.
- @param MediaId The media ID of the device
- @param Lba Starting LBA address to read data
- @param BufferSize The size of data to be read
- @param Buffer Caller supplied buffer to save data
-
- @retval EFI_DEVICE_ERROR unknown device type
- @retval other read data status.
-
-**/
-EFI_STATUS
-EFIAPI
-IDEBlkIoReadBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- )
-{
- IDE_BLK_IO_DEV *IdeBlkIoDevice;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
-
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
-
- IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_THIS (This);
-
- //
- // Requery IDE IO resources in case of the switch of native and legacy modes
- //
- ReassignIdeResources (IdeBlkIoDevice);
-
- //
- // For ATA compatible device, use ATA read block's mechanism
- //
- if (IdeBlkIoDevice->Type == IdeHardDisk ||
- IdeBlkIoDevice->Type == Ide48bitAddressingHardDisk) {
- Status = AtaBlkIoReadBlocks (
- IdeBlkIoDevice,
- MediaId,
- Lba,
- BufferSize,
- Buffer
- );
- goto Done;
- }
-
- if (IdeBlkIoDevice->Type == IdeUnknown) {
- Status = EFI_DEVICE_ERROR;
- goto Done;
- }
-
- //
- // for ATAPI device, using ATAPI read block's mechanism
- //
- Status = AtapiBlkIoReadBlocks (
- IdeBlkIoDevice,
- MediaId,
- Lba,
- BufferSize,
- Buffer
- );
-
-Done:
- gBS->RestoreTPL (OldTpl);
-
- return Status;
-}
-
-/**
- Write data to block io device.
-
- @param This Protocol instance pointer.
- @param MediaId The media ID of the device
- @param Lba Starting LBA address to write data
- @param BufferSize The size of data to be written
- @param Buffer Caller supplied buffer to save data
-
- @retval EFI_DEVICE_ERROR unknown device type
- @retval other write data status
-
-**/
-EFI_STATUS
-EFIAPI
-IDEBlkIoWriteBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- IN VOID *Buffer
- )
-{
- IDE_BLK_IO_DEV *IdeBlkIoDevice;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
-
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
-
- IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_THIS (This);
- //
- // Requery IDE IO resources in case of the switch of native and legacy modes
- //
- ReassignIdeResources (IdeBlkIoDevice);
-
- //
- // for ATA device, using ATA write block's mechanism
- //
- if (IdeBlkIoDevice->Type == IdeHardDisk ||
- IdeBlkIoDevice->Type == Ide48bitAddressingHardDisk) {
-
- Status = AtaBlkIoWriteBlocks (
- IdeBlkIoDevice,
- MediaId,
- Lba,
- BufferSize,
- Buffer
- );
- goto Done;
- }
-
- if (IdeBlkIoDevice->Type == IdeUnknown) {
- Status = EFI_DEVICE_ERROR;
- goto Done;
- }
-
- //
- // for ATAPI device, using ATAPI write block's mechanism
- //
- Status = AtapiBlkIoWriteBlocks (
- IdeBlkIoDevice,
- MediaId,
- Lba,
- BufferSize,
- Buffer
- );
-
-Done:
- gBS->RestoreTPL (OldTpl);
- return Status;
-}
-/**
- Flushes all modified data to a physical block devices
-
- @param This Indicates a pointer to the calling context which to sepcify a
- sepcific block device
-
- @retval EFI_SUCCESS Always return success.
-**/
-EFI_STATUS
-EFIAPI
-IDEBlkIoFlushBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This
- )
-{
- //
- // return directly
- //
- return EFI_SUCCESS;
-}
-
-/**
- This function is used by the IDE bus driver to get inquiry data.
- Data format of Identify data is defined by the Interface GUID.
-
- @param This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
- @param InquiryData Pointer to a buffer for the inquiry data.
- @param InquiryDataSize Pointer to the value for the inquiry data size.
-
- @retval EFI_SUCCESS The command was accepted without any errors.
- @retval EFI_NOT_FOUND Device does not support this data class
- @retval EFI_DEVICE_ERROR Error reading InquiryData from device
- @retval EFI_BUFFER_TOO_SMALL IntquiryDataSize not big enough
-
-**/
-EFI_STATUS
-EFIAPI
-IDEDiskInfoInquiry (
- IN EFI_DISK_INFO_PROTOCOL *This,
- IN OUT VOID *InquiryData,
- IN OUT UINT32 *InquiryDataSize
- )
-{
- IDE_BLK_IO_DEV *IdeBlkIoDevice;
-
- IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_DISK_INFO_THIS (This);
-
- if (*InquiryDataSize < sizeof (ATAPI_INQUIRY_DATA)) {
- *InquiryDataSize = sizeof (ATAPI_INQUIRY_DATA);
- return EFI_BUFFER_TOO_SMALL;
- }
-
- if (IdeBlkIoDevice->InquiryData == NULL) {
- return EFI_NOT_FOUND;
- }
-
- gBS->CopyMem (InquiryData, IdeBlkIoDevice->InquiryData, sizeof (ATAPI_INQUIRY_DATA));
- *InquiryDataSize = sizeof (ATAPI_INQUIRY_DATA);
-
- return EFI_SUCCESS;
-}
-
-/**
- This function is used by the IDE bus driver to get identify data.
- Data format of Identify data is defined by the Interface GUID.
-
- @param This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
- @param IdentifyData Pointer to a buffer for the identify data.
- @param IdentifyDataSize Pointer to the value for the identify data size.
-
- @retval EFI_SUCCESS The command was accepted without any errors.
- @retval EFI_NOT_FOUND Device does not support this data class
- @retval EFI_DEVICE_ERROR Error reading IdentifyData from device
- @retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough
-
-**/
-EFI_STATUS
-EFIAPI
-IDEDiskInfoIdentify (
- IN EFI_DISK_INFO_PROTOCOL *This,
- IN OUT VOID *IdentifyData,
- IN OUT UINT32 *IdentifyDataSize
- )
-{
- IDE_BLK_IO_DEV *IdeBlkIoDevice;
-
- IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_DISK_INFO_THIS (This);
-
- if (*IdentifyDataSize < sizeof (EFI_IDENTIFY_DATA)) {
- *IdentifyDataSize = sizeof (EFI_IDENTIFY_DATA);
- return EFI_BUFFER_TOO_SMALL;
- }
-
- if (IdeBlkIoDevice->IdData == NULL) {
- return EFI_NOT_FOUND;
- }
-
- gBS->CopyMem (IdentifyData, IdeBlkIoDevice->IdData, sizeof (EFI_IDENTIFY_DATA));
- *IdentifyDataSize = sizeof (EFI_IDENTIFY_DATA);
-
- return EFI_SUCCESS;
-}
-
-/**
- This function is used by the IDE bus driver to get sense data.
- Data format of Sense data is defined by the Interface GUID.
-
- @param This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
- @param SenseData Pointer to the SenseData.
- @param SenseDataSize Size of SenseData in bytes.
- @param SenseDataNumber Pointer to the value for the identify data size.
-
- @retval EFI_SUCCESS The command was accepted without any errors.
- @retval EFI_NOT_FOUND Device does not support this data class
- @retval EFI_DEVICE_ERROR Error reading InquiryData from device
- @retval EFI_BUFFER_TOO_SMALL SenseDataSize not big enough
-
-**/
-EFI_STATUS
-EFIAPI
-IDEDiskInfoSenseData (
- IN EFI_DISK_INFO_PROTOCOL *This,
- IN OUT VOID *SenseData,
- IN OUT UINT32 *SenseDataSize,
- OUT UINT8 *SenseDataNumber
- )
-{
- return EFI_NOT_FOUND;
-}
-
-/**
- This function is used by the IDE bus driver to get controller information.
-
- @param This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
- @param IdeChannel Pointer to the Ide Channel number. Primary or secondary.
- @param IdeDevice Pointer to the Ide Device number. Master or slave.
-
- @retval EFI_SUCCESS IdeChannel and IdeDevice are valid
- @retval EFI_UNSUPPORTED This is not an IDE device
-
-**/
-EFI_STATUS
-EFIAPI
-IDEDiskInfoWhichIde (
- IN EFI_DISK_INFO_PROTOCOL *This,
- OUT UINT32 *IdeChannel,
- OUT UINT32 *IdeDevice
- )
-{
- IDE_BLK_IO_DEV *IdeBlkIoDevice;
-
- IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_DISK_INFO_THIS (This);
- *IdeChannel = IdeBlkIoDevice->Channel;
- *IdeDevice = IdeBlkIoDevice->Device;
-
- return EFI_SUCCESS;
-}
-
-/**
- The is an event(generally the event is exitBootService event) call back function.
- Clear pending IDE interrupt before OS loader/kernel take control of the IDE device.
-
- @param Event Pointer to this event
- @param Context Event handler private data
-
-**/
-VOID
-EFIAPI
-ClearInterrupt (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- EFI_STATUS Status;
- UINT64 IoPortForBmis;
- UINT8 RegisterValue;
- IDE_BLK_IO_DEV *IdeDev;
-
- //
- // Get our context
- //
- IdeDev = (IDE_BLK_IO_DEV *) Context;
-
- //
- // Obtain IDE IO port registers' base addresses
- //
- Status = ReassignIdeResources (IdeDev);
- if (EFI_ERROR (Status)) {
- return;
- }
-
- //
- // Check whether interrupt is pending
- //
-
- //
- // Reset IDE device to force it de-assert interrupt pin
- // Note: this will reset all devices on this IDE channel
- //
- Status = AtaSoftReset (IdeDev);
- if (EFI_ERROR (Status)) {
- return;
- }
-
- //
- // Get base address of IDE Bus Master Status Regsiter
- //
- if (IdePrimary == IdeDev->Channel) {
- IoPortForBmis = IdeDev->IoPort->BusMasterBaseAddr + BMISP_OFFSET;
- } else {
- if (IdeSecondary == IdeDev->Channel) {
- IoPortForBmis = IdeDev->IoPort->BusMasterBaseAddr + BMISS_OFFSET;
- } else {
- return;
- }
- }
- //
- // Read BMIS register and clear ERROR and INTR bit
- //
- IdeDev->PciIo->Io.Read (
- IdeDev->PciIo,
- EfiPciIoWidthUint8,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- IoPortForBmis,
- 1,
- &RegisterValue
- );
-
- RegisterValue |= (BMIS_INTERRUPT | BMIS_ERROR);
-
- IdeDev->PciIo->Io.Write (
- IdeDev->PciIo,
- EfiPciIoWidthUint8,
- EFI_PCI_IO_PASS_THROUGH_BAR,
- IoPortForBmis,
- 1,
- &RegisterValue
- );
-
- //
- // Select the other device on this channel to ensure this device to release the interrupt pin
- //
- if (IdeDev->Device == 0) {
- RegisterValue = (1 << 4) | 0xe0;
- } else {
- RegisterValue = (0 << 4) | 0xe0;
- }
- IDEWritePortB (
- IdeDev->PciIo,
- IdeDev->IoPort->Head,
- RegisterValue
- );
-
-}
-
-/**
- The user Entry Point for module IdeBus. The user code starts with this function.
-
- @param[in] ImageHandle The firmware allocated handle for the EFI image.
- @param[in] SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The entry point is executed successfully.
- @retval other Some error occurs when executing this entry point.
-
-**/
-EFI_STATUS
-EFIAPI
-InitializeIdeBus(
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- //
- // Install driver model protocol(s).
- //
- Status = EfiLibInstallAllDriverProtocols2 (
- ImageHandle,
- SystemTable,
- &gIDEBusDriverBinding,
- ImageHandle,
- &gIDEBusComponentName,
- &gIDEBusComponentName2,
- NULL,
- NULL,
- &gIDEBusDriverDiagnostics,
- &gIDEBusDriverDiagnostics2
- );
- ASSERT_EFI_ERROR (Status);
-
- return Status;
-}
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.h b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.h deleted file mode 100644 index a3db16ca85..0000000000 --- a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBus.h +++ /dev/null @@ -1,540 +0,0 @@ -/** @file
- Header file for IDE Bus Driver.
-
- Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
- 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.
-
-**/
-
-#ifndef _IDE_BUS_H_
-#define _IDE_BUS_H_
-
-
-
-#include <FrameworkDxe.h>
-
-#include <Protocol/IdeControllerInit.h>
-#include <Protocol/BlockIo.h>
-#include <Protocol/PciIo.h>
-#include <Protocol/DiskInfo.h>
-#include <Protocol/DevicePath.h>
-
-#include <Library/DebugLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/BaseLib.h>
-#include <Library/UefiLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/ReportStatusCodeLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/PerformanceLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/DevicePathLib.h>
-
-#include <Guid/EventGroup.h>
-
-#include <IndustryStandard/Pci.h>
-#include "IdeData.h"
-
-//
-// Global Variables
-//
-extern EFI_DRIVER_BINDING_PROTOCOL gIDEBusDriverBinding;
-extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL gIDEBusDriverDiagnostics;
-extern EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gIDEBusDriverDiagnostics2;
-
-//
-// Extra Definition to porting
-//
-#define MAX_IDE_DEVICE 4
-#define MAX_IDE_CHANNELS 2
-#define MAX_IDE_DRIVES 2
-
-#define INVALID_DEVICE_TYPE 0xff
-#define ATA_DEVICE_TYPE 0x00
-#define ATAPI_DEVICE_TYPE 0x01
-
-typedef struct {
- BOOLEAN HaveScannedDevice[MAX_IDE_DEVICE];
- BOOLEAN DeviceFound[MAX_IDE_DEVICE];
- BOOLEAN DeviceProcessed[MAX_IDE_DEVICE];
-} IDE_BUS_DRIVER_PRIVATE_DATA;
-
-#define IDE_BLK_IO_DEV_SIGNATURE SIGNATURE_32 ('i', 'b', 'i', 'd')
-
-typedef struct {
- UINT32 Signature;
-
- EFI_HANDLE Handle;
- EFI_BLOCK_IO_PROTOCOL BlkIo;
- EFI_BLOCK_IO_MEDIA BlkMedia;
- EFI_DISK_INFO_PROTOCOL DiskInfo;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_PCI_IO_PROTOCOL *PciIo;
- IDE_BUS_DRIVER_PRIVATE_DATA *IdeBusDriverPrivateData;
-
- //
- // Local Data for IDE interface goes here
- //
- EFI_IDE_CHANNEL Channel;
- EFI_IDE_DEVICE Device;
- UINT16 Lun;
- IDE_DEVICE_TYPE Type;
-
- IDE_BASE_REGISTERS *IoPort;
- UINT16 AtapiError;
-
- ATAPI_INQUIRY_DATA *InquiryData;
- EFI_IDENTIFY_DATA *IdData;
- ATA_PIO_MODE PioMode;
- EFI_ATA_MODE UdmaMode;
- CHAR8 ModelName[41];
- ATAPI_REQUEST_SENSE_DATA *SenseData;
- UINT8 SenseDataNumber;
- UINT8 *Cache;
-
- //
- // ExitBootService Event, it is used to clear pending IDE interrupt
- //
- EFI_EVENT ExitBootServiceEvent;
-
- EFI_UNICODE_STRING_TABLE *ControllerNameTable;
-} IDE_BLK_IO_DEV;
-
-#include "ComponentName.h"
-
-#define IDE_BLOCK_IO_DEV_FROM_THIS(a) CR (a, IDE_BLK_IO_DEV, BlkIo, IDE_BLK_IO_DEV_SIGNATURE)
-#define IDE_BLOCK_IO_DEV_FROM_DISK_INFO_THIS(a) CR (a, IDE_BLK_IO_DEV, DiskInfo, IDE_BLK_IO_DEV_SIGNATURE)
-
-#include "Ide.h"
-
-
-/**
- Supported function of Driver Binding protocol for this driver.
-
- @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
- @param ControllerHandle The handle of the controller to test.
- @param RemainingDevicePath A pointer to the remaining portion of a device path.
-
- @retval EFI_SUCCESS Driver loaded.
- @retval other Driver not loaded.
-
-**/
-EFI_STATUS
-EFIAPI
-IDEBusDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-/**
- Start function of Driver binding protocol which start this driver on Controller
- by detecting all disks and installing BlockIo protocol on them.
-
- @param This Protocol instance pointer.
- @param Controller Handle of device to bind driver to.
- @param RemainingDevicePath produce all possible children.
-
- @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.
-
-**/
-EFI_STATUS
-EFIAPI
-IDEBusDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-/**
- Stop function of Driver Binding Protocol which is to stop the driver on Controller Handle and all
- child handle attached to the controller handle if there are.
-
- @param This Protocol instance pointer.
- @param Controller Handle of device to stop driver on
- @param NumberOfChildren Not used
- @param ChildHandleBuffer Not used
-
- @retval EFI_SUCCESS This driver is removed DeviceHandle
- @retval other This driver was not removed from this device
-
-**/
-EFI_STATUS
-EFIAPI
-IDEBusDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- );
-
-//
-// EFI Driver Configuration Functions
-//
-/**
- Allows the user to set controller specific options for a controller that a
- driver is currently managing.
-
- @param This A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.
- @param ControllerHandle The handle of the controller to set options on.
- @param ChildHandle The handle of the child controller to set options on.
- This is an optional parameter that may be NULL.
- It will be NULL for device drivers, and for a bus drivers
- that wish to set options for the bus controller.
- It will not be NULL for a bus driver that wishes to set
- options for one of its child controllers.
- @param Language A pointer to a three character ISO 639-2 language identifier.
- This is the language of the user interface that should be presented
- to the user, and it must match one of the languages specified in
- SupportedLanguages. The number of languages supported by a driver is up to
- the driver writer.
- @param ActionRequired A pointer to the action that the calling agent is required
- to perform when this function returns.
-
-
- @retval EFI_SUCCESS The driver specified by This successfully set the configuration
- options for the controller specified by ControllerHandle..
- @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
- @retval EFI_INVALID_PARAMETER ActionRequired is NULL.
- @retval EFI_UNSUPPORTED The driver specified by This does not support setting configuration options for
- the controller specified by ControllerHandle and ChildHandle.
- @retval EFI_UNSUPPORTED The driver specified by This does not support the language specified by Language.
- @retval EFI_DEVICE_ERROR A device error occurred while attempt to set the configuration options for the
- controller specified by ControllerHandle and ChildHandle.
- @retval EFI_OUT_RESOURCES There are not enough resources available to set the configuration options for the
- controller specified by ControllerHandle and ChildHandle
-**/
-EFI_STATUS
-EFIAPI
-IDEBusDriverConfigurationSetOptions (
- IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired
- );
-
-/**
- Tests to see if a controller's current configuration options are valid.
-
- @param This A pointer to the EFI_DRIVER_CONFIGURATION_PROTOCOL instance.
- @param ControllerHandle The handle of the controller to test if it's current configuration options
- are valid.
- @param ChildHandle The handle of the child controller to test if it's current configuration
- options are valid. This is an optional parameter that may be NULL. It will
- be NULL for device drivers. It will also be NULL for a bus drivers that
- wish to test the configuration options for the bus controller. It will
- not be NULL for a bus driver that wishes to test configuration options for
- one of its child controllers.
- @retval EFI_SUCCESS The controller specified by ControllerHandle and ChildHandle that is being
- managed by the driver specified by This has a valid set of configuration
- options.
- @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
- @retval EFI_UNSUPPORTED The driver specified by This is not currently managing the controller
- specified by ControllerHandle and ChildHandle.
- @retval EFI_DEVICE_ERROR The controller specified by ControllerHandle and ChildHandle that is being
- managed by the driver specified by This has an invalid set of configuration
- options.
-**/
-EFI_STATUS
-EFIAPI
-IDEBusDriverConfigurationOptionsValid (
- IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL
- );
-
-/**
- Forces a driver to set the default configuration options for a controller.
-
- @param This A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.
- @param ControllerHandle The handle of the controller to force default configuration options on.
- @param ChildHandle The handle of the child controller to force default configuration
- options on This is an optional parameter that may be NULL. It
- will be NULL for device drivers. It will also be NULL for a bus
- drivers that wish to force default configuration options for the bus
- controller. It will not be NULL for a bus driver that wishes to force
- default configuration options for one of its child controllers.
- @param DefaultType The type of default configuration options to force on the controller
- specified by ControllerHandle and ChildHandle.
- @param ActionRequired A pointer to the action that the calling agent is required to perform
- when this function returns.
-
- @retval EFI_SUCCESS The driver specified by This successfully forced the
- default configuration options on the controller specified by
- ControllerHandle and ChildHandle.
- @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
- @retval EFI_INVALID_PARAMETER ActionRequired is NULL.
- @retval EFI_UNSUPPORTED The driver specified by This does not support forcing the default
- configuration options on the controller specified by ControllerHandle
- and ChildHandle.
- @retval EFI_UNSUPPORTED The driver specified by This does not support the configuration type
- specified by DefaultType.
- @retval EFI_DEVICE_ERROR A device error occurred while attempt to force the default configuration
- options on the controller specified by ControllerHandle and ChildHandle.
- @retval EFI_OUT_RESOURCES There are not enough resources available to force the default configuration
- options on the controller specified by ControllerHandle and ChildHandle.
-**/
-EFI_STATUS
-EFIAPI
-IDEBusDriverConfigurationForceDefaults (
- IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN UINT32 DefaultType,
- OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired
- );
-
-//
-// EFI Driver Diagnostics Functions
-//
-/**
- Runs diagnostics on a controller.
-
- @param This A pointer to the EFI_DRIVER_DIAGNOSTICS_PROTOCOLinstance.
- @param ControllerHandle The handle of the controller to run diagnostics on.
- @param ChildHandle The handle of the child controller to run diagnostics on
- This is an optional parameter that may be NULL. It will
- be NULL for device drivers. It will also be NULL for a
- bus drivers that wish to run diagnostics on the bus controller.
- It will not be NULL for a bus driver that wishes to run
- diagnostics on one of its child controllers.
- @param DiagnosticType Indicates type of diagnostics to perform on the controller
- specified by ControllerHandle and ChildHandle.
- @param Language A pointer to a three character ISO 639-2 language identifier.
- This is the language in which the optional error message should
- be returned in Buffer, and it must match one of the languages
- specified in SupportedLanguages. The number of languages supported by
- a driver is up to the driver writer.
- @param ErrorType A GUID that defines the format of the data returned in Buffer.
- @param BufferSize The size, in bytes, of the data returned in Buffer.
- @param Buffer A buffer that contains a Null-terminated Unicode string
- plus some additional data whose format is defined by ErrorType.
- Buffer is allocated by this function with AllocatePool(), and
- it is the caller's responsibility to free it with a call to FreePool().
-
- @retval EFI_SUCCESS The controller specified by ControllerHandle and ChildHandle passed
- the diagnostic.
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
- @retval EFI_INVALID_PARAMETER Language is NULL.
- @retval EFI_INVALID_PARAMETER ErrorType is NULL.
- @retval EFI_INVALID_PARAMETER BufferType is NULL.
- @retval EFI_INVALID_PARAMETER Buffer is NULL.
- @retval EFI_UNSUPPORTED The driver specified by This does not support running
- diagnostics for the controller specified by ControllerHandle
- and ChildHandle.
- @retval EFI_UNSUPPORTED The driver specified by This does not support the
- type of diagnostic specified by DiagnosticType.
- @retval EFI_UNSUPPORTED The driver specified by This does not support the language
- specified by Language.
- @retval EFI_OUT_OF_RESOURCES There are not enough resources available to complete the
- diagnostics.
- @retval EFI_OUT_OF_RESOURCES There are not enough resources available to return the
- status information in ErrorType, BufferSize,and Buffer.
- @retval EFI_DEVICE_ERROR The controller specified by ControllerHandle and ChildHandle
- did not pass the diagnostic.
-**/
-EFI_STATUS
-EFIAPI
-IDEBusDriverDiagnosticsRunDiagnostics (
- IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType,
- IN CHAR8 *Language,
- OUT EFI_GUID **ErrorType,
- OUT UINTN *BufferSize,
- OUT CHAR16 **Buffer
- );
-
-/**
- issue ATA or ATAPI command to reset a block IO device.
- @param This Block IO protocol instance pointer.
- @param ExtendedVerification If FALSE,for ATAPI device, driver will only invoke ATAPI reset method
- If TRUE, for ATAPI device, driver need invoke ATA reset method after
- invoke ATAPI reset method
-
- @retval EFI_DEVICE_ERROR When the device is neighther ATA device or ATAPI device.
- @retval EFI_SUCCESS The device reset successfully
-
-**/
-EFI_STATUS
-EFIAPI
-IDEBlkIoReset (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- );
-
-/**
- Read data from a block IO device.
-
- @param This Block IO protocol instance pointer.
- @param MediaId The media ID of the device
- @param Lba Starting LBA address to read data
- @param BufferSize The size of data to be read
- @param Buffer Caller supplied buffer to save data
-
- @retval EFI_DEVICE_ERROR unknown device type
- @retval EFI_SUCCESS read the data successfully.
-
-**/
-EFI_STATUS
-EFIAPI
-IDEBlkIoReadBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- );
-
-/**
- Write data to block io device
-
- @param This Protocol instance pointer.
- @param MediaId The media ID of the device
- @param Lba Starting LBA address to write data
- @param BufferSize The size of data to be written
- @param Buffer Caller supplied buffer to save data
-
- @retval EFI_DEVICE_ERROR unknown device type
- @retval other write data status
-
-**/
-EFI_STATUS
-EFIAPI
-IDEBlkIoWriteBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- IN VOID *Buffer
- );
-
-/**
- Flushes all modified data to a physical block devices
-
- @param This Indicates a pointer to the calling context which to sepcify a
- sepcific block device
-
- @retval EFI_SUCCESS Always return success.
-**/
-EFI_STATUS
-EFIAPI
-IDEBlkIoFlushBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This
- );
-/**
- This function is used by the IDE bus driver to get inquiry data.
- Data format of Identify data is defined by the Interface GUID.
-
- @param This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
- @param InquiryData Pointer to a buffer for the inquiry data.
- @param InquiryDataSize Pointer to the value for the inquiry data size.
-
- @retval EFI_SUCCESS The command was accepted without any errors.
- @retval EFI_NOT_FOUND Device does not support this data class
- @retval EFI_DEVICE_ERROR Error reading InquiryData from device
- @retval EFI_BUFFER_TOO_SMALL IntquiryDataSize not big enough
-
-**/
-EFI_STATUS
-EFIAPI
-IDEDiskInfoInquiry (
- IN EFI_DISK_INFO_PROTOCOL *This,
- IN OUT VOID *InquiryData,
- IN OUT UINT32 *InquiryDataSize
- );
-
-/**
- This function is used by the IDE bus driver to get identify data.
- Data format of Identify data is defined by the Interface GUID.
-
- @param This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
- @param IdentifyData Pointer to a buffer for the identify data.
- @param IdentifyDataSize Pointer to the value for the identify data size.
-
- @retval EFI_SUCCESS The command was accepted without any errors.
- @retval EFI_NOT_FOUND Device does not support this data class
- @retval EFI_DEVICE_ERROR Error reading IdentifyData from device
- @retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough
-
-**/
-EFI_STATUS
-EFIAPI
-IDEDiskInfoIdentify (
- IN EFI_DISK_INFO_PROTOCOL *This,
- IN OUT VOID *IdentifyData,
- IN OUT UINT32 *IdentifyDataSize
- );
-
-/**
- This function is used by the IDE bus driver to get sense data.
- Data format of Sense data is defined by the Interface GUID.
-
- @param This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
- @param SenseData Pointer to the SenseData.
- @param SenseDataSize Size of SenseData in bytes.
- @param SenseDataNumber Pointer to the value for the identify data size.
-
- @retval EFI_SUCCESS The command was accepted without any errors.
- @retval EFI_NOT_FOUND Device does not support this data class
- @retval EFI_DEVICE_ERROR Error reading InquiryData from device
- @retval EFI_BUFFER_TOO_SMALL SenseDataSize not big enough
-
-**/
-EFI_STATUS
-EFIAPI
-IDEDiskInfoSenseData (
- IN EFI_DISK_INFO_PROTOCOL *This,
- IN OUT VOID *SenseData,
- IN OUT UINT32 *SenseDataSize,
- OUT UINT8 *SenseDataNumber
- );
-
-/**
- This function is used by the IDE bus driver to get controller information.
-
- @param This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
- @param IdeChannel Pointer to the Ide Channel number. Primary or secondary.
- @param IdeDevice Pointer to the Ide Device number. Master or slave.
-
- @retval EFI_SUCCESS IdeChannel and IdeDevice are valid
- @retval EFI_UNSUPPORTED This is not an IDE device
-
-**/
-EFI_STATUS
-EFIAPI
-IDEDiskInfoWhichIde (
- IN EFI_DISK_INFO_PROTOCOL *This,
- OUT UINT32 *IdeChannel,
- OUT UINT32 *IdeDevice
- );
-/**
- The is an event(generally the event is exitBootService event) call back function.
- Clear pending IDE interrupt before OS loader/kernel take control of the IDE device.
-
- @param Event Pointer to this event
- @param Context Event handler private data
-
-**/
-VOID
-EFIAPI
-ClearInterrupt (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
-#endif
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.inf b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.inf deleted file mode 100644 index 8beea2d9ca..0000000000 --- a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.inf +++ /dev/null @@ -1,88 +0,0 @@ -## @file
-# IDE bus driver.
-#
-# This driver will enumerate IDE device and export the blockIo protocol for every device.
-#
-# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
-#
-# 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.
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = IdeBusDxe
- MODULE_UNI_FILE = IdeBusDxe.uni
- FILE_GUID = 69FD8E47-A161-4550-B01A-5594CEB2B2B2
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = InitializeIdeBus
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-#
-# DRIVER_BINDING = gIDEBusDriverBinding
-# COMPONENT_NAME = gIDEBusComponentName
-# COMPONENT_NAME2 = gIDEBusComponentName2
-# Variable Guid C Name: gConfigurationGuid Variable Name: L"Configuration"
-#
-#
-
-[Sources]
- DriverDiagnostics.c
- DriverConfiguration.c
- ComponentName.h
- ComponentName.c
- Atapi.c
- Ata.c
- Ide.c
- IdeBus.c
- IdeData.h
- Ide.h
- IdeBus.h
-
-
-[Packages]
- MdePkg/MdePkg.dec
- IntelFrameworkPkg/IntelFrameworkPkg.dec
- IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
-
-
-[LibraryClasses]
- DevicePathLib
- UefiRuntimeServicesTableLib
- UefiBootServicesTableLib
- PerformanceLib
- MemoryAllocationLib
- ReportStatusCodeLib
- BaseMemoryLib
- UefiLib
- BaseLib
- UefiDriverEntryPoint
- DebugLib
-
-
-[Guids]
- gEfiDiskInfoIdeInterfaceGuid ## SOMETIMES_PRODUCES ## UNDEFINED # DiskInfo Interface Guid
- gEfiEventExitBootServicesGuid ## CONSUMES ## Event
-
-
-[Protocols]
- gEfiDiskInfoProtocolGuid ## BY_START
- gEfiBlockIoProtocolGuid ## BY_START
- gEfiIdeControllerInitProtocolGuid ## TO_START
- gEfiPciIoProtocolGuid ## TO_START
- ## TO_START
- ## BY_START
- gEfiDevicePathProtocolGuid
-
-[UserExtensions.TianoCore."ExtraFiles"]
- IdeBusDxeExtra.uni
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.uni b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.uni deleted file mode 100644 index fe2710d392..0000000000 --- a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.uni +++ /dev/null @@ -1,21 +0,0 @@ -// /** @file
-// IDE bus driver.
-//
-// This driver will enumerate IDE device and export the blockIo protocol for every device.
-//
-// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
-//
-// 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.
-//
-// **/
-
-
-#string STR_MODULE_ABSTRACT #language en-US "IDE bus driver"
-
-#string STR_MODULE_DESCRIPTION #language en-US "This driver will enumerate IDE device and export the blockIo protocol for every device."
-
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxeExtra.uni b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxeExtra.uni deleted file mode 100644 index f47950f533..0000000000 --- a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxeExtra.uni +++ /dev/null @@ -1,19 +0,0 @@ -// /** @file
-// IdeBusDxe Localized Strings and Content
-//
-// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
-//
-// 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.
-//
-// **/
-
-#string STR_PROPERTIES_MODULE_NAME
-#language en-US
-"IDE Bus DXE Driver"
-
-
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeData.h b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeData.h deleted file mode 100644 index 487fe6f3ea..0000000000 --- a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeData.h +++ /dev/null @@ -1,311 +0,0 @@ -/** @file
- Header file for IDE Bus Driver's Data Structures
-
- Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
- 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.
-
-**/
-
-#ifndef _IDE_DATA_H_
-#define _IDE_DATA_H_
-
-#include <IndustryStandard/Atapi.h>
-
-//
-// common constants
-//
-#define STALL_1_MILLI_SECOND 1000 // stall 1 ms
-#define STALL_1_SECOND 1000000 // stall 1 second
-typedef enum {
- IdePrimary = 0,
- IdeSecondary = 1,
- IdeMaxChannel = 2
-} EFI_IDE_CHANNEL;
-
-typedef enum {
- IdeMaster = 0,
- IdeSlave = 1,
- IdeMaxDevice = 2
-} EFI_IDE_DEVICE;
-
-typedef enum {
- IdeMagnetic, /* ZIP Drive or LS120 Floppy Drive */
- IdeCdRom, /* ATAPI CDROM */
- IdeHardDisk, /* Hard Disk */
- Ide48bitAddressingHardDisk, /* Hard Disk larger than 120GB */
- IdeUnknown
-} IDE_DEVICE_TYPE;
-
-typedef enum {
- SenseNoSenseKey,
- SenseDeviceNotReadyNoRetry,
- SenseDeviceNotReadyNeedRetry,
- SenseNoMedia,
- SenseMediaChange,
- SenseMediaError,
- SenseOtherSense
-} SENSE_RESULT;
-
-typedef enum {
- AtaUdmaReadOp,
- AtaUdmaReadExtOp,
- AtaUdmaWriteOp,
- AtaUdmaWriteExtOp
-} ATA_UDMA_OPERATION;
-
-//
-// IDE Registers
-//
-typedef union {
- UINT16 Command; /* when write */
- UINT16 Status; /* when read */
-} IDE_CMD_OR_STATUS;
-
-typedef union {
- UINT16 Error; /* when read */
- UINT16 Feature; /* when write */
-} IDE_ERROR_OR_FEATURE;
-
-typedef union {
- UINT16 AltStatus; /* when read */
- UINT16 DeviceControl; /* when write */
-} IDE_ALTSTATUS_OR_DEVICECONTROL;
-
-//
-// IDE registers set
-//
-typedef struct {
- UINT16 Data;
- IDE_ERROR_OR_FEATURE Reg1;
- UINT16 SectorCount;
- UINT16 SectorNumber;
- UINT16 CylinderLsb;
- UINT16 CylinderMsb;
- UINT16 Head;
- IDE_CMD_OR_STATUS Reg;
-
- IDE_ALTSTATUS_OR_DEVICECONTROL Alt;
- UINT16 DriveAddress;
-
- UINT16 MasterSlave;
- UINT16 BusMasterBaseAddr;
-} IDE_BASE_REGISTERS;
-
-//
-// IDE registers' base addresses
-//
-typedef struct {
- UINT16 CommandBlockBaseAddr;
- UINT16 ControlBlockBaseAddr;
- UINT16 BusMasterBaseAddr;
-} IDE_REGISTERS_BASE_ADDR;
-
-//
-// Bit definitions in Programming Interface byte of the Class Code field
-// in PCI IDE controller's Configuration Space
-//
-#define IDE_PRIMARY_OPERATING_MODE BIT0
-#define IDE_PRIMARY_PROGRAMMABLE_INDICATOR BIT1
-#define IDE_SECONDARY_OPERATING_MODE BIT2
-#define IDE_SECONDARY_PROGRAMMABLE_INDICATOR BIT3
-
-
-//
-// Bus Master Reg
-//
-#define BMIC_NREAD BIT3
-#define BMIC_START BIT0
-#define BMIS_INTERRUPT BIT2
-#define BMIS_ERROR BIT1
-
-#define BMICP_OFFSET 0x00
-#define BMISP_OFFSET 0x02
-#define BMIDP_OFFSET 0x04
-#define BMICS_OFFSET 0x08
-#define BMISS_OFFSET 0x0A
-#define BMIDS_OFFSET 0x0C
-
-//
-// Time Out Value For IDE Device Polling
-//
-
-//
-// ATATIMEOUT is used for waiting time out for ATA device
-//
-
-//
-// 1 second
-//
-#define ATATIMEOUT 1000
-
-//
-// ATAPITIMEOUT is used for waiting operation
-// except read and write time out for ATAPI device
-//
-
-//
-// 1 second
-//
-#define ATAPITIMEOUT 1000
-
-//
-// ATAPILONGTIMEOUT is used for waiting read and
-// write operation timeout for ATAPI device
-//
-
-//
-// 2 seconds
-//
-#define CDROMLONGTIMEOUT 2000
-
-//
-// 5 seconds
-//
-#define ATAPILONGTIMEOUT 5000
-
-//
-// 10 seconds
-//
-#define ATASMARTTIMEOUT 10000
-
-
-//
-// ATAPI6 related data structure definition
-//
-
-//
-// The maximum sectors count in 28 bit addressing mode
-//
-#define MAX_28BIT_ADDRESSING_CAPACITY 0xfffffff
-
-#pragma pack(1)
-
-typedef struct {
- UINT32 RegionBaseAddr;
- UINT16 ByteCount;
- UINT16 EndOfTable;
-} IDE_DMA_PRD;
-
-#pragma pack()
-
-#define SETFEATURE TRUE
-#define CLEARFEATURE FALSE
-
-///
-/// PIO mode definition
-///
-typedef enum _ATA_PIO_MODE_ {
- AtaPioModeBelow2,
- AtaPioMode2,
- AtaPioMode3,
- AtaPioMode4
-} ATA_PIO_MODE;
-
-//
-// Multi word DMA definition
-//
-typedef enum _ATA_MDMA_MODE_ {
- AtaMdmaMode0,
- AtaMdmaMode1,
- AtaMdmaMode2
-} ATA_MDMA_MODE;
-
-//
-// UDMA mode definition
-//
-typedef enum _ATA_UDMA_MODE_ {
- AtaUdmaMode0,
- AtaUdmaMode1,
- AtaUdmaMode2,
- AtaUdmaMode3,
- AtaUdmaMode4,
- AtaUdmaMode5
-} ATA_UDMA_MODE;
-
-#define ATA_MODE_CATEGORY_DEFAULT_PIO 0x00
-#define ATA_MODE_CATEGORY_FLOW_PIO 0x01
-#define ATA_MODE_CATEGORY_MDMA 0x04
-#define ATA_MODE_CATEGORY_UDMA 0x08
-
-#pragma pack(1)
-
-typedef struct {
- UINT8 ModeNumber : 3;
- UINT8 ModeCategory : 5;
-} ATA_TRANSFER_MODE;
-
-typedef struct {
- UINT8 Sector;
- UINT8 Heads;
- UINT8 MultipleSector;
-} ATA_DRIVE_PARMS;
-
-#pragma pack()
-//
-// IORDY Sample Point field value
-//
-#define ISP_5_CLK 0
-#define ISP_4_CLK 1
-#define ISP_3_CLK 2
-#define ISP_2_CLK 3
-
-//
-// Recovery Time field value
-//
-#define RECVY_4_CLK 0
-#define RECVY_3_CLK 1
-#define RECVY_2_CLK 2
-#define RECVY_1_CLK 3
-
-//
-// Slave IDE Timing Register Enable
-//
-#define SITRE BIT14
-
-//
-// DMA Timing Enable Only Select 1
-//
-#define DTE1 BIT7
-
-//
-// Pre-fetch and Posting Enable Select 1
-//
-#define PPE1 BIT6
-
-//
-// IORDY Sample Point Enable Select 1
-//
-#define IE1 BIT5
-
-//
-// Fast Timing Bank Drive Select 1
-//
-#define TIME1 BIT4
-
-//
-// DMA Timing Enable Only Select 0
-//
-#define DTE0 BIT3
-
-//
-// Pre-fetch and Posting Enable Select 0
-//
-#define PPE0 BIT2
-
-//
-// IOREY Sample Point Enable Select 0
-//
-#define IE0 BIT1
-
-//
-// Fast Timing Bank Drive Select 0
-//
-#define TIME0 BIT0
-
-#endif
diff --git a/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/ComponentName.c b/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/ComponentName.c deleted file mode 100644 index e495d96af8..0000000000 --- a/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/ComponentName.c +++ /dev/null @@ -1,168 +0,0 @@ -/** @file
- Implements EFI Component Name Protocol for VGA Mini Port Driver.
-
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
-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 "VgaMiniPort.h"
-
-
-//
-// EFI Component Name Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gPciVgaMiniPortComponentName = {
- PciVgaMiniPortComponentNameGetDriverName,
- PciVgaMiniPortComponentNameGetControllerName,
- "eng"
-};
-
-//
-// EFI Component Name 2 Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPciVgaMiniPortComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) PciVgaMiniPortComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) PciVgaMiniPortComponentNameGetControllerName,
- "en"
-};
-
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPciVgaMiniPortDriverNameTable[] = {
- {
- "eng;en",
- L"PCI VGA Mini Port Driver"
- },
- {
- NULL,
- NULL
- }
-};
-
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
- @param Language A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
- @param DriverName A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
- @retval EFI_INVALID_PARAMETER Language is NULL.
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-PciVgaMiniPortComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- )
-{
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mPciVgaMiniPortDriverNameTable,
- DriverName,
- (BOOLEAN)(This == &gPciVgaMiniPortComponentName)
- );
-}
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
- @param ControllerHandle The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
- @param ChildHandle The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
- @param Language A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
- @param ControllerName A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
- @retval EFI_INVALID_PARAMETER Language is NULL.
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-PciVgaMiniPortComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- )
-{
- return EFI_UNSUPPORTED;
-}
diff --git a/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPort.c b/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPort.c deleted file mode 100644 index 25d1e3beb7..0000000000 --- a/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPort.c +++ /dev/null @@ -1,331 +0,0 @@ -/** @file
- Implements EFI Driver Binding Protocol and VGA Mini Port Protocol for VGA Mini Port Driver.
-
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
-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 "VgaMiniPort.h"
-
-//
-// EFI Driver Binding Protocol Instance
-//
-// This driver has a version value of 0x00000000. This is the
-// lowest possible priority for a driver. This is done on purpose to help
-// the developers of UGA drivers. This driver can bind if no UGA driver
-// is present, so a console is available. Then, when a UGA driver is loaded
-// this driver can be disconnected, and the UGA driver can be connected.
-// As long as the UGA driver has a version value greater than 0x00000000, it
-// will be connected first and will block this driver from connecting.
-//
-EFI_DRIVER_BINDING_PROTOCOL gPciVgaMiniPortDriverBinding = {
- PciVgaMiniPortDriverBindingSupported,
- PciVgaMiniPortDriverBindingStart,
- PciVgaMiniPortDriverBindingStop,
- 0x00000000,
- NULL,
- NULL
-};
-
-/**
- Entrypoint of VGA Mini Port Driver.
-
- This function is the entrypoint of UVGA Mini Port Driver. It installs Driver Binding
- Protocols together with Component Name Protocols.
-
- @param ImageHandle The firmware allocated handle for the EFI image.
- @param SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The entry point is executed successfully.
-
-**/
-EFI_STATUS
-EFIAPI
-PciVgaMiniPortDriverEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- Status = EfiLibInstallDriverBindingComponentName2 (
- ImageHandle,
- SystemTable,
- &gPciVgaMiniPortDriverBinding,
- ImageHandle,
- &gPciVgaMiniPortComponentName,
- &gPciVgaMiniPortComponentName2
- );
- ASSERT_EFI_ERROR (Status);
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Check whether VGA Mini Port driver supports this device.
-
- @param This The driver binding protocol.
- @param Controller The controller handle to check.
- @param RemainingDevicePath The remaining device path.
-
- @retval EFI_SUCCESS The driver supports this controller.
- @retval EFI_UNSUPPORTED This device isn't supported.
-
-**/
-EFI_STATUS
-EFIAPI
-PciVgaMiniPortDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL *PciIo;
- PCI_TYPE00 Pci;
-
- //
- // Open the IO Abstraction(s) needed to perform the supported test
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- (VOID **) &PciIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
- //
- // See if this is a PCI VGA Controller by looking at the Command register and
- // Class Code Register
- //
- Status = PciIo->Pci.Read (
- PciIo,
- EfiPciIoWidthUint32,
- 0,
- sizeof (Pci) / sizeof (UINT32),
- &Pci
- );
- if (EFI_ERROR (Status)) {
- goto Done;
- }
-
- Status = EFI_UNSUPPORTED;
- //
- // See if the device is an enabled VGA device.
- // Most systems can only have on VGA device on at a time.
- //
- if (((Pci.Hdr.Command & 0x03) == 0x03) && IS_PCI_VGA (&Pci)) {
- Status = EFI_SUCCESS;
- }
-
-Done:
- gBS->CloseProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- return Status;
-}
-
-
-/**
- Starts the VGA device with this driver.
-
- This function consumes PCI I/O Protocol, and installs VGA Mini Port Protocol
- onto the VGA device handle.
-
- @param This The driver binding instance.
- @param Controller The controller to check.
- @param RemainingDevicePath The remaining device patch.
-
- @retval EFI_SUCCESS The controller is controlled by the driver.
- @retval EFI_ALREADY_STARTED The controller is already controlled by the driver.
- @retval EFI_OUT_OF_RESOURCES Failed to allocate resources.
-
-**/
-EFI_STATUS
-EFIAPI
-PciVgaMiniPortDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- EFI_STATUS Status;
- EFI_PCI_IO_PROTOCOL *PciIo;
- PCI_VGA_MINI_PORT_DEV *PciVgaMiniPortPrivate;
-
- PciVgaMiniPortPrivate = NULL;
- PciIo = NULL;
- //
- // Open the IO Abstraction(s) needed
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- (VOID **) &PciIo,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- goto Done;
- }
- //
- // Allocate the private device structure
- //
- PciVgaMiniPortPrivate = AllocateZeroPool (sizeof (PCI_VGA_MINI_PORT_DEV));
- ASSERT (PciVgaMiniPortPrivate != NULL);
-
- //
- // Initialize the private device structure
- //
- PciVgaMiniPortPrivate->Signature = PCI_VGA_MINI_PORT_DEV_SIGNATURE;
- PciVgaMiniPortPrivate->Handle = Controller;
- PciVgaMiniPortPrivate->PciIo = PciIo;
-
- PciVgaMiniPortPrivate->VgaMiniPort.SetMode = PciVgaMiniPortSetMode;
- PciVgaMiniPortPrivate->VgaMiniPort.VgaMemoryOffset = 0xb8000;
- PciVgaMiniPortPrivate->VgaMiniPort.CrtcAddressRegisterOffset = 0x3d4;
- PciVgaMiniPortPrivate->VgaMiniPort.CrtcDataRegisterOffset = 0x3d5;
- PciVgaMiniPortPrivate->VgaMiniPort.VgaMemoryBar = EFI_PCI_IO_PASS_THROUGH_BAR;
- PciVgaMiniPortPrivate->VgaMiniPort.CrtcAddressRegisterBar = EFI_PCI_IO_PASS_THROUGH_BAR;
- PciVgaMiniPortPrivate->VgaMiniPort.CrtcDataRegisterBar = EFI_PCI_IO_PASS_THROUGH_BAR;
- PciVgaMiniPortPrivate->VgaMiniPort.MaxMode = 1;
-
- //
- // Install VGA Mini Port Protocol
- //
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Controller,
- &gEfiVgaMiniPortProtocolGuid,
- &PciVgaMiniPortPrivate->VgaMiniPort,
- NULL
- );
-Done:
- if (EFI_ERROR (Status)) {
- gBS->CloseProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- if (PciVgaMiniPortPrivate != NULL) {
- FreePool (PciVgaMiniPortPrivate);
- }
- }
-
- return Status;
-}
-
-
-/**
- Stop the VGA device with this driver.
-
- This function uninstalls VGA Mini Port Protocol from the VGA device handle,
- and closes PCI I/O Protocol.
-
- @param This The driver binding protocol.
- @param Controller The controller to release.
- @param NumberOfChildren The child number that opened controller
- BY_CHILD.
- @param ChildHandleBuffer The array of child handle.
-
- @retval EFI_SUCCESS The controller or children are stopped.
- @retval EFI_DEVICE_ERROR Failed to stop the driver.
-
-**/
-EFI_STATUS
-EFIAPI
-PciVgaMiniPortDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- )
-{
- EFI_STATUS Status;
- EFI_VGA_MINI_PORT_PROTOCOL *VgaMiniPort;
- PCI_VGA_MINI_PORT_DEV *PciVgaMiniPortPrivate;
-
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiVgaMiniPortProtocolGuid,
- (VOID **) &VgaMiniPort,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- PciVgaMiniPortPrivate = PCI_VGA_MINI_PORT_DEV_FROM_THIS (VgaMiniPort);
-
- Status = gBS->UninstallProtocolInterface (
- Controller,
- &gEfiVgaMiniPortProtocolGuid,
- &PciVgaMiniPortPrivate->VgaMiniPort
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- gBS->CloseProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- FreePool (PciVgaMiniPortPrivate);
-
- return EFI_SUCCESS;
-}
-//
-// VGA Mini Port Protocol Functions
-//
-
-/**
- Sets the text display mode of a VGA controller.
-
- This function implements EFI_VGA_MINI_PORT_PROTOCOL.SetMode().
- If ModeNumber exceeds the valid range, then EFI_UNSUPPORTED is returned.
- Otherwise, EFI_SUCCESS is directly returned without real operation.
-
- @param This Protocol instance pointer.
- @param ModeNumber Mode number. 0 - 80x25 1-80x50
-
- @retval EFI_SUCCESS The mode was set
- @retval EFI_UNSUPPORTED ModeNumber is not supported.
- @retval EFI_DEVICE_ERROR The device is not functioning properly.
-
-**/
-EFI_STATUS
-EFIAPI
-PciVgaMiniPortSetMode (
- IN EFI_VGA_MINI_PORT_PROTOCOL *This,
- IN UINTN ModeNumber
- )
-{
- if (ModeNumber > This->MaxMode) {
- return EFI_UNSUPPORTED;
- }
-
- return EFI_SUCCESS;
-}
-
diff --git a/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPort.h b/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPort.h deleted file mode 100644 index f39c00364b..0000000000 --- a/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPort.h +++ /dev/null @@ -1,271 +0,0 @@ -/** @file
- Internal include file for VGA Mini Port Driver.
-
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
-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.
-
-**/
-
-#ifndef _VGA_MINIPORT_H_
-#define _VGA_MINIPORT_H_
-
-//
-// The package level header files this module uses
-//
-#include <PiDxe.h>
-//
-// The protocols, PPI and GUID defintions for this module
-//
-#include <Protocol/PciIo.h>
-#include <Protocol/VgaMiniPort.h>
-#include <Protocol/ComponentName2.h>
-
-
-//
-// The Library classes this module consumes
-//
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiLib.h>
-#include <Library/MemoryAllocationLib.h>
-
-#include <IndustryStandard/Pci.h>
-
-//
-// Global Variables
-//
-extern EFI_DRIVER_BINDING_PROTOCOL gPciVgaMiniPortDriverBinding;
-extern EFI_COMPONENT_NAME_PROTOCOL gPciVgaMiniPortComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gPciVgaMiniPortComponentName2;
-
-//
-// PCI VGA MiniPort Device Structure
-//
-#define PCI_VGA_MINI_PORT_DEV_SIGNATURE SIGNATURE_32('P','V','M','P')
-
-typedef struct {
- UINTN Signature;
- EFI_HANDLE Handle;
- EFI_VGA_MINI_PORT_PROTOCOL VgaMiniPort;
- EFI_PCI_IO_PROTOCOL *PciIo;
-} PCI_VGA_MINI_PORT_DEV;
-
-#define PCI_VGA_MINI_PORT_DEV_FROM_THIS(a) CR(a, PCI_VGA_MINI_PORT_DEV, VgaMiniPort, PCI_VGA_MINI_PORT_DEV_SIGNATURE)
-
-//
-// Driver Binding Protocol functions
-//
-/**
- Check whether VGA Mini Port driver supports this device.
-
- @param This The driver binding protocol.
- @param Controller The controller handle to check.
- @param RemainingDevicePath The remaining device path.
-
- @retval EFI_SUCCESS The driver supports this controller.
- @retval EFI_UNSUPPORTED This device isn't supported.
-
-**/
-EFI_STATUS
-EFIAPI
-PciVgaMiniPortDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-/**
- Starts the VGA device with this driver.
-
- This function consumes PCI I/O Protocol, and installs VGA Mini Port Protocol
- onto the VGA device handle.
-
- @param This The driver binding instance.
- @param Controller The controller to check.
- @param RemainingDevicePath The remaining device patch.
-
- @retval EFI_SUCCESS The controller is controlled by the driver.
- @retval EFI_ALREADY_STARTED The controller is already controlled by the driver.
- @retval EFI_OUT_OF_RESOURCES Failed to allocate resources.
-
-**/
-EFI_STATUS
-EFIAPI
-PciVgaMiniPortDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-/**
- Stop the VGA device with this driver.
-
- This function uninstalls VGA Mini Port Protocol from the VGA device handle,
- and closes PCI I/O Protocol.
-
- @param This The driver binding protocol.
- @param Controller The controller to release.
- @param NumberOfChildren The child number that opened controller
- BY_CHILD.
- @param ChildHandleBuffer The array of child handle.
-
- @retval EFI_SUCCESS The controller or children are stopped.
- @retval EFI_DEVICE_ERROR Failed to stop the driver.
-
-**/
-EFI_STATUS
-EFIAPI
-PciVgaMiniPortDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- );
-
-//
-// EFI Component Name Functions
-//
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
- @param Language A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
- @param DriverName A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
- @retval EFI_INVALID_PARAMETER Language is NULL.
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-PciVgaMiniPortComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- );
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
- @param ControllerHandle The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
- @param ChildHandle The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
- @param Language A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
- @param ControllerName A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
- @retval EFI_INVALID_PARAMETER Language is NULL.
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-PciVgaMiniPortComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- );
-
-//
-// VGA Mini Port Protocol functions
-//
-/**
- Sets the text display mode of a VGA controller.
-
- This function implements EFI_VGA_MINI_PORT_PROTOCOL.SetMode().
- If ModeNumber exceeds the valid range, then EFI_UNSUPPORTED is returned.
- Otherwise, EFI_SUCCESS is directly returned without real operation.
-
- @param This Protocol instance pointer.
- @param ModeNumber Mode number. 0 - 80x25 1-80x50
-
- @retval EFI_SUCCESS The mode was set
- @retval EFI_UNSUPPORTED ModeNumber is not supported.
- @retval EFI_DEVICE_ERROR The device is not functioning properly.
-
-**/
-EFI_STATUS
-EFIAPI
-PciVgaMiniPortSetMode (
- IN EFI_VGA_MINI_PORT_PROTOCOL *This,
- IN UINTN ModeNumber
- );
-
-#endif
diff --git a/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPort.uni b/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPort.uni deleted file mode 100644 index ad04f35127..0000000000 --- a/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPort.uni +++ /dev/null @@ -1,22 +0,0 @@ -// /** @file
-// VGA Mini Port Driver that manages VGA device and produces VGA Mini Port Protocol.
-//
-// VGA Mini Port Driver that manages VGA device and produces the VGA Mini Port Protocol.
-//
-// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
-//
-// 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.
-//
-// **/
-
-
-#string STR_MODULE_ABSTRACT #language en-US "VGA Mini Port Driver that manages VGA device and produces the VGA Mini Port Protocol"
-
-#string STR_MODULE_DESCRIPTION #language en-US "VGA Mini Port Driver that manages VGA device and produces the VGA Mini Port Protocol."
-
diff --git a/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPortDxe.inf b/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPortDxe.inf deleted file mode 100644 index d3c35faa6c..0000000000 --- a/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPortDxe.inf +++ /dev/null @@ -1,57 +0,0 @@ -## @file
-# VGA Mini Port Driver that manages VGA device and produces VGA Mini Port Protocol.
-#
-# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
-#
-# 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.
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = VgaMiniPort
- MODULE_UNI_FILE = VgaMiniPort.uni
- FILE_GUID = 15C5E761-58D8-461a-9173-CAB020916264
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = PciVgaMiniPortDriverEntryPoint
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-# DRIVER_BINDING = gPciVgaMiniPortDriverBinding;
-# COMPONENT_NAME = gPciVgaMiniPortComponentName;
-# COMPONENT_NAME2 = gPciVgaMiniPortComponentName2;
-#
-
-[Sources]
- ComponentName.c
- VgaMiniPort.c
- VgaMiniPort.h
-
-[Packages]
- MdePkg/MdePkg.dec
- IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
-
-[LibraryClasses]
- UefiLib
- DebugLib
- UefiBootServicesTableLib
- UefiDriverEntryPoint
- BaseMemoryLib
- MemoryAllocationLib
-
-[Protocols]
- gEfiPciIoProtocolGuid ## TO_START
- gEfiVgaMiniPortProtocolGuid ## BY_START
-
-[UserExtensions.TianoCore."ExtraFiles"]
- VgaMiniPortExtra.uni
diff --git a/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPortExtra.uni b/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPortExtra.uni deleted file mode 100644 index 4e206ae06a..0000000000 --- a/IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPortExtra.uni +++ /dev/null @@ -1,20 +0,0 @@ -// /** @file
-// VgaMiniPort Localized Strings and Content
-//
-// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
-//
-// 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.
-//
-// **/
-
-#string STR_PROPERTIES_MODULE_NAME
-#language en-US
-"VGA Mini Port DXE Driver"
-
-
|