EmbeddedPkg: Apply uncrustify changes

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737

Apply uncrustify changes to .c/.h files in the EmbeddedPkg package

Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Andrew Fish <afish@apple.com>
This commit is contained in:
Michael Kubacki
2021-12-05 14:53:56 -08:00
committed by mergify[bot]
parent 731c67e1d7
commit e7108d0e96
106 changed files with 9242 additions and 7648 deletions

View File

@@ -22,7 +22,7 @@
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#define IP4_ADDR_TO_STRING(IpAddr, IpAddrString) UnicodeSPrint ( \
#define IP4_ADDR_TO_STRING(IpAddr, IpAddrString) UnicodeSPrint ( \
IpAddrString, \
16 * 2, \
L"%d.%d.%d.%d", \
@@ -37,49 +37,49 @@
// (This isn't actually a packet size - it's just the size of the buffers we
// pass to the TCP driver to fill with received data.)
// We can achieve much better performance by doing this in larger chunks.
#define RX_FRAGMENT_SIZE 2048
#define RX_FRAGMENT_SIZE 2048
STATIC EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *mTextOut;
STATIC EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *mTextOut;
STATIC EFI_TCP4_PROTOCOL *mTcpConnection;
STATIC EFI_TCP4_PROTOCOL *mTcpListener;
STATIC EFI_TCP4_PROTOCOL *mTcpConnection;
STATIC EFI_TCP4_PROTOCOL *mTcpListener;
STATIC EFI_EVENT mReceiveEvent;
STATIC EFI_EVENT mReceiveEvent;
STATIC EFI_SERVICE_BINDING_PROTOCOL *mTcpServiceBinding;
STATIC EFI_SERVICE_BINDING_PROTOCOL *mTcpServiceBinding;
STATIC EFI_HANDLE mTcpHandle = NULL;
// We only ever use one IO token for receive and one for transmit. To save
// repeatedly allocating and freeing, just allocate statically and re-use.
#define NUM_RX_TOKENS 16
#define TOKEN_NEXT(Index) (((Index) + 1) % NUM_RX_TOKENS)
#define NUM_RX_TOKENS 16
#define TOKEN_NEXT(Index) (((Index) + 1) % NUM_RX_TOKENS)
STATIC UINTN mNextSubmitIndex;
STATIC UINTN mNextReceiveIndex;
STATIC EFI_TCP4_IO_TOKEN mReceiveToken[NUM_RX_TOKENS];
STATIC EFI_TCP4_RECEIVE_DATA mRxData[NUM_RX_TOKENS];
STATIC EFI_TCP4_IO_TOKEN mTransmitToken;
STATIC EFI_TCP4_TRANSMIT_DATA mTxData;
STATIC UINTN mNextSubmitIndex;
STATIC UINTN mNextReceiveIndex;
STATIC EFI_TCP4_IO_TOKEN mReceiveToken[NUM_RX_TOKENS];
STATIC EFI_TCP4_RECEIVE_DATA mRxData[NUM_RX_TOKENS];
STATIC EFI_TCP4_IO_TOKEN mTransmitToken;
STATIC EFI_TCP4_TRANSMIT_DATA mTxData;
// We also reuse the accept token
STATIC EFI_TCP4_LISTEN_TOKEN mAcceptToken;
STATIC EFI_TCP4_LISTEN_TOKEN mAcceptToken;
// .. and the close token
STATIC EFI_TCP4_CLOSE_TOKEN mCloseToken;
STATIC EFI_TCP4_CLOSE_TOKEN mCloseToken;
// List type for queued received packets
typedef struct _FASTBOOT_TCP_PACKET_LIST {
LIST_ENTRY Link;
VOID *Buffer;
UINTN BufferSize;
LIST_ENTRY Link;
VOID *Buffer;
UINTN BufferSize;
} FASTBOOT_TCP_PACKET_LIST;
STATIC LIST_ENTRY mPacketListHead;
STATIC LIST_ENTRY mPacketListHead;
STATIC
VOID
EFIAPI
DataReceived (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
);
/*
@@ -91,8 +91,8 @@ SubmitRecieveToken (
VOID
)
{
EFI_STATUS Status;
VOID *FragmentBuffer;
EFI_STATUS Status;
VOID *FragmentBuffer;
Status = EFI_SUCCESS;
@@ -103,12 +103,12 @@ SubmitRecieveToken (
return EFI_OUT_OF_RESOURCES;
}
mRxData[mNextSubmitIndex].DataLength = RX_FRAGMENT_SIZE;
mRxData[mNextSubmitIndex].DataLength = RX_FRAGMENT_SIZE;
mRxData[mNextSubmitIndex].FragmentTable[0].FragmentLength = RX_FRAGMENT_SIZE;
mRxData[mNextSubmitIndex].FragmentTable[0].FragmentBuffer = FragmentBuffer;
Status = mTcpConnection->Receive (mTcpConnection, &mReceiveToken[mNextSubmitIndex]);
if (EFI_ERROR (Status)) {
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "TCP Receive: %r\n", Status));
FreePool (FragmentBuffer);
}
@@ -125,10 +125,10 @@ STATIC
VOID
ConnectionClosed (
IN EFI_EVENT Event,
IN VOID *Context
IN VOID *Context
)
{
EFI_STATUS Status;
EFI_STATUS Status;
// Possible bug in EDK2 TCP4 driver: closing a connection doesn't remove its
// PCB from the list of live connections. Subsequent attempts to Configure()
@@ -150,7 +150,7 @@ CloseReceiveEvents (
VOID
)
{
UINTN Index;
UINTN Index;
for (Index = 0; Index < NUM_RX_TOKENS; Index++) {
gBS->CloseEvent (mReceiveToken[Index].CompletionToken.Event);
@@ -164,11 +164,11 @@ STATIC
VOID
EFIAPI
DataReceived (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
)
{
EFI_STATUS Status;
EFI_STATUS Status;
FASTBOOT_TCP_PACKET_LIST *NewEntry;
EFI_TCP4_IO_TOKEN *ReceiveToken;
@@ -208,11 +208,11 @@ DataReceived (
= ReceiveToken->Packet.RxData->FragmentTable[0].FragmentLength;
// Prepare to receive more data
SubmitRecieveToken();
SubmitRecieveToken ();
} else {
// Fatal receive error. Put an entry with NULL in the queue, signifying
// to return EFI_DEVICE_ERROR from TcpFastbootTransportReceive.
NewEntry->Buffer = NULL;
NewEntry->Buffer = NULL;
NewEntry->BufferSize = 0;
DEBUG ((DEBUG_ERROR, "\nTCP Fastboot Receive error: %r\n", Status));
@@ -224,7 +224,6 @@ DataReceived (
ASSERT_EFI_ERROR (Status);
}
/*
Event notify function to be called when we accept an incoming TCP connection.
*/
@@ -232,21 +231,22 @@ STATIC
VOID
EFIAPI
ConnectionAccepted (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
)
{
EFI_TCP4_LISTEN_TOKEN *AcceptToken;
EFI_TCP4_LISTEN_TOKEN *AcceptToken;
EFI_STATUS Status;
UINTN Index;
AcceptToken = (EFI_TCP4_LISTEN_TOKEN *) Context;
Status = AcceptToken->CompletionToken.Status;
AcceptToken = (EFI_TCP4_LISTEN_TOKEN *)Context;
Status = AcceptToken->CompletionToken.Status;
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "TCP Fastboot: Connection Error: %r\n", Status));
return;
}
DEBUG ((DEBUG_ERROR, "TCP Fastboot: Connection Received.\n"));
//
@@ -257,7 +257,7 @@ ConnectionAccepted (
Status = gBS->OpenProtocol (
AcceptToken->NewChildHandle,
&gEfiTcp4ProtocolGuid,
(VOID **) &mTcpConnection,
(VOID **)&mTcpConnection,
gImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -267,7 +267,7 @@ ConnectionAccepted (
return;
}
mNextSubmitIndex = 0;
mNextSubmitIndex = 0;
mNextReceiveIndex = 0;
for (Index = 0; Index < NUM_RX_TOKENS; Index++) {
@@ -282,7 +282,7 @@ ConnectionAccepted (
}
for (Index = 0; Index < NUM_RX_TOKENS; Index++) {
SubmitRecieveToken();
SubmitRecieveToken ();
}
}
@@ -292,26 +292,32 @@ ConnectionAccepted (
*/
EFI_STATUS
TcpFastbootTransportStart (
EFI_EVENT ReceiveEvent
EFI_EVENT ReceiveEvent
)
{
EFI_STATUS Status;
EFI_HANDLE NetDeviceHandle;
EFI_HANDLE *HandleBuffer;
EFI_IP4_MODE_DATA Ip4ModeData;
UINTN NumHandles;
CHAR16 IpAddrString[16];
UINTN Index;
EFI_STATUS Status;
EFI_HANDLE NetDeviceHandle;
EFI_HANDLE *HandleBuffer;
EFI_IP4_MODE_DATA Ip4ModeData;
UINTN NumHandles;
CHAR16 IpAddrString[16];
UINTN Index;
EFI_TCP4_CONFIG_DATA TcpConfigData = {
EFI_TCP4_CONFIG_DATA TcpConfigData = {
0x00, // IPv4 Type of Service
255, // IPv4 Time to Live
{ // AccessPoint:
TRUE, // Use default address
{ {0, 0, 0, 0} }, // IP Address (ignored - use default)
{ {0, 0, 0, 0} }, // Subnet mask (ignored - use default)
{
{ 0, 0, 0, 0 }
}, // IP Address (ignored - use default)
{
{ 0, 0, 0, 0 }
}, // Subnet mask (ignored - use default)
FixedPcdGet32 (PcdAndroidFastbootTcpPort), // Station port
{ {0, 0, 0, 0} }, // Remote address: accept any
{
{ 0, 0, 0, 0 }
}, // Remote address: accept any
0, // Remote Port: accept any
FALSE // ActiveFlag: be a "server"
},
@@ -343,13 +349,13 @@ TcpFastbootTransportStart (
NetDeviceHandle = HandleBuffer[0];
Status = gBS->OpenProtocol (
NetDeviceHandle,
&gEfiTcp4ServiceBindingProtocolGuid,
(VOID **) &mTcpServiceBinding,
gImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
NetDeviceHandle,
&gEfiTcp4ServiceBindingProtocolGuid,
(VOID **)&mTcpServiceBinding,
gImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Open TCP Service Binding: %r\n", Status));
return Status;
@@ -362,13 +368,13 @@ TcpFastbootTransportStart (
}
Status = gBS->OpenProtocol (
mTcpHandle,
&gEfiTcp4ProtocolGuid,
(VOID **) &mTcpListener,
gImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
mTcpHandle,
&gEfiTcp4ProtocolGuid,
(VOID **)&mTcpListener,
gImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Open TCP Protocol: %r\n", Status));
}
@@ -378,14 +384,14 @@ TcpFastbootTransportStart (
//
for (Index = 0; Index < NUM_RX_TOKENS; Index++) {
mRxData[Index].UrgentFlag = FALSE;
mRxData[Index].FragmentCount = 1;
mRxData[Index].UrgentFlag = FALSE;
mRxData[Index].FragmentCount = 1;
mReceiveToken[Index].Packet.RxData = &mRxData[Index];
}
mTxData.Push = TRUE;
mTxData.Urgent = FALSE;
mTxData.FragmentCount = 1;
mTxData.Push = TRUE;
mTxData.Urgent = FALSE;
mTxData.FragmentCount = 1;
mTransmitToken.Packet.TxData = &mTxData;
Status = gBS->CreateEvent (
@@ -414,13 +420,17 @@ TcpFastbootTransportStart (
if (Status == EFI_NO_MAPPING) {
// Wait until the IP configuration process (probably DHCP) has finished
do {
Status = mTcpListener->GetModeData (mTcpListener,
NULL, NULL,
Status = mTcpListener->GetModeData (
mTcpListener,
NULL,
NULL,
&Ip4ModeData,
NULL, NULL
NULL,
NULL
);
ASSERT_EFI_ERROR (Status);
} while (!Ip4ModeData.IsConfigured);
Status = mTcpListener->Configure (mTcpListener, &TcpConfigData);
} else if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "TCP Configure: %r\n", Status));
@@ -434,7 +444,7 @@ TcpFastbootTransportStart (
mTextOut->OutputString (mTextOut, L"TCP Fastboot transport configured.");
mTextOut->OutputString (mTextOut, L"\r\nIP address: ");
mTextOut->OutputString (mTextOut ,IpAddrString);
mTextOut->OutputString (mTextOut, IpAddrString);
mTextOut->OutputString (mTextOut, L"\r\n");
//
@@ -462,8 +472,8 @@ TcpFastbootTransportStop (
EFI_TCP4_CLOSE_TOKEN CloseToken;
EFI_STATUS Status;
UINTN EventIndex;
FASTBOOT_TCP_PACKET_LIST *Entry;
FASTBOOT_TCP_PACKET_LIST *NextEntry;
FASTBOOT_TCP_PACKET_LIST *Entry;
FASTBOOT_TCP_PACKET_LIST *NextEntry;
// Close any existing TCP connection, blocking until it's done.
if (mTcpConnection != NULL) {
@@ -494,7 +504,6 @@ TcpFastbootTransportStop (
ASSERT_EFI_ERROR (Status);
}
gBS->CloseEvent (mAcceptToken.CompletionToken.Event);
// Stop listening for connections.
@@ -506,14 +515,15 @@ TcpFastbootTransportStop (
Status = mTcpServiceBinding->DestroyChild (mTcpServiceBinding, mTcpHandle);
// Free any data the user didn't pick up
Entry = (FASTBOOT_TCP_PACKET_LIST *) GetFirstNode (&mPacketListHead);
Entry = (FASTBOOT_TCP_PACKET_LIST *)GetFirstNode (&mPacketListHead);
while (!IsNull (&mPacketListHead, &Entry->Link)) {
NextEntry = (FASTBOOT_TCP_PACKET_LIST *) GetNextNode (&mPacketListHead, &Entry->Link);
NextEntry = (FASTBOOT_TCP_PACKET_LIST *)GetNextNode (&mPacketListHead, &Entry->Link);
RemoveEntryList (&Entry->Link);
if (Entry->Buffer) {
FreePool (Entry->Buffer);
}
FreePool (Entry);
Entry = NextEntry;
@@ -531,16 +541,16 @@ TcpFastbootTransportStop (
STATIC
VOID
DataSent (
EFI_EVENT Event,
VOID *Context
EFI_EVENT Event,
VOID *Context
)
{
EFI_STATUS Status;
EFI_STATUS Status;
Status = mTransmitToken.CompletionToken.Status;
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "TCP Fastboot transmit result: %r\n", Status));
gBS->SignalEvent (*(EFI_EVENT *) Context);
gBS->SignalEvent (*(EFI_EVENT *)Context);
}
FreePool (mTransmitToken.Packet.TxData->FragmentTable[0].FragmentBuffer);
@@ -549,11 +559,11 @@ DataSent (
EFI_STATUS
TcpFastbootTransportSend (
IN UINTN BufferSize,
IN CONST VOID *Buffer,
IN EFI_EVENT *FatalErrorEvent
IN CONST VOID *Buffer,
IN EFI_EVENT *FatalErrorEvent
)
{
EFI_STATUS Status;
EFI_STATUS Status;
if (BufferSize > 512) {
return EFI_INVALID_PARAMETER;
@@ -578,9 +588,9 @@ TcpFastbootTransportSend (
mTxData.FragmentTable[0].FragmentLength = BufferSize;
mTxData.FragmentTable[0].FragmentBuffer = AllocateCopyPool (
BufferSize,
Buffer
);
BufferSize,
Buffer
);
Status = mTcpConnection->Transmit (mTcpConnection, &mTransmitToken);
if (EFI_ERROR (Status)) {
@@ -591,27 +601,26 @@ TcpFastbootTransportSend (
return EFI_SUCCESS;
}
EFI_STATUS
TcpFastbootTransportReceive (
OUT UINTN *BufferSize,
OUT VOID **Buffer
OUT VOID **Buffer
)
{
FASTBOOT_TCP_PACKET_LIST *Entry;
FASTBOOT_TCP_PACKET_LIST *Entry;
if (IsListEmpty (&mPacketListHead)) {
return EFI_NOT_READY;
}
Entry = (FASTBOOT_TCP_PACKET_LIST *) GetFirstNode (&mPacketListHead);
Entry = (FASTBOOT_TCP_PACKET_LIST *)GetFirstNode (&mPacketListHead);
if (Entry->Buffer == NULL) {
// There was an error receiving this packet.
return EFI_DEVICE_ERROR;
}
*Buffer = Entry->Buffer;
*Buffer = Entry->Buffer;
*BufferSize = Entry->BufferSize;
RemoveEntryList (&Entry->Link);
@@ -620,7 +629,7 @@ TcpFastbootTransportReceive (
return EFI_SUCCESS;
}
FASTBOOT_TRANSPORT_PROTOCOL mTransportProtocol = {
FASTBOOT_TRANSPORT_PROTOCOL mTransportProtocol = {
TcpFastbootTransportStart,
TcpFastbootTransportStop,
TcpFastbootTransportSend,
@@ -630,17 +639,16 @@ FASTBOOT_TRANSPORT_PROTOCOL mTransportProtocol = {
EFI_STATUS
TcpFastbootTransportEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_STATUS Status;
Status = gBS->LocateProtocol(
&gEfiSimpleTextOutProtocolGuid,
NULL,
(VOID **) &mTextOut
);
Status = gBS->LocateProtocol (
&gEfiSimpleTextOutProtocolGuid,
NULL,
(VOID **)&mTextOut
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Fastboot: Open Text Output Protocol: %r\n", Status));
return Status;

View File

@@ -21,45 +21,44 @@
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiDriverEntryPoint.h>
STATIC USB_DEVICE_PROTOCOL *mUsbDevice;
STATIC USB_DEVICE_PROTOCOL *mUsbDevice;
// Configuration attributes:
// bit 7 reserved and must be 1, bit 6 means self-powered.
#define CONFIG_DESC_ATTRIBUTES (BIT7 | BIT6)
#define CONFIG_DESC_ATTRIBUTES (BIT7 | BIT6)
#define MAX_PACKET_SIZE_BULK 512
#define MAX_PACKET_SIZE_BULK 512
STATIC USB_DEVICE_PROTOCOL *mUsbDevice;
STATIC EFI_EVENT mReceiveEvent = NULL;
STATIC LIST_ENTRY mPacketList;
STATIC EFI_EVENT mReceiveEvent = NULL;
STATIC LIST_ENTRY mPacketList;
// List type for queued received packets
typedef struct _FASTBOOT_USB_PACKET_LIST {
LIST_ENTRY Link;
VOID *Buffer;
UINTN BufferSize;
LIST_ENTRY Link;
VOID *Buffer;
UINTN BufferSize;
} FASTBOOT_USB_PACKET_LIST;
/*
No string descriptors - all string descriptor members are set to 0
*/
STATIC USB_DEVICE_DESCRIPTOR mDeviceDescriptor = {
sizeof (USB_DEVICE_DESCRIPTOR), //Length
USB_DESC_TYPE_DEVICE, //DescriptorType
0x0200, //BcdUSB
0xFF, //DeviceClass
0, //DeviceSubClass
0, //DeviceProtocol
64, //MaxPacketSize0
FixedPcdGet32 (PcdAndroidFastbootUsbVendorId), //IdVendor
FixedPcdGet32 (PcdAndroidFastbootUsbProductId), //IdProduct
0, //BcdDevice
0, //StrManufacturer
0, //StrProduct
0, //StrSerialNumber
1 //NumConfigurations
STATIC USB_DEVICE_DESCRIPTOR mDeviceDescriptor = {
sizeof (USB_DEVICE_DESCRIPTOR), // Length
USB_DESC_TYPE_DEVICE, // DescriptorType
0x0200, // BcdUSB
0xFF, // DeviceClass
0, // DeviceSubClass
0, // DeviceProtocol
64, // MaxPacketSize0
FixedPcdGet32 (PcdAndroidFastbootUsbVendorId), // IdVendor
FixedPcdGet32 (PcdAndroidFastbootUsbProductId), // IdProduct
0, // BcdDevice
0, // StrManufacturer
0, // StrProduct
0, // StrSerialNumber
1 // NumConfigurations
};
/*
@@ -71,69 +70,69 @@ STATIC USB_DEVICE_DESCRIPTOR mDeviceDescriptor = {
#pragma pack(1)
typedef struct {
USB_CONFIG_DESCRIPTOR ConfigDescriptor;
USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
USB_ENDPOINT_DESCRIPTOR EndpointDescriptor1;
USB_ENDPOINT_DESCRIPTOR EndpointDescriptor2;
USB_CONFIG_DESCRIPTOR ConfigDescriptor;
USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
USB_ENDPOINT_DESCRIPTOR EndpointDescriptor1;
USB_ENDPOINT_DESCRIPTOR EndpointDescriptor2;
} GET_CONFIG_DESCRIPTOR_RESPONSE;
#pragma pack()
STATIC GET_CONFIG_DESCRIPTOR_RESPONSE mGetConfigDescriptorResponse = {
{ // USB_CONFIG_DESCRIPTOR
sizeof (USB_CONFIG_DESCRIPTOR), //Length;
USB_DESC_TYPE_CONFIG, //DescriptorType;
sizeof (GET_CONFIG_DESCRIPTOR_RESPONSE), //TotalLength;
1, //NumInterfaces;
1, //ConfigurationValue;
0, //Configuration;
CONFIG_DESC_ATTRIBUTES, //Attributes;
0 //MaxPower;
STATIC GET_CONFIG_DESCRIPTOR_RESPONSE mGetConfigDescriptorResponse = {
{ // USB_CONFIG_DESCRIPTOR
sizeof (USB_CONFIG_DESCRIPTOR), // Length;
USB_DESC_TYPE_CONFIG, // DescriptorType;
sizeof (GET_CONFIG_DESCRIPTOR_RESPONSE), // TotalLength;
1, // NumInterfaces;
1, // ConfigurationValue;
0, // Configuration;
CONFIG_DESC_ATTRIBUTES, // Attributes;
0 // MaxPower;
},
{ // USB_INTERFACE_DESCRIPTOR
sizeof (USB_INTERFACE_DESCRIPTOR), //Length;
USB_DESC_TYPE_INTERFACE, //DescriptorType;
0, //InterfaceNumber;
0, //AlternateSetting;
2, //NumEndpoints;
0xFF, //InterfaceClass;
{ // USB_INTERFACE_DESCRIPTOR
sizeof (USB_INTERFACE_DESCRIPTOR), // Length;
USB_DESC_TYPE_INTERFACE, // DescriptorType;
0, // InterfaceNumber;
0, // AlternateSetting;
2, // NumEndpoints;
0xFF, // InterfaceClass;
// Vendor specific interface subclass and protocol codes.
// I found these values in the Fastboot code
// (in match_fastboot_with_serial in fastboot.c).
0x42, //InterfaceSubClass;
0x03, //InterfaceProtocol;
0 //Interface;
0x42, // InterfaceSubClass;
0x03, // InterfaceProtocol;
0 // Interface;
},
{ // USB_ENDPOINT_DESCRIPTOR (In Endpoint)
sizeof (USB_ENDPOINT_DESCRIPTOR), //Length;
USB_DESC_TYPE_ENDPOINT, //DescriptorType;
1 | BIT7, //EndpointAddress;
0x2, //Attributes;
MAX_PACKET_SIZE_BULK, //MaxPacketSize;
16 //Interval;
{ // USB_ENDPOINT_DESCRIPTOR (In Endpoint)
sizeof (USB_ENDPOINT_DESCRIPTOR), // Length;
USB_DESC_TYPE_ENDPOINT, // DescriptorType;
1 | BIT7, // EndpointAddress;
0x2, // Attributes;
MAX_PACKET_SIZE_BULK, // MaxPacketSize;
16 // Interval;
},
{ // STATIC USB_ENDPOINT_DESCRIPTOR (Out Endpoint)
sizeof (USB_ENDPOINT_DESCRIPTOR), //Length;
USB_DESC_TYPE_ENDPOINT, //DescriptorType;
1, //EndpointAddress;
0x2, //Attributes;
MAX_PACKET_SIZE_BULK, //MaxPacketSize;
16 //Interval;
{ // STATIC USB_ENDPOINT_DESCRIPTOR (Out Endpoint)
sizeof (USB_ENDPOINT_DESCRIPTOR), // Length;
USB_DESC_TYPE_ENDPOINT, // DescriptorType;
1, // EndpointAddress;
0x2, // Attributes;
MAX_PACKET_SIZE_BULK, // MaxPacketSize;
16 // Interval;
}
};
STATIC
VOID
DataReceived (
IN UINTN Size,
IN VOID *Buffer
IN UINTN Size,
IN VOID *Buffer
)
{
FASTBOOT_USB_PACKET_LIST *NewEntry;
FASTBOOT_USB_PACKET_LIST *NewEntry;
NewEntry = AllocatePool (sizeof (*NewEntry));
ASSERT (NewEntry != NULL);
NewEntry->Buffer = Buffer;
NewEntry->Buffer = Buffer;
NewEntry->BufferSize = Size;
InsertTailList (&mPacketList, &NewEntry->Link);
@@ -146,7 +145,7 @@ DataReceived (
STATIC
VOID
DataSent (
IN UINT8 EndpointIndex
IN UINT8 EndpointIndex
)
{
// Don't care.
@@ -158,7 +157,7 @@ DataSent (
*/
EFI_STATUS
FastbootTransportUsbStart (
EFI_EVENT ReceiveEvent
EFI_EVENT ReceiveEvent
)
{
GET_CONFIG_DESCRIPTOR_RESPONSE *Responses;
@@ -166,11 +165,11 @@ FastbootTransportUsbStart (
mReceiveEvent = ReceiveEvent;
mGetConfigDescriptorResponse.ConfigDescriptor.TotalLength = sizeof (GET_CONFIG_DESCRIPTOR_RESPONSE);
Responses = &mGetConfigDescriptorResponse;
Responses = &mGetConfigDescriptorResponse;
InitializeListHead (&mPacketList);
return mUsbDevice->Start (&mDeviceDescriptor, (VOID **) &Responses, DataReceived, DataSent);
return mUsbDevice->Start (&mDeviceDescriptor, (VOID **)&Responses, DataReceived, DataSent);
}
/*
@@ -196,12 +195,12 @@ FastbootTransportUsbStop (
EFI_STATUS
FastbootTransportUsbSend (
IN UINTN BufferSize,
IN CONST VOID *Buffer,
IN EFI_EVENT *FatalErrorEvent
IN CONST VOID *Buffer,
IN EFI_EVENT *FatalErrorEvent
)
{
// Current USB protocol is blocking, so ignore FatalErrorEvent
return mUsbDevice->Send(1, BufferSize, Buffer);
return mUsbDevice->Send (1, BufferSize, Buffer);
}
/*
@@ -221,19 +220,19 @@ FastbootTransportUsbSend (
EFI_STATUS
FastbootTransportUsbReceive (
OUT UINTN *BufferSize,
OUT VOID **Buffer
OUT VOID **Buffer
)
{
FASTBOOT_USB_PACKET_LIST *Entry;
FASTBOOT_USB_PACKET_LIST *Entry;
if (IsListEmpty (&mPacketList)) {
return EFI_NOT_READY;
}
Entry = (FASTBOOT_USB_PACKET_LIST *) GetFirstNode (&mPacketList);
Entry = (FASTBOOT_USB_PACKET_LIST *)GetFirstNode (&mPacketList);
*BufferSize = Entry->BufferSize;
*Buffer = Entry->Buffer;
*Buffer = Entry->Buffer;
RemoveEntryList (&Entry->Link);
FreePool (Entry);
@@ -241,7 +240,7 @@ FastbootTransportUsbReceive (
return EFI_SUCCESS;
}
STATIC FASTBOOT_TRANSPORT_PROTOCOL mTransportProtocol = {
STATIC FASTBOOT_TRANSPORT_PROTOCOL mTransportProtocol = {
FastbootTransportUsbStart,
FastbootTransportUsbStop,
FastbootTransportUsbSend,
@@ -251,13 +250,13 @@ STATIC FASTBOOT_TRANSPORT_PROTOCOL mTransportProtocol = {
EFI_STATUS
FastbootTransportUsbEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_STATUS Status;
// Assume there's only one USB peripheral controller.
Status = gBS->LocateProtocol (&gUsbDeviceProtocolGuid, NULL, (VOID **) &mUsbDevice);
Status = gBS->LocateProtocol (&gUsbDeviceProtocolGuid, NULL, (VOID **)&mUsbDevice);
if (EFI_ERROR (Status)) {
return Status;
}

View File

@@ -24,24 +24,24 @@
#include "ConsolePrefDxe.h"
#define SPCR_SIG EFI_ACPI_2_0_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE
#define SPCR_SIG EFI_ACPI_2_0_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE
extern UINT8 ConsolePrefHiiBin[];
extern UINT8 ConsolePrefDxeStrings[];
extern UINT8 ConsolePrefHiiBin[];
extern UINT8 ConsolePrefDxeStrings[];
typedef struct {
VENDOR_DEVICE_PATH VendorDevicePath;
EFI_DEVICE_PATH_PROTOCOL End;
VENDOR_DEVICE_PATH VendorDevicePath;
EFI_DEVICE_PATH_PROTOCOL End;
} HII_VENDOR_DEVICE_PATH;
STATIC HII_VENDOR_DEVICE_PATH mConsolePrefDxeVendorDevicePath = {
STATIC HII_VENDOR_DEVICE_PATH mConsolePrefDxeVendorDevicePath = {
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
(UINT8) (sizeof (VENDOR_DEVICE_PATH)),
(UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
(UINT8)(sizeof (VENDOR_DEVICE_PATH)),
(UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
CONSOLE_PREF_FORMSET_GUID
@@ -50,13 +50,13 @@ STATIC HII_VENDOR_DEVICE_PATH mConsolePrefDxeVendorDevicePath = {
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
(UINT8) (END_DEVICE_PATH_LENGTH),
(UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)
(UINT8)(END_DEVICE_PATH_LENGTH),
(UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
}
}
};
STATIC EFI_EVENT mReadyToBootEvent;
STATIC EFI_EVENT mReadyToBootEvent;
STATIC
EFI_STATUS
@@ -64,32 +64,39 @@ InstallHiiPages (
VOID
)
{
EFI_STATUS Status;
EFI_HII_HANDLE HiiHandle;
EFI_HANDLE DriverHandle;
EFI_STATUS Status;
EFI_HII_HANDLE HiiHandle;
EFI_HANDLE DriverHandle;
DriverHandle = NULL;
Status = gBS->InstallMultipleProtocolInterfaces (&DriverHandle,
&gEfiDevicePathProtocolGuid,
&mConsolePrefDxeVendorDevicePath,
NULL);
Status = gBS->InstallMultipleProtocolInterfaces (
&DriverHandle,
&gEfiDevicePathProtocolGuid,
&mConsolePrefDxeVendorDevicePath,
NULL
);
if (EFI_ERROR (Status)) {
return Status;
}
HiiHandle = HiiAddPackages (&gConsolePrefFormSetGuid,
DriverHandle,
ConsolePrefDxeStrings,
ConsolePrefHiiBin,
NULL);
HiiHandle = HiiAddPackages (
&gConsolePrefFormSetGuid,
DriverHandle,
ConsolePrefDxeStrings,
ConsolePrefHiiBin,
NULL
);
if (HiiHandle == NULL) {
gBS->UninstallMultipleProtocolInterfaces (DriverHandle,
gBS->UninstallMultipleProtocolInterfaces (
DriverHandle,
&gEfiDevicePathProtocolGuid,
&mConsolePrefDxeVendorDevicePath,
NULL);
NULL
);
return EFI_OUT_OF_RESOURCES;
}
return EFI_SUCCESS;
}
@@ -97,7 +104,7 @@ STATIC
VOID
RemoveDtStdoutPath (
VOID
)
)
{
VOID *Dtb;
INT32 Node;
@@ -106,8 +113,12 @@ RemoveDtStdoutPath (
Status = EfiGetSystemConfigurationTable (&gFdtTableGuid, &Dtb);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "%a: could not retrieve DT blob - %r\n", __FUNCTION__,
Status));
DEBUG ((
DEBUG_INFO,
"%a: could not retrieve DT blob - %r\n",
__FUNCTION__,
Status
));
return;
}
@@ -118,8 +129,12 @@ RemoveDtStdoutPath (
Error = fdt_delprop (Dtb, Node, "stdout-path");
if (Error) {
DEBUG ((DEBUG_INFO, "%a: Failed to delete 'stdout-path' property: %a\n",
__FUNCTION__, fdt_strerror (Error)));
DEBUG ((
DEBUG_INFO,
"%a: Failed to delete 'stdout-path' property: %a\n",
__FUNCTION__,
fdt_strerror (Error)
));
}
}
@@ -129,16 +144,19 @@ RemoveSpcrTable (
VOID
)
{
EFI_ACPI_SDT_PROTOCOL *Sdt;
EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
EFI_STATUS Status;
UINTN TableIndex;
EFI_ACPI_SDT_HEADER *TableHeader;
EFI_ACPI_TABLE_VERSION TableVersion;
UINTN TableKey;
EFI_ACPI_SDT_PROTOCOL *Sdt;
EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
EFI_STATUS Status;
UINTN TableIndex;
EFI_ACPI_SDT_HEADER *TableHeader;
EFI_ACPI_TABLE_VERSION TableVersion;
UINTN TableKey;
Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL,
(VOID **)&AcpiTable);
Status = gBS->LocateProtocol (
&gEfiAcpiTableProtocolGuid,
NULL,
(VOID **)&AcpiTable
);
if (EFI_ERROR (Status)) {
return;
}
@@ -153,8 +171,12 @@ RemoveSpcrTable (
TableHeader = NULL;
do {
Status = Sdt->GetAcpiTable (TableIndex++, &TableHeader, &TableVersion,
&TableKey);
Status = Sdt->GetAcpiTable (
TableIndex++,
&TableHeader,
&TableVersion,
&TableKey
);
if (EFI_ERROR (Status)) {
break;
}
@@ -165,9 +187,14 @@ RemoveSpcrTable (
Status = AcpiTable->UninstallAcpiTable (AcpiTable, TableKey);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_WARN, "%a: failed to uninstall SPCR table - %r\n",
__FUNCTION__, Status));
DEBUG ((
DEBUG_WARN,
"%a: failed to uninstall SPCR table - %r\n",
__FUNCTION__,
Status
));
}
break;
} while (TRUE);
}
@@ -180,24 +207,35 @@ OnReadyToBoot (
IN VOID *Context
)
{
CONSOLE_PREF_VARSTORE_DATA ConsolePref;
UINTN BufferSize;
EFI_STATUS Status;
VOID *Gop;
CONSOLE_PREF_VARSTORE_DATA ConsolePref;
UINTN BufferSize;
EFI_STATUS Status;
VOID *Gop;
BufferSize = sizeof (ConsolePref);
Status = gRT->GetVariable (CONSOLE_PREF_VARIABLE_NAME,
&gConsolePrefFormSetGuid, NULL, &BufferSize, &ConsolePref);
Status = gRT->GetVariable (
CONSOLE_PREF_VARIABLE_NAME,
&gConsolePrefFormSetGuid,
NULL,
&BufferSize,
&ConsolePref
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR,
"%a: variable '%s' could not be read - bailing!\n", __FUNCTION__,
CONSOLE_PREF_VARIABLE_NAME));
DEBUG ((
DEBUG_ERROR,
"%a: variable '%s' could not be read - bailing!\n",
__FUNCTION__,
CONSOLE_PREF_VARIABLE_NAME
));
return;
}
if (ConsolePref.Console == CONSOLE_PREF_SERIAL) {
DEBUG ((DEBUG_INFO,
"%a: serial console preferred - doing nothing\n", __FUNCTION__));
DEBUG ((
DEBUG_INFO,
"%a: serial console preferred - doing nothing\n",
__FUNCTION__
));
return;
}
@@ -206,9 +244,12 @@ OnReadyToBoot (
//
Status = gBS->LocateProtocol (&gEfiGraphicsOutputProtocolGuid, NULL, &Gop);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO,
"%a: no GOP instances found - doing nothing (%r)\n", __FUNCTION__,
Status));
DEBUG ((
DEBUG_INFO,
"%a: no GOP instances found - doing nothing (%r)\n",
__FUNCTION__,
Status
));
return;
}
@@ -232,34 +273,46 @@ OnReadyToBoot (
EFI_STATUS
EFIAPI
ConsolePrefDxeEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
CONSOLE_PREF_VARSTORE_DATA ConsolePref;
UINTN BufferSize;
EFI_STATUS Status;
CONSOLE_PREF_VARSTORE_DATA ConsolePref;
UINTN BufferSize;
//
// Get the current console preference from the ConsolePref variable.
//
BufferSize = sizeof (ConsolePref);
Status = gRT->GetVariable (CONSOLE_PREF_VARIABLE_NAME,
&gConsolePrefFormSetGuid, NULL, &BufferSize, &ConsolePref);
Status = gRT->GetVariable (
CONSOLE_PREF_VARIABLE_NAME,
&gConsolePrefFormSetGuid,
NULL,
&BufferSize,
&ConsolePref
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO,
DEBUG ((
DEBUG_INFO,
"%a: no console preference found, defaulting to graphical\n",
__FUNCTION__));
__FUNCTION__
));
ConsolePref.Console = CONSOLE_PREF_GRAPHICAL;
}
if (!EFI_ERROR (Status) &&
ConsolePref.Console != CONSOLE_PREF_GRAPHICAL &&
ConsolePref.Console != CONSOLE_PREF_SERIAL) {
DEBUG ((DEBUG_WARN, "%a: invalid value for %s, defaulting to graphical\n",
__FUNCTION__, CONSOLE_PREF_VARIABLE_NAME));
(ConsolePref.Console != CONSOLE_PREF_GRAPHICAL) &&
(ConsolePref.Console != CONSOLE_PREF_SERIAL))
{
DEBUG ((
DEBUG_WARN,
"%a: invalid value for %s, defaulting to graphical\n",
__FUNCTION__,
CONSOLE_PREF_VARIABLE_NAME
));
ConsolePref.Console = CONSOLE_PREF_GRAPHICAL;
Status = EFI_INVALID_PARAMETER; // trigger setvar below
Status = EFI_INVALID_PARAMETER; // trigger setvar below
}
//
@@ -267,21 +320,33 @@ ConsolePrefDxeEntryPoint (
//
if (EFI_ERROR (Status)) {
ZeroMem (&ConsolePref.Reserved, sizeof (ConsolePref.Reserved));
Status = gRT->SetVariable (CONSOLE_PREF_VARIABLE_NAME,
Status = gRT->SetVariable (
CONSOLE_PREF_VARIABLE_NAME,
&gConsolePrefFormSetGuid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
sizeof (ConsolePref), &ConsolePref);
sizeof (ConsolePref),
&ConsolePref
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: gRT->SetVariable () failed - %r\n",
__FUNCTION__, Status));
DEBUG ((
DEBUG_ERROR,
"%a: gRT->SetVariable () failed - %r\n",
__FUNCTION__,
Status
));
return Status;
}
}
Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_CALLBACK,
OnReadyToBoot, NULL, &gEfiEventReadyToBootGuid,
&mReadyToBootEvent);
Status = gBS->CreateEventEx (
EVT_NOTIFY_SIGNAL,
TPL_CALLBACK,
OnReadyToBoot,
NULL,
&gEfiEventReadyToBootGuid,
&mReadyToBootEvent
);
ASSERT_EFI_ERROR (Status);
return InstallHiiPages ();

View File

@@ -12,14 +12,14 @@
#include <Guid/HiiPlatformSetupFormset.h>
#include <Guid/ConsolePrefFormSet.h>
#define CONSOLE_PREF_GRAPHICAL 0x0
#define CONSOLE_PREF_SERIAL 0x1
#define CONSOLE_PREF_GRAPHICAL 0x0
#define CONSOLE_PREF_SERIAL 0x1
#define CONSOLE_PREF_VARIABLE_NAME L"ConsolePref"
typedef struct {
UINT8 Console;
UINT8 Reserved[3];
UINT8 Console;
UINT8 Reserved[3];
} CONSOLE_PREF_VARSTORE_DATA;
#endif

View File

@@ -18,22 +18,22 @@
#include "DtPlatformDxe.h"
extern UINT8 DtPlatformHiiBin[];
extern UINT8 DtPlatformDxeStrings[];
extern UINT8 DtPlatformHiiBin[];
extern UINT8 DtPlatformDxeStrings[];
typedef struct {
VENDOR_DEVICE_PATH VendorDevicePath;
EFI_DEVICE_PATH_PROTOCOL End;
VENDOR_DEVICE_PATH VendorDevicePath;
EFI_DEVICE_PATH_PROTOCOL End;
} HII_VENDOR_DEVICE_PATH;
STATIC HII_VENDOR_DEVICE_PATH mDtPlatformDxeVendorDevicePath = {
STATIC HII_VENDOR_DEVICE_PATH mDtPlatformDxeVendorDevicePath = {
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
(UINT8) (sizeof (VENDOR_DEVICE_PATH)),
(UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
(UINT8)(sizeof (VENDOR_DEVICE_PATH)),
(UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
DT_PLATFORM_FORMSET_GUID
@@ -42,8 +42,8 @@ STATIC HII_VENDOR_DEVICE_PATH mDtPlatformDxeVendorDevicePath = {
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
(UINT8) (END_DEVICE_PATH_LENGTH),
(UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)
(UINT8)(END_DEVICE_PATH_LENGTH),
(UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
}
}
};
@@ -54,32 +54,39 @@ InstallHiiPages (
VOID
)
{
EFI_STATUS Status;
EFI_HII_HANDLE HiiHandle;
EFI_HANDLE DriverHandle;
EFI_STATUS Status;
EFI_HII_HANDLE HiiHandle;
EFI_HANDLE DriverHandle;
DriverHandle = NULL;
Status = gBS->InstallMultipleProtocolInterfaces (&DriverHandle,
&gEfiDevicePathProtocolGuid,
&mDtPlatformDxeVendorDevicePath,
NULL);
Status = gBS->InstallMultipleProtocolInterfaces (
&DriverHandle,
&gEfiDevicePathProtocolGuid,
&mDtPlatformDxeVendorDevicePath,
NULL
);
if (EFI_ERROR (Status)) {
return Status;
}
HiiHandle = HiiAddPackages (&gDtPlatformFormSetGuid,
DriverHandle,
DtPlatformDxeStrings,
DtPlatformHiiBin,
NULL);
HiiHandle = HiiAddPackages (
&gDtPlatformFormSetGuid,
DriverHandle,
DtPlatformDxeStrings,
DtPlatformHiiBin,
NULL
);
if (HiiHandle == NULL) {
gBS->UninstallMultipleProtocolInterfaces (DriverHandle,
&gEfiDevicePathProtocolGuid,
&mDtPlatformDxeVendorDevicePath,
NULL);
gBS->UninstallMultipleProtocolInterfaces (
DriverHandle,
&gEfiDevicePathProtocolGuid,
&mDtPlatformDxeVendorDevicePath,
NULL
);
return EFI_OUT_OF_RESOURCES;
}
return EFI_SUCCESS;
}
@@ -99,44 +106,61 @@ InstallHiiPages (
EFI_STATUS
EFIAPI
DtPlatformDxeEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
DT_ACPI_VARSTORE_DATA DtAcpiPref;
UINTN BufferSize;
VOID *Dtb;
UINTN DtbSize;
EFI_STATUS Status;
DT_ACPI_VARSTORE_DATA DtAcpiPref;
UINTN BufferSize;
VOID *Dtb;
UINTN DtbSize;
Dtb = NULL;
Dtb = NULL;
Status = DtPlatformLoadDtb (&Dtb, &DtbSize);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_WARN,
DEBUG ((
DEBUG_WARN,
"%a: no DTB blob could be loaded, defaulting to ACPI (Status == %r)\n",
__FUNCTION__, Status));
__FUNCTION__,
Status
));
DtAcpiPref.Pref = DT_ACPI_SELECT_ACPI;
} else {
//
// Get the current DT/ACPI preference from the DtAcpiPref variable.
//
BufferSize = sizeof (DtAcpiPref);
Status = gRT->GetVariable(DT_ACPI_VARIABLE_NAME, &gDtPlatformFormSetGuid,
NULL, &BufferSize, &DtAcpiPref);
Status = gRT->GetVariable (
DT_ACPI_VARIABLE_NAME,
&gDtPlatformFormSetGuid,
NULL,
&BufferSize,
&DtAcpiPref
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_WARN, "%a: no DT/ACPI preference found, defaulting to %a\n",
__FUNCTION__, PcdGetBool (PcdDefaultDtPref) ? "DT" : "ACPI"));
DEBUG ((
DEBUG_WARN,
"%a: no DT/ACPI preference found, defaulting to %a\n",
__FUNCTION__,
PcdGetBool (PcdDefaultDtPref) ? "DT" : "ACPI"
));
DtAcpiPref.Pref = PcdGetBool (PcdDefaultDtPref) ? DT_ACPI_SELECT_DT
: DT_ACPI_SELECT_ACPI;
}
}
if (!EFI_ERROR (Status) &&
DtAcpiPref.Pref != DT_ACPI_SELECT_ACPI &&
DtAcpiPref.Pref != DT_ACPI_SELECT_DT) {
DEBUG ((DEBUG_WARN, "%a: invalid value for %s, defaulting to %a\n",
__FUNCTION__, DT_ACPI_VARIABLE_NAME,
PcdGetBool (PcdDefaultDtPref) ? "DT" : "ACPI"));
(DtAcpiPref.Pref != DT_ACPI_SELECT_ACPI) &&
(DtAcpiPref.Pref != DT_ACPI_SELECT_DT))
{
DEBUG ((
DEBUG_WARN,
"%a: invalid value for %s, defaulting to %a\n",
__FUNCTION__,
DT_ACPI_VARIABLE_NAME,
PcdGetBool (PcdDefaultDtPref) ? "DT" : "ACPI"
));
DtAcpiPref.Pref = PcdGetBool (PcdDefaultDtPref) ? DT_ACPI_SELECT_DT
: DT_ACPI_SELECT_ACPI;
Status = EFI_INVALID_PARAMETER; // trigger setvar below
@@ -146,9 +170,13 @@ DtPlatformDxeEntryPoint (
// Write the newly selected default value back to the variable store.
//
if (EFI_ERROR (Status)) {
Status = gRT->SetVariable(DT_ACPI_VARIABLE_NAME, &gDtPlatformFormSetGuid,
Status = gRT->SetVariable (
DT_ACPI_VARIABLE_NAME,
&gDtPlatformFormSetGuid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
sizeof (DtAcpiPref), &DtAcpiPref);
sizeof (DtAcpiPref),
&DtAcpiPref
);
if (EFI_ERROR (Status)) {
goto FreeDtb;
}
@@ -159,12 +187,18 @@ DtPlatformDxeEntryPoint (
// ACPI was selected: install the gEdkiiPlatformHasAcpiGuid GUID as a
// NULL protocol to unlock dispatch of ACPI related drivers.
//
Status = gBS->InstallMultipleProtocolInterfaces (&ImageHandle,
&gEdkiiPlatformHasAcpiGuid, NULL, NULL);
Status = gBS->InstallMultipleProtocolInterfaces (
&ImageHandle,
&gEdkiiPlatformHasAcpiGuid,
NULL,
NULL
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR,
DEBUG ((
DEBUG_ERROR,
"%a: failed to install gEdkiiPlatformHasAcpiGuid as a protocol\n",
__FUNCTION__));
__FUNCTION__
));
goto FreeDtb;
}
} else if (DtAcpiPref.Pref == DT_ACPI_SELECT_DT) {
@@ -174,8 +208,11 @@ DtPlatformDxeEntryPoint (
//
Status = gBS->InstallConfigurationTable (&gFdtTableGuid, Dtb);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: failed to install FDT configuration table\n",
__FUNCTION__));
DEBUG ((
DEBUG_ERROR,
"%a: failed to install FDT configuration table\n",
__FUNCTION__
));
goto FreeDtb;
}
} else {

View File

@@ -12,14 +12,14 @@
#include <Guid/HiiPlatformSetupFormset.h>
#include <Guid/DtPlatformFormSet.h>
#define DT_ACPI_SELECT_DT 0x0
#define DT_ACPI_SELECT_ACPI 0x1
#define DT_ACPI_SELECT_DT 0x0
#define DT_ACPI_SELECT_ACPI 0x1
#define DT_ACPI_VARIABLE_NAME L"DtAcpiPref"
#define DT_ACPI_VARIABLE_NAME L"DtAcpiPref"
typedef struct {
UINT8 Pref;
UINT8 Reserved[3];
UINT8 Pref;
UINT8 Reserved[3];
} DT_ACPI_VARSTORE_DATA;
#endif

View File

@@ -26,14 +26,14 @@ STATIC
EFI_STATUS
EFIAPI
GetNodeProperty (
IN FDT_CLIENT_PROTOCOL *This,
IN INT32 Node,
IN CONST CHAR8 *PropertyName,
OUT CONST VOID **Prop,
OUT UINT32 *PropSize OPTIONAL
IN FDT_CLIENT_PROTOCOL *This,
IN INT32 Node,
IN CONST CHAR8 *PropertyName,
OUT CONST VOID **Prop,
OUT UINT32 *PropSize OPTIONAL
)
{
INT32 Len;
INT32 Len;
ASSERT (mDeviceTreeBase != NULL);
ASSERT (Prop != NULL);
@@ -46,6 +46,7 @@ GetNodeProperty (
if (PropSize != NULL) {
*PropSize = Len;
}
return EFI_SUCCESS;
}
@@ -53,14 +54,14 @@ STATIC
EFI_STATUS
EFIAPI
SetNodeProperty (
IN FDT_CLIENT_PROTOCOL *This,
IN INT32 Node,
IN CONST CHAR8 *PropertyName,
IN CONST VOID *Prop,
IN UINT32 PropSize
IN FDT_CLIENT_PROTOCOL *This,
IN INT32 Node,
IN CONST CHAR8 *PropertyName,
IN CONST VOID *Prop,
IN UINT32 PropSize
)
{
INT32 Ret;
INT32 Ret;
ASSERT (mDeviceTreeBase != NULL);
@@ -75,11 +76,11 @@ SetNodeProperty (
STATIC
BOOLEAN
IsNodeEnabled (
INT32 Node
INT32 Node
)
{
CONST CHAR8 *NodeStatus;
INT32 Len;
CONST CHAR8 *NodeStatus;
INT32 Len;
//
// A missing status property implies 'ok' so ignore any errors that
@@ -90,12 +91,15 @@ IsNodeEnabled (
if (NodeStatus == NULL) {
return TRUE;
}
if (Len >= 5 && AsciiStrCmp (NodeStatus, "okay") == 0) {
if ((Len >= 5) && (AsciiStrCmp (NodeStatus, "okay") == 0)) {
return TRUE;
}
if (Len >= 3 && AsciiStrCmp (NodeStatus, "ok") == 0) {
if ((Len >= 3) && (AsciiStrCmp (NodeStatus, "ok") == 0)) {
return TRUE;
}
return FALSE;
}
@@ -103,20 +107,20 @@ STATIC
EFI_STATUS
EFIAPI
FindNextCompatibleNode (
IN FDT_CLIENT_PROTOCOL *This,
IN CONST CHAR8 *CompatibleString,
IN INT32 PrevNode,
OUT INT32 *Node
IN FDT_CLIENT_PROTOCOL *This,
IN CONST CHAR8 *CompatibleString,
IN INT32 PrevNode,
OUT INT32 *Node
)
{
INT32 Prev, Next;
CONST CHAR8 *Type, *Compatible;
INT32 Len;
INT32 Prev, Next;
CONST CHAR8 *Type, *Compatible;
INT32 Len;
ASSERT (mDeviceTreeBase != NULL);
ASSERT (Node != NULL);
for (Prev = PrevNode;; Prev = Next) {
for (Prev = PrevNode; ; Prev = Next) {
Next = fdt_next_node (mDeviceTreeBase, Prev, NULL);
if (Next < 0) {
break;
@@ -136,13 +140,15 @@ FindNextCompatibleNode (
// compatible strings so check each one
//
for (Compatible = Type; Compatible < Type + Len && *Compatible;
Compatible += 1 + AsciiStrLen (Compatible)) {
Compatible += 1 + AsciiStrLen (Compatible))
{
if (AsciiStrCmp (CompatibleString, Compatible) == 0) {
*Node = Next;
return EFI_SUCCESS;
}
}
}
return EFI_NOT_FOUND;
}
@@ -150,9 +156,9 @@ STATIC
EFI_STATUS
EFIAPI
FindCompatibleNode (
IN FDT_CLIENT_PROTOCOL *This,
IN CONST CHAR8 *CompatibleString,
OUT INT32 *Node
IN FDT_CLIENT_PROTOCOL *This,
IN CONST CHAR8 *CompatibleString,
OUT INT32 *Node
)
{
return FindNextCompatibleNode (This, CompatibleString, 0, Node);
@@ -162,15 +168,15 @@ STATIC
EFI_STATUS
EFIAPI
FindCompatibleNodeProperty (
IN FDT_CLIENT_PROTOCOL *This,
IN CONST CHAR8 *CompatibleString,
IN CONST CHAR8 *PropertyName,
OUT CONST VOID **Prop,
OUT UINT32 *PropSize OPTIONAL
IN FDT_CLIENT_PROTOCOL *This,
IN CONST CHAR8 *CompatibleString,
IN CONST CHAR8 *PropertyName,
OUT CONST VOID **Prop,
OUT UINT32 *PropSize OPTIONAL
)
{
EFI_STATUS Status;
INT32 Node;
EFI_STATUS Status;
INT32 Node;
Status = FindCompatibleNode (This, CompatibleString, &Node);
if (EFI_ERROR (Status)) {
@@ -184,15 +190,15 @@ STATIC
EFI_STATUS
EFIAPI
FindCompatibleNodeReg (
IN FDT_CLIENT_PROTOCOL *This,
IN CONST CHAR8 *CompatibleString,
OUT CONST VOID **Reg,
OUT UINTN *AddressCells,
OUT UINTN *SizeCells,
OUT UINT32 *RegSize
IN FDT_CLIENT_PROTOCOL *This,
IN CONST CHAR8 *CompatibleString,
OUT CONST VOID **Reg,
OUT UINTN *AddressCells,
OUT UINTN *SizeCells,
OUT UINT32 *RegSize
)
{
EFI_STATUS Status;
EFI_STATUS Status;
ASSERT (RegSize != NULL);
@@ -201,21 +207,30 @@ FindCompatibleNodeReg (
// 8 byte quantities for base and size, respectively.
// TODO use #cells root properties instead
//
Status = FindCompatibleNodeProperty (This, CompatibleString, "reg", Reg,
RegSize);
Status = FindCompatibleNodeProperty (
This,
CompatibleString,
"reg",
Reg,
RegSize
);
if (EFI_ERROR (Status)) {
return Status;
}
if ((*RegSize % 16) != 0) {
DEBUG ((DEBUG_ERROR,
DEBUG ((
DEBUG_ERROR,
"%a: '%a' compatible node has invalid 'reg' property (size == 0x%x)\n",
__FUNCTION__, CompatibleString, *RegSize));
__FUNCTION__,
CompatibleString,
*RegSize
));
return EFI_NOT_FOUND;
}
*AddressCells = 2;
*SizeCells = 2;
*SizeCells = 2;
return EFI_SUCCESS;
}
@@ -224,24 +239,24 @@ STATIC
EFI_STATUS
EFIAPI
FindNextMemoryNodeReg (
IN FDT_CLIENT_PROTOCOL *This,
IN INT32 PrevNode,
OUT INT32 *Node,
OUT CONST VOID **Reg,
OUT UINTN *AddressCells,
OUT UINTN *SizeCells,
OUT UINT32 *RegSize
IN FDT_CLIENT_PROTOCOL *This,
IN INT32 PrevNode,
OUT INT32 *Node,
OUT CONST VOID **Reg,
OUT UINTN *AddressCells,
OUT UINTN *SizeCells,
OUT UINT32 *RegSize
)
{
INT32 Prev, Next;
CONST CHAR8 *DeviceType;
INT32 Len;
EFI_STATUS Status;
INT32 Prev, Next;
CONST CHAR8 *DeviceType;
INT32 Len;
EFI_STATUS Status;
ASSERT (mDeviceTreeBase != NULL);
ASSERT (Node != NULL);
for (Prev = PrevNode;; Prev = Next) {
for (Prev = PrevNode; ; Prev = Next) {
Next = fdt_next_node (mDeviceTreeBase, Prev, NULL);
if (Next < 0) {
break;
@@ -253,7 +268,7 @@ FindNextMemoryNodeReg (
}
DeviceType = fdt_getprop (mDeviceTreeBase, Next, "device_type", &Len);
if (DeviceType != NULL && AsciiStrCmp (DeviceType, "memory") == 0) {
if ((DeviceType != NULL) && (AsciiStrCmp (DeviceType, "memory") == 0)) {
//
// Get the 'reg' property of this memory node. For now, we will assume
// 8 byte quantities for base and size, respectively.
@@ -261,24 +276,31 @@ FindNextMemoryNodeReg (
//
Status = GetNodeProperty (This, Next, "reg", Reg, RegSize);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_WARN,
DEBUG ((
DEBUG_WARN,
"%a: ignoring memory node with no 'reg' property\n",
__FUNCTION__));
continue;
}
if ((*RegSize % 16) != 0) {
DEBUG ((DEBUG_WARN,
"%a: ignoring memory node with invalid 'reg' property (size == 0x%x)\n",
__FUNCTION__, *RegSize));
__FUNCTION__
));
continue;
}
*Node = Next;
if ((*RegSize % 16) != 0) {
DEBUG ((
DEBUG_WARN,
"%a: ignoring memory node with invalid 'reg' property (size == 0x%x)\n",
__FUNCTION__,
*RegSize
));
continue;
}
*Node = Next;
*AddressCells = 2;
*SizeCells = 2;
*SizeCells = 2;
return EFI_SUCCESS;
}
}
return EFI_NOT_FOUND;
}
@@ -286,27 +308,34 @@ STATIC
EFI_STATUS
EFIAPI
FindMemoryNodeReg (
IN FDT_CLIENT_PROTOCOL *This,
OUT INT32 *Node,
OUT CONST VOID **Reg,
OUT UINTN *AddressCells,
OUT UINTN *SizeCells,
OUT UINT32 *RegSize
IN FDT_CLIENT_PROTOCOL *This,
OUT INT32 *Node,
OUT CONST VOID **Reg,
OUT UINTN *AddressCells,
OUT UINTN *SizeCells,
OUT UINT32 *RegSize
)
{
return FindNextMemoryNodeReg (This, 0, Node, Reg, AddressCells, SizeCells,
RegSize);
return FindNextMemoryNodeReg (
This,
0,
Node,
Reg,
AddressCells,
SizeCells,
RegSize
);
}
STATIC
EFI_STATUS
EFIAPI
GetOrInsertChosenNode (
IN FDT_CLIENT_PROTOCOL *This,
OUT INT32 *Node
IN FDT_CLIENT_PROTOCOL *This,
OUT INT32 *Node
)
{
INT32 NewNode;
INT32 NewNode;
ASSERT (mDeviceTreeBase != NULL);
ASSERT (Node != NULL);
@@ -325,7 +354,7 @@ GetOrInsertChosenNode (
return EFI_SUCCESS;
}
STATIC FDT_CLIENT_PROTOCOL mFdtClientProtocol = {
STATIC FDT_CLIENT_PROTOCOL mFdtClientProtocol = {
GetNodeProperty,
SetNodeProperty,
FindCompatibleNode,
@@ -341,13 +370,13 @@ STATIC
VOID
EFIAPI
OnPlatformHasDeviceTree (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
)
{
EFI_STATUS Status;
VOID *Interface;
VOID *DeviceTreeBase;
EFI_STATUS Status;
VOID *Interface;
VOID *DeviceTreeBase;
Status = gBS->LocateProtocol (
&gEdkiiPlatformHasDeviceTreeGuid,
@@ -374,25 +403,30 @@ OnPlatformHasDeviceTree (
EFI_STATUS
EFIAPI
InitializeFdtClientDxe (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
VOID *Hob;
VOID *DeviceTreeBase;
EFI_STATUS Status;
EFI_EVENT PlatformHasDeviceTreeEvent;
VOID *Registration;
VOID *Hob;
VOID *DeviceTreeBase;
EFI_STATUS Status;
EFI_EVENT PlatformHasDeviceTreeEvent;
VOID *Registration;
Hob = GetFirstGuidHob (&gFdtHobGuid);
if (Hob == NULL || GET_GUID_HOB_DATA_SIZE (Hob) != sizeof (UINT64)) {
if ((Hob == NULL) || (GET_GUID_HOB_DATA_SIZE (Hob) != sizeof (UINT64))) {
return EFI_NOT_FOUND;
}
DeviceTreeBase = (VOID *)(UINTN)*(UINT64 *)GET_GUID_HOB_DATA (Hob);
if (fdt_check_header (DeviceTreeBase) != 0) {
DEBUG ((DEBUG_ERROR, "%a: No DTB found @ 0x%p\n", __FUNCTION__,
DeviceTreeBase));
DEBUG ((
DEBUG_ERROR,
"%a: No DTB found @ 0x%p\n",
__FUNCTION__,
DeviceTreeBase
));
return EFI_NOT_FOUND;
}

View File

@@ -107,15 +107,15 @@ STATIC
EFI_STATUS
EFIAPI
NonCoherentIoMmuMap (
IN EDKII_IOMMU_PROTOCOL *This,
IN EDKII_IOMMU_OPERATION Operation,
IN VOID *HostAddress,
IN OUT UINTN *NumberOfBytes,
OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
OUT VOID **Mapping
IN EDKII_IOMMU_PROTOCOL *This,
IN EDKII_IOMMU_OPERATION Operation,
IN VOID *HostAddress,
IN OUT UINTN *NumberOfBytes,
OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
OUT VOID **Mapping
)
{
DMA_MAP_OPERATION DmaOperation;
DMA_MAP_OPERATION DmaOperation;
switch (Operation) {
case EdkiiIoMmuOperationBusMasterRead:
@@ -138,8 +138,13 @@ NonCoherentIoMmuMap (
return EFI_INVALID_PARAMETER;
}
return DmaMap (DmaOperation, HostAddress, NumberOfBytes,
DeviceAddress, Mapping);
return DmaMap (
DmaOperation,
HostAddress,
NumberOfBytes,
DeviceAddress,
Mapping
);
}
/**
@@ -158,8 +163,8 @@ STATIC
EFI_STATUS
EFIAPI
NonCoherentIoMmuUnmap (
IN EDKII_IOMMU_PROTOCOL *This,
IN VOID *Mapping
IN EDKII_IOMMU_PROTOCOL *This,
IN VOID *Mapping
)
{
return DmaUnmap (Mapping);
@@ -191,12 +196,12 @@ STATIC
EFI_STATUS
EFIAPI
NonCoherentIoMmuAllocateBuffer (
IN EDKII_IOMMU_PROTOCOL *This,
IN EFI_ALLOCATE_TYPE Type,
IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages,
IN OUT VOID **HostAddress,
IN UINT64 Attributes
IN EDKII_IOMMU_PROTOCOL *This,
IN EFI_ALLOCATE_TYPE Type,
IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages,
IN OUT VOID **HostAddress,
IN UINT64 Attributes
)
{
return DmaAllocateBuffer (MemoryType, Pages, HostAddress);
@@ -219,9 +224,9 @@ STATIC
EFI_STATUS
EFIAPI
NonCoherentIoMmuFreeBuffer (
IN EDKII_IOMMU_PROTOCOL *This,
IN UINTN Pages,
IN VOID *HostAddress
IN EDKII_IOMMU_PROTOCOL *This,
IN UINTN Pages,
IN VOID *HostAddress
)
{
return DmaFreeBuffer (Pages, HostAddress);
@@ -236,15 +241,17 @@ STATIC EDKII_IOMMU_PROTOCOL mNonCoherentIoMmuOps = {
NonCoherentIoMmuFreeBuffer,
};
EFI_STATUS
EFIAPI
NonCoherentIoMmuDxeEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
return gBS->InstallMultipleProtocolInterfaces (&ImageHandle,
&gEdkiiIoMmuProtocolGuid, &mNonCoherentIoMmuOps,
NULL);
return gBS->InstallMultipleProtocolInterfaces (
&ImageHandle,
&gEdkiiIoMmuProtocolGuid,
&mNonCoherentIoMmuOps,
NULL
);
}

View File

@@ -21,14 +21,13 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gVirtualKeyboardCompo
//
// EFI Component Name 2 Protocol
//
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gVirtualKeyboardComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) VirtualKeyboardComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) VirtualKeyboardComponentNameGetControllerName,
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gVirtualKeyboardComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME)VirtualKeyboardComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)VirtualKeyboardComponentNameGetControllerName,
"en"
};
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mVirtualKeyboardDriverNameTable[] = {
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mVirtualKeyboardDriverNameTable[] = {
{
"eng;en",
L"Virtual Keyboard Driver"
@@ -170,11 +169,11 @@ VirtualKeyboardComponentNameGetDriverName (
EFI_STATUS
EFIAPI
VirtualKeyboardComponentNameGetControllerName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
)
{
return EFI_UNSUPPORTED;

View File

@@ -10,13 +10,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _VIRTUAL_KEYBOARD_COMPONENT_NAME_H_
#define _VIRTUAL_KEYBOARD_COMPONENT_NAME_H_
extern EFI_COMPONENT_NAME_PROTOCOL gVirtualKeyboardComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gVirtualKeyboardComponentName2;
//
// EFI Component Name Functions
//
/**
Retrieves a Unicode string that is the user readable name of the driver.
@@ -64,7 +64,6 @@ VirtualKeyboardComponentNameGetDriverName (
OUT CHAR16 **DriverName
);
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
@@ -136,12 +135,11 @@ VirtualKeyboardComponentNameGetDriverName (
EFI_STATUS
EFIAPI
VirtualKeyboardComponentNameGetControllerName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
);
#endif

View File

@@ -13,7 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// RAM Keyboard Driver Binding Protocol Instance
//
EFI_DRIVER_BINDING_PROTOCOL gVirtualKeyboardDriverBinding = {
EFI_DRIVER_BINDING_PROTOCOL gVirtualKeyboardDriverBinding = {
VirtualKeyboardDriverBindingSupported,
VirtualKeyboardDriverBindingStart,
VirtualKeyboardDriverBindingStop,
@@ -45,13 +45,13 @@ VirtualKeyboardDriverBindingSupported (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
EFI_STATUS Status;
PLATFORM_VIRTUAL_KBD_PROTOCOL *PlatformVirtual;
EFI_STATUS Status;
PLATFORM_VIRTUAL_KBD_PROTOCOL *PlatformVirtual;
Status = gBS->OpenProtocol (
Controller,
&gPlatformVirtualKeyboardProtocolGuid,
(VOID **) &PlatformVirtual,
(VOID **)&PlatformVirtual,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -59,6 +59,7 @@ VirtualKeyboardDriverBindingSupported (
if (EFI_ERROR (Status)) {
return Status;
}
gBS->CloseProtocol (
Controller,
&gPlatformVirtualKeyboardProtocolGuid,
@@ -88,14 +89,14 @@ VirtualKeyboardDriverBindingStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
EFI_STATUS Status;
VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
PLATFORM_VIRTUAL_KBD_PROTOCOL *PlatformVirtual;
EFI_STATUS Status;
VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
PLATFORM_VIRTUAL_KBD_PROTOCOL *PlatformVirtual;
Status = gBS->OpenProtocol (
Controller,
&gPlatformVirtualKeyboardProtocolGuid,
(VOID **) &PlatformVirtual,
(VOID **)&PlatformVirtual,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -107,7 +108,7 @@ VirtualKeyboardDriverBindingStart (
//
// Allocate the private device structure
//
VirtualKeyboardPrivate = (VIRTUAL_KEYBOARD_DEV *) AllocateZeroPool (sizeof (VIRTUAL_KEYBOARD_DEV));
VirtualKeyboardPrivate = (VIRTUAL_KEYBOARD_DEV *)AllocateZeroPool (sizeof (VIRTUAL_KEYBOARD_DEV));
if (VirtualKeyboardPrivate == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Done;
@@ -116,20 +117,20 @@ VirtualKeyboardDriverBindingStart (
//
// Initialize the private device structure
//
VirtualKeyboardPrivate->Signature = VIRTUAL_KEYBOARD_DEV_SIGNATURE;
VirtualKeyboardPrivate->Handle = Controller;
VirtualKeyboardPrivate->PlatformVirtual = PlatformVirtual;
VirtualKeyboardPrivate->Queue.Front = 0;
VirtualKeyboardPrivate->Queue.Rear = 0;
VirtualKeyboardPrivate->QueueForNotify.Front = 0;
VirtualKeyboardPrivate->QueueForNotify.Rear = 0;
VirtualKeyboardPrivate->Signature = VIRTUAL_KEYBOARD_DEV_SIGNATURE;
VirtualKeyboardPrivate->Handle = Controller;
VirtualKeyboardPrivate->PlatformVirtual = PlatformVirtual;
VirtualKeyboardPrivate->Queue.Front = 0;
VirtualKeyboardPrivate->Queue.Rear = 0;
VirtualKeyboardPrivate->QueueForNotify.Front = 0;
VirtualKeyboardPrivate->QueueForNotify.Rear = 0;
VirtualKeyboardPrivate->SimpleTextIn.Reset = VirtualKeyboardReset;
VirtualKeyboardPrivate->SimpleTextIn.ReadKeyStroke = VirtualKeyboardReadKeyStroke;
VirtualKeyboardPrivate->SimpleTextInputEx.Reset = VirtualKeyboardResetEx;
VirtualKeyboardPrivate->SimpleTextInputEx.ReadKeyStrokeEx = VirtualKeyboardReadKeyStrokeEx;
VirtualKeyboardPrivate->SimpleTextInputEx.SetState = VirtualKeyboardSetState;
VirtualKeyboardPrivate->SimpleTextInputEx.Reset = VirtualKeyboardResetEx;
VirtualKeyboardPrivate->SimpleTextInputEx.ReadKeyStrokeEx = VirtualKeyboardReadKeyStrokeEx;
VirtualKeyboardPrivate->SimpleTextInputEx.SetState = VirtualKeyboardSetState;
VirtualKeyboardPrivate->SimpleTextInputEx.RegisterKeyNotify = VirtualKeyboardRegisterKeyNotify;
VirtualKeyboardPrivate->SimpleTextInputEx.UnregisterKeyNotify = VirtualKeyboardUnregisterKeyNotify;
@@ -162,6 +163,7 @@ VirtualKeyboardDriverBindingStart (
(VirtualKeyboardPrivate->SimpleTextIn).WaitForKey = NULL;
goto Done;
}
Status = gBS->CreateEvent (
EVT_NOTIFY_WAIT,
TPL_NOTIFY,
@@ -215,13 +217,14 @@ VirtualKeyboardDriverBindingStart (
// Reset the keyboard device
//
Status = VirtualKeyboardPrivate->SimpleTextInputEx.Reset (
&VirtualKeyboardPrivate->SimpleTextInputEx,
FALSE
);
&VirtualKeyboardPrivate->SimpleTextInputEx,
FALSE
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "[KBD]Reset Failed. Status - %r\n", Status));
goto Done;
}
//
// Install protocol interfaces for the keyboard device.
//
@@ -256,6 +259,7 @@ Done:
if (VirtualKeyboardPrivate->TimerEvent != NULL) {
gBS->CloseEvent (VirtualKeyboardPrivate->TimerEvent);
}
FreePool (VirtualKeyboardPrivate);
}
}
@@ -297,7 +301,6 @@ VirtualKeyboardDriverBindingStop (
return EFI_SUCCESS;
}
/**
Enqueue the key.
@@ -310,8 +313,8 @@ VirtualKeyboardDriverBindingStop (
**/
EFI_STATUS
Enqueue (
IN SIMPLE_QUEUE *Queue,
IN EFI_KEY_DATA *KeyData
IN SIMPLE_QUEUE *Queue,
IN EFI_KEY_DATA *KeyData
)
{
if ((Queue->Rear + 1) % QUEUE_MAX_COUNT == Queue->Front) {
@@ -336,8 +339,8 @@ Enqueue (
**/
EFI_STATUS
Dequeue (
IN SIMPLE_QUEUE *Queue,
IN EFI_KEY_DATA *KeyData
IN SIMPLE_QUEUE *Queue,
IN EFI_KEY_DATA *KeyData
)
{
if (Queue->Front == Queue->Rear) {
@@ -345,7 +348,7 @@ Dequeue (
}
CopyMem (KeyData, &Queue->Buffer[Queue->Front], sizeof (EFI_KEY_DATA));
Queue->Front = (Queue->Front + 1) % QUEUE_MAX_COUNT;
Queue->Front = (Queue->Front + 1) % QUEUE_MAX_COUNT;
return EFI_SUCCESS;
}
@@ -361,7 +364,7 @@ Dequeue (
**/
EFI_STATUS
CheckQueue (
IN SIMPLE_QUEUE *Queue
IN SIMPLE_QUEUE *Queue
)
{
if (Queue->Front == Queue->Rear) {
@@ -386,7 +389,7 @@ VirtualKeyboardCheckForKey (
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This
)
{
VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
VirtualKeyboardPrivate = VIRTUAL_KEYBOARD_DEV_FROM_THIS (This);
@@ -404,14 +407,15 @@ VirtualKeyboardCheckForKey (
**/
EFI_STATUS
VirtualKeyboardFreeNotifyList (
IN OUT LIST_ENTRY *ListHead
IN OUT LIST_ENTRY *ListHead
)
{
VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *NotifyNode;
VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *NotifyNode;
if (ListHead == NULL) {
return EFI_INVALID_PARAMETER;
}
while (!IsListEmpty (ListHead)) {
NotifyNode = CR (
ListHead->ForwardLink,
@@ -450,7 +454,8 @@ IsKeyRegistered (
ASSERT (RegsiteredData != NULL && InputData != NULL);
if ((RegsiteredData->Key.ScanCode != InputData->Key.ScanCode) ||
(RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar)) {
(RegsiteredData->Key.UnicodeChar != InputData->Key.UnicodeChar))
{
return FALSE;
}
@@ -459,16 +464,18 @@ IsKeyRegistered (
// these state could be ignored.
//
if ((RegsiteredData->KeyState.KeyShiftState != 0) &&
(RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState)) {
(RegsiteredData->KeyState.KeyShiftState != InputData->KeyState.KeyShiftState))
{
return FALSE;
}
if ((RegsiteredData->KeyState.KeyToggleState != 0) &&
(RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState)) {
(RegsiteredData->KeyState.KeyToggleState != InputData->KeyState.KeyToggleState))
{
return FALSE;
}
return TRUE;
}
/**
@@ -482,8 +489,8 @@ IsKeyRegistered (
VOID
EFIAPI
VirtualKeyboardWaitForKey (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
)
{
//
@@ -519,21 +526,21 @@ VirtualKeyboardWaitForKey (
VOID
EFIAPI
VirtualKeyboardWaitForKeyEx (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
)
{
VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
VirtualKeyboardPrivate = TEXT_INPUT_EX_VIRTUAL_KEYBOARD_DEV_FROM_THIS (Context);
VirtualKeyboardWaitForKey (Event, &VirtualKeyboardPrivate->SimpleTextIn);
}
//
// EFI Simple Text In Protocol Functions
//
/**
Reset the Keyboard and do BAT test for it, if (ExtendedVerification == TRUE)
then do some extra keyboard validations.
@@ -553,9 +560,9 @@ VirtualKeyboardReset (
IN BOOLEAN ExtendedVerification
)
{
VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
EFI_STATUS Status;
EFI_TPL OldTpl;
VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
EFI_STATUS Status;
EFI_TPL OldTpl;
VirtualKeyboardPrivate = VIRTUAL_KEYBOARD_DEV_FROM_THIS (This);
@@ -565,7 +572,8 @@ VirtualKeyboardReset (
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
if (VirtualKeyboardPrivate->PlatformVirtual &&
VirtualKeyboardPrivate->PlatformVirtual->Reset) {
VirtualKeyboardPrivate->PlatformVirtual->Reset)
{
Status = VirtualKeyboardPrivate->PlatformVirtual->Reset ();
} else {
Status = EFI_INVALID_PARAMETER;
@@ -597,16 +605,16 @@ VirtualKeyboardResetEx (
IN BOOLEAN ExtendedVerification
)
{
VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
EFI_STATUS Status;
EFI_TPL OldTpl;
VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
EFI_STATUS Status;
EFI_TPL OldTpl;
VirtualKeyboardPrivate = TEXT_INPUT_EX_VIRTUAL_KEYBOARD_DEV_FROM_THIS (This);
Status = VirtualKeyboardPrivate->SimpleTextIn.Reset (
&VirtualKeyboardPrivate->SimpleTextIn,
ExtendedVerification
);
&VirtualKeyboardPrivate->SimpleTextIn,
ExtendedVerification
);
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
@@ -616,7 +624,6 @@ VirtualKeyboardResetEx (
gBS->RestoreTPL (OldTpl);
return EFI_SUCCESS;
}
/**
@@ -638,11 +645,12 @@ VirtualKeyboardResetEx (
EFI_STATUS
KeyboardReadKeyStrokeWorker (
IN VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate,
OUT EFI_KEY_DATA *KeyData
OUT EFI_KEY_DATA *KeyData
)
{
EFI_STATUS Status;
EFI_TPL OldTpl;
EFI_STATUS Status;
EFI_TPL OldTpl;
if (KeyData == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -700,9 +708,9 @@ VirtualKeyboardReadKeyStroke (
OUT EFI_INPUT_KEY *Key
)
{
VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
EFI_STATUS Status;
EFI_KEY_DATA KeyData;
VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
EFI_STATUS Status;
EFI_KEY_DATA KeyData;
VirtualKeyboardPrivate = VIRTUAL_KEYBOARD_DEV_FROM_THIS (This);
@@ -715,12 +723,14 @@ VirtualKeyboardReadKeyStroke (
// Convert the Ctrl+[a-z] to Ctrl+[1-26]
//
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);
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);
}
}
@@ -747,11 +757,11 @@ VirtualKeyboardReadKeyStroke (
EFI_STATUS
EFIAPI
VirtualKeyboardReadKeyStrokeEx (
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
OUT EFI_KEY_DATA *KeyData
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
OUT EFI_KEY_DATA *KeyData
)
{
VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
if (KeyData == NULL) {
return EFI_INVALID_PARAMETER;
@@ -760,7 +770,6 @@ VirtualKeyboardReadKeyStrokeEx (
VirtualKeyboardPrivate = TEXT_INPUT_EX_VIRTUAL_KEYBOARD_DEV_FROM_THIS (This);
return KeyboardReadKeyStrokeWorker (VirtualKeyboardPrivate, KeyData);
}
/**
@@ -822,16 +831,17 @@ VirtualKeyboardRegisterKeyNotify (
OUT VOID **NotifyHandle
)
{
EFI_STATUS Status;
VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
EFI_TPL OldTpl;
VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *NewNotify;
LIST_ENTRY *Link;
VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
EFI_STATUS Status;
VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
EFI_TPL OldTpl;
VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *NewNotify;
LIST_ENTRY *Link;
VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
if (KeyData == NULL ||
NotifyHandle == NULL ||
KeyNotificationFunction == NULL) {
if ((KeyData == NULL) ||
(NotifyHandle == NULL) ||
(KeyNotificationFunction == NULL))
{
return EFI_INVALID_PARAMETER;
}
@@ -848,7 +858,8 @@ VirtualKeyboardRegisterKeyNotify (
//
for (Link = VirtualKeyboardPrivate->NotifyList.ForwardLink;
Link != &VirtualKeyboardPrivate->NotifyList;
Link = Link->ForwardLink) {
Link = Link->ForwardLink)
{
CurrentNotify = CR (
Link,
VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY,
@@ -858,7 +869,7 @@ VirtualKeyboardRegisterKeyNotify (
if (IsKeyRegistered (&CurrentNotify->KeyData, KeyData)) {
if (CurrentNotify->KeyNotificationFn == KeyNotificationFunction) {
*NotifyHandle = CurrentNotify;
Status = EFI_SUCCESS;
Status = EFI_SUCCESS;
goto Exit;
}
}
@@ -868,7 +879,7 @@ VirtualKeyboardRegisterKeyNotify (
// Allocate resource to save the notification function
//
NewNotify = (VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *) AllocateZeroPool (sizeof (VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY));
NewNotify = (VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *)AllocateZeroPool (sizeof (VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY));
if (NewNotify == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Exit;
@@ -879,8 +890,8 @@ VirtualKeyboardRegisterKeyNotify (
CopyMem (&NewNotify->KeyData, KeyData, sizeof (EFI_KEY_DATA));
InsertTailList (&VirtualKeyboardPrivate->NotifyList, &NewNotify->NotifyEntry);
*NotifyHandle = NewNotify;
Status = EFI_SUCCESS;
*NotifyHandle = NewNotify;
Status = EFI_SUCCESS;
Exit:
//
@@ -888,7 +899,6 @@ Exit:
//
gBS->RestoreTPL (OldTpl);
return Status;
}
/**
@@ -910,11 +920,11 @@ VirtualKeyboardUnregisterKeyNotify (
IN VOID *NotificationHandle
)
{
EFI_STATUS Status;
VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
EFI_TPL OldTpl;
LIST_ENTRY *Link;
VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
EFI_STATUS Status;
VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
EFI_TPL OldTpl;
LIST_ENTRY *Link;
VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
//
// Check incoming notification handle
@@ -923,8 +933,9 @@ VirtualKeyboardUnregisterKeyNotify (
return EFI_INVALID_PARAMETER;
}
if (((VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *) NotificationHandle)->Signature !=
VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE) {
if (((VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *)NotificationHandle)->Signature !=
VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE)
{
return EFI_INVALID_PARAMETER;
}
@@ -937,7 +948,8 @@ VirtualKeyboardUnregisterKeyNotify (
for (Link = VirtualKeyboardPrivate->NotifyList.ForwardLink;
Link != &VirtualKeyboardPrivate->NotifyList;
Link = Link->ForwardLink) {
Link = Link->ForwardLink)
{
CurrentNotify = CR (
Link,
VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY,
@@ -982,8 +994,8 @@ Exit:
VOID
EFIAPI
VirtualKeyboardTimerHandler (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
)
{
EFI_TPL OldTpl;
@@ -1001,14 +1013,17 @@ VirtualKeyboardTimerHandler (
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
if (VirtualKeyboardPrivate->PlatformVirtual &&
VirtualKeyboardPrivate->PlatformVirtual->Query) {
VirtualKeyboardPrivate->PlatformVirtual->Query)
{
if (VirtualKeyboardPrivate->PlatformVirtual->Query (&VirtualKey) ==
FALSE) {
FALSE)
{
goto Exit;
}
// Found key
KeyData.Key.ScanCode = VirtualKey.Key.ScanCode;
KeyData.Key.UnicodeChar = VirtualKey.Key.UnicodeChar;
KeyData.Key.ScanCode = VirtualKey.Key.ScanCode;
KeyData.Key.UnicodeChar = VirtualKey.Key.UnicodeChar;
KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID;
KeyData.KeyState.KeyToggleState = EFI_TOGGLE_STATE_VALID;
if (VirtualKeyboardPrivate->PlatformVirtual->Clear) {
@@ -1023,7 +1038,8 @@ VirtualKeyboardTimerHandler (
//
for (Link = VirtualKeyboardPrivate->NotifyList.ForwardLink;
Link != &VirtualKeyboardPrivate->NotifyList;
Link = Link->ForwardLink) {
Link = Link->ForwardLink)
{
CurrentNotify = CR (
Link,
VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY,
@@ -1060,19 +1076,19 @@ Exit:
VOID
EFIAPI
KeyNotifyProcessHandler (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
)
{
EFI_STATUS Status;
VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
EFI_KEY_DATA KeyData;
LIST_ENTRY *Link;
LIST_ENTRY *NotifyList;
VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
EFI_TPL OldTpl;
EFI_STATUS Status;
VIRTUAL_KEYBOARD_DEV *VirtualKeyboardPrivate;
EFI_KEY_DATA KeyData;
LIST_ENTRY *Link;
LIST_ENTRY *NotifyList;
VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY *CurrentNotify;
EFI_TPL OldTpl;
VirtualKeyboardPrivate = (VIRTUAL_KEYBOARD_DEV *) Context;
VirtualKeyboardPrivate = (VIRTUAL_KEYBOARD_DEV *)Context;
//
// Invoke notification functions.
@@ -1091,10 +1107,13 @@ KeyNotifyProcessHandler (
if (EFI_ERROR (Status)) {
break;
}
for (Link = GetFirstNode (NotifyList);
!IsNull (NotifyList, Link);
Link = GetNextNode (NotifyList, Link)) {
CurrentNotify = CR (Link,
Link = GetNextNode (NotifyList, Link))
{
CurrentNotify = CR (
Link,
VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY,
NotifyEntry,
VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE
@@ -1119,12 +1138,12 @@ KeyNotifyProcessHandler (
**/
EFI_STATUS
EFIAPI
InitializeVirtualKeyboard(
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
InitializeVirtualKeyboard (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_STATUS Status;
//
// Install driver model protocol(s).

View File

@@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _VIRTUAL_KEYBOARD_H_
#define _VIRTUAL_KEYBOARD_H_
#include <Guid/StatusCodeDataTypeId.h>
#include <Protocol/DevicePath.h>
#include <Protocol/PlatformVirtualKeyboard.h>
@@ -31,70 +30,69 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// Driver Binding Externs
//
extern EFI_DRIVER_BINDING_PROTOCOL gVirtualKeyboardDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gVirtualKeyboardComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gVirtualKeyboardComponentName2;
extern EFI_DRIVER_BINDING_PROTOCOL gVirtualKeyboardDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gVirtualKeyboardComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gVirtualKeyboardComponentName2;
//
// VIRTUAL Keyboard Defines
//
#define CHAR_SCANCODE 0xe0
#define CHAR_ESC 0x1b
#define CHAR_SCANCODE 0xe0
#define CHAR_ESC 0x1b
#define KEYBOARD_TIMEOUT 65536 // 0.07s
#define KEYBOARD_WAITFORVALUE_TIMEOUT 1000000 // 1s
#define KEYBOARD_BAT_TIMEOUT 4000000 // 4s
#define KEYBOARD_TIMER_INTERVAL 500000 // 0.5s
#define KEYBOARD_TIMEOUT 65536 // 0.07s
#define KEYBOARD_WAITFORVALUE_TIMEOUT 1000000 // 1s
#define KEYBOARD_BAT_TIMEOUT 4000000 // 4s
#define KEYBOARD_TIMER_INTERVAL 500000 // 0.5s
#define QUEUE_MAX_COUNT 32
#define QUEUE_MAX_COUNT 32
#define KEYBOARD_SCAN_CODE_MAX_COUNT 32
#define KEYBOARD_SCAN_CODE_MAX_COUNT 32
//
// VIRTUAL Keyboard Device Structure
//
#define VIRTUAL_KEYBOARD_DEV_SIGNATURE SIGNATURE_32 ('V', 'K', 'B', 'D')
#define VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('v', 'k', 'c', 'n')
#define VIRTUAL_KEYBOARD_DEV_SIGNATURE SIGNATURE_32 ('V', 'K', 'B', 'D')
#define VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('v', 'k', 'c', 'n')
typedef struct _VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY {
UINTN Signature;
EFI_KEY_DATA KeyData;
EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;
LIST_ENTRY NotifyEntry;
UINTN Signature;
EFI_KEY_DATA KeyData;
EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;
LIST_ENTRY NotifyEntry;
} VIRTUAL_KEYBOARD_CONSOLE_IN_EX_NOTIFY;
typedef struct {
UINTN Front;
UINTN Rear;
EFI_KEY_DATA Buffer[QUEUE_MAX_COUNT];
UINTN Front;
UINTN Rear;
EFI_KEY_DATA Buffer[QUEUE_MAX_COUNT];
} SIMPLE_QUEUE;
typedef struct {
UINT8 Buffer[KEYBOARD_SCAN_CODE_MAX_COUNT];
UINTN Head;
UINTN Tail;
UINT8 Buffer[KEYBOARD_SCAN_CODE_MAX_COUNT];
UINTN Head;
UINTN Tail;
} SCAN_CODE_QUEUE;
typedef struct {
UINTN Signature;
EFI_HANDLE Handle;
PLATFORM_VIRTUAL_KBD_PROTOCOL *PlatformVirtual;
EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleTextIn;
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleTextInputEx;
UINTN Signature;
EFI_HANDLE Handle;
PLATFORM_VIRTUAL_KBD_PROTOCOL *PlatformVirtual;
EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleTextIn;
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleTextInputEx;
//
// Buffer storing EFI_KEY_DATA
//
SIMPLE_QUEUE Queue;
SIMPLE_QUEUE QueueForNotify;
SIMPLE_QUEUE Queue;
SIMPLE_QUEUE QueueForNotify;
//
// Notification Function List
//
LIST_ENTRY NotifyList;
EFI_EVENT KeyNotifyProcessEvent;
EFI_EVENT TimerEvent;
LIST_ENTRY NotifyList;
EFI_EVENT KeyNotifyProcessEvent;
EFI_EVENT TimerEvent;
} VIRTUAL_KEYBOARD_DEV;
#define VIRTUAL_KEYBOARD_DEV_FROM_THIS(a) CR (a, VIRTUAL_KEYBOARD_DEV, SimpleTextIn, VIRTUAL_KEYBOARD_DEV_SIGNATURE)
@@ -108,7 +106,7 @@ typedef struct {
//
// Global Variables
//
extern EFI_DRIVER_BINDING_PROTOCOL gVirtualKeyboardDriverBinding;
extern EFI_DRIVER_BINDING_PROTOCOL gVirtualKeyboardDriverBinding;
//
// Driver Binding Protocol functions
@@ -222,7 +220,6 @@ VirtualKeyboardComponentNameGetDriverName (
OUT CHAR16 **DriverName
);
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
@@ -294,17 +291,17 @@ VirtualKeyboardComponentNameGetDriverName (
EFI_STATUS
EFIAPI
VirtualKeyboardComponentNameGetControllerName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
);
//
// Simple Text Input Protocol functions
//
/**
Reset the Keyboard and do BAT test for it, if (ExtendedVerification == TRUE) then do some extra keyboard validations.
@@ -406,6 +403,7 @@ VirtualKeyboardUnregisterKeyNotify (
//
// Private worker functions
//
/**
Free keyboard notify list.
@@ -417,7 +415,7 @@ VirtualKeyboardUnregisterKeyNotify (
**/
EFI_STATUS
VirtualKeyboardFreeNotifyList (
IN OUT LIST_ENTRY *ListHead
IN OUT LIST_ENTRY *ListHead
);
/**
@@ -478,8 +476,8 @@ VirtualKeyboardWaitForKeyEx (
VOID
EFIAPI
VirtualKeyboardTimerHandler (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
);
/**
@@ -491,8 +489,8 @@ VirtualKeyboardTimerHandler (
VOID
EFIAPI
KeyNotifyProcessHandler (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
);
/**
@@ -530,8 +528,8 @@ VirtualKeyboardReadKeyStroke (
EFI_STATUS
EFIAPI
VirtualKeyboardReadKeyStrokeEx (
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
OUT EFI_KEY_DATA *KeyData
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
OUT EFI_KEY_DATA *KeyData
);
#endif /* _VIRTUAL_KEYBOARD_H_ */