summaryrefslogtreecommitdiff
path: root/IntelFrameworkModulePkg/Bus/Isa
diff options
context:
space:
mode:
Diffstat (limited to 'IntelFrameworkModulePkg/Bus/Isa')
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/ComponentName.c182
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/ComponentName.h148
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/InternalIsaBus.h297
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/InternalIsaIo.h331
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBus.c673
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.inf73
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.uni25
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxeExtra.uni20
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaIo.c1463
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/ComponentName.c249
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/ComponentName.h146
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.c515
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppy.h1093
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyBlock.c375
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyCtrl.c1398
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.inf78
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.uni24
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxeExtra.uni20
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/Fdc.h235
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/FloppyPeim.c1759
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/FloppyPeim.h246
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/IsaFloppyPei.inf73
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/IsaFloppyPei.uni25
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaFloppyPei/IsaFloppyPeiExtra.uni21
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/ComponentName.c182
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/ComponentName.h148
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaDriver.c326
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaDriver.h263
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIo.c1803
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIo.h331
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIoDxe.inf71
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIoDxe.uni24
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaIoDxeExtra.uni20
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/ComponentName.c272
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf80
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.uni23
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxeExtra.uni20
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.c2038
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/Serial.h842
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/ComponentName.c372
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c1916
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c732
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.c663
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h565
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxe.uni23
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KeyboardDxeExtra.uni20
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf85
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/CommPs2.c923
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/CommPs2.h435
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/ComponentName.c241
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointer.c778
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointer.h400
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointerDxe.inf76
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointerDxe.uni23
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2MouseAbsolutePointerDxe/Ps2MouseAbsolutePointerDxeExtra.uni20
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/CommPs2.c921
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/CommPs2.h435
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/ComponentName.c241
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.c792
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.h400
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxe.inf75
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxe.uni22
-rw-r--r--IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2MouseDxeExtra.uni20
63 files changed, 0 insertions, 26090 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"
-
-