Remove IntelFrameworkModulePkg
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1605 Please note a subsequent commit will followed to update the information in Maintainers.txt to reflect this package removal. Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif.lindholm@linaro.org> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Hao A Wu <hao.a.wu@intel.com> Acked-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
This commit is contained in:
@ -1,176 +0,0 @@
|
|||||||
/** @file
|
|
||||||
UEFI Component Name(2) protocol implementation for IsaBus driver.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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;
|
|
||||||
}
|
|
@ -1,142 +0,0 @@
|
|||||||
/** @file
|
|
||||||
Header file for implementation of UEFI Component Name(2) protocol.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
@ -1,291 +0,0 @@
|
|||||||
/** @file
|
|
||||||
The header file for ISA bus driver
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
@ -1,325 +0,0 @@
|
|||||||
/** @file
|
|
||||||
The header file for EFI_ISA_IO protocol implementation.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
@ -1,667 +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 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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;
|
|
||||||
}
|
|
||||||
|
|
@ -1,67 +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 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
##
|
|
||||||
|
|
||||||
[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 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
|
|
@ -1,19 +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 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
//
|
|
||||||
// **/
|
|
||||||
|
|
||||||
|
|
||||||
#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."
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
|||||||
// /** @file
|
|
||||||
// IsaBusDxe Localized Strings and Content
|
|
||||||
//
|
|
||||||
// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
//
|
|
||||||
// **/
|
|
||||||
|
|
||||||
#string STR_PROPERTIES_MODULE_NAME
|
|
||||||
#language en-US
|
|
||||||
"ISA Bus DXE Driver"
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -1,243 +0,0 @@
|
|||||||
/** @file
|
|
||||||
UEFI Component Name(2) protocol implementation for Isa Floppy driver.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,140 +0,0 @@
|
|||||||
/** @file
|
|
||||||
Header file for implementation of UEFI Component Name(2) protocol.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
@ -1,509 +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 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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;
|
|
||||||
}
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -1,369 +0,0 @@
|
|||||||
/** @file
|
|
||||||
Implementation of the EFI Block IO Protocol for ISA Floppy driver
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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;
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,72 +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 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
#
|
|
||||||
##
|
|
||||||
|
|
||||||
[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 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
|
|
@ -1,18 +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 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
//
|
|
||||||
// **/
|
|
||||||
|
|
||||||
|
|
||||||
#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."
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
|||||||
// /** @file
|
|
||||||
// IsaFloppyDxe Localized Strings and Content
|
|
||||||
//
|
|
||||||
// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
//
|
|
||||||
// **/
|
|
||||||
|
|
||||||
#string STR_PROPERTIES_MODULE_NAME
|
|
||||||
#language en-US
|
|
||||||
"ISA Floppy DXE Driver"
|
|
||||||
|
|
||||||
|
|
@ -1,228 +0,0 @@
|
|||||||
/** @file
|
|
||||||
Definition of FDC registers and structures.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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
|
|
File diff suppressed because it is too large
Load Diff
@ -1,239 +0,0 @@
|
|||||||
/** @file
|
|
||||||
Private include file for IsaFloppyPei PEIM.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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
|
|
@ -1,66 +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 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
#
|
|
||||||
##
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
#
|
|
||||||
# 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 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
|
|
@ -1,18 +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 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
//
|
|
||||||
// **/
|
|
||||||
|
|
||||||
|
|
||||||
#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."
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
|||||||
// /** @file
|
|
||||||
// IsaFloppyPei Localized Strings and Content
|
|
||||||
//
|
|
||||||
// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
//
|
|
||||||
// **/
|
|
||||||
|
|
||||||
#string STR_PROPERTIES_MODULE_NAME
|
|
||||||
#language en-US
|
|
||||||
"ISA Floppy PEI Module"
|
|
||||||
|
|
||||||
|
|
@ -1,176 +0,0 @@
|
|||||||
/** @file
|
|
||||||
UEFI Component Name(2) protocol implementation for Isa driver.
|
|
||||||
|
|
||||||
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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;
|
|
||||||
}
|
|
@ -1,142 +0,0 @@
|
|||||||
/** @file
|
|
||||||
Header file for implementation of UEFI Component Name(2) protocol.
|
|
||||||
|
|
||||||
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
@ -1,320 +0,0 @@
|
|||||||
/** @file
|
|
||||||
IsaIo UEFI driver.
|
|
||||||
|
|
||||||
Produce an instance of the ISA I/O Protocol for every SIO controller.
|
|
||||||
|
|
||||||
Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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;
|
|
||||||
}
|
|
@ -1,256 +0,0 @@
|
|||||||
/** @file
|
|
||||||
The header file for ISA driver
|
|
||||||
|
|
||||||
Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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 <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
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -1,325 +0,0 @@
|
|||||||
/** @file
|
|
||||||
The header file for EFI_ISA_IO protocol implementation.
|
|
||||||
|
|
||||||
Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
@ -1,64 +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 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
##
|
|
||||||
|
|
||||||
[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 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
|
|
||||||
|
|
||||||
[Pcd]
|
|
||||||
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdIsaBusSupportedFeatures ## CONSUMES
|
|
||||||
|
|
||||||
[UserExtensions.TianoCore."ExtraFiles"]
|
|
||||||
IsaIoDxeExtra.uni
|
|
@ -1,18 +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 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
//
|
|
||||||
// **/
|
|
||||||
|
|
||||||
|
|
||||||
#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."
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
|||||||
// /** @file
|
|
||||||
// IsaIoDxe Localized Strings and Content
|
|
||||||
//
|
|
||||||
// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
//
|
|
||||||
// **/
|
|
||||||
|
|
||||||
#string STR_PROPERTIES_MODULE_NAME
|
|
||||||
#language en-US
|
|
||||||
"ISA I/O DXE Driver"
|
|
||||||
|
|
||||||
|
|
@ -1,266 +0,0 @@
|
|||||||
/** @file
|
|
||||||
UEFI Component Name and Name2 protocol for Isa serial driver.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
@ -1,74 +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 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
#
|
|
||||||
##
|
|
||||||
|
|
||||||
[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 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
|
|
@ -1,17 +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 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
//
|
|
||||||
// **/
|
|
||||||
|
|
||||||
|
|
||||||
#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."
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
|||||||
// /** @file
|
|
||||||
// IsaSerialDxe Localized Strings and Content
|
|
||||||
//
|
|
||||||
// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
//
|
|
||||||
// **/
|
|
||||||
|
|
||||||
#string STR_PROPERTIES_MODULE_NAME
|
|
||||||
#language en-US
|
|
||||||
"ISA UART Serial Bus DXE Driver"
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -1,836 +0,0 @@
|
|||||||
/** @file
|
|
||||||
Include for Serial Driver
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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
|
|
@ -1,366 +0,0 @@
|
|||||||
/** @file
|
|
||||||
Routines related Component Name protocol.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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)
|
|
||||||
);
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,734 +0,0 @@
|
|||||||
/** @file
|
|
||||||
Routines implements SIMPLE_TEXT_IN protocol's interfaces based on 8042 interfaces
|
|
||||||
provided by Ps2KbdCtrller.c.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
|
|
||||||
#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);
|
|
||||||
if (Status == EFI_NOT_READY) {
|
|
||||||
ZeroMem (&KeyData->Key, sizeof (KeyData->Key));
|
|
||||||
InitializeKeyState (ConsoleInDev, &KeyData->KeyState);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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. If KeyData.Key,
|
|
||||||
KeyData.KeyState.KeyToggleState and KeyData.KeyState.KeyShiftState
|
|
||||||
are 0, then any incomplete keystroke will trigger a notification of
|
|
||||||
the KeyNotificationFunction.
|
|
||||||
@param KeyNotificationFunction Points to the function to be called when the key
|
|
||||||
sequence is typed specified by KeyData. This notification function
|
|
||||||
should be called at <=TPL_CALLBACK.
|
|
||||||
@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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,657 +0,0 @@
|
|||||||
/** @file
|
|
||||||
|
|
||||||
PS/2 Keyboard driver. Routines that interacts with callers,
|
|
||||||
conforming to EFI driver model
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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;
|
|
||||||
}
|
|
||||||
|
|
@ -1,564 +0,0 @@
|
|||||||
/** @file
|
|
||||||
PS/2 keyboard driver header file
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
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. If KeyData.Key,
|
|
||||||
KeyData.KeyState.KeyToggleState and KeyData.KeyState.KeyShiftState
|
|
||||||
are 0, then any incomplete keystroke will trigger a notification of
|
|
||||||
the KeyNotificationFunction.
|
|
||||||
@param KeyNotificationFunction - Points to the function to be called when the key
|
|
||||||
sequence is typed specified by KeyData. This notification function
|
|
||||||
should be called at <=TPL_CALLBACK.
|
|
||||||
@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
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Initialize the key state.
|
|
||||||
|
|
||||||
@param ConsoleIn The KEYBOARD_CONSOLE_IN_DEV instance.
|
|
||||||
@param KeyState A pointer to receive the key state information.
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
InitializeKeyState (
|
|
||||||
IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn,
|
|
||||||
OUT EFI_KEY_STATE *KeyState
|
|
||||||
);
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,17 +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 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
//
|
|
||||||
// **/
|
|
||||||
|
|
||||||
|
|
||||||
#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."
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
|||||||
// /** @file
|
|
||||||
// Ps2KeyboardDxe Localized Strings and Content
|
|
||||||
//
|
|
||||||
// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
//
|
|
||||||
// **/
|
|
||||||
|
|
||||||
#string STR_PROPERTIES_MODULE_NAME
|
|
||||||
#language en-US
|
|
||||||
"PS2 Keyboard DXE Driver"
|
|
||||||
|
|
||||||
|
|
@ -1,79 +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 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
#
|
|
||||||
#
|
|
||||||
##
|
|
||||||
|
|
||||||
[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 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
|
|
@ -1,917 +0,0 @@
|
|||||||
/** @file
|
|
||||||
PS2 Mouse Communication Interface.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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;
|
|
||||||
}
|
|
||||||
|
|
@ -1,429 +0,0 @@
|
|||||||
/** @file
|
|
||||||
Using PS2 Mouse to simulation Absolution Pointer Device.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
@ -1,235 +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>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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)
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,772 +0,0 @@
|
|||||||
/** @file
|
|
||||||
A faked PS/2 Absolute Pointer driver. Routines that interacts with callers,
|
|
||||||
conforming to EFI driver model
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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;
|
|
||||||
}
|
|
||||||
|
|
@ -1,394 +0,0 @@
|
|||||||
/** @file
|
|
||||||
A Ps2MouseAbsolutePointer driver header file
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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
|
|
@ -1,70 +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 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
#
|
|
||||||
#
|
|
||||||
##
|
|
||||||
|
|
||||||
[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 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
|
|
@ -1,17 +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 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
//
|
|
||||||
// **/
|
|
||||||
|
|
||||||
|
|
||||||
#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."
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
|||||||
// /** @file
|
|
||||||
// Ps2MouseAbsolutePointerDxe Localized Strings and Content
|
|
||||||
//
|
|
||||||
// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
//
|
|
||||||
// **/
|
|
||||||
|
|
||||||
#string STR_PROPERTIES_MODULE_NAME
|
|
||||||
#language en-US
|
|
||||||
"PS2 Tablet Pointer DXE Driver"
|
|
||||||
|
|
||||||
|
|
@ -1,915 +0,0 @@
|
|||||||
/** @file
|
|
||||||
PS2 Mouse Communication Interface.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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;
|
|
||||||
}
|
|
@ -1,429 +0,0 @@
|
|||||||
/** @file
|
|
||||||
PS2 Mouse Communication Interface
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
@ -1,235 +0,0 @@
|
|||||||
/** @file
|
|
||||||
UEFI Component Name(2) protocol implementation for Ps2MouseDxe driver.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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)
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,786 +0,0 @@
|
|||||||
/** @file
|
|
||||||
PS/2 Mouse driver. Routines that interacts with callers,
|
|
||||||
conforming to EFI driver model.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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;
|
|
||||||
}
|
|
||||||
|
|
@ -1,394 +0,0 @@
|
|||||||
/** @file
|
|
||||||
PS/2 Mouse driver header file.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#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
|
|
@ -1,69 +0,0 @@
|
|||||||
## @file
|
|
||||||
# PS2 Mouse Driver.
|
|
||||||
#
|
|
||||||
# This dirver provides support for PS2 based mice.
|
|
||||||
#
|
|
||||||
# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
#
|
|
||||||
#
|
|
||||||
##
|
|
||||||
|
|
||||||
[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 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
|
|
@ -1,16 +0,0 @@
|
|||||||
// /** @file
|
|
||||||
// PS2 Mouse Driver.
|
|
||||||
//
|
|
||||||
// This dirver provides support for PS2 based mice.
|
|
||||||
//
|
|
||||||
// Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
//
|
|
||||||
// **/
|
|
||||||
|
|
||||||
|
|
||||||
#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."
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
|||||||
// /** @file
|
|
||||||
// Ps2MouseDxe Localized Strings and Content
|
|
||||||
//
|
|
||||||
// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
//
|
|
||||||
// **/
|
|
||||||
|
|
||||||
#string STR_PROPERTIES_MODULE_NAME
|
|
||||||
#language en-US
|
|
||||||
"PS2 Mouse DXE Driver"
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,272 +0,0 @@
|
|||||||
/** @file
|
|
||||||
UEFI Component Name(2) protocol implementation for ConPlatform driver.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#include "IdeBus.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// EFI Component Name Protocol
|
|
||||||
//
|
|
||||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIDEBusComponentName = {
|
|
||||||
IDEBusComponentNameGetDriverName,
|
|
||||||
IDEBusComponentNameGetControllerName,
|
|
||||||
"eng"
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// EFI Component Name 2 Protocol
|
|
||||||
//
|
|
||||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIDEBusComponentName2 = {
|
|
||||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IDEBusComponentNameGetDriverName,
|
|
||||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IDEBusComponentNameGetControllerName,
|
|
||||||
"en"
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIDEBusDriverNameTable[] = {
|
|
||||||
{ "eng;en", (CHAR16 *) L"PCI IDE/ATAPI Bus Driver" },
|
|
||||||
{ NULL , NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIDEBusControllerNameTable[] = {
|
|
||||||
{ "eng;en", (CHAR16 *) L"PCI IDE/ATAPI Controller" },
|
|
||||||
{ NULL , NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
Retrieves a Unicode string that is the user readable name of the driver.
|
|
||||||
|
|
||||||
This function retrieves the user readable name of a driver in the form of a
|
|
||||||
Unicode string. If the driver specified by This has a user readable name in
|
|
||||||
the language specified by Language, then a pointer to the driver name is
|
|
||||||
returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
|
|
||||||
by This does not support the language specified by Language,
|
|
||||||
then EFI_UNSUPPORTED is returned.
|
|
||||||
|
|
||||||
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
|
||||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
|
||||||
|
|
||||||
@param Language[in] A pointer to a Null-terminated ASCII string
|
|
||||||
array indicating the language. This is the
|
|
||||||
language of the driver name that the caller is
|
|
||||||
requesting, and it must match one of the
|
|
||||||
languages specified in SupportedLanguages. The
|
|
||||||
number of languages supported by a driver is up
|
|
||||||
to the driver writer. Language is specified
|
|
||||||
in RFC 4646 or ISO 639-2 language code format.
|
|
||||||
|
|
||||||
@param DriverName[out] A pointer to the Unicode string to return.
|
|
||||||
This Unicode string is the name of the
|
|
||||||
driver specified by This in the language
|
|
||||||
specified by Language.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The Unicode string for the Driver specified by
|
|
||||||
This and the language specified by Language was
|
|
||||||
returned in DriverName.
|
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER Language is NULL.
|
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER DriverName is NULL.
|
|
||||||
|
|
||||||
@retval EFI_UNSUPPORTED The driver specified by This does not support
|
|
||||||
the language specified by Language.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
IDEBusComponentNameGetDriverName (
|
|
||||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
|
||||||
IN CHAR8 *Language,
|
|
||||||
OUT CHAR16 **DriverName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return LookupUnicodeString2 (
|
|
||||||
Language,
|
|
||||||
This->SupportedLanguages,
|
|
||||||
mIDEBusDriverNameTable,
|
|
||||||
DriverName,
|
|
||||||
(BOOLEAN)(This == &gIDEBusComponentName)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Retrieves a Unicode string that is the user readable name of the controller
|
|
||||||
that is being managed by a driver.
|
|
||||||
|
|
||||||
This function retrieves the user readable name of the controller specified by
|
|
||||||
ControllerHandle and ChildHandle in the form of a Unicode string. If the
|
|
||||||
driver specified by This has a user readable name in the language specified by
|
|
||||||
Language, then a pointer to the controller name is returned in ControllerName,
|
|
||||||
and EFI_SUCCESS is returned. If the driver specified by This is not currently
|
|
||||||
managing the controller specified by ControllerHandle and ChildHandle,
|
|
||||||
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
|
|
||||||
support the language specified by Language, then EFI_UNSUPPORTED is returned.
|
|
||||||
|
|
||||||
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
|
||||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
|
||||||
|
|
||||||
@param ControllerHandle[in] The handle of a controller that the driver
|
|
||||||
specified by This is managing. This handle
|
|
||||||
specifies the controller whose name is to be
|
|
||||||
returned.
|
|
||||||
|
|
||||||
@param ChildHandle[in] The handle of the child controller to retrieve
|
|
||||||
the name of. This is an optional parameter that
|
|
||||||
may be NULL. It will be NULL for device
|
|
||||||
drivers. It will also be NULL for a bus drivers
|
|
||||||
that wish to retrieve the name of the bus
|
|
||||||
controller. It will not be NULL for a bus
|
|
||||||
driver that wishes to retrieve the name of a
|
|
||||||
child controller.
|
|
||||||
|
|
||||||
@param Language[in] A pointer to a Null-terminated ASCII string
|
|
||||||
array indicating the language. This is the
|
|
||||||
language of the driver name that the caller is
|
|
||||||
requesting, and it must match one of the
|
|
||||||
languages specified in SupportedLanguages. The
|
|
||||||
number of languages supported by a driver is up
|
|
||||||
to the driver writer. Language is specified in
|
|
||||||
RFC 4646 or ISO 639-2 language code format.
|
|
||||||
|
|
||||||
@param ControllerName[out] A pointer to the Unicode string to return.
|
|
||||||
This Unicode string is the name of the
|
|
||||||
controller specified by ControllerHandle and
|
|
||||||
ChildHandle in the language specified by
|
|
||||||
Language from the point of view of the driver
|
|
||||||
specified by This.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The Unicode string for the user readable name in
|
|
||||||
the language specified by Language for the
|
|
||||||
driver specified by This was returned in
|
|
||||||
DriverName.
|
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
|
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
|
|
||||||
EFI_HANDLE.
|
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER Language is NULL.
|
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER ControllerName is NULL.
|
|
||||||
|
|
||||||
@retval EFI_UNSUPPORTED The driver specified by This is not currently
|
|
||||||
managing the controller specified by
|
|
||||||
ControllerHandle and ChildHandle.
|
|
||||||
|
|
||||||
@retval EFI_UNSUPPORTED The driver specified by This does not support
|
|
||||||
the language specified by Language.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
IDEBusComponentNameGetControllerName (
|
|
||||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE ControllerHandle,
|
|
||||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
|
||||||
IN CHAR8 *Language,
|
|
||||||
OUT CHAR16 **ControllerName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
EFI_BLOCK_IO_PROTOCOL *BlockIo;
|
|
||||||
IDE_BLK_IO_DEV *IdeBlkIoDevice;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Make sure this driver is currently managing ControllHandle
|
|
||||||
//
|
|
||||||
Status = EfiTestManagedDevice (
|
|
||||||
ControllerHandle,
|
|
||||||
gIDEBusDriverBinding.DriverBindingHandle,
|
|
||||||
&gEfiIdeControllerInitProtocolGuid
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ChildHandle == NULL) {
|
|
||||||
return LookupUnicodeString2 (
|
|
||||||
Language,
|
|
||||||
This->SupportedLanguages,
|
|
||||||
mIDEBusControllerNameTable,
|
|
||||||
ControllerName,
|
|
||||||
(BOOLEAN)(This == &gIDEBusComponentName)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = EfiTestChildHandle (
|
|
||||||
ControllerHandle,
|
|
||||||
ChildHandle,
|
|
||||||
&gEfiPciIoProtocolGuid
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Get the child context
|
|
||||||
//
|
|
||||||
Status = gBS->OpenProtocol (
|
|
||||||
ChildHandle,
|
|
||||||
&gEfiBlockIoProtocolGuid,
|
|
||||||
(VOID **) &BlockIo,
|
|
||||||
gIDEBusDriverBinding.DriverBindingHandle,
|
|
||||||
ChildHandle,
|
|
||||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return EFI_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_THIS (BlockIo);
|
|
||||||
|
|
||||||
return LookupUnicodeString2 (
|
|
||||||
Language,
|
|
||||||
This->SupportedLanguages,
|
|
||||||
IdeBlkIoDevice->ControllerNameTable,
|
|
||||||
ControllerName,
|
|
||||||
(BOOLEAN)(This == &gIDEBusComponentName)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Add the component name for the IDE/ATAPI device
|
|
||||||
|
|
||||||
@param IdeBlkIoDevicePtr A pointer to the IDE_BLK_IO_DEV instance.
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
AddName (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeBlkIoDevicePtr
|
|
||||||
)
|
|
||||||
{
|
|
||||||
UINTN StringIndex;
|
|
||||||
CHAR16 ModelName[41];
|
|
||||||
|
|
||||||
//
|
|
||||||
// Add Component Name for the IDE/ATAPI device that was discovered.
|
|
||||||
//
|
|
||||||
IdeBlkIoDevicePtr->ControllerNameTable = NULL;
|
|
||||||
for (StringIndex = 0; StringIndex < 41; StringIndex++) {
|
|
||||||
ModelName[StringIndex] = IdeBlkIoDevicePtr->ModelName[StringIndex];
|
|
||||||
}
|
|
||||||
|
|
||||||
AddUnicodeString2 (
|
|
||||||
"eng",
|
|
||||||
gIDEBusComponentName.SupportedLanguages,
|
|
||||||
&IdeBlkIoDevicePtr->ControllerNameTable,
|
|
||||||
ModelName,
|
|
||||||
TRUE
|
|
||||||
);
|
|
||||||
AddUnicodeString2 (
|
|
||||||
"en",
|
|
||||||
gIDEBusComponentName2.SupportedLanguages,
|
|
||||||
&IdeBlkIoDevicePtr->ControllerNameTable,
|
|
||||||
ModelName,
|
|
||||||
FALSE
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
@ -1,160 +0,0 @@
|
|||||||
/** @file
|
|
||||||
|
|
||||||
UEFI Component Name(2) protocol implementation header file for IDE Bus driver.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef _IDE_BUS_COMPONENT_NAME_H_
|
|
||||||
#define _IDE_BUS_COMPONENT_NAME_H_
|
|
||||||
|
|
||||||
#define ADD_IDE_ATAPI_NAME(x) AddName ((x));
|
|
||||||
|
|
||||||
extern EFI_COMPONENT_NAME_PROTOCOL gIDEBusComponentName;
|
|
||||||
extern EFI_COMPONENT_NAME2_PROTOCOL gIDEBusComponentName2;
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// EFI Component Name Functions
|
|
||||||
//
|
|
||||||
/**
|
|
||||||
Retrieves a Unicode string that is the user readable name of the driver.
|
|
||||||
|
|
||||||
This function retrieves the user readable name of a driver in the form of a
|
|
||||||
Unicode string. If the driver specified by This has a user readable name in
|
|
||||||
the language specified by Language, then a pointer to the driver name is
|
|
||||||
returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
|
|
||||||
by This does not support the language specified by Language,
|
|
||||||
then EFI_UNSUPPORTED is returned.
|
|
||||||
|
|
||||||
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
|
||||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
|
||||||
|
|
||||||
@param Language[in] A pointer to a Null-terminated ASCII string
|
|
||||||
array indicating the language. This is the
|
|
||||||
language of the driver name that the caller is
|
|
||||||
requesting, and it must match one of the
|
|
||||||
languages specified in SupportedLanguages. The
|
|
||||||
number of languages supported by a driver is up
|
|
||||||
to the driver writer. Language is specified
|
|
||||||
in RFC 4646 or ISO 639-2 language code format.
|
|
||||||
|
|
||||||
@param DriverName[out] A pointer to the Unicode string to return.
|
|
||||||
This Unicode string is the name of the
|
|
||||||
driver specified by This in the language
|
|
||||||
specified by Language.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The Unicode string for the Driver specified by
|
|
||||||
This and the language specified by Language was
|
|
||||||
returned in DriverName.
|
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER Language is NULL.
|
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER DriverName is NULL.
|
|
||||||
|
|
||||||
@retval EFI_UNSUPPORTED The driver specified by This does not support
|
|
||||||
the language specified by Language.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
IDEBusComponentNameGetDriverName (
|
|
||||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
|
||||||
IN CHAR8 *Language,
|
|
||||||
OUT CHAR16 **DriverName
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Retrieves a Unicode string that is the user readable name of the controller
|
|
||||||
that is being managed by a driver.
|
|
||||||
|
|
||||||
This function retrieves the user readable name of the controller specified by
|
|
||||||
ControllerHandle and ChildHandle in the form of a Unicode string. If the
|
|
||||||
driver specified by This has a user readable name in the language specified by
|
|
||||||
Language, then a pointer to the controller name is returned in ControllerName,
|
|
||||||
and EFI_SUCCESS is returned. If the driver specified by This is not currently
|
|
||||||
managing the controller specified by ControllerHandle and ChildHandle,
|
|
||||||
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
|
|
||||||
support the language specified by Language, then EFI_UNSUPPORTED is returned.
|
|
||||||
|
|
||||||
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
|
||||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
|
||||||
|
|
||||||
@param ControllerHandle[in] The handle of a controller that the driver
|
|
||||||
specified by This is managing. This handle
|
|
||||||
specifies the controller whose name is to be
|
|
||||||
returned.
|
|
||||||
|
|
||||||
@param ChildHandle[in] The handle of the child controller to retrieve
|
|
||||||
the name of. This is an optional parameter that
|
|
||||||
may be NULL. It will be NULL for device
|
|
||||||
drivers. It will also be NULL for a bus drivers
|
|
||||||
that wish to retrieve the name of the bus
|
|
||||||
controller. It will not be NULL for a bus
|
|
||||||
driver that wishes to retrieve the name of a
|
|
||||||
child controller.
|
|
||||||
|
|
||||||
@param Language[in] A pointer to a Null-terminated ASCII string
|
|
||||||
array indicating the language. This is the
|
|
||||||
language of the driver name that the caller is
|
|
||||||
requesting, and it must match one of the
|
|
||||||
languages specified in SupportedLanguages. The
|
|
||||||
number of languages supported by a driver is up
|
|
||||||
to the driver writer. Language is specified in
|
|
||||||
RFC 4646 or ISO 639-2 language code format.
|
|
||||||
|
|
||||||
@param ControllerName[out] A pointer to the Unicode string to return.
|
|
||||||
This Unicode string is the name of the
|
|
||||||
controller specified by ControllerHandle and
|
|
||||||
ChildHandle in the language specified by
|
|
||||||
Language from the point of view of the driver
|
|
||||||
specified by This.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The Unicode string for the user readable name in
|
|
||||||
the language specified by Language for the
|
|
||||||
driver specified by This was returned in
|
|
||||||
DriverName.
|
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
|
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
|
|
||||||
EFI_HANDLE.
|
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER Language is NULL.
|
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER ControllerName is NULL.
|
|
||||||
|
|
||||||
@retval EFI_UNSUPPORTED The driver specified by This is not currently
|
|
||||||
managing the controller specified by
|
|
||||||
ControllerHandle and ChildHandle.
|
|
||||||
|
|
||||||
@retval EFI_UNSUPPORTED The driver specified by This does not support
|
|
||||||
the language specified by Language.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
IDEBusComponentNameGetControllerName (
|
|
||||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE ControllerHandle,
|
|
||||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
|
||||||
IN CHAR8 *Language,
|
|
||||||
OUT CHAR16 **ControllerName
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Add the component name for the IDE/ATAPI device
|
|
||||||
|
|
||||||
@param IdeBlkIoDevicePtr A pointer to the IDE_BLK_IO_DEV instance.
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
AddName (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeBlkIoDevicePtr
|
|
||||||
);
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,25 +0,0 @@
|
|||||||
/** @file
|
|
||||||
Implementation of UEFI Driver Configuration Protocol for IDE bus driver which
|
|
||||||
provides ability to set IDE bus controller specific options.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
|
|
||||||
#include "IdeBus.h"
|
|
||||||
|
|
||||||
CHAR16 *OptionString[4] = {
|
|
||||||
L"Enable Primary Master (Y/N)? -->",
|
|
||||||
L"Enable Primary Slave (Y/N)? -->",
|
|
||||||
L"Enable Secondary Master (Y/N)? -->",
|
|
||||||
L"Enable Secondary Slave (Y/N)? -->"
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// EFI Driver Configuration Protocol
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,239 +0,0 @@
|
|||||||
/** @file
|
|
||||||
Implementation of UEFI driver Dialnostics protocol which to perform diagnostic on the IDE
|
|
||||||
Bus controller.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
|
|
||||||
#include "IdeBus.h"
|
|
||||||
|
|
||||||
#define IDE_BUS_DIAGNOSTIC_ERROR L"PCI IDE/ATAPI Driver Diagnostics Failed"
|
|
||||||
|
|
||||||
//
|
|
||||||
// EFI Driver Diagnostics Protocol
|
|
||||||
//
|
|
||||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_DRIVER_DIAGNOSTICS_PROTOCOL gIDEBusDriverDiagnostics = {
|
|
||||||
IDEBusDriverDiagnosticsRunDiagnostics,
|
|
||||||
"eng"
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// EFI Driver Diagnostics 2 Protocol
|
|
||||||
//
|
|
||||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gIDEBusDriverDiagnostics2 = {
|
|
||||||
(EFI_DRIVER_DIAGNOSTICS2_RUN_DIAGNOSTICS) IDEBusDriverDiagnosticsRunDiagnostics,
|
|
||||||
"en"
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
Runs diagnostics on a controller.
|
|
||||||
|
|
||||||
@param This A pointer to the EFI_DRIVER_DIAGNOSTICS_PROTOCOLinstance.
|
|
||||||
@param ControllerHandle The handle of the controller to run diagnostics on.
|
|
||||||
@param ChildHandle The handle of the child controller to run diagnostics on
|
|
||||||
This is an optional parameter that may be NULL. It will
|
|
||||||
be NULL for device drivers. It will also be NULL for a
|
|
||||||
bus drivers that wish to run diagnostics on the bus controller.
|
|
||||||
It will not be NULL for a bus driver that wishes to run
|
|
||||||
diagnostics on one of its child controllers.
|
|
||||||
@param DiagnosticType Indicates type of diagnostics to perform on the controller
|
|
||||||
specified by ControllerHandle and ChildHandle.
|
|
||||||
@param Language A pointer to a three character ISO 639-2 language identifier.
|
|
||||||
This is the language in which the optional error message should
|
|
||||||
be returned in Buffer, and it must match one of the languages
|
|
||||||
specified in SupportedLanguages. The number of languages supported by
|
|
||||||
a driver is up to the driver writer.
|
|
||||||
@param ErrorType A GUID that defines the format of the data returned in Buffer.
|
|
||||||
@param BufferSize The size, in bytes, of the data returned in Buffer.
|
|
||||||
@param Buffer A buffer that contains a Null-terminated Unicode string
|
|
||||||
plus some additional data whose format is defined by ErrorType.
|
|
||||||
Buffer is allocated by this function with AllocatePool(), and
|
|
||||||
it is the caller's responsibility to free it with a call to FreePool().
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The controller specified by ControllerHandle and ChildHandle passed
|
|
||||||
the diagnostic.
|
|
||||||
@retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
|
|
||||||
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
|
|
||||||
@retval EFI_INVALID_PARAMETER Language is NULL.
|
|
||||||
@retval EFI_INVALID_PARAMETER ErrorType is NULL.
|
|
||||||
@retval EFI_INVALID_PARAMETER BufferType is NULL.
|
|
||||||
@retval EFI_INVALID_PARAMETER Buffer is NULL.
|
|
||||||
@retval EFI_UNSUPPORTED The driver specified by This does not support running
|
|
||||||
diagnostics for the controller specified by ControllerHandle
|
|
||||||
and ChildHandle.
|
|
||||||
@retval EFI_UNSUPPORTED The driver specified by This does not support the
|
|
||||||
type of diagnostic specified by DiagnosticType.
|
|
||||||
@retval EFI_UNSUPPORTED The driver specified by This does not support the language
|
|
||||||
specified by Language.
|
|
||||||
@retval EFI_OUT_OF_RESOURCES There are not enough resources available to complete the
|
|
||||||
diagnostics.
|
|
||||||
@retval EFI_OUT_OF_RESOURCES There are not enough resources available to return the
|
|
||||||
status information in ErrorType, BufferSize,and Buffer.
|
|
||||||
@retval EFI_DEVICE_ERROR The controller specified by ControllerHandle and ChildHandle
|
|
||||||
did not pass the diagnostic.
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
IDEBusDriverDiagnosticsRunDiagnostics (
|
|
||||||
IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE ControllerHandle,
|
|
||||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
|
||||||
IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType,
|
|
||||||
IN CHAR8 *Language,
|
|
||||||
OUT EFI_GUID **ErrorType,
|
|
||||||
OUT UINTN *BufferSize,
|
|
||||||
OUT CHAR16 **Buffer
|
|
||||||
)
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
|
||||||
EFI_BLOCK_IO_PROTOCOL *BlkIo;
|
|
||||||
IDE_BLK_IO_DEV *IdeBlkIoDevice;
|
|
||||||
UINT32 VendorDeviceId;
|
|
||||||
VOID *BlockBuffer;
|
|
||||||
CHAR8 *SupportedLanguages;
|
|
||||||
BOOLEAN Iso639Language;
|
|
||||||
BOOLEAN Found;
|
|
||||||
UINTN Index;
|
|
||||||
|
|
||||||
if (Language == NULL ||
|
|
||||||
ErrorType == NULL ||
|
|
||||||
Buffer == NULL ||
|
|
||||||
ControllerHandle == NULL ||
|
|
||||||
BufferSize == NULL) {
|
|
||||||
|
|
||||||
return EFI_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
SupportedLanguages = This->SupportedLanguages;
|
|
||||||
Iso639Language = (BOOLEAN)(This == &gIDEBusDriverDiagnostics);
|
|
||||||
//
|
|
||||||
// Make sure Language is in the set of Supported Languages
|
|
||||||
//
|
|
||||||
Found = FALSE;
|
|
||||||
while (*SupportedLanguages != 0) {
|
|
||||||
if (Iso639Language) {
|
|
||||||
if (CompareMem (Language, SupportedLanguages, 3) == 0) {
|
|
||||||
Found = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
SupportedLanguages += 3;
|
|
||||||
} else {
|
|
||||||
for (Index = 0; SupportedLanguages[Index] != 0 && SupportedLanguages[Index] != ';'; Index++);
|
|
||||||
if ((AsciiStrnCmp(SupportedLanguages, Language, Index) == 0) && (Language[Index] == 0)) {
|
|
||||||
Found = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
SupportedLanguages += Index;
|
|
||||||
for (; *SupportedLanguages != 0 && *SupportedLanguages == ';'; SupportedLanguages++);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// If Language is not a member of SupportedLanguages, then return EFI_UNSUPPORTED
|
|
||||||
//
|
|
||||||
if (!Found) {
|
|
||||||
return EFI_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
*ErrorType = NULL;
|
|
||||||
*BufferSize = 0;
|
|
||||||
|
|
||||||
if (ChildHandle == NULL) {
|
|
||||||
Status = gBS->OpenProtocol (
|
|
||||||
ControllerHandle,
|
|
||||||
&gEfiCallerIdGuid,
|
|
||||||
NULL,
|
|
||||||
gIDEBusDriverBinding.DriverBindingHandle,
|
|
||||||
ControllerHandle,
|
|
||||||
EFI_OPEN_PROTOCOL_TEST_PROTOCOL
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = gBS->OpenProtocol (
|
|
||||||
ControllerHandle,
|
|
||||||
&gEfiPciIoProtocolGuid,
|
|
||||||
(VOID **) &PciIo,
|
|
||||||
gIDEBusDriverBinding.DriverBindingHandle,
|
|
||||||
ControllerHandle,
|
|
||||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return EFI_DEVICE_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Use services of PCI I/O Protocol to test the PCI IDE/ATAPI Controller
|
|
||||||
// The following test simply reads the Device ID and Vendor ID.
|
|
||||||
// It should never fail. A real test would perform more advanced
|
|
||||||
// diagnostics.
|
|
||||||
//
|
|
||||||
|
|
||||||
Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, 0, 1, &VendorDeviceId);
|
|
||||||
if (EFI_ERROR (Status) || VendorDeviceId == 0xffffffff) {
|
|
||||||
return EFI_DEVICE_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = gBS->OpenProtocol (
|
|
||||||
ChildHandle,
|
|
||||||
&gEfiBlockIoProtocolGuid,
|
|
||||||
(VOID **) &BlkIo,
|
|
||||||
gIDEBusDriverBinding.DriverBindingHandle,
|
|
||||||
ChildHandle,
|
|
||||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_THIS (BlkIo);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Use services available from IdeBlkIoDevice to test the IDE/ATAPI device
|
|
||||||
//
|
|
||||||
Status = gBS->AllocatePool (
|
|
||||||
EfiBootServicesData,
|
|
||||||
IdeBlkIoDevice->BlkMedia.BlockSize,
|
|
||||||
(VOID **) &BlockBuffer
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = IdeBlkIoDevice->BlkIo.ReadBlocks (
|
|
||||||
&IdeBlkIoDevice->BlkIo,
|
|
||||||
IdeBlkIoDevice->BlkMedia.MediaId,
|
|
||||||
0,
|
|
||||||
IdeBlkIoDevice->BlkMedia.BlockSize,
|
|
||||||
BlockBuffer
|
|
||||||
);
|
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
*ErrorType = &gEfiCallerIdGuid;
|
|
||||||
*BufferSize = sizeof (IDE_BUS_DIAGNOSTIC_ERROR);
|
|
||||||
|
|
||||||
Status = gBS->AllocatePool (
|
|
||||||
EfiBootServicesData,
|
|
||||||
(UINTN) (*BufferSize),
|
|
||||||
(VOID **) Buffer
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
CopyMem (*Buffer, IDE_BUS_DIAGNOSTIC_ERROR, *BufferSize);
|
|
||||||
|
|
||||||
Status = EFI_DEVICE_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
gBS->FreePool (BlockBuffer);
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,805 +0,0 @@
|
|||||||
/** @file
|
|
||||||
Header file for IDE Bus Driver, containing the helper functions'
|
|
||||||
prototype.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
@par Revision Reference:
|
|
||||||
2002-6: Add Atapi6 enhancement, support >120GB hard disk, including
|
|
||||||
Add - IDEBlkIoReadBlocksExt() func definition
|
|
||||||
Add - IDEBlkIoWriteBlocksExt() func definition
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef _IDE_H_
|
|
||||||
#define _IDE_H_
|
|
||||||
|
|
||||||
//
|
|
||||||
// Helper functions Prototype
|
|
||||||
//
|
|
||||||
/**
|
|
||||||
read a one-byte data from a IDE port.
|
|
||||||
|
|
||||||
@param PciIo The PCI IO protocol instance
|
|
||||||
@param Port the IDE Port number
|
|
||||||
|
|
||||||
return the one-byte data read from IDE port
|
|
||||||
**/
|
|
||||||
UINT8
|
|
||||||
IDEReadPortB (
|
|
||||||
IN EFI_PCI_IO_PROTOCOL *PciIo,
|
|
||||||
IN UINT16 Port
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Reads multiple words of data from the IDE data port.
|
|
||||||
Call the IO abstraction once to do the complete read,
|
|
||||||
not one word at a time.
|
|
||||||
|
|
||||||
@param PciIo Pointer to the EFI_PCI_IO instance
|
|
||||||
@param Port IO port to read
|
|
||||||
@param Count No. of UINT16's to read
|
|
||||||
@param Buffer Pointer to the data buffer for read
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
IDEReadPortWMultiple (
|
|
||||||
IN EFI_PCI_IO_PROTOCOL *PciIo,
|
|
||||||
IN UINT16 Port,
|
|
||||||
IN UINTN Count,
|
|
||||||
OUT VOID *Buffer
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
write a 1-byte data to a specific IDE port.
|
|
||||||
|
|
||||||
@param PciIo PCI IO protocol instance
|
|
||||||
@param Port The IDE port to be writen
|
|
||||||
@param Data The data to write to the port
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
IDEWritePortB (
|
|
||||||
IN EFI_PCI_IO_PROTOCOL *PciIo,
|
|
||||||
IN UINT16 Port,
|
|
||||||
IN UINT8 Data
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
write a 1-word data to a specific IDE port.
|
|
||||||
|
|
||||||
@param PciIo PCI IO protocol instance
|
|
||||||
@param Port The IDE port to be writen
|
|
||||||
@param Data The data to write to the port
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
IDEWritePortW (
|
|
||||||
IN EFI_PCI_IO_PROTOCOL *PciIo,
|
|
||||||
IN UINT16 Port,
|
|
||||||
IN UINT16 Data
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Write multiple words of data to the IDE data port.
|
|
||||||
Call the IO abstraction once to do the complete read,
|
|
||||||
not one word at a time.
|
|
||||||
|
|
||||||
@param PciIo Pointer to the EFI_PCI_IO instance
|
|
||||||
@param Port IO port to read
|
|
||||||
@param Count No. of UINT16's to read
|
|
||||||
@param Buffer Pointer to the data buffer for read
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
IDEWritePortWMultiple (
|
|
||||||
IN EFI_PCI_IO_PROTOCOL *PciIo,
|
|
||||||
IN UINT16 Port,
|
|
||||||
IN UINTN Count,
|
|
||||||
IN VOID *Buffer
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Get IDE IO port registers' base addresses by mode. In 'Compatibility' mode,
|
|
||||||
use fixed addresses. In Native-PCI mode, get base addresses from BARs in
|
|
||||||
the PCI IDE controller's Configuration Space.
|
|
||||||
|
|
||||||
The steps to get IDE IO port registers' base addresses for each channel
|
|
||||||
as follows:
|
|
||||||
|
|
||||||
1. Examine the Programming Interface byte of the Class Code fields in PCI IDE
|
|
||||||
controller's Configuration Space to determine the operating mode.
|
|
||||||
|
|
||||||
2. a) In 'Compatibility' mode, use fixed addresses shown in the Table 1 below.
|
|
||||||
<pre>
|
|
||||||
___________________________________________
|
|
||||||
| | Command Block | Control Block |
|
|
||||||
| Channel | Registers | Registers |
|
|
||||||
|___________|_______________|_______________|
|
|
||||||
| Primary | 1F0h - 1F7h | 3F6h - 3F7h |
|
|
||||||
|___________|_______________|_______________|
|
|
||||||
| Secondary | 170h - 177h | 376h - 377h |
|
|
||||||
|___________|_______________|_______________|
|
|
||||||
|
|
||||||
Table 1. Compatibility resource mappings
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
b) In Native-PCI mode, IDE registers are mapped into IO space using the BARs
|
|
||||||
in IDE controller's PCI Configuration Space, shown in the Table 2 below.
|
|
||||||
<pre>
|
|
||||||
___________________________________________________
|
|
||||||
| | Command Block | Control Block |
|
|
||||||
| Channel | Registers | Registers |
|
|
||||||
|___________|___________________|___________________|
|
|
||||||
| Primary | BAR at offset 0x10| BAR at offset 0x14|
|
|
||||||
|___________|___________________|___________________|
|
|
||||||
| Secondary | BAR at offset 0x18| BAR at offset 0x1C|
|
|
||||||
|___________|___________________|___________________|
|
|
||||||
|
|
||||||
Table 2. BARs for Register Mapping
|
|
||||||
</pre>
|
|
||||||
@note Refer to Intel ICH4 datasheet, Control Block Offset: 03F4h for
|
|
||||||
primary, 0374h for secondary. So 2 bytes extra offset should be
|
|
||||||
added to the base addresses read from BARs.
|
|
||||||
|
|
||||||
For more details, please refer to PCI IDE Controller Specification and Intel
|
|
||||||
ICH4 Datasheet.
|
|
||||||
|
|
||||||
@param PciIo Pointer to the EFI_PCI_IO_PROTOCOL instance
|
|
||||||
@param IdeRegsBaseAddr Pointer to IDE_REGISTERS_BASE_ADDR to
|
|
||||||
receive IDE IO port registers' base addresses
|
|
||||||
|
|
||||||
@retval EFI_UNSUPPORTED return this value when the BARs is not IO type
|
|
||||||
@retval EFI_SUCCESS Get the Base address successfully
|
|
||||||
@retval other read the pci configureation data error
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
GetIdeRegistersBaseAddr (
|
|
||||||
IN EFI_PCI_IO_PROTOCOL *PciIo,
|
|
||||||
OUT IDE_REGISTERS_BASE_ADDR *IdeRegsBaseAddr
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
This function is used to requery IDE resources. The IDE controller will
|
|
||||||
probably switch between native and legacy modes during the EFI->CSM->OS
|
|
||||||
transfer. We do this everytime before an BlkIo operation to ensure its
|
|
||||||
succeess.
|
|
||||||
|
|
||||||
@param IdeDev The BLK_IO private data which specifies the IDE device
|
|
||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER return this value when the channel is invalid
|
|
||||||
@retval EFI_SUCCESS reassign the IDE IO resource successfully
|
|
||||||
@retval other get the IDE current base address effor
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
ReassignIdeResources (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeDev
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Detect if there is disk attached to this port.
|
|
||||||
|
|
||||||
@param IdeDev The BLK_IO private data which specifies the IDE device.
|
|
||||||
|
|
||||||
@retval EFI_NOT_FOUND The device or channel is not found
|
|
||||||
@retval EFI_SUCCESS The device is found
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
DiscoverIdeDevice (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeDev
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
This interface is used to initialize all state data related to the
|
|
||||||
detection of one channel.
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
InitializeIDEChannelData (
|
|
||||||
VOID
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
This function is used to poll for the DRQ bit clear in the Status
|
|
||||||
Register. DRQ is cleared when the device is finished transferring data.
|
|
||||||
So this function is called after data transfer is finished.
|
|
||||||
|
|
||||||
@param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
|
|
||||||
to record all the information of the IDE device.
|
|
||||||
@param TimeoutInMilliSeconds used to designate the timeout for the DRQ clear.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS DRQ bit clear within the time out.
|
|
||||||
|
|
||||||
@retval EFI_TIMEOUT DRQ bit not clear within the time out.
|
|
||||||
|
|
||||||
@note
|
|
||||||
Read Status Register will clear interrupt status.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
DRQClear (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeDev,
|
|
||||||
IN UINTN TimeoutInMilliSeconds
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
This function is used to poll for the DRQ bit clear in the Alternate
|
|
||||||
Status Register. DRQ is cleared when the device is finished
|
|
||||||
transferring data. So this function is called after data transfer
|
|
||||||
is finished.
|
|
||||||
|
|
||||||
@param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
|
|
||||||
to record all the information of the IDE device.
|
|
||||||
|
|
||||||
@param TimeoutInMilliSeconds used to designate the timeout for the DRQ clear.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS DRQ bit clear within the time out.
|
|
||||||
|
|
||||||
@retval EFI_TIMEOUT DRQ bit not clear within the time out.
|
|
||||||
@note
|
|
||||||
Read Alternate Status Register will not clear interrupt status.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
DRQClear2 (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeDev,
|
|
||||||
IN UINTN TimeoutInMilliSeconds
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
This function is used to poll for the DRQ bit set in the
|
|
||||||
Status Register.
|
|
||||||
DRQ is set when the device is ready to transfer data. So this function
|
|
||||||
is called after the command is sent to the device and before required
|
|
||||||
data is transferred.
|
|
||||||
|
|
||||||
@param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure,used to
|
|
||||||
record all the information of the IDE device.
|
|
||||||
@param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS DRQ bit set within the time out.
|
|
||||||
@retval EFI_TIMEOUT DRQ bit not set within the time out.
|
|
||||||
@retval EFI_ABORTED DRQ bit not set caused by the command abort.
|
|
||||||
|
|
||||||
@note Read Status Register will clear interrupt status.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
DRQReady (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeDev,
|
|
||||||
IN UINTN TimeoutInMilliSeconds
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
This function is used to poll for the DRQ bit set in the Alternate Status Register.
|
|
||||||
DRQ is set when the device is ready to transfer data. So this function is called after
|
|
||||||
the command is sent to the device and before required data is transferred.
|
|
||||||
|
|
||||||
@param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to
|
|
||||||
record all the information of the IDE device.
|
|
||||||
|
|
||||||
@param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS DRQ bit set within the time out.
|
|
||||||
@retval EFI_TIMEOUT DRQ bit not set within the time out.
|
|
||||||
@retval EFI_ABORTED DRQ bit not set caused by the command abort.
|
|
||||||
@note Read Alternate Status Register will not clear interrupt status.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
DRQReady2 (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeDev,
|
|
||||||
IN UINTN TimeoutInMilliSeconds
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
This function is used to poll for the BSY bit clear in the Status Register. BSY
|
|
||||||
is clear when the device is not busy. Every command must be sent after device is not busy.
|
|
||||||
|
|
||||||
@param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
|
|
||||||
to record all the information of the IDE device.
|
|
||||||
@param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS BSY bit clear within the time out.
|
|
||||||
@retval EFI_TIMEOUT BSY bit not clear within the time out.
|
|
||||||
|
|
||||||
@note Read Status Register will clear interrupt status.
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
WaitForBSYClear (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeDev,
|
|
||||||
IN UINTN TimeoutInMilliSeconds
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
This function is used to poll for the BSY bit clear in the Alternate Status Register.
|
|
||||||
BSY is clear when the device is not busy. Every command must be sent after device is
|
|
||||||
not busy.
|
|
||||||
|
|
||||||
@param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record
|
|
||||||
all the information of the IDE device.
|
|
||||||
@param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS BSY bit clear within the time out.
|
|
||||||
@retval EFI_TIMEOUT BSY bit not clear within the time out.
|
|
||||||
@note Read Alternate Status Register will not clear interrupt status.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
WaitForBSYClear2 (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeDev,
|
|
||||||
IN UINTN TimeoutInMilliSeconds
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
This function is used to poll for the DRDY bit set in the Status Register. DRDY
|
|
||||||
bit is set when the device is ready to accept command. Most ATA commands must be
|
|
||||||
sent after DRDY set except the ATAPI Packet Command.
|
|
||||||
|
|
||||||
@param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
|
|
||||||
to record all the information of the IDE device.
|
|
||||||
@param DelayInMilliSeconds used to designate the timeout for the DRQ ready.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS DRDY bit set within the time out.
|
|
||||||
@retval EFI_TIMEOUT DRDY bit not set within the time out.
|
|
||||||
|
|
||||||
@note Read Status Register will clear interrupt status.
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
DRDYReady (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeDev,
|
|
||||||
IN UINTN DelayInMilliSeconds
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
This function is used to poll for the DRDY bit set in the Alternate Status Register.
|
|
||||||
DRDY bit is set when the device is ready to accept command. Most ATA commands must
|
|
||||||
be sent after DRDY set except the ATAPI Packet Command.
|
|
||||||
|
|
||||||
@param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
|
|
||||||
to record all the information of the IDE device.
|
|
||||||
@param DelayInMilliSeconds used to designate the timeout for the DRQ ready.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS DRDY bit set within the time out.
|
|
||||||
@retval EFI_TIMEOUT DRDY bit not set within the time out.
|
|
||||||
|
|
||||||
@note Read Alternate Status Register will clear interrupt status.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
DRDYReady2 (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeDev,
|
|
||||||
IN UINTN DelayInMilliSeconds
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// ATA device functions' prototype
|
|
||||||
//
|
|
||||||
/**
|
|
||||||
Sends out an ATA Identify Command to the specified device.
|
|
||||||
|
|
||||||
This function is called by DiscoverIdeDevice() during its device
|
|
||||||
identification. It sends out the ATA Identify Command to the
|
|
||||||
specified device. Only ATA device responses to this command. If
|
|
||||||
the command succeeds, it returns the Identify data structure which
|
|
||||||
contains information about the device. This function extracts the
|
|
||||||
information it needs to fill the IDE_BLK_IO_DEV data structure,
|
|
||||||
including device type, media block size, media capacity, and etc.
|
|
||||||
|
|
||||||
@param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure,used to record
|
|
||||||
all the information of the IDE device.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS Identify ATA device successfully.
|
|
||||||
@retval EFI_DEVICE_ERROR ATA Identify Device Command failed or device is not ATA device.
|
|
||||||
@note parameter IdeDev will be updated in this function.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
ATAIdentify (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeDev
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
This function is called by ATAIdentify() or ATAPIIdentify() to print device's module name.
|
|
||||||
|
|
||||||
@param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record
|
|
||||||
all the information of the IDE device.
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
PrintAtaModuleName (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeDev
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
This function is used to send out ATA commands conforms to the PIO Data In Protocol.
|
|
||||||
|
|
||||||
@param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record
|
|
||||||
all the information of the IDE device.
|
|
||||||
@param Buffer buffer contained data transferred from device to host.
|
|
||||||
@param ByteCount data size in byte unit of the buffer.
|
|
||||||
@param AtaCommand value of the Command Register
|
|
||||||
@param Head value of the Head/Device Register
|
|
||||||
@param SectorCount value of the Sector Count Register
|
|
||||||
@param SectorNumber value of the Sector Number Register
|
|
||||||
@param CylinderLsb value of the low byte of the Cylinder Register
|
|
||||||
@param CylinderMsb value of the high byte of the Cylinder Register
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS send out the ATA command and device send required data successfully.
|
|
||||||
@retval EFI_DEVICE_ERROR command sent failed.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
AtaPioDataIn (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeDev,
|
|
||||||
IN VOID *Buffer,
|
|
||||||
IN UINT32 ByteCount,
|
|
||||||
IN UINT8 AtaCommand,
|
|
||||||
IN UINT8 Head,
|
|
||||||
IN UINT8 SectorCount,
|
|
||||||
IN UINT8 SectorNumber,
|
|
||||||
IN UINT8 CylinderLsb,
|
|
||||||
IN UINT8 CylinderMsb
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
This function is used to send out ATA commands conforms to the
|
|
||||||
PIO Data Out Protocol.
|
|
||||||
|
|
||||||
@param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
|
|
||||||
to record all the information of the IDE device.
|
|
||||||
@param *Buffer buffer contained data transferred from host to device.
|
|
||||||
@param ByteCount data size in byte unit of the buffer.
|
|
||||||
@param AtaCommand value of the Command Register
|
|
||||||
@param Head value of the Head/Device Register
|
|
||||||
@param SectorCount value of the Sector Count Register
|
|
||||||
@param SectorNumber value of the Sector Number Register
|
|
||||||
@param CylinderLsb value of the low byte of the Cylinder Register
|
|
||||||
@param CylinderMsb value of the high byte of the Cylinder Register
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS send out the ATA command and device received required
|
|
||||||
data successfully.
|
|
||||||
@retval EFI_DEVICE_ERROR command sent failed.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
AtaPioDataOut (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeDev,
|
|
||||||
IN VOID *Buffer,
|
|
||||||
IN UINT32 ByteCount,
|
|
||||||
IN UINT8 AtaCommand,
|
|
||||||
IN UINT8 Head,
|
|
||||||
IN UINT8 SectorCount,
|
|
||||||
IN UINT8 SectorNumber,
|
|
||||||
IN UINT8 CylinderLsb,
|
|
||||||
IN UINT8 CylinderMsb
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
This function is used to analyze the Status Register and print out
|
|
||||||
some debug information and if there is ERR bit set in the Status
|
|
||||||
Register, the Error Register's value is also be parsed and print out.
|
|
||||||
|
|
||||||
@param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to
|
|
||||||
record all the information of the IDE device.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS No err information in the Status Register.
|
|
||||||
@retval EFI_DEVICE_ERROR Any err information in the Status Register.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
CheckErrorStatus (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeDev
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
This function is used to implement the Soft Reset on the specified device. But,
|
|
||||||
the ATA Soft Reset mechanism is so strong a reset method that it will force
|
|
||||||
resetting on both devices connected to the same cable.
|
|
||||||
|
|
||||||
It is called by IdeBlkIoReset(), a interface function of Block
|
|
||||||
I/O protocol.
|
|
||||||
|
|
||||||
This function can also be used by the ATAPI device to perform reset when
|
|
||||||
ATAPI Reset command is failed.
|
|
||||||
|
|
||||||
@param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record
|
|
||||||
all the information of the IDE device.
|
|
||||||
@retval EFI_SUCCESS Soft reset completes successfully.
|
|
||||||
@retval EFI_DEVICE_ERROR Any step during the reset process is failed.
|
|
||||||
|
|
||||||
@note The registers initial values after ATA soft reset are different
|
|
||||||
to the ATA device and ATAPI device.
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
AtaSoftReset (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeDev
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
This function is the ATA implementation for ReadBlocks in the
|
|
||||||
Block I/O Protocol interface.
|
|
||||||
|
|
||||||
@param IdeBlkIoDevice Indicates the calling context.
|
|
||||||
@param MediaId The media id that the read request is for.
|
|
||||||
@param Lba The starting logical block address to read from on the device.
|
|
||||||
@param BufferSize The size of the Buffer in bytes. This must be a multiple
|
|
||||||
of the intrinsic block size of the device.
|
|
||||||
|
|
||||||
@param Buffer A pointer to the destination buffer for the data. The caller
|
|
||||||
is responsible for either having implicit or explicit ownership
|
|
||||||
of the memory that data is read into.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS Read Blocks successfully.
|
|
||||||
@retval EFI_DEVICE_ERROR Read Blocks failed.
|
|
||||||
@retval EFI_NO_MEDIA There is no media in the device.
|
|
||||||
@retval EFI_MEDIA_CHANGE The MediaId is not for the current media.
|
|
||||||
@retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
|
|
||||||
intrinsic block size of the device.
|
|
||||||
@retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
|
|
||||||
or the data buffer is not valid.
|
|
||||||
|
|
||||||
@note If Read Block error because of device error, this function will call
|
|
||||||
AtaSoftReset() function to reset device.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
AtaBlkIoReadBlocks (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeBlkIoDevice,
|
|
||||||
IN UINT32 MediaId,
|
|
||||||
IN EFI_LBA Lba,
|
|
||||||
IN UINTN BufferSize,
|
|
||||||
OUT VOID *Buffer
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
This function is the ATA implementation for WriteBlocks in the
|
|
||||||
Block I/O Protocol interface.
|
|
||||||
|
|
||||||
@param IdeBlkIoDevice Indicates the calling context.
|
|
||||||
@param MediaId The media id that the write request is for.
|
|
||||||
@param Lba The starting logical block address to write onto the device.
|
|
||||||
@param BufferSize The size of the Buffer in bytes. This must be a multiple
|
|
||||||
of the intrinsic block size of the device.
|
|
||||||
@param Buffer A pointer to the source buffer for the data.The caller
|
|
||||||
is responsible for either having implicit or explicit
|
|
||||||
ownership of the memory that data is written from.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS Write Blocks successfully.
|
|
||||||
@retval EFI_DEVICE_ERROR Write Blocks failed.
|
|
||||||
@retval EFI_NO_MEDIA There is no media in the device.
|
|
||||||
@retval EFI_MEDIA_CHANGE The MediaId is not for the current media.
|
|
||||||
|
|
||||||
@retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
|
|
||||||
intrinsic block size of the device.
|
|
||||||
@retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
|
|
||||||
or the data buffer is not valid.
|
|
||||||
|
|
||||||
@note If Write Block error because of device error, this function will call
|
|
||||||
AtaSoftReset() function to reset device.
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
AtaBlkIoWriteBlocks (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeBlkIoDevice,
|
|
||||||
IN UINT32 MediaId,
|
|
||||||
IN EFI_LBA Lba,
|
|
||||||
IN UINTN BufferSize,
|
|
||||||
OUT VOID *Buffer
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
This function is called by DiscoverIdeDevice() during its device
|
|
||||||
identification.
|
|
||||||
Its main purpose is to get enough information for the device media
|
|
||||||
to fill in the Media data structure of the Block I/O Protocol interface.
|
|
||||||
|
|
||||||
There are 5 steps to reach such objective:
|
|
||||||
1. Sends out the ATAPI Identify Command to the specified device.
|
|
||||||
Only ATAPI device responses to this command. If the command succeeds,
|
|
||||||
it returns the Identify data structure which filled with information
|
|
||||||
about the device. Since the ATAPI device contains removable media,
|
|
||||||
the only meaningful information is the device module name.
|
|
||||||
2. Sends out ATAPI Inquiry Packet Command to the specified device.
|
|
||||||
This command will return inquiry data of the device, which contains
|
|
||||||
the device type information.
|
|
||||||
3. Allocate sense data space for future use. We don't detect the media
|
|
||||||
presence here to improvement boot performance, especially when CD
|
|
||||||
media is present. The media detection will be performed just before
|
|
||||||
each BLK_IO read/write
|
|
||||||
|
|
||||||
@param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
|
|
||||||
to record all the information of the IDE device.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS Identify ATAPI device successfully.
|
|
||||||
@retval EFI_DEVICE_ERROR ATAPI Identify Device Command failed or device type
|
|
||||||
is not supported by this IDE driver.
|
|
||||||
@retval EFI_OUT_OF_RESOURCES Allocate memory for sense data failed
|
|
||||||
|
|
||||||
@note Parameter "IdeDev" will be updated in this function.
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
ATAPIIdentify (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeDev
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
This function is used to implement the Soft Reset on the specified
|
|
||||||
ATAPI device. Different from the AtaSoftReset(), here reset is a ATA
|
|
||||||
Soft Reset Command special for ATAPI device, and it only take effects
|
|
||||||
on the specified ATAPI device, not on the whole IDE bus.
|
|
||||||
Since the ATAPI soft reset is needed when device is in exceptional
|
|
||||||
condition (such as BSY bit is always set ), I think the Soft Reset
|
|
||||||
command should be sent without waiting for the BSY clear and DRDY
|
|
||||||
set.
|
|
||||||
This function is called by IdeBlkIoReset(),
|
|
||||||
a interface function of Block I/O protocol.
|
|
||||||
|
|
||||||
@param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used
|
|
||||||
to record all the information of the IDE device.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS Soft reset completes successfully.
|
|
||||||
@retval EFI_DEVICE_ERROR Any step during the reset process is failed.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
AtapiSoftReset (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeDev
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
This function is the ATAPI implementation for ReadBlocks in the
|
|
||||||
Block I/O Protocol interface.
|
|
||||||
|
|
||||||
@param IdeBlkIoDevice Indicates the calling context.
|
|
||||||
@param MediaId The media id that the read request is for.
|
|
||||||
@param Lba The starting logical block address to read from on the device.
|
|
||||||
@param BufferSize The size of the Buffer in bytes. This must be a multiple
|
|
||||||
of the intrinsic block size of the device.
|
|
||||||
@param Buffer A pointer to the destination buffer for the data. The caller
|
|
||||||
is responsible for either having implicit or explicit
|
|
||||||
ownership of the memory that data is read into.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS Read Blocks successfully.
|
|
||||||
@retval EFI_DEVICE_ERROR Read Blocks failed.
|
|
||||||
@retval EFI_NO_MEDIA There is no media in the device.
|
|
||||||
@retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
|
|
||||||
@retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
|
|
||||||
intrinsic block size of the device.
|
|
||||||
@retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
|
|
||||||
or the data buffer is not valid.
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
AtapiBlkIoReadBlocks (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeBlkIoDevice,
|
|
||||||
IN UINT32 MediaId,
|
|
||||||
IN EFI_LBA Lba,
|
|
||||||
IN UINTN BufferSize,
|
|
||||||
OUT VOID *Buffer
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
This function is the ATAPI implementation for WriteBlocks in the
|
|
||||||
Block I/O Protocol interface.
|
|
||||||
|
|
||||||
@param IdeBlkIoDevice Indicates the calling context.
|
|
||||||
@param MediaId The media id that the write request is for.
|
|
||||||
@param Lba The starting logical block address to write onto the device.
|
|
||||||
@param BufferSize The size of the Buffer in bytes. This must be a multiple
|
|
||||||
of the intrinsic block size of the device.
|
|
||||||
@param Buffer A pointer to the source buffer for the data. The caller
|
|
||||||
is responsible for either having implicit or explicit ownership
|
|
||||||
of the memory that data is written from.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS Write Blocks successfully.
|
|
||||||
@retval EFI_DEVICE_ERROR Write Blocks failed.
|
|
||||||
@retval EFI_NO_MEDIA There is no media in the device.
|
|
||||||
@retval EFI_MEDIA_CHANGE The MediaId is not for the current media.
|
|
||||||
@retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
|
|
||||||
intrinsic block size of the device.
|
|
||||||
@retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
|
|
||||||
or the data buffer is not valid.
|
|
||||||
|
|
||||||
@retval EFI_WRITE_PROTECTED The write protected is enabled or the media does not support write
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
AtapiBlkIoWriteBlocks (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeBlkIoDevice,
|
|
||||||
IN UINT32 MediaId,
|
|
||||||
IN EFI_LBA Lba,
|
|
||||||
IN UINTN BufferSize,
|
|
||||||
OUT VOID *Buffer
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Release resources of an IDE device before stopping it.
|
|
||||||
|
|
||||||
@param IdeBlkIoDevice Standard IDE device private data structure
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
ReleaseIdeResources (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeBlkIoDevice
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Set the calculated Best transfer mode to a detected device
|
|
||||||
|
|
||||||
@param IdeDev Standard IDE device private data structure
|
|
||||||
@param TransferMode The device transfer mode to be set
|
|
||||||
@return Set transfer mode Command execute status.
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
SetDeviceTransferMode (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeDev,
|
|
||||||
IN ATA_TRANSFER_MODE *TransferMode
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
Send ATA command into device with NON_DATA protocol.
|
|
||||||
|
|
||||||
@param IdeDev Standard IDE device private data structure
|
|
||||||
@param AtaCommand The ATA command to be sent
|
|
||||||
@param Device The value in Device register
|
|
||||||
@param Feature The value in Feature register
|
|
||||||
@param SectorCount The value in SectorCount register
|
|
||||||
@param LbaLow The value in LBA_LOW register
|
|
||||||
@param LbaMiddle The value in LBA_MIDDLE register
|
|
||||||
@param LbaHigh The value in LBA_HIGH register
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS Reading succeed
|
|
||||||
@retval EFI_ABORTED Command failed
|
|
||||||
@retval EFI_DEVICE_ERROR Device status error.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
AtaNonDataCommandIn (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeDev,
|
|
||||||
IN UINT8 AtaCommand,
|
|
||||||
IN UINT8 Device,
|
|
||||||
IN UINT8 Feature,
|
|
||||||
IN UINT8 SectorCount,
|
|
||||||
IN UINT8 LbaLow,
|
|
||||||
IN UINT8 LbaMiddle,
|
|
||||||
IN UINT8 LbaHigh
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Enable Long Physical Sector Feature for ATA device.
|
|
||||||
|
|
||||||
@param IdeDev The IDE device data
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The ATA device supports Long Physical Sector feature
|
|
||||||
and corresponding fields in BlockIo structure is updated.
|
|
||||||
@retval EFI_UNSUPPORTED The device is not ATA device or Long Physical Sector
|
|
||||||
feature is not supported.
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
AtaEnableLongPhysicalSector (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeDev
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Set drive parameters for devices not support PACKETS command.
|
|
||||||
|
|
||||||
@param IdeDev Standard IDE device private data structure
|
|
||||||
@param DriveParameters The device parameters to be set into the disk
|
|
||||||
@return SetParameters Command execute status.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
SetDriveParameters (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeDev,
|
|
||||||
IN ATA_DRIVE_PARMS *DriveParameters
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Enable Interrupt on IDE controller.
|
|
||||||
|
|
||||||
@param IdeDev Standard IDE device private data structure
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS Enable Interrupt successfully
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EnableInterrupt (
|
|
||||||
IN IDE_BLK_IO_DEV *IdeDev
|
|
||||||
);
|
|
||||||
#endif
|
|
File diff suppressed because it is too large
Load Diff
@ -1,421 +0,0 @@
|
|||||||
/** @file
|
|
||||||
Header file for IDE Bus Driver.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef _IDE_BUS_H_
|
|
||||||
#define _IDE_BUS_H_
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <FrameworkDxe.h>
|
|
||||||
|
|
||||||
#include <Protocol/IdeControllerInit.h>
|
|
||||||
#include <Protocol/BlockIo.h>
|
|
||||||
#include <Protocol/PciIo.h>
|
|
||||||
#include <Protocol/DiskInfo.h>
|
|
||||||
#include <Protocol/DevicePath.h>
|
|
||||||
|
|
||||||
#include <Library/DebugLib.h>
|
|
||||||
#include <Library/UefiDriverEntryPoint.h>
|
|
||||||
#include <Library/BaseLib.h>
|
|
||||||
#include <Library/UefiLib.h>
|
|
||||||
#include <Library/BaseMemoryLib.h>
|
|
||||||
#include <Library/ReportStatusCodeLib.h>
|
|
||||||
#include <Library/MemoryAllocationLib.h>
|
|
||||||
#include <Library/PerformanceLib.h>
|
|
||||||
#include <Library/UefiBootServicesTableLib.h>
|
|
||||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
|
||||||
#include <Library/DevicePathLib.h>
|
|
||||||
|
|
||||||
#include <Guid/EventGroup.h>
|
|
||||||
|
|
||||||
#include <IndustryStandard/Pci.h>
|
|
||||||
#include "IdeData.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// Global Variables
|
|
||||||
//
|
|
||||||
extern EFI_DRIVER_BINDING_PROTOCOL gIDEBusDriverBinding;
|
|
||||||
extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL gIDEBusDriverDiagnostics;
|
|
||||||
extern EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gIDEBusDriverDiagnostics2;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Extra Definition to porting
|
|
||||||
//
|
|
||||||
#define MAX_IDE_DEVICE 4
|
|
||||||
#define MAX_IDE_CHANNELS 2
|
|
||||||
#define MAX_IDE_DRIVES 2
|
|
||||||
|
|
||||||
#define INVALID_DEVICE_TYPE 0xff
|
|
||||||
#define ATA_DEVICE_TYPE 0x00
|
|
||||||
#define ATAPI_DEVICE_TYPE 0x01
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
BOOLEAN HaveScannedDevice[MAX_IDE_DEVICE];
|
|
||||||
BOOLEAN DeviceFound[MAX_IDE_DEVICE];
|
|
||||||
BOOLEAN DeviceProcessed[MAX_IDE_DEVICE];
|
|
||||||
} IDE_BUS_DRIVER_PRIVATE_DATA;
|
|
||||||
|
|
||||||
#define IDE_BLK_IO_DEV_SIGNATURE SIGNATURE_32 ('i', 'b', 'i', 'd')
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINT32 Signature;
|
|
||||||
|
|
||||||
EFI_HANDLE Handle;
|
|
||||||
EFI_BLOCK_IO_PROTOCOL BlkIo;
|
|
||||||
EFI_BLOCK_IO_MEDIA BlkMedia;
|
|
||||||
EFI_DISK_INFO_PROTOCOL DiskInfo;
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
|
||||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
|
||||||
IDE_BUS_DRIVER_PRIVATE_DATA *IdeBusDriverPrivateData;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Local Data for IDE interface goes here
|
|
||||||
//
|
|
||||||
EFI_IDE_CHANNEL Channel;
|
|
||||||
EFI_IDE_DEVICE Device;
|
|
||||||
UINT16 Lun;
|
|
||||||
IDE_DEVICE_TYPE Type;
|
|
||||||
|
|
||||||
IDE_BASE_REGISTERS *IoPort;
|
|
||||||
UINT16 AtapiError;
|
|
||||||
|
|
||||||
ATAPI_INQUIRY_DATA *InquiryData;
|
|
||||||
EFI_IDENTIFY_DATA *IdData;
|
|
||||||
ATA_PIO_MODE PioMode;
|
|
||||||
EFI_ATA_MODE UdmaMode;
|
|
||||||
CHAR8 ModelName[41];
|
|
||||||
ATAPI_REQUEST_SENSE_DATA *SenseData;
|
|
||||||
UINT8 SenseDataNumber;
|
|
||||||
UINT8 *Cache;
|
|
||||||
|
|
||||||
//
|
|
||||||
// ExitBootService Event, it is used to clear pending IDE interrupt
|
|
||||||
//
|
|
||||||
EFI_EVENT ExitBootServiceEvent;
|
|
||||||
|
|
||||||
EFI_UNICODE_STRING_TABLE *ControllerNameTable;
|
|
||||||
} IDE_BLK_IO_DEV;
|
|
||||||
|
|
||||||
#include "ComponentName.h"
|
|
||||||
|
|
||||||
#define IDE_BLOCK_IO_DEV_FROM_THIS(a) CR (a, IDE_BLK_IO_DEV, BlkIo, IDE_BLK_IO_DEV_SIGNATURE)
|
|
||||||
#define IDE_BLOCK_IO_DEV_FROM_DISK_INFO_THIS(a) CR (a, IDE_BLK_IO_DEV, DiskInfo, IDE_BLK_IO_DEV_SIGNATURE)
|
|
||||||
|
|
||||||
#include "Ide.h"
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Supported function of Driver Binding protocol for this driver.
|
|
||||||
|
|
||||||
@param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
|
|
||||||
@param ControllerHandle The handle of the controller to test.
|
|
||||||
@param RemainingDevicePath A pointer to the remaining portion of a device path.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS Driver loaded.
|
|
||||||
@retval other Driver not loaded.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
IDEBusDriverBindingSupported (
|
|
||||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE Controller,
|
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Start function of Driver binding protocol which start this driver on Controller
|
|
||||||
by detecting all disks and installing BlockIo protocol on them.
|
|
||||||
|
|
||||||
@param This Protocol instance pointer.
|
|
||||||
@param Controller Handle of device to bind driver to.
|
|
||||||
@param RemainingDevicePath produce all possible children.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS This driver is added to ControllerHandle.
|
|
||||||
@retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
|
|
||||||
@retval other This driver does not support this device.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
IDEBusDriverBindingStart (
|
|
||||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE Controller,
|
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Stop function of Driver Binding Protocol which is to stop the driver on Controller Handle and all
|
|
||||||
child handle attached to the controller handle if there are.
|
|
||||||
|
|
||||||
@param This Protocol instance pointer.
|
|
||||||
@param Controller Handle of device to stop driver on
|
|
||||||
@param NumberOfChildren Not used
|
|
||||||
@param ChildHandleBuffer Not used
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS This driver is removed DeviceHandle
|
|
||||||
@retval other This driver was not removed from this device
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
IDEBusDriverBindingStop (
|
|
||||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE Controller,
|
|
||||||
IN UINTN NumberOfChildren,
|
|
||||||
IN EFI_HANDLE *ChildHandleBuffer
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// EFI Driver Configuration Functions
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// EFI Driver Diagnostics Functions
|
|
||||||
//
|
|
||||||
/**
|
|
||||||
Runs diagnostics on a controller.
|
|
||||||
|
|
||||||
@param This A pointer to the EFI_DRIVER_DIAGNOSTICS_PROTOCOLinstance.
|
|
||||||
@param ControllerHandle The handle of the controller to run diagnostics on.
|
|
||||||
@param ChildHandle The handle of the child controller to run diagnostics on
|
|
||||||
This is an optional parameter that may be NULL. It will
|
|
||||||
be NULL for device drivers. It will also be NULL for a
|
|
||||||
bus drivers that wish to run diagnostics on the bus controller.
|
|
||||||
It will not be NULL for a bus driver that wishes to run
|
|
||||||
diagnostics on one of its child controllers.
|
|
||||||
@param DiagnosticType Indicates type of diagnostics to perform on the controller
|
|
||||||
specified by ControllerHandle and ChildHandle.
|
|
||||||
@param Language A pointer to a three character ISO 639-2 language identifier.
|
|
||||||
This is the language in which the optional error message should
|
|
||||||
be returned in Buffer, and it must match one of the languages
|
|
||||||
specified in SupportedLanguages. The number of languages supported by
|
|
||||||
a driver is up to the driver writer.
|
|
||||||
@param ErrorType A GUID that defines the format of the data returned in Buffer.
|
|
||||||
@param BufferSize The size, in bytes, of the data returned in Buffer.
|
|
||||||
@param Buffer A buffer that contains a Null-terminated Unicode string
|
|
||||||
plus some additional data whose format is defined by ErrorType.
|
|
||||||
Buffer is allocated by this function with AllocatePool(), and
|
|
||||||
it is the caller's responsibility to free it with a call to FreePool().
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The controller specified by ControllerHandle and ChildHandle passed
|
|
||||||
the diagnostic.
|
|
||||||
@retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
|
|
||||||
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
|
|
||||||
@retval EFI_INVALID_PARAMETER Language is NULL.
|
|
||||||
@retval EFI_INVALID_PARAMETER ErrorType is NULL.
|
|
||||||
@retval EFI_INVALID_PARAMETER BufferType is NULL.
|
|
||||||
@retval EFI_INVALID_PARAMETER Buffer is NULL.
|
|
||||||
@retval EFI_UNSUPPORTED The driver specified by This does not support running
|
|
||||||
diagnostics for the controller specified by ControllerHandle
|
|
||||||
and ChildHandle.
|
|
||||||
@retval EFI_UNSUPPORTED The driver specified by This does not support the
|
|
||||||
type of diagnostic specified by DiagnosticType.
|
|
||||||
@retval EFI_UNSUPPORTED The driver specified by This does not support the language
|
|
||||||
specified by Language.
|
|
||||||
@retval EFI_OUT_OF_RESOURCES There are not enough resources available to complete the
|
|
||||||
diagnostics.
|
|
||||||
@retval EFI_OUT_OF_RESOURCES There are not enough resources available to return the
|
|
||||||
status information in ErrorType, BufferSize,and Buffer.
|
|
||||||
@retval EFI_DEVICE_ERROR The controller specified by ControllerHandle and ChildHandle
|
|
||||||
did not pass the diagnostic.
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
IDEBusDriverDiagnosticsRunDiagnostics (
|
|
||||||
IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE ControllerHandle,
|
|
||||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
|
||||||
IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType,
|
|
||||||
IN CHAR8 *Language,
|
|
||||||
OUT EFI_GUID **ErrorType,
|
|
||||||
OUT UINTN *BufferSize,
|
|
||||||
OUT CHAR16 **Buffer
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
issue ATA or ATAPI command to reset a block IO device.
|
|
||||||
@param This Block IO protocol instance pointer.
|
|
||||||
@param ExtendedVerification If FALSE,for ATAPI device, driver will only invoke ATAPI reset method
|
|
||||||
If TRUE, for ATAPI device, driver need invoke ATA reset method after
|
|
||||||
invoke ATAPI reset method
|
|
||||||
|
|
||||||
@retval EFI_DEVICE_ERROR When the device is neighther ATA device or ATAPI device.
|
|
||||||
@retval EFI_SUCCESS The device reset successfully
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
IDEBlkIoReset (
|
|
||||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
|
||||||
IN BOOLEAN ExtendedVerification
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Read data from a block IO device.
|
|
||||||
|
|
||||||
@param This Block IO protocol instance pointer.
|
|
||||||
@param MediaId The media ID of the device
|
|
||||||
@param Lba Starting LBA address to read data
|
|
||||||
@param BufferSize The size of data to be read
|
|
||||||
@param Buffer Caller supplied buffer to save data
|
|
||||||
|
|
||||||
@retval EFI_DEVICE_ERROR unknown device type
|
|
||||||
@retval EFI_SUCCESS read the data successfully.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
IDEBlkIoReadBlocks (
|
|
||||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
|
||||||
IN UINT32 MediaId,
|
|
||||||
IN EFI_LBA Lba,
|
|
||||||
IN UINTN BufferSize,
|
|
||||||
OUT VOID *Buffer
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Write data to block io device
|
|
||||||
|
|
||||||
@param This Protocol instance pointer.
|
|
||||||
@param MediaId The media ID of the device
|
|
||||||
@param Lba Starting LBA address to write data
|
|
||||||
@param BufferSize The size of data to be written
|
|
||||||
@param Buffer Caller supplied buffer to save data
|
|
||||||
|
|
||||||
@retval EFI_DEVICE_ERROR unknown device type
|
|
||||||
@retval other write data status
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
IDEBlkIoWriteBlocks (
|
|
||||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
|
||||||
IN UINT32 MediaId,
|
|
||||||
IN EFI_LBA Lba,
|
|
||||||
IN UINTN BufferSize,
|
|
||||||
IN VOID *Buffer
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Flushes all modified data to a physical block devices
|
|
||||||
|
|
||||||
@param This Indicates a pointer to the calling context which to sepcify a
|
|
||||||
sepcific block device
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS Always return success.
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
IDEBlkIoFlushBlocks (
|
|
||||||
IN EFI_BLOCK_IO_PROTOCOL *This
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
This function is used by the IDE bus driver to get inquiry data.
|
|
||||||
Data format of Identify data is defined by the Interface GUID.
|
|
||||||
|
|
||||||
@param This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
|
|
||||||
@param InquiryData Pointer to a buffer for the inquiry data.
|
|
||||||
@param InquiryDataSize Pointer to the value for the inquiry data size.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The command was accepted without any errors.
|
|
||||||
@retval EFI_NOT_FOUND Device does not support this data class
|
|
||||||
@retval EFI_DEVICE_ERROR Error reading InquiryData from device
|
|
||||||
@retval EFI_BUFFER_TOO_SMALL IntquiryDataSize not big enough
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
IDEDiskInfoInquiry (
|
|
||||||
IN EFI_DISK_INFO_PROTOCOL *This,
|
|
||||||
IN OUT VOID *InquiryData,
|
|
||||||
IN OUT UINT32 *InquiryDataSize
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
This function is used by the IDE bus driver to get identify data.
|
|
||||||
Data format of Identify data is defined by the Interface GUID.
|
|
||||||
|
|
||||||
@param This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
|
|
||||||
@param IdentifyData Pointer to a buffer for the identify data.
|
|
||||||
@param IdentifyDataSize Pointer to the value for the identify data size.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The command was accepted without any errors.
|
|
||||||
@retval EFI_NOT_FOUND Device does not support this data class
|
|
||||||
@retval EFI_DEVICE_ERROR Error reading IdentifyData from device
|
|
||||||
@retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
IDEDiskInfoIdentify (
|
|
||||||
IN EFI_DISK_INFO_PROTOCOL *This,
|
|
||||||
IN OUT VOID *IdentifyData,
|
|
||||||
IN OUT UINT32 *IdentifyDataSize
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
This function is used by the IDE bus driver to get sense data.
|
|
||||||
Data format of Sense data is defined by the Interface GUID.
|
|
||||||
|
|
||||||
@param This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
|
|
||||||
@param SenseData Pointer to the SenseData.
|
|
||||||
@param SenseDataSize Size of SenseData in bytes.
|
|
||||||
@param SenseDataNumber Pointer to the value for the identify data size.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The command was accepted without any errors.
|
|
||||||
@retval EFI_NOT_FOUND Device does not support this data class
|
|
||||||
@retval EFI_DEVICE_ERROR Error reading InquiryData from device
|
|
||||||
@retval EFI_BUFFER_TOO_SMALL SenseDataSize not big enough
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
IDEDiskInfoSenseData (
|
|
||||||
IN EFI_DISK_INFO_PROTOCOL *This,
|
|
||||||
IN OUT VOID *SenseData,
|
|
||||||
IN OUT UINT32 *SenseDataSize,
|
|
||||||
OUT UINT8 *SenseDataNumber
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
This function is used by the IDE bus driver to get controller information.
|
|
||||||
|
|
||||||
@param This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
|
|
||||||
@param IdeChannel Pointer to the Ide Channel number. Primary or secondary.
|
|
||||||
@param IdeDevice Pointer to the Ide Device number. Master or slave.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS IdeChannel and IdeDevice are valid
|
|
||||||
@retval EFI_UNSUPPORTED This is not an IDE device
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
IDEDiskInfoWhichIde (
|
|
||||||
IN EFI_DISK_INFO_PROTOCOL *This,
|
|
||||||
OUT UINT32 *IdeChannel,
|
|
||||||
OUT UINT32 *IdeDevice
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
The is an event(generally the event is exitBootService event) call back function.
|
|
||||||
Clear pending IDE interrupt before OS loader/kernel take control of the IDE device.
|
|
||||||
|
|
||||||
@param Event Pointer to this event
|
|
||||||
@param Context Event handler private data
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
EFIAPI
|
|
||||||
ClearInterrupt (
|
|
||||||
IN EFI_EVENT Event,
|
|
||||||
IN VOID *Context
|
|
||||||
);
|
|
||||||
#endif
|
|
@ -1,83 +0,0 @@
|
|||||||
## @file
|
|
||||||
# IDE bus driver.
|
|
||||||
#
|
|
||||||
# This driver will enumerate IDE device and export the blockIo protocol for every device.
|
|
||||||
#
|
|
||||||
# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
#
|
|
||||||
#
|
|
||||||
##
|
|
||||||
|
|
||||||
[Defines]
|
|
||||||
INF_VERSION = 0x00010005
|
|
||||||
BASE_NAME = IdeBusDxe
|
|
||||||
MODULE_UNI_FILE = IdeBusDxe.uni
|
|
||||||
FILE_GUID = 69FD8E47-A161-4550-B01A-5594CEB2B2B2
|
|
||||||
MODULE_TYPE = UEFI_DRIVER
|
|
||||||
VERSION_STRING = 1.0
|
|
||||||
ENTRY_POINT = InitializeIdeBus
|
|
||||||
|
|
||||||
#
|
|
||||||
# The following information is for reference only and not required by the build tools.
|
|
||||||
#
|
|
||||||
# VALID_ARCHITECTURES = IA32 X64 EBC
|
|
||||||
#
|
|
||||||
# DRIVER_BINDING = gIDEBusDriverBinding
|
|
||||||
# COMPONENT_NAME = gIDEBusComponentName
|
|
||||||
# COMPONENT_NAME2 = gIDEBusComponentName2
|
|
||||||
# Variable Guid C Name: gConfigurationGuid Variable Name: L"Configuration"
|
|
||||||
#
|
|
||||||
#
|
|
||||||
|
|
||||||
[Sources]
|
|
||||||
DriverDiagnostics.c
|
|
||||||
DriverConfiguration.c
|
|
||||||
ComponentName.h
|
|
||||||
ComponentName.c
|
|
||||||
Atapi.c
|
|
||||||
Ata.c
|
|
||||||
Ide.c
|
|
||||||
IdeBus.c
|
|
||||||
IdeData.h
|
|
||||||
Ide.h
|
|
||||||
IdeBus.h
|
|
||||||
|
|
||||||
|
|
||||||
[Packages]
|
|
||||||
MdePkg/MdePkg.dec
|
|
||||||
IntelFrameworkPkg/IntelFrameworkPkg.dec
|
|
||||||
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
|
|
||||||
|
|
||||||
|
|
||||||
[LibraryClasses]
|
|
||||||
DevicePathLib
|
|
||||||
UefiRuntimeServicesTableLib
|
|
||||||
UefiBootServicesTableLib
|
|
||||||
PerformanceLib
|
|
||||||
MemoryAllocationLib
|
|
||||||
ReportStatusCodeLib
|
|
||||||
BaseMemoryLib
|
|
||||||
UefiLib
|
|
||||||
BaseLib
|
|
||||||
UefiDriverEntryPoint
|
|
||||||
DebugLib
|
|
||||||
|
|
||||||
|
|
||||||
[Guids]
|
|
||||||
gEfiDiskInfoIdeInterfaceGuid ## SOMETIMES_PRODUCES ## UNDEFINED # DiskInfo Interface Guid
|
|
||||||
gEfiEventExitBootServicesGuid ## CONSUMES ## Event
|
|
||||||
|
|
||||||
|
|
||||||
[Protocols]
|
|
||||||
gEfiDiskInfoProtocolGuid ## BY_START
|
|
||||||
gEfiBlockIoProtocolGuid ## BY_START
|
|
||||||
gEfiIdeControllerInitProtocolGuid ## TO_START
|
|
||||||
gEfiPciIoProtocolGuid ## TO_START
|
|
||||||
## TO_START
|
|
||||||
## BY_START
|
|
||||||
gEfiDevicePathProtocolGuid
|
|
||||||
|
|
||||||
[UserExtensions.TianoCore."ExtraFiles"]
|
|
||||||
IdeBusDxeExtra.uni
|
|
@ -1,16 +0,0 @@
|
|||||||
// /** @file
|
|
||||||
// IDE bus driver.
|
|
||||||
//
|
|
||||||
// This driver will enumerate IDE device and export the blockIo protocol for every device.
|
|
||||||
//
|
|
||||||
// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
//
|
|
||||||
// **/
|
|
||||||
|
|
||||||
|
|
||||||
#string STR_MODULE_ABSTRACT #language en-US "IDE bus driver"
|
|
||||||
|
|
||||||
#string STR_MODULE_DESCRIPTION #language en-US "This driver will enumerate IDE device and export the blockIo protocol for every device."
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
|||||||
// /** @file
|
|
||||||
// IdeBusDxe Localized Strings and Content
|
|
||||||
//
|
|
||||||
// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
//
|
|
||||||
// **/
|
|
||||||
|
|
||||||
#string STR_PROPERTIES_MODULE_NAME
|
|
||||||
#language en-US
|
|
||||||
"IDE Bus DXE Driver"
|
|
||||||
|
|
||||||
|
|
@ -1,305 +0,0 @@
|
|||||||
/** @file
|
|
||||||
Header file for IDE Bus Driver's Data Structures
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef _IDE_DATA_H_
|
|
||||||
#define _IDE_DATA_H_
|
|
||||||
|
|
||||||
#include <IndustryStandard/Atapi.h>
|
|
||||||
|
|
||||||
//
|
|
||||||
// common constants
|
|
||||||
//
|
|
||||||
#define STALL_1_MILLI_SECOND 1000 // stall 1 ms
|
|
||||||
#define STALL_1_SECOND 1000000 // stall 1 second
|
|
||||||
typedef enum {
|
|
||||||
IdePrimary = 0,
|
|
||||||
IdeSecondary = 1,
|
|
||||||
IdeMaxChannel = 2
|
|
||||||
} EFI_IDE_CHANNEL;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
IdeMaster = 0,
|
|
||||||
IdeSlave = 1,
|
|
||||||
IdeMaxDevice = 2
|
|
||||||
} EFI_IDE_DEVICE;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
IdeMagnetic, /* ZIP Drive or LS120 Floppy Drive */
|
|
||||||
IdeCdRom, /* ATAPI CDROM */
|
|
||||||
IdeHardDisk, /* Hard Disk */
|
|
||||||
Ide48bitAddressingHardDisk, /* Hard Disk larger than 120GB */
|
|
||||||
IdeUnknown
|
|
||||||
} IDE_DEVICE_TYPE;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
SenseNoSenseKey,
|
|
||||||
SenseDeviceNotReadyNoRetry,
|
|
||||||
SenseDeviceNotReadyNeedRetry,
|
|
||||||
SenseNoMedia,
|
|
||||||
SenseMediaChange,
|
|
||||||
SenseMediaError,
|
|
||||||
SenseOtherSense
|
|
||||||
} SENSE_RESULT;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
AtaUdmaReadOp,
|
|
||||||
AtaUdmaReadExtOp,
|
|
||||||
AtaUdmaWriteOp,
|
|
||||||
AtaUdmaWriteExtOp
|
|
||||||
} ATA_UDMA_OPERATION;
|
|
||||||
|
|
||||||
//
|
|
||||||
// IDE Registers
|
|
||||||
//
|
|
||||||
typedef union {
|
|
||||||
UINT16 Command; /* when write */
|
|
||||||
UINT16 Status; /* when read */
|
|
||||||
} IDE_CMD_OR_STATUS;
|
|
||||||
|
|
||||||
typedef union {
|
|
||||||
UINT16 Error; /* when read */
|
|
||||||
UINT16 Feature; /* when write */
|
|
||||||
} IDE_ERROR_OR_FEATURE;
|
|
||||||
|
|
||||||
typedef union {
|
|
||||||
UINT16 AltStatus; /* when read */
|
|
||||||
UINT16 DeviceControl; /* when write */
|
|
||||||
} IDE_ALTSTATUS_OR_DEVICECONTROL;
|
|
||||||
|
|
||||||
//
|
|
||||||
// IDE registers set
|
|
||||||
//
|
|
||||||
typedef struct {
|
|
||||||
UINT16 Data;
|
|
||||||
IDE_ERROR_OR_FEATURE Reg1;
|
|
||||||
UINT16 SectorCount;
|
|
||||||
UINT16 SectorNumber;
|
|
||||||
UINT16 CylinderLsb;
|
|
||||||
UINT16 CylinderMsb;
|
|
||||||
UINT16 Head;
|
|
||||||
IDE_CMD_OR_STATUS Reg;
|
|
||||||
|
|
||||||
IDE_ALTSTATUS_OR_DEVICECONTROL Alt;
|
|
||||||
UINT16 DriveAddress;
|
|
||||||
|
|
||||||
UINT16 MasterSlave;
|
|
||||||
UINT16 BusMasterBaseAddr;
|
|
||||||
} IDE_BASE_REGISTERS;
|
|
||||||
|
|
||||||
//
|
|
||||||
// IDE registers' base addresses
|
|
||||||
//
|
|
||||||
typedef struct {
|
|
||||||
UINT16 CommandBlockBaseAddr;
|
|
||||||
UINT16 ControlBlockBaseAddr;
|
|
||||||
UINT16 BusMasterBaseAddr;
|
|
||||||
} IDE_REGISTERS_BASE_ADDR;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Bit definitions in Programming Interface byte of the Class Code field
|
|
||||||
// in PCI IDE controller's Configuration Space
|
|
||||||
//
|
|
||||||
#define IDE_PRIMARY_OPERATING_MODE BIT0
|
|
||||||
#define IDE_PRIMARY_PROGRAMMABLE_INDICATOR BIT1
|
|
||||||
#define IDE_SECONDARY_OPERATING_MODE BIT2
|
|
||||||
#define IDE_SECONDARY_PROGRAMMABLE_INDICATOR BIT3
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Bus Master Reg
|
|
||||||
//
|
|
||||||
#define BMIC_NREAD BIT3
|
|
||||||
#define BMIC_START BIT0
|
|
||||||
#define BMIS_INTERRUPT BIT2
|
|
||||||
#define BMIS_ERROR BIT1
|
|
||||||
|
|
||||||
#define BMICP_OFFSET 0x00
|
|
||||||
#define BMISP_OFFSET 0x02
|
|
||||||
#define BMIDP_OFFSET 0x04
|
|
||||||
#define BMICS_OFFSET 0x08
|
|
||||||
#define BMISS_OFFSET 0x0A
|
|
||||||
#define BMIDS_OFFSET 0x0C
|
|
||||||
|
|
||||||
//
|
|
||||||
// Time Out Value For IDE Device Polling
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// ATATIMEOUT is used for waiting time out for ATA device
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// 1 second
|
|
||||||
//
|
|
||||||
#define ATATIMEOUT 1000
|
|
||||||
|
|
||||||
//
|
|
||||||
// ATAPITIMEOUT is used for waiting operation
|
|
||||||
// except read and write time out for ATAPI device
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// 1 second
|
|
||||||
//
|
|
||||||
#define ATAPITIMEOUT 1000
|
|
||||||
|
|
||||||
//
|
|
||||||
// ATAPILONGTIMEOUT is used for waiting read and
|
|
||||||
// write operation timeout for ATAPI device
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// 2 seconds
|
|
||||||
//
|
|
||||||
#define CDROMLONGTIMEOUT 2000
|
|
||||||
|
|
||||||
//
|
|
||||||
// 5 seconds
|
|
||||||
//
|
|
||||||
#define ATAPILONGTIMEOUT 5000
|
|
||||||
|
|
||||||
//
|
|
||||||
// 10 seconds
|
|
||||||
//
|
|
||||||
#define ATASMARTTIMEOUT 10000
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// ATAPI6 related data structure definition
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// The maximum sectors count in 28 bit addressing mode
|
|
||||||
//
|
|
||||||
#define MAX_28BIT_ADDRESSING_CAPACITY 0xfffffff
|
|
||||||
|
|
||||||
#pragma pack(1)
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINT32 RegionBaseAddr;
|
|
||||||
UINT16 ByteCount;
|
|
||||||
UINT16 EndOfTable;
|
|
||||||
} IDE_DMA_PRD;
|
|
||||||
|
|
||||||
#pragma pack()
|
|
||||||
|
|
||||||
#define SETFEATURE TRUE
|
|
||||||
#define CLEARFEATURE FALSE
|
|
||||||
|
|
||||||
///
|
|
||||||
/// PIO mode definition
|
|
||||||
///
|
|
||||||
typedef enum _ATA_PIO_MODE_ {
|
|
||||||
AtaPioModeBelow2,
|
|
||||||
AtaPioMode2,
|
|
||||||
AtaPioMode3,
|
|
||||||
AtaPioMode4
|
|
||||||
} ATA_PIO_MODE;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Multi word DMA definition
|
|
||||||
//
|
|
||||||
typedef enum _ATA_MDMA_MODE_ {
|
|
||||||
AtaMdmaMode0,
|
|
||||||
AtaMdmaMode1,
|
|
||||||
AtaMdmaMode2
|
|
||||||
} ATA_MDMA_MODE;
|
|
||||||
|
|
||||||
//
|
|
||||||
// UDMA mode definition
|
|
||||||
//
|
|
||||||
typedef enum _ATA_UDMA_MODE_ {
|
|
||||||
AtaUdmaMode0,
|
|
||||||
AtaUdmaMode1,
|
|
||||||
AtaUdmaMode2,
|
|
||||||
AtaUdmaMode3,
|
|
||||||
AtaUdmaMode4,
|
|
||||||
AtaUdmaMode5
|
|
||||||
} ATA_UDMA_MODE;
|
|
||||||
|
|
||||||
#define ATA_MODE_CATEGORY_DEFAULT_PIO 0x00
|
|
||||||
#define ATA_MODE_CATEGORY_FLOW_PIO 0x01
|
|
||||||
#define ATA_MODE_CATEGORY_MDMA 0x04
|
|
||||||
#define ATA_MODE_CATEGORY_UDMA 0x08
|
|
||||||
|
|
||||||
#pragma pack(1)
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINT8 ModeNumber : 3;
|
|
||||||
UINT8 ModeCategory : 5;
|
|
||||||
} ATA_TRANSFER_MODE;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINT8 Sector;
|
|
||||||
UINT8 Heads;
|
|
||||||
UINT8 MultipleSector;
|
|
||||||
} ATA_DRIVE_PARMS;
|
|
||||||
|
|
||||||
#pragma pack()
|
|
||||||
//
|
|
||||||
// IORDY Sample Point field value
|
|
||||||
//
|
|
||||||
#define ISP_5_CLK 0
|
|
||||||
#define ISP_4_CLK 1
|
|
||||||
#define ISP_3_CLK 2
|
|
||||||
#define ISP_2_CLK 3
|
|
||||||
|
|
||||||
//
|
|
||||||
// Recovery Time field value
|
|
||||||
//
|
|
||||||
#define RECVY_4_CLK 0
|
|
||||||
#define RECVY_3_CLK 1
|
|
||||||
#define RECVY_2_CLK 2
|
|
||||||
#define RECVY_1_CLK 3
|
|
||||||
|
|
||||||
//
|
|
||||||
// Slave IDE Timing Register Enable
|
|
||||||
//
|
|
||||||
#define SITRE BIT14
|
|
||||||
|
|
||||||
//
|
|
||||||
// DMA Timing Enable Only Select 1
|
|
||||||
//
|
|
||||||
#define DTE1 BIT7
|
|
||||||
|
|
||||||
//
|
|
||||||
// Pre-fetch and Posting Enable Select 1
|
|
||||||
//
|
|
||||||
#define PPE1 BIT6
|
|
||||||
|
|
||||||
//
|
|
||||||
// IORDY Sample Point Enable Select 1
|
|
||||||
//
|
|
||||||
#define IE1 BIT5
|
|
||||||
|
|
||||||
//
|
|
||||||
// Fast Timing Bank Drive Select 1
|
|
||||||
//
|
|
||||||
#define TIME1 BIT4
|
|
||||||
|
|
||||||
//
|
|
||||||
// DMA Timing Enable Only Select 0
|
|
||||||
//
|
|
||||||
#define DTE0 BIT3
|
|
||||||
|
|
||||||
//
|
|
||||||
// Pre-fetch and Posting Enable Select 0
|
|
||||||
//
|
|
||||||
#define PPE0 BIT2
|
|
||||||
|
|
||||||
//
|
|
||||||
// IOREY Sample Point Enable Select 0
|
|
||||||
//
|
|
||||||
#define IE0 BIT1
|
|
||||||
|
|
||||||
//
|
|
||||||
// Fast Timing Bank Drive Select 0
|
|
||||||
//
|
|
||||||
#define TIME0 BIT0
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,162 +0,0 @@
|
|||||||
/** @file
|
|
||||||
Implements EFI Component Name Protocol for VGA Mini Port Driver.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#include "VgaMiniPort.h"
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// EFI Component Name Protocol
|
|
||||||
//
|
|
||||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gPciVgaMiniPortComponentName = {
|
|
||||||
PciVgaMiniPortComponentNameGetDriverName,
|
|
||||||
PciVgaMiniPortComponentNameGetControllerName,
|
|
||||||
"eng"
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// EFI Component Name 2 Protocol
|
|
||||||
//
|
|
||||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPciVgaMiniPortComponentName2 = {
|
|
||||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) PciVgaMiniPortComponentNameGetDriverName,
|
|
||||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) PciVgaMiniPortComponentNameGetControllerName,
|
|
||||||
"en"
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPciVgaMiniPortDriverNameTable[] = {
|
|
||||||
{
|
|
||||||
"eng;en",
|
|
||||||
L"PCI VGA Mini Port Driver"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
Retrieves a Unicode string that is the user readable name of the driver.
|
|
||||||
|
|
||||||
This function retrieves the user readable name of a driver in the form of a
|
|
||||||
Unicode string. If the driver specified by This has a user readable name in
|
|
||||||
the language specified by Language, then a pointer to the driver name is
|
|
||||||
returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
|
|
||||||
by This does not support the language specified by Language,
|
|
||||||
then EFI_UNSUPPORTED is returned.
|
|
||||||
|
|
||||||
@param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
|
||||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
|
||||||
@param Language A pointer to a Null-terminated ASCII string
|
|
||||||
array indicating the language. This is the
|
|
||||||
language of the driver name that the caller is
|
|
||||||
requesting, and it must match one of the
|
|
||||||
languages specified in SupportedLanguages. The
|
|
||||||
number of languages supported by a driver is up
|
|
||||||
to the driver writer. Language is specified
|
|
||||||
in RFC 4646 or ISO 639-2 language code format.
|
|
||||||
@param DriverName A pointer to the Unicode string to return.
|
|
||||||
This Unicode string is the name of the
|
|
||||||
driver specified by This in the language
|
|
||||||
specified by Language.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The Unicode string for the Driver specified by
|
|
||||||
This and the language specified by Language was
|
|
||||||
returned in DriverName.
|
|
||||||
@retval EFI_INVALID_PARAMETER Language is NULL.
|
|
||||||
@retval EFI_INVALID_PARAMETER DriverName is NULL.
|
|
||||||
@retval EFI_UNSUPPORTED The driver specified by This does not support
|
|
||||||
the language specified by Language.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
PciVgaMiniPortComponentNameGetDriverName (
|
|
||||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
|
||||||
IN CHAR8 *Language,
|
|
||||||
OUT CHAR16 **DriverName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return LookupUnicodeString2 (
|
|
||||||
Language,
|
|
||||||
This->SupportedLanguages,
|
|
||||||
mPciVgaMiniPortDriverNameTable,
|
|
||||||
DriverName,
|
|
||||||
(BOOLEAN)(This == &gPciVgaMiniPortComponentName)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Retrieves a Unicode string that is the user readable name of the controller
|
|
||||||
that is being managed by a driver.
|
|
||||||
|
|
||||||
This function retrieves the user readable name of the controller specified by
|
|
||||||
ControllerHandle and ChildHandle in the form of a Unicode string. If the
|
|
||||||
driver specified by This has a user readable name in the language specified by
|
|
||||||
Language, then a pointer to the controller name is returned in ControllerName,
|
|
||||||
and EFI_SUCCESS is returned. If the driver specified by This is not currently
|
|
||||||
managing the controller specified by ControllerHandle and ChildHandle,
|
|
||||||
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
|
|
||||||
support the language specified by Language, then EFI_UNSUPPORTED is returned.
|
|
||||||
|
|
||||||
@param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
|
||||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
|
||||||
@param ControllerHandle The handle of a controller that the driver
|
|
||||||
specified by This is managing. This handle
|
|
||||||
specifies the controller whose name is to be
|
|
||||||
returned.
|
|
||||||
@param ChildHandle The handle of the child controller to retrieve
|
|
||||||
the name of. This is an optional parameter that
|
|
||||||
may be NULL. It will be NULL for device
|
|
||||||
drivers. It will also be NULL for a bus drivers
|
|
||||||
that wish to retrieve the name of the bus
|
|
||||||
controller. It will not be NULL for a bus
|
|
||||||
driver that wishes to retrieve the name of a
|
|
||||||
child controller.
|
|
||||||
@param Language A pointer to a Null-terminated ASCII string
|
|
||||||
array indicating the language. This is the
|
|
||||||
language of the driver name that the caller is
|
|
||||||
requesting, and it must match one of the
|
|
||||||
languages specified in SupportedLanguages. The
|
|
||||||
number of languages supported by a driver is up
|
|
||||||
to the driver writer. Language is specified in
|
|
||||||
RFC 4646 or ISO 639-2 language code format.
|
|
||||||
@param ControllerName A pointer to the Unicode string to return.
|
|
||||||
This Unicode string is the name of the
|
|
||||||
controller specified by ControllerHandle and
|
|
||||||
ChildHandle in the language specified by
|
|
||||||
Language from the point of view of the driver
|
|
||||||
specified by This.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The Unicode string for the user readable name in
|
|
||||||
the language specified by Language for the
|
|
||||||
driver specified by This was returned in
|
|
||||||
DriverName.
|
|
||||||
@retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
|
|
||||||
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
|
|
||||||
EFI_HANDLE.
|
|
||||||
@retval EFI_INVALID_PARAMETER Language is NULL.
|
|
||||||
@retval EFI_INVALID_PARAMETER ControllerName is NULL.
|
|
||||||
@retval EFI_UNSUPPORTED The driver specified by This is not currently
|
|
||||||
managing the controller specified by
|
|
||||||
ControllerHandle and ChildHandle.
|
|
||||||
@retval EFI_UNSUPPORTED The driver specified by This does not support
|
|
||||||
the language specified by Language.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
PciVgaMiniPortComponentNameGetControllerName (
|
|
||||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE ControllerHandle,
|
|
||||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
|
||||||
IN CHAR8 *Language,
|
|
||||||
OUT CHAR16 **ControllerName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return EFI_UNSUPPORTED;
|
|
||||||
}
|
|
@ -1,325 +0,0 @@
|
|||||||
/** @file
|
|
||||||
Implements EFI Driver Binding Protocol and VGA Mini Port Protocol for VGA Mini Port Driver.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#include "VgaMiniPort.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// EFI Driver Binding Protocol Instance
|
|
||||||
//
|
|
||||||
// This driver has a version value of 0x00000000. This is the
|
|
||||||
// lowest possible priority for a driver. This is done on purpose to help
|
|
||||||
// the developers of UGA drivers. This driver can bind if no UGA driver
|
|
||||||
// is present, so a console is available. Then, when a UGA driver is loaded
|
|
||||||
// this driver can be disconnected, and the UGA driver can be connected.
|
|
||||||
// As long as the UGA driver has a version value greater than 0x00000000, it
|
|
||||||
// will be connected first and will block this driver from connecting.
|
|
||||||
//
|
|
||||||
EFI_DRIVER_BINDING_PROTOCOL gPciVgaMiniPortDriverBinding = {
|
|
||||||
PciVgaMiniPortDriverBindingSupported,
|
|
||||||
PciVgaMiniPortDriverBindingStart,
|
|
||||||
PciVgaMiniPortDriverBindingStop,
|
|
||||||
0x00000000,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
Entrypoint of VGA Mini Port Driver.
|
|
||||||
|
|
||||||
This function is the entrypoint of UVGA Mini Port Driver. It installs Driver Binding
|
|
||||||
Protocols together with Component Name Protocols.
|
|
||||||
|
|
||||||
@param ImageHandle The firmware allocated handle for the EFI image.
|
|
||||||
@param SystemTable A pointer to the EFI System Table.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The entry point is executed successfully.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
PciVgaMiniPortDriverEntryPoint (
|
|
||||||
IN EFI_HANDLE ImageHandle,
|
|
||||||
IN EFI_SYSTEM_TABLE *SystemTable
|
|
||||||
)
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
|
|
||||||
Status = EfiLibInstallDriverBindingComponentName2 (
|
|
||||||
ImageHandle,
|
|
||||||
SystemTable,
|
|
||||||
&gPciVgaMiniPortDriverBinding,
|
|
||||||
ImageHandle,
|
|
||||||
&gPciVgaMiniPortComponentName,
|
|
||||||
&gPciVgaMiniPortComponentName2
|
|
||||||
);
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Check whether VGA Mini Port driver supports this device.
|
|
||||||
|
|
||||||
@param This The driver binding protocol.
|
|
||||||
@param Controller The controller handle to check.
|
|
||||||
@param RemainingDevicePath The remaining device path.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The driver supports this controller.
|
|
||||||
@retval EFI_UNSUPPORTED This device isn't supported.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
PciVgaMiniPortDriverBindingSupported (
|
|
||||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE Controller,
|
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
|
||||||
)
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
|
||||||
PCI_TYPE00 Pci;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Open the IO Abstraction(s) needed to perform the supported test
|
|
||||||
//
|
|
||||||
Status = gBS->OpenProtocol (
|
|
||||||
Controller,
|
|
||||||
&gEfiPciIoProtocolGuid,
|
|
||||||
(VOID **) &PciIo,
|
|
||||||
This->DriverBindingHandle,
|
|
||||||
Controller,
|
|
||||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// See if this is a PCI VGA Controller by looking at the Command register and
|
|
||||||
// Class Code Register
|
|
||||||
//
|
|
||||||
Status = PciIo->Pci.Read (
|
|
||||||
PciIo,
|
|
||||||
EfiPciIoWidthUint32,
|
|
||||||
0,
|
|
||||||
sizeof (Pci) / sizeof (UINT32),
|
|
||||||
&Pci
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
goto Done;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = EFI_UNSUPPORTED;
|
|
||||||
//
|
|
||||||
// See if the device is an enabled VGA device.
|
|
||||||
// Most systems can only have on VGA device on at a time.
|
|
||||||
//
|
|
||||||
if (((Pci.Hdr.Command & 0x03) == 0x03) && IS_PCI_VGA (&Pci)) {
|
|
||||||
Status = EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
Done:
|
|
||||||
gBS->CloseProtocol (
|
|
||||||
Controller,
|
|
||||||
&gEfiPciIoProtocolGuid,
|
|
||||||
This->DriverBindingHandle,
|
|
||||||
Controller
|
|
||||||
);
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Starts the VGA device with this driver.
|
|
||||||
|
|
||||||
This function consumes PCI I/O Protocol, and installs VGA Mini Port Protocol
|
|
||||||
onto the VGA device handle.
|
|
||||||
|
|
||||||
@param This The driver binding instance.
|
|
||||||
@param Controller The controller to check.
|
|
||||||
@param RemainingDevicePath The remaining device patch.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The controller is controlled by the driver.
|
|
||||||
@retval EFI_ALREADY_STARTED The controller is already controlled by the driver.
|
|
||||||
@retval EFI_OUT_OF_RESOURCES Failed to allocate resources.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
PciVgaMiniPortDriverBindingStart (
|
|
||||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE Controller,
|
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
|
||||||
)
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
|
||||||
PCI_VGA_MINI_PORT_DEV *PciVgaMiniPortPrivate;
|
|
||||||
|
|
||||||
PciVgaMiniPortPrivate = NULL;
|
|
||||||
PciIo = NULL;
|
|
||||||
//
|
|
||||||
// Open the IO Abstraction(s) needed
|
|
||||||
//
|
|
||||||
Status = gBS->OpenProtocol (
|
|
||||||
Controller,
|
|
||||||
&gEfiPciIoProtocolGuid,
|
|
||||||
(VOID **) &PciIo,
|
|
||||||
This->DriverBindingHandle,
|
|
||||||
Controller,
|
|
||||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
goto Done;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Allocate the private device structure
|
|
||||||
//
|
|
||||||
PciVgaMiniPortPrivate = AllocateZeroPool (sizeof (PCI_VGA_MINI_PORT_DEV));
|
|
||||||
ASSERT (PciVgaMiniPortPrivate != NULL);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Initialize the private device structure
|
|
||||||
//
|
|
||||||
PciVgaMiniPortPrivate->Signature = PCI_VGA_MINI_PORT_DEV_SIGNATURE;
|
|
||||||
PciVgaMiniPortPrivate->Handle = Controller;
|
|
||||||
PciVgaMiniPortPrivate->PciIo = PciIo;
|
|
||||||
|
|
||||||
PciVgaMiniPortPrivate->VgaMiniPort.SetMode = PciVgaMiniPortSetMode;
|
|
||||||
PciVgaMiniPortPrivate->VgaMiniPort.VgaMemoryOffset = 0xb8000;
|
|
||||||
PciVgaMiniPortPrivate->VgaMiniPort.CrtcAddressRegisterOffset = 0x3d4;
|
|
||||||
PciVgaMiniPortPrivate->VgaMiniPort.CrtcDataRegisterOffset = 0x3d5;
|
|
||||||
PciVgaMiniPortPrivate->VgaMiniPort.VgaMemoryBar = EFI_PCI_IO_PASS_THROUGH_BAR;
|
|
||||||
PciVgaMiniPortPrivate->VgaMiniPort.CrtcAddressRegisterBar = EFI_PCI_IO_PASS_THROUGH_BAR;
|
|
||||||
PciVgaMiniPortPrivate->VgaMiniPort.CrtcDataRegisterBar = EFI_PCI_IO_PASS_THROUGH_BAR;
|
|
||||||
PciVgaMiniPortPrivate->VgaMiniPort.MaxMode = 1;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Install VGA Mini Port Protocol
|
|
||||||
//
|
|
||||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
|
||||||
&Controller,
|
|
||||||
&gEfiVgaMiniPortProtocolGuid,
|
|
||||||
&PciVgaMiniPortPrivate->VgaMiniPort,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
Done:
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
gBS->CloseProtocol (
|
|
||||||
Controller,
|
|
||||||
&gEfiPciIoProtocolGuid,
|
|
||||||
This->DriverBindingHandle,
|
|
||||||
Controller
|
|
||||||
);
|
|
||||||
if (PciVgaMiniPortPrivate != NULL) {
|
|
||||||
FreePool (PciVgaMiniPortPrivate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Stop the VGA device with this driver.
|
|
||||||
|
|
||||||
This function uninstalls VGA Mini Port Protocol from the VGA device handle,
|
|
||||||
and closes PCI I/O Protocol.
|
|
||||||
|
|
||||||
@param This The driver binding protocol.
|
|
||||||
@param Controller The controller to release.
|
|
||||||
@param NumberOfChildren The child number that opened controller
|
|
||||||
BY_CHILD.
|
|
||||||
@param ChildHandleBuffer The array of child handle.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The controller or children are stopped.
|
|
||||||
@retval EFI_DEVICE_ERROR Failed to stop the driver.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
PciVgaMiniPortDriverBindingStop (
|
|
||||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE Controller,
|
|
||||||
IN UINTN NumberOfChildren,
|
|
||||||
IN EFI_HANDLE *ChildHandleBuffer
|
|
||||||
)
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
EFI_VGA_MINI_PORT_PROTOCOL *VgaMiniPort;
|
|
||||||
PCI_VGA_MINI_PORT_DEV *PciVgaMiniPortPrivate;
|
|
||||||
|
|
||||||
Status = gBS->OpenProtocol (
|
|
||||||
Controller,
|
|
||||||
&gEfiVgaMiniPortProtocolGuid,
|
|
||||||
(VOID **) &VgaMiniPort,
|
|
||||||
This->DriverBindingHandle,
|
|
||||||
Controller,
|
|
||||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
PciVgaMiniPortPrivate = PCI_VGA_MINI_PORT_DEV_FROM_THIS (VgaMiniPort);
|
|
||||||
|
|
||||||
Status = gBS->UninstallProtocolInterface (
|
|
||||||
Controller,
|
|
||||||
&gEfiVgaMiniPortProtocolGuid,
|
|
||||||
&PciVgaMiniPortPrivate->VgaMiniPort
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
gBS->CloseProtocol (
|
|
||||||
Controller,
|
|
||||||
&gEfiPciIoProtocolGuid,
|
|
||||||
This->DriverBindingHandle,
|
|
||||||
Controller
|
|
||||||
);
|
|
||||||
|
|
||||||
FreePool (PciVgaMiniPortPrivate);
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// VGA Mini Port Protocol Functions
|
|
||||||
//
|
|
||||||
|
|
||||||
/**
|
|
||||||
Sets the text display mode of a VGA controller.
|
|
||||||
|
|
||||||
This function implements EFI_VGA_MINI_PORT_PROTOCOL.SetMode().
|
|
||||||
If ModeNumber exceeds the valid range, then EFI_UNSUPPORTED is returned.
|
|
||||||
Otherwise, EFI_SUCCESS is directly returned without real operation.
|
|
||||||
|
|
||||||
@param This Protocol instance pointer.
|
|
||||||
@param ModeNumber Mode number. 0 - 80x25 1-80x50
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The mode was set
|
|
||||||
@retval EFI_UNSUPPORTED ModeNumber is not supported.
|
|
||||||
@retval EFI_DEVICE_ERROR The device is not functioning properly.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
PciVgaMiniPortSetMode (
|
|
||||||
IN EFI_VGA_MINI_PORT_PROTOCOL *This,
|
|
||||||
IN UINTN ModeNumber
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (ModeNumber > This->MaxMode) {
|
|
||||||
return EFI_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
@ -1,265 +0,0 @@
|
|||||||
/** @file
|
|
||||||
Internal include file for VGA Mini Port Driver.
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef _VGA_MINIPORT_H_
|
|
||||||
#define _VGA_MINIPORT_H_
|
|
||||||
|
|
||||||
//
|
|
||||||
// The package level header files this module uses
|
|
||||||
//
|
|
||||||
#include <PiDxe.h>
|
|
||||||
//
|
|
||||||
// The protocols, PPI and GUID defintions for this module
|
|
||||||
//
|
|
||||||
#include <Protocol/PciIo.h>
|
|
||||||
#include <Protocol/VgaMiniPort.h>
|
|
||||||
#include <Protocol/ComponentName2.h>
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// The Library classes this module consumes
|
|
||||||
//
|
|
||||||
#include <Library/DebugLib.h>
|
|
||||||
#include <Library/BaseMemoryLib.h>
|
|
||||||
#include <Library/UefiDriverEntryPoint.h>
|
|
||||||
#include <Library/UefiBootServicesTableLib.h>
|
|
||||||
#include <Library/UefiLib.h>
|
|
||||||
#include <Library/MemoryAllocationLib.h>
|
|
||||||
|
|
||||||
#include <IndustryStandard/Pci.h>
|
|
||||||
|
|
||||||
//
|
|
||||||
// Global Variables
|
|
||||||
//
|
|
||||||
extern EFI_DRIVER_BINDING_PROTOCOL gPciVgaMiniPortDriverBinding;
|
|
||||||
extern EFI_COMPONENT_NAME_PROTOCOL gPciVgaMiniPortComponentName;
|
|
||||||
extern EFI_COMPONENT_NAME2_PROTOCOL gPciVgaMiniPortComponentName2;
|
|
||||||
|
|
||||||
//
|
|
||||||
// PCI VGA MiniPort Device Structure
|
|
||||||
//
|
|
||||||
#define PCI_VGA_MINI_PORT_DEV_SIGNATURE SIGNATURE_32('P','V','M','P')
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINTN Signature;
|
|
||||||
EFI_HANDLE Handle;
|
|
||||||
EFI_VGA_MINI_PORT_PROTOCOL VgaMiniPort;
|
|
||||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
|
||||||
} PCI_VGA_MINI_PORT_DEV;
|
|
||||||
|
|
||||||
#define PCI_VGA_MINI_PORT_DEV_FROM_THIS(a) CR(a, PCI_VGA_MINI_PORT_DEV, VgaMiniPort, PCI_VGA_MINI_PORT_DEV_SIGNATURE)
|
|
||||||
|
|
||||||
//
|
|
||||||
// Driver Binding Protocol functions
|
|
||||||
//
|
|
||||||
/**
|
|
||||||
Check whether VGA Mini Port driver supports this device.
|
|
||||||
|
|
||||||
@param This The driver binding protocol.
|
|
||||||
@param Controller The controller handle to check.
|
|
||||||
@param RemainingDevicePath The remaining device path.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The driver supports this controller.
|
|
||||||
@retval EFI_UNSUPPORTED This device isn't supported.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
PciVgaMiniPortDriverBindingSupported (
|
|
||||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE Controller,
|
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Starts the VGA device with this driver.
|
|
||||||
|
|
||||||
This function consumes PCI I/O Protocol, and installs VGA Mini Port Protocol
|
|
||||||
onto the VGA device handle.
|
|
||||||
|
|
||||||
@param This The driver binding instance.
|
|
||||||
@param Controller The controller to check.
|
|
||||||
@param RemainingDevicePath The remaining device patch.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The controller is controlled by the driver.
|
|
||||||
@retval EFI_ALREADY_STARTED The controller is already controlled by the driver.
|
|
||||||
@retval EFI_OUT_OF_RESOURCES Failed to allocate resources.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
PciVgaMiniPortDriverBindingStart (
|
|
||||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE Controller,
|
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Stop the VGA device with this driver.
|
|
||||||
|
|
||||||
This function uninstalls VGA Mini Port Protocol from the VGA device handle,
|
|
||||||
and closes PCI I/O Protocol.
|
|
||||||
|
|
||||||
@param This The driver binding protocol.
|
|
||||||
@param Controller The controller to release.
|
|
||||||
@param NumberOfChildren The child number that opened controller
|
|
||||||
BY_CHILD.
|
|
||||||
@param ChildHandleBuffer The array of child handle.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The controller or children are stopped.
|
|
||||||
@retval EFI_DEVICE_ERROR Failed to stop the driver.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
PciVgaMiniPortDriverBindingStop (
|
|
||||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE Controller,
|
|
||||||
IN UINTN NumberOfChildren,
|
|
||||||
IN EFI_HANDLE *ChildHandleBuffer
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// EFI Component Name Functions
|
|
||||||
//
|
|
||||||
/**
|
|
||||||
Retrieves a Unicode string that is the user readable name of the driver.
|
|
||||||
|
|
||||||
This function retrieves the user readable name of a driver in the form of a
|
|
||||||
Unicode string. If the driver specified by This has a user readable name in
|
|
||||||
the language specified by Language, then a pointer to the driver name is
|
|
||||||
returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
|
|
||||||
by This does not support the language specified by Language,
|
|
||||||
then EFI_UNSUPPORTED is returned.
|
|
||||||
|
|
||||||
@param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
|
||||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
|
||||||
@param Language A pointer to a Null-terminated ASCII string
|
|
||||||
array indicating the language. This is the
|
|
||||||
language of the driver name that the caller is
|
|
||||||
requesting, and it must match one of the
|
|
||||||
languages specified in SupportedLanguages. The
|
|
||||||
number of languages supported by a driver is up
|
|
||||||
to the driver writer. Language is specified
|
|
||||||
in RFC 4646 or ISO 639-2 language code format.
|
|
||||||
@param DriverName A pointer to the Unicode string to return.
|
|
||||||
This Unicode string is the name of the
|
|
||||||
driver specified by This in the language
|
|
||||||
specified by Language.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The Unicode string for the Driver specified by
|
|
||||||
This and the language specified by Language was
|
|
||||||
returned in DriverName.
|
|
||||||
@retval EFI_INVALID_PARAMETER Language is NULL.
|
|
||||||
@retval EFI_INVALID_PARAMETER DriverName is NULL.
|
|
||||||
@retval EFI_UNSUPPORTED The driver specified by This does not support
|
|
||||||
the language specified by Language.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
PciVgaMiniPortComponentNameGetDriverName (
|
|
||||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
|
||||||
IN CHAR8 *Language,
|
|
||||||
OUT CHAR16 **DriverName
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Retrieves a Unicode string that is the user readable name of the controller
|
|
||||||
that is being managed by a driver.
|
|
||||||
|
|
||||||
This function retrieves the user readable name of the controller specified by
|
|
||||||
ControllerHandle and ChildHandle in the form of a Unicode string. If the
|
|
||||||
driver specified by This has a user readable name in the language specified by
|
|
||||||
Language, then a pointer to the controller name is returned in ControllerName,
|
|
||||||
and EFI_SUCCESS is returned. If the driver specified by This is not currently
|
|
||||||
managing the controller specified by ControllerHandle and ChildHandle,
|
|
||||||
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
|
|
||||||
support the language specified by Language, then EFI_UNSUPPORTED is returned.
|
|
||||||
|
|
||||||
@param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
|
||||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
|
||||||
@param ControllerHandle The handle of a controller that the driver
|
|
||||||
specified by This is managing. This handle
|
|
||||||
specifies the controller whose name is to be
|
|
||||||
returned.
|
|
||||||
@param ChildHandle The handle of the child controller to retrieve
|
|
||||||
the name of. This is an optional parameter that
|
|
||||||
may be NULL. It will be NULL for device
|
|
||||||
drivers. It will also be NULL for a bus drivers
|
|
||||||
that wish to retrieve the name of the bus
|
|
||||||
controller. It will not be NULL for a bus
|
|
||||||
driver that wishes to retrieve the name of a
|
|
||||||
child controller.
|
|
||||||
@param Language A pointer to a Null-terminated ASCII string
|
|
||||||
array indicating the language. This is the
|
|
||||||
language of the driver name that the caller is
|
|
||||||
requesting, and it must match one of the
|
|
||||||
languages specified in SupportedLanguages. The
|
|
||||||
number of languages supported by a driver is up
|
|
||||||
to the driver writer. Language is specified in
|
|
||||||
RFC 4646 or ISO 639-2 language code format.
|
|
||||||
@param ControllerName A pointer to the Unicode string to return.
|
|
||||||
This Unicode string is the name of the
|
|
||||||
controller specified by ControllerHandle and
|
|
||||||
ChildHandle in the language specified by
|
|
||||||
Language from the point of view of the driver
|
|
||||||
specified by This.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The Unicode string for the user readable name in
|
|
||||||
the language specified by Language for the
|
|
||||||
driver specified by This was returned in
|
|
||||||
DriverName.
|
|
||||||
@retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
|
|
||||||
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
|
|
||||||
EFI_HANDLE.
|
|
||||||
@retval EFI_INVALID_PARAMETER Language is NULL.
|
|
||||||
@retval EFI_INVALID_PARAMETER ControllerName is NULL.
|
|
||||||
@retval EFI_UNSUPPORTED The driver specified by This is not currently
|
|
||||||
managing the controller specified by
|
|
||||||
ControllerHandle and ChildHandle.
|
|
||||||
@retval EFI_UNSUPPORTED The driver specified by This does not support
|
|
||||||
the language specified by Language.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
PciVgaMiniPortComponentNameGetControllerName (
|
|
||||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE ControllerHandle,
|
|
||||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
|
||||||
IN CHAR8 *Language,
|
|
||||||
OUT CHAR16 **ControllerName
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// VGA Mini Port Protocol functions
|
|
||||||
//
|
|
||||||
/**
|
|
||||||
Sets the text display mode of a VGA controller.
|
|
||||||
|
|
||||||
This function implements EFI_VGA_MINI_PORT_PROTOCOL.SetMode().
|
|
||||||
If ModeNumber exceeds the valid range, then EFI_UNSUPPORTED is returned.
|
|
||||||
Otherwise, EFI_SUCCESS is directly returned without real operation.
|
|
||||||
|
|
||||||
@param This Protocol instance pointer.
|
|
||||||
@param ModeNumber Mode number. 0 - 80x25 1-80x50
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The mode was set
|
|
||||||
@retval EFI_UNSUPPORTED ModeNumber is not supported.
|
|
||||||
@retval EFI_DEVICE_ERROR The device is not functioning properly.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
PciVgaMiniPortSetMode (
|
|
||||||
IN EFI_VGA_MINI_PORT_PROTOCOL *This,
|
|
||||||
IN UINTN ModeNumber
|
|
||||||
);
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,16 +0,0 @@
|
|||||||
// /** @file
|
|
||||||
// VGA Mini Port Driver that manages VGA device and produces VGA Mini Port Protocol.
|
|
||||||
//
|
|
||||||
// VGA Mini Port Driver that manages VGA device and produces the VGA Mini Port Protocol.
|
|
||||||
//
|
|
||||||
// Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
//
|
|
||||||
// **/
|
|
||||||
|
|
||||||
|
|
||||||
#string STR_MODULE_ABSTRACT #language en-US "VGA Mini Port Driver that manages VGA device and produces the VGA Mini Port Protocol"
|
|
||||||
|
|
||||||
#string STR_MODULE_DESCRIPTION #language en-US "VGA Mini Port Driver that manages VGA device and produces the VGA Mini Port Protocol."
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
|||||||
## @file
|
|
||||||
# VGA Mini Port Driver that manages VGA device and produces VGA Mini Port Protocol.
|
|
||||||
#
|
|
||||||
# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
#
|
|
||||||
#
|
|
||||||
##
|
|
||||||
|
|
||||||
[Defines]
|
|
||||||
INF_VERSION = 0x00010005
|
|
||||||
BASE_NAME = VgaMiniPort
|
|
||||||
MODULE_UNI_FILE = VgaMiniPort.uni
|
|
||||||
FILE_GUID = 15C5E761-58D8-461a-9173-CAB020916264
|
|
||||||
MODULE_TYPE = UEFI_DRIVER
|
|
||||||
VERSION_STRING = 1.0
|
|
||||||
ENTRY_POINT = PciVgaMiniPortDriverEntryPoint
|
|
||||||
|
|
||||||
#
|
|
||||||
# The following information is for reference only and not required by the build tools.
|
|
||||||
#
|
|
||||||
# VALID_ARCHITECTURES = IA32 X64 EBC
|
|
||||||
# DRIVER_BINDING = gPciVgaMiniPortDriverBinding;
|
|
||||||
# COMPONENT_NAME = gPciVgaMiniPortComponentName;
|
|
||||||
# COMPONENT_NAME2 = gPciVgaMiniPortComponentName2;
|
|
||||||
#
|
|
||||||
|
|
||||||
[Sources]
|
|
||||||
ComponentName.c
|
|
||||||
VgaMiniPort.c
|
|
||||||
VgaMiniPort.h
|
|
||||||
|
|
||||||
[Packages]
|
|
||||||
MdePkg/MdePkg.dec
|
|
||||||
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
|
|
||||||
|
|
||||||
[LibraryClasses]
|
|
||||||
UefiLib
|
|
||||||
DebugLib
|
|
||||||
UefiBootServicesTableLib
|
|
||||||
UefiDriverEntryPoint
|
|
||||||
BaseMemoryLib
|
|
||||||
MemoryAllocationLib
|
|
||||||
|
|
||||||
[Protocols]
|
|
||||||
gEfiPciIoProtocolGuid ## TO_START
|
|
||||||
gEfiVgaMiniPortProtocolGuid ## BY_START
|
|
||||||
|
|
||||||
[UserExtensions.TianoCore."ExtraFiles"]
|
|
||||||
VgaMiniPortExtra.uni
|
|
@ -1,14 +0,0 @@
|
|||||||
// /** @file
|
|
||||||
// VgaMiniPort Localized Strings and Content
|
|
||||||
//
|
|
||||||
// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
//
|
|
||||||
// **/
|
|
||||||
|
|
||||||
#string STR_PROPERTIES_MODULE_NAME
|
|
||||||
#language en-US
|
|
||||||
"VGA Mini Port DXE Driver"
|
|
||||||
|
|
||||||
|
|
@ -1,773 +0,0 @@
|
|||||||
/** @file
|
|
||||||
EFI glue for BIOS INT 13h block devices.
|
|
||||||
|
|
||||||
This file is coded to EDD 3.0 as defined by T13 D1386 Revision 4
|
|
||||||
Availible on http://www.t13.org/#Project drafts
|
|
||||||
Currently at ftp://fission.dt.wdc.com/pub/standards/x3t13/project/d1386r4.pdf
|
|
||||||
|
|
||||||
Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#include "BiosBlkIo.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// Global data declaration
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// EFI Driver Binding Protocol Instance
|
|
||||||
//
|
|
||||||
EFI_DRIVER_BINDING_PROTOCOL gBiosBlockIoDriverBinding = {
|
|
||||||
BiosBlockIoDriverBindingSupported,
|
|
||||||
BiosBlockIoDriverBindingStart,
|
|
||||||
BiosBlockIoDriverBindingStop,
|
|
||||||
0x3,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// Semaphore to control access to global variables mActiveInstances and mBufferUnder1Mb
|
|
||||||
//
|
|
||||||
EFI_LOCK mGlobalDataLock = EFI_INITIALIZE_LOCK_VARIABLE(TPL_APPLICATION);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Number of active instances of this protocol. This is used to allocate/free
|
|
||||||
// the shared buffer. You must acquire the semaphore to modify.
|
|
||||||
//
|
|
||||||
UINTN mActiveInstances = 0;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Pointer to the beginning of the buffer used for real mode thunk
|
|
||||||
// You must acquire the semaphore to modify.
|
|
||||||
//
|
|
||||||
EFI_PHYSICAL_ADDRESS mBufferUnder1Mb = 0;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Address packet is a buffer under 1 MB for all version EDD calls
|
|
||||||
//
|
|
||||||
EDD_DEVICE_ADDRESS_PACKET *mEddBufferUnder1Mb;
|
|
||||||
|
|
||||||
//
|
|
||||||
// This is a buffer for INT 13h func 48 information
|
|
||||||
//
|
|
||||||
BIOS_LEGACY_DRIVE *mLegacyDriverUnder1Mb;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Buffer of 0xFE00 bytes for EDD 1.1 transfer must be under 1 MB
|
|
||||||
// 0xFE00 bytes is the max transfer size supported.
|
|
||||||
//
|
|
||||||
VOID *mEdd11Buffer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Driver entry point.
|
|
||||||
|
|
||||||
@param ImageHandle Handle of driver image.
|
|
||||||
@param SystemTable Pointer to system table.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS Entrypoint successfully executed.
|
|
||||||
@retval Others Fail to execute entrypoint.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
BiosBlockIoDriverEntryPoint (
|
|
||||||
IN EFI_HANDLE ImageHandle,
|
|
||||||
IN EFI_SYSTEM_TABLE *SystemTable
|
|
||||||
)
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Install protocols
|
|
||||||
//
|
|
||||||
Status = EfiLibInstallDriverBindingComponentName2 (
|
|
||||||
ImageHandle,
|
|
||||||
SystemTable,
|
|
||||||
&gBiosBlockIoDriverBinding,
|
|
||||||
ImageHandle,
|
|
||||||
&gBiosBlockIoComponentName,
|
|
||||||
&gBiosBlockIoComponentName2
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Install Legacy BIOS GUID to mark this driver as a BIOS Thunk Driver
|
|
||||||
//
|
|
||||||
return gBS->InstallMultipleProtocolInterfaces (
|
|
||||||
&ImageHandle,
|
|
||||||
&gEfiLegacyBiosGuid,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Check whether the driver supports this device.
|
|
||||||
|
|
||||||
@param This The Udriver binding protocol.
|
|
||||||
@param Controller The controller handle to check.
|
|
||||||
@param RemainingDevicePath The remaining device path.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The driver supports this controller.
|
|
||||||
@retval other This device isn't supported.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
BiosBlockIoDriverBindingSupported (
|
|
||||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE Controller,
|
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
|
||||||
)
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
EFI_LEGACY_BIOS_PROTOCOL *LegacyBios;
|
|
||||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
|
||||||
PCI_TYPE00 Pci;
|
|
||||||
|
|
||||||
//
|
|
||||||
// See if the Legacy BIOS Protocol is available
|
|
||||||
//
|
|
||||||
Status = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) &LegacyBios);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = gBS->OpenProtocol (
|
|
||||||
Controller,
|
|
||||||
&gEfiDevicePathProtocolGuid,
|
|
||||||
(VOID **) &DevicePath,
|
|
||||||
This->DriverBindingHandle,
|
|
||||||
Controller,
|
|
||||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
gBS->CloseProtocol (
|
|
||||||
Controller,
|
|
||||||
&gEfiDevicePathProtocolGuid,
|
|
||||||
This->DriverBindingHandle,
|
|
||||||
Controller
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Open the IO Abstraction(s) needed to perform the supported test
|
|
||||||
//
|
|
||||||
Status = gBS->OpenProtocol (
|
|
||||||
Controller,
|
|
||||||
&gEfiPciIoProtocolGuid,
|
|
||||||
(VOID **) &PciIo,
|
|
||||||
This->DriverBindingHandle,
|
|
||||||
Controller,
|
|
||||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// See if this is a PCI VGA Controller by looking at the Command register and
|
|
||||||
// Class Code Register
|
|
||||||
//
|
|
||||||
Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, 0, sizeof (Pci) / sizeof (UINT32), &Pci);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
Status = EFI_UNSUPPORTED;
|
|
||||||
goto Done;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = EFI_UNSUPPORTED;
|
|
||||||
if (Pci.Hdr.ClassCode[2] == PCI_CLASS_MASS_STORAGE ||
|
|
||||||
(Pci.Hdr.ClassCode[2] == PCI_BASE_CLASS_INTELLIGENT && Pci.Hdr.ClassCode[1] == PCI_SUB_CLASS_INTELLIGENT)
|
|
||||||
) {
|
|
||||||
Status = EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
Done:
|
|
||||||
gBS->CloseProtocol (
|
|
||||||
Controller,
|
|
||||||
&gEfiPciIoProtocolGuid,
|
|
||||||
This->DriverBindingHandle,
|
|
||||||
Controller
|
|
||||||
);
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Starts the device with this driver.
|
|
||||||
|
|
||||||
@param This The driver binding instance.
|
|
||||||
@param Controller Handle of device to bind driver to.
|
|
||||||
@param RemainingDevicePath Optional parameter use to pick a specific child
|
|
||||||
device to start.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The controller is controlled by the driver.
|
|
||||||
@retval Other This controller cannot be started.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
BiosBlockIoDriverBindingStart (
|
|
||||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE Controller,
|
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
|
||||||
)
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
EFI_LEGACY_BIOS_PROTOCOL *LegacyBios;
|
|
||||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
|
||||||
UINT8 DiskStart;
|
|
||||||
UINT8 DiskEnd;
|
|
||||||
BIOS_BLOCK_IO_DEV *BiosBlockIoPrivate;
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *PciDevPath;
|
|
||||||
UINTN Index;
|
|
||||||
UINTN Flags;
|
|
||||||
UINTN TmpAddress;
|
|
||||||
BOOLEAN DeviceEnable;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Initialize variables
|
|
||||||
//
|
|
||||||
PciIo = NULL;
|
|
||||||
PciDevPath = NULL;
|
|
||||||
|
|
||||||
DeviceEnable = FALSE;
|
|
||||||
|
|
||||||
//
|
|
||||||
// See if the Legacy BIOS Protocol is available
|
|
||||||
//
|
|
||||||
Status = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) &LegacyBios);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
goto Error;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Open the IO Abstraction(s) needed
|
|
||||||
//
|
|
||||||
Status = gBS->OpenProtocol (
|
|
||||||
Controller,
|
|
||||||
&gEfiPciIoProtocolGuid,
|
|
||||||
(VOID **) &PciIo,
|
|
||||||
This->DriverBindingHandle,
|
|
||||||
Controller,
|
|
||||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
goto Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = gBS->OpenProtocol (
|
|
||||||
Controller,
|
|
||||||
&gEfiDevicePathProtocolGuid,
|
|
||||||
(VOID **) &PciDevPath,
|
|
||||||
This->DriverBindingHandle,
|
|
||||||
Controller,
|
|
||||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
|
||||||
);
|
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
goto Error;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Enable the device and make sure VGA cycles are being forwarded to this VGA device
|
|
||||||
//
|
|
||||||
Status = PciIo->Attributes (
|
|
||||||
PciIo,
|
|
||||||
EfiPciIoAttributeOperationEnable,
|
|
||||||
EFI_PCI_DEVICE_ENABLE,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
goto Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
DeviceEnable = TRUE;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check to see if there is a legacy option ROM image associated with this PCI device
|
|
||||||
//
|
|
||||||
Status = LegacyBios->CheckPciRom (
|
|
||||||
LegacyBios,
|
|
||||||
Controller,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
&Flags
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
goto Error;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Post the legacy option ROM if it is available.
|
|
||||||
//
|
|
||||||
Status = LegacyBios->InstallPciRom (
|
|
||||||
LegacyBios,
|
|
||||||
Controller,
|
|
||||||
NULL,
|
|
||||||
&Flags,
|
|
||||||
&DiskStart,
|
|
||||||
&DiskEnd,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
goto Error;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// All instances share a buffer under 1MB to put real mode thunk code in
|
|
||||||
// If it has not been allocated, then we allocate it.
|
|
||||||
//
|
|
||||||
if (mBufferUnder1Mb == 0) {
|
|
||||||
//
|
|
||||||
// Should only be here if there are no active instances
|
|
||||||
//
|
|
||||||
ASSERT (mActiveInstances == 0);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Acquire the lock
|
|
||||||
//
|
|
||||||
EfiAcquireLock (&mGlobalDataLock);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Allocate below 1MB
|
|
||||||
//
|
|
||||||
mBufferUnder1Mb = 0x00000000000FFFFF;
|
|
||||||
Status = gBS->AllocatePages (AllocateMaxAddress, EfiBootServicesData, BLOCK_IO_BUFFER_PAGE_SIZE, &mBufferUnder1Mb);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Release the lock
|
|
||||||
//
|
|
||||||
EfiReleaseLock (&mGlobalDataLock);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check memory allocation success
|
|
||||||
//
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
//
|
|
||||||
// In checked builds we want to assert if the allocate failed.
|
|
||||||
//
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
|
||||||
Status = EFI_OUT_OF_RESOURCES;
|
|
||||||
mBufferUnder1Mb = 0;
|
|
||||||
goto Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
TmpAddress = (UINTN) mBufferUnder1Mb;
|
|
||||||
//
|
|
||||||
// Adjusting the value to be on proper boundary
|
|
||||||
//
|
|
||||||
mEdd11Buffer = (VOID *) ALIGN_VARIABLE (TmpAddress);
|
|
||||||
|
|
||||||
TmpAddress = (UINTN) mEdd11Buffer + MAX_EDD11_XFER;
|
|
||||||
//
|
|
||||||
// Adjusting the value to be on proper boundary
|
|
||||||
//
|
|
||||||
mLegacyDriverUnder1Mb = (BIOS_LEGACY_DRIVE *) ALIGN_VARIABLE (TmpAddress);
|
|
||||||
|
|
||||||
TmpAddress = (UINTN) mLegacyDriverUnder1Mb + sizeof (BIOS_LEGACY_DRIVE);
|
|
||||||
//
|
|
||||||
// Adjusting the value to be on proper boundary
|
|
||||||
//
|
|
||||||
mEddBufferUnder1Mb = (EDD_DEVICE_ADDRESS_PACKET *) ALIGN_VARIABLE (TmpAddress);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Allocate the private device structure for each disk
|
|
||||||
//
|
|
||||||
for (Index = DiskStart; Index < DiskEnd; Index++) {
|
|
||||||
|
|
||||||
Status = gBS->AllocatePool (
|
|
||||||
EfiBootServicesData,
|
|
||||||
sizeof (BIOS_BLOCK_IO_DEV),
|
|
||||||
(VOID **) &BiosBlockIoPrivate
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
goto Error;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Zero the private device structure
|
|
||||||
//
|
|
||||||
ZeroMem (BiosBlockIoPrivate, sizeof (BIOS_BLOCK_IO_DEV));
|
|
||||||
|
|
||||||
//
|
|
||||||
// Initialize the private device structure
|
|
||||||
//
|
|
||||||
BiosBlockIoPrivate->Signature = BIOS_CONSOLE_BLOCK_IO_DEV_SIGNATURE;
|
|
||||||
BiosBlockIoPrivate->ControllerHandle = Controller;
|
|
||||||
BiosBlockIoPrivate->LegacyBios = LegacyBios;
|
|
||||||
BiosBlockIoPrivate->PciIo = PciIo;
|
|
||||||
|
|
||||||
BiosBlockIoPrivate->Bios.Floppy = FALSE;
|
|
||||||
BiosBlockIoPrivate->Bios.Number = (UINT8) Index;
|
|
||||||
BiosBlockIoPrivate->Bios.Letter = (UINT8) (Index - 0x80 + 'C');
|
|
||||||
BiosBlockIoPrivate->BlockMedia.RemovableMedia = FALSE;
|
|
||||||
|
|
||||||
if (BiosInitBlockIo (BiosBlockIoPrivate)) {
|
|
||||||
SetBiosInitBlockIoDevicePath (PciDevPath, &BiosBlockIoPrivate->Bios, &BiosBlockIoPrivate->DevicePath);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Install the Block Io Protocol onto a new child handle
|
|
||||||
//
|
|
||||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
|
||||||
&BiosBlockIoPrivate->Handle,
|
|
||||||
&gEfiBlockIoProtocolGuid,
|
|
||||||
&BiosBlockIoPrivate->BlockIo,
|
|
||||||
&gEfiDevicePathProtocolGuid,
|
|
||||||
BiosBlockIoPrivate->DevicePath,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
gBS->FreePool (BiosBlockIoPrivate);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Open For Child Device
|
|
||||||
//
|
|
||||||
Status = gBS->OpenProtocol (
|
|
||||||
Controller,
|
|
||||||
&gEfiPciIoProtocolGuid,
|
|
||||||
(VOID **) &BiosBlockIoPrivate->PciIo,
|
|
||||||
This->DriverBindingHandle,
|
|
||||||
BiosBlockIoPrivate->Handle,
|
|
||||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
|
||||||
);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
gBS->FreePool (BiosBlockIoPrivate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Error:
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
if (PciIo != NULL) {
|
|
||||||
if (DeviceEnable) {
|
|
||||||
PciIo->Attributes (
|
|
||||||
PciIo,
|
|
||||||
EfiPciIoAttributeOperationDisable,
|
|
||||||
EFI_PCI_DEVICE_ENABLE,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
}
|
|
||||||
gBS->CloseProtocol (
|
|
||||||
Controller,
|
|
||||||
&gEfiPciIoProtocolGuid,
|
|
||||||
This->DriverBindingHandle,
|
|
||||||
Controller
|
|
||||||
);
|
|
||||||
if (PciDevPath != NULL) {
|
|
||||||
gBS->CloseProtocol (
|
|
||||||
Controller,
|
|
||||||
&gEfiDevicePathProtocolGuid,
|
|
||||||
This->DriverBindingHandle,
|
|
||||||
Controller
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (mBufferUnder1Mb != 0 && mActiveInstances == 0) {
|
|
||||||
gBS->FreePages (mBufferUnder1Mb, BLOCK_IO_BUFFER_PAGE_SIZE);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Clear the buffer back to 0
|
|
||||||
//
|
|
||||||
EfiAcquireLock (&mGlobalDataLock);
|
|
||||||
mBufferUnder1Mb = 0;
|
|
||||||
EfiReleaseLock (&mGlobalDataLock);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Successfully installed, so increment the number of active instances
|
|
||||||
//
|
|
||||||
EfiAcquireLock (&mGlobalDataLock);
|
|
||||||
mActiveInstances++;
|
|
||||||
EfiReleaseLock (&mGlobalDataLock);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Stop the device handled by this driver.
|
|
||||||
|
|
||||||
@param This The driver binding protocol.
|
|
||||||
@param Controller The controller to release.
|
|
||||||
@param NumberOfChildren The number of handles in ChildHandleBuffer.
|
|
||||||
@param ChildHandleBuffer The array of child handle.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The device was stopped.
|
|
||||||
@retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
|
|
||||||
@retval Others Fail to uninstall protocols attached on the device.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
BiosBlockIoDriverBindingStop (
|
|
||||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE Controller,
|
|
||||||
IN UINTN NumberOfChildren,
|
|
||||||
IN EFI_HANDLE *ChildHandleBuffer
|
|
||||||
)
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
BOOLEAN AllChildrenStopped;
|
|
||||||
EFI_BLOCK_IO_PROTOCOL *BlockIo;
|
|
||||||
BIOS_BLOCK_IO_DEV *BiosBlockIoPrivate;
|
|
||||||
UINTN Index;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Decrement the number of active instances
|
|
||||||
//
|
|
||||||
if (mActiveInstances != 0) {
|
|
||||||
//
|
|
||||||
// Add a check since the stop function will be called 2 times for each handle
|
|
||||||
//
|
|
||||||
EfiAcquireLock (&mGlobalDataLock);
|
|
||||||
mActiveInstances--;
|
|
||||||
EfiReleaseLock (&mGlobalDataLock);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((mActiveInstances == 0) && (mBufferUnder1Mb != 0)) {
|
|
||||||
//
|
|
||||||
// Free our global buffer
|
|
||||||
//
|
|
||||||
Status = gBS->FreePages (mBufferUnder1Mb, BLOCK_IO_BUFFER_PAGE_SIZE);
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
|
||||||
|
|
||||||
EfiAcquireLock (&mGlobalDataLock);
|
|
||||||
mBufferUnder1Mb = 0;
|
|
||||||
EfiReleaseLock (&mGlobalDataLock);
|
|
||||||
}
|
|
||||||
|
|
||||||
AllChildrenStopped = TRUE;
|
|
||||||
|
|
||||||
for (Index = 0; Index < NumberOfChildren; Index++) {
|
|
||||||
Status = gBS->OpenProtocol (
|
|
||||||
ChildHandleBuffer[Index],
|
|
||||||
&gEfiBlockIoProtocolGuid,
|
|
||||||
(VOID **) &BlockIo,
|
|
||||||
This->DriverBindingHandle,
|
|
||||||
Controller,
|
|
||||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
BiosBlockIoPrivate = BIOS_BLOCK_IO_FROM_THIS (BlockIo);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Release PCI I/O and Block IO Protocols on the clild handle.
|
|
||||||
//
|
|
||||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
|
||||||
ChildHandleBuffer[Index],
|
|
||||||
&gEfiBlockIoProtocolGuid,
|
|
||||||
&BiosBlockIoPrivate->BlockIo,
|
|
||||||
&gEfiDevicePathProtocolGuid,
|
|
||||||
BiosBlockIoPrivate->DevicePath,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
AllChildrenStopped = FALSE;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Shutdown the hardware
|
|
||||||
//
|
|
||||||
BiosBlockIoPrivate->PciIo->Attributes (
|
|
||||||
BiosBlockIoPrivate->PciIo,
|
|
||||||
EfiPciIoAttributeOperationDisable,
|
|
||||||
EFI_PCI_DEVICE_ENABLE,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
gBS->CloseProtocol (
|
|
||||||
Controller,
|
|
||||||
&gEfiPciIoProtocolGuid,
|
|
||||||
This->DriverBindingHandle,
|
|
||||||
ChildHandleBuffer[Index]
|
|
||||||
);
|
|
||||||
|
|
||||||
gBS->FreePool (BiosBlockIoPrivate);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!AllChildrenStopped) {
|
|
||||||
return EFI_DEVICE_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = gBS->CloseProtocol (
|
|
||||||
Controller,
|
|
||||||
&gEfiDevicePathProtocolGuid,
|
|
||||||
This->DriverBindingHandle,
|
|
||||||
Controller
|
|
||||||
);
|
|
||||||
|
|
||||||
Status = gBS->CloseProtocol (
|
|
||||||
Controller,
|
|
||||||
&gEfiPciIoProtocolGuid,
|
|
||||||
This->DriverBindingHandle,
|
|
||||||
Controller
|
|
||||||
);
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Build device path for device.
|
|
||||||
|
|
||||||
@param BaseDevicePath Base device path.
|
|
||||||
@param Drive Legacy drive.
|
|
||||||
@param DevicePath Device path for output.
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
SetBiosInitBlockIoDevicePath (
|
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *BaseDevicePath,
|
|
||||||
IN BIOS_LEGACY_DRIVE *Drive,
|
|
||||||
OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
|
|
||||||
)
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
BLOCKIO_VENDOR_DEVICE_PATH VendorNode;
|
|
||||||
|
|
||||||
Status = EFI_UNSUPPORTED;
|
|
||||||
|
|
||||||
//
|
|
||||||
// BugBug: Check for memory leaks!
|
|
||||||
//
|
|
||||||
if (Drive->EddVersion == EDD_VERSION_30) {
|
|
||||||
//
|
|
||||||
// EDD 3.0 case.
|
|
||||||
//
|
|
||||||
Status = BuildEdd30DevicePath (BaseDevicePath, Drive, DevicePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
//
|
|
||||||
// EDD 1.1 device case or it is unrecognized EDD 3.0 device
|
|
||||||
//
|
|
||||||
ZeroMem (&VendorNode, sizeof (VendorNode));
|
|
||||||
VendorNode.DevicePath.Header.Type = HARDWARE_DEVICE_PATH;
|
|
||||||
VendorNode.DevicePath.Header.SubType = HW_VENDOR_DP;
|
|
||||||
SetDevicePathNodeLength (&VendorNode.DevicePath.Header, sizeof (VendorNode));
|
|
||||||
CopyMem (&VendorNode.DevicePath.Guid, &gBlockIoVendorGuid, sizeof (EFI_GUID));
|
|
||||||
VendorNode.LegacyDriveLetter = Drive->Number;
|
|
||||||
*DevicePath = AppendDevicePathNode (BaseDevicePath, &VendorNode.DevicePath.Header);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Build device path for EDD 3.0.
|
|
||||||
|
|
||||||
@param BaseDevicePath Base device path.
|
|
||||||
@param Drive Legacy drive.
|
|
||||||
@param DevicePath Device path for output.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The device path is built successfully.
|
|
||||||
@retval EFI_UNSUPPORTED It is failed to built device path.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
BuildEdd30DevicePath (
|
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *BaseDevicePath,
|
|
||||||
IN BIOS_LEGACY_DRIVE *Drive,
|
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL **DevicePath
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// AVL UINT64 Address;
|
|
||||||
// AVL EFI_HANDLE Handle;
|
|
||||||
//
|
|
||||||
EFI_DEV_PATH Node;
|
|
||||||
UINT32 Controller;
|
|
||||||
|
|
||||||
Controller = (UINT32) Drive->Parameters.InterfacePath.Pci.Controller;
|
|
||||||
|
|
||||||
ZeroMem (&Node, sizeof (Node));
|
|
||||||
if ((AsciiStrnCmp ("ATAPI", Drive->Parameters.InterfaceType, 5) == 0) ||
|
|
||||||
(AsciiStrnCmp ("ATA", Drive->Parameters.InterfaceType, 3) == 0)
|
|
||||||
) {
|
|
||||||
//
|
|
||||||
// ATA or ATAPI drive found
|
|
||||||
//
|
|
||||||
Node.Atapi.Header.Type = MESSAGING_DEVICE_PATH;
|
|
||||||
Node.Atapi.Header.SubType = MSG_ATAPI_DP;
|
|
||||||
SetDevicePathNodeLength (&Node.Atapi.Header, sizeof (ATAPI_DEVICE_PATH));
|
|
||||||
Node.Atapi.SlaveMaster = Drive->Parameters.DevicePath.Atapi.Master;
|
|
||||||
Node.Atapi.Lun = Drive->Parameters.DevicePath.Atapi.Lun;
|
|
||||||
Node.Atapi.PrimarySecondary = (UINT8) Controller;
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Not an ATA/ATAPI drive
|
|
||||||
//
|
|
||||||
if (Controller != 0) {
|
|
||||||
ZeroMem (&Node, sizeof (Node));
|
|
||||||
Node.Controller.Header.Type = HARDWARE_DEVICE_PATH;
|
|
||||||
Node.Controller.Header.SubType = HW_CONTROLLER_DP;
|
|
||||||
SetDevicePathNodeLength (&Node.Controller.Header, sizeof (CONTROLLER_DEVICE_PATH));
|
|
||||||
Node.Controller.ControllerNumber = Controller;
|
|
||||||
*DevicePath = AppendDevicePathNode (*DevicePath, &Node.DevPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
ZeroMem (&Node, sizeof (Node));
|
|
||||||
|
|
||||||
if (AsciiStrnCmp ("SCSI", Drive->Parameters.InterfaceType, 4) == 0) {
|
|
||||||
//
|
|
||||||
// SCSI drive
|
|
||||||
//
|
|
||||||
Node.Scsi.Header.Type = MESSAGING_DEVICE_PATH;
|
|
||||||
Node.Scsi.Header.SubType = MSG_SCSI_DP;
|
|
||||||
SetDevicePathNodeLength (&Node.Scsi.Header, sizeof (SCSI_DEVICE_PATH));
|
|
||||||
|
|
||||||
//
|
|
||||||
// Lun is miss aligned in both EDD and Device Path data structures.
|
|
||||||
// thus we do a byte copy, to prevent alignment traps on IA-64.
|
|
||||||
//
|
|
||||||
CopyMem (&Node.Scsi.Lun, &Drive->Parameters.DevicePath.Scsi.Lun, sizeof (UINT16));
|
|
||||||
Node.Scsi.Pun = Drive->Parameters.DevicePath.Scsi.Pun;
|
|
||||||
|
|
||||||
} else if (AsciiStrnCmp ("USB", Drive->Parameters.InterfaceType, 3) == 0) {
|
|
||||||
//
|
|
||||||
// USB drive
|
|
||||||
//
|
|
||||||
Node.Usb.Header.Type = MESSAGING_DEVICE_PATH;
|
|
||||||
Node.Usb.Header.SubType = MSG_USB_DP;
|
|
||||||
SetDevicePathNodeLength (&Node.Usb.Header, sizeof (USB_DEVICE_PATH));
|
|
||||||
Node.Usb.ParentPortNumber = (UINT8) Drive->Parameters.DevicePath.Usb.Reserved;
|
|
||||||
|
|
||||||
} else if (AsciiStrnCmp ("1394", Drive->Parameters.InterfaceType, 4) == 0) {
|
|
||||||
//
|
|
||||||
// 1394 drive
|
|
||||||
//
|
|
||||||
Node.F1394.Header.Type = MESSAGING_DEVICE_PATH;
|
|
||||||
Node.F1394.Header.SubType = MSG_1394_DP;
|
|
||||||
SetDevicePathNodeLength (&Node.F1394.Header, sizeof (F1394_DEVICE_PATH));
|
|
||||||
Node.F1394.Guid = Drive->Parameters.DevicePath.FireWire.Guid;
|
|
||||||
|
|
||||||
} else if (AsciiStrnCmp ("FIBRE", Drive->Parameters.InterfaceType, 5) == 0) {
|
|
||||||
//
|
|
||||||
// Fibre drive
|
|
||||||
//
|
|
||||||
Node.FibreChannel.Header.Type = MESSAGING_DEVICE_PATH;
|
|
||||||
Node.FibreChannel.Header.SubType = MSG_FIBRECHANNEL_DP;
|
|
||||||
SetDevicePathNodeLength (&Node.FibreChannel.Header, sizeof (FIBRECHANNEL_DEVICE_PATH));
|
|
||||||
Node.FibreChannel.WWN = Drive->Parameters.DevicePath.FibreChannel.Wwn;
|
|
||||||
Node.FibreChannel.Lun = Drive->Parameters.DevicePath.FibreChannel.Lun;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
DEBUG (
|
|
||||||
(
|
|
||||||
DEBUG_BLKIO, "It is unrecognized EDD 3.0 device, Drive Number = %x, InterfaceType = %s\n",
|
|
||||||
Drive->Number,
|
|
||||||
Drive->Parameters.InterfaceType
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Node.DevPath.Type == 0) {
|
|
||||||
return EFI_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
*DevicePath = AppendDevicePathNode (BaseDevicePath, &Node.DevPath);
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
@ -1,425 +0,0 @@
|
|||||||
/** @file
|
|
||||||
|
|
||||||
Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef _BIOS_BLOCK_IO_H_
|
|
||||||
#define _BIOS_BLOCK_IO_H_
|
|
||||||
|
|
||||||
#include <Uefi.h>
|
|
||||||
|
|
||||||
#include <Protocol/BlockIo.h>
|
|
||||||
#include <Protocol/PciIo.h>
|
|
||||||
#include <Protocol/LegacyBios.h>
|
|
||||||
#include <Protocol/DevicePath.h>
|
|
||||||
#include <Guid/LegacyBios.h>
|
|
||||||
#include <Guid/BlockIoVendor.h>
|
|
||||||
|
|
||||||
#include <Library/UefiDriverEntryPoint.h>
|
|
||||||
#include <Library/DebugLib.h>
|
|
||||||
#include <Library/BaseMemoryLib.h>
|
|
||||||
#include <Library/UefiBootServicesTableLib.h>
|
|
||||||
#include <Library/UefiLib.h>
|
|
||||||
#include <Library/DevicePathLib.h>
|
|
||||||
#include <Library/MemoryAllocationLib.h>
|
|
||||||
|
|
||||||
#include <IndustryStandard/Pci.h>
|
|
||||||
|
|
||||||
#include "Edd.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// Global Variables
|
|
||||||
//
|
|
||||||
extern EFI_COMPONENT_NAME_PROTOCOL gBiosBlockIoComponentName;
|
|
||||||
extern EFI_COMPONENT_NAME2_PROTOCOL gBiosBlockIoComponentName2;
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Define the I2O class code
|
|
||||||
//
|
|
||||||
#define PCI_BASE_CLASS_INTELLIGENT 0x0e
|
|
||||||
#define PCI_SUB_CLASS_INTELLIGENT 0x00
|
|
||||||
|
|
||||||
//
|
|
||||||
// Number of pages needed for our buffer under 1MB
|
|
||||||
//
|
|
||||||
#define BLOCK_IO_BUFFER_PAGE_SIZE (((sizeof (EDD_DEVICE_ADDRESS_PACKET) + sizeof (BIOS_LEGACY_DRIVE) + MAX_EDD11_XFER) / EFI_PAGE_SIZE) + 1 \
|
|
||||||
)
|
|
||||||
|
|
||||||
//
|
|
||||||
// Driver Binding Protocol functions
|
|
||||||
//
|
|
||||||
|
|
||||||
/**
|
|
||||||
Check whether the driver supports this device.
|
|
||||||
|
|
||||||
@param This The Udriver binding protocol.
|
|
||||||
@param Controller The controller handle to check.
|
|
||||||
@param RemainingDevicePath The remaining device path.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The driver supports this controller.
|
|
||||||
@retval other This device isn't supported.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
BiosBlockIoDriverBindingSupported (
|
|
||||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE Controller,
|
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Starts the device with this driver.
|
|
||||||
|
|
||||||
@param This The driver binding instance.
|
|
||||||
@param Controller Handle of device to bind driver to.
|
|
||||||
@param RemainingDevicePath Optional parameter use to pick a specific child
|
|
||||||
device to start.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The controller is controlled by the driver.
|
|
||||||
@retval Other This controller cannot be started.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
BiosBlockIoDriverBindingStart (
|
|
||||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE Controller,
|
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Stop the device handled by this driver.
|
|
||||||
|
|
||||||
@param This The driver binding protocol.
|
|
||||||
@param Controller The controller to release.
|
|
||||||
@param NumberOfChildren The number of handles in ChildHandleBuffer.
|
|
||||||
@param ChildHandleBuffer The array of child handle.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The device was stopped.
|
|
||||||
@retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
|
|
||||||
@retval Others Fail to uninstall protocols attached on the device.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
BiosBlockIoDriverBindingStop (
|
|
||||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE Controller,
|
|
||||||
IN UINTN NumberOfChildren,
|
|
||||||
IN EFI_HANDLE *ChildHandleBuffer
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Other internal functions
|
|
||||||
//
|
|
||||||
|
|
||||||
/**
|
|
||||||
Build device path for EDD 3.0.
|
|
||||||
|
|
||||||
@param BaseDevicePath Base device path.
|
|
||||||
@param Drive Legacy drive.
|
|
||||||
@param DevicePath Device path for output.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The device path is built successfully.
|
|
||||||
@retval EFI_UNSUPPORTED It is failed to built device path.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
BuildEdd30DevicePath (
|
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *BaseDevicePath,
|
|
||||||
IN BIOS_LEGACY_DRIVE *Drive,
|
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL **DevicePath
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Initialize block I/O device instance
|
|
||||||
|
|
||||||
@param Dev Instance of block I/O device instance
|
|
||||||
|
|
||||||
@retval TRUE Initialization succeeds.
|
|
||||||
@retval FALSE Initialization fails.
|
|
||||||
|
|
||||||
**/
|
|
||||||
BOOLEAN
|
|
||||||
BiosInitBlockIo (
|
|
||||||
IN BIOS_BLOCK_IO_DEV *Dev
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
Edd30BiosReadBlocks (
|
|
||||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
|
||||||
IN UINT32 MediaId,
|
|
||||||
IN EFI_LBA Lba,
|
|
||||||
IN UINTN BufferSize,
|
|
||||||
OUT VOID *Buffer
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
Edd30BiosWriteBlocks (
|
|
||||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
|
||||||
IN UINT32 MediaId,
|
|
||||||
IN EFI_LBA Lba,
|
|
||||||
IN UINTN BufferSize,
|
|
||||||
OUT VOID *Buffer
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
BiosBlockIoFlushBlocks (
|
|
||||||
IN EFI_BLOCK_IO_PROTOCOL *This
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
BiosBlockIoReset (
|
|
||||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
|
||||||
IN BOOLEAN ExtendedVerification
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
Edd11BiosReadBlocks (
|
|
||||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
|
||||||
IN UINT32 MediaId,
|
|
||||||
IN EFI_LBA Lba,
|
|
||||||
IN UINTN BufferSize,
|
|
||||||
OUT VOID *Buffer
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
Edd11BiosWriteBlocks (
|
|
||||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
|
||||||
IN UINT32 MediaId,
|
|
||||||
IN EFI_LBA Lba,
|
|
||||||
IN UINTN BufferSize,
|
|
||||||
OUT VOID *Buffer
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
BiosReadLegacyDrive (
|
|
||||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
|
||||||
IN UINT32 MediaId,
|
|
||||||
IN EFI_LBA Lba,
|
|
||||||
IN UINTN BufferSize,
|
|
||||||
OUT VOID *Buffer
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
BiosWriteLegacyDrive (
|
|
||||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
|
||||||
IN UINT32 MediaId,
|
|
||||||
IN EFI_LBA Lba,
|
|
||||||
IN UINTN BufferSize,
|
|
||||||
OUT VOID *Buffer
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Gets parameters of block I/O device.
|
|
||||||
|
|
||||||
@param BiosBlockIoDev Instance of block I/O device.
|
|
||||||
@param Drive Legacy drive.
|
|
||||||
|
|
||||||
@return Result of device parameter retrieval.
|
|
||||||
|
|
||||||
**/
|
|
||||||
UINTN
|
|
||||||
Int13GetDeviceParameters (
|
|
||||||
IN BIOS_BLOCK_IO_DEV *BiosBlockIoDev,
|
|
||||||
IN BIOS_LEGACY_DRIVE *Drive
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Extension of INT13 call.
|
|
||||||
|
|
||||||
@param BiosBlockIoDev Instance of block I/O device.
|
|
||||||
@param Drive Legacy drive.
|
|
||||||
|
|
||||||
@return Result of this extension.
|
|
||||||
|
|
||||||
**/
|
|
||||||
UINTN
|
|
||||||
Int13Extensions (
|
|
||||||
IN BIOS_BLOCK_IO_DEV *BiosBlockIoDev,
|
|
||||||
IN BIOS_LEGACY_DRIVE *Drive
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Gets parameters of legacy drive.
|
|
||||||
|
|
||||||
@param BiosBlockIoDev Instance of block I/O device.
|
|
||||||
@param Drive Legacy drive.
|
|
||||||
|
|
||||||
@return Result of drive parameter retrieval.
|
|
||||||
|
|
||||||
**/
|
|
||||||
UINTN
|
|
||||||
GetDriveParameters (
|
|
||||||
IN BIOS_BLOCK_IO_DEV *BiosBlockIoDev,
|
|
||||||
IN BIOS_LEGACY_DRIVE *Drive
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Build device path for device.
|
|
||||||
|
|
||||||
@param BaseDevicePath Base device path.
|
|
||||||
@param Drive Legacy drive.
|
|
||||||
@param DevicePath Device path for output.
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
SetBiosInitBlockIoDevicePath (
|
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *BaseDevicePath,
|
|
||||||
IN BIOS_LEGACY_DRIVE *Drive,
|
|
||||||
OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
|
|
||||||
);
|
|
||||||
|
|
||||||
#endif
|
|
File diff suppressed because it is too large
Load Diff
@ -1,58 +0,0 @@
|
|||||||
## @file
|
|
||||||
# BIOS Block IO module.
|
|
||||||
#
|
|
||||||
# This is the UEFI driver to thunk legacy BIOS int13 interface into UEFI block IO interface.
|
|
||||||
# Once connected it installs EfiBlockIoProtocol on top of legacy BIOS int13.
|
|
||||||
#
|
|
||||||
# Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.<BR>
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
#
|
|
||||||
##
|
|
||||||
|
|
||||||
[Defines]
|
|
||||||
INF_VERSION = 0x00010005
|
|
||||||
BASE_NAME = BlockIoDxe
|
|
||||||
MODULE_UNI_FILE = BlockIoDxe.uni
|
|
||||||
FILE_GUID = 4495E47E-42A9-4007-8c17-B6664F909D04
|
|
||||||
MODULE_TYPE = UEFI_DRIVER
|
|
||||||
VERSION_STRING = 1.0
|
|
||||||
|
|
||||||
ENTRY_POINT = BiosBlockIoDriverEntryPoint
|
|
||||||
|
|
||||||
[Sources]
|
|
||||||
BiosBlkIo.h
|
|
||||||
Edd.h
|
|
||||||
BiosBlkIo.c
|
|
||||||
BiosInt13.c
|
|
||||||
ComponentName.c
|
|
||||||
|
|
||||||
[LibraryClasses]
|
|
||||||
UefiDriverEntryPoint
|
|
||||||
DebugLib
|
|
||||||
BaseMemoryLib
|
|
||||||
UefiBootServicesTableLib
|
|
||||||
UefiLib
|
|
||||||
DevicePathLib
|
|
||||||
MemoryAllocationLib
|
|
||||||
|
|
||||||
|
|
||||||
[Protocols]
|
|
||||||
gEfiBlockIoProtocolGuid ## BY_START
|
|
||||||
gEfiDevicePathProtocolGuid ## BY_START
|
|
||||||
gEfiDevicePathProtocolGuid ## TO_START
|
|
||||||
gEfiPciIoProtocolGuid ## TO_START
|
|
||||||
gEfiLegacyBiosProtocolGuid ## TO_START
|
|
||||||
|
|
||||||
|
|
||||||
[Guids]
|
|
||||||
gEfiLegacyBiosGuid ## PRODUCES ## UNDEFINED
|
|
||||||
gBlockIoVendorGuid ## SOMETIMES_CONSUMES ## UNDEFINED
|
|
||||||
|
|
||||||
[Packages]
|
|
||||||
MdePkg/MdePkg.dec
|
|
||||||
IntelFrameworkPkg/IntelFrameworkPkg.dec
|
|
||||||
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
|
|
||||||
|
|
||||||
[UserExtensions.TianoCore."ExtraFiles"]
|
|
||||||
BlockIoDxeExtra.uni
|
|
@ -1,17 +0,0 @@
|
|||||||
// /** @file
|
|
||||||
// BIOS Block IO module.
|
|
||||||
//
|
|
||||||
// This is the UEFI driver to thunk legacy BIOS int13 interface into UEFI block IO interface.
|
|
||||||
// Once connected it installs EfiBlockIoProtocol on top of legacy BIOS int13.
|
|
||||||
//
|
|
||||||
// Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
//
|
|
||||||
// **/
|
|
||||||
|
|
||||||
|
|
||||||
#string STR_MODULE_ABSTRACT #language en-US "BIOS Block IO module"
|
|
||||||
|
|
||||||
#string STR_MODULE_DESCRIPTION #language en-US "This is the UEFI driver to thunk legacy BIOS int13 interface into the UEFI block IO interface. Once connected, it installs EfiBlockIoProtocol on top of legacy BIOS int13."
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
|||||||
// /** @file
|
|
||||||
// BlockIoDxe Localized Strings and Content
|
|
||||||
//
|
|
||||||
// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
//
|
|
||||||
// **/
|
|
||||||
|
|
||||||
#string STR_PROPERTIES_MODULE_NAME
|
|
||||||
#language en-US
|
|
||||||
"Legacy Block I/O DXE Driver"
|
|
||||||
|
|
||||||
|
|
@ -1,302 +0,0 @@
|
|||||||
/** @file
|
|
||||||
|
|
||||||
Copyright (c) 1999 - 2011, Intel Corporation. All rights reserved.<BR>
|
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#include "BiosBlkIo.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
BiosBlockIoComponentNameGetDriverName (
|
|
||||||
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
|
|
||||||
BiosBlockIoComponentNameGetControllerName (
|
|
||||||
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 gBiosBlockIoComponentName = {
|
|
||||||
BiosBlockIoComponentNameGetDriverName,
|
|
||||||
BiosBlockIoComponentNameGetControllerName,
|
|
||||||
"eng"
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// EFI Component Name 2 Protocol
|
|
||||||
//
|
|
||||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gBiosBlockIoComponentName2 = {
|
|
||||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) BiosBlockIoComponentNameGetDriverName,
|
|
||||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) BiosBlockIoComponentNameGetControllerName,
|
|
||||||
"en"
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mBiosBlockIoDriverNameTable[] = {
|
|
||||||
{
|
|
||||||
"eng;en",
|
|
||||||
L"BIOS[INT13] Block 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
|
|
||||||
BiosBlockIoComponentNameGetDriverName (
|
|
||||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
|
||||||
IN CHAR8 *Language,
|
|
||||||
OUT CHAR16 **DriverName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return LookupUnicodeString2 (
|
|
||||||
Language,
|
|
||||||
This->SupportedLanguages,
|
|
||||||
mBiosBlockIoDriverNameTable,
|
|
||||||
DriverName,
|
|
||||||
(BOOLEAN)(This == &gBiosBlockIoComponentName)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
BiosBlockIoComponentNameGetControllerName (
|
|
||||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE ControllerHandle,
|
|
||||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
|
||||||
IN CHAR8 *Language,
|
|
||||||
OUT CHAR16 **ControllerName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return EFI_UNSUPPORTED;
|
|
||||||
}
|
|
@ -1,202 +0,0 @@
|
|||||||
/** @file
|
|
||||||
Include file to suport EDD 3.0.
|
|
||||||
This file is coded to T13 D1386 Revision 3
|
|
||||||
Availible on http://www.t13.org/#Project drafts
|
|
||||||
Currently at ftp://fission.dt.wdc.com/pub/standards/x3t13/project/d1386r3.pdf
|
|
||||||
|
|
||||||
Copyright (c) 1999 - 2010, Intel Corporation. All rights reserved.<BR>
|
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef _EDD_H_
|
|
||||||
#define _EDD_H_
|
|
||||||
|
|
||||||
//
|
|
||||||
// packing with no compiler padding, so that the fields
|
|
||||||
// of the following architected structures can be
|
|
||||||
// properly accessed from C code.
|
|
||||||
//
|
|
||||||
#pragma pack(1)
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINT8 Bus;
|
|
||||||
UINT8 Device;
|
|
||||||
UINT8 Function;
|
|
||||||
UINT8 Controller;
|
|
||||||
UINT32 Reserved;
|
|
||||||
} EDD_PCI;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINT16 Base;
|
|
||||||
UINT16 Reserved;
|
|
||||||
UINT32 Reserved2;
|
|
||||||
} EDD_LEGACY;
|
|
||||||
|
|
||||||
typedef union {
|
|
||||||
EDD_PCI Pci;
|
|
||||||
EDD_LEGACY Legacy;
|
|
||||||
} EDD_INTERFACE_PATH;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINT8 Master;
|
|
||||||
UINT8 Reserved[15];
|
|
||||||
} EDD_ATA;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINT8 Master;
|
|
||||||
UINT8 Lun;
|
|
||||||
UINT8 Reserved[14];
|
|
||||||
} EDD_ATAPI;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINT16 Pun;
|
|
||||||
UINT64 Lun;
|
|
||||||
UINT8 Reserved[6];
|
|
||||||
} EDD_SCSI;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINT64 SerialNumber;
|
|
||||||
UINT64 Reserved;
|
|
||||||
} EDD_USB;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINT64 Guid;
|
|
||||||
UINT64 Reserved;
|
|
||||||
} EDD_1394;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINT64 Wwn;
|
|
||||||
UINT64 Lun;
|
|
||||||
} EDD_FIBRE;
|
|
||||||
|
|
||||||
typedef union {
|
|
||||||
EDD_ATA Ata;
|
|
||||||
EDD_ATAPI Atapi;
|
|
||||||
EDD_SCSI Scsi;
|
|
||||||
EDD_USB Usb;
|
|
||||||
EDD_1394 FireWire;
|
|
||||||
EDD_FIBRE FibreChannel;
|
|
||||||
} EDD_DEVICE_PATH;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINT16 StructureSize;
|
|
||||||
UINT16 Flags;
|
|
||||||
UINT32 MaxCylinders;
|
|
||||||
UINT32 MaxHeads;
|
|
||||||
UINT32 SectorsPerTrack;
|
|
||||||
UINT64 PhysicalSectors;
|
|
||||||
UINT16 BytesPerSector;
|
|
||||||
UINT32 Fdpt;
|
|
||||||
UINT16 Key;
|
|
||||||
UINT8 DevicePathLength;
|
|
||||||
UINT8 Reserved1;
|
|
||||||
UINT16 Reserved2;
|
|
||||||
CHAR8 HostBusType[4];
|
|
||||||
CHAR8 InterfaceType[8];
|
|
||||||
EDD_INTERFACE_PATH InterfacePath;
|
|
||||||
EDD_DEVICE_PATH DevicePath;
|
|
||||||
UINT8 Reserved3;
|
|
||||||
UINT8 Checksum;
|
|
||||||
} EDD_DRIVE_PARAMETERS;
|
|
||||||
|
|
||||||
//
|
|
||||||
// EDD_DRIVE_PARAMETERS.Flags defines
|
|
||||||
//
|
|
||||||
#define EDD_GEOMETRY_VALID 0x02
|
|
||||||
#define EDD_DEVICE_REMOVABLE 0x04
|
|
||||||
#define EDD_WRITE_VERIFY_SUPPORTED 0x08
|
|
||||||
#define EDD_DEVICE_CHANGE 0x10
|
|
||||||
#define EDD_DEVICE_LOCKABLE 0x20
|
|
||||||
|
|
||||||
//
|
|
||||||
// BUGBUG: This bit does not follow the spec. It tends to be always set
|
|
||||||
// to work properly with Win98.
|
|
||||||
//
|
|
||||||
#define EDD_DEVICE_GEOMETRY_MAX 0x40
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINT8 PacketSizeInBytes; // 0x18
|
|
||||||
UINT8 Zero;
|
|
||||||
UINT8 NumberOfBlocks; // Max 0x7f
|
|
||||||
UINT8 Zero2;
|
|
||||||
UINT32 SegOffset;
|
|
||||||
UINT64 Lba;
|
|
||||||
UINT64 TransferBuffer;
|
|
||||||
UINT32 ExtendedBlockCount; // Max 0xffffffff
|
|
||||||
UINT32 Zero3;
|
|
||||||
} EDD_DEVICE_ADDRESS_PACKET;
|
|
||||||
|
|
||||||
#define EDD_VERSION_30 0x30
|
|
||||||
|
|
||||||
//
|
|
||||||
// Int 13 BIOS Errors
|
|
||||||
//
|
|
||||||
#define BIOS_PASS 0x00
|
|
||||||
#define BIOS_WRITE_PROTECTED 0x03
|
|
||||||
#define BIOS_SECTOR_NOT_FOUND 0x04
|
|
||||||
#define BIOS_RESET_FAILED 0x05
|
|
||||||
#define BIOS_DISK_CHANGED 0x06
|
|
||||||
#define BIOS_DRIVE_DOES_NOT_EXIST 0x07
|
|
||||||
#define BIOS_DMA_ERROR 0x08
|
|
||||||
#define BIOS_DATA_BOUNDRY_ERROR 0x09
|
|
||||||
#define BIOS_BAD_SECTOR 0x0a
|
|
||||||
#define BIOS_BAD_TRACK 0x0b
|
|
||||||
#define BIOS_MEADIA_TYPE_NOT_FOUND 0x0c
|
|
||||||
#define BIOS_INVALED_FORMAT 0x0d
|
|
||||||
#define BIOS_ECC_ERROR 0x10
|
|
||||||
#define BIOS_ECC_CORRECTED_ERROR 0x11
|
|
||||||
#define BIOS_HARD_DRIVE_FAILURE 0x20
|
|
||||||
#define BIOS_SEEK_FAILED 0x40
|
|
||||||
#define BIOS_DRIVE_TIMEOUT 0x80
|
|
||||||
#define BIOS_DRIVE_NOT_READY 0xaa
|
|
||||||
#define BIOS_UNDEFINED_ERROR 0xbb
|
|
||||||
#define BIOS_WRITE_FAULT 0xcc
|
|
||||||
#define BIOS_SENSE_FAILED 0xff
|
|
||||||
|
|
||||||
#define MAX_EDD11_XFER 0xfe00
|
|
||||||
|
|
||||||
#pragma pack()
|
|
||||||
//
|
|
||||||
// Internal Data Structures
|
|
||||||
//
|
|
||||||
typedef struct {
|
|
||||||
CHAR8 Letter;
|
|
||||||
UINT8 Number;
|
|
||||||
UINT8 EddVersion;
|
|
||||||
BOOLEAN ExtendedInt13;
|
|
||||||
BOOLEAN DriveLockingAndEjecting;
|
|
||||||
BOOLEAN Edd;
|
|
||||||
BOOLEAN Extensions64Bit;
|
|
||||||
BOOLEAN ParametersValid;
|
|
||||||
UINT8 ErrorCode;
|
|
||||||
VOID *FdptPointer;
|
|
||||||
BOOLEAN Floppy;
|
|
||||||
BOOLEAN AtapiFloppy;
|
|
||||||
UINT8 MaxHead;
|
|
||||||
UINT8 MaxSector;
|
|
||||||
UINT16 MaxCylinder;
|
|
||||||
UINT16 Pad;
|
|
||||||
EDD_DRIVE_PARAMETERS Parameters;
|
|
||||||
} BIOS_LEGACY_DRIVE;
|
|
||||||
|
|
||||||
#define BIOS_CONSOLE_BLOCK_IO_DEV_SIGNATURE SIGNATURE_32 ('b', 'b', 'i', 'o')
|
|
||||||
typedef struct {
|
|
||||||
UINTN Signature;
|
|
||||||
|
|
||||||
EFI_HANDLE Handle;
|
|
||||||
EFI_HANDLE ControllerHandle;
|
|
||||||
EFI_BLOCK_IO_PROTOCOL BlockIo;
|
|
||||||
EFI_BLOCK_IO_MEDIA BlockMedia;
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
|
||||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
|
||||||
EFI_LEGACY_BIOS_PROTOCOL *LegacyBios;
|
|
||||||
|
|
||||||
BIOS_LEGACY_DRIVE Bios;
|
|
||||||
|
|
||||||
} BIOS_BLOCK_IO_DEV;
|
|
||||||
|
|
||||||
#define BIOS_BLOCK_IO_FROM_THIS(a) CR (a, BIOS_BLOCK_IO_DEV, BlockIo, BIOS_CONSOLE_BLOCK_IO_DEV_SIGNATURE)
|
|
||||||
|
|
||||||
#endif
|
|
File diff suppressed because it is too large
Load Diff
@ -1,758 +0,0 @@
|
|||||||
/** @file
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef _BIOS_KEYBOARD_H_
|
|
||||||
#define _BIOS_KEYBOARD_H_
|
|
||||||
|
|
||||||
|
|
||||||
#include <FrameworkDxe.h>
|
|
||||||
#include <Pi/PiDxeCis.h>
|
|
||||||
|
|
||||||
#include <Guid/StatusCodeDataTypeId.h>
|
|
||||||
#include <Protocol/SimpleTextIn.h>
|
|
||||||
#include <Protocol/SimpleTextInEx.h>
|
|
||||||
#include <Protocol/LegacyBios.h>
|
|
||||||
#include <Protocol/IsaIo.h>
|
|
||||||
#include <Protocol/DevicePath.h>
|
|
||||||
#include <Protocol/Ps2Policy.h>
|
|
||||||
|
|
||||||
#include <Library/DebugLib.h>
|
|
||||||
#include <Library/UefiLib.h>
|
|
||||||
#include <Library/BaseMemoryLib.h>
|
|
||||||
#include <Library/ReportStatusCodeLib.h>
|
|
||||||
#include <Library/UefiDriverEntryPoint.h>
|
|
||||||
#include <Library/UefiBootServicesTableLib.h>
|
|
||||||
#include <Library/DxeServicesTableLib.h>
|
|
||||||
#include <Library/MemoryAllocationLib.h>
|
|
||||||
#include <Library/BaseLib.h>
|
|
||||||
#include <Library/PcdLib.h>
|
|
||||||
|
|
||||||
//
|
|
||||||
// Driver Binding Externs
|
|
||||||
//
|
|
||||||
extern EFI_DRIVER_BINDING_PROTOCOL gBiosKeyboardDriverBinding;
|
|
||||||
extern EFI_COMPONENT_NAME_PROTOCOL gBiosKeyboardComponentName;
|
|
||||||
extern EFI_COMPONENT_NAME2_PROTOCOL gBiosKeyboardComponentName2;
|
|
||||||
|
|
||||||
|
|
||||||
#include <IndustryStandard/Pci.h>
|
|
||||||
|
|
||||||
//
|
|
||||||
// BISO Keyboard Defines
|
|
||||||
//
|
|
||||||
#define CHAR_SCANCODE 0xe0
|
|
||||||
#define CHAR_ESC 0x1b
|
|
||||||
|
|
||||||
#define KEYBOARD_8042_DATA_REGISTER 0x60
|
|
||||||
#define KEYBOARD_8042_STATUS_REGISTER 0x64
|
|
||||||
#define KEYBOARD_8042_COMMAND_REGISTER 0x64
|
|
||||||
|
|
||||||
#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
|
|
||||||
// KEYBOARD COMMAND BYTE -- read by writing command KBC_CMDREG_VIA64_CMDBYTE_R to 64H, then read from 60H
|
|
||||||
// write by wrting command KBC_CMDREG_VIA64_CMDBYTE_W to 64H, then write to 60H
|
|
||||||
// 7: Reserved
|
|
||||||
// 6: PC/XT translation mode convert
|
|
||||||
// 5: Disable Auxiliary device interface
|
|
||||||
// 4: Disable keyboard interface
|
|
||||||
// 3: Reserved
|
|
||||||
// 2: System Flag: selftest successful
|
|
||||||
// 1: Enable Auxiliary device interrupt
|
|
||||||
// 0: Enable Keyboard interrupt )
|
|
||||||
//
|
|
||||||
#define KB_CMMBYTE_KSCAN2UNI_COV (0x1 << 6)
|
|
||||||
#define KB_CMMBYTE_DISABLE_AUX (0x1 << 5)
|
|
||||||
#define KB_CMMBYTE_DISABLE_KB (0x1 << 4)
|
|
||||||
#define KB_CMMBYTE_SLFTEST_SUCC (0x1 << 2)
|
|
||||||
#define KB_CMMBYTE_ENABLE_AUXINT (0x1 << 1)
|
|
||||||
#define KB_CMMBYTE_ENABLE_KBINT (0x1 << 0)
|
|
||||||
|
|
||||||
//
|
|
||||||
// KEYBOARD CONTROLLER STATUS REGISTER - read from 64h
|
|
||||||
// 7: Parity error
|
|
||||||
// 6: General time out
|
|
||||||
// 5: Output buffer holds data for AUX
|
|
||||||
// 4: Keyboard is not locked
|
|
||||||
// 3: Command written via 64h / Data written via 60h
|
|
||||||
// 2: KBC self-test successful / Power-on reset
|
|
||||||
// 1: Input buffer holds CPU data / empty
|
|
||||||
// 0: Output buffer holds keyboard data / empty
|
|
||||||
//
|
|
||||||
#define KBC_STSREG_VIA64_PARE (0x1 << 7)
|
|
||||||
#define KBC_STSREG_VIA64_TIM (0x1 << 6)
|
|
||||||
#define KBC_STSREG_VIA64_AUXB (0x1 << 5)
|
|
||||||
#define KBC_STSREG_VIA64_KEYL (0x1 << 4)
|
|
||||||
#define KBC_STSREG_VIA64_C_D (0x1 << 3)
|
|
||||||
#define KBC_STSREG_VIA64_SYSF (0x1 << 2)
|
|
||||||
#define KBC_STSREG_VIA64_INPB (0x1 << 1)
|
|
||||||
#define KBC_STSREG_VIA64_OUTB (0x1 << 0)
|
|
||||||
|
|
||||||
//
|
|
||||||
// COMMANDs of KEYBOARD CONTROLLER COMMAND REGISTER - write to 64h
|
|
||||||
//
|
|
||||||
#define KBC_CMDREG_VIA64_CMDBYTE_R 0x20
|
|
||||||
#define KBC_CMDREG_VIA64_CMDBYTE_W 0x60
|
|
||||||
#define KBC_CMDREG_VIA64_AUX_DISABLE 0xA7
|
|
||||||
#define KBC_CMDREG_VIA64_AUX_ENABLE 0xA8
|
|
||||||
#define KBC_CMDREG_VIA64_KBC_SLFTEST 0xAA
|
|
||||||
#define KBC_CMDREG_VIA64_KB_CKECK 0xAB
|
|
||||||
#define KBC_CMDREG_VIA64_KB_DISABLE 0xAD
|
|
||||||
#define KBC_CMDREG_VIA64_KB_ENABLE 0xAE
|
|
||||||
#define KBC_CMDREG_VIA64_INTP_LOW_R 0xC0
|
|
||||||
#define KBC_CMDREG_VIA64_INTP_HIGH_R 0xC2
|
|
||||||
#define KBC_CMDREG_VIA64_OUTP_R 0xD0
|
|
||||||
#define KBC_CMDREG_VIA64_OUTP_W 0xD1
|
|
||||||
#define KBC_CMDREG_VIA64_OUTB_KB_W 0xD2
|
|
||||||
#define KBC_CMDREG_VIA64_OUTB_AUX_W 0xD3
|
|
||||||
#define KBC_CMDREG_VIA64_AUX_W 0xD4
|
|
||||||
|
|
||||||
//
|
|
||||||
// echos of KEYBOARD CONTROLLER COMMAND - read from 60h
|
|
||||||
//
|
|
||||||
#define KBC_CMDECHO_KBCSLFTEST_OK 0x55
|
|
||||||
#define KBC_CMDECHO_KBCHECK_OK 0x00
|
|
||||||
#define KBC_CMDECHO_ACK 0xFA
|
|
||||||
#define KBC_CMDECHO_BATTEST_OK 0xAA
|
|
||||||
#define KBC_CMDECHO_BATTEST_FAILE 0xFC
|
|
||||||
|
|
||||||
//
|
|
||||||
// OUTPUT PORT COMMANDs - write port by writing KBC_CMDREG_VIA64_OUTP_W via 64H, then write the command to 60H
|
|
||||||
// drive data and clock of KB to high for at least 500us for BAT needs
|
|
||||||
//
|
|
||||||
#define KBC_OUTPORT_DCHIGH_BAT 0xC0
|
|
||||||
//
|
|
||||||
// scan code set type
|
|
||||||
//
|
|
||||||
#define KBC_INPBUF_VIA60_SCODESET1 0x01
|
|
||||||
#define KBC_INPBUF_VIA60_SCODESET2 0x02
|
|
||||||
#define KBC_INPBUF_VIA60_SCODESET3 0x03
|
|
||||||
|
|
||||||
//
|
|
||||||
// COMMANDs written to INPUT BUFFER - write to 60h
|
|
||||||
//
|
|
||||||
#define KBC_INPBUF_VIA60_KBECHO 0xEE
|
|
||||||
#define KBC_INPBUF_VIA60_KBSCODE 0xF0
|
|
||||||
#define KBC_INPBUF_VIA60_KBTYPE 0xF2
|
|
||||||
#define KBC_INPBUF_VIA60_KBDELAY 0xF3
|
|
||||||
#define KBC_INPBUF_VIA60_KBEN 0xF4
|
|
||||||
#define KBC_INPBUF_VIA60_KBSTDDIS 0xF5
|
|
||||||
#define KBC_INPBUF_VIA60_KBSTDEN 0xF6
|
|
||||||
#define KBC_INPBUF_VIA60_KBRESEND 0xFE
|
|
||||||
#define KBC_INPBUF_VIA60_KBRESET 0xFF
|
|
||||||
|
|
||||||
//
|
|
||||||
// 0040h:0017h - KEYBOARD - STATUS FLAGS 1
|
|
||||||
// 7 INSert active
|
|
||||||
// 6 Caps Lock active
|
|
||||||
// 5 Num Lock active
|
|
||||||
// 4 Scroll Lock active
|
|
||||||
// 3 either Alt pressed
|
|
||||||
// 2 either Ctrl pressed
|
|
||||||
// 1 Left Shift pressed
|
|
||||||
// 0 Right Shift pressed
|
|
||||||
//
|
|
||||||
// 0040h:0018h - KEYBOARD - STATUS FLAGS 2
|
|
||||||
// 7: insert key is depressed
|
|
||||||
// 6: caps-lock key is depressed (does not work well)
|
|
||||||
// 5: num-lock key is depressed (does not work well)
|
|
||||||
// 4: scroll lock key is depressed (does not work well)
|
|
||||||
// 3: suspend key has been toggled (does not work well)
|
|
||||||
// 2: system key is pressed and held (does not work well)
|
|
||||||
// 1: left ALT key is pressed
|
|
||||||
// 0: left CTRL key is pressed
|
|
||||||
//
|
|
||||||
#define KB_INSERT_BIT (0x1 << 7)
|
|
||||||
#define KB_CAPS_LOCK_BIT (0x1 << 6)
|
|
||||||
#define KB_NUM_LOCK_BIT (0x1 << 5)
|
|
||||||
#define KB_SCROLL_LOCK_BIT (0x1 << 4)
|
|
||||||
#define KB_ALT_PRESSED (0x1 << 3)
|
|
||||||
#define KB_CTRL_PRESSED (0x1 << 2)
|
|
||||||
#define KB_LEFT_SHIFT_PRESSED (0x1 << 1)
|
|
||||||
#define KB_RIGHT_SHIFT_PRESSED (0x1 << 0)
|
|
||||||
|
|
||||||
#define KB_SUSPEND_PRESSED (0x1 << 3)
|
|
||||||
#define KB_SYSREQ_PRESSED (0x1 << 2)
|
|
||||||
#define KB_LEFT_ALT_PRESSED (0x1 << 1)
|
|
||||||
#define KB_LEFT_CTRL_PRESSED (0x1 << 0)
|
|
||||||
|
|
||||||
//
|
|
||||||
// BIOS Keyboard Device Structure
|
|
||||||
//
|
|
||||||
#define BIOS_KEYBOARD_DEV_SIGNATURE SIGNATURE_32 ('B', 'K', 'B', 'D')
|
|
||||||
#define BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('c', 'b', 'k', 'h')
|
|
||||||
|
|
||||||
typedef struct _BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY {
|
|
||||||
UINTN Signature;
|
|
||||||
EFI_KEY_DATA KeyData;
|
|
||||||
EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;
|
|
||||||
LIST_ENTRY NotifyEntry;
|
|
||||||
} BIOS_KEYBOARD_CONSOLE_IN_EX_NOTIFY;
|
|
||||||
|
|
||||||
#define QUEUE_MAX_COUNT 32
|
|
||||||
typedef struct {
|
|
||||||
UINTN Front;
|
|
||||||
UINTN Rear;
|
|
||||||
EFI_KEY_DATA Buffer[QUEUE_MAX_COUNT];
|
|
||||||
} SIMPLE_QUEUE;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINTN Signature;
|
|
||||||
EFI_HANDLE Handle;
|
|
||||||
EFI_LEGACY_BIOS_PROTOCOL *LegacyBios;
|
|
||||||
EFI_ISA_IO_PROTOCOL *IsaIo;
|
|
||||||
EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleTextIn;
|
|
||||||
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleTextInputEx;
|
|
||||||
UINT16 DataRegisterAddress;
|
|
||||||
UINT16 StatusRegisterAddress;
|
|
||||||
UINT16 CommandRegisterAddress;
|
|
||||||
BOOLEAN ExtendedKeyboard;
|
|
||||||
|
|
||||||
EFI_KEY_STATE KeyState;
|
|
||||||
//
|
|
||||||
// Buffer storing EFI_KEY_DATA
|
|
||||||
//
|
|
||||||
SIMPLE_QUEUE Queue;
|
|
||||||
SIMPLE_QUEUE QueueForNotify;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Notification Function List
|
|
||||||
//
|
|
||||||
LIST_ENTRY NotifyList;
|
|
||||||
EFI_EVENT KeyNotifyProcessEvent;
|
|
||||||
EFI_EVENT TimerEvent;
|
|
||||||
|
|
||||||
} BIOS_KEYBOARD_DEV;
|
|
||||||
|
|
||||||
#define BIOS_KEYBOARD_DEV_FROM_THIS(a) CR (a, BIOS_KEYBOARD_DEV, SimpleTextIn, BIOS_KEYBOARD_DEV_SIGNATURE)
|
|
||||||
#define TEXT_INPUT_EX_BIOS_KEYBOARD_DEV_FROM_THIS(a) \
|
|
||||||
CR (a, \
|
|
||||||
BIOS_KEYBOARD_DEV, \
|
|
||||||
SimpleTextInputEx, \
|
|
||||||
BIOS_KEYBOARD_DEV_SIGNATURE \
|
|
||||||
)
|
|
||||||
|
|
||||||
//
|
|
||||||
// Global Variables
|
|
||||||
//
|
|
||||||
extern EFI_DRIVER_BINDING_PROTOCOL gBiosKeyboardDriverBinding;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Driver Binding Protocol functions
|
|
||||||
//
|
|
||||||
|
|
||||||
/**
|
|
||||||
Check whether the driver supports this device.
|
|
||||||
|
|
||||||
@param This The Udriver binding protocol.
|
|
||||||
@param Controller The controller handle to check.
|
|
||||||
@param RemainingDevicePath The remaining device path.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The driver supports this controller.
|
|
||||||
@retval other This device isn't supported.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
BiosKeyboardDriverBindingSupported (
|
|
||||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE Controller,
|
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Starts the device with this driver.
|
|
||||||
|
|
||||||
@param This The driver binding instance.
|
|
||||||
@param Controller Handle of device to bind driver to.
|
|
||||||
@param RemainingDevicePath Optional parameter use to pick a specific child
|
|
||||||
device to start.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The controller is controlled by the driver.
|
|
||||||
@retval Other This controller cannot be started.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
BiosKeyboardDriverBindingStart (
|
|
||||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE Controller,
|
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Stop the device handled by this driver.
|
|
||||||
|
|
||||||
@param This The driver binding protocol.
|
|
||||||
@param Controller The controller to release.
|
|
||||||
@param NumberOfChildren The number of handles in ChildHandleBuffer.
|
|
||||||
@param ChildHandleBuffer The array of child handle.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The device was stopped.
|
|
||||||
@retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
|
|
||||||
@retval Others Fail to uninstall protocols attached on the device.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
BiosKeyboardDriverBindingStop (
|
|
||||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE Controller,
|
|
||||||
IN UINTN NumberOfChildren,
|
|
||||||
IN EFI_HANDLE *ChildHandleBuffer
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
BiosKeyboardComponentNameGetDriverName (
|
|
||||||
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
|
|
||||||
BiosKeyboardComponentNameGetControllerName (
|
|
||||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE ControllerHandle,
|
|
||||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
|
||||||
IN CHAR8 *Language,
|
|
||||||
OUT CHAR16 **ControllerName
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Simple Text Input Protocol functions
|
|
||||||
//
|
|
||||||
/**
|
|
||||||
Reset the Keyboard and do BAT test for it, if (ExtendedVerification == TRUE) then do some extra keyboard validations.
|
|
||||||
|
|
||||||
@param This Pointer of simple text Protocol.
|
|
||||||
@param ExtendedVerification Whether perform the extra validation of keyboard. True: perform; FALSE: skip.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The command byte is written successfully.
|
|
||||||
@retval EFI_DEVICE_ERROR Errors occurred during resetting keyboard.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
BiosKeyboardReset (
|
|
||||||
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
|
|
||||||
IN BOOLEAN ExtendedVerification
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Read out the scan code of the key that has just been stroked.
|
|
||||||
|
|
||||||
@param This Pointer of simple text Protocol.
|
|
||||||
@param Key Pointer for store the key that read out.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The key is read out successfully.
|
|
||||||
@retval other The key reading failed.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
BiosKeyboardReadKeyStroke (
|
|
||||||
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
|
|
||||||
OUT EFI_INPUT_KEY *Key
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Private worker functions
|
|
||||||
//
|
|
||||||
/**
|
|
||||||
Waiting on the keyboard event, if there's any key pressed by the user, signal the event
|
|
||||||
|
|
||||||
@param Event The event that be siganlled when any key has been stroked.
|
|
||||||
@param Context Pointer of the protocol EFI_SIMPLE_TEXT_INPUT_PROTOCOL.
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
EFIAPI
|
|
||||||
BiosKeyboardWaitForKey (
|
|
||||||
IN EFI_EVENT Event,
|
|
||||||
IN VOID *Context
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Check key buffer to get the key stroke status.
|
|
||||||
|
|
||||||
@param This Pointer of the protocol EFI_SIMPLE_TEXT_IN_PROTOCOL.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS A key is being pressed now.
|
|
||||||
@retval Other No key is now pressed.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
BiosKeyboardCheckForKey (
|
|
||||||
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Convert unicode combined with scan code of key to the counterpart of EFIScancode of it.
|
|
||||||
|
|
||||||
@param KeyChar Unicode of key.
|
|
||||||
@param ScanCode Scan code of key.
|
|
||||||
|
|
||||||
@return The value of EFI Scancode for the key.
|
|
||||||
@retval SCAN_NULL No corresponding value in the EFI convert table is found for the key.
|
|
||||||
|
|
||||||
**/
|
|
||||||
UINT16
|
|
||||||
ConvertToEFIScanCode (
|
|
||||||
IN CHAR16 KeyChar,
|
|
||||||
IN UINT16 ScanCode
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
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 BiosKeyboardPrivate Keyboard Private Data Struture
|
|
||||||
|
|
||||||
@retval TRUE Keyboard in System.
|
|
||||||
@retval FALSE Keyboard not in System.
|
|
||||||
|
|
||||||
**/
|
|
||||||
BOOLEAN
|
|
||||||
CheckKeyboardConnect (
|
|
||||||
IN BIOS_KEYBOARD_DEV *BiosKeyboardPrivate
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Timer event handler: read a series of key stroke from 8042
|
|
||||||
and put them into memory key buffer.
|
|
||||||
It is registered as running under TPL_NOTIFY
|
|
||||||
|
|
||||||
@param Event The timer event
|
|
||||||
@param Context A BIOS_KEYBOARD_DEV pointer
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
EFIAPI
|
|
||||||
BiosKeyboardTimerHandler (
|
|
||||||
IN EFI_EVENT Event,
|
|
||||||
IN VOID *Context
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
BiosKeyboardResetEx (
|
|
||||||
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
|
|
||||||
BiosKeyboardReadKeyStrokeEx (
|
|
||||||
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
|
|
||||||
BiosKeyboardSetState (
|
|
||||||
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. If KeyData.Key,
|
|
||||||
KeyData.KeyState.KeyToggleState and KeyData.KeyState.KeyShiftState
|
|
||||||
are 0, then any incomplete keystroke will trigger a notification of
|
|
||||||
the KeyNotificationFunction.
|
|
||||||
@param KeyNotificationFunction Points to the function to be called when the key
|
|
||||||
sequence is typed specified by KeyData. This notification function
|
|
||||||
should be called at <=TPL_CALLBACK.
|
|
||||||
@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
|
|
||||||
BiosKeyboardRegisterKeyNotify (
|
|
||||||
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.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
EFIAPI
|
|
||||||
BiosKeyboardUnregisterKeyNotify (
|
|
||||||
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
|
|
||||||
IN VOID *NotificationHandle
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Wait for a specific value to be presented in
|
|
||||||
Data register of Keyboard Controller by keyboard and then read it,
|
|
||||||
used in keyboard commands ack
|
|
||||||
|
|
||||||
@param BiosKeyboardPrivate Keyboard instance pointer.
|
|
||||||
@param Value The value to be waited for
|
|
||||||
@param WaitForValueTimeOut The limit of microseconds for timeout
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The command byte is written successfully.
|
|
||||||
@retval EFI_TIMEOUT Timeout occurred during writing.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
KeyboardWaitForValue (
|
|
||||||
IN BIOS_KEYBOARD_DEV *BiosKeyboardPrivate,
|
|
||||||
IN UINT8 Value,
|
|
||||||
IN UINTN WaitForValueTimeOut
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Write data byte to input buffer or input/output ports of Keyboard Controller with delay and waiting for buffer-empty state.
|
|
||||||
|
|
||||||
@param BiosKeyboardPrivate Keyboard instance pointer.
|
|
||||||
@param Data Data byte to write.
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS The data byte is written successfully.
|
|
||||||
@retval EFI_TIMEOUT Timeout occurred during writing.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
KeyboardWrite (
|
|
||||||
IN BIOS_KEYBOARD_DEV *BiosKeyboardPrivate,
|
|
||||||
IN UINT8 Data
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Free keyboard notify list.
|
|
||||||
|
|
||||||
@param ListHead The list head
|
|
||||||
|
|
||||||
@retval EFI_SUCCESS Free the notify list successfully
|
|
||||||
@retval EFI_INVALID_PARAMETER ListHead is invalid.
|
|
||||||
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
BiosKeyboardFreeNotifyList (
|
|
||||||
IN OUT LIST_ENTRY *ListHead
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Check if key is registered.
|
|
||||||
|
|
||||||
@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
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Waiting on the keyboard event, if there's any key pressed by the user, signal the event
|
|
||||||
|
|
||||||
@param Event The event that be siganlled when any key has been stroked.
|
|
||||||
@param Context Pointer of the protocol EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
|
||||||
EFIAPI
|
|
||||||
BiosKeyboardWaitForKeyEx (
|
|
||||||
IN EFI_EVENT Event,
|
|
||||||
IN VOID *Context
|
|
||||||
);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,176 +0,0 @@
|
|||||||
/** @file
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#include "BiosKeyboard.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// EFI Component Name Protocol
|
|
||||||
//
|
|
||||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gBiosKeyboardComponentName = {
|
|
||||||
BiosKeyboardComponentNameGetDriverName,
|
|
||||||
BiosKeyboardComponentNameGetControllerName,
|
|
||||||
"eng"
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// EFI Component Name 2 Protocol
|
|
||||||
//
|
|
||||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gBiosKeyboardComponentName2 = {
|
|
||||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) BiosKeyboardComponentNameGetDriverName,
|
|
||||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) BiosKeyboardComponentNameGetControllerName,
|
|
||||||
"en"
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mBiosKeyboardDriverNameTable[] = {
|
|
||||||
{
|
|
||||||
"eng;en",
|
|
||||||
L"BIOS[INT16] 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
|
|
||||||
BiosKeyboardComponentNameGetDriverName (
|
|
||||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
|
||||||
IN CHAR8 *Language,
|
|
||||||
OUT CHAR16 **DriverName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return LookupUnicodeString2 (
|
|
||||||
Language,
|
|
||||||
This->SupportedLanguages,
|
|
||||||
mBiosKeyboardDriverNameTable,
|
|
||||||
DriverName,
|
|
||||||
(BOOLEAN)(This == &gBiosKeyboardComponentName)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
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
|
|
||||||
BiosKeyboardComponentNameGetControllerName (
|
|
||||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE ControllerHandle,
|
|
||||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
|
||||||
IN CHAR8 *Language,
|
|
||||||
OUT CHAR16 **ControllerName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return EFI_UNSUPPORTED;
|
|
||||||
}
|
|
@ -1,146 +0,0 @@
|
|||||||
/** @file
|
|
||||||
|
|
||||||
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef _BIOS_KEYBOARD_COMPONENT_NAME_H_
|
|
||||||
#define _BIOS_KEYBOARD_COMPONENT_NAME_H_
|
|
||||||
|
|
||||||
|
|
||||||
extern EFI_COMPONENT_NAME_PROTOCOL gBiosKeyboardComponentName;
|
|
||||||
extern EFI_COMPONENT_NAME2_PROTOCOL gBiosKeyboardComponentName2;
|
|
||||||
|
|
||||||
//
|
|
||||||
// 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
|
|
||||||
BiosKeyboardComponentNameGetDriverName (
|
|
||||||
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
|
|
||||||
BiosKeyboardComponentNameGetControllerName (
|
|
||||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
|
||||||
IN EFI_HANDLE ControllerHandle,
|
|
||||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
|
||||||
IN CHAR8 *Language,
|
|
||||||
OUT CHAR16 **ControllerName
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,72 +0,0 @@
|
|||||||
## @file
|
|
||||||
# Ps2 Keyboard driver.
|
|
||||||
#
|
|
||||||
# Ps2 Keyboard driver by using Legacy Bios protocol service and IsaIo protocol
|
|
||||||
# service. This dirver uses legacy INT16 to get the key stroke status.
|
|
||||||
#
|
|
||||||
# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
#
|
|
||||||
##
|
|
||||||
|
|
||||||
[Defines]
|
|
||||||
INF_VERSION = 0x00010005
|
|
||||||
BASE_NAME = KeyboardDxe
|
|
||||||
MODULE_UNI_FILE = KeyboardDxe.uni
|
|
||||||
FILE_GUID = 5479662B-6AE4-49e8-A6BD-6DE4B625811F
|
|
||||||
MODULE_TYPE = UEFI_DRIVER
|
|
||||||
VERSION_STRING = 1.0
|
|
||||||
|
|
||||||
ENTRY_POINT = InitializeBiosKeyboard
|
|
||||||
|
|
||||||
#
|
|
||||||
# The following information is for reference only and not required by the build tools.
|
|
||||||
#
|
|
||||||
# VALID_ARCHITECTURES = IA32 X64 EBC
|
|
||||||
#
|
|
||||||
# DRIVER_BINDING = gBiosKeyboardDriverBinding
|
|
||||||
# COMPONENT_NAME = gBiosKeyboardComponentName
|
|
||||||
#
|
|
||||||
|
|
||||||
[Sources]
|
|
||||||
ComponentName.c
|
|
||||||
ComponentName.h
|
|
||||||
BiosKeyboard.c
|
|
||||||
BiosKeyboard.h
|
|
||||||
|
|
||||||
|
|
||||||
[Packages]
|
|
||||||
MdePkg/MdePkg.dec
|
|
||||||
MdeModulePkg/MdeModulePkg.dec
|
|
||||||
IntelFrameworkPkg/IntelFrameworkPkg.dec
|
|
||||||
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
|
|
||||||
|
|
||||||
|
|
||||||
[LibraryClasses]
|
|
||||||
MemoryAllocationLib
|
|
||||||
UefiBootServicesTableLib
|
|
||||||
UefiDriverEntryPoint
|
|
||||||
ReportStatusCodeLib
|
|
||||||
BaseMemoryLib
|
|
||||||
UefiLib
|
|
||||||
DebugLib
|
|
||||||
BaseLib
|
|
||||||
PcdLib
|
|
||||||
DxeServicesTableLib
|
|
||||||
|
|
||||||
[Protocols]
|
|
||||||
gEfiIsaIoProtocolGuid ## TO_START
|
|
||||||
gEfiSimpleTextInProtocolGuid ## BY_START
|
|
||||||
gEfiSimpleTextInputExProtocolGuid ## BY_START
|
|
||||||
gEfiLegacyBiosProtocolGuid ## CONSUMES
|
|
||||||
gEfiPs2PolicyProtocolGuid ## SOMETIMES_CONSUMES
|
|
||||||
|
|
||||||
[FeaturePcd]
|
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdPs2KbdExtendedVerification|FALSE ## CONSUMES
|
|
||||||
|
|
||||||
[Pcd]
|
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFastPS2Detection ## SOMETIMES_CONSUMES
|
|
||||||
|
|
||||||
[UserExtensions.TianoCore."ExtraFiles"]
|
|
||||||
KeyboardDxeExtra.uni
|
|
@ -1,17 +0,0 @@
|
|||||||
// /** @file
|
|
||||||
// Ps2 Keyboard driver.
|
|
||||||
//
|
|
||||||
// Ps2 Keyboard driver by using Legacy Bios protocol service and IsaIo protocol
|
|
||||||
// service. This dirver uses legacy INT16 to get the key stroke status.
|
|
||||||
//
|
|
||||||
// Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
//
|
|
||||||
// **/
|
|
||||||
|
|
||||||
|
|
||||||
#string STR_MODULE_ABSTRACT #language en-US "Ps2 Keyboard Driver"
|
|
||||||
|
|
||||||
#string STR_MODULE_DESCRIPTION #language en-US "Ps2 Keyboard driver by using Legacy Bios protocol service and IsaIo protocol service. This driver uses legacy INT16 to get the key stroke status."
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
|||||||
// /** @file
|
|
||||||
// KeyboardDxe Localized Strings and Content
|
|
||||||
//
|
|
||||||
// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
//
|
|
||||||
// **/
|
|
||||||
|
|
||||||
#string STR_PROPERTIES_MODULE_NAME
|
|
||||||
#language en-US
|
|
||||||
"Legacy Keyboard DXE Driver"
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user