Adding Simple Pointer, GOP, SimpleTextInEx, and Networking protocols to the emulator. Cleaned up POSIX include situation by centralizing it in a single file, like NT32. Fixed TPL issue with TPL High not being emulated correctly, it was possible to take a timer tick when the locks in the DXE core should have prevented this. Remove some unused files to make things easier to maintain.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11105 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
andrewfish 2010-11-30 23:38:40 +00:00
parent e23a349aae
commit 2ff79f2eda
44 changed files with 6574 additions and 9581 deletions

View File

@ -28,6 +28,7 @@ Abstract:
#include <Guid/DataHubRecords.h> #include <Guid/DataHubRecords.h>
#include <Protocol/CpuIo2.h> #include <Protocol/CpuIo2.h>
#include <Protocol/FrameworkHii.h> #include <Protocol/FrameworkHii.h>
#include <Protocol/UnixThunk.h>
#include <Library/BaseLib.h> #include <Library/BaseLib.h>
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
@ -37,6 +38,8 @@ Abstract:
#include <Library/BaseMemoryLib.h> #include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h> #include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h> #include <Library/UefiBootServicesTableLib.h>
#include <Library/UnixLib.h>
#include "CpuDriver.h" #include "CpuDriver.h"
#include "UnixDxe.h" #include "UnixDxe.h"
#include <Protocol/UnixIo.h> #include <Protocol/UnixIo.h>
@ -151,6 +154,7 @@ Returns:
Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This); Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);
Private->InterruptState = TRUE; Private->InterruptState = TRUE;
gUnix->EnableInterrupt ();
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -184,6 +188,7 @@ Returns:
Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This); Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);
Private->InterruptState = FALSE; Private->InterruptState = FALSE;
gUnix->DisableInterrupt ();
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -52,6 +52,7 @@
HiiLib HiiLib
DebugLib DebugLib
BaseLib BaseLib
UnixLib
[Protocols] [Protocols]
gEfiUnixIoProtocolGuid # PROTOCOL_NOTIFY SOMETIMES_CONSUMED gEfiUnixIoProtocolGuid # PROTOCOL_NOTIFY SOMETIMES_CONSUMED

View File

@ -20,6 +20,8 @@ Abstract:
#ifndef _UNIX_IO_H_ #ifndef _UNIX_IO_H_
#define _UNIX_IO_H_ #define _UNIX_IO_H_
#include <Protocol/UnixThunk.h>
#define EFI_UNIX_IO_PROTOCOL_GUID \ #define EFI_UNIX_IO_PROTOCOL_GUID \
{ \ { \
0xf2e23f54, 0x8985, 0x11db, {0xac, 0x79, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \ 0xf2e23f54, 0x8985, 0x11db, {0xac, 0x79, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
@ -139,4 +141,14 @@ extern EFI_GUID gEfiUnixCPUModelGuid;
extern EFI_GUID gEfiUnixCPUSpeedGuid; extern EFI_GUID gEfiUnixCPUSpeedGuid;
//
// EFI_UNIX_NETWORK
//
#define EFI_UNIX_NETWORK_GUID \
{ \
0x081603B4, 0x0F1D, 0x4022, {0xB6, 0xFD, 0x4C, 0xE3, 0x5E, 0x09, 0xA1, 0xA6 } \
}
extern EFI_GUID gEfiUnixNetworkGuid;
#endif #endif

View File

@ -1,7 +1,7 @@
/*++ /*++
Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR> Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR> Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -51,10 +51,21 @@ Abstract:
#include <stdlib.h> #include <stdlib.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <ifaddrs.h>
#include <net/bpf.h>
#ifdef __APPLE__ #ifdef __APPLE__
#include <sys/param.h> #include <sys/param.h>
#include <sys/mount.h> #include <sys/mount.h>
#define _XOPEN_SOURCE #define _XOPEN_SOURCE
#ifndef _Bool
#define _Bool char // for clang debug
#endif
#else #else
#include <termio.h> #include <termio.h>
#include <sys/vfs.h> #include <sys/vfs.h>
@ -76,7 +87,15 @@ Abstract:
#pragma pack(4) #pragma pack(4)
#endif #endif
#if __DARWIN_64_BIT_INO_T #if defined(__DARWIN_64_BIT_INO_T)
typedef struct {
UINTN tv_sec; /* seconds */
UINTN tv_nsec; /* and nanoseconds */
} EFI_timespec;
typedef struct stat_fix { \ typedef struct stat_fix { \
dev_t st_dev; /* [XSI] ID of device containing file */ dev_t st_dev; /* [XSI] ID of device containing file */
@ -86,7 +105,15 @@ typedef struct stat_fix { \
uid_t st_uid; /* [XSI] User ID of the file */ uid_t st_uid; /* [XSI] User ID of the file */
gid_t st_gid; /* [XSI] Group ID of the file */ gid_t st_gid; /* [XSI] Group ID of the file */
dev_t st_rdev; /* [XSI] Device ID */ dev_t st_rdev; /* [XSI] Device ID */
__DARWIN_STRUCT_STAT64_TIMES
// clang for X64 ABI follows Windows and a long is 32-bits
// this breaks system inlcude files so that is why we need
// to redefine timespec as EFI_timespec
EFI_timespec st_atimespec;
EFI_timespec st_mtimespec;
EFI_timespec st_ctimespec;
EFI_timespec st_birthtimespec;
off_t st_size; /* [XSI] file size, in bytes */ off_t st_size; /* [XSI] file size, in bytes */
blkcnt_t st_blocks; /* [XSI] blocks allocated for file */ blkcnt_t st_blocks; /* [XSI] blocks allocated for file */
blksize_t st_blksize; /* [XSI] optimal blocksize for I/O */ blksize_t st_blksize; /* [XSI] optimal blocksize for I/O */
@ -358,6 +385,35 @@ VOID
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
); );
typedef
int
(EFIAPI *UnixGetIfAddrs) (
struct ifaddrs **ifap
);
typedef
void
(EFIAPI *UnixFreeIfAddrs) (
struct ifaddrs *ifap
);
typedef
int
(EFIAPI *UnixSocket) (
int domain,
int type,
int protocol
);
typedef
void
(EFIAPI *UnixDisableInterruptEmulation) (void);
typedef
void
(EFIAPI *UnixEnableInterruptEmulation) (void);
#define EFI_UNIX_THUNK_PROTOCOL_SIGNATURE SIGNATURE_32 ('L', 'N', 'X', 'T') #define EFI_UNIX_THUNK_PROTOCOL_SIGNATURE SIGNATURE_32 ('L', 'N', 'X', 'T')
@ -407,8 +463,12 @@ typedef struct _EFI_UNIX_THUNK_PROTOCOL {
UnixPeCoffGetEntryPoint PeCoffGetEntryPoint; UnixPeCoffGetEntryPoint PeCoffGetEntryPoint;
UnixPeCoffRelocateImageExtraAction PeCoffRelocateImageExtraAction; UnixPeCoffRelocateImageExtraAction PeCoffRelocateImageExtraAction;
UnixPeCoffLoaderUnloadImageExtraAction PeCoffUnloadImageExtraAction; UnixPeCoffLoaderUnloadImageExtraAction PeCoffUnloadImageExtraAction;
UnixEnableInterruptEmulation EnableInterrupt;
UnixDisableInterruptEmulation DisableInterrupt;
UnixGetIfAddrs GetIfAddrs;
UnixFreeIfAddrs FreeIfAddrs;
UnixSocket Socket;
} EFI_UNIX_THUNK_PROTOCOL; } EFI_UNIX_THUNK_PROTOCOL;
extern EFI_GUID gEfiUnixThunkProtocolGuid; extern EFI_GUID gEfiUnixThunkProtocolGuid;

View File

@ -20,19 +20,24 @@ Abstract:
#ifndef _UNIX_UGA_IO_H_ #ifndef _UNIX_UGA_IO_H_
#define _UNIX_UGA_IO_H_ #define _UNIX_UGA_IO_H_
#include <Protocol/SimplePointer.h>
#include <Protocol/SimpleTextIn.h>
#include <Protocol/SimpleTextInEx.h>
#include <Protocol/UgaDraw.h>
#define EFI_UNIX_UGA_IO_PROTOCOL_GUID {0xf2e5e2c6, 0x8985, 0x11db, {0xa1, 0x91, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } } #define EFI_UNIX_UGA_IO_PROTOCOL_GUID {0xf2e5e2c6, 0x8985, 0x11db, {0xa1, 0x91, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } }
typedef struct _EFI_UNIX_UGA_IO_PROTOCOL EFI_UNIX_UGA_IO_PROTOCOL; typedef struct _EFI_UNIX_UGA_IO_PROTOCOL EFI_UNIX_UGA_IO_PROTOCOL;
typedef typedef
EFI_STATUS EFI_STATUS
(*UGAClose)( (EFIAPI *UGAClose)(
EFI_UNIX_UGA_IO_PROTOCOL *Uga EFI_UNIX_UGA_IO_PROTOCOL *Uga
); );
typedef typedef
EFI_STATUS EFI_STATUS
(*UGASize)( (EFIAPI *UGASize)(
EFI_UNIX_UGA_IO_PROTOCOL *Uga, EFI_UNIX_UGA_IO_PROTOCOL *Uga,
UINT32 Width, UINT32 Width,
UINT32 Height UINT32 Height
@ -40,15 +45,38 @@ EFI_STATUS
typedef typedef
EFI_STATUS EFI_STATUS
(*UGACheckKey)( (EFIAPI *UGACheckKey)(
EFI_UNIX_UGA_IO_PROTOCOL *Uga EFI_UNIX_UGA_IO_PROTOCOL *Uga
); );
typedef typedef
EFI_STATUS EFI_STATUS
(*UGAGetKey)( (EFIAPI *UGAGetKey)(
EFI_UNIX_UGA_IO_PROTOCOL *Uga, EFI_UNIX_UGA_IO_PROTOCOL *Uga,
EFI_INPUT_KEY *key EFI_KEY_DATA *key
);
typedef
EFI_STATUS
(EFIAPI *UGAKeySetState) (
IN EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
IN EFI_KEY_TOGGLE_STATE *KeyToggleState
);
typedef
VOID
(EFIAPI *UGA_REGISTER_KEY_NOTIFY_CALLBACK) (
IN VOID *Context,
IN EFI_KEY_DATA *KeyData
);
typedef
EFI_STATUS
(EFIAPI *UGARegisterKeyNotify) (
IN EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
IN UGA_REGISTER_KEY_NOTIFY_CALLBACK CallBack,
IN VOID *Context
); );
@ -64,20 +92,45 @@ typedef struct {
typedef typedef
EFI_STATUS EFI_STATUS
(*UGABlt)( (EFIAPI *UGABlt)(
IN EFI_UNIX_UGA_IO_PROTOCOL *Uga, IN EFI_UNIX_UGA_IO_PROTOCOL *Uga,
IN EFI_UGA_PIXEL *BltBuffer OPTIONAL, IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
IN EFI_UGA_BLT_OPERATION BltOperation, IN EFI_UGA_BLT_OPERATION BltOperation,
IN UGA_BLT_ARGS *Args IN UGA_BLT_ARGS *Args
); );
typedef
BOOLEAN
(EFIAPI *UGAIsKeyPressed) (
IN EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
IN EFI_KEY_DATA *KeyData
);
typedef
EFI_STATUS
(EFIAPI *UGACheckPointer)(
EFI_UNIX_UGA_IO_PROTOCOL *Uga
);
typedef
EFI_STATUS
(EFIAPI *UGAGetPointerState)(
EFI_UNIX_UGA_IO_PROTOCOL *Uga,
EFI_SIMPLE_POINTER_STATE *state
);
struct _EFI_UNIX_UGA_IO_PROTOCOL { struct _EFI_UNIX_UGA_IO_PROTOCOL {
VOID *Private; VOID *Private;
UGAClose UgaClose; UGAClose UgaClose;
UGASize UgaSize; UGASize UgaSize;
UGACheckKey UgaCheckKey; UGACheckKey UgaCheckKey;
UGAKeySetState UgaKeySetState;
UGAGetKey UgaGetKey; UGAGetKey UgaGetKey;
UGARegisterKeyNotify UgaRegisterKeyNotify;
UGABlt UgaBlt; UGABlt UgaBlt;
UGAIsKeyPressed UgaIsKeyPressed;
UGACheckPointer UgaCheckPointer;
UGAGetPointerState UgaGetPointerState;
}; };

View File

@ -40,12 +40,9 @@ ASM_PFX(InternalSwitchStack):
movq %rcx, %rax movq %rcx, %rax
movq %rdx, %rcx movq %rdx, %rcx
movq %r8, %rdx movq %r8, %rdx
movq %r9, %rsp
# #
# Reserve space for register parameters (rcx, rdx, r8 & r9) on the stack, # Reserve space for register parameters (rcx, rdx, r8 & r9) on the stack,
# in case the callee wishes to spill them. # in case the callee wishes to spill them.
# #
subq $40, %rsp // 32-byte shadow space plus alignment pad lea -0x20(%r9), %rsp
call *%rax call *%rax

View File

@ -30,7 +30,7 @@ UINT16 gPlatformBootTimeOutDefault = 10;
// //
// Platform specific keyboard device path // Platform specific keyboard device path
// //
UNIX_PLATFORM_UGA_DEVICE_PATH gUgaDevicePath0 = UNIX_PLATFORM_UGA_DEVICE_PATH gUgaDevicePath =
{ {
{ {
HARDWARE_DEVICE_PATH, HARDWARE_DEVICE_PATH,
@ -54,7 +54,7 @@ UNIX_PLATFORM_UGA_DEVICE_PATH gUgaDevicePath0 =
gEndEntire gEndEntire
}; };
UNIX_PLATFORM_UGA_DEVICE_PATH gUgaDevicePath1 = { UNIX_PLATFORM_UGA_DEVICE_PATH gGopDevicePath = {
{ {
HARDWARE_DEVICE_PATH, HARDWARE_DEVICE_PATH,
HW_VENDOR_DP, HW_VENDOR_DP,
@ -71,8 +71,8 @@ UNIX_PLATFORM_UGA_DEVICE_PATH gUgaDevicePath1 = {
(UINT8) (sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)), (UINT8) (sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)),
(UINT8) ((sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)) >> 8) (UINT8) ((sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)) >> 8)
}, },
EFI_UNIX_UGA_GUID, EFI_UNIX_GOP_GUID,
1 0
}, },
gEndEntire gEndEntire
}; };
@ -108,11 +108,11 @@ BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
(CONSOLE_OUT | CONSOLE_IN) (CONSOLE_OUT | CONSOLE_IN)
}, },
{ {
(EFI_DEVICE_PATH_PROTOCOL *) &gUgaDevicePath0, (EFI_DEVICE_PATH_PROTOCOL *) &gUgaDevicePath,
(CONSOLE_OUT | CONSOLE_IN) (CONSOLE_OUT | CONSOLE_IN)
}, },
{ {
(EFI_DEVICE_PATH_PROTOCOL *) &gUgaDevicePath1, (EFI_DEVICE_PATH_PROTOCOL *) &gGopDevicePath,
(CONSOLE_OUT | CONSOLE_IN) (CONSOLE_OUT | CONSOLE_IN)
}, },
{ {

View File

@ -1,6 +1,6 @@
/** @file /** @file
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR> Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
@ -369,28 +369,88 @@ GasketUgaCheckKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
GasketUgaGetKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_INPUT_KEY *key) GasketUgaKeySetState (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_KEY_TOGGLE_STATE *KeyToggleState)
{
return GasketUintnUintn (UgaGetKey, (UINTN)UgaIo, (UINTN)KeyToggleState);
}
EFI_STATUS
EFIAPI
GasketUgaGetKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_KEY_DATA *key)
{ {
return GasketUintnUintn (UgaGetKey, (UINTN)UgaIo, (UINTN)key); return GasketUintnUintn (UgaGetKey, (UINTN)UgaIo, (UINTN)key);
} }
EFI_STATUS
EFIAPI
GasketUgaRegisterKeyNotify (
IN EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
IN UGA_REGISTER_KEY_NOTIFY_CALLBACK CallBack,
IN VOID *Context
)
{
return GasketUintnUintnUintn (UgaRegisterKeyNotify, (UINTN)UgaIo, (UINTN)CallBack, (UINTN)Context);
}
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
GasketUgaBlt ( GasketUgaBlt (
EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
IN EFI_UGA_PIXEL *BltBuffer OPTIONAL, IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
IN EFI_UGA_BLT_OPERATION BltOperation, IN EFI_UGA_BLT_OPERATION BltOperation,
IN UINTN SourceX, IN UGA_BLT_ARGS *Args
IN UINTN SourceY,
IN UINTN DestinationX,
IN UINTN DestinationY,
IN UINTN Width,
IN UINTN Height,
IN UINTN Delta OPTIONAL
) )
{ {
return GasketUintn10Args (UgaBlt, (UINTN)UgaIo, (UINTN)BltBuffer, BltOperation, SourceX, SourceY, DestinationX, DestinationY, Width, Height, Delta); return GasketUintnUintnUintnUintn (UgaBlt, (UINTN)UgaIo, (UINTN)BltBuffer, (UINTN)BltOperation, (UINTN)Args);
} }
EFI_STATUS
EFIAPI
GasketUgaCheckPointer (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)
{
return GasketUintn (UgaCheckPointer, (UINTN)UgaIo);
}
EFI_STATUS
EFIAPI
GasketUgaGetPointerState (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_SIMPLE_POINTER_STATE *state)
{
return GasketUintnUintn (UgaGetPointerState, (UINTN)UgaIo, (UINTN)state);
}
void
GasketUnixEnableInterrupt (void)
{
GasketVoid (UnixEnableInterrupt);
}
void
GasketUnixDisableInterrupt (void)
{
GasketVoid (UnixDisableInterrupt);
}
int
Gasketgetifaddrs (struct ifaddrs **ifap)
{
return( GasketUintn( getifaddrs, ( UINTN ) ifap ) );
}
void
Gasketfreeifaddrs (struct ifaddrs *ifap)
{
GasketUintn( freeifaddrs, ( UINTN ) ifap );
}
int
Gasketsocket (int domain, int type, int protocol )
{
return( GasketUintnUintnUintn( socket, domain, type, protocol ) );
}
#endif #endif

View File

@ -1,6 +1,6 @@
/** @file /** @file
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR> Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
@ -19,6 +19,7 @@
#include <Protocol/UgaDraw.h> #include <Protocol/UgaDraw.h>
#include <Protocol/SimpleTextIn.h> #include <Protocol/SimpleTextIn.h>
#include <Protocol/SimpleTextInEx.h>
#include <Protocol/UnixUgaIo.h> #include <Protocol/UnixUgaIo.h>
@ -177,11 +178,17 @@ Gasketclosedir (
int int
EFIAPI EFIAPI
Gasketstat (const char *path, STAT_FIX *buf); Gasketstat (
const char *path,
STAT_FIX *buf)
;
int int
EFIAPI EFIAPI
Gasketstatfs (const char *path, struct statfs *buf); Gasketstatfs (
const char *path,
struct statfs *buf
);
int int
EFIAPI EFIAPI
@ -293,6 +300,34 @@ Gasketsigaction (
struct sigaction *oact struct sigaction *oact
); );
int
EFIAPI
Gasketgetifaddrs (
struct ifaddrs **ifap
);
void
EFIAPI
Gasketfreeifaddrs (
struct ifaddrs *ifap
);
int
EFIAPI
Gasketsocket (
int domain,
int type,
int protocol
);
void
EFIAPI
GasketUnixEnableInterrupt (void);
void
EFIAPI
GasketUnixDisableInterrupt (void);
RETURN_STATUS RETURN_STATUS
EFIAPI EFIAPI
GasketUnixPeCoffGetEntryPoint ( GasketUnixPeCoffGetEntryPoint (
@ -406,6 +441,13 @@ ReverseGasketUint64 (
UINT64 a UINT64 a
); );
UINTN
ReverseGasketUint64Uint64 (
VOID *CallBack,
VOID *Context,
VOID *Key
);
// //
// Gasket functions for EFI_UNIX_UGA_IO_PROTOCOL // Gasket functions for EFI_UNIX_UGA_IO_PROTOCOL
// //
@ -435,24 +477,52 @@ EFI_STATUS
EFIAPI EFIAPI
GasketUgaGetKey ( GasketUgaGetKey (
EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
EFI_INPUT_KEY *key EFI_KEY_DATA *key
); );
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
GasketUgaBlt ( GasketUgaKeySetState (
EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
EFI_KEY_TOGGLE_STATE *KeyToggleState
);
EFI_STATUS
EFIAPI
GasketUgaRegisterKeyNotify (
IN EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
IN UGA_REGISTER_KEY_NOTIFY_CALLBACK CallBack,
IN VOID *Context
);
EFI_STATUS
EFIAPI
GasketUgaBlt (
IN EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
IN EFI_UGA_PIXEL *BltBuffer OPTIONAL, IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
IN EFI_UGA_BLT_OPERATION BltOperation, IN EFI_UGA_BLT_OPERATION BltOperation,
IN UINTN SourceX, IN UGA_BLT_ARGS *Args
IN UINTN SourceY,
IN UINTN DestinationX,
IN UINTN DestinationY,
IN UINTN Width,
IN UINTN Height,
IN UINTN Delta OPTIONAL
); );
EFI_STATUS
EFIAPI
GasketUgaCheckPointer (
EFI_UNIX_UGA_IO_PROTOCOL *UgaIo
);
EFI_STATUS
EFIAPI
GasketUgaGetPointerState (
EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
EFI_SIMPLE_POINTER_STATE *state
);
//
// Gasket functions for EFI_UNIX_UGA_IO_PROTOCOL C calls
//
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
UgaCreate ( UgaCreate (
@ -460,10 +530,6 @@ UgaCreate (
CONST CHAR16 *Title CONST CHAR16 *Title
); );
//
// Gasket functions for EFI_UNIX_UGA_IO_PROTOCOL
//
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
UgaClose ( UgaClose (
@ -488,25 +554,40 @@ EFI_STATUS
EFIAPI EFIAPI
UgaGetKey ( UgaGetKey (
EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
EFI_INPUT_KEY *key EFI_KEY_DATA *key
); );
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
UgaBlt ( UgaRegisterKeyNotify (
EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, IN EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
IN EFI_UGA_PIXEL *BltBuffer OPTIONAL, IN UGA_REGISTER_KEY_NOTIFY_CALLBACK CallBack,
IN EFI_UGA_BLT_OPERATION BltOperation, IN VOID *Context
IN UINTN SourceX,
IN UINTN SourceY,
IN UINTN DestinationX,
IN UINTN DestinationY,
IN UINTN Width,
IN UINTN Height,
IN UINTN Delta OPTIONAL
); );
EFI_STATUS
EFIAPI
UgaBlt (
IN EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
IN EFI_UGA_BLT_OPERATION BltOperation,
IN UGA_BLT_ARGS *Args
);
EFI_STATUS
EFIAPI
UgaCheckPointer (
IN EFI_UNIX_UGA_IO_PROTOCOL *UgaIo
);
EFI_STATUS
EFIAPI
UgaGetPointerState (
IN EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
IN EFI_SIMPLE_POINTER_STATE *State
);
#endif #endif

View File

@ -127,6 +127,31 @@ _GasketUintnUintnUintnUintn:
leave leave
ret ret
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
.globl _GasketUintnUintnUintnUintnUintn
_GasketUintnUintnUintnUintnUintn:
pushl %ebp
movl %esp, %ebp
subl $50, %esp # sub extra 0x10 from the stack for the AND
and $-16, %esp # stack needs to end in 0xFFFFFFF0 before call
movl 8(%ebp), %eax
movl %eax, -12(%ebp)
movl 28(%ebp), %eax
movl %eax, 16(%esp)
movl 24(%ebp), %eax
movl %eax, 12(%esp)
movl 20(%ebp), %eax
movl %eax, 8(%esp)
movl 16(%ebp), %eax
movl %eax, 4(%esp)
movl 12(%ebp), %eax
movl %eax, (%esp)
movl -12(%ebp), %eax
call *%eax
leave
ret
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
.globl _GasketUintn10Args .globl _GasketUintn10Args
@ -256,6 +281,35 @@ _ReverseGasketUint64:
ret ret
.globl _ReverseGasketUint64Uint64
_ReverseGasketUint64Uint64:
pushl %ebp
movl %esp, %ebp
subl $56, %esp
movl 12(%ebp), %eax
movl %eax, -32(%ebp)
movl 16(%ebp), %eax
movl %eax, -28(%ebp)
movl 20(%ebp), %eax
movl %eax, -40(%ebp)
movl 24(%ebp), %eax
movl %eax, -36(%ebp)
movl 8(%ebp), %eax
movl %eax, -12(%ebp)
movl -40(%ebp), %eax
movl -36(%ebp), %edx
movl %eax, 8(%esp)
movl %edx, 12(%esp)
movl -32(%ebp), %eax
movl -28(%ebp), %edx
movl %eax, (%esp)
movl %edx, 4(%esp)
movl -12(%ebp), %eax
call *%eax
leave
ret
// Sec PPI Callbacks // Sec PPI Callbacks
.globl _GasketSecUnixPeiLoadFile .globl _GasketSecUnixPeiLoadFile
@ -288,4 +342,3 @@ _GasketSecTemporaryRamSupport:
jmp _SecTemporaryRamSupport jmp _SecTemporaryRamSupport
#endif #endif

View File

@ -7,7 +7,7 @@
the assembly functions. the assembly functions.
Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR> Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -36,6 +36,7 @@ typedef UINT32 UINTN;
typedef int (*GASKET_VOID) (); typedef int (*GASKET_VOID) ();
typedef int (*GASKET_UINTN) (UINTN); typedef int (*GASKET_UINTN) (UINTN);
typedef int (*GASKET_UINT64) (UINT64); typedef int (*GASKET_UINT64) (UINT64);
typedef int (*GASKET_UINT64UINT64) (UINT64, UINT64);
typedef int (*GASKET_UINTN_UINTN) (UINTN, UINTN); typedef int (*GASKET_UINTN_UINTN) (UINTN, UINTN);
typedef int (*GASKET_UINTN_UINTN_UINTN) (UINTN, UINTN, UINTN); typedef int (*GASKET_UINTN_UINTN_UINTN) (UINTN, UINTN, UINTN);
typedef int (*GASKET_UINTN_UINTN_UINTN_UINTN) (UINTN, UINTN, UINTN, UINTN); typedef int (*GASKET_UINTN_UINTN_UINTN_UINTN) (UINTN, UINTN, UINTN, UINTN);
@ -149,4 +150,14 @@ ReverseGasketUint64 (void *api, UINT64 a)
return; return;
} }
void
ReverseGasketUint64UINT64 (void *api, UINT64 a, UINT64 b)
{
GASKET_UINT64UINT64 func;
func = (GASKET_UINT64UINT64)api;
func (a, b);
return;
}

View File

@ -1,7 +1,7 @@
/*++ /*++
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR> Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -1114,6 +1114,18 @@ SecPeCoffRelocateImageExtraAction (
{ {
#ifdef __APPLE__ #ifdef __APPLE__
BOOLEAN EnabledOnEntry;
//
// Make sure writting of the file is an atomic operation
//
if (UnixInterruptEanbled ()) {
UnixDisableInterrupt ();
EnabledOnEntry = TRUE;
} else {
EnabledOnEntry = FALSE;
}
PrintLoadAddress (ImageContext); PrintLoadAddress (ImageContext);
// //
@ -1165,10 +1177,17 @@ SecPeCoffRelocateImageExtraAction (
// Hey what can you say scripting in gdb is not that great.... // Hey what can you say scripting in gdb is not that great....
// //
SecGdbScriptBreak (); SecGdbScriptBreak ();
} else {
ASSERT (FALSE);
} }
AddHandle (ImageContext, ImageContext->PdbPointer); AddHandle (ImageContext, ImageContext->PdbPointer);
if (EnabledOnEntry) {
UnixEnableInterrupt ();
}
} }
#else #else
@ -1223,12 +1242,20 @@ SecPeCoffLoaderUnloadImageExtraAction (
#ifdef __APPLE__ #ifdef __APPLE__
FILE *GdbTempFile; FILE *GdbTempFile;
BOOLEAN EnabledOnEntry;
if (Handle != NULL) { if (Handle != NULL) {
// //
// Need to skip .PDB files created from VC++ // Need to skip .PDB files created from VC++
// //
if (!IsPdbFile (ImageContext->PdbPointer)) { if (!IsPdbFile (ImageContext->PdbPointer)) {
if (UnixInterruptEanbled ()) {
UnixDisableInterrupt ();
EnabledOnEntry = TRUE;
} else {
EnabledOnEntry = FALSE;
}
// //
// Write the file we need for the gdb script // Write the file we need for the gdb script
// //
@ -1242,6 +1269,12 @@ SecPeCoffLoaderUnloadImageExtraAction (
// Hey what can you say scripting in gdb is not that great.... // Hey what can you say scripting in gdb is not that great....
// //
SecGdbScriptBreak (); SecGdbScriptBreak ();
} else {
ASSERT (FALSE);
}
if (EnabledOnEntry) {
UnixEnableInterrupt ();
} }
} }
} }

View File

@ -1,7 +1,7 @@
/*++ /*++
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR> Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -585,7 +585,6 @@ SecPeCoffLoaderUnloadImageExtraAction (
); );
VOID SetTimer (UINT64 PeriodMs, VOID (*CallBack)(UINT64 DeltaMs)); VOID SetTimer (UINT64 PeriodMs, VOID (*CallBack)(UINT64 DeltaMs));
void msSleep (unsigned long Milliseconds); void msSleep (unsigned long Milliseconds);
void GetLocalTime (EFI_TIME *Time); void GetLocalTime (EFI_TIME *Time);
@ -593,6 +592,9 @@ void TzSet (void);
long GetTimeZone(void); long GetTimeZone(void);
int GetDayLight(void); int GetDayLight(void);
int GetErrno(void); int GetErrno(void);
void UnixEnableInterrupt (void);
void UnixDisableInterrupt (void);
BOOLEAN UnixInterruptEanbled (void);

View File

@ -3,7 +3,7 @@
# #
# Main executable file of Unix Emulator that loads PEI core after initialization finished. # Main executable file of Unix Emulator that loads PEI core after initialization finished.
# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>
# Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR> # Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
# #
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
@ -42,7 +42,7 @@
Ia32/SwitchStack.c Ia32/SwitchStack.c
[Sources.X64] [Sources.X64]
# X64/Gasket.S # pure UINX x86_64 ABI also need to fix issues in BaseLib # X64/Gasket.S # pure UNIX x86_64 ABI also need to fix issues in BaseLib
X64/MangleGasket.S # convert between UNIX x86_64 ABI and EFI X64 ABI X64/MangleGasket.S # convert between UNIX x86_64 ABI and EFI X64 ABI
X64/SwitchStack.S X64/SwitchStack.S

View File

@ -1,7 +1,7 @@
/*++ /*++
Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR> Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR> Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -17,16 +17,20 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "PiPei.h" #include <PiPei.h>
#include "Protocol/UnixThunk.h" #include <Protocol/SimplePointer.h>
#include "Protocol/SimpleTextIn.h" #include <Protocol/SimpleTextIn.h>
#include "Protocol/UgaDraw.h" #include <Protocol/SimpleTextInEx.h>
#include "Protocol/UnixUgaIo.h" #include <Protocol/UgaDraw.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/Xos.h> #include <X11/Xos.h>
#include <X11/extensions/XShm.h> #include <X11/extensions/XShm.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#include <X11/cursorfont.h>
#include <Protocol/UnixThunk.h>
#include <Protocol/UnixUgaIo.h>
#include <Ppi/StatusCode.h> #include <Ppi/StatusCode.h>
@ -37,20 +41,22 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/PcdLib.h> #include <Library/PcdLib.h>
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
#include "Gasket.h"
#include "SecMain.h"
extern void msSleep (unsigned long Milliseconds); extern void msSleep (unsigned long Milliseconds);
/* XQueryPointer */ /* XQueryPointer */
struct uga_drv_shift_mask struct uga_drv_shift_mask {
{
unsigned char shift; unsigned char shift;
unsigned char size; unsigned char size;
unsigned char csize; unsigned char csize;
}; };
#define NBR_KEYS 32 #define NBR_KEYS 32
typedef struct typedef struct {
{
EFI_UNIX_UGA_IO_PROTOCOL UgaIo; EFI_UNIX_UGA_IO_PROTOCOL UgaIo;
Display *display; Display *display;
@ -75,7 +81,17 @@ typedef struct
unsigned int key_rd; unsigned int key_rd;
unsigned int key_wr; unsigned int key_wr;
unsigned int key_count; unsigned int key_count;
EFI_INPUT_KEY keys[NBR_KEYS]; EFI_KEY_DATA keys[NBR_KEYS];
EFI_KEY_STATE KeyState;
UGA_REGISTER_KEY_NOTIFY_CALLBACK RegisterdKeyCallback;
VOID *RegisterdKeyCallbackContext;
int previous_x;
int previous_y;
EFI_SIMPLE_POINTER_STATE pointer_state;
int pointer_state_changed;
} UGA_IO_PRIVATE; } UGA_IO_PRIVATE;
void void
@ -246,49 +262,165 @@ handleKeyEvent(UGA_IO_PRIVATE *drv, XEvent *ev)
{ {
KeySym keysym; KeySym keysym;
char str[4]; char str[4];
EFI_INPUT_KEY Key; EFI_KEY_DATA KeyData;
int res; int res;
if (drv->key_count == NBR_KEYS) if (drv->key_count == NBR_KEYS)
return; return;
res = XLookupString(&ev->xkey, str, sizeof(str), &keysym, NULL); res = XLookupString(&ev->xkey, str, sizeof(str), &keysym, NULL);
Key.ScanCode = 0; KeyData.Key.ScanCode = 0;
Key.UnicodeChar = 0; KeyData.Key.UnicodeChar = 0;
switch (keysym) { KeyData.KeyState.KeyShiftState = 0;
case XK_Home: Key.ScanCode = SCAN_HOME; break;
case XK_End: Key.ScanCode = SCAN_END; break;
case XK_Left: Key.ScanCode = SCAN_LEFT; break;
case XK_Right: Key.ScanCode = SCAN_RIGHT; break;
case XK_Up: Key.ScanCode = SCAN_UP; break;
case XK_Down: Key.ScanCode = SCAN_DOWN; break;
case XK_Delete: Key.ScanCode = SCAN_DELETE; break;
case XK_Insert: Key.ScanCode = SCAN_INSERT; break;
case XK_Page_Up: Key.ScanCode = SCAN_PAGE_UP; break;
case XK_Page_Down: Key.ScanCode = SCAN_PAGE_DOWN; break;
case XK_Escape: Key.ScanCode = SCAN_ESC; break;
case XK_F1: Key.ScanCode = SCAN_F1; break; //
case XK_F2: Key.ScanCode = SCAN_F2; break; // KeyRelease is not supported (on Mac) so we can not easily implement Ex functions.
case XK_F3: Key.ScanCode = SCAN_F3; break; // If a modifier key is hit by its self we get a keysym. If a modfifier and key is hit
case XK_F4: Key.ScanCode = SCAN_F4; break; // we get the state bit set and keysym is the modified key.
case XK_F5: Key.ScanCode = SCAN_F5; break; //
case XK_F6: Key.ScanCode = SCAN_F6; break; // We use lack of state bits being set to clear ToggleState and KeyShiftState. We can
case XK_F7: Key.ScanCode = SCAN_F7; break; // also use the stat bits to set ToggleState and KeyShiftState.
case XK_F8: Key.ScanCode = SCAN_F8; break; // Skipping EFI_SCROLL_LOCK_ACTIVE & EFI_NUM_LOCK_ACTIVE since they are not on Macs
case XK_F9: Key.ScanCode = SCAN_F9; break; //
if ((ev->xkey.state & LockMask) == 0) {
drv->KeyState.KeyToggleState &= ~EFI_CAPS_LOCK_ACTIVE;
} else {
drv->KeyState.KeyToggleState |= EFI_CAPS_LOCK_ACTIVE;
}
if ((ev->xkey.state & ControlMask) == 0) {
drv->KeyState.KeyShiftState &= ~(EFI_RIGHT_CONTROL_PRESSED | EFI_LEFT_CONTROL_PRESSED);
} else if ((drv->KeyState.KeyShiftState & EFI_RIGHT_CONTROL_PRESSED) == 0) {
drv->KeyState.KeyShiftState |= EFI_LEFT_CONTROL_PRESSED;
}
if ((ev->xkey.state & ShiftMask) == 0) {
drv->KeyState.KeyShiftState &= ~(EFI_RIGHT_SHIFT_PRESSED | EFI_LEFT_SHIFT_PRESSED);
} else if ((drv->KeyState.KeyShiftState & EFI_RIGHT_SHIFT_PRESSED) == 0) {
drv->KeyState.KeyShiftState |= EFI_LEFT_SHIFT_PRESSED;
}
if ((ev->xkey.state & Mod2Mask) == 0) {
drv->KeyState.KeyShiftState &= ~(EFI_RIGHT_LOGO_PRESSED | EFI_LEFT_LOGO_PRESSED);
} else if ((drv->KeyState.KeyShiftState & EFI_RIGHT_LOGO_PRESSED) == 0) {
drv->KeyState.KeyShiftState |= EFI_LEFT_LOGO_PRESSED;
}
if ((ev->xkey.state & 0x2000) == 0) {
drv->KeyState.KeyShiftState &= ~(EFI_LEFT_ALT_PRESSED);
} else {
drv->KeyState.KeyShiftState |= EFI_LEFT_ALT_PRESSED;
}
switch (keysym) {
case XK_Control_R:
drv->KeyState.KeyShiftState |= EFI_RIGHT_CONTROL_PRESSED;
break;
case XK_Control_L:
drv->KeyState.KeyShiftState |= EFI_LEFT_CONTROL_PRESSED;
break;
case XK_Shift_R:
drv->KeyState.KeyShiftState |= EFI_RIGHT_SHIFT_PRESSED;
break;
case XK_Shift_L:
drv->KeyState.KeyShiftState |= EFI_LEFT_SHIFT_PRESSED;
break;
case XK_Mode_switch:
drv->KeyState.KeyShiftState |= EFI_LEFT_ALT_PRESSED;
break;
case XK_Meta_R:
drv->KeyState.KeyShiftState |= EFI_RIGHT_LOGO_PRESSED;
break;
case XK_Meta_L:
drv->KeyState.KeyShiftState |= EFI_LEFT_LOGO_PRESSED;
break;
case XK_Home: KeyData.Key.ScanCode = SCAN_HOME; break;
case XK_End: KeyData.Key.ScanCode = SCAN_END; break;
case XK_Left: KeyData.Key.ScanCode = SCAN_LEFT; break;
case XK_Right: KeyData.Key.ScanCode = SCAN_RIGHT; break;
case XK_Up: KeyData.Key.ScanCode = SCAN_UP; break;
case XK_Down: KeyData.Key.ScanCode = SCAN_DOWN; break;
case XK_Delete: KeyData.Key.ScanCode = SCAN_DELETE; break;
case XK_Insert: KeyData.Key.ScanCode = SCAN_INSERT; break;
case XK_Page_Up: KeyData.Key.ScanCode = SCAN_PAGE_UP; break;
case XK_Page_Down: KeyData.Key.ScanCode = SCAN_PAGE_DOWN; break;
case XK_Escape: KeyData.Key.ScanCode = SCAN_ESC; break;
case XK_F1: KeyData.Key.ScanCode = SCAN_F1; break;
case XK_F2: KeyData.Key.ScanCode = SCAN_F2; break;
case XK_F3: KeyData.Key.ScanCode = SCAN_F3; break;
case XK_F4: KeyData.Key.ScanCode = SCAN_F4; break;
case XK_F5: KeyData.Key.ScanCode = SCAN_F5; break;
case XK_F6: KeyData.Key.ScanCode = SCAN_F6; break;
case XK_F7: KeyData.Key.ScanCode = SCAN_F7; break;
case XK_F8: KeyData.Key.ScanCode = SCAN_F8; break;
case XK_F9: KeyData.Key.ScanCode = SCAN_F9; break;
default: default:
if (res == 1) { if (res == 1) {
Key.UnicodeChar = str[0]; KeyData.Key.UnicodeChar = str[0];
} else { } else {
return; return;
} }
} }
drv->keys[drv->key_wr] = Key; // The global state is our state
KeyData.KeyState.KeyShiftState = drv->KeyState.KeyShiftState;
KeyData.KeyState.KeyToggleState = drv->KeyState.KeyToggleState;
CopyMem (&drv->keys[drv->key_wr], &KeyData, sizeof (EFI_KEY_DATA));
drv->key_wr = (drv->key_wr + 1) % NBR_KEYS; drv->key_wr = (drv->key_wr + 1) % NBR_KEYS;
drv->key_count++; drv->key_count++;
#if defined(__APPLE__) || defined(MDE_CPU_X64)
ReverseGasketUint64Uint64 (drv->RegisterdKeyCallback ,drv->RegisterdKeyCallbackContext, &KeyData);
#else
drv->RegisterdKeyCallback (drv->RegisterdKeyCallbackContext, &KeyData);
#endif
}
void
handleMouseMoved(UGA_IO_PRIVATE *drv, XEvent *ev)
{
if ( ev->xmotion.x != drv->previous_x )
{
drv->pointer_state.RelativeMovementX += ( ev->xmotion.x - drv->previous_x );
drv->previous_x = ev->xmotion.x;
drv->pointer_state_changed = 1;
}
if ( ev->xmotion.y != drv->previous_y )
{
drv->pointer_state.RelativeMovementY += ( ev->xmotion.y - drv->previous_y );
drv->previous_y = ev->xmotion.y;
drv->pointer_state_changed = 1;
}
drv->pointer_state.RelativeMovementZ = 0;
}
void
handleMouseDown(UGA_IO_PRIVATE *drv, XEvent *ev, BOOLEAN Pressed)
{
if ( ev->xbutton.button == Button1 )
{
drv->pointer_state_changed = ( drv->pointer_state.LeftButton != Pressed );
drv->pointer_state.LeftButton = Pressed;
}
if ( ev->xbutton.button == Button2 )
{
drv->pointer_state_changed = ( drv->pointer_state.RightButton != Pressed );
drv->pointer_state.RightButton = Pressed;
}
} }
void void
@ -319,9 +451,20 @@ HandleEvent(UGA_IO_PRIVATE *drv, XEvent *ev)
case KeyPress: case KeyPress:
handleKeyEvent(drv, ev); handleKeyEvent(drv, ev);
break; break;
case KeyRelease:
break;
case MappingNotify: case MappingNotify:
XRefreshKeyboardMapping(&ev->xmapping); XRefreshKeyboardMapping(&ev->xmapping);
break; break;
case MotionNotify:
handleMouseMoved(drv, ev);
break;
case ButtonPress:
handleMouseDown(drv, ev, TRUE);
break;
case ButtonRelease:
handleMouseDown(drv, ev, FALSE);
break;
#if 0 #if 0
case DestroyNotify: case DestroyNotify:
XCloseDisplay (drv->display); XCloseDisplay (drv->display);
@ -368,37 +511,87 @@ UgaColorToPixel (UGA_IO_PRIVATE *drv, unsigned long val)
return res; return res;
} }
EFI_STATUS STATIC EFI_STATUS
UgaCheckKey(EFI_UNIX_UGA_IO_PROTOCOL *UgaIo) CheckKeyInternal( UGA_IO_PRIVATE *drv, BOOLEAN delay )
{ {
UGA_IO_PRIVATE *drv = (UGA_IO_PRIVATE *)UgaIo;
HandleEvents(drv); HandleEvents(drv);
if (drv->key_count != 0)
if (drv->key_count != 0) {
return EFI_SUCCESS; return EFI_SUCCESS;
} else { if ( delay )
/* EFI is certainly polling. Be CPU-friendly. */ /* EFI is polling. Be CPU-friendly. */
msSleep (20); msSleep (20);
return EFI_NOT_READY; return EFI_NOT_READY;
} }
EFI_STATUS
UgaCheckKey(EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)
{
UGA_IO_PRIVATE *drv = (UGA_IO_PRIVATE *)UgaIo;
return( CheckKeyInternal( drv, TRUE ) );
} }
EFI_STATUS EFI_STATUS
UgaGetKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_INPUT_KEY *key) EFIAPI
UgaGetKey (
IN EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
IN EFI_KEY_DATA *KeyData
)
{ {
UGA_IO_PRIVATE *drv = (UGA_IO_PRIVATE *)UgaIo; UGA_IO_PRIVATE *drv = (UGA_IO_PRIVATE *)UgaIo;
EFI_STATUS status; EFI_STATUS status;
status = UgaCheckKey(UgaIo); status = CheckKeyInternal(drv, FALSE);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
return status; return status;
*key = drv->keys[drv->key_rd]; CopyMem (KeyData, &drv->keys[drv->key_rd], sizeof (EFI_KEY_DATA));
drv->key_rd = (drv->key_rd + 1) % NBR_KEYS; drv->key_rd = (drv->key_rd + 1) % NBR_KEYS;
drv->key_count--; drv->key_count--;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS
EFIAPI
UgaKeySetState (
IN EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
IN EFI_KEY_TOGGLE_STATE *KeyToggleState
)
{
UGA_IO_PRIVATE *drv = (UGA_IO_PRIVATE *)UgaIo;
// XKeyEvent event;
if (*KeyToggleState & EFI_CAPS_LOCK_ACTIVE) {
if ((drv->KeyState.KeyToggleState & EFI_CAPS_LOCK_ACTIVE) == 0) {
//
// We could create an XKeyEvent and send a XK_Caps_Lock to
// the UGA/GOP Window
//
}
}
drv->KeyState.KeyToggleState = *KeyToggleState;
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
UgaRegisterKeyNotify (
IN EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
IN UGA_REGISTER_KEY_NOTIFY_CALLBACK CallBack,
IN VOID *Context
)
{
UGA_IO_PRIVATE *drv = (UGA_IO_PRIVATE *)UgaIo;
drv->RegisterdKeyCallback = CallBack;
drv->RegisterdKeyCallbackContext = Context;
return EFI_SUCCESS;
}
EFI_STATUS EFI_STATUS
UgaBlt( UgaBlt(
IN EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, IN EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
@ -545,6 +738,44 @@ UgaBlt(
return EFI_SUCCESS; return EFI_SUCCESS;
} }
STATIC EFI_STATUS
CheckPointerInternal( UGA_IO_PRIVATE *drv, BOOLEAN delay )
{
HandleEvents(drv);
if (drv->pointer_state_changed != 0)
return EFI_SUCCESS;
if ( delay )
/* EFI is polling. Be CPU-friendly. */
msSleep (20);
return EFI_NOT_READY;
}
EFI_STATUS
UgaCheckPointer(EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)
{
UGA_IO_PRIVATE *drv = (UGA_IO_PRIVATE *)UgaIo;
return( CheckPointerInternal( drv, TRUE ) );
}
EFI_STATUS
UgaGetPointerState (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_SIMPLE_POINTER_STATE *state)
{
UGA_IO_PRIVATE *drv = (UGA_IO_PRIVATE *)UgaIo;
EFI_STATUS status;
status = CheckPointerInternal( drv, FALSE );
if (status != EFI_SUCCESS)
return status;
memcpy( state, &drv->pointer_state, sizeof( EFI_SIMPLE_POINTER_STATE ) );
drv->pointer_state.RelativeMovementX = 0;
drv->pointer_state.RelativeMovementY = 0;
drv->pointer_state.RelativeMovementZ = 0;
drv->pointer_state_changed = 0;
return EFI_SUCCESS;
}
EFI_STATUS EFI_STATUS
UgaCreate (EFI_UNIX_UGA_IO_PROTOCOL **Uga, CONST CHAR16 *Title) UgaCreate (EFI_UNIX_UGA_IO_PROTOCOL **Uga, CONST CHAR16 *Title)
{ {
@ -557,32 +788,29 @@ UgaCreate (EFI_UNIX_UGA_IO_PROTOCOL **Uga, CONST CHAR16 *Title)
if (drv == NULL) if (drv == NULL)
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
#ifdef __APPLE__ #if defined(__APPLE__) || defined(MDE_CPU_X64)
// //
// //
// //
EFI_STATUS EFIAPI GasketUgaClose (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo);
EFI_STATUS EFIAPI GasketUgaSize (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, UINT32 Width, UINT32 Height);
EFI_STATUS EFIAPI GasketUgaCheckKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo);
EFI_STATUS EFIAPI GasketUgaGetKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_INPUT_KEY *key);
EFI_STATUS EFIAPI GasketUgaBlt (
EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
IN EFI_UGA_BLT_OPERATION BltOperation,
IN UGA_BLT_ARGS *Args
);
drv->UgaIo.UgaClose = GasketUgaClose; drv->UgaIo.UgaClose = GasketUgaClose;
drv->UgaIo.UgaSize = GasketUgaSize; drv->UgaIo.UgaSize = GasketUgaSize;
drv->UgaIo.UgaCheckKey = GasketUgaCheckKey; drv->UgaIo.UgaCheckKey = GasketUgaCheckKey;
drv->UgaIo.UgaGetKey = GasketUgaGetKey; drv->UgaIo.UgaGetKey = GasketUgaGetKey;
drv->UgaIo.UgaKeySetState = GasketUgaKeySetState;
drv->UgaIo.UgaRegisterKeyNotify = GasketUgaRegisterKeyNotify;
drv->UgaIo.UgaBlt = GasketUgaBlt; drv->UgaIo.UgaBlt = GasketUgaBlt;
drv->UgaIo.UgaCheckPointer = GasketUgaCheckPointer;
drv->UgaIo.UgaGetPointerState = GasketUgaGetPointerState;
#else #else
drv->UgaIo.UgaClose = UgaClose; drv->UgaIo.UgaClose = UgaClose;
drv->UgaIo.UgaSize = UgaSize; drv->UgaIo.UgaSize = UgaSize;
drv->UgaIo.UgaCheckKey = UgaCheckKey; drv->UgaIo.UgaCheckKey = UgaCheckKey;
drv->UgaIo.UgaGetKey = UgaGetKey; drv->UgaIo.UgaGetKey = UgaGetKey;
drv->UgaIo.UgaKeySetState = UgaKeySetState;
drv->UgaIo.UgaRegisterKeyNotify = UgaRegisterKeyNotify;
drv->UgaIo.UgaBlt = UgaBlt; drv->UgaIo.UgaBlt = UgaBlt;
drv->UgaIo.UgaCheckPointer = UgaCheckPointer;
drv->UgaIo.UgaGetPointerState = UgaGetPointerState;
#endif #endif
@ -590,6 +818,12 @@ EFI_STATUS EFIAPI GasketUgaBlt (
drv->key_count = 0; drv->key_count = 0;
drv->key_rd = 0; drv->key_rd = 0;
drv->key_wr = 0; drv->key_wr = 0;
drv->KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID;
drv->KeyState.KeyToggleState = EFI_TOGGLE_STATE_VALID;
drv->RegisterdKeyCallback = NULL;
drv->RegisterdKeyCallbackContext = NULL;
drv->display = XOpenDisplay (display_name); drv->display = XOpenDisplay (display_name);
if (drv->display == NULL) if (drv->display == NULL)
{ {
@ -607,6 +841,7 @@ EFI_STATUS EFIAPI GasketUgaBlt (
BlackPixel (drv->display, drv->screen)); BlackPixel (drv->display, drv->screen));
drv->depth = DefaultDepth (drv->display, drv->screen); drv->depth = DefaultDepth (drv->display, drv->screen);
XDefineCursor (drv->display, drv->win, XCreateFontCursor (drv->display, XC_pirate));
/* Compute title len and convert to Ascii. */ /* Compute title len and convert to Ascii. */
for (title_len = 0; Title[title_len] != 0; title_len++) for (title_len = 0; Title[title_len] != 0; title_len++)
@ -621,8 +856,8 @@ EFI_STATUS EFIAPI GasketUgaBlt (
XStoreName (drv->display, drv->win, title); XStoreName (drv->display, drv->win, title);
} }
XSelectInput (drv->display, drv->win, ExposureMask | KeyPressMask); XSelectInput (drv->display, drv->win,
ExposureMask | KeyPressMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask );
drv->gc = DefaultGC (drv->display, drv->screen); drv->gc = DefaultGC (drv->display, drv->screen);
*Uga = (EFI_UNIX_UGA_IO_PROTOCOL *)drv; *Uga = (EFI_UNIX_UGA_IO_PROTOCOL *)drv;

View File

@ -1,14 +1,14 @@
/*++ /*++
Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR> Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR> Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name: Module Name:
@ -16,7 +16,7 @@ Module Name:
Abstract: Abstract:
Since the SEC is the only program in our emulation we Since the SEC is the only program in our emulation we
must use a Tiano mechanism to export APIs to other modules. must use a Tiano mechanism to export APIs to other modules.
This is the role of the EFI_UNIX_THUNK_PROTOCOL. This is the role of the EFI_UNIX_THUNK_PROTOCOL.
@ -25,7 +25,7 @@ Abstract:
are not added. It looks like adding a element to end and not initializing are not added. It looks like adding a element to end and not initializing
it may cause the table to be initaliized with the members at the end being it may cause the table to be initaliized with the members at the end being
set to zero. This is bad as jumping to zero will crash. set to zero. This is bad as jumping to zero will crash.
gUnix is a a public exported global that contains the initialized gUnix is a a public exported global that contains the initialized
data. data.
@ -44,6 +44,9 @@ int settimer_initialized;
struct timeval settimer_timeval; struct timeval settimer_timeval;
void (*settimer_callback)(UINT64 delta); void (*settimer_callback)(UINT64 delta);
BOOLEAN gEmulatorInterruptEnabled = FALSE;
void void
settimer_handler (int sig) settimer_handler (int sig)
{ {
@ -52,15 +55,15 @@ settimer_handler (int sig)
gettimeofday (&timeval, NULL); gettimeofday (&timeval, NULL);
delta = ((UINT64)timeval.tv_sec * 1000) + (timeval.tv_usec / 1000) delta = ((UINT64)timeval.tv_sec * 1000) + (timeval.tv_usec / 1000)
- ((UINT64)settimer_timeval.tv_sec * 1000) - ((UINT64)settimer_timeval.tv_sec * 1000)
- (settimer_timeval.tv_usec / 1000); - (settimer_timeval.tv_usec / 1000);
settimer_timeval = timeval; settimer_timeval = timeval;
if (settimer_callback) { if (settimer_callback) {
#if defined(__APPLE__) || defined(MDE_CPU_X64) #if defined(__APPLE__) || defined(MDE_CPU_X64)
ReverseGasketUint64 (settimer_callback, delta); ReverseGasketUint64 (settimer_callback, delta);
#else #else
(*settimer_callback)(delta); (*settimer_callback)(delta);
#endif #endif
} }
} }
@ -78,6 +81,7 @@ SetTimer (UINT64 PeriodMs, VOID (*CallBack)(UINT64 DeltaMs))
act.sa_handler = settimer_handler; act.sa_handler = settimer_handler;
act.sa_flags = 0; act.sa_flags = 0;
sigemptyset (&act.sa_mask); sigemptyset (&act.sa_mask);
gEmulatorInterruptEnabled = TRUE;
if (sigaction (SIGALRM, &act, NULL) != 0) { if (sigaction (SIGALRM, &act, NULL) != 0) {
printf ("SetTimer: sigaction error %s\n", strerror (errno)); printf ("SetTimer: sigaction error %s\n", strerror (errno));
} }
@ -90,13 +94,50 @@ SetTimer (UINT64 PeriodMs, VOID (*CallBack)(UINT64 DeltaMs))
timerval.it_value.tv_usec = remainder * 1000; timerval.it_value.tv_usec = remainder * 1000;
timerval.it_value.tv_sec = DivU64x32(PeriodMs, 1000); timerval.it_value.tv_sec = DivU64x32(PeriodMs, 1000);
timerval.it_interval = timerval.it_value; timerval.it_interval = timerval.it_value;
if (setitimer (ITIMER_REAL, &timerval, NULL) != 0) { if (setitimer (ITIMER_REAL, &timerval, NULL) != 0) {
printf ("SetTimer: setitimer error %s\n", strerror (errno)); printf ("SetTimer: setitimer error %s\n", strerror (errno));
} }
settimer_callback = CallBack; settimer_callback = CallBack;
} }
void
UnixEnableInterrupt (void)
{
sigset_t sigset;
gEmulatorInterruptEnabled = TRUE;
// Since SetTimer() uses SIGALRM we emulate turning on and off interrupts
// by enabling/disabling SIGALRM.
sigemptyset (&sigset);
sigaddset (&sigset, SIGALRM);
sigprocmask (SIG_UNBLOCK, &sigset, NULL);
}
void
UnixDisableInterrupt (void)
{
sigset_t sigset;
// Since SetTimer() uses SIGALRM we emulate turning on and off interrupts
// by enabling/disabling SIGALRM.
sigemptyset (&sigset);
sigaddset (&sigset, SIGALRM);
sigprocmask (SIG_BLOCK, &sigset, NULL);
gEmulatorInterruptEnabled = FALSE;
}
BOOLEAN
UnixInterruptEanbled (void)
{
return gEmulatorInterruptEnabled;
}
void void
msSleep (unsigned long Milliseconds) msSleep (unsigned long Milliseconds)
{ {
@ -110,7 +151,7 @@ msSleep (unsigned long Milliseconds)
break; break;
} }
rq = rm; rq = rm;
} }
} }
@ -174,7 +215,7 @@ EFI_UNIX_THUNK_PROTOCOL mUnixThunkTable = {
#if defined(__APPLE__) || defined(MDE_CPU_X64) #if defined(__APPLE__) || defined(MDE_CPU_X64)
// //
// Mac OS X requires the stack to be 16-byte aligned for IA-32. So on an OS X build // Mac OS X requires the stack to be 16-byte aligned for IA-32. So on an OS X build
// we add an assembly wrapper that makes sure the stack ges aligned. // we add an assembly wrapper that makes sure the stack ges aligned.
// This has the nice benfit of being able to run EFI ABI code, like the EFI shell // This has the nice benfit of being able to run EFI ABI code, like the EFI shell
// that is checked in to source control in the OS X version of the emulator // that is checked in to source control in the OS X version of the emulator
// //
@ -217,9 +258,16 @@ EFI_UNIX_THUNK_PROTOCOL mUnixThunkTable = {
Gasketcfsetospeed, Gasketcfsetospeed,
Gaskettcgetattr, Gaskettcgetattr,
Gaskettcsetattr, Gaskettcsetattr,
GasketUnixPeCoffGetEntryPoint, GasketUnixPeCoffGetEntryPoint,
GasketUnixPeCoffRelocateImageExtraAction, GasketUnixPeCoffRelocateImageExtraAction,
GasketUnixPeCoffUnloadImageExtraAction GasketUnixPeCoffUnloadImageExtraAction,
GasketUnixEnableInterrupt,
GasketUnixDisableInterrupt,
Gasketgetifaddrs,
Gasketfreeifaddrs,
Gasketsocket,
#else #else
msSleep, /* Sleep */ msSleep, /* Sleep */
@ -263,7 +311,12 @@ EFI_UNIX_THUNK_PROTOCOL mUnixThunkTable = {
tcsetattr, tcsetattr,
SecPeCoffGetEntryPoint, SecPeCoffGetEntryPoint,
SecPeCoffRelocateImageExtraAction, SecPeCoffRelocateImageExtraAction,
SecPeCoffLoaderUnloadImageExtraAction SecPeCoffLoaderUnloadImageExtraAction,
UnixEnableInterrupt,
UnixDisableInterrupt,
getifaddrs,
freeifaddrs,
socket
#endif #endif
}; };

File diff suppressed because it is too large Load Diff

View File

@ -1,154 +0,0 @@
/** @file
Template file used to create Gasket.S
This file is built on the command line via gcc GasketTemplate.c -S
and it will create GasketTemplate.s and this was used to create
Gasket.S. This builds code for Unix ABI on both sides. To convert
to EFI ABI will require changing the code by hand
Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2008 - 2010, Apple Inc. 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 <stdint.h>
#include <sys/stat.h>
typedef int8_t INT8;
typedef uint8_t UINT8;
typedef int16_t INT16;
typedef uint16_t UINT16;
typedef int32_t INT32;
typedef uint32_t UINT32;
typedef int64_t INT64;
typedef uint64_t UINT64;
typedef UINT64 UINTN;
typedef UINTN (*GASKET_VOID) ();
typedef UINTN (*GASKET_UINTN) (UINTN);
typedef UINTN (*GASKET_UINT64) (UINT64);
typedef UINTN (*GASKET_UINTN_UINTN) (UINTN, UINTN);
typedef UINTN (*GASKET_UINTN_UINTN_UINTN) (UINTN, UINTN, UINTN);
typedef UINTN (*GASKET_UINTN_UINTN_UINTN_UINTN) (UINTN, UINTN, UINTN, UINTN);
typedef UINTN (*GASKET_UINTN_10ARGS) (UINTN, UINTN, UINTN, UINTN, UINTN, UINTN, UINTN, UINTN, UINTN, UINTN);
typedef UINTN (*GASKET_UINT64_UINTN) (UINT64, UINTN);
typedef UINT64 (*GASKET_UINTN_UINT64_UINTN) (UINTN, UINT64, UINTN);
typedef UINTN (*GASKET_UINTN_UINT16) (UINTN, UINT16);
UINTN GasketVoid (void *api);
UINTN GasketUintn (void *api, UINTN a);
UINTN GasketUintnUintn (void *api, UINTN a, UINTN b);
UINTN GasketUintnUintnUintn (void *api, UINTN a, UINTN b, UINTN c);
UINTN GasketUintnUintnUintnUintn (void *api, UINTN a, UINTN b, UINTN c, UINTN d);
UINTN GasketUintn10Args (void *api, UINTN a, UINTN b, UINTN c, UINTN d, UINTN e, UINTN f, UINTN g, UINTN h, UINTN i, UINTN j);
UINTN GasketUint64Uintn (void *api, UINT64 a, UINTN b);
UINT64 GasketUintnUiny64Uintn (void *api, UINTN a, UINT64 b, UINTN c);
UINTN GasketUintnUint16 (void *api, UINTN a, UINT16 b);
UINTN
GasketVoid (void *api)
{
GASKET_VOID func;
func = (GASKET_VOID)api;
return func ();
}
UINTN
GasketUintn (void *api, UINTN a)
{
GASKET_UINTN func;
func = (GASKET_UINTN)api;
return func (a);
}
UINTN
GasketUintnUintn (void *api, UINTN a, UINTN b)
{
GASKET_UINTN_UINTN func;
func = (GASKET_UINTN_UINTN)api;
return func (a, b);
}
UINTN
GasketUintnUintnUintn (void *api, UINTN a, UINTN b, UINTN c)
{
GASKET_UINTN_UINTN_UINTN func;
func = (GASKET_UINTN_UINTN_UINTN)api;
return func (a, b, c);
}
UINTN
GasketUintnUintnUintnUintn (void *api, UINTN a, UINTN b, UINTN c, UINTN d)
{
GASKET_UINTN_UINTN_UINTN_UINTN func;
func = (GASKET_UINTN_UINTN_UINTN_UINTN)api;
return func (a, b, c, d);
}
UINTN
GasketUintn10Args (void *api, UINTN a, UINTN b, UINTN c, UINTN d, UINTN e, UINTN f, UINTN g, UINTN h, UINTN i, UINTN j)
{
GASKET_UINTN_10ARGS func;
func = (GASKET_UINTN_10ARGS)api;
return func (a, b, c, d, e, f, g, h, i, j);
}
UINTN
GasketUint64Uintn (void *api, UINT64 a, UINTN b)
{
GASKET_UINT64_UINTN func;
func = (GASKET_UINT64_UINTN)api;
return func (a, b);
}
UINT64
GasketUintnUint64Uintn (void *api, UINTN a, UINT64 b, UINTN c)
{
GASKET_UINTN_UINT64_UINTN func;
func = (GASKET_UINTN_UINT64_UINTN)api;
return func (a, b, c);
}
UINTN
GasketUintnUint16 (void *api, UINTN a, UINT16 b)
{
GASKET_UINTN_UINT16 func;
func = (GASKET_UINTN_UINT16)api;
return func (a, b);
}
void
ReverseGasketUint64 (void *api, UINT64 a)
{
GASKET_UINT64 func;
func = (GASKET_UINT64)api;
func (a);
return;
}

File diff suppressed because it is too large Load Diff

View File

@ -39,7 +39,9 @@
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
ASM_GLOBAL ASM_PFX(PeiSwitchStacks) ASM_GLOBAL ASM_PFX(PeiSwitchStacks)
ASM_PFX(PeiSwitchStacks): ASM_PFX(PeiSwitchStacks):
// movq %rdx, %rdx pushq %rbp // stack frame is for the debugger
movq %rsp, %rbp
movq %r8, %rsp movq %r8, %rsp
movq %rdi, %rax movq %rdi, %rax
@ -50,7 +52,7 @@ ASM_PFX(PeiSwitchStacks):
# Reserve space for register parameters (rcx, rdx, r8 & r9) on the stack, # Reserve space for register parameters (rcx, rdx, r8 & r9) on the stack,
# in case the callee wishes to spill them. # in case the callee wishes to spill them.
# #
subq $40, %rsp // 32-byte shadow space plus alignment pad subq $32, %rsp // 32-byte shadow space plus alignment pad
call *%rax call *%rax
@ -74,6 +76,9 @@ ASM_PFX(PeiSwitchStacks):
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
ASM_GLOBAL ASM_PFX(UnixPeiSwitchStacks) ASM_GLOBAL ASM_PFX(UnixPeiSwitchStacks)
ASM_PFX(UnixPeiSwitchStacks): ASM_PFX(UnixPeiSwitchStacks):
pushq %rbp // stack frame is for the debugger
movq %rsp, %rbp
mov %rdi, %rax mov %rdi, %rax
mov %rsi, %rdi mov %rsi, %rdi
mov %rdx, %rsi mov %rdx, %rsi
@ -100,12 +105,16 @@ ASM_PFX(UnixPeiSwitchStacks):
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
ASM_GLOBAL ASM_PFX(SecSwitchStack) ASM_GLOBAL ASM_PFX(SecSwitchStack)
ASM_PFX(SecSwitchStack): ASM_PFX(SecSwitchStack):
pushq %rbp // stack frame is for the debugger
movq %rsp, %rbp
mov %rsp, %rax mov %rsp, %rax
sub %rdi, %rax sub %rdi, %rax
add %rsi, %rax add %rsi, %rax
mov (%rip), %r10 mov (%rip), %r10
mov %r10, (%rax) mov %r10, (%rax)
popq %rbp
ret ret

View File

@ -15,7 +15,7 @@ Module Name:
Abstract: Abstract:
This following section documents the envirnoment variables for the Win UNIX This following section documents the environment variables for the UNIX
build. These variables are used to define the (virtual) hardware build. These variables are used to define the (virtual) hardware
configuration of the UNIX environment configuration of the UNIX environment
@ -118,15 +118,17 @@ EFI_DRIVER_BINDING_PROTOCOL gUnixBusDriverBinding = {
// device path. // device path.
// //
UNIX_PCD_ENTRY mPcdEnvironment[] = { UNIX_PCD_ENTRY mPcdEnvironment[] = {
{PcdToken(PcdUnixConsole), &gEfiUnixConsoleGuid}, {PcdToken(PcdUnixConsole), &gEfiUnixConsoleGuid},
{PcdToken(PcdUnixUga), &gEfiUnixUgaGuid}, {PcdToken(PcdUnixUga), &gEfiUnixUgaGuid},
{PcdToken(PcdUnixFileSystem), &gEfiUnixFileSystemGuid}, {PcdToken(PcdUnixGop), &gEfiUnixGopGuid},
{PcdToken(PcdUnixSerialPort), &gEfiUnixSerialPortGuid}, {PcdToken(PcdUnixFileSystem), &gEfiUnixFileSystemGuid},
{PcdToken(PcdUnixVirtualDisk), &gEfiUnixVirtualDisksGuid}, {PcdToken(PcdUnixSerialPort), &gEfiUnixSerialPortGuid},
{PcdToken(PcdUnixPhysicalDisk), &gEfiUnixPhysicalDisksGuid}, {PcdToken(PcdUnixVirtualDisk), &gEfiUnixVirtualDisksGuid},
{PcdToken(PcdUnixCpuModel), &gEfiUnixCPUModelGuid}, {PcdToken(PcdUnixPhysicalDisk), &gEfiUnixPhysicalDisksGuid},
{PcdToken(PcdUnixCpuSpeed), &gEfiUnixCPUSpeedGuid}, {PcdToken(PcdUnixCpuModel), &gEfiUnixCPUModelGuid},
{PcdToken(PcdUnixMemorySize), &gEfiUnixMemoryGuid} {PcdToken(PcdUnixCpuSpeed), &gEfiUnixCPUSpeedGuid},
{PcdToken(PcdUnixMemorySize), &gEfiUnixMemoryGuid},
{PcdToken(PcdUnixNetworkInterface), &gEfiUnixNetworkGuid}
}; };
VOID * VOID *
@ -168,13 +170,6 @@ Returns:
None None
--*/ --*/
// TODO: This - add argument and description to function comment
// TODO: ControllerHandle - add argument and description to function comment
// TODO: RemainingDevicePath - add argument and description to function comment
// TODO: EFI_UNSUPPORTED - add return value to function comment
// TODO: EFI_UNSUPPORTED - add return value to function comment
// TODO: EFI_SUCCESS - add return value to function comment
// TODO: EFI_SUCCESS - add return value to function comment
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
@ -300,12 +295,6 @@ Returns:
None None
--*/ --*/
// TODO: This - add argument and description to function comment
// TODO: ControllerHandle - add argument and description to function comment
// TODO: RemainingDevicePath - add argument and description to function comment
// TODO: EFI_OUT_OF_RESOURCES - add return value to function comment
// TODO: EFI_OUT_OF_RESOURCES - add return value to function comment
// TODO: EFI_SUCCESS - add return value to function comment
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_STATUS InstallStatus; EFI_STATUS InstallStatus;
@ -403,7 +392,7 @@ Returns:
StartString = TempStr; StartString = TempStr;
// //
// Parse the envirnment variable into sub strings using '!' as a delimator. // Parse the environment variable into sub strings using '!' as a delimator.
// Each substring needs it's own handle to be added to the system. This code // Each substring needs it's own handle to be added to the system. This code
// does not understand the sub string. Thats the device drivers job. // does not understand the sub string. Thats the device drivers job.
// //
@ -566,13 +555,6 @@ Returns:
None None
--*/ --*/
// TODO: This - add argument and description to function comment
// TODO: ControllerHandle - add argument and description to function comment
// TODO: NumberOfChildren - add argument and description to function comment
// TODO: ChildHandleBuffer - add argument and description to function comment
// TODO: EFI_SUCCESS - add return value to function comment
// TODO: EFI_DEVICE_ERROR - add return value to function comment
// TODO: EFI_SUCCESS - add return value to function comment
{ {
EFI_STATUS Status; EFI_STATUS Status;
UINTN Index; UINTN Index;

View File

@ -61,6 +61,7 @@
[Guids] [Guids]
gEfiUnixConsoleGuid # ALWAYS_CONSUMED gEfiUnixConsoleGuid # ALWAYS_CONSUMED
gEfiUnixUgaGuid # ALWAYS_CONSUMED gEfiUnixUgaGuid # ALWAYS_CONSUMED
gEfiUnixGopGuid # ALWAYS_CONSUMED
gEfiUnixSerialPortGuid # ALWAYS_CONSUMED gEfiUnixSerialPortGuid # ALWAYS_CONSUMED
gEfiUnixFileSystemGuid # ALWAYS_CONSUMED gEfiUnixFileSystemGuid # ALWAYS_CONSUMED
gEfiUnixPhysicalDisksGuid # ALWAYS_CONSUMED gEfiUnixPhysicalDisksGuid # ALWAYS_CONSUMED
@ -68,6 +69,7 @@
gEfiUnixCPUModelGuid gEfiUnixCPUModelGuid
gEfiUnixCPUSpeedGuid gEfiUnixCPUSpeedGuid
gEfiUnixMemoryGuid gEfiUnixMemoryGuid
gEfiUnixNetworkGuid
[Protocols] [Protocols]
@ -86,5 +88,7 @@
gEfiUnixPkgTokenSpaceGuid.PcdUnixVirtualDisk gEfiUnixPkgTokenSpaceGuid.PcdUnixVirtualDisk
gEfiUnixPkgTokenSpaceGuid.PcdUnixFileSystem gEfiUnixPkgTokenSpaceGuid.PcdUnixFileSystem
gEfiUnixPkgTokenSpaceGuid.PcdUnixUga gEfiUnixPkgTokenSpaceGuid.PcdUnixUga
gEfiUnixPkgTokenSpaceGuid.PcdUnixGop
gEfiUnixPkgTokenSpaceGuid.PcdUnixConsole gEfiUnixPkgTokenSpaceGuid.PcdUnixConsole
gEfiUnixPkgTokenSpaceGuid.PcdUnixNetworkInterface

View File

@ -0,0 +1,251 @@
/*++
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2010, Apple, Inc. 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.
Module Name:
ComponentName.c
Abstract:
--*/
#include "UnixGop.h"
//
// EFI Component Name Functions
//
EFI_STATUS
EFIAPI
UnixGopComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
);
EFI_STATUS
EFIAPI
UnixGopComponentNameGetControllerName (
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
//
EFI_COMPONENT_NAME_PROTOCOL gUnixGopComponentName = {
UnixGopComponentNameGetDriverName,
UnixGopComponentNameGetControllerName,
"eng"
};
//
// EFI Component Name 2 Protocol
//
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUnixGopComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) UnixGopComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) UnixGopComponentNameGetControllerName,
"en"
};
EFI_UNICODE_STRING_TABLE mUnixGopDriverNameTable[] = {
{ "eng", L"Unix GOP 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
UnixGopComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
)
{
return LookupUnicodeString2 (
Language,
This->SupportedLanguages,
mUnixGopDriverNameTable,
DriverName,
(BOOLEAN)(This == &gUnixGopComponentName)
);
}
/**
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 not a valid EFI_HANDLE.
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
EFI_HANDLE.
@retval EFI_INVALID_PARAMETER 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
UnixGopComponentNameGetControllerName (
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_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
GOP_PRIVATE_DATA *Private;
//
// This is a device driver, so ChildHandle must be NULL.
//
if (ChildHandle != NULL) {
return EFI_UNSUPPORTED;
}
//
// Make sure this driver is currently managing ControllerHandle
//
Status = EfiTestManagedDevice (
ControllerHandle,
gUnixGopDriverBinding.DriverBindingHandle,
&gEfiUnixIoProtocolGuid
);
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
//
// Get our context back
//
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiGraphicsOutputProtocolGuid,
(VOID **)&GraphicsOutput,
gUnixGopDriverBinding.DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
Private = GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput);
return LookupUnicodeString2 (
Language,
This->SupportedLanguages,
Private->ControllerNameTable,
ControllerName,
(BOOLEAN)(This == &gUnixGopComponentName)
);
}

View File

@ -0,0 +1,377 @@
/*++
Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2010, Apple, Inc. 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.
Module Name:
UnixGop.h
Abstract:
Private data for the Gop driver that is bound to the Unix Thunk protocol
--*/
#ifndef _UNIX_UGA_H_
#define _UNIX_UGA_H_
#include <PiDxe.h>
#include "UnixDxe.h"
#include <Library/DebugLib.h>
#include <Library/BaseLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Protocol/GraphicsOutput.h>
#include <Protocol/SimpleTextIn.h>
#include <Protocol/SimpleTextInEx.h>
#include <Protocol/SimplePointer.h>
#include "Protocol/UnixUgaIo.h"
#include <Guid/EventGroup.h>
#define MAX_Q 256
typedef struct {
UINTN Front;
UINTN Rear;
UINTN Count;
EFI_INPUT_KEY Q[MAX_Q];
} GOP_QUEUE_FIXED;
#define UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('U', 'g', 'S', 'n')
typedef struct _UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY {
UINTN Signature;
EFI_HANDLE NotifyHandle;
EFI_KEY_DATA KeyData;
EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;
EFI_EVENT Event;
LIST_ENTRY NotifyEntry;
} UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY;
#define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff
typedef struct {
UINT32 HorizontalResolution;
UINT32 VerticalResolution;
UINT32 ColorDepth;
UINT32 RefreshRate;
} GOP_MODE_DATA;
extern EFI_DRIVER_BINDING_PROTOCOL gUnixGopDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gUnixGopComponentName;
#define UNIX_UGA_CLASS_NAME L"UnixGopWindow"
#define GOP_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('G', 'o', 'p', 'N')
typedef struct {
UINT64 Signature;
EFI_HANDLE Handle;
EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput;
EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleTextIn;
EFI_SIMPLE_POINTER_PROTOCOL SimplePointer;
EFI_UNIX_THUNK_PROTOCOL *UnixThunk;
EFI_UNIX_UGA_IO_PROTOCOL *UgaIo;
EFI_UNICODE_STRING_TABLE *ControllerNameTable;
EFI_SIMPLE_POINTER_MODE PointerMode;
//
// GOP Private Data for QueryMode ()
//
GOP_MODE_DATA *ModeData;
//
// UGA Private Data knowing when to start hardware
//
BOOLEAN HardwareNeedsStarting;
CHAR16 *WindowName;
GOP_QUEUE_FIXED Queue;
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleTextInEx;
EFI_KEY_STATE KeyState;
LIST_ENTRY NotifyList;
} GOP_PRIVATE_DATA;
#define GOP_PRIVATE_DATA_FROM_THIS(a) \
CR(a, GOP_PRIVATE_DATA, GraphicsOutput, GOP_PRIVATE_DATA_SIGNATURE)
#define GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS(a) \
CR(a, GOP_PRIVATE_DATA, SimpleTextIn, GOP_PRIVATE_DATA_SIGNATURE)
#define GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS(a) \
CR(a, GOP_PRIVATE_DATA, SimpleTextInEx, GOP_PRIVATE_DATA_SIGNATURE)
#define GOP_PRIVATE_DATA_FROM_POINTER_MODE_THIS(a) \
CR(a, GOP_PRIVATE_DATA, SimplePointer, GOP_PRIVATE_DATA_SIGNATURE)
//
// Global Protocol Variables
//
extern EFI_DRIVER_BINDING_PROTOCOL gUnixGopDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gUnixGopComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gUnixGopComponentName2;
//
// Gop Hardware abstraction internal worker functions
//
EFI_STATUS
UnixGopSupported (
IN EFI_UNIX_IO_PROTOCOL *UnixIo
)
/*++
Routine Description:
TODO: Add function description
Arguments:
UnixIo - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
UnixGopConstructor (
IN GOP_PRIVATE_DATA *Private
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
UnixGopDestructor (
IN GOP_PRIVATE_DATA *Private
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Returns:
TODO: add return values
--*/
;
//
// EFI 1.1 driver model prototypes for Win UNIX UGA
//
EFI_STATUS
EFIAPI
UnixGopInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
TODO: Add function description
Arguments:
ImageHandle - TODO: add argument description
SystemTable - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
EFIAPI
UnixGopDriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Handle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Handle - TODO: add argument description
RemainingDevicePath - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
EFIAPI
UnixGopDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Handle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Handle - TODO: add argument description
RemainingDevicePath - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
EFIAPI
UnixGopDriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Handle,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Handle - TODO: add argument description
NumberOfChildren - TODO: add argument description
ChildHandleBuffer - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
GopPrivateAddQ (
IN GOP_PRIVATE_DATA *Private,
IN EFI_INPUT_KEY Key
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Key - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
UnixGopInitializeSimpleTextInForWindow (
IN GOP_PRIVATE_DATA *Private
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
UnixGopInitializeSimplePointerForWindow (
IN GOP_PRIVATE_DATA *Private
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Returns:
TODO: add return values
--*/
;
#endif

View File

@ -0,0 +1,73 @@
## @file
# Uga driver
#
# UGA is short hand for Universal Graphics Abstraction protocol.
# This file is a verision of UgaIo the uses UnixThunk system calls as an IO
# abstraction. For a PCI device UnixIo would be replaced with
# a PCI IO abstraction that abstracted a specific PCI device.
# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
# Portions copyright (c) 2010, Apple, Inc. 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 = UnixUga
FILE_GUID = f33cad86-8985-11db-8040-0040d02b1835
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = InitializeUnixGop
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
# DRIVER_BINDING = gUnixUgaDriverBinding
# COMPONENT_NAME = gUnixUgaComponentName
#
[Sources]
ComponentName.c
UnixGopScreen.c
UnixGopDriver.c
UnixGopInput.c
UnixGop.h
[Packages]
MdePkg/MdePkg.dec
UnixPkg/UnixPkg.dec
[LibraryClasses]
UefiBootServicesTableLib
MemoryAllocationLib
BaseMemoryLib
UefiLib
UefiDriverEntryPoint
BaseLib
DebugLib
[Guids]
gEfiEventExitBootServicesGuid # SOMETIMES_CONSUMED Create Event: EVENT_GROUP_GUID
gEfiUnixGopGuid # ALWAYS_CONSUMED
[Protocols]
gEfiGraphicsOutputProtocolGuid
gEfiSimpleTextInProtocolGuid # PROTOCOL BY_START
gEfiSimpleTextInputExProtocolGuid # PROTOCOL BY_START
gEfiSimplePointerProtocolGuid # PROTOCOL BY_START
gEfiUnixIoProtocolGuid # PROTOCOL TO_START

View File

@ -0,0 +1,396 @@
/*++
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2010, Apple, Inc. 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.
Module Name:
UnixGopDriver.c
Abstract:
This file implements the EFI 1.1 Device Driver model requirements for UGA
UGA is short hand for Universal Graphics Abstraction protocol.
This file is a verision of UgaIo the uses UnixThunk system calls as an IO
abstraction. For a PCI device UnixIo would be replaced with
a PCI IO abstraction that abstracted a specific PCI device.
--*/
#include "UnixGop.h"
EFI_STATUS
FreeNotifyList (
IN OUT LIST_ENTRY *ListHead
)
/*++
Routine Description:
Arguments:
ListHead - The list head
Returns:
EFI_SUCCESS - Free the notify list successfully
EFI_INVALID_PARAMETER - ListHead is invalid.
--*/
{
UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY *NotifyNode;
if (ListHead == NULL) {
return EFI_INVALID_PARAMETER;
}
while (!IsListEmpty (ListHead)) {
NotifyNode = CR (
ListHead->ForwardLink,
UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY,
NotifyEntry,
UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
);
RemoveEntryList (ListHead->ForwardLink);
gBS->FreePool (NotifyNode);
}
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
UnixGopDriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Handle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
Routine Description:
Arguments:
Returns:
None
--*/
// TODO: This - add argument and description to function comment
// TODO: Handle - add argument and description to function comment
// TODO: RemainingDevicePath - add argument and description to function comment
{
EFI_STATUS Status;
EFI_UNIX_IO_PROTOCOL *UnixIo;
//
// Open the IO Abstraction(s) needed to perform the supported test
//
Status = gBS->OpenProtocol (
Handle,
&gEfiUnixIoProtocolGuid,
(VOID **)&UnixIo,
This->DriverBindingHandle,
Handle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
return Status;
}
Status = UnixGopSupported (UnixIo);
//
// Close the I/O Abstraction(s) used to perform the supported test
//
gBS->CloseProtocol (
Handle,
&gEfiUnixIoProtocolGuid,
This->DriverBindingHandle,
Handle
);
return Status;
}
EFI_STATUS
EFIAPI
UnixGopDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Handle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
/*++
Routine Description:
Arguments:
Returns:
None
--*/
// TODO: This - add argument and description to function comment
// TODO: Handle - add argument and description to function comment
// TODO: RemainingDevicePath - add argument and description to function comment
// TODO: EFI_UNSUPPORTED - add return value to function comment
{
EFI_UNIX_IO_PROTOCOL *UnixIo;
EFI_STATUS Status;
GOP_PRIVATE_DATA *Private;
//
// Grab the protocols we need
//
Status = gBS->OpenProtocol (
Handle,
&gEfiUnixIoProtocolGuid,
(VOID **)&UnixIo,
This->DriverBindingHandle,
Handle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
//
// Allocate Private context data for SGO inteface.
//
Private = NULL;
Status = gBS->AllocatePool (
EfiBootServicesData,
sizeof (GOP_PRIVATE_DATA),
(VOID **)&Private
);
if (EFI_ERROR (Status)) {
goto Done;
}
//
// Set up context record
//
Private->Signature = GOP_PRIVATE_DATA_SIGNATURE;
Private->Handle = Handle;
Private->UnixThunk = UnixIo->UnixThunk;
Private->ControllerNameTable = NULL;
AddUnicodeString (
"eng",
gUnixGopComponentName.SupportedLanguages,
&Private->ControllerNameTable,
UnixIo->EnvString
);
AddUnicodeString2 (
"en",
gUnixGopComponentName2.SupportedLanguages,
&Private->ControllerNameTable,
UnixIo->EnvString,
FALSE
);
Private->WindowName = UnixIo->EnvString;
Status = UnixGopConstructor (Private);
if (EFI_ERROR (Status)) {
goto Done;
}
//
// Publish the Gop interface to the world
//
Status = gBS->InstallMultipleProtocolInterfaces (
&Private->Handle,
&gEfiGraphicsOutputProtocolGuid, &Private->GraphicsOutput,
&gEfiSimpleTextInProtocolGuid, &Private->SimpleTextIn,
&gEfiSimplePointerProtocolGuid, &Private->SimplePointer,
// &gEfiSimpleTextInputExProtocolGuid, &Private->SimpleTextInEx,
NULL
);
Done:
if (EFI_ERROR (Status)) {
gBS->CloseProtocol (
Handle,
&gEfiUnixIoProtocolGuid,
This->DriverBindingHandle,
Handle
);
if (Private != NULL) {
//
// On Error Free back private data
//
if (Private->ControllerNameTable != NULL) {
FreeUnicodeStringTable (Private->ControllerNameTable);
}
if (Private->SimpleTextIn.WaitForKey != NULL) {
gBS->CloseEvent (Private->SimpleTextIn.WaitForKey);
}
if (Private->SimpleTextInEx.WaitForKeyEx != NULL) {
gBS->CloseEvent (Private->SimpleTextInEx.WaitForKeyEx);
}
FreeNotifyList (&Private->NotifyList);
gBS->FreePool (Private);
}
}
return Status;
}
EFI_STATUS
EFIAPI
UnixGopDriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Handle,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
)
/*++
Routine Description:
Arguments:
Returns:
None
--*/
// TODO: This - add argument and description to function comment
// TODO: Handle - add argument and description to function comment
// TODO: NumberOfChildren - add argument and description to function comment
// TODO: ChildHandleBuffer - add argument and description to function comment
// TODO: EFI_NOT_STARTED - add return value to function comment
// TODO: EFI_DEVICE_ERROR - add return value to function comment
{
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
EFI_STATUS Status;
GOP_PRIVATE_DATA *Private;
Status = gBS->OpenProtocol (
Handle,
&gEfiGraphicsOutputProtocolGuid,
(VOID **)&GraphicsOutput,
This->DriverBindingHandle,
Handle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
//
// If the GOP interface does not exist the driver is not started
//
return EFI_NOT_STARTED;
}
//
// Get our private context information
//
Private = GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput);
//
// Remove the SGO interface from the system
//
Status = gBS->UninstallMultipleProtocolInterfaces (
Private->Handle,
&gEfiGraphicsOutputProtocolGuid, &Private->GraphicsOutput,
&gEfiSimpleTextInProtocolGuid, &Private->SimpleTextIn,
&gEfiSimplePointerProtocolGuid, &Private->SimplePointer,
// &gEfiSimpleTextInputExProtocolGuid, &Private->SimpleTextInEx,
NULL
);
if (!EFI_ERROR (Status)) {
//
// Shutdown the hardware
//
Status = UnixGopDestructor (Private);
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
gBS->CloseProtocol (
Handle,
&gEfiUnixIoProtocolGuid,
This->DriverBindingHandle,
Handle
);
//
// Free our instance data
//
FreeUnicodeStringTable (Private->ControllerNameTable);
Status = gBS->CloseEvent (Private->SimpleTextIn.WaitForKey);
ASSERT_EFI_ERROR (Status);
Status = gBS->CloseEvent (Private->SimpleTextInEx.WaitForKeyEx);
ASSERT_EFI_ERROR (Status);
FreeNotifyList (&Private->NotifyList);
gBS->FreePool (Private);
}
return Status;
}
EFI_DRIVER_BINDING_PROTOCOL gUnixGopDriverBinding = {
UnixGopDriverBindingSupported,
UnixGopDriverBindingStart,
UnixGopDriverBindingStop,
0xa,
NULL,
NULL
};
/**
The user Entry Point for module UnixGop. 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
InitializeUnixGop (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
Status = EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
SystemTable,
&gUnixGopDriverBinding,
ImageHandle,
&gUnixGopComponentName,
&gUnixGopComponentName2
);
ASSERT_EFI_ERROR (Status);
return Status;
}

View File

@ -0,0 +1,885 @@
/*++
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2010, Apple, Inc. All rights reserved.
Portions copyright (c) 2010, Apple Inc. 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 "UnixGop.h"
BOOLEAN
GopPrivateIsKeyRegistered (
IN EFI_KEY_DATA *RegsiteredData,
IN EFI_KEY_DATA *InputData
)
/*++
Routine Description:
Arguments:
RegsiteredData - A pointer to a buffer that is filled in with the keystroke
state data for the key that was registered.
InputData - A pointer to a buffer that is filled in with the keystroke
state data for the key that was pressed.
Returns:
TRUE - Key be pressed matches a registered key.
FLASE - Match failed.
--*/
{
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;
}
VOID
EFIAPI
GopPrivateInvokeRegisteredFunction (
IN VOID *Context,
IN EFI_KEY_DATA *KeyData
)
{
LIST_ENTRY *Link;
UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY *CurrentNotify;
GOP_PRIVATE_DATA *Private = (GOP_PRIVATE_DATA *)Context;
for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) {
CurrentNotify = CR (
Link,
UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY,
NotifyEntry,
UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
);
if (GopPrivateIsKeyRegistered (&CurrentNotify->KeyData, KeyData)) {
// We could be called at a high TPL so signal an event to call the registered function
// at a lower TPL.
gBS->SignalEvent (CurrentNotify->Event);
}
}
}
//
// Simple Text In implementation.
//
/**
Reset the input device and optionally 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
UnixGopSimpleTextInReset (
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
)
{
GOP_PRIVATE_DATA *Private;
EFI_KEY_DATA KeyData;
EFI_TPL OldTpl;
Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);
if (Private->UgaIo == NULL) {
return EFI_SUCCESS;
}
//
// Enter critical section
//
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
//
// A reset is draining the Queue
//
while (Private->UgaIo->UgaGetKey (Private->UgaIo, &KeyData) == EFI_SUCCESS)
;
//
// Leave critical section and return
//
gBS->RestoreTPL (OldTpl);
return EFI_SUCCESS;
}
/**
Reads the next keystroke from the input device. The WaitForKey Event can
be used to test for existence of a keystroke via WaitForEvent () call.
@param This Protocol instance pointer.
@param Key A pointer to a buffer that is filled in with the keystroke
information for the key that was pressed.
@retval EFI_SUCCESS The keystroke information was returned.
@retval EFI_NOT_READY There was no keystroke data available.
@retval EFI_DEVICE_ERROR The keystroke information was not returned due to
hardware errors.
**/
EFI_STATUS
EFIAPI
UnixGopSimpleTextInReadKeyStroke (
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
OUT EFI_INPUT_KEY *Key
)
{
GOP_PRIVATE_DATA *Private;
EFI_STATUS Status;
EFI_TPL OldTpl;
EFI_KEY_DATA KeyData;
Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);
if (Private->UgaIo == NULL) {
return EFI_NOT_READY;
}
//
// Enter critical section
//
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
Status = Private->UgaIo->UgaGetKey(Private->UgaIo, &KeyData);
CopyMem (Key, &KeyData.Key, sizeof (EFI_INPUT_KEY));
//
// Leave critical section and return
//
gBS->RestoreTPL (OldTpl);
return Status;
}
/**
SimpleTextIn and SimpleTextInEx Notify Wait Event
@param Event Event whose notification function is being invoked.
@param Context Pointer to GOP_PRIVATE_DATA.
**/
VOID
EFIAPI
UnixGopSimpleTextInWaitForKey (
IN EFI_EVENT Event,
IN VOID *Context
)
{
GOP_PRIVATE_DATA *Private;
EFI_STATUS Status;
EFI_TPL OldTpl;
Private = (GOP_PRIVATE_DATA *) Context;
if (Private->UgaIo == NULL) {
return;
}
//
// Enter critical section
//
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
Status = Private->UgaIo->UgaCheckKey (Private->UgaIo);
if (!EFI_ERROR (Status)) {
//
// If a there is a key in the queue signal our event.
//
gBS->SignalEvent (Event);
}
//
// Leave critical section and return
//
gBS->RestoreTPL (OldTpl);
}
//
// Simple Text Input Ex protocol functions
//
/**
The Reset() function resets the input device hardware. As part
of initialization process, the firmware/device will make a quick
but reasonable attempt to verify that the device is functioning.
If the ExtendedVerification flag is TRUE the firmware may take
an extended amount of time to verify the device is operating on
reset. Otherwise the reset operation is to occur as quickly as
possible. The hardware verification process is not defined by
this specification and is left up to the platform firmware or
driver to implement.
@param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
@param ExtendedVerification Indicates that the driver may
perform a more exhaustive
verification operation of the
device during reset.
@retval EFI_SUCCESS The device was reset.
@retval EFI_DEVICE_ERROR The device is not functioning
correctly and could not be reset.
**/
EFI_STATUS
EFIAPI
UnixGopSimpleTextInExResetEx (
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
)
/*++
Routine Description:
Reset the input device and optionaly run diagnostics
Arguments:
This - Protocol instance pointer.
ExtendedVerification - Driver may perform diagnostics on reset.
Returns:
EFI_SUCCESS - The device was reset.
--*/
{
GOP_PRIVATE_DATA *Private;
Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This);
return EFI_SUCCESS;
}
/**
The function reads the next keystroke from the input device. If
there is no pending keystroke the function returns
EFI_NOT_READY. If there is a pending keystroke, then
KeyData.Key.ScanCode is the EFI scan code defined in Error!
Reference source not found. The KeyData.Key.UnicodeChar is the
actual printable character or is zero if the key does not
represent a printable character (control key, function key,
etc.). The KeyData.KeyState is shift state for the character
reflected in KeyData.Key.UnicodeChar or KeyData.Key.ScanCode .
When interpreting the data from this function, it should be
noted that if a class of printable characters that are
normally adjusted by shift modifiers (e.g. Shift Key + "f"
key) would be presented solely as a KeyData.Key.UnicodeChar
without the associated shift state. So in the previous example
of a Shift Key + "f" key being pressed, the only pertinent
data returned would be KeyData.Key.UnicodeChar with the value
of "F". This of course would not typically be the case for
non-printable characters such as the pressing of the Right
Shift Key + F10 key since the corresponding returned data
would be reflected both in the KeyData.KeyState.KeyShiftState
and KeyData.Key.ScanCode values. UEFI drivers which implement
the EFI_SIMPLE_TEXT_INPUT_EX protocol are required to return
KeyData.Key and KeyData.KeyState values. These drivers must
always return the most current state of
KeyData.KeyState.KeyShiftState and
KeyData.KeyState.KeyToggleState. It should also be noted that
certain input devices may not be able to produce shift or toggle
state information, and in those cases the high order bit in the
respective Toggle and Shift state fields should not be active.
@param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
@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 available.
EFI_DEVICE_ERROR The keystroke
information was not returned due to
hardware errors.
**/
EFI_STATUS
EFIAPI
UnixGopSimpleTextInExReadKeyStrokeEx (
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
OUT EFI_KEY_DATA *KeyData
)
/*++
Routine Description:
Reads the next keystroke from the input device. The WaitForKey Event can
be used to test for existance of a keystroke via WaitForEvent () call.
Arguments:
This - Protocol instance pointer.
KeyData - A pointer to a buffer that is filled in with the keystroke
state data for the key that was pressed.
Returns:
EFI_SUCCESS - The keystroke information was returned.
EFI_NOT_READY - There was no keystroke data availiable.
EFI_DEVICE_ERROR - The keystroke information was not returned due to
hardware errors.
EFI_INVALID_PARAMETER - KeyData is NULL.
--*/
{
EFI_STATUS Status;
GOP_PRIVATE_DATA *Private;
EFI_TPL OldTpl;
if (KeyData == NULL) {
return EFI_INVALID_PARAMETER;
}
Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);
if (Private->UgaIo == NULL) {
return EFI_NOT_READY;
}
//
// Enter critical section
//
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
Status = Private->UgaIo->UgaGetKey(Private->UgaIo, KeyData);
//
// Leave critical section and return
//
gBS->RestoreTPL (OldTpl);
return Status;
}
/**
The SetState() function allows the input device hardware to
have state settings adjusted.
@param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
@param KeyToggleState Pointer to the EFI_KEY_TOGGLE_STATE to
set the state for the input device.
@retval EFI_SUCCESS The device state was set appropriately.
@retval EFI_DEVICE_ERROR The device is not functioning
correctly and could not have the
setting adjusted.
@retval EFI_UNSUPPORTED The device does not support the
ability to have its state set.
**/
EFI_STATUS
EFIAPI
UnixGopSimpleTextInExSetState (
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
IN EFI_KEY_TOGGLE_STATE *KeyToggleState
)
{
GOP_PRIVATE_DATA *Private;
EFI_STATUS Status;
EFI_TPL OldTpl;
Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);
if (Private->UgaIo == NULL) {
return EFI_NOT_READY;
}
//
// Enter critical section
//
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
Status = Private->UgaIo->UgaKeySetState (Private->UgaIo, KeyToggleState);
//
// Leave critical section and return
//
gBS->RestoreTPL (OldTpl);
return Status;
}
/**
SimpleTextIn and SimpleTextInEx Notify Wait Event
@param Event Event whose notification function is being invoked.
@param Context Pointer to GOP_PRIVATE_DATA.
**/
VOID
EFIAPI
UnixGopRegisterKeyCallback (
IN EFI_EVENT Event,
IN VOID *Context
)
{
UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY *ExNotify = (UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY *)Context;
ExNotify->KeyNotificationFn (&ExNotify->KeyData);
}
/**
The RegisterKeystrokeNotify() function registers a function
which will be called when a specified keystroke will occur.
@param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
@param KeyData A pointer to a buffer that is filled in with
the keystroke information 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 device state was set
appropriately.
@retval EFI_OUT_OF_RESOURCES Unable to allocate necessary
data structures.
**/
EFI_STATUS
EFIAPI
UnixGopSimpleTextInExRegisterKeyNotify (
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
IN EFI_KEY_DATA *KeyData,
IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,
OUT EFI_HANDLE *NotifyHandle
)
{
EFI_STATUS Status;
GOP_PRIVATE_DATA *Private;
UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY *CurrentNotify;
LIST_ENTRY *Link;
UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY *NewNotify;
if (KeyData == NULL || KeyNotificationFunction == NULL || NotifyHandle == NULL) {
return EFI_INVALID_PARAMETER;
}
Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This);
//
// Return EFI_SUCCESS if the (KeyData, NotificationFunction) is already registered.
//
for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) {
CurrentNotify = CR (
Link,
UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY,
NotifyEntry,
UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
);
if (GopPrivateIsKeyRegistered (&CurrentNotify->KeyData, KeyData)) {
if (CurrentNotify->KeyNotificationFn == KeyNotificationFunction) {
*NotifyHandle = CurrentNotify->NotifyHandle;
return EFI_SUCCESS;
}
}
}
//
// Allocate resource to save the notification function
//
NewNotify = (UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY *) AllocateZeroPool (sizeof (UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY));
if (NewNotify == NULL) {
return EFI_OUT_OF_RESOURCES;
}
NewNotify->Signature = UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE;
NewNotify->KeyNotificationFn = KeyNotificationFunction;
NewNotify->NotifyHandle = (EFI_HANDLE) NewNotify;
CopyMem (&NewNotify->KeyData, KeyData, sizeof (KeyData));
InsertTailList (&Private->NotifyList, &NewNotify->NotifyEntry);
Status = gBS->CreateEvent (
EVT_NOTIFY_SIGNAL,
TPL_NOTIFY,
UnixGopRegisterKeyCallback,
NewNotify,
NewNotify->Event
);
ASSERT_EFI_ERROR (Status);
*NotifyHandle = NewNotify->NotifyHandle;
return EFI_SUCCESS;
}
/**
The UnregisterKeystrokeNotify() function removes the
notification which was previously registered.
@param This A pointer to the EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL instance.
@param NotificationHandle The handle of the notification
function being unregistered.
@retval EFI_SUCCESS The device state was set appropriately.
@retval EFI_INVALID_PARAMETER The NotificationHandle is
invalid.
**/
EFI_STATUS
EFIAPI
UnixGopSimpleTextInExUnregisterKeyNotify (
IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
IN EFI_HANDLE NotificationHandle
)
/*++
Routine Description:
Remove a registered notification function from a particular keystroke.
Arguments:
This - Protocol instance pointer.
NotificationHandle - The handle of the notification function being unregistered.
Returns:
EFI_SUCCESS - The notification function was unregistered successfully.
EFI_INVALID_PARAMETER - The NotificationHandle is invalid.
--*/
{
GOP_PRIVATE_DATA *Private;
LIST_ENTRY *Link;
UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY *CurrentNotify;
if (NotificationHandle == NULL) {
return EFI_INVALID_PARAMETER;
}
if (((UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY *) NotificationHandle)->Signature != UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE) {
return EFI_INVALID_PARAMETER;
}
Private = GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS (This);
for (Link = Private->NotifyList.ForwardLink; Link != &Private->NotifyList; Link = Link->ForwardLink) {
CurrentNotify = CR (
Link,
UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY,
NotifyEntry,
UNIX_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE
);
if (CurrentNotify->NotifyHandle == NotificationHandle) {
//
// Remove the notification function from NotifyList and free resources
//
RemoveEntryList (&CurrentNotify->NotifyEntry);
gBS->CloseEvent (CurrentNotify->Event);
gBS->FreePool (CurrentNotify);
return EFI_SUCCESS;
}
}
//
// Can not find the specified Notification Handle
//
return EFI_INVALID_PARAMETER;
}
/**
Initialize SimplelTextIn and SimpleTextInEx protocols in the Private
context structure.
@param Private Context structure to fill in.
@return EFI_SUCCESS Initialization was a success
**/
EFI_STATUS
UnixGopInitializeSimpleTextInForWindow (
IN GOP_PRIVATE_DATA *Private
)
{
EFI_STATUS Status;
//
// Initialize Simple Text In protoocol
//
Private->SimpleTextIn.Reset = UnixGopSimpleTextInReset;
Private->SimpleTextIn.ReadKeyStroke = UnixGopSimpleTextInReadKeyStroke;
Status = gBS->CreateEvent (
EVT_NOTIFY_WAIT,
TPL_NOTIFY,
UnixGopSimpleTextInWaitForKey,
Private,
&Private->SimpleTextIn.WaitForKey
);
ASSERT_EFI_ERROR (Status);
//
// Initialize Simple Text In Ex
//
Private->SimpleTextInEx.Reset = UnixGopSimpleTextInExResetEx;
Private->SimpleTextInEx.ReadKeyStrokeEx = UnixGopSimpleTextInExReadKeyStrokeEx;
Private->SimpleTextInEx.SetState = UnixGopSimpleTextInExSetState;
Private->SimpleTextInEx.RegisterKeyNotify = UnixGopSimpleTextInExRegisterKeyNotify;
Private->SimpleTextInEx.UnregisterKeyNotify = UnixGopSimpleTextInExUnregisterKeyNotify;
Private->SimpleTextInEx.Reset (&Private->SimpleTextInEx, FALSE);
InitializeListHead (&Private->NotifyList);
Status = gBS->CreateEvent (
EVT_NOTIFY_WAIT,
TPL_NOTIFY,
UnixGopSimpleTextInWaitForKey,
Private,
&Private->SimpleTextInEx.WaitForKeyEx
);
ASSERT_EFI_ERROR (Status);
return Status;
}
//
// Simple Pointer implementation.
//
/**
Resets the pointer device hardware.
@param This A pointer to the EFI_SIMPLE_POINTER_PROTOCOL
instance.
@param ExtendedVerification Indicates that the driver may perform a more exhaustive
verification operation of the device during reset.
@retval EFI_SUCCESS The device was reset.
@retval EFI_DEVICE_ERROR The device is not functioning correctly and could not be reset.
**/
EFI_STATUS
EFIAPI
UnixGopSimplePointerReset (
IN EFI_SIMPLE_POINTER_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
)
{
GOP_PRIVATE_DATA *Private;
EFI_SIMPLE_POINTER_STATE State;
EFI_TPL OldTpl;
Private = GOP_PRIVATE_DATA_FROM_POINTER_MODE_THIS (This);
if (Private->UgaIo == NULL) {
return EFI_SUCCESS;
}
//
// Enter critical section
//
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
//
// A reset is draining the Queue
//
while (Private->UgaIo->UgaGetPointerState (Private->UgaIo, &State) == EFI_SUCCESS)
;
//
// Leave critical section and return
//
gBS->RestoreTPL (OldTpl);
return EFI_SUCCESS;
}
/**
Retrieves the current state of a pointer device.
@param This A pointer to the EFI_SIMPLE_POINTER_PROTOCOL
instance.
@param State A pointer to the state information on the pointer device.
@retval EFI_SUCCESS The state of the pointer device was returned in State.
@retval EFI_NOT_READY The state of the pointer device has not changed since the last call to
GetState().
@retval EFI_DEVICE_ERROR A device error occurred while attempting to retrieve the pointer device's
current state.
**/
EFI_STATUS
EFIAPI
UnixGopSimplePointerGetState (
IN EFI_SIMPLE_POINTER_PROTOCOL *This,
IN OUT EFI_SIMPLE_POINTER_STATE *State
)
{
GOP_PRIVATE_DATA *Private;
EFI_STATUS Status;
EFI_TPL OldTpl;
Private = GOP_PRIVATE_DATA_FROM_POINTER_MODE_THIS (This);
if (Private->UgaIo == NULL) {
return EFI_NOT_READY;
}
//
// Enter critical section
//
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
Status = Private->UgaIo->UgaGetPointerState (Private->UgaIo, State);
//
// Leave critical section and return
//
gBS->RestoreTPL (OldTpl);
return Status;
}
/**
SimplePointer Notify Wait Event
@param Event Event whose notification function is being invoked.
@param Context Pointer to GOP_PRIVATE_DATA.
**/
VOID
EFIAPI
UnixGopSimplePointerWaitForInput (
IN EFI_EVENT Event,
IN VOID *Context
)
{
GOP_PRIVATE_DATA *Private;
EFI_STATUS Status;
EFI_TPL OldTpl;
Private = (GOP_PRIVATE_DATA *) Context;
if (Private->UgaIo == NULL) {
return;
}
//
// Enter critical section
//
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
Status = Private->UgaIo->UgaCheckPointer (Private->UgaIo);
if (!EFI_ERROR (Status)) {
//
// If the pointer state has changed, signal our event.
//
gBS->SignalEvent (Event);
}
//
// Leave critical section and return
//
gBS->RestoreTPL (OldTpl);
}
/**
SimplePointer constructor
@param Private Context structure to fill in.
@retval EFI_SUCCESS Constructor had success
**/
EFI_STATUS
UnixGopInitializeSimplePointerForWindow (
IN GOP_PRIVATE_DATA *Private
)
{
EFI_STATUS Status;
//
// Initialize Simple Pointer protoocol
//
Private->PointerMode.ResolutionX = 1;
Private->PointerMode.ResolutionY = 1;
Private->PointerMode.ResolutionZ = 1;
Private->PointerMode.LeftButton = TRUE;
Private->PointerMode.RightButton = TRUE;
Private->SimplePointer.Reset = UnixGopSimplePointerReset;
Private->SimplePointer.GetState = UnixGopSimplePointerGetState;
Private->SimplePointer.Mode = &Private->PointerMode;
Status = gBS->CreateEvent (
EVT_NOTIFY_WAIT,
TPL_NOTIFY,
UnixGopSimplePointerWaitForInput,
Private,
&Private->SimplePointer.WaitForInput
);
return Status;
}

View File

@ -0,0 +1,404 @@
/*++
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2010, Apple, Inc. 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.
Module Name:
UnixGopScreen.c
Abstract:
This file produces the graphics abstration of UGA. It is called by
UnixGopDriver.c file which deals with the EFI 1.1 driver model.
This file just does graphics.
--*/
#include "UnixGop.h"
EFI_UNIX_THUNK_PROTOCOL *mUnix;
EFI_EVENT mGopScreenExitBootServicesEvent;
GOP_MODE_DATA mGopModeData[] = {
{ 800, 600, 0, 0 },
{ 640, 480, 0, 0 },
{ 720, 400, 0, 0 },
{1024, 768, 0, 0 },
{1280, 1024, 0, 0 }
};
EFI_STATUS
UnixGopStartWindow (
IN GOP_PRIVATE_DATA *Private,
IN UINT32 HorizontalResolution,
IN UINT32 VerticalResolution,
IN UINT32 ColorDepth,
IN UINT32 RefreshRate
);
VOID
EFIAPI
KillUgaGopThread (
IN EFI_EVENT Event,
IN VOID *Context
);
//
// UGA Protocol Member Functions
//
EFI_STATUS
EFIAPI
UnixGopQuerytMode (
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
IN UINT32 ModeNumber,
OUT UINTN *SizeOfInfo,
OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info
)
{
GOP_PRIVATE_DATA *Private;
Private = GOP_PRIVATE_DATA_FROM_THIS (This);
if (Info == NULL || SizeOfInfo == NULL || (UINTN) ModeNumber >= This->Mode->MaxMode) {
return EFI_INVALID_PARAMETER;
}
*Info = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));
if (*Info == NULL) {
return EFI_OUT_OF_RESOURCES;
}
*SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
(*Info)->Version = 0;
(*Info)->HorizontalResolution = Private->ModeData[ModeNumber].HorizontalResolution;
(*Info)->VerticalResolution = Private->ModeData[ModeNumber].VerticalResolution;
(*Info)->PixelFormat = PixelBltOnly;
(*Info)->PixelsPerScanLine = (*Info)->HorizontalResolution;
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
UnixGopSetMode (
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
IN UINT32 ModeNumber
)
{
EFI_STATUS Status;
GOP_PRIVATE_DATA *Private;
GOP_MODE_DATA *ModeData;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Fill;
Private = GOP_PRIVATE_DATA_FROM_THIS (This);
if (ModeNumber >= This->Mode->MaxMode) {
return EFI_UNSUPPORTED;
}
ModeData = &Private->ModeData[ModeNumber];
This->Mode->Mode = ModeNumber;
Private->GraphicsOutput.Mode->Info->HorizontalResolution = ModeData->HorizontalResolution;
Private->GraphicsOutput.Mode->Info->VerticalResolution = ModeData->VerticalResolution;
Private->GraphicsOutput.Mode->Info->PixelsPerScanLine = ModeData->HorizontalResolution;
if (Private->HardwareNeedsStarting) {
Status = UnixGopStartWindow (
Private,
ModeData->HorizontalResolution,
ModeData->VerticalResolution,
ModeData->ColorDepth,
ModeData->RefreshRate
);
if (EFI_ERROR (Status)) {
return EFI_DEVICE_ERROR;
}
Private->HardwareNeedsStarting = FALSE;
}
Status = Private->UgaIo->UgaSize(
Private->UgaIo,
ModeData->HorizontalResolution,
ModeData->VerticalResolution
);
Fill.Red = 0x7f;
Fill.Green = 0x7F;
Fill.Blue = 0x7f;
This->Blt (
This,
&Fill,
EfiBltVideoFill,
0,
0,
0,
0,
ModeData->HorizontalResolution,
ModeData->VerticalResolution,
ModeData->HorizontalResolution * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
);
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
UnixGopBlt (
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL
IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
IN UINTN SourceX,
IN UINTN SourceY,
IN UINTN DestinationX,
IN UINTN DestinationY,
IN UINTN Width,
IN UINTN Height,
IN UINTN Delta OPTIONAL
)
{
GOP_PRIVATE_DATA *Private;
EFI_TPL OriginalTPL;
EFI_STATUS Status;
UGA_BLT_ARGS GopBltArgs;
Private = GOP_PRIVATE_DATA_FROM_THIS (This);
if ((BltOperation < 0) || (BltOperation >= EfiGraphicsOutputBltOperationMax)) {
return EFI_INVALID_PARAMETER;
}
if (Width == 0 || Height == 0) {
return EFI_INVALID_PARAMETER;
}
//
// If Delta is zero, then the entire BltBuffer is being used, so Delta
// is the number of bytes in each row of BltBuffer. Since BltBuffer is Width pixels size,
// the number of bytes in each row can be computed.
//
if (Delta == 0) {
Delta = Width * sizeof (EFI_UGA_PIXEL);
}
//
// We have to raise to TPL Notify, so we make an atomic write the frame buffer.
// We would not want a timer based event (Cursor, ...) to come in while we are
// doing this operation.
//
OriginalTPL = gBS->RaiseTPL (TPL_NOTIFY);
//
// Pack UGA Draw protocol parameters to UGA_BLT_ARGS structure to adapt to
// GopBlt() API of Unix UGA IO protocol.
//
GopBltArgs.DestinationX = DestinationX;
GopBltArgs.DestinationY = DestinationY;
GopBltArgs.Height = Height;
GopBltArgs.Width = Width;
GopBltArgs.SourceX = SourceX;
GopBltArgs.SourceY = SourceY;
GopBltArgs.Delta = Delta;
Status = Private->UgaIo->UgaBlt (
Private->UgaIo,
(EFI_UGA_PIXEL *)BltBuffer,
BltOperation,
&GopBltArgs
);
gBS->RestoreTPL (OriginalTPL);
return Status;
}
//
// Construction and Destruction functions
//
EFI_STATUS
UnixGopSupported (
IN EFI_UNIX_IO_PROTOCOL *UnixIo
)
/*++
Routine Description:
Arguments:
Returns:
None
--*/
// TODO: UnixIo - add argument and description to function comment
// TODO: EFI_UNSUPPORTED - add return value to function comment
// TODO: EFI_SUCCESS - add return value to function comment
{
//
// Check to see if the IO abstraction represents a device type we support.
//
// This would be replaced a check of PCI subsystem ID, etc.
//
if (!CompareGuid (UnixIo->TypeGuid, &gEfiUnixGopGuid)) {
return EFI_UNSUPPORTED;
}
return EFI_SUCCESS;
}
VOID
EFIAPI
GopPrivateInvokeRegisteredFunction (
IN VOID *Context,
IN EFI_KEY_DATA *KeyData
);
EFI_STATUS
UnixGopStartWindow (
IN GOP_PRIVATE_DATA *Private,
IN UINT32 HorizontalResolution,
IN UINT32 VerticalResolution,
IN UINT32 ColorDepth,
IN UINT32 RefreshRate
)
{
EFI_STATUS Status;
mUnix = Private->UnixThunk;
//
// Register to be notified on exit boot services so we can destroy the window.
//
Status = gBS->CreateEvent (
EVT_SIGNAL_EXIT_BOOT_SERVICES,
TPL_CALLBACK,
KillUgaGopThread,
Private,
&mGopScreenExitBootServicesEvent
);
Status = Private->UnixThunk->UgaCreate (&Private->UgaIo, Private->WindowName);
if (!EFI_ERROR (Status)) {
// Register callback to support RegisterKeyNotify()
Status = Private->UgaIo->UgaRegisterKeyNotify (Private->UgaIo, GopPrivateInvokeRegisteredFunction, Private);
ASSERT_EFI_ERROR (Status);
}
return Status;
}
EFI_STATUS
UnixGopConstructor (
GOP_PRIVATE_DATA *Private
)
{
Private->ModeData = mGopModeData;
Private->GraphicsOutput.QueryMode = UnixGopQuerytMode;
Private->GraphicsOutput.SetMode = UnixGopSetMode;
Private->GraphicsOutput.Blt = UnixGopBlt;
//
// Allocate buffer for Graphics Output Protocol mode information
//
Private->GraphicsOutput.Mode = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE));
if (Private->GraphicsOutput.Mode == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Private->GraphicsOutput.Mode->Info = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));
if (Private->GraphicsOutput.Mode->Info == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Private->GraphicsOutput.Mode->MaxMode = sizeof(mGopModeData) / sizeof(GOP_MODE_DATA);
//
// Till now, we have no idea about the window size.
//
Private->GraphicsOutput.Mode->Mode = GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER;
Private->GraphicsOutput.Mode->Info->Version = 0;
Private->GraphicsOutput.Mode->Info->HorizontalResolution = 0;
Private->GraphicsOutput.Mode->Info->VerticalResolution = 0;
Private->GraphicsOutput.Mode->Info->PixelFormat = PixelBltOnly;
Private->GraphicsOutput.Mode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
Private->GraphicsOutput.Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) (UINTN) NULL;
Private->GraphicsOutput.Mode->FrameBufferSize = 0;
Private->HardwareNeedsStarting = TRUE;
Private->UgaIo = NULL;
UnixGopInitializeSimpleTextInForWindow (Private);
UnixGopInitializeSimplePointerForWindow (Private);
return EFI_SUCCESS;
}
EFI_STATUS
UnixGopDestructor (
GOP_PRIVATE_DATA *Private
)
{
if (!Private->HardwareNeedsStarting) {
Private->UgaIo->UgaClose (Private->UgaIo);
Private->UgaIo = NULL;
}
//
// Free graphics output protocol occupied resource
//
if (Private->GraphicsOutput.Mode != NULL) {
if (Private->GraphicsOutput.Mode->Info != NULL) {
FreePool (Private->GraphicsOutput.Mode->Info);
}
FreePool (Private->GraphicsOutput.Mode);
}
return EFI_SUCCESS;
}
VOID
EFIAPI
KillUgaGopThread (
IN EFI_EVENT Event,
IN VOID *Context
)
/*++
Routine Description:
This is the UGA screen's callback notification function for exit-boot-services.
All we do here is call UnixGopDestructor().
Arguments:
Event - not used
Context - pointer to the Private structure.
Returns:
None.
--*/
{
EFI_STATUS Status;
Status = UnixGopDestructor (Context);
}

View File

@ -47,12 +47,15 @@
gEfiUnixPhysicalDisksGuid = {0xf2bdcc96, 0x8985, 0x11db, {0x87, 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35}} gEfiUnixPhysicalDisksGuid = {0xf2bdcc96, 0x8985, 0x11db, {0x87, 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35}}
gEfiUnixFileSystemGuid = {0xf2c16b9e, 0x8985, 0x11db, {0x92, 0xc8, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35}} gEfiUnixFileSystemGuid = {0xf2c16b9e, 0x8985, 0x11db, {0x92, 0xc8, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35}}
gEfiUnixUgaGuid = {0xf2c8b80e, 0x8985, 0x11db, {0x93, 0xf1, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35}} gEfiUnixUgaGuid = {0xf2c8b80e, 0x8985, 0x11db, {0x93, 0xf1, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35}}
gEfiUnixGopGuid = {0xbace07c2, 0x8987, 0x11db, {0xa5, 0x9a, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35}}
gEfiUnixConsoleGuid = {0xf2cc5d06, 0x8985, 0x11db, {0xbb, 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35}} gEfiUnixConsoleGuid = {0xf2cc5d06, 0x8985, 0x11db, {0xbb, 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35}}
gEfiUnixMemoryGuid = {0xf2d006cc, 0x8985, 0x11db, {0xa4, 0x72, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35}} gEfiUnixMemoryGuid = {0xf2d006cc, 0x8985, 0x11db, {0xa4, 0x72, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35}}
gEfiUnixCPUModelGuid = {0xf2d3b330, 0x8985, 0x11db, {0x8a, 0xa3, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35}} gEfiUnixCPUModelGuid = {0xf2d3b330, 0x8985, 0x11db, {0x8a, 0xa3, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35}}
gEfiUnixCPUSpeedGuid = {0xf2d74e5a, 0x8985, 0x11db, {0x97, 0x05, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35}} gEfiUnixCPUSpeedGuid = {0xf2d74e5a, 0x8985, 0x11db, {0x97, 0x05, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35}}
gEfiUnixSerialPortGuid = {0x6d3a727d, 0x66c8, 0x4d19, {0x87, 0xe6, 0x02, 0x15, 0x86, 0x14, 0x90, 0xf3}} gEfiUnixSerialPortGuid = {0x6d3a727d, 0x66c8, 0x4d19, {0x87, 0xe6, 0x02, 0x15, 0x86, 0x14, 0x90, 0xf3}}
gEfiUnixSystemConfigGuid = {0x375ea976, 0x3ccd, 0x4e74, {0xa8, 0x45, 0x26, 0xb9, 0xb3, 0x24, 0xb1, 0x3c}} gEfiUnixSystemConfigGuid = {0x375ea976, 0x3ccd, 0x4e74, {0xa8, 0x45, 0x26, 0xb9, 0xb3, 0x24, 0xb1, 0x3c}}
gEfiUnixNetworkGuid = {0x081603B4, 0x0F1D, 0x4022, {0xB6, 0xFD, 0x4C, 0xE3, 0x5E, 0x09, 0xA1, 0xA6}}
[PcdsFixedAtBuild] [PcdsFixedAtBuild]
gEfiUnixPkgTokenSpaceGuid.PcdUnixBootMode|1|UINT32|0x00001006 gEfiUnixPkgTokenSpaceGuid.PcdUnixBootMode|1|UINT32|0x00001006
@ -79,12 +82,14 @@
gEfiUnixPkgTokenSpaceGuid.PcdUnixPhysicalDisk|L"E:RW;245760;512"|VOID*|0x00001000 gEfiUnixPkgTokenSpaceGuid.PcdUnixPhysicalDisk|L"E:RW;245760;512"|VOID*|0x00001000
gEfiUnixPkgTokenSpaceGuid.PcdUnixVirtualDisk|L"FW;40960;512"|VOID*|0x00001001 gEfiUnixPkgTokenSpaceGuid.PcdUnixVirtualDisk|L"FW;40960;512"|VOID*|0x00001001
gEfiUnixPkgTokenSpaceGuid.PcdUnixUga|L"UGA Window"|VOID*|0x00001003 gEfiUnixPkgTokenSpaceGuid.PcdUnixUga|L"UGA Window"|VOID*|0x00001003
gEfiUnixPkgTokenSpaceGuid.PcdUnixGop|L"GOP Window"|VOID*|0x0000100e
gEfiUnixPkgTokenSpaceGuid.PcdUnixFileSystem|L".!..\\..\\..\\..\\..\\EdkShellBinPkg\\bin\\ia32\\Apps"|VOID*|0x00001004 gEfiUnixPkgTokenSpaceGuid.PcdUnixFileSystem|L".!..\\..\\..\\..\\..\\EdkShellBinPkg\\bin\\ia32\\Apps"|VOID*|0x00001004
gEfiUnixPkgTokenSpaceGuid.PcdUnixMemorySize|L"64!64"|VOID*|0x00001005 gEfiUnixPkgTokenSpaceGuid.PcdUnixMemorySize|L"64!64"|VOID*|0x00001005
gEfiUnixPkgTokenSpaceGuid.PcdUnixCpuModel|L"Intel(R) Processor Model"|VOID*|0x00001007 gEfiUnixPkgTokenSpaceGuid.PcdUnixCpuModel|L"Intel(R) Processor Model"|VOID*|0x00001007
gEfiUnixPkgTokenSpaceGuid.PcdUnixCpuSpeed|L"3000"|VOID*|0x00001008 gEfiUnixPkgTokenSpaceGuid.PcdUnixCpuSpeed|L"3000"|VOID*|0x00001008
gEfiUnixPkgTokenSpaceGuid.PcdUnixConsole|L"Bus Driver Console Window"|VOID*|0x0000100a gEfiUnixPkgTokenSpaceGuid.PcdUnixConsole|L"Bus Driver Console Window"|VOID*|0x0000100a
gEfiUnixPkgTokenSpaceGuid.PcdUnixSerialPort|L"/dev/ttyS0"|VOID*|0x00001002 gEfiUnixPkgTokenSpaceGuid.PcdUnixSerialPort|L"/dev/ttyS0"|VOID*|0x00001002
gEfiUnixPkgTokenSpaceGuid.PcdUnixNetworkInterface|L"en0"|VOID*|0x0000100d
[PcdsPatchableInModule] [PcdsPatchableInModule]

View File

@ -199,6 +199,7 @@
gEfiUnixPkgTokenSpaceGuid.PcdUnixCpuSpeed|L"3000" gEfiUnixPkgTokenSpaceGuid.PcdUnixCpuSpeed|L"3000"
gEfiUnixPkgTokenSpaceGuid.PcdUnixMemorySize|L"128!128" gEfiUnixPkgTokenSpaceGuid.PcdUnixMemorySize|L"128!128"
gEfiUnixPkgTokenSpaceGuid.PcdUnixSerialPort|L"/dev/ttyS0!/dev/ttyS1" gEfiUnixPkgTokenSpaceGuid.PcdUnixSerialPort|L"/dev/ttyS0!/dev/ttyS1"
gEfiUnixPkgTokenSpaceGuid.PcdUnixNetworkInterface|L"en0"
[PcdsDynamicHii.common.DEFAULT] [PcdsDynamicHii.common.DEFAULT]
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn|L"Setup"|gEfiUnixSystemConfigGuid|0x0|80 gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn|L"Setup"|gEfiUnixSystemConfigGuid|0x0|80
@ -295,14 +296,16 @@
UnixPkg/UnixBlockIoDxe/UnixBlockIo.inf UnixPkg/UnixBlockIoDxe/UnixBlockIo.inf
UnixPkg/UnixSerialIoDxe/UnixSerialIo.inf UnixPkg/UnixSerialIoDxe/UnixSerialIo.inf
UnixPkg/UnixUgaDxe/UnixUga.inf UnixPkg/UnixUgaDxe/UnixUga.inf
UnixPkg/UnixGopDxe/UnixGop.inf
UnixPkg/UnixConsoleDxe/UnixConsole.inf UnixPkg/UnixConsoleDxe/UnixConsole.inf
UnixPkg/UnixSimpleFileSystemDxe/UnixSimpleFileSystem.inf UnixPkg/UnixSimpleFileSystemDxe/UnixSimpleFileSystem.inf
MdeModulePkg/Application/HelloWorld/HelloWorld.inf MdeModulePkg/Application/HelloWorld/HelloWorld.inf
# #
# Network stack drivers # Network stack drivers
# To test network drivers, need network Io driver(SnpNt32Io.dll), please refer to NETWORK-IO Subproject.
# #
UnixPkg/UnixSnpDxe/UnixSnpDxe.inf
MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf

View File

@ -217,7 +217,9 @@ INF UnixPkg/UnixBusDriverDxe/UnixBusDriver.inf
INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
INF UnixPkg/UnixBlockIoDxe/UnixBlockIo.inf INF UnixPkg/UnixBlockIoDxe/UnixBlockIo.inf
INF UnixPkg/UnixSerialIoDxe/UnixSerialIo.inf INF UnixPkg/UnixSerialIoDxe/UnixSerialIo.inf
INF UnixPkg/UnixUgaDxe/UnixUga.inf #INF UnixPkg/UnixUgaDxe/UnixUga.inf
INF UnixPkg/UnixGopDxe/UnixGop.inf
#INF UnixPkg/UnixConsoleDxe/UnixConsole.inf #INF UnixPkg/UnixConsoleDxe/UnixConsole.inf
INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
@ -229,19 +231,18 @@ INF MdeModulePkg/Application/HelloWorld/HelloWorld.inf
# #
# Network stack drivers # Network stack drivers
# To test network drivers, need network Io driver(SnpNt32Io.dll), please refer to NETWORK-IO Subproject.
# #
#INF MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf INF MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
#INF MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf INF MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
#INF MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf INF MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
#INF MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf INF MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf
#INF MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf INF MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf
#INF MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf INF MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
#INF MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf INF MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf
#INF MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf INF MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf
#INF MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf INF MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf
#INF MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf INF MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf
#INF UnixPkg/SnpUnixDxe/SnpUnixDxe.inf INF UnixPkg/UnixSnpDxe/UnixSnpDxe.inf
# #
# Build from source or use checked in binary # Build from source or use checked in binary

View File

@ -5,6 +5,7 @@
# The Emulation Platform can be used to debug individual modules, prior to creating # The Emulation Platform can be used to debug individual modules, prior to creating
# a real platform. This also provides an example for how an DSC is created. # a real platform. This also provides an example for how an DSC is created.
# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
# Portions copywrite (c) 2010, Apple, Inc. All rights reserved.
# #
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
@ -199,6 +200,7 @@
gEfiUnixPkgTokenSpaceGuid.PcdUnixCpuSpeed|L"3000" gEfiUnixPkgTokenSpaceGuid.PcdUnixCpuSpeed|L"3000"
gEfiUnixPkgTokenSpaceGuid.PcdUnixMemorySize|L"128!128" gEfiUnixPkgTokenSpaceGuid.PcdUnixMemorySize|L"128!128"
gEfiUnixPkgTokenSpaceGuid.PcdUnixSerialPort|L"/dev/ttyS0!/dev/ttyS1" gEfiUnixPkgTokenSpaceGuid.PcdUnixSerialPort|L"/dev/ttyS0!/dev/ttyS1"
gEfiUnixPkgTokenSpaceGuid.PcdUnixNetworkInterface|L"en0"
[PcdsDynamicHii.common.DEFAULT] [PcdsDynamicHii.common.DEFAULT]
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn|L"Setup"|gEfiUnixSystemConfigGuid|0x0|80 gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn|L"Setup"|gEfiUnixSystemConfigGuid|0x0|80
@ -223,7 +225,7 @@
# generated for it, but the binary will not be put into any firmware volume. # generated for it, but the binary will not be put into any firmware volume.
# #
################################################################################################### ###################################################################################################
[Components.common] [Components]
!if $(SEC_ONLY) !if $(SEC_ONLY)
## ##
# SEC Phase modules # SEC Phase modules
@ -296,14 +298,15 @@
UnixPkg/UnixBlockIoDxe/UnixBlockIo.inf UnixPkg/UnixBlockIoDxe/UnixBlockIo.inf
UnixPkg/UnixSerialIoDxe/UnixSerialIo.inf UnixPkg/UnixSerialIoDxe/UnixSerialIo.inf
UnixPkg/UnixUgaDxe/UnixUga.inf UnixPkg/UnixUgaDxe/UnixUga.inf
UnixPkg/UnixGopDxe/UnixGop.inf
UnixPkg/UnixConsoleDxe/UnixConsole.inf UnixPkg/UnixConsoleDxe/UnixConsole.inf
UnixPkg/UnixSimpleFileSystemDxe/UnixSimpleFileSystem.inf UnixPkg/UnixSimpleFileSystemDxe/UnixSimpleFileSystem.inf
MdeModulePkg/Application/HelloWorld/HelloWorld.inf MdeModulePkg/Application/HelloWorld/HelloWorld.inf
# #
# Network stack drivers # Network stack drivers
# To test network drivers, need network Io driver(SnpNt32Io.dll), please refer to NETWORK-IO Subproject.
# #
UnixPkg/UnixSnpDxe/UnixSnpDxe.inf
MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf

View File

@ -2,6 +2,7 @@
# This is Unix FDF file with UEFI HII features enabled # This is Unix FDF file with UEFI HII features enabled
# #
# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>
# Portions copyright (c) 2009 - 2010, Apple Inc. All rights reserved.
# #
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # are licensed and made available under the terms and conditions of the BSD License
@ -32,10 +33,10 @@
# relocated in place (works, but not a great idea). # relocated in place (works, but not a great idea).
# #
BaseAddress = 0x102000000|gEfiUnixPkgTokenSpaceGuid.PcdUnixFdBaseAddress #The base address of the FLASH Device. BaseAddress = 0x102000000|gEfiUnixPkgTokenSpaceGuid.PcdUnixFdBaseAddress #The base address of the FLASH Device.
Size = 0x004a0000|gEfiUnixPkgTokenSpaceGuid.PcdUnixFirmwareFdSize #The size in bytes of the FLASH Device Size = 0x005a0000|gEfiUnixPkgTokenSpaceGuid.PcdUnixFirmwareFdSize #The size in bytes of the FLASH Device
ErasePolarity = 1 ErasePolarity = 1
BlockSize = 0x10000 BlockSize = 0x10000
NumBlocks = 0x4a NumBlocks = 0x5a
################################################################################ ################################################################################
# #
@ -52,11 +53,11 @@ NumBlocks = 0x4a
# RegionType <FV, DATA, or FILE> # RegionType <FV, DATA, or FILE>
# #
################################################################################ ################################################################################
0x00000000|0x00480000 0x00000000|0x00580000
gEfiUnixPkgTokenSpaceGuid.PcdUnixFlashFvRecoveryBase|gEfiUnixPkgTokenSpaceGuid.PcdUnixFlashFvRecoverySize gEfiUnixPkgTokenSpaceGuid.PcdUnixFlashFvRecoveryBase|gEfiUnixPkgTokenSpaceGuid.PcdUnixFlashFvRecoverySize
FV = FvRecovery FV = FvRecovery
0x00480000|0x0000c000 0x00580000|0x0000c000
gEfiUnixPkgTokenSpaceGuid.PcdUnixFlashNvStorageVariableBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize gEfiUnixPkgTokenSpaceGuid.PcdUnixFlashNvStorageVariableBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
#NV_VARIABLE_STORE #NV_VARIABLE_STORE
DATA = { DATA = {
@ -90,11 +91,11 @@ DATA = {
0x5A, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 0x5A, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
} }
0x0048c000|0x00002000 0x0058c000|0x00002000
#NV_EVENT_LOG #NV_EVENT_LOG
gEfiUnixPkgTokenSpaceGuid.PcdUnixFlashNvStorageEventLogBase|gEfiUnixPkgTokenSpaceGuid.PcdUnixFlashNvStorageEventLogSize gEfiUnixPkgTokenSpaceGuid.PcdUnixFlashNvStorageEventLogBase|gEfiUnixPkgTokenSpaceGuid.PcdUnixFlashNvStorageEventLogSize
0x0048e000|0x00002000 0x0058e000|0x00002000
gEfiUnixPkgTokenSpaceGuid.PcdUnixFlashNvStorageFtwWorkingBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize gEfiUnixPkgTokenSpaceGuid.PcdUnixFlashNvStorageFtwWorkingBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize
#NV_FTW_WORKING #NV_FTW_WORKING
DATA = { DATA = {
@ -108,7 +109,7 @@ DATA = {
0xE0, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 0xE0, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
} }
0x00490000|0x00010000 0x00590000|0x00010000
#NV_FTW_SPARE #NV_FTW_SPARE
gEfiUnixPkgTokenSpaceGuid.PcdUnixFlashNvStorageFtwSpareBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize gEfiUnixPkgTokenSpaceGuid.PcdUnixFlashNvStorageFtwSpareBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
@ -217,7 +218,8 @@ INF UnixPkg/UnixBusDriverDxe/UnixBusDriver.inf
INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
INF UnixPkg/UnixBlockIoDxe/UnixBlockIo.inf INF UnixPkg/UnixBlockIoDxe/UnixBlockIo.inf
INF UnixPkg/UnixSerialIoDxe/UnixSerialIo.inf INF UnixPkg/UnixSerialIoDxe/UnixSerialIo.inf
INF UnixPkg/UnixUgaDxe/UnixUga.inf #INF UnixPkg/UnixUgaDxe/UnixUga.inf
INF UnixPkg/UnixGopDxe/UnixGop.inf
#INF UnixPkg/UnixConsoleDxe/UnixConsole.inf #INF UnixPkg/UnixConsoleDxe/UnixConsole.inf
INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
@ -228,21 +230,20 @@ INF MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf
INF MdeModulePkg/Application/HelloWorld/HelloWorld.inf INF MdeModulePkg/Application/HelloWorld/HelloWorld.inf
# #
# Need to port this to UnixPkg
# Network stack drivers # Network stack drivers
# To test network drivers, need network Io driver(SnpNt32Io.dll), please refer to NETWORK-IO Subproject.
# #
#INF MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf INF UnixPkg/UnixSnpDxe/UnixSnpDxe.inf
#INF MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf INF MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
#INF MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf INF MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
#INF MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf INF MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
#INF MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf INF MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDxe.inf
#INF MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf INF MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Dxe.inf
#INF MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf INF MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
#INF MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf INF MdeModulePkg/Universal/Network/VlanConfigDxe/VlanConfigDxe.inf
#INF MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf INF MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf
#INF MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf INF MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf
#INF UnixPkg/SnpUnixDxe/SnpUnixDxe.inf INF MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Dxe.inf
!if $(COMPILE_BINS) !if $(COMPILE_BINS)
INF FatPkg/EnhancedFatDxe/Fat.inf INF FatPkg/EnhancedFatDxe/Fat.inf

View File

@ -0,0 +1,318 @@
/** @file
Copyright (c) 2010, Apple, Inc. 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.
Module Name:
ComponentName.c
Abstract:
-**/
#include "UnixSnp.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
UnixSnpDriverComponentNameGetDriverName (
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 not a valid EFI_HANDLE.
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
EFI_HANDLE.
@retval EFI_INVALID_PARAMETER 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
UnixSnpDriverComponentNameGetControllerName (
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 gUnixSnpDriverComponentName = {
UnixSnpDriverComponentNameGetDriverName,
UnixSnpDriverComponentNameGetControllerName,
"eng"
};
//
// EFI Component Name 2 Protocol
//
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUnixSnpDriverComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) UnixSnpDriverComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) UnixSnpDriverComponentNameGetControllerName,
"en"
};
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUnixSnpDriverNameTable[] = {
{
"eng;en",
L"Unix SNP 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
UnixSnpDriverComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
)
{
return LookupUnicodeString2 (
Language,
This->SupportedLanguages,
mUnixSnpDriverNameTable,
DriverName,
(BOOLEAN)(This == &gUnixSnpDriverComponentName)
);
}
/**
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 not a valid EFI_HANDLE.
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
EFI_HANDLE.
@retval EFI_INVALID_PARAMETER 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
UnixSnpDriverComponentNameGetControllerName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
)
{
return EFI_UNSUPPORTED;
}

1791
UnixPkg/UnixSnpDxe/UnixSnp.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,156 @@
/** @file
Copyright (c) 2010, Apple, Inc. 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.
Module Name:
UnixSnp.h
Abstract:
-**/
#ifndef _UNIX_SNP_H_
#define _UNIX_SNP_H_
#include <Uefi.h>
#include <Protocol/SimpleNetwork.h>
#include <Protocol/DevicePath.h>
#include <Protocol/UnixIo.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/NetLib.h>
#define NET_ETHER_HEADER_SIZE 14
//
// Private data for driver.
//
#define UNIX_SNP_PRIVATE_DATA_SIGNATURE SIGNATURE_32( 'U', 'S', 'N', 'P' )
typedef struct
{
UINT32 Signature;
EFI_UNIX_THUNK_PROTOCOL* UnixThunk;
EFI_HANDLE DeviceHandle;
EFI_DEVICE_PATH_PROTOCOL* DevicePath;
EFI_MAC_ADDRESS MacAddress;
CHAR8* InterfaceName;
INTN ReadBufferSize;
VOID* ReadBuffer;
//
// Two walking pointers to manage the multiple packets that can be returned
// in a single read.
//
VOID* CurrentReadPointer;
VOID* EndReadPointer;
INTN BpfFd;
EFI_SIMPLE_NETWORK_PROTOCOL Snp;
EFI_SIMPLE_NETWORK_MODE Mode;
} UNIX_SNP_PRIVATE_DATA;
#define UNIX_SNP_PRIVATE_DATA_FROM_SNP_THIS(a) \
CR( a, UNIX_SNP_PRIVATE_DATA, Snp, UNIX_SNP_PRIVATE_DATA_SIGNATURE )
extern EFI_DRIVER_BINDING_PROTOCOL gUnixSnpDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gUnixSnpDriverComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gUnixSnpDriverComponentName2;
/**
Test to see if this driver supports ControllerHandle. This service
is called by the EFI boot service ConnectController(). In
order to make drivers as small as possible, there are a few calling
restrictions for this service. ConnectController() must
follow these calling restrictions. If any other agent wishes to call
Supported() it must also follow these calling restrictions.
@param This Protocol instance pointer.
@param ControllerHandle Handle of device to test
@param RemainingDevicePath Optional parameter use to pick a specific child
device to start.
@retval EFI_SUCCESS This driver supports this device
@retval EFI_UNSUPPORTED This driver does not support this device
**/
EFI_STATUS
EFIAPI
UnixSnpDriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL * This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
);
/**
Start this driver on ControllerHandle. This service is called by the
EFI boot service ConnectController(). In order to make
drivers as small as possible, there are a few calling restrictions for
this service. ConnectController() must follow these
calling restrictions. If any other agent wishes to call Start() it
must also follow these calling restrictions.
@param This Protocol instance pointer.
@param ControllerHandle Handle of device to bind driver to
@param RemainingDevicePath Optional parameter use to pick a specific child
device to start.
@retval EFI_SUCCESS Always succeeds.
**/
EFI_STATUS
EFIAPI
UnixSnpDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL * This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
);
/**
Stop this driver on ControllerHandle. This service is called by the
EFI boot service DisconnectController(). In order to
make drivers as small as possible, there are a few calling
restrictions for this service. DisconnectController()
must follow these calling restrictions. If any other agent wishes
to call Stop() it must also follow these calling restrictions.
@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 Always succeeds.
**/
EFI_STATUS
EFIAPI
UnixSnpDriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
);
#endif // _UNIX_SNP_H_

View File

@ -0,0 +1,58 @@
#/** @file
# Component name for module UnixSnpDxe
#
# Copyright (c) 2010, Apple, Inc. All rights reserved
#
# 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 = UnixSnpDxe
FILE_GUID = 20BAF49B-036D-4CA6-8FAF-583ED2737F95
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
ENTRY_POINT = InitializeUnixSnpDriver
# UNLOAD_IMAGE = UnixSnpUnload
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources.common]
ComponentName.c
UnixSnp.h
UnixSnp.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
UnixPkg/UnixPkg.dec
[LibraryClasses]
DevicePathLib
UefiLib
UefiBootServicesTableLib
BaseMemoryLib
DebugLib
UefiDriverEntryPoint
NetLib
[Protocols]
gEfiSimpleNetworkProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiDevicePathProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiUnixIoProtocolGuid # PROTOCOL ALWAYS_CONSUMED
[Guids]
gEfiUnixNetworkGuid # GUID ALWAYS_CONSUMED

View File

@ -25,6 +25,7 @@ Abstract:
#include "PiDxe.h" #include "PiDxe.h"
#include <Guid/EventGroup.h> #include <Guid/EventGroup.h>
#include <Protocol/SimpleTextIn.h> #include <Protocol/SimpleTextIn.h>
#include <Protocol/SimplePointer.h>
#include <Protocol/UgaDraw.h> #include <Protocol/UgaDraw.h>
#include "Protocol/UnixUgaIo.h" #include "Protocol/UnixUgaIo.h"
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
@ -48,6 +49,7 @@ typedef struct {
EFI_HANDLE Handle; EFI_HANDLE Handle;
EFI_UGA_DRAW_PROTOCOL UgaDraw; EFI_UGA_DRAW_PROTOCOL UgaDraw;
EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleTextIn; EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleTextIn;
EFI_SIMPLE_POINTER_PROTOCOL SimplePointer;
EFI_UNIX_THUNK_PROTOCOL *UnixThunk; EFI_UNIX_THUNK_PROTOCOL *UnixThunk;
@ -61,6 +63,8 @@ typedef struct {
UINT32 ColorDepth; UINT32 ColorDepth;
UINT32 RefreshRate; UINT32 RefreshRate;
EFI_SIMPLE_POINTER_MODE PointerMode;
// //
// UGA Private Data knowing when to start hardware // UGA Private Data knowing when to start hardware
// //
@ -78,6 +82,9 @@ typedef struct {
#define UGA_PRIVATE_DATA_FROM_TEXT_IN_THIS(a) \ #define UGA_PRIVATE_DATA_FROM_TEXT_IN_THIS(a) \
CR(a, UGA_PRIVATE_DATA, SimpleTextIn, UGA_PRIVATE_DATA_SIGNATURE) CR(a, UGA_PRIVATE_DATA, SimpleTextIn, UGA_PRIVATE_DATA_SIGNATURE)
#define UGA_PRIVATE_DATA_FROM_POINTER_THIS(a) \
CR(a, UGA_PRIVATE_DATA, SimplePointer, UGA_PRIVATE_DATA_SIGNATURE)
// //
// Global Protocol Variables // Global Protocol Variables
// //
@ -287,6 +294,27 @@ UnixUgaInitializeSimpleTextInForWindow (
) )
/*++ /*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Returns:
TODO: add return values
--*/
;
EFI_STATUS
UnixUgaInitializeSimplePointerForWindow (
IN UGA_PRIVATE_DATA *Private
)
/*++
Routine Description: Routine Description:
TODO: Add function description TODO: Add function description

View File

@ -66,6 +66,7 @@
[Protocols] [Protocols]
gEfiSimpleTextInProtocolGuid # PROTOCOL BY_START gEfiSimpleTextInProtocolGuid # PROTOCOL BY_START
gEfiSimplePointerProtocolGuid # PROTOCOL BY_START
gEfiUnixUgaIoProtocolGuid # PROTOCOL BY_START gEfiUnixUgaIoProtocolGuid # PROTOCOL BY_START
gEfiUgaDrawProtocolGuid # PROTOCOL BY_START gEfiUgaDrawProtocolGuid # PROTOCOL BY_START
gEfiUnixIoProtocolGuid # PROTOCOL TO_START gEfiUnixIoProtocolGuid # PROTOCOL TO_START

View File

@ -177,6 +177,8 @@ Returns:
&Private->UgaDraw, &Private->UgaDraw,
&gEfiSimpleTextInProtocolGuid, &gEfiSimpleTextInProtocolGuid,
&Private->SimpleTextIn, &Private->SimpleTextIn,
&gEfiSimplePointerProtocolGuid,
&Private->SimplePointer,
NULL NULL
); );
@ -264,6 +266,8 @@ Returns:
&Private->UgaDraw, &Private->UgaDraw,
&gEfiSimpleTextInProtocolGuid, &gEfiSimpleTextInProtocolGuid,
&Private->SimpleTextIn, &Private->SimpleTextIn,
&gEfiSimplePointerProtocolGuid,
&Private->SimplePointer,
NULL NULL
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {

View File

@ -1,6 +1,7 @@
/*++ /*++
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2010, Apple, Inc. All rights reserved.
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -57,7 +58,7 @@ Returns:
--*/ --*/
{ {
UGA_PRIVATE_DATA *Private; UGA_PRIVATE_DATA *Private;
EFI_INPUT_KEY Key; EFI_KEY_DATA Key;
EFI_TPL OldTpl; EFI_TPL OldTpl;
Private = UGA_PRIVATE_DATA_FROM_TEXT_IN_THIS (This); Private = UGA_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);
@ -73,7 +74,7 @@ Returns:
// //
// A reset is draining the Queue // A reset is draining the Queue
// //
while (Private->UgaIo->UgaGetKey(Private->UgaIo, &Key) == EFI_SUCCESS) while (Private->UgaIo->UgaGetKey (Private->UgaIo, &Key) == EFI_SUCCESS)
; ;
// //
@ -87,7 +88,7 @@ EFI_STATUS
EFIAPI EFIAPI
UnixUgaSimpleTextInReadKeyStroke ( UnixUgaSimpleTextInReadKeyStroke (
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
OUT EFI_INPUT_KEY *Key OUT EFI_INPUT_KEY *Key
) )
/*++ /*++
@ -109,7 +110,8 @@ Returns:
UGA_PRIVATE_DATA *Private; UGA_PRIVATE_DATA *Private;
EFI_STATUS Status; EFI_STATUS Status;
EFI_TPL OldTpl; EFI_TPL OldTpl;
EFI_KEY_DATA KeyData;
Private = UGA_PRIVATE_DATA_FROM_TEXT_IN_THIS (This); Private = UGA_PRIVATE_DATA_FROM_TEXT_IN_THIS (This);
if (Private->UgaIo == NULL) { if (Private->UgaIo == NULL) {
return EFI_NOT_READY; return EFI_NOT_READY;
@ -120,7 +122,9 @@ Returns:
// //
OldTpl = gBS->RaiseTPL (TPL_NOTIFY); OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
Status = Private->UgaIo->UgaGetKey(Private->UgaIo, Key); Status = Private->UgaIo->UgaGetKey(Private->UgaIo, &KeyData);
CopyMem (Key, &KeyData, sizeof (EFI_INPUT_KEY));
// //
// Leave critical section and return // Leave critical section and return
// //
@ -179,6 +183,156 @@ Returns:
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
} }
//
// Simple Pointer implementation.
//
EFI_STATUS
EFIAPI
UnixUgaSimplePointerReset (
IN EFI_SIMPLE_POINTER_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
ExtendedVerification - TODO: add argument description
Returns:
EFI_SUCCESS - TODO: Add description for return value
--*/
{
UGA_PRIVATE_DATA *Private;
EFI_SIMPLE_POINTER_STATE State;
EFI_TPL OldTpl;
Private = UGA_PRIVATE_DATA_FROM_POINTER_THIS (This);
if (Private->UgaIo == NULL) {
return EFI_SUCCESS;
}
//
// Enter critical section
//
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
//
// A reset is draining the Queue
//
while (Private->UgaIo->UgaGetPointerState(Private->UgaIo, &State) == EFI_SUCCESS)
;
//
// Leave critical section and return
//
gBS->RestoreTPL (OldTpl);
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
UnixUgaSimplePointerGetState (
IN EFI_SIMPLE_POINTER_PROTOCOL *This,
IN OUT EFI_SIMPLE_POINTER_STATE *State
)
/*++
Routine Description:
TODO: Add function description
Arguments:
This - TODO: add argument description
Key - TODO: add argument description
Returns:
TODO: add return values
--*/
{
UGA_PRIVATE_DATA *Private;
EFI_STATUS Status;
EFI_TPL OldTpl;
Private = UGA_PRIVATE_DATA_FROM_POINTER_THIS (This);
if (Private->UgaIo == NULL) {
return EFI_NOT_READY;
}
//
// Enter critical section
//
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
Status = Private->UgaIo->UgaGetPointerState(Private->UgaIo, State);
//
// Leave critical section and return
//
gBS->RestoreTPL (OldTpl);
return Status;
}
VOID
EFIAPI
UnixUgaSimplePointerWaitForInput (
IN EFI_EVENT Event,
IN VOID *Context
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Event - TODO: add argument description
Context - TODO: add argument description
Returns:
TODO: add return values
--*/
{
UGA_PRIVATE_DATA *Private;
EFI_STATUS Status;
EFI_TPL OldTpl;
Private = (UGA_PRIVATE_DATA *) Context;
if (Private->UgaIo == NULL) {
return;
}
//
// Enter critical section
//
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
Status = Private->UgaIo->UgaCheckPointer(Private->UgaIo);
if (!EFI_ERROR (Status)) {
//
// If the pointer state has changed, signal our event.
//
gBS->SignalEvent (Event);
}
//
// Leave critical section and return
//
gBS->RestoreTPL (OldTpl);
}
EFI_STATUS EFI_STATUS
UnixUgaInitializeSimpleTextInForWindow ( UnixUgaInitializeSimpleTextInForWindow (
IN UGA_PRIVATE_DATA *Private IN UGA_PRIVATE_DATA *Private
@ -217,3 +371,48 @@ Returns:
return Status; return Status;
} }
EFI_STATUS
UnixUgaInitializeSimplePointerForWindow (
IN UGA_PRIVATE_DATA *Private
)
/*++
Routine Description:
TODO: Add function description
Arguments:
Private - TODO: add argument description
Returns:
TODO: add return values
--*/
{
EFI_STATUS Status;
//
// Initialize Simple Pointer protoocol
//
Private->PointerMode.ResolutionX = 1;
Private->PointerMode.ResolutionY = 1;
Private->PointerMode.LeftButton = TRUE;
Private->PointerMode.RightButton = TRUE;
Private->SimplePointer.Reset = UnixUgaSimplePointerReset;
Private->SimplePointer.GetState = UnixUgaSimplePointerGetState;
Private->SimplePointer.Mode = &Private->PointerMode;
Status = gBS->CreateEvent (
EVT_NOTIFY_WAIT,
TPL_NOTIFY,
UnixUgaSimplePointerWaitForInput,
Private,
&Private->SimplePointer.WaitForInput
);
return Status;
}

View File

@ -394,6 +394,8 @@ Returns:
UnixUgaInitializeSimpleTextInForWindow (Private); UnixUgaInitializeSimpleTextInForWindow (Private);
UnixUgaInitializeSimplePointerForWindow (Private);
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -7,7 +7,7 @@
set -e set -e
# #
# Source the workspace and set up the environment varaibles we need # Source the workspace and set up the environment variables we need
# #
cd ../.. cd ../..
./build.sh $1 $2 $3 $4 $5 $6 $8 ./build.sh $1 $2 $3 $4 $5 $6 $8

View File

@ -7,7 +7,7 @@
set -e set -e
# #
# Source the workspace and set up the environment varaibles we need # Source the workspace and set up the environment variables we need
# #
cd ../.. cd ../..
echo `pwd` echo `pwd`