MSM8916Pkg: implement more libreries and drivers
Added MemoryPeiLib, PlatformPeiLib, PlatformBootManagerLib, KeypadDxe, GenericKeypadDeviceDxe. Signed-off-by: Ivaylo Ivanov <ivo.ivanov@null.net> Cc: fxsheep <sunxiaoyang2003@gmail.com>
This commit is contained in:
parent
e442368895
commit
7e44ba1051
@ -323,5 +323,5 @@
|
||||
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultReceiveFifoDepth|32
|
||||
|
||||
[PcdsDynamicHii.common.DEFAULT]
|
||||
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|L"Timeout"|gEfiGlobalVariableGuid|0x0|0 # Variable: L"Timeout"
|
||||
#gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|L"Timeout"|gEfiGlobalVariableGuid|0x0|0 # Variable: L"Timeout"
|
||||
|
||||
|
@ -0,0 +1,56 @@
|
||||
#include <PiDxe.h>
|
||||
#include <Protocol/KeypadDevice.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/KeypadDeviceImplLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
|
||||
typedef struct {
|
||||
VENDOR_DEVICE_PATH Keypad;
|
||||
EFI_DEVICE_PATH End;
|
||||
} KEYPAD_DEVICE_PATH;
|
||||
|
||||
KEYPAD_DEVICE_PATH mInternalDevicePath = {
|
||||
{
|
||||
{
|
||||
HARDWARE_DEVICE_PATH,
|
||||
HW_VENDOR_DP,
|
||||
{
|
||||
(UINT8)(sizeof(VENDOR_DEVICE_PATH)),
|
||||
(UINT8)((sizeof(VENDOR_DEVICE_PATH)) >> 8),
|
||||
},
|
||||
},
|
||||
EFI_CALLER_ID_GUID,
|
||||
},
|
||||
{
|
||||
END_DEVICE_PATH_TYPE,
|
||||
END_ENTIRE_DEVICE_PATH_SUBTYPE,
|
||||
{ sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 }
|
||||
}
|
||||
};
|
||||
|
||||
STATIC KEYPAD_DEVICE_PROTOCOL mInternalKeypadDevice = {
|
||||
KeypadDeviceImplReset,
|
||||
KeypadDeviceImplGetKeys,
|
||||
};
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
KeypadDeviceDxeInitialize (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = gBS->InstallMultipleProtocolInterfaces(
|
||||
&ImageHandle,
|
||||
&gEFIDroidKeypadDeviceProtocolGuid,
|
||||
&mInternalKeypadDevice,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
&mInternalDevicePath,
|
||||
NULL
|
||||
);
|
||||
ASSERT_EFI_ERROR(Status);
|
||||
|
||||
return Status;
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = GenericKeypadDeviceDxe
|
||||
FILE_GUID = 39A24CF8-411E-48EB-8BEA-3ED07327F400
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
|
||||
ENTRY_POINT = KeypadDeviceDxeInitialize
|
||||
|
||||
[Sources.common]
|
||||
GenericKeypadDevice.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
ArmPkg/ArmPkg.dec
|
||||
EmbeddedPkg/EmbeddedPkg.dec
|
||||
MSM8916Pkg/MSM8916Pkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
UefiDriverEntryPoint
|
||||
MemoryAllocationLib
|
||||
KeypadDeviceImplLib
|
||||
|
||||
[Protocols]
|
||||
gEFIDroidKeypadDeviceProtocolGuid
|
||||
gEfiDevicePathProtocolGuid
|
||||
|
||||
[Depex]
|
||||
TRUE
|
352
MSM8916Pkg/Drivers/KeypadDxe/ComponentName.c
Normal file
352
MSM8916Pkg/Drivers/KeypadDxe/ComponentName.c
Normal file
@ -0,0 +1,352 @@
|
||||
/** @file
|
||||
Routines related Component Name protocol.
|
||||
|
||||
Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include "Keypad.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
|
||||
KeypadComponentNameGetDriverName (
|
||||
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
|
||||
KeypadComponentNameGetControllerName (
|
||||
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 gKeypadComponentName = {
|
||||
KeypadComponentNameGetDriverName,
|
||||
KeypadComponentNameGetControllerName,
|
||||
"eng"
|
||||
};
|
||||
|
||||
//
|
||||
// EFI Component Name 2 Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gKeypadComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) KeypadComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) KeypadComponentNameGetControllerName,
|
||||
"en"
|
||||
};
|
||||
|
||||
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mKeypadDriverNameTable[] = {
|
||||
{
|
||||
"eng;en",
|
||||
L"Keypad 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
|
||||
KeypadComponentNameGetDriverName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **DriverName
|
||||
)
|
||||
{
|
||||
return LookupUnicodeString2 (
|
||||
Language,
|
||||
This->SupportedLanguages,
|
||||
mKeypadDriverNameTable,
|
||||
DriverName,
|
||||
(BOOLEAN)(This == &gKeypadComponentName)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
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
|
||||
KeypadComponentNameGetControllerName (
|
||||
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;
|
||||
KEYPAD_CONSOLE_IN_DEV *ConsoleIn;
|
||||
//
|
||||
// This is a device driver, so ChildHandle must be NULL.
|
||||
//
|
||||
if (ChildHandle != NULL) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Controller's handle
|
||||
//
|
||||
Status = EfiTestManagedDevice (ControllerHandle, gKeypadControllerDriver.DriverBindingHandle, &gEFIDroidKeypadDeviceProtocolGuid);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
//
|
||||
// Get the device context
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiSimpleTextInProtocolGuid,
|
||||
(VOID **) &ConIn,
|
||||
gKeypadControllerDriver.DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
ConsoleIn = KEYPAD_CONSOLE_IN_DEV_FROM_THIS (ConIn);
|
||||
|
||||
return LookupUnicodeString2 (
|
||||
Language,
|
||||
This->SupportedLanguages,
|
||||
ConsoleIn->ControllerNameTable,
|
||||
ControllerName,
|
||||
(BOOLEAN)(This == &gKeypadComponentName)
|
||||
);
|
||||
}
|
583
MSM8916Pkg/Drivers/KeypadDxe/Keypad.c
Normal file
583
MSM8916Pkg/Drivers/KeypadDxe/Keypad.c
Normal file
@ -0,0 +1,583 @@
|
||||
/** @file
|
||||
|
||||
Keypad driver. Routines that interacts with callers,
|
||||
conforming to EFI driver model
|
||||
|
||||
Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include "Keypad.h"
|
||||
#include <Configuration/BootDevices.h>
|
||||
|
||||
//
|
||||
// Function prototypes
|
||||
//
|
||||
/**
|
||||
Test controller is a keypad 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
|
||||
KeypadControllerDriverSupported (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE Controller,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||
);
|
||||
|
||||
/**
|
||||
Create KEYPAD_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
|
||||
KeypadControllerDriverStart (
|
||||
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
|
||||
KeypadControllerDriverStop (
|
||||
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 gKeypadControllerDriver = {
|
||||
KeypadControllerDriverSupported,
|
||||
KeypadControllerDriverStart,
|
||||
KeypadControllerDriverStop,
|
||||
0xa,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
/**
|
||||
Test controller is a keypad 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
|
||||
KeypadControllerDriverSupported (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE Controller,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
KEYPAD_DEVICE_PROTOCOL *KeypadDevice;
|
||||
|
||||
//
|
||||
// Open the IO Abstraction(s) needed to perform the supported test
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEFIDroidKeypadDeviceProtocolGuid,
|
||||
(VOID **) &KeypadDevice,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Close the I/O Abstraction(s) used to perform the supported test
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
Controller,
|
||||
&gEFIDroidKeypadDeviceProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
Controller
|
||||
);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
EFIAPI
|
||||
KeypadReturnApiPushEfikeyBufTail (
|
||||
KEYPAD_RETURN_API *This,
|
||||
EFI_KEY_DATA *KeyData
|
||||
)
|
||||
{
|
||||
KEYPAD_CONSOLE_IN_DEV *ConsoleIn;
|
||||
LIST_ENTRY *Link;
|
||||
KEYPAD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
|
||||
|
||||
ConsoleIn = KEYPAD_CONSOLE_IN_DEV_FROM_KEYPAD_RETURN_API (This);
|
||||
|
||||
//
|
||||
// If the key can not be converted then just return.
|
||||
//
|
||||
if (KeyData->Key.ScanCode == SCAN_NULL && KeyData->Key.UnicodeChar == CHAR_NULL) {
|
||||
if (!ConsoleIn->IsSupportPartialKey) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Signal KeyNotify process event if this key pressed matches any key registered.
|
||||
//
|
||||
for (Link = GetFirstNode (&ConsoleIn->NotifyList); !IsNull (&ConsoleIn->NotifyList, Link); Link = GetNextNode (&ConsoleIn->NotifyList, Link)) {
|
||||
CurrentNotify = CR (
|
||||
Link,
|
||||
KEYPAD_CONSOLE_IN_EX_NOTIFY,
|
||||
NotifyEntry,
|
||||
KEYPAD_CONSOLE_IN_EX_NOTIFY_SIGNATURE
|
||||
);
|
||||
if (IsKeyRegistered (&CurrentNotify->KeyData, KeyData)) {
|
||||
//
|
||||
// The key notification function needs to run at TPL_CALLBACK
|
||||
// while current TPL is TPL_NOTIFY. It will be invoked in
|
||||
// KeyNotifyProcessHandler() which runs at TPL_CALLBACK.
|
||||
//
|
||||
PushEfikeyBufTail (&ConsoleIn->EfiKeyQueueForNotify, KeyData);
|
||||
gBS->SignalEvent (ConsoleIn->KeyNotifyProcessEvent);
|
||||
}
|
||||
}
|
||||
|
||||
PushEfikeyBufTail (&ConsoleIn->EfiKeyQueue, KeyData);
|
||||
}
|
||||
|
||||
/**
|
||||
Create KEYPAD_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
|
||||
KeypadControllerDriverStart (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE Controller,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
KEYPAD_DEVICE_PROTOCOL *KeypadDevice;
|
||||
KEYPAD_CONSOLE_IN_DEV *ConsoleIn;
|
||||
|
||||
//
|
||||
// Get the ISA I/O Protocol on Controller's handle
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEFIDroidKeypadDeviceProtocolGuid,
|
||||
(VOID **) &KeypadDevice,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
//
|
||||
// Allocate private data
|
||||
//
|
||||
ConsoleIn = AllocateZeroPool (sizeof (KEYPAD_CONSOLE_IN_DEV));
|
||||
if (ConsoleIn == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ErrorExit;
|
||||
}
|
||||
//
|
||||
// Setup the device instance
|
||||
//
|
||||
ConsoleIn->Signature = KEYPAD_CONSOLE_IN_DEV_SIGNATURE;
|
||||
ConsoleIn->Handle = Controller;
|
||||
(ConsoleIn->ConIn).Reset = KeypadEfiReset;
|
||||
(ConsoleIn->ConIn).ReadKeyStroke = KeypadReadKeyStroke;
|
||||
ConsoleIn->KeypadDevice = KeypadDevice;
|
||||
ConsoleIn->KeypadReturnApi.PushEfikeyBufTail = KeypadReturnApiPushEfikeyBufTail;
|
||||
ConsoleIn->Last = (UINT64)-1;
|
||||
|
||||
ConsoleIn->ConInEx.Reset = KeypadEfiResetEx;
|
||||
ConsoleIn->ConInEx.ReadKeyStrokeEx = KeypadReadKeyStrokeEx;
|
||||
ConsoleIn->ConInEx.SetState = KeypadSetState;
|
||||
ConsoleIn->ConInEx.RegisterKeyNotify = KeypadRegisterKeyNotify;
|
||||
ConsoleIn->ConInEx.UnregisterKeyNotify = KeypadUnregisterKeyNotify;
|
||||
|
||||
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,
|
||||
// KeypadRead 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.
|
||||
//
|
||||
|
||||
//
|
||||
// Setup the WaitForKey event
|
||||
//
|
||||
Status = gBS->CreateEvent (
|
||||
EVT_NOTIFY_WAIT,
|
||||
TPL_NOTIFY,
|
||||
KeypadWaitForKey,
|
||||
ConsoleIn,
|
||||
&((ConsoleIn->ConIn).WaitForKey)
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ErrorExit;
|
||||
}
|
||||
//
|
||||
// Setup the WaitForKeyEx event
|
||||
//
|
||||
Status = gBS->CreateEvent (
|
||||
EVT_NOTIFY_WAIT,
|
||||
TPL_NOTIFY,
|
||||
KeypadWaitForKeyEx,
|
||||
ConsoleIn,
|
||||
&(ConsoleIn->ConInEx.WaitForKeyEx)
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ErrorExit;
|
||||
}
|
||||
// Setup a periodic timer, used for reading keystrokes at a fixed interval
|
||||
//
|
||||
Status = gBS->CreateEvent (
|
||||
EVT_TIMER | EVT_NOTIFY_SIGNAL,
|
||||
TPL_NOTIFY,
|
||||
KeypadTimerHandler,
|
||||
ConsoleIn,
|
||||
&ConsoleIn->TimerEvent
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ErrorExit;
|
||||
}
|
||||
|
||||
Status = gBS->SetTimer (
|
||||
ConsoleIn->TimerEvent,
|
||||
TimerPeriodic,
|
||||
KEYPAD_TIMER_INTERVAL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ErrorExit;
|
||||
}
|
||||
|
||||
Status = gBS->CreateEvent (
|
||||
EVT_NOTIFY_SIGNAL,
|
||||
TPL_CALLBACK,
|
||||
KeyNotifyProcessHandler,
|
||||
ConsoleIn,
|
||||
&ConsoleIn->KeyNotifyProcessEvent
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ErrorExit;
|
||||
}
|
||||
|
||||
//
|
||||
// Reset the keypad device
|
||||
//
|
||||
Status = ConsoleIn->ConInEx.Reset (&ConsoleIn->ConInEx, FALSE);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto ErrorExit;
|
||||
}
|
||||
|
||||
ConsoleIn->ControllerNameTable = NULL;
|
||||
AddUnicodeString2 (
|
||||
"eng",
|
||||
gKeypadComponentName.SupportedLanguages,
|
||||
&ConsoleIn->ControllerNameTable,
|
||||
L"Keypad Device",
|
||||
TRUE
|
||||
);
|
||||
AddUnicodeString2 (
|
||||
"en",
|
||||
gKeypadComponentName2.SupportedLanguages,
|
||||
&ConsoleIn->ControllerNameTable,
|
||||
L"Keypad Device",
|
||||
FALSE
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// Install protocol interfaces for the keypad device.
|
||||
//
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&Controller,
|
||||
&gEfiSimpleTextInProtocolGuid,
|
||||
&ConsoleIn->ConIn,
|
||||
&gEfiSimpleTextInputExProtocolGuid,
|
||||
&ConsoleIn->ConInEx,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ErrorExit;
|
||||
}
|
||||
|
||||
return Status;
|
||||
|
||||
ErrorExit:
|
||||
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);
|
||||
}
|
||||
|
||||
if (ConsoleIn != NULL) {
|
||||
gBS->FreePool (ConsoleIn);
|
||||
}
|
||||
|
||||
gBS->CloseProtocol (
|
||||
Controller,
|
||||
&gEFIDroidKeypadDeviceProtocolGuid,
|
||||
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
|
||||
KeypadControllerDriverStop (
|
||||
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;
|
||||
KEYPAD_CONSOLE_IN_DEV *ConsoleIn;
|
||||
|
||||
//
|
||||
// Disable Keypad
|
||||
//
|
||||
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 = KEYPAD_CONSOLE_IN_DEV_FROM_THIS (ConIn);
|
||||
|
||||
if (ConsoleIn->TimerEvent != NULL) {
|
||||
gBS->CloseEvent (ConsoleIn->TimerEvent);
|
||||
ConsoleIn->TimerEvent = NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// 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,
|
||||
&gEFIDroidKeypadDeviceProtocolGuid,
|
||||
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
|
||||
)
|
||||
{
|
||||
KEYPAD_CONSOLE_IN_EX_NOTIFY *NotifyNode;
|
||||
|
||||
if (ListHead == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
while (!IsListEmpty (ListHead)) {
|
||||
NotifyNode = CR (
|
||||
ListHead->ForwardLink,
|
||||
KEYPAD_CONSOLE_IN_EX_NOTIFY,
|
||||
NotifyEntry,
|
||||
KEYPAD_CONSOLE_IN_EX_NOTIFY_SIGNATURE
|
||||
);
|
||||
RemoveEntryList (ListHead->ForwardLink);
|
||||
gBS->FreePool (NotifyNode);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
The module Entry Point for module Keypad.
|
||||
|
||||
@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
|
||||
InitializeKeypad(
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Install driver model protocol(s).
|
||||
//
|
||||
Status = EfiLibInstallDriverBindingComponentName2 (
|
||||
ImageHandle,
|
||||
SystemTable,
|
||||
&gKeypadControllerDriver,
|
||||
ImageHandle,
|
||||
&gKeypadComponentName,
|
||||
&gKeypadComponentName2
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
402
MSM8916Pkg/Drivers/KeypadDxe/Keypad.h
Normal file
402
MSM8916Pkg/Drivers/KeypadDxe/Keypad.h
Normal file
@ -0,0 +1,402 @@
|
||||
/** @file
|
||||
Keypad driver header file
|
||||
|
||||
Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _KEYPAD_H_
|
||||
#define _KEYPAD_H_
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
#include <Protocol/SimpleTextIn.h>
|
||||
#include <Protocol/SimpleTextInEx.h>
|
||||
#include <Protocol/KeypadDevice.h>
|
||||
|
||||
#include <Library/IoLib.h>
|
||||
#include <Library/UefiDriverEntryPoint.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.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 gKeypadControllerDriver;
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL gKeypadComponentName;
|
||||
extern EFI_COMPONENT_NAME2_PROTOCOL gKeypadComponentName2;
|
||||
|
||||
//
|
||||
// Driver Private Data
|
||||
//
|
||||
#define KEYPAD_CONSOLE_IN_DEV_SIGNATURE SIGNATURE_32 ('k', 'k', 'e', 'y')
|
||||
#define KEYPAD_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('k', 'c', 'e', 'n')
|
||||
|
||||
typedef struct _KEYPAD_CONSOLE_IN_EX_NOTIFY {
|
||||
UINTN Signature;
|
||||
EFI_KEY_DATA KeyData;
|
||||
EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;
|
||||
LIST_ENTRY NotifyEntry;
|
||||
} KEYPAD_CONSOLE_IN_EX_NOTIFY;
|
||||
|
||||
#define KEYPAD_EFI_KEY_MAX_COUNT 256
|
||||
typedef struct {
|
||||
EFI_KEY_DATA Buffer[KEYPAD_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_EVENT TimerEvent;
|
||||
|
||||
KEYPAD_DEVICE_PROTOCOL *KeypadDevice;
|
||||
KEYPAD_RETURN_API KeypadReturnApi;
|
||||
|
||||
// counter value of the last poll
|
||||
UINT64 Last;
|
||||
|
||||
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
|
||||
//
|
||||
EFI_KEY_QUEUE EfiKeyQueue;
|
||||
EFI_KEY_QUEUE EfiKeyQueueForNotify;
|
||||
|
||||
//
|
||||
// Error state
|
||||
//
|
||||
BOOLEAN KeypadErr;
|
||||
|
||||
EFI_UNICODE_STRING_TABLE *ControllerNameTable;
|
||||
|
||||
//
|
||||
// Notification Function List
|
||||
//
|
||||
LIST_ENTRY NotifyList;
|
||||
EFI_EVENT KeyNotifyProcessEvent;
|
||||
} KEYPAD_CONSOLE_IN_DEV;
|
||||
|
||||
#define KEYPAD_CONSOLE_IN_DEV_FROM_KEYPAD_RETURN_API(a) CR (a, KEYPAD_CONSOLE_IN_DEV, KeypadReturnApi, KEYPAD_CONSOLE_IN_DEV_SIGNATURE)
|
||||
#define KEYPAD_CONSOLE_IN_DEV_FROM_THIS(a) CR (a, KEYPAD_CONSOLE_IN_DEV, ConIn, KEYPAD_CONSOLE_IN_DEV_SIGNATURE)
|
||||
#define TEXT_INPUT_EX_KEYPAD_CONSOLE_IN_DEV_FROM_THIS(a) \
|
||||
CR (a, \
|
||||
KEYPAD_CONSOLE_IN_DEV, \
|
||||
ConInEx, \
|
||||
KEYPAD_CONSOLE_IN_DEV_SIGNATURE \
|
||||
)
|
||||
|
||||
#define TABLE_END 0x0
|
||||
|
||||
#define KEYPAD_TIMER_INTERVAL 200000 // 0.02s
|
||||
|
||||
//
|
||||
// Driver entry point
|
||||
//
|
||||
/**
|
||||
The user Entry Point for module KeypadDxe. 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
|
||||
InstallKeypadDriver (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
);
|
||||
|
||||
//
|
||||
// Other functions that are used among .c files
|
||||
//
|
||||
|
||||
/**
|
||||
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 keypad Initialization.
|
||||
If ExtendedVerification is TRUE, do additional test for
|
||||
the keypad interface
|
||||
|
||||
@param ConsoleIn - KEYPAD_CONSOLE_IN_DEV instance pointer
|
||||
@param ExtendedVerification - indicates a thorough initialization
|
||||
|
||||
@retval EFI_DEVICE_ERROR Fail to init keypad
|
||||
@retval EFI_SUCCESS Success to init keypad
|
||||
**/
|
||||
EFI_STATUS
|
||||
InitKeypad (
|
||||
IN OUT KEYPAD_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 keypad buffer.
|
||||
It is registered as running under TPL_NOTIFY
|
||||
|
||||
@param Event - The timer event
|
||||
@param Context - A KEYPAD_CONSOLE_IN_DEV pointer
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
KeypadTimerHandler (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
logic reset keypad
|
||||
Implement SIMPLE_TEXT_IN.Reset()
|
||||
Perform 8042 controller and keypad 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
|
||||
KeypadEfiReset (
|
||||
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
|
||||
KeypadReadKeyStroke (
|
||||
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
|
||||
KeypadWaitForKey (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
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
|
||||
KeypadWaitForKeyEx (
|
||||
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
|
||||
KeypadEfiResetEx (
|
||||
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
|
||||
KeypadReadKeyStrokeEx (
|
||||
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
|
||||
KeypadSetState (
|
||||
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
|
||||
IN EFI_KEY_TOGGLE_STATE *KeyToggleState
|
||||
);
|
||||
|
||||
/**
|
||||
Register a notification function for a particular keystroke for the input device.
|
||||
|
||||
@param This - Protocol instance pointer.
|
||||
@param KeyData - A pointer to a buffer that is filled in with the keystroke
|
||||
information data for the key that was pressed.
|
||||
@param KeyNotificationFunction - Points to the function to be called when the key
|
||||
sequence is typed specified by KeyData.
|
||||
@param NotifyHandle - Points to the unique handle assigned to the registered notification.
|
||||
|
||||
@retval EFI_SUCCESS - The notification function was registered successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES - Unable to allocate resources for necesssary data structures.
|
||||
@retval EFI_INVALID_PARAMETER - KeyData or NotifyHandle is NULL.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
KeypadRegisterKeyNotify (
|
||||
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
|
||||
KeypadUnregisterKeyNotify (
|
||||
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
|
||||
IN VOID *NotificationHandle
|
||||
);
|
||||
|
||||
/**
|
||||
Push one key data to the EFI key buffer.
|
||||
|
||||
@param Queue Pointer to instance of EFI_KEY_QUEUE.
|
||||
@param KeyData The key data to push.
|
||||
**/
|
||||
VOID
|
||||
PushEfikeyBufTail (
|
||||
IN EFI_KEY_QUEUE *Queue,
|
||||
IN EFI_KEY_DATA *KeyData
|
||||
);
|
||||
|
||||
/**
|
||||
Judge whether is a registed key
|
||||
|
||||
@param RegsiteredData A pointer to a buffer that is filled in with the keystroke
|
||||
state data for the key that was registered.
|
||||
@param InputData A pointer to a buffer that is filled in with the keystroke
|
||||
state data for the key that was pressed.
|
||||
|
||||
@retval TRUE Key be pressed matches a registered key.
|
||||
@retval FLASE Match failed.
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
IsKeyRegistered (
|
||||
IN EFI_KEY_DATA *RegsiteredData,
|
||||
IN EFI_KEY_DATA *InputData
|
||||
);
|
||||
|
||||
#endif
|
138
MSM8916Pkg/Drivers/KeypadDxe/KeypadController.c
Normal file
138
MSM8916Pkg/Drivers/KeypadDxe/KeypadController.c
Normal file
@ -0,0 +1,138 @@
|
||||
/** @file
|
||||
Routines that talk to the KeypadDevice protocol
|
||||
|
||||
Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include "Keypad.h"
|
||||
|
||||
/**
|
||||
Display error message.
|
||||
|
||||
@param ConsoleIn Pointer to instance of KEYPAD_CONSOLE_IN_DEV
|
||||
@param ErrMsg Unicode string of error message
|
||||
|
||||
**/
|
||||
VOID
|
||||
KeypadError (
|
||||
IN KEYPAD_CONSOLE_IN_DEV *ConsoleIn,
|
||||
IN CHAR16 *ErrMsg
|
||||
)
|
||||
{
|
||||
ConsoleIn->KeypadErr = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
Timer event handler: read a series of scancodes from 8042
|
||||
and put them into memory scancode buffer.
|
||||
it read as much scancodes to either fill
|
||||
the memory buffer or empty the keypad buffer.
|
||||
It is registered as running under TPL_NOTIFY
|
||||
|
||||
@param Event The timer event
|
||||
@param Context A KEYPAD_CONSOLE_IN_DEV pointer
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
KeypadTimerHandler (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
|
||||
{
|
||||
EFI_TPL OldTpl;
|
||||
KEYPAD_CONSOLE_IN_DEV *ConsoleIn;
|
||||
|
||||
ConsoleIn = (KEYPAD_CONSOLE_IN_DEV *) Context;
|
||||
|
||||
//
|
||||
// Enter critical section
|
||||
//
|
||||
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
|
||||
|
||||
if (((KEYPAD_CONSOLE_IN_DEV *) Context)->KeypadErr) {
|
||||
//
|
||||
// Leave critical section and return
|
||||
//
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
return ;
|
||||
}
|
||||
|
||||
UINT64 CurrentCounterValue = GetPerformanceCounter();
|
||||
UINT64 DeltaCounter = CurrentCounterValue - ConsoleIn->Last;
|
||||
ConsoleIn->Last = CurrentCounterValue;
|
||||
|
||||
ConsoleIn->KeypadDevice->GetKeys(ConsoleIn->KeypadDevice, &ConsoleIn->KeypadReturnApi, GetTimeInNanoSecond(DeltaCounter));
|
||||
|
||||
//
|
||||
// Leave critical section and return
|
||||
//
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
}
|
||||
|
||||
/**
|
||||
Perform 8042 controller and keypad Initialization.
|
||||
If ExtendedVerification is TRUE, do additional test for
|
||||
the keypad interface
|
||||
|
||||
@param ConsoleIn - KEYPAD_CONSOLE_IN_DEV instance pointer
|
||||
@param ExtendedVerification - indicates a thorough initialization
|
||||
|
||||
@retval EFI_DEVICE_ERROR Fail to init keypad
|
||||
@retval EFI_SUCCESS Success to init keypad
|
||||
**/
|
||||
EFI_STATUS
|
||||
InitKeypad (
|
||||
IN OUT KEYPAD_CONSOLE_IN_DEV *ConsoleIn,
|
||||
IN BOOLEAN ExtendedVerification
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
ConsoleIn->KeypadDevice->Reset(ConsoleIn->KeypadDevice);
|
||||
|
||||
//
|
||||
// Clear Memory Scancode Buffer
|
||||
//
|
||||
ConsoleIn->EfiKeyQueue.Head = 0;
|
||||
ConsoleIn->EfiKeyQueue.Tail = 0;
|
||||
ConsoleIn->EfiKeyQueueForNotify.Head = 0;
|
||||
ConsoleIn->EfiKeyQueueForNotify.Tail = 0;
|
||||
|
||||
//
|
||||
// Reset the status indicators
|
||||
//
|
||||
ConsoleIn->CapsLock = FALSE;
|
||||
ConsoleIn->NumLock = FALSE;
|
||||
ConsoleIn->ScrollLock = FALSE;
|
||||
ConsoleIn->LeftCtrl = FALSE;
|
||||
ConsoleIn->RightCtrl = FALSE;
|
||||
ConsoleIn->LeftAlt = FALSE;
|
||||
ConsoleIn->RightAlt = FALSE;
|
||||
ConsoleIn->LeftShift = FALSE;
|
||||
ConsoleIn->RightShift = FALSE;
|
||||
ConsoleIn->LeftLogo = FALSE;
|
||||
ConsoleIn->RightLogo = FALSE;
|
||||
ConsoleIn->Menu = FALSE;
|
||||
ConsoleIn->SysReq = FALSE;
|
||||
|
||||
ConsoleIn->IsSupportPartialKey = FALSE;
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
return EFI_SUCCESS;
|
||||
} else {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
}
|
57
MSM8916Pkg/Drivers/KeypadDxe/KeypadDxe.inf
Normal file
57
MSM8916Pkg/Drivers/KeypadDxe/KeypadDxe.inf
Normal file
@ -0,0 +1,57 @@
|
||||
## @file
|
||||
# Keypad Driver.
|
||||
#
|
||||
# Keypad Driver for UEFI. The keypad type implemented follows IBM
|
||||
# compatible PS2 protocol using Scan Code Set 1.
|
||||
#
|
||||
# Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
#
|
||||
##
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = KeypadDxe
|
||||
FILE_GUID = 463C9415-765B-4AE8-9B1A-AA5C6ECB2892
|
||||
MODULE_TYPE = UEFI_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
ENTRY_POINT = InitializeKeypad
|
||||
|
||||
[Sources]
|
||||
ComponentName.c
|
||||
Keypad.h
|
||||
KeypadController.c
|
||||
KeypadTextIn.c
|
||||
Keypad.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
MSM8916Pkg/MSM8916Pkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
MemoryAllocationLib
|
||||
UefiRuntimeServicesTableLib
|
||||
DebugLib
|
||||
DevicePathLib
|
||||
UefiBootServicesTableLib
|
||||
UefiLib
|
||||
UefiDriverEntryPoint
|
||||
BaseLib
|
||||
BaseMemoryLib
|
||||
TimerLib
|
||||
PcdLib
|
||||
IoLib
|
||||
|
||||
[Protocols]
|
||||
gEfiSimpleTextInProtocolGuid ## BY_START
|
||||
gEfiSimpleTextInputExProtocolGuid ## BY_START
|
||||
gEFIDroidKeypadDeviceProtocolGuid
|
700
MSM8916Pkg/Drivers/KeypadDxe/KeypadTextIn.c
Normal file
700
MSM8916Pkg/Drivers/KeypadDxe/KeypadTextIn.c
Normal file
@ -0,0 +1,700 @@
|
||||
/** @file
|
||||
Routines implements SIMPLE_TEXT_IN protocol's interfaces based on interfaces
|
||||
provided by KeypadController.c.
|
||||
|
||||
Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include "Keypad.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) % KEYPAD_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) % KEYPAD_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) % KEYPAD_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 Keypad 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
|
||||
KeypadReadKeyStrokeWorker (
|
||||
IN KEYPAD_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);
|
||||
|
||||
KeypadTimerHandler (NULL, ConsoleInDev);
|
||||
|
||||
if (ConsoleInDev->KeypadErr) {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
} else {
|
||||
Status = PopEfikeyBufHead (&ConsoleInDev->EfiKeyQueue, KeyData);
|
||||
}
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
Perform 8042 controller and keypad 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
|
||||
KeypadEfiReset (
|
||||
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
|
||||
IN BOOLEAN ExtendedVerification
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
KEYPAD_CONSOLE_IN_DEV *ConsoleIn;
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
ConsoleIn = KEYPAD_CONSOLE_IN_DEV_FROM_THIS (This);
|
||||
if (ConsoleIn->KeypadErr) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Enter critical section
|
||||
//
|
||||
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
|
||||
|
||||
//
|
||||
// Call InitKeypad to initialize the keypad
|
||||
//
|
||||
Status = InitKeypad (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);
|
||||
|
||||
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
|
||||
KeypadReadKeyStroke (
|
||||
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
|
||||
OUT EFI_INPUT_KEY *Key
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
KEYPAD_CONSOLE_IN_DEV *ConsoleIn;
|
||||
EFI_KEY_DATA KeyData;
|
||||
|
||||
ConsoleIn = KEYPAD_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 = KeypadReadKeyStrokeWorker (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
|
||||
KeypadWaitForKey (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
EFI_TPL OldTpl;
|
||||
KEYPAD_CONSOLE_IN_DEV *ConsoleIn;
|
||||
EFI_KEY_DATA KeyData;
|
||||
|
||||
ConsoleIn = (KEYPAD_CONSOLE_IN_DEV *) Context;
|
||||
|
||||
//
|
||||
// Enter critical section
|
||||
//
|
||||
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
|
||||
|
||||
KeypadTimerHandler (NULL, ConsoleIn);
|
||||
|
||||
if (!ConsoleIn->KeypadErr) {
|
||||
//
|
||||
// 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
|
||||
KeypadWaitForKeyEx (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
|
||||
{
|
||||
KeypadWaitForKey (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
|
||||
KeypadEfiResetEx (
|
||||
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
|
||||
IN BOOLEAN ExtendedVerification
|
||||
)
|
||||
|
||||
{
|
||||
KEYPAD_CONSOLE_IN_DEV *ConsoleInDev;
|
||||
|
||||
ConsoleInDev = TEXT_INPUT_EX_KEYPAD_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
|
||||
KeypadReadKeyStrokeEx (
|
||||
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
|
||||
OUT EFI_KEY_DATA *KeyData
|
||||
)
|
||||
|
||||
{
|
||||
KEYPAD_CONSOLE_IN_DEV *ConsoleInDev;
|
||||
|
||||
if (KeyData == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
ConsoleInDev = TEXT_INPUT_EX_KEYPAD_CONSOLE_IN_DEV_FROM_THIS (This);
|
||||
return KeypadReadKeyStrokeWorker (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
|
||||
KeypadSetState (
|
||||
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
|
||||
IN EFI_KEY_TOGGLE_STATE *KeyToggleState
|
||||
)
|
||||
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
KEYPAD_CONSOLE_IN_DEV *ConsoleInDev;
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
if (KeyToggleState == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
ConsoleInDev = TEXT_INPUT_EX_KEYPAD_CONSOLE_IN_DEV_FROM_THIS (This);
|
||||
|
||||
//
|
||||
// Enter critical section
|
||||
//
|
||||
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
|
||||
|
||||
if (ConsoleInDev->KeypadErr) {
|
||||
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;
|
||||
}
|
||||
|
||||
Exit:
|
||||
//
|
||||
// Leave critical section and return
|
||||
//
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Register a notification function for a particular keystroke for the input device.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param KeyData A pointer to a buffer that is filled in with the keystroke
|
||||
information data for the key that was pressed.
|
||||
@param KeyNotificationFunction Points to the function to be called when the key
|
||||
sequence is typed specified by KeyData.
|
||||
@param NotifyHandle Points to the unique handle assigned to the registered notification.
|
||||
|
||||
@retval EFI_SUCCESS The notification function was registered successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES Unable to allocate resources for necesssary data structures.
|
||||
@retval EFI_INVALID_PARAMETER KeyData or NotifyHandle or KeyNotificationFunction is NULL.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
KeypadRegisterKeyNotify (
|
||||
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;
|
||||
KEYPAD_CONSOLE_IN_DEV *ConsoleInDev;
|
||||
EFI_TPL OldTpl;
|
||||
LIST_ENTRY *Link;
|
||||
KEYPAD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
|
||||
KEYPAD_CONSOLE_IN_EX_NOTIFY *NewNotify;
|
||||
|
||||
if (KeyData == NULL || NotifyHandle == NULL || KeyNotificationFunction == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
ConsoleInDev = TEXT_INPUT_EX_KEYPAD_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,
|
||||
KEYPAD_CONSOLE_IN_EX_NOTIFY,
|
||||
NotifyEntry,
|
||||
KEYPAD_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 = (KEYPAD_CONSOLE_IN_EX_NOTIFY *) AllocateZeroPool (sizeof (KEYPAD_CONSOLE_IN_EX_NOTIFY));
|
||||
if (NewNotify == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
NewNotify->Signature = KEYPAD_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
|
||||
KeypadUnregisterKeyNotify (
|
||||
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
|
||||
IN VOID *NotificationHandle
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
KEYPAD_CONSOLE_IN_DEV *ConsoleInDev;
|
||||
EFI_TPL OldTpl;
|
||||
LIST_ENTRY *Link;
|
||||
KEYPAD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
|
||||
|
||||
if (NotificationHandle == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
ConsoleInDev = TEXT_INPUT_EX_KEYPAD_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,
|
||||
KEYPAD_CONSOLE_IN_EX_NOTIFY,
|
||||
NotifyEntry,
|
||||
KEYPAD_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;
|
||||
KEYPAD_CONSOLE_IN_DEV *ConsoleIn;
|
||||
EFI_KEY_DATA KeyData;
|
||||
LIST_ENTRY *Link;
|
||||
LIST_ENTRY *NotifyList;
|
||||
KEYPAD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
|
||||
EFI_TPL OldTpl;
|
||||
|
||||
ConsoleIn = (KEYPAD_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, KEYPAD_CONSOLE_IN_EX_NOTIFY, NotifyEntry, KEYPAD_CONSOLE_IN_EX_NOTIFY_SIGNATURE);
|
||||
if (IsKeyRegistered (&CurrentNotify->KeyData, &KeyData)) {
|
||||
CurrentNotify->KeyNotificationFn (&KeyData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
MSM8916Pkg/Drivers/KeypadDxe/Source.txt
Normal file
2
MSM8916Pkg/Drivers/KeypadDxe/Source.txt
Normal file
@ -0,0 +1,2 @@
|
||||
URL: https://github.com/tianocore/edk2/tree/master/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe
|
||||
BRANCH: master @ 35dadd7c54
|
34
MSM8916Pkg/Include/Configuration/BootDevices.h
Normal file
34
MSM8916Pkg/Include/Configuration/BootDevices.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef _BOOT_DEVICES_H_
|
||||
#define _BOOT_DEVICES_H_
|
||||
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Uefi.h>
|
||||
|
||||
#define PLAT_KEYPAD_DEVICE_GUID \
|
||||
{ \
|
||||
0xD7F58A0E, 0xBED2, 0x4B5A, \
|
||||
{ \
|
||||
0xBB, 0x43, 0x8A, 0xB2, 0x3D, 0xD0, 0xE2, 0xB0 \
|
||||
} \
|
||||
}
|
||||
|
||||
/* DevicePath definition for Button driver */
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
VENDOR_DEVICE_PATH VendorDevicePath;
|
||||
EFI_DEVICE_PATH_PROTOCOL End;
|
||||
} EFI_KEYPAD_DEVICE_PATH;
|
||||
#pragma pack()
|
||||
|
||||
EFI_KEYPAD_DEVICE_PATH KeyPadDxeDevicePath = {
|
||||
{{HARDWARE_DEVICE_PATH,
|
||||
HW_VENDOR_DP,
|
||||
{(UINT8)(sizeof(VENDOR_DEVICE_PATH)),
|
||||
(UINT8)((sizeof(VENDOR_DEVICE_PATH)) >> 8)}},
|
||||
PLAT_KEYPAD_DEVICE_GUID},
|
||||
{END_DEVICE_PATH_TYPE,
|
||||
END_ENTIRE_DEVICE_PATH_SUBTYPE,
|
||||
{(UINT8)(END_DEVICE_PATH_LENGTH),
|
||||
(UINT8)((END_DEVICE_PATH_LENGTH) >> 8)}}};
|
||||
|
||||
#endif
|
277
MSM8916Pkg/Include/Configuration/DeviceMemoryMap.h
Normal file
277
MSM8916Pkg/Include/Configuration/DeviceMemoryMap.h
Normal file
@ -0,0 +1,277 @@
|
||||
#ifndef _DEVICE_MEMORY_MAP_H_
|
||||
#define _DEVICE_MEMORY_MAP_H_
|
||||
|
||||
#include <Library/ArmLib.h>
|
||||
|
||||
#define MAX_ARM_MEMORY_REGION_DESCRIPTOR_COUNT 73
|
||||
|
||||
/* Below flag is used for system memory */
|
||||
#define SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES \
|
||||
EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \
|
||||
EFI_RESOURCE_ATTRIBUTE_TESTED | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE | \
|
||||
EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE | \
|
||||
EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE | \
|
||||
EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE | \
|
||||
EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTABLE
|
||||
|
||||
typedef enum { NoHob, AddMem, AddDev, MaxMem } DeviceMemoryAddHob;
|
||||
|
||||
typedef struct {
|
||||
EFI_PHYSICAL_ADDRESS Address;
|
||||
UINT64 Length;
|
||||
EFI_RESOURCE_TYPE ResourceType;
|
||||
EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute;
|
||||
ARM_MEMORY_REGION_ATTRIBUTES ArmAttributes;
|
||||
DeviceMemoryAddHob HobOption;
|
||||
EFI_MEMORY_TYPE MemoryType;
|
||||
} ARM_MEMORY_REGION_DESCRIPTOR_EX, *PARM_MEMORY_REGION_DESCRIPTOR_EX;
|
||||
|
||||
static ARM_MEMORY_REGION_DESCRIPTOR_EX gDeviceMemoryDescriptorEx[] = {
|
||||
/* Address, Length, ResourceType, Resource Attribute, ARM MMU
|
||||
Attribute, HobOption, EFI Memory Type */
|
||||
|
||||
/* HYP */
|
||||
{0x80000000, 0x00600000, EFI_RESOURCE_MEMORY_RESERVED,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED,
|
||||
AddMem, EfiReservedMemoryType},
|
||||
/* AOP CMD DB */
|
||||
{0x80820000, 0x00020000, EFI_RESOURCE_MEMORY_RESERVED,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED,
|
||||
AddMem, EfiReservedMemoryType},
|
||||
/* SMEM */
|
||||
{0x80900000, 0x00200000, EFI_RESOURCE_MEMORY_RESERVED,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED,
|
||||
AddMem, EfiReservedMemoryType},
|
||||
/* PIL Reserved */
|
||||
{0x84400000, 0x0F800000, EFI_RESOURCE_MEMORY_RESERVED,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED,
|
||||
AddMem, EfiReservedMemoryType},
|
||||
/* DXE Heap */
|
||||
{0x93C00000, 0x04500000, EFI_RESOURCE_SYSTEM_MEMORY,
|
||||
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES, ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK,
|
||||
AddMem, EfiConventionalMemory},
|
||||
/* DBI Dump */
|
||||
{0x98100000, 0x03700000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_INITIALIZED, ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED,
|
||||
NoHob, EfiConventionalMemory},
|
||||
/* Sched Heap */
|
||||
{0x9B800000, 0x00400000, EFI_RESOURCE_SYSTEM_MEMORY,
|
||||
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES, ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK,
|
||||
AddMem, EfiBootServicesData},
|
||||
/* Display Reserved */
|
||||
{0x9C000000, 0x01800000, EFI_RESOURCE_MEMORY_RESERVED,
|
||||
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES, ARM_MEMORY_REGION_ATTRIBUTE_WRITE_THROUGH,
|
||||
AddMem, EfiReservedMemoryType},
|
||||
/* FV Region */
|
||||
{0x9F800000, 0x00200000, EFI_RESOURCE_SYSTEM_MEMORY,
|
||||
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES, ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK,
|
||||
AddMem, EfiBootServicesData},
|
||||
/* ABOOT FV */
|
||||
{0x9FA00000, 0x00200000, EFI_RESOURCE_SYSTEM_MEMORY,
|
||||
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES, ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK,
|
||||
AddMem, EfiReservedMemoryType},
|
||||
/* UEFI FD */
|
||||
{0x9FC00000, 0x00300000, EFI_RESOURCE_SYSTEM_MEMORY,
|
||||
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES, ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK,
|
||||
AddMem, EfiBootServicesData},
|
||||
/* SEC Heap */
|
||||
{0x9FF00000, 0x0008C000, EFI_RESOURCE_SYSTEM_MEMORY,
|
||||
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES, ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK,
|
||||
AddMem, EfiBootServicesData},
|
||||
/* CPU Vectors */
|
||||
{0x9FF8C000, 0x00001000, EFI_RESOURCE_SYSTEM_MEMORY,
|
||||
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES, ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK,
|
||||
AddMem, EfiBootServicesData},
|
||||
/* MMU PageTables */
|
||||
{0x9FF8D000, 0x00003000, EFI_RESOURCE_SYSTEM_MEMORY,
|
||||
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES, ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK,
|
||||
AddMem, EfiBootServicesData},
|
||||
/* UEFI Stack */
|
||||
{0x9FF90000, 0x00040000, EFI_RESOURCE_SYSTEM_MEMORY,
|
||||
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES, ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK,
|
||||
AddMem, EfiBootServicesData},
|
||||
/* Log Buffer */
|
||||
{0x9FFF7000, 0x00008000, EFI_RESOURCE_SYSTEM_MEMORY,
|
||||
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES, ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK,
|
||||
AddMem, EfiRuntimeServicesData},
|
||||
/* Info Blk */
|
||||
{0x9FFFF000, 0x00001000, EFI_RESOURCE_SYSTEM_MEMORY,
|
||||
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES, ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK,
|
||||
AddMem, EfiRuntimeServicesData},
|
||||
/* Secure DSP */
|
||||
{0xA0000000, 0x01200000, EFI_RESOURCE_SYSTEM_MEMORY,
|
||||
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES, ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK,
|
||||
AddMem, EfiReservedMemoryType},
|
||||
/* Kernel */
|
||||
{0xA1200000, 0x08000000, EFI_RESOURCE_SYSTEM_MEMORY,
|
||||
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES, ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK,
|
||||
AddMem, EfiReservedMemoryType},
|
||||
/* MLVM_APSS */
|
||||
{0xA9200000, 0x03A00000, EFI_RESOURCE_SYSTEM_MEMORY,
|
||||
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES, ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK,
|
||||
AddMem, EfiReservedMemoryType},
|
||||
/* MLVM_1 */
|
||||
{0xACC00000, 0x07800000, EFI_RESOURCE_SYSTEM_MEMORY,
|
||||
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES, ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK,
|
||||
AddMem, EfiReservedMemoryType},
|
||||
/* SEC DEBUG */
|
||||
{0xB4400000, 0x00C00000, EFI_RESOURCE_MEMORY_RESERVED,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED,
|
||||
AddMem, EfiReservedMemoryType},
|
||||
/* SOD Test */
|
||||
{0xC2000000, 0x0A100000, EFI_RESOURCE_SYSTEM_MEMORY,
|
||||
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES, ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK,
|
||||
AddMem, EfiReservedMemoryType},
|
||||
|
||||
/* HLOS */
|
||||
{0xC0000000, 0x140000000, EFI_RESOURCE_SYSTEM_MEMORY,
|
||||
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES, ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK,
|
||||
AddMem, EfiConventionalMemory},
|
||||
|
||||
/* Other memory regions */
|
||||
/* AOP_SS_MSG_RAM */
|
||||
{0x0C300000, 0x00100000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_INITIALIZED, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
NoHob, EfiConventionalMemory},
|
||||
/* IMEM Base */
|
||||
{0x14680000, 0x0002B000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_INITIALIZED, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
NoHob, EfiConventionalMemory},
|
||||
/* IMEM Cookie Base */
|
||||
{0x146AA000, 0x00001000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_INITIALIZED, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiConventionalMemory},
|
||||
|
||||
/* Registers */
|
||||
{0x00100000, 0x00200000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x00780000, 0x00007000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x00790000, 0x00010000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x007C0000, 0x00020000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x00800000, 0x00100000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x00A00000, 0x00100000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x01D80000, 0x00020000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x01DC0000, 0x00040000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x01FC0000, 0x00040000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x03500000, 0x00300000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x03900000, 0x00300000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x03D00000, 0x00300000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x05090000, 0x00009000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x0509A000, 0x00004000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x0C200000, 0x00010000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x62B00000, 0x00060000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x08800000, 0x00200000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x090B0000, 0x00001000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x0A600000, 0x0011B000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x0A720000, 0x00010000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x0B2A0000, 0x00010000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x0B4A0000, 0x00010000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x0BA00000, 0x00200000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x0C221000, 0x00003000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x0C263000, 0x00003000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x0C400000, 0x02800000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x0AB00000, 0x00020000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x09980000, 0x00010000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x0AD00000, 0x00020000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x0AF00000, 0x00020000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x18280000, 0x00001000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x18282000, 0x00001000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x18284000, 0x00001000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x18200000, 0x00030000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x17A00000, 0x00010000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x17A60000, 0x00100000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x17C00000, 0x00110000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x18300000, 0x000B0000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x0AE00000, 0x00134000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
{0x15000000, 0x000D0000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO},
|
||||
|
||||
/* Terminator for MMU*/
|
||||
{0},
|
||||
|
||||
/* Terminator for LibMem */
|
||||
{ 0xFFFFFFFF, 0x00001000, EFI_RESOURCE_MEMORY_MAPPED_IO,
|
||||
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, ARM_MEMORY_REGION_ATTRIBUTE_DEVICE,
|
||||
AddDev, EfiMemoryMappedIO}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
74
MSM8916Pkg/Library/MemoryInitPeiLib/MemoryInitPeiLib.c
Normal file
74
MSM8916Pkg/Library/MemoryInitPeiLib/MemoryInitPeiLib.c
Normal file
@ -0,0 +1,74 @@
|
||||
/** @file
|
||||
*
|
||||
* Copyright (c) 2011-2015, ARM Limited. All rights reserved.
|
||||
* Copyright (c) 2019, RUIKAI LIU and MR TUNNEL. All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are licensed and made available under the terms and conditions of the BSD License
|
||||
* which accompanies this distribution. The full text of the license may be found at
|
||||
* http://opensource.org/licenses/bsd-license.php
|
||||
*
|
||||
* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
*
|
||||
**/
|
||||
|
||||
#include <PiPei.h>
|
||||
|
||||
#include <Library/ArmMmuLib.h>
|
||||
#include <Library/ArmPlatformLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/HobLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
|
||||
extern UINT64 mSystemMemoryEnd;
|
||||
|
||||
VOID
|
||||
BuildMemoryTypeInformationHob (
|
||||
VOID
|
||||
);
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
InitMmu (
|
||||
IN ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable
|
||||
)
|
||||
{
|
||||
|
||||
VOID *TranslationTableBase;
|
||||
UINTN TranslationTableSize;
|
||||
RETURN_STATUS Status;
|
||||
|
||||
//Note: Because we called PeiServicesInstallPeiMemory() before to call InitMmu() the MMU Page Table resides in
|
||||
// DRAM (even at the top of DRAM as it is the first permanent memory allocation)
|
||||
Status = ArmConfigureMmu (MemoryTable, &TranslationTableBase, &TranslationTableSize);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((EFI_D_ERROR, "Error: Failed to enable MMU\n"));
|
||||
}
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
MemoryPeim (
|
||||
IN EFI_PHYSICAL_ADDRESS UefiMemoryBase,
|
||||
IN UINT64 UefiMemorySize
|
||||
)
|
||||
{
|
||||
ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable;
|
||||
|
||||
// Get Virtual Memory Map from the Platform Library
|
||||
ArmPlatformGetVirtualMemoryMap (&MemoryTable);
|
||||
|
||||
// Ensure PcdSystemMemorySize has been set
|
||||
ASSERT (PcdGet64 (PcdSystemMemorySize) != 0);
|
||||
|
||||
InitMmu (MemoryTable);
|
||||
|
||||
if (FeaturePcdGet (PcdPrePiProduceMemoryTypeInformationHob)){
|
||||
// Optional feature that helps prevent EFI memory map fragmentation.
|
||||
BuildMemoryTypeInformationHob();
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
#/** @file
|
||||
#
|
||||
# Copyright (c) 2011-2014, ARM Ltd. All rights reserved.<BR>
|
||||
# Copyright (c) 2016, Linaro, Ltd. All rights reserved.<BR>
|
||||
# This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
#**/
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = MemoryInitPeiLib
|
||||
FILE_GUID = 4bbc9c10-a100-43fb-8311-332ba497d1b4
|
||||
MODULE_TYPE = BASE
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = MemoryInitPeiLib|SEC PEIM
|
||||
|
||||
[Sources]
|
||||
MemoryInitPeiLib.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
EmbeddedPkg/EmbeddedPkg.dec
|
||||
ArmPkg/ArmPkg.dec
|
||||
ArmPlatformPkg/ArmPlatformPkg.dec
|
||||
MSM8916Pkg/MSM8916Pkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
DebugLib
|
||||
HobLib
|
||||
ArmMmuLib
|
||||
ArmPlatformLib
|
||||
|
||||
[Guids]
|
||||
gEfiMemoryTypeInformationGuid
|
||||
|
||||
[FeaturePcd]
|
||||
gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob
|
||||
|
||||
[FixedPcd]
|
||||
gArmTokenSpaceGuid.PcdSystemMemoryBase
|
||||
gArmTokenSpaceGuid.PcdSystemMemorySize
|
||||
|
||||
[Depex]
|
||||
TRUE
|
691
MSM8916Pkg/Library/PlatformBootManagerLib/PlatformBm.c
Normal file
691
MSM8916Pkg/Library/PlatformBootManagerLib/PlatformBm.c
Normal file
@ -0,0 +1,691 @@
|
||||
/** @file
|
||||
Implementation for PlatformBootManagerLib library class interfaces.
|
||||
|
||||
Copyright (C) 2015-2016, Red Hat, Inc.
|
||||
Copyright (c) 2014, ARM Ltd. All rights reserved.
|
||||
Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
|
||||
Copyright (c) 2016, Linaro Ltd. All rights reserved.
|
||||
Copyright (c), 2017, Andrei Warkentin <andrey.warkentin@gmail.com>
|
||||
|
||||
This program and the accompanying materials are licensed and made available
|
||||
under the terms and conditions of the BSD License which accompanies this
|
||||
distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include <Library/BootLogoLib.h>
|
||||
#include <Library/CapsuleLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/HobLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/UefiBootManagerLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
#include <Protocol/DevicePath.h>
|
||||
#include <Protocol/EsrtManagement.h>
|
||||
#include <Protocol/GraphicsOutput.h>
|
||||
#include <Protocol/LoadedImage.h>
|
||||
#include <Guid/EventGroup.h>
|
||||
#include <Guid/TtyTerm.h>
|
||||
#include <Configuration/BootDevices.h>
|
||||
|
||||
#include "PlatformBm.h"
|
||||
|
||||
#define DP_NODE_LEN(Type) { (UINT8)sizeof (Type), (UINT8)(sizeof (Type) >> 8) }
|
||||
|
||||
#pragma pack (1)
|
||||
typedef struct {
|
||||
VENDOR_DEVICE_PATH SerialDxe;
|
||||
UART_DEVICE_PATH Uart;
|
||||
VENDOR_DEFINED_DEVICE_PATH TermType;
|
||||
EFI_DEVICE_PATH_PROTOCOL End;
|
||||
} PLATFORM_SERIAL_CONSOLE;
|
||||
#pragma pack ()
|
||||
|
||||
typedef struct {
|
||||
VENDOR_DEVICE_PATH Custom;
|
||||
USB_DEVICE_PATH Hub;
|
||||
USB_DEVICE_PATH Dev;
|
||||
EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
|
||||
} PLATFORM_USB_DEV;
|
||||
|
||||
#define DW_USB_DXE_FILE_GUID { \
|
||||
0x4bf1704c, 0x03f4, 0x46d5, \
|
||||
{ 0xbc, 0xa6, 0x82, 0xfa, 0x58, 0x0b, 0xad, 0xfd } \
|
||||
}
|
||||
|
||||
STATIC PLATFORM_USB_DEV mUsbHubPort = {
|
||||
//
|
||||
// VENDOR_DEVICE_PATH DwUsbHostDxe
|
||||
//
|
||||
{
|
||||
{ HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DP_NODE_LEN (VENDOR_DEVICE_PATH) },
|
||||
DW_USB_DXE_FILE_GUID
|
||||
},
|
||||
|
||||
//
|
||||
// USB_DEVICE_PATH Hub
|
||||
//
|
||||
{
|
||||
{ MESSAGING_DEVICE_PATH, MSG_USB_DP, DP_NODE_LEN (USB_DEVICE_PATH) },
|
||||
0, 0
|
||||
},
|
||||
|
||||
//
|
||||
// USB_DEVICE_PATH Dev
|
||||
//
|
||||
{
|
||||
{ MESSAGING_DEVICE_PATH, MSG_USB_DP, DP_NODE_LEN (USB_DEVICE_PATH) },
|
||||
1, 0
|
||||
},
|
||||
|
||||
//
|
||||
// EFI_DEVICE_PATH_PROTOCOL End
|
||||
//
|
||||
{
|
||||
END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
|
||||
DP_NODE_LEN (EFI_DEVICE_PATH_PROTOCOL)
|
||||
}
|
||||
};
|
||||
|
||||
#define SERIAL_DXE_FILE_GUID { \
|
||||
0xD3987D4B, 0x971A, 0x435F, \
|
||||
{ 0x8C, 0xAF, 0x49, 0x67, 0xEB, 0x62, 0x72, 0x41 } \
|
||||
}
|
||||
|
||||
STATIC PLATFORM_SERIAL_CONSOLE mSerialConsole = {
|
||||
//
|
||||
// VENDOR_DEVICE_PATH SerialDxe
|
||||
//
|
||||
{
|
||||
{ HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DP_NODE_LEN (VENDOR_DEVICE_PATH) },
|
||||
SERIAL_DXE_FILE_GUID
|
||||
},
|
||||
|
||||
//
|
||||
// UART_DEVICE_PATH Uart
|
||||
//
|
||||
{
|
||||
{ MESSAGING_DEVICE_PATH, MSG_UART_DP, DP_NODE_LEN (UART_DEVICE_PATH) },
|
||||
0, // Reserved
|
||||
FixedPcdGet64 (PcdUartDefaultBaudRate), // BaudRate
|
||||
FixedPcdGet8 (PcdUartDefaultDataBits), // DataBits
|
||||
FixedPcdGet8 (PcdUartDefaultParity), // Parity
|
||||
FixedPcdGet8 (PcdUartDefaultStopBits) // StopBits
|
||||
},
|
||||
|
||||
//
|
||||
// VENDOR_DEFINED_DEVICE_PATH TermType
|
||||
//
|
||||
{
|
||||
{
|
||||
MESSAGING_DEVICE_PATH, MSG_VENDOR_DP,
|
||||
DP_NODE_LEN (VENDOR_DEFINED_DEVICE_PATH)
|
||||
}
|
||||
//
|
||||
// Guid to be filled in dynamically
|
||||
//
|
||||
},
|
||||
|
||||
//
|
||||
// EFI_DEVICE_PATH_PROTOCOL End
|
||||
//
|
||||
{
|
||||
END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
|
||||
DP_NODE_LEN (EFI_DEVICE_PATH_PROTOCOL)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#pragma pack (1)
|
||||
typedef struct {
|
||||
USB_CLASS_DEVICE_PATH Keyboard;
|
||||
EFI_DEVICE_PATH_PROTOCOL End;
|
||||
} PLATFORM_USB_KEYBOARD;
|
||||
#pragma pack ()
|
||||
|
||||
STATIC PLATFORM_USB_KEYBOARD mUsbKeyboard = {
|
||||
//
|
||||
// USB_CLASS_DEVICE_PATH Keyboard
|
||||
//
|
||||
{
|
||||
{
|
||||
MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP,
|
||||
DP_NODE_LEN (USB_CLASS_DEVICE_PATH)
|
||||
},
|
||||
0xFFFF, // VendorId: any
|
||||
0xFFFF, // ProductId: any
|
||||
3, // DeviceClass: HID
|
||||
1, // DeviceSubClass: boot
|
||||
1 // DeviceProtocol: keyboard
|
||||
},
|
||||
|
||||
//
|
||||
// EFI_DEVICE_PATH_PROTOCOL End
|
||||
//
|
||||
{
|
||||
END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
|
||||
DP_NODE_LEN (EFI_DEVICE_PATH_PROTOCOL)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Check if the handle satisfies a particular condition.
|
||||
|
||||
@param[in] Handle The handle to check.
|
||||
@param[in] ReportText A caller-allocated string passed in for reporting
|
||||
purposes. It must never be NULL.
|
||||
|
||||
@retval TRUE The condition is satisfied.
|
||||
@retval FALSE Otherwise. This includes the case when the condition could not
|
||||
be fully evaluated due to an error.
|
||||
**/
|
||||
typedef
|
||||
BOOLEAN
|
||||
(EFIAPI *FILTER_FUNCTION) (
|
||||
IN EFI_HANDLE Handle,
|
||||
IN CONST CHAR16 *ReportText
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Process a handle.
|
||||
|
||||
@param[in] Handle The handle to process.
|
||||
@param[in] ReportText A caller-allocated string passed in for reporting
|
||||
purposes. It must never be NULL.
|
||||
**/
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *CALLBACK_FUNCTION) (
|
||||
IN EFI_HANDLE Handle,
|
||||
IN CONST CHAR16 *ReportText
|
||||
);
|
||||
|
||||
/**
|
||||
Locate all handles that carry the specified protocol, filter them with a
|
||||
callback function, and pass each handle that passes the filter to another
|
||||
callback.
|
||||
|
||||
@param[in] ProtocolGuid The protocol to look for.
|
||||
|
||||
@param[in] Filter The filter function to pass each handle to. If this
|
||||
parameter is NULL, then all handles are processed.
|
||||
|
||||
@param[in] Process The callback function to pass each handle to that
|
||||
clears the filter.
|
||||
**/
|
||||
STATIC
|
||||
VOID
|
||||
FilterAndProcess (
|
||||
IN EFI_GUID *ProtocolGuid,
|
||||
IN FILTER_FUNCTION Filter OPTIONAL,
|
||||
IN CALLBACK_FUNCTION Process
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE *Handles;
|
||||
UINTN NoHandles;
|
||||
UINTN Idx;
|
||||
|
||||
Status = gBS->LocateHandleBuffer (ByProtocol, ProtocolGuid,
|
||||
NULL /* SearchKey */, &NoHandles, &Handles);
|
||||
if (EFI_ERROR (Status)) {
|
||||
//
|
||||
// This is not an error, just an informative condition.
|
||||
//
|
||||
DEBUG ((EFI_D_VERBOSE, "%a: %g: %r\n", __FUNCTION__, ProtocolGuid,
|
||||
Status));
|
||||
return;
|
||||
}
|
||||
|
||||
ASSERT (NoHandles > 0);
|
||||
for (Idx = 0; Idx < NoHandles; ++Idx) {
|
||||
CHAR16 *DevicePathText;
|
||||
STATIC CHAR16 Fallback[] = L"<device path unavailable>";
|
||||
|
||||
//
|
||||
// The ConvertDevicePathToText() function handles NULL input transparently.
|
||||
//
|
||||
DevicePathText = ConvertDevicePathToText (
|
||||
DevicePathFromHandle (Handles[Idx]),
|
||||
FALSE, // DisplayOnly
|
||||
FALSE // AllowShortcuts
|
||||
);
|
||||
if (DevicePathText == NULL) {
|
||||
DevicePathText = Fallback;
|
||||
}
|
||||
|
||||
if (Filter == NULL || Filter (Handles[Idx], DevicePathText)) {
|
||||
Process (Handles[Idx], DevicePathText);
|
||||
}
|
||||
|
||||
if (DevicePathText != Fallback) {
|
||||
FreePool (DevicePathText);
|
||||
}
|
||||
}
|
||||
gBS->FreePool (Handles);
|
||||
}
|
||||
|
||||
/**
|
||||
This CALLBACK_FUNCTION retrieves the EFI_DEVICE_PATH_PROTOCOL from the
|
||||
handle, and adds it to ConOut and ErrOut.
|
||||
**/
|
||||
STATIC
|
||||
VOID
|
||||
EFIAPI
|
||||
AddOutput (
|
||||
IN EFI_HANDLE Handle,
|
||||
IN CONST CHAR16 *ReportText
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
|
||||
DevicePath = DevicePathFromHandle (Handle);
|
||||
if (DevicePath == NULL) {
|
||||
DEBUG ((EFI_D_ERROR, "%a: %s: handle %p: device path not found\n",
|
||||
__FUNCTION__, ReportText, Handle));
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((EFI_D_ERROR, "%a: %s: adding to ConOut: %r\n", __FUNCTION__,
|
||||
ReportText, Status));
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((EFI_D_ERROR, "%a: %s: adding to ErrOut: %r\n", __FUNCTION__,
|
||||
ReportText, Status));
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG ((EFI_D_VERBOSE, "%a: %s: added to ConOut and ErrOut\n", __FUNCTION__,
|
||||
ReportText));
|
||||
}
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
EFIAPI
|
||||
AddInput (
|
||||
IN EFI_HANDLE Handle,
|
||||
IN CONST CHAR16 *ReportText
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
|
||||
DevicePath = DevicePathFromHandle (Handle);
|
||||
if (DevicePath == NULL) {
|
||||
DEBUG ((EFI_D_ERROR, "%a: %s: handle %p: device path not found\n",
|
||||
__FUNCTION__, ReportText, Handle));
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((EFI_D_ERROR, "%a: %s: adding to ConIn: %r\n", __FUNCTION__,
|
||||
ReportText, Status));
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG ((EFI_D_VERBOSE, "%a: %s: added to ConOut and ErrOut\n", __FUNCTION__,
|
||||
ReportText));
|
||||
}
|
||||
|
||||
STATIC
|
||||
INTN
|
||||
PlatformRegisterBootOption (
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath,
|
||||
CHAR16 *Description,
|
||||
UINT32 Attributes
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
INTN OptionIndex;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
|
||||
UINTN BootOptionCount;
|
||||
|
||||
Status = EfiBootManagerInitializeLoadOption (
|
||||
&NewOption,
|
||||
LoadOptionNumberUnassigned,
|
||||
LoadOptionTypeBoot,
|
||||
Attributes,
|
||||
Description,
|
||||
DevicePath,
|
||||
NULL,
|
||||
0
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
BootOptions = EfiBootManagerGetLoadOptions (
|
||||
&BootOptionCount, LoadOptionTypeBoot
|
||||
);
|
||||
|
||||
OptionIndex = EfiBootManagerFindLoadOption (
|
||||
&NewOption, BootOptions, BootOptionCount
|
||||
);
|
||||
|
||||
if (OptionIndex == -1) {
|
||||
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
OptionIndex = BootOptionCount;
|
||||
}
|
||||
|
||||
EfiBootManagerFreeLoadOption (&NewOption);
|
||||
EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
|
||||
|
||||
return OptionIndex;
|
||||
}
|
||||
|
||||
STATIC
|
||||
INTN
|
||||
PlatformRegisterFvBootOption (
|
||||
CONST EFI_GUID *FileGuid,
|
||||
CHAR16 *Description,
|
||||
UINT32 Attributes
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
|
||||
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
INTN OptionIndex;
|
||||
|
||||
Status = gBS->HandleProtocol (
|
||||
gImageHandle,
|
||||
&gEfiLoadedImageProtocolGuid,
|
||||
(VOID **) &LoadedImage
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
|
||||
DevicePath = DevicePathFromHandle (LoadedImage->DeviceHandle);
|
||||
ASSERT (DevicePath != NULL);
|
||||
DevicePath = AppendDevicePathNode (
|
||||
DevicePath,
|
||||
(EFI_DEVICE_PATH_PROTOCOL *) &FileNode
|
||||
);
|
||||
ASSERT (DevicePath != NULL);
|
||||
|
||||
OptionIndex = PlatformRegisterBootOption (DevicePath,
|
||||
Description,
|
||||
Attributes);
|
||||
FreePool (DevicePath);
|
||||
|
||||
return OptionIndex;
|
||||
}
|
||||
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
PlatformRegisterOptionsAndKeys (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
INTN ShellOption;
|
||||
|
||||
ShellOption = PlatformRegisterFvBootOption(
|
||||
&gUefiShellFileGuid,
|
||||
L"UEFI Shell",
|
||||
LOAD_OPTION_ACTIVE
|
||||
);
|
||||
}
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
PlatformRegisterSetupKey(
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_INPUT_KEY PowerBtn;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
|
||||
|
||||
//
|
||||
// Map Power to Boot Manager Menu
|
||||
//
|
||||
PowerBtn.ScanCode = SCAN_NULL;
|
||||
PowerBtn.UnicodeChar = CHAR_CARRIAGE_RETURN;
|
||||
Status = EfiBootManagerGetBootManagerMenu(&BootOption);
|
||||
ASSERT_EFI_ERROR(Status);
|
||||
Status = EfiBootManagerAddKeyOptionVariable(
|
||||
NULL,
|
||||
(UINT16) BootOption.OptionNumber,
|
||||
0,
|
||||
&PowerBtn,
|
||||
NULL
|
||||
);
|
||||
ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// BDS Platform Functions
|
||||
//
|
||||
/**
|
||||
Do the platform init, can be customized by OEM/IBV
|
||||
Possible things that can be done in PlatformBootManagerBeforeConsole:
|
||||
> Update console variable: 1. include hot-plug devices;
|
||||
> 2. Clear ConIn and add SOL for AMT
|
||||
> Register new Driver#### or Boot####
|
||||
> Register new Key####: e.g.: F12
|
||||
> Signal ReadyToLock event
|
||||
> Authentication action: 1. connect Auth devices;
|
||||
> 2. Identify auto logon user.
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
PlatformBootManagerBeforeConsole (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
ESRT_MANAGEMENT_PROTOCOL *EsrtManagement;
|
||||
|
||||
if (GetBootModeHob() == BOOT_ON_FLASH_UPDATE) {
|
||||
DEBUG ((DEBUG_INFO, "ProcessCapsules Before EndOfDxe ......\n"));
|
||||
Status = ProcessCapsules ();
|
||||
DEBUG ((DEBUG_INFO, "ProcessCapsules returned %r\n", Status));
|
||||
} else {
|
||||
Status = gBS->LocateProtocol (&gEsrtManagementProtocolGuid, NULL,
|
||||
(VOID **)&EsrtManagement);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
EsrtManagement->SyncEsrtFmp ();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Now add the device path of all handles with GOP on them to ConOut and
|
||||
// ErrOut.
|
||||
//
|
||||
FilterAndProcess (&gEfiGraphicsOutputProtocolGuid, NULL, AddOutput);
|
||||
|
||||
//
|
||||
// Add the hardcoded short-form USB keyboard device path to ConIn.
|
||||
//
|
||||
EfiBootManagerUpdateConsoleVariable (ConIn,
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&mUsbKeyboard, NULL);
|
||||
|
||||
//
|
||||
// Now add the device path of all handles with QcomKeypadDeviceProtocolGuid
|
||||
// on them to ConIn.
|
||||
//
|
||||
FilterAndProcess (&gEFIDroidKeypadDeviceProtocolGuid, NULL, AddInput);
|
||||
// Register setup key then
|
||||
PlatformRegisterSetupKey();
|
||||
|
||||
//
|
||||
// Add the hardcoded serial console device path to ConIn, ConOut, ErrOut.
|
||||
//
|
||||
ASSERT (FixedPcdGet8 (PcdDefaultTerminalType) == 4);
|
||||
CopyGuid (&mSerialConsole.TermType.Guid, &gEfiTtyTermGuid);
|
||||
|
||||
EfiBootManagerUpdateConsoleVariable (ConIn,
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole, NULL);
|
||||
EfiBootManagerUpdateConsoleVariable (ConOut,
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole, NULL);
|
||||
EfiBootManagerUpdateConsoleVariable (ErrOut,
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&mSerialConsole, NULL);
|
||||
|
||||
//
|
||||
// Signal EndOfDxe PI Event
|
||||
//
|
||||
EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);
|
||||
|
||||
//
|
||||
// Dispatch deferred images after EndOfDxe event and ReadyToLock installation.
|
||||
//
|
||||
EfiBootManagerDispatchDeferredImages ();
|
||||
}
|
||||
|
||||
/**
|
||||
Do the platform specific action after the console is ready
|
||||
Possible things that can be done in PlatformBootManagerAfterConsole:
|
||||
> Console post action:
|
||||
> Dynamically switch output mode from 100x31 to 80x25 for certain senarino
|
||||
> Signal console ready platform customized event
|
||||
> Run diagnostics like memory testing
|
||||
> Connect certain devices
|
||||
> Dispatch aditional option roms
|
||||
> Special boot: e.g.: USB boot, enter UI
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
PlatformBootManagerAfterConsole (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
ESRT_MANAGEMENT_PROTOCOL *EsrtManagement;
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Show the splash screen.
|
||||
//
|
||||
Status = BootLogoEnableLogo ();
|
||||
|
||||
//
|
||||
// Connect the rest of the devices.
|
||||
//
|
||||
EfiBootManagerConnectAll ();
|
||||
|
||||
Status = gBS->LocateProtocol (&gEsrtManagementProtocolGuid, NULL,
|
||||
(VOID **)&EsrtManagement);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
EsrtManagement->SyncEsrtFmp ();
|
||||
}
|
||||
|
||||
if (GetBootModeHob() == BOOT_ON_FLASH_UPDATE) {
|
||||
DEBUG((DEBUG_INFO, "ProcessCapsules After EndOfDxe ......\n"));
|
||||
Status = ProcessCapsules ();
|
||||
DEBUG((DEBUG_INFO, "ProcessCapsules returned %r\n", Status));
|
||||
}
|
||||
|
||||
EfiBootManagerRefreshAllBootOption ();
|
||||
|
||||
PlatformRegisterOptionsAndKeys ();
|
||||
}
|
||||
|
||||
/**
|
||||
This function is called each second during the boot manager waits the
|
||||
timeout.
|
||||
|
||||
@param TimeoutRemain The remaining timeout.
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
PlatformBootManagerWaitCallback (
|
||||
UINT16 TimeoutRemain
|
||||
)
|
||||
{
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;
|
||||
UINT16 Timeout;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Timeout = PcdGet16 (PcdPlatformBootTimeOut);
|
||||
|
||||
Black.Raw = 0x00000000;
|
||||
White.Raw = 0x00FFFFFF;
|
||||
|
||||
Status = BootLogoUpdateProgress (
|
||||
White.Pixel,
|
||||
Black.Pixel,
|
||||
L"Press Power Button for Setup Utility\n",
|
||||
White.Pixel,
|
||||
(Timeout - TimeoutRemain) * 100 / Timeout,
|
||||
0
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Print (L".");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
The function is called when no boot option could be launched,
|
||||
including platform recovery options and options pointing to applications
|
||||
built into firmware volumes.
|
||||
|
||||
If this function returns, BDS attempts to enter an infinite loop.
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
PlatformBootManagerUnableToBoot (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_INPUT_KEY Key;
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION BootManagerMenu;
|
||||
UINTN Index;
|
||||
|
||||
//
|
||||
// BootManagerMenu doesn't contain the correct information when return status
|
||||
// is EFI_NOT_FOUND.
|
||||
//
|
||||
Status = EfiBootManagerGetBootManagerMenu (&BootManagerMenu);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return;
|
||||
}
|
||||
//
|
||||
// Normally BdsDxe does not print anything to the system console, but this is
|
||||
// a last resort -- the end-user will likely not see any DEBUG messages
|
||||
// logged in this situation.
|
||||
//
|
||||
// AsciiPrint() will NULL-check gST->ConOut internally. We check gST->ConIn
|
||||
// here to see if it makes sense to request and wait for a keypress.
|
||||
//
|
||||
if (gST->ConIn != NULL) {
|
||||
AsciiPrint (
|
||||
"%a: No bootable option or device was found.\n"
|
||||
"%a: Press any key to enter the Boot Manager Menu.\n",
|
||||
gEfiCallerBaseName,
|
||||
gEfiCallerBaseName
|
||||
);
|
||||
Status = gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &Index);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
ASSERT (Index == 0);
|
||||
|
||||
//
|
||||
// Drain any queued keys.
|
||||
//
|
||||
while (!EFI_ERROR (gST->ConIn->ReadKeyStroke (gST->ConIn, &Key))) {
|
||||
//
|
||||
// just throw away Key
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
EfiBootManagerBoot (&BootManagerMenu);
|
||||
}
|
||||
}
|
60
MSM8916Pkg/Library/PlatformBootManagerLib/PlatformBm.h
Normal file
60
MSM8916Pkg/Library/PlatformBootManagerLib/PlatformBm.h
Normal file
@ -0,0 +1,60 @@
|
||||
/** @file
|
||||
Head file for BDS Platform specific code
|
||||
|
||||
Copyright (C) 2015-2016, Red Hat, Inc.
|
||||
Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
|
||||
Copyright (c) 2016, Linaro Ltd. All rights reserved.
|
||||
Copyright (c), 2017, Andrei Warkentin <andrey.warkentin@gmail.com>
|
||||
|
||||
This program and the accompanying materials are licensed and made available
|
||||
under the terms and conditions of the BSD License which accompanies this
|
||||
distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _PLATFORM_BM_H_
|
||||
#define _PLATFORM_BM_H_
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
|
||||
/**
|
||||
Use SystemTable Conout to stop video based Simple Text Out consoles from
|
||||
going to the video device. Put up LogoFile on every video device that is a
|
||||
console.
|
||||
|
||||
@param[in] LogoFile File name of logo to display on the center of the
|
||||
screen.
|
||||
|
||||
@retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo
|
||||
displayed.
|
||||
@retval EFI_UNSUPPORTED Logo not found
|
||||
**/
|
||||
EFI_STATUS
|
||||
EnableQuietBoot (
|
||||
IN EFI_GUID *LogoFile
|
||||
);
|
||||
|
||||
/**
|
||||
Use SystemTable Conout to turn on video based Simple Text Out consoles. The
|
||||
Simple Text Out screens will now be synced up with all non video output
|
||||
devices
|
||||
|
||||
@retval EFI_SUCCESS UGA devices are back in text mode and synced up.
|
||||
**/
|
||||
EFI_STATUS
|
||||
DisableQuietBoot (
|
||||
VOID
|
||||
);
|
||||
|
||||
#endif // _PLATFORM_BM_H_
|
@ -0,0 +1,92 @@
|
||||
## @file
|
||||
# Implementation for PlatformBootManagerLib library class interfaces.
|
||||
#
|
||||
# Copyright (C) 2015-2016, Red Hat, Inc.
|
||||
# Copyright (c) 2014, ARM Ltd. All rights reserved.
|
||||
# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
|
||||
# Copyright (c) 2016, Linaro Ltd. All rights reserved.
|
||||
# Copyright (c), 2017, Andrei Warkentin <andrey.warkentin@gmail.com>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED.
|
||||
#
|
||||
##
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = PlatformBootManagerLib
|
||||
FILE_GUID = 92FD2DE3-B9CB-4B35-8141-42AD34D73C9F
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = PlatformBootManagerLib|DXE_DRIVER
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = ARM AARCH64
|
||||
#
|
||||
|
||||
[Sources]
|
||||
PlatformBm.c
|
||||
|
||||
[Packages]
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
MdePkg/MdePkg.dec
|
||||
ShellPkg/ShellPkg.dec
|
||||
MSM8916Pkg/MSM8916Pkg.dec
|
||||
|
||||
[BuildOptions.AARCH64]
|
||||
GCC:*_*_*_CC_FLAGS = -Wno-unused-variable
|
||||
|
||||
[LibraryClasses]
|
||||
BaseLib
|
||||
BaseMemoryLib
|
||||
BootLogoLib
|
||||
CapsuleLib
|
||||
DebugLib
|
||||
DevicePathLib
|
||||
DxeServicesLib
|
||||
HobLib
|
||||
MemoryAllocationLib
|
||||
PcdLib
|
||||
PrintLib
|
||||
UefiBootManagerLib
|
||||
UefiBootServicesTableLib
|
||||
UefiLib
|
||||
|
||||
[FeaturePcd]
|
||||
gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport
|
||||
|
||||
[FixedPcd]
|
||||
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
|
||||
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits
|
||||
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
|
||||
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits
|
||||
gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType
|
||||
|
||||
[Pcd]
|
||||
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
|
||||
|
||||
[Guids]
|
||||
gEfiFileInfoGuid
|
||||
gEfiFileSystemInfoGuid
|
||||
gEfiFileSystemVolumeLabelInfoIdGuid
|
||||
gEfiEndOfDxeEventGroupGuid
|
||||
gEfiTtyTermGuid
|
||||
gUefiShellFileGuid
|
||||
|
||||
[Protocols]
|
||||
gEfiDevicePathProtocolGuid
|
||||
gEfiGraphicsOutputProtocolGuid
|
||||
gEfiLoadedImageProtocolGuid
|
||||
gEfiSimpleFileSystemProtocolGuid
|
||||
gEsrtManagementProtocolGuid
|
||||
gEfiUsb2HcProtocolGuid
|
||||
gEFIDroidKeypadDeviceProtocolGuid
|
||||
|
32
MSM8916Pkg/Library/PlatformPeiLib/PlatformPeiLib.c
Normal file
32
MSM8916Pkg/Library/PlatformPeiLib/PlatformPeiLib.c
Normal file
@ -0,0 +1,32 @@
|
||||
/** @file
|
||||
*
|
||||
* Copyright (c) 2011-2014, ARM Limited. All rights reserved.
|
||||
* Copyright (c) 2014, Linaro Limited. All rights reserved.
|
||||
*
|
||||
* This program and the accompanying materials
|
||||
* are licensed and made available under the terms and conditions of the BSD
|
||||
*License which accompanies this distribution. The full text of the license may
|
||||
*be found at http://opensource.org/licenses/bsd-license.php
|
||||
*
|
||||
* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
|
||||
*IMPLIED.
|
||||
*
|
||||
**/
|
||||
|
||||
#include <PiPei.h>
|
||||
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/HobLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
PlatformPeim(VOID)
|
||||
{
|
||||
|
||||
BuildFvHob(PcdGet64(PcdFvBaseAddress), PcdGet32(PcdFvSize));
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
45
MSM8916Pkg/Library/PlatformPeiLib/PlatformPeiLib.inf
Normal file
45
MSM8916Pkg/Library/PlatformPeiLib/PlatformPeiLib.inf
Normal file
@ -0,0 +1,45 @@
|
||||
#/** @file
|
||||
#
|
||||
# Copyright (c) 2011-2015, ARM Limited. All rights reserved.
|
||||
# Copyright (c) 2014, Linaro Limited. All rights reserved.
|
||||
#
|
||||
# This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
#**/
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = PlatformPeiLib
|
||||
FILE_GUID = 59C11815-F8DA-4F49-B4FB-EC1E41ED1F06
|
||||
MODULE_TYPE = SEC
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = PlatformPeiLib
|
||||
|
||||
[Sources]
|
||||
PlatformPeiLib.c
|
||||
|
||||
[Packages]
|
||||
ArmPkg/ArmPkg.dec
|
||||
MSM8916Pkg/MSM8916Pkg.dec
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
EmbeddedPkg/EmbeddedPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
DebugLib
|
||||
HobLib
|
||||
|
||||
[FixedPcd]
|
||||
gArmTokenSpaceGuid.PcdFvSize
|
||||
|
||||
[Pcd]
|
||||
gArmTokenSpaceGuid.PcdFvBaseAddress
|
||||
|
||||
[Depex]
|
||||
gEfiPeiMemoryDiscoveredPpiGuid
|
@ -31,6 +31,9 @@
|
||||
[Guids.common]
|
||||
gMSM8916PkgTokenSpaceGuid = { 0x99a14446, 0xaad7, 0xe460, {0xb4, 0xe5, 0x1f, 0x79, 0xaa, 0xa4, 0x93, 0xfd } }
|
||||
|
||||
[Protocols]
|
||||
gEFIDroidKeypadDeviceProtocolGuid = { 0xb27625b5, 0x0b6c, 0x4614, { 0xaa, 0x3c, 0x33, 0x13, 0xb5, 0x1d, 0x36, 0x46 } }
|
||||
|
||||
[PcdsFixedAtBuild.common]
|
||||
# Simple FrameBuffer
|
||||
gMSM8916PkgTokenSpaceGuid.PcdMipiFrameBufferAddress|0x00400000|UINT32|0x0000a400 # 0x7C400000
|
||||
|
@ -68,14 +68,15 @@
|
||||
FrameBufferBltLib|MSM8916Pkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
|
||||
|
||||
SerialPortLib|MSM8916Pkg/Library/FrameBufferSerialPortLib/FrameBufferSerialPortLib.inf
|
||||
PlatformBootManagerLib|MSM8916Pkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
|
||||
MemoryInitPeiLib|MSM8916Pkg/Library/MemoryInitPeiLib/PeiMemoryAllocationLib.inf
|
||||
PlatformPeiLib|MSM8916Pkg/Library/PlatformPeiLib/PlatformPeiLib.inf
|
||||
|
||||
[LibraryClasses.common.SEC]
|
||||
PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf
|
||||
ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf
|
||||
HobLib|EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf
|
||||
MemoryAllocationLib|EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf
|
||||
MemoryInitPeiLib|ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.inf
|
||||
PlatformPeiLib|ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf
|
||||
PrePiHobListPointerLib|ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf
|
||||
|
||||
################################################################################
|
||||
@ -111,6 +112,8 @@
|
||||
# GUID of the UI app
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 }
|
||||
|
||||
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|5
|
||||
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
|
||||
|
||||
gEmbeddedTokenSpaceGuid.PcdMetronomeTickPeriod|1000
|
||||
@ -237,13 +240,15 @@
|
||||
#
|
||||
# Bds
|
||||
#
|
||||
MdeModulePkg/Universal/PrintDxe/PrintDxe.inf
|
||||
MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
|
||||
MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf {
|
||||
<LibraryClasses>
|
||||
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
|
||||
}
|
||||
MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
|
||||
MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
|
||||
MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
|
||||
MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf
|
||||
MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
|
||||
MdeModulePkg/Application/UiApp/UiApp.inf {
|
||||
<LibraryClasses>
|
||||
|
@ -211,9 +211,11 @@ READ_LOCK_STATUS = TRUE
|
||||
#
|
||||
# Bds
|
||||
#
|
||||
INF MdeModulePkg/Universal/PrintDxe/PrintDxe.inf
|
||||
INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
|
||||
INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
|
||||
INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
|
||||
INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
|
||||
INF MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf
|
||||
INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
|
||||
INF MdeModulePkg/Application/UiApp/UiApp.inf
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user