Complete coding to support X64 EFI ABI in UnixPkg. Code is not currently hooked in or tested, but it is code complete. Only missing step from testing is figuring out how to build with two different ABIs for the same platform. Sec needs a different ABI. May need to add a 2nd build step.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10710 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
andrewfish 2010-07-29 03:24:13 +00:00
parent 712a5698a6
commit a4902cccdf
10 changed files with 761 additions and 7967 deletions

View File

@ -308,14 +308,14 @@ void
typedef
int
#if __CYGWIN__
(*UnixIoCtl) (int fd, int __request, ...);
(*UnixIoCtl) (int fd, int __request, UINTN Arg);
#else
(*UnixIoCtl) (int fd, unsigned long int __request, ...);
(*UnixIoCtl) (int fd, unsigned long int __request, void *Arg);
#endif
typedef
int
(*UnixFcntl) (int __fd, int __cmd, ...);
(*UnixFcntl) (int __fd, int __cmd, void *Arg);
typedef
int

View File

@ -51,19 +51,24 @@ EFI_STATUS
EFI_INPUT_KEY *key
);
typedef struct {
UINTN SourceX;
UINTN SourceY;
UINTN DestinationX;
UINTN DestinationY;
UINTN Width;
UINTN Height;
UINTN Delta;
} UGA_BLT_ARGS;
typedef
EFI_STATUS
(*UGABlt)(
IN EFI_UNIX_UGA_IO_PROTOCOL *Uga,
IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
IN EFI_UGA_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
IN UGA_BLT_ARGS *Args
);
struct _EFI_UNIX_UGA_IO_PROTOCOL {

View File

@ -266,22 +266,16 @@ Gasketperror (__const char *__s)
// ... is always an int or pointer to device specific data structure
//
int
Gasketioctl (int fd, unsigned long int __request, ...)
Gasketioctl (int fd, unsigned long int __request, void *Arg)
{
VA_LIST Marker;
VA_START (Marker, __request);
return GasketUintnUintnUintn (ioctl, fd, __request, VA_ARG (Marker, UINTN));
return GasketUintnUintnUintn (ioctl, fd, __request, (UINTN)Arg);
}
int
Gasketfcntl (int __fd, int __cmd, ...)
Gasketfcntl (int __fd, int __cmd, void *Arg)
{
VA_LIST Marker;
VA_START (Marker, __cmd);
return GasketUintnUintnUintn (fcntl, __fd, __cmd, VA_ARG (Marker, UINTN));
return GasketUintnUintnUintn (fcntl, __fd, __cmd, (UINTN)Arg);
}

View File

@ -63,8 +63,8 @@ void Gasketperror (__const char *__s);
//
// ... is always an int or pointer to device specific data structure
//
int Gasketioctl (int fd, unsigned long int __request, ...);
int Gasketfcntl (int __fd, int __cmd, ...);
int Gasketioctl (int fd, unsigned long int __request, void *Arg);
int Gasketfcntl (int __fd, int __cmd, void *Arg);
int Gasketcfsetispeed (struct termios *__termios_p, speed_t __speed);
int Gasketcfsetospeed (struct termios *__termios_p, speed_t __speed);

View File

@ -400,16 +400,11 @@ UgaGetKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_INPUT_KEY *key)
}
EFI_STATUS
UgaBlt(EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
IN EFI_UGA_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
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
)
{
UGA_IO_PRIVATE *Private = (UGA_IO_PRIVATE *)UgaIo;
@ -432,11 +427,11 @@ UgaBlt(EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
//
// Source is Video.
//
if (SourceY + Height > Private->height) {
if (Args->SourceY + Args->Height > Private->height) {
return EFI_INVALID_PARAMETER;
}
if (SourceX + Width > Private->width) {
if (Args->SourceX + Args->Width > Private->width) {
return EFI_INVALID_PARAMETER;
}
}
@ -447,55 +442,55 @@ UgaBlt(EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
//
// Destination is Video
//
if (DestinationY + Height > Private->height) {
if (Args->DestinationY + Args->Height > Private->height) {
return EFI_INVALID_PARAMETER;
}
if (DestinationX + Width > Private->width) {
if (Args->DestinationX + Args->Width > Private->width) {
return EFI_INVALID_PARAMETER;
}
}
switch (BltOperation) {
case EfiUgaVideoToBltBuffer:
Blt = (EFI_UGA_PIXEL *)((UINT8 *)BltBuffer + (DestinationY * Delta) + DestinationX * sizeof (EFI_UGA_PIXEL));
Delta -= Width * sizeof (EFI_UGA_PIXEL);
for (SrcY = SourceY; SrcY < (Height + SourceY); SrcY++) {
for (SrcX = SourceX; SrcX < (Width + SourceX); SrcX++) {
Blt = (EFI_UGA_PIXEL *)((UINT8 *)BltBuffer + (Args->DestinationY * Args->Delta) + Args->DestinationX * sizeof (EFI_UGA_PIXEL));
Args->Delta -= Args->Width * sizeof (EFI_UGA_PIXEL);
for (SrcY = Args->SourceY; SrcY < (Args->Height + Args->SourceY); SrcY++) {
for (SrcX = Args->SourceX; SrcX < (Args->Width + Args->SourceX); SrcX++) {
*Blt++ = UgaColorToPixel(Private,
XGetPixel(Private->image, SrcX, SrcY));
}
Blt = (EFI_UGA_PIXEL *) ((UINT8 *) Blt + Delta);
Blt = (EFI_UGA_PIXEL *) ((UINT8 *) Blt + Args->Delta);
}
break;
case EfiUgaBltBufferToVideo:
Blt = (EFI_UGA_PIXEL *)((UINT8 *)BltBuffer + (SourceY * Delta) + SourceX * sizeof (EFI_UGA_PIXEL));
Delta -= Width * sizeof (EFI_UGA_PIXEL);
for (DstY = DestinationY; DstY < (Height + DestinationY); DstY++) {
for (DstX = DestinationX; DstX < (Width + DestinationX); DstX++) {
Blt = (EFI_UGA_PIXEL *)((UINT8 *)BltBuffer + (Args->SourceY * Args->Delta) + Args->SourceX * sizeof (EFI_UGA_PIXEL));
Args->Delta -= Args->Width * sizeof (EFI_UGA_PIXEL);
for (DstY = Args->DestinationY; DstY < (Args->Height + Args->DestinationY); DstY++) {
for (DstX = Args->DestinationX; DstX < (Args->Width + Args->DestinationX); DstX++) {
XPutPixel(Private->image, DstX, DstY, UgaPixelToColor(Private, *Blt));
Blt++;
}
Blt = (EFI_UGA_PIXEL *) ((UINT8 *) Blt + Delta);
Blt = (EFI_UGA_PIXEL *) ((UINT8 *) Blt + Args->Delta);
}
break;
case EfiUgaVideoToVideo:
Dst = Private->image_data + (DestinationX << Private->pixel_shift)
+ DestinationY * Private->line_bytes;
Src = Private->image_data + (SourceX << Private->pixel_shift)
+ SourceY * Private->line_bytes;
Nbr = Width << Private->pixel_shift;
if (DestinationY < SourceY) {
for (Index = 0; Index < Height; Index++) {
Dst = Private->image_data + (Args->DestinationX << Private->pixel_shift)
+ Args->DestinationY * Private->line_bytes;
Src = Private->image_data + (Args->SourceX << Private->pixel_shift)
+ Args->SourceY * Private->line_bytes;
Nbr = Args->Width << Private->pixel_shift;
if (Args->DestinationY < Args->SourceY) {
for (Index = 0; Index < Args->Height; Index++) {
memcpy (Dst, Src, Nbr);
Dst += Private->line_bytes;
Src += Private->line_bytes;
}
}
else {
Dst += (Height - 1) * Private->line_bytes;
Src += (Height - 1) * Private->line_bytes;
for (Index = 0; Index < Height; Index++) {
Dst += (Args->Height - 1) * Private->line_bytes;
Src += (Args->Height - 1) * Private->line_bytes;
for (Index = 0; Index < Args->Height; Index++) {
//
// Source and Destination Y may be equal, therefore Dst and Src may
// overlap.
@ -508,8 +503,8 @@ UgaBlt(EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
break;
case EfiUgaVideoFill:
Color = UgaPixelToColor(Private, *BltBuffer);
for (DstY = DestinationY; DstY < (Height + DestinationY); DstY++) {
for (DstX = DestinationX; DstX < (Width + DestinationX); DstX++) {
for (DstY = Args->DestinationY; DstY < (Args->Height + Args->DestinationY); DstY++) {
for (DstX = Args->DestinationX; DstX < (Args->Width + Args->DestinationX); DstX++) {
XPutPixel(Private->image, DstX, DstY, Color);
}
}
@ -524,7 +519,7 @@ UgaBlt(EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
switch (BltOperation) {
case EfiUgaVideoToVideo:
XCopyArea(Private->display, Private->win, Private->win, Private->gc,
SourceX, SourceY, Width, Height, DestinationX, DestinationY);
Args->SourceX, Args->SourceY, Args->Width, Args->Height, Args->DestinationX, Args->DestinationY);
while (1) {
XEvent ev;
@ -538,11 +533,11 @@ UgaBlt(EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
Color = UgaPixelToColor(Private, *BltBuffer);
XSetForeground(Private->display, Private->gc, Color);
XFillRectangle(Private->display, Private->win, Private->gc,
DestinationX, DestinationY, Width, Height);
Args->DestinationX, Args->DestinationY, Args->Width, Args->Height);
XFlush(Private->display);
break;
case EfiUgaBltBufferToVideo:
Redraw(Private, DestinationX, DestinationY, Width, Height);
Redraw(Private, Args->DestinationX, Args->DestinationY, Args->Width, Args->Height);
break;
default:
break;
@ -571,16 +566,10 @@ EFI_STATUS EFIAPI GasketUgaSize (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, UINT32 Width,
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,
EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
IN EFI_UGA_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
IN UGA_BLT_ARGS *Args
);
drv->UgaIo.UgaClose = GasketUgaClose;

View File

@ -1,3 +1,36 @@
#------------------------------------------------------------------------------
#
# This template was generated from GasketEfiTemplate.c Unix x86_64 ABI
#
# Efi Prefix means it has been ported to gasket EFIABI to Unix x86_64 ABI
#
# The EFI_UNIX_THUNK_PROTOCOL member functions call these these generic assembly
# routines.
#
# Some OS X POSIX calls get name mangled in C code and we need to fill in a C global
# to get the correct binding (does not work from assembly). So we have 4 functions
# that do an indirect call, while the others call POSIX APIs directly
#
# movq _gUnixRmDir@GOTPCREL(%rip), %rax
#
#
# UNIX Arg passing: RCX, RDX, R8, R9
# EFI Arg passing: RDI, RDI, RDX, RCX, R8, R9
#
# RSI, RDI calle-save on EFI, scatch on UNIX callign
#
#
# 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.
#
#------------------------------------------------------------------------------
#ifdef __APPLE__
.section __DWARF,__debug_frame,regular,debug
Lsection__debug_frame:
.section __DWARF,__debug_info,regular,debug
@ -28,6 +61,8 @@ Ldebug_abbrev0:
Ldebug_info0:
.section __DWARF,__debug_line,regular,debug
Ldebug_line0:
#endif
.text
Ltext0:
.globl _Gasketrmdir
@ -50,6 +85,7 @@ LCFI2:
.loc 1 37 0
leave
ret
LFE16:
.globl _Gasketopendir
_Gasketopendir:
@ -1069,6 +1105,7 @@ LCFI137:
leave
ret
LFE62:
.globl _ReverseGasketUint64
_ReverseGasketUint64:
LFB63:
@ -1093,6 +1130,24 @@ LCFI140:
.loc 1 418 0
leave
ret
.globl _EfiReverseGasketUint64
_EfiReverseGasketUint64:
pushq %rbp
movq %rsp, %rbp
subq $64, %rsp
movq %rdi, -24(%rbp)
movq %rsi, -32(%rbp)
movq -24(%rbp), %rax
movq %rax, -8(%rbp)
movq -32(%rbp), %rcx
movq -8(%rbp), %rax
call *%rax
leave
ret
#if __APPLE__
LFE63:
.section __DWARF,__debug_frame,regular,debug
Lframe0:
@ -8777,3 +8832,6 @@ LASF10:
LASF29:
.ascii "Gasketfsync\0"
.subsections_via_symbols
#endif

View File

@ -390,19 +390,13 @@ GasketUgaGetKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_INPUT_KEY *key)
EFI_STATUS
EFIAPI
GasketUgaBlt (
EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
IN EFI_UGA_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
IN UGA_BLT_ARGS *Args
)
{
return UgaBlt (UgaIo, BltBuffer, BltOperation, SourceX, SourceY, DestinationX, DestinationY, Width, Height, Delta);
return UgaBlt (UgaIo, BltBuffer, BltOperation, Args);
}
typedef void (*SET_TIMER_CALLBACK)(UINT64 delta);

File diff suppressed because it is too large Load Diff

View File

@ -20,8 +20,25 @@
// So these globals get you the correct name mangled functions that can
// be accessed from assembly
//
UnixRmDir gUnixRmDir = rmdir;
UnixOpenDir gUnixOpenDir = opendir;
UnixStat gUnixStat = (UnixStat)stat;
UnixStatFs gUnixStatFs = statfs;
UnixRmDir gUnixRmDir = rmdir;
UnixOpenDir gUnixOpenDir = opendir;
UnixStat gUnixStat = (UnixStat)stat;
UnixStatFs gUnixStatFs = statfs;
UnixReadDir gUnixReaddir = readdir;
UnixRewindDir gUnixRewinddir = rewinddir;
int
UnixIoCtl1 (
int fd,
unsigned long int __request,
UINTN Arg
)
{
return ioctl (fd, __request, Arg);
}
int
UnixFcntl1 (int __fd, int __cmd, UINTN Arg)
{
return fcntl (__fd, __cmd, Arg);
}

View File

@ -22,35 +22,35 @@
# Routine Description:
#
# Routine for switching stacks with 3 parameters EFI ABI
# Convert UNIX to EFI ABI
#
# Arguments:
#
# (rcx) EntryPoint - Entry point with new stack.
# (rdx) Context1 - Parameter1 for entry point.
# (r8) Context2 - Parameter2 for entry point.
# (r9) Context3 - Parameter3 for entry point.
# (rsp)0x20 NewStack - The pointer to new stack.
# (rdi) EntryPoint - Entry point with new stack.
# (rsi) Context1 - Parameter1 for entry point. (rcx)
# (rdx) Context2 - Parameter2 for entry point. (rdx)
# (rcx) Context3 - Parameter3 for entry point. (r8)
# (r8) NewStack - The pointer to new stack.
#
# Returns:
#
# None
#
#------------------------------------------------------------------------------
ASM_GLOBAL ASM_PFX(MsftPeiSwitchStacks)
ASM_PFX(MsftPeiSwitchStacks):
mov %rcx, %rax
mov %rdx, %rcx
mov %r8, %rdx
mov %r9, %r8
ASM_GLOBAL ASM_PFX(GasketPeiSwitchStacks)
ASM_PFX(GasketPeiSwitchStacks):
// movq %rdx, %rdx
movq %r8, %rsp
# get new stack from the stack
mov 0x20(%rsp), %rsp # is this off by 8?
movq %rdi, %rax
movq %rsi, %rcx
movq %rcx, %r8
#
# Reserve space for register parameters (rcx, rdx, r8 & r9) on the stack,
# in case the callee wishes to spill them.
#
lea -0x20(%rsp), %rsp
subq 40, %rsp // 32-byte shadow space plus alignment pad
call *%rax