diff options
author | andrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-12-01 00:41:31 +0000 |
---|---|---|
committer | andrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-12-01 00:41:31 +0000 |
commit | d0c3acd4c4b3cf48e025db8a22b8a181454813fc (patch) | |
tree | a7e5f8d7ad1188f4f78ce361fb9b2dca5c276a8e | |
parent | 2ff79f2eda16f8219140d3dae188d2b341f610e1 (diff) | |
download | edk2-platforms-d0c3acd4c4b3cf48e025db8a22b8a181454813fc.tar.xz |
2nd wave of r11105 checkin.2nd wave of r11105 checkin.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11106 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r-- | UnixPkg/Include/Common/UnixInclude.h | 157 | ||||
-rw-r--r-- | UnixPkg/Include/Protocol/UnixThunk.h | 132 | ||||
-rw-r--r-- | UnixPkg/Library/UnixBaseLib/X64/Thunk16.S | 60 | ||||
-rw-r--r-- | UnixPkg/Sec/UgaX11.c | 3 | ||||
-rw-r--r-- | UnixPkg/UnixSerialIoDxe/UnixSerialIo.c | 3 | ||||
-rw-r--r-- | UnixPkg/UnixSerialIoDxe/UnixSerialIo.h | 14 |
6 files changed, 190 insertions, 179 deletions
diff --git a/UnixPkg/Include/Common/UnixInclude.h b/UnixPkg/Include/Common/UnixInclude.h index cc02353cd2..8cfa2a3deb 100644 --- a/UnixPkg/Include/Common/UnixInclude.h +++ b/UnixPkg/Include/Common/UnixInclude.h @@ -1,7 +1,7 @@ /*++
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
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
@@ -20,21 +20,164 @@ Abstract: #ifndef __UNIX_INCLUDE_H__
#define __UNIX_INCLUDE_H__
+
+// #include <sys/poll.h>
+// #include <dirent.h>
+
+//
+// Name mangle to prevent build errors. I.e conflicts between EFI and OS
+//
+#define NTOHL _UNIX_EFI_NAME_MANGLE_NTOHL_
+#define HTONL _UNIX_EFI_NAME_MANGLE_HTONL_
+#define NTOHS _UNIX_EFI_NAME_MANGLE_NTOHS_
+#define HTONS _UNIX_EFI_NAME_MANGLE_HTOHS_
+#define B0 _UNIX_EFI_NAME_MANGLE_B0_
+
+
+#include <stdio.h>
+#include <stdlib.h>
+
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/termios.h>
+#include <sys/time.h>
+
+#if __CYGWIN__
+#include <sys/dirent.h>
+#else
+#include <sys/dir.h>
+#endif
+
+#include <unistd.h>
+#include <poll.h>
+#include <fcntl.h>
+#include <time.h>
+#include <signal.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.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__
#include <sys/param.h>
#include <sys/mount.h>
+#define _XOPEN_SOURCE
+#ifndef _Bool
+ #define _Bool char // for clang debug
+#endif
#else
+#include <termio.h>
#include <sys/vfs.h>
#endif
-#include <sys/poll.h>
-#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <time.h>
#include <utime.h>
-#include <unistd.h>
+
+#if __APPLE__
+//
+// EFI packing is not compatible witht he default OS packing for struct stat.
+// st_size is 64-bit but starts on a 32-bit offset in the structure. The compiler
+// flags used to produce compatible EFI images, break struct stat
+//
+#ifdef MDE_CPU_IA32
+#pragma pack(4)
#endif
+
+#if defined(__DARWIN_64_BIT_INO_T)
+
+
+typedef struct {
+ UINTN tv_sec; /* seconds */
+ UINTN tv_nsec; /* and nanoseconds */
+} EFI_timespec;
+
+
+
+typedef struct stat_fix { \
+ dev_t st_dev; /* [XSI] ID of device containing file */
+ mode_t st_mode; /* [XSI] Mode of file (see below) */
+ nlink_t st_nlink; /* [XSI] Number of hard links */
+ __darwin_ino64_t st_ino; /* [XSI] File serial number */
+ uid_t st_uid; /* [XSI] User ID of the file */
+ gid_t st_gid; /* [XSI] Group ID of the file */
+ dev_t st_rdev; /* [XSI] Device ID */
+
+ // 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 */
+ blkcnt_t st_blocks; /* [XSI] blocks allocated for file */
+ blksize_t st_blksize; /* [XSI] optimal blocksize for I/O */
+ __uint32_t st_flags; /* user defined flags for file */
+ __uint32_t st_gen; /* file generation number */
+ __int32_t st_lspare; /* RESERVED: DO NOT USE! */
+ __int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */
+} STAT_FIX;
+
+#else /* !__DARWIN_64_BIT_INO_T */
+
+typedef struct stat_fix {
+ dev_t st_dev; /* [XSI] ID of device containing file */
+ ino_t st_ino; /* [XSI] File serial number */
+ mode_t st_mode; /* [XSI] Mode of file (see below) */
+ nlink_t st_nlink; /* [XSI] Number of hard links */
+ uid_t st_uid; /* [XSI] User ID of the file */
+ gid_t st_gid; /* [XSI] Group ID of the file */
+ dev_t st_rdev; /* [XSI] Device ID */
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
+ struct timespec st_atimespec; /* time of last access */
+ struct timespec st_mtimespec; /* time of last data modification */
+ struct timespec st_ctimespec; /* time of last status change */
+#else
+ time_t st_atime; /* [XSI] Time of last access */
+ long st_atimensec; /* nsec of last access */
+ time_t st_mtime; /* [XSI] Last data modification time */
+ long st_mtimensec; /* last data modification nsec */
+ time_t st_ctime; /* [XSI] Time of last status change */
+ long st_ctimensec; /* nsec of last status change */
+#endif
+ off_t st_size; /* [XSI] file size, in bytes */
+ blkcnt_t st_blocks; /* [XSI] blocks allocated for file */
+ blksize_t st_blksize; /* [XSI] optimal blocksize for I/O */
+ __uint32_t st_flags; /* user defined flags for file */
+ __uint32_t st_gen; /* file generation number */
+ __int32_t st_lspare; /* RESERVED: DO NOT USE! */
+ __int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */
+} STAT_FIX;
+
+#endif
+
+#ifdef MDE_CPU_IA32
+#pragma pack(4)
+#endif
+
+#else
+
+ typedef struct stat STAT_FIX;
+
+#endif
+
+//
+// Undo name mangling
+//
+#undef NTOHL
+#undef HTONL
+#undef NTOHS
+#undef HTONS
+#undef B0
+
+
+#endif
+
diff --git a/UnixPkg/Include/Protocol/UnixThunk.h b/UnixPkg/Include/Protocol/UnixThunk.h index a5383be29e..85ac5f9086 100644 --- a/UnixPkg/Include/Protocol/UnixThunk.h +++ b/UnixPkg/Include/Protocol/UnixThunk.h @@ -29,142 +29,12 @@ Abstract: #ifndef _UNIX_THUNK_H_ #define _UNIX_THUNK_H_ -#include <sys/termios.h> -#include <stdio.h> -#include <sys/time.h> - -#if __CYGWIN__ -#include <sys/dirent.h> -#else -#include <sys/dir.h> -#endif - -#include <unistd.h> -#include <poll.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <time.h> -#include <signal.h> -#include <errno.h> -#include <string.h> -#include <stdlib.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__ -#include <sys/param.h> -#include <sys/mount.h> -#define _XOPEN_SOURCE -#ifndef _Bool - #define _Bool char // for clang debug -#endif -#else -#include <termio.h> -#include <sys/vfs.h> -#endif - -#include <utime.h> +#include <Common/UnixInclude.h> #include <Base.h> #include <Library/PeCoffLib.h> -#if __APPLE__ -// -// EFI packing is not compatible witht he default OS packing for struct stat. -// st_size is 64-bit but starts on a 32-bit offset in the structure. The compiler -// flags used to produce compatible EFI images, break struct stat -// -#ifdef MDE_CPU_IA32 -#pragma pack(4) -#endif - -#if defined(__DARWIN_64_BIT_INO_T) - - -typedef struct { - UINTN tv_sec; /* seconds */ - UINTN tv_nsec; /* and nanoseconds */ -} EFI_timespec; - - - -typedef struct stat_fix { \ - dev_t st_dev; /* [XSI] ID of device containing file */ - mode_t st_mode; /* [XSI] Mode of file (see below) */ - nlink_t st_nlink; /* [XSI] Number of hard links */ - __darwin_ino64_t st_ino; /* [XSI] File serial number */ - uid_t st_uid; /* [XSI] User ID of the file */ - gid_t st_gid; /* [XSI] Group ID of the file */ - dev_t st_rdev; /* [XSI] Device ID */ - - // 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 */ - blkcnt_t st_blocks; /* [XSI] blocks allocated for file */ - blksize_t st_blksize; /* [XSI] optimal blocksize for I/O */ - __uint32_t st_flags; /* user defined flags for file */ - __uint32_t st_gen; /* file generation number */ - __int32_t st_lspare; /* RESERVED: DO NOT USE! */ - __int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */ -} STAT_FIX; - -#else /* !__DARWIN_64_BIT_INO_T */ - -typedef struct stat_fix { - dev_t st_dev; /* [XSI] ID of device containing file */ - ino_t st_ino; /* [XSI] File serial number */ - mode_t st_mode; /* [XSI] Mode of file (see below) */ - nlink_t st_nlink; /* [XSI] Number of hard links */ - uid_t st_uid; /* [XSI] User ID of the file */ - gid_t st_gid; /* [XSI] Group ID of the file */ - dev_t st_rdev; /* [XSI] Device ID */ -#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) - struct timespec st_atimespec; /* time of last access */ - struct timespec st_mtimespec; /* time of last data modification */ - struct timespec st_ctimespec; /* time of last status change */ -#else - time_t st_atime; /* [XSI] Time of last access */ - long st_atimensec; /* nsec of last access */ - time_t st_mtime; /* [XSI] Last data modification time */ - long st_mtimensec; /* last data modification nsec */ - time_t st_ctime; /* [XSI] Time of last status change */ - long st_ctimensec; /* nsec of last status change */ -#endif - off_t st_size; /* [XSI] file size, in bytes */ - blkcnt_t st_blocks; /* [XSI] blocks allocated for file */ - blksize_t st_blksize; /* [XSI] optimal blocksize for I/O */ - __uint32_t st_flags; /* user defined flags for file */ - __uint32_t st_gen; /* file generation number */ - __int32_t st_lspare; /* RESERVED: DO NOT USE! */ - __int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */ -} STAT_FIX; - -#endif - -#ifdef MDE_CPU_IA32 -#pragma pack(4) -#endif - -#else - - typedef struct stat STAT_FIX; - -#endif #define EFI_UNIX_THUNK_PROTOCOL_GUID \ { \ diff --git a/UnixPkg/Library/UnixBaseLib/X64/Thunk16.S b/UnixPkg/Library/UnixBaseLib/X64/Thunk16.S index 049ec86355..0ec71cd4b0 100644 --- a/UnixPkg/Library/UnixBaseLib/X64/Thunk16.S +++ b/UnixPkg/Library/UnixBaseLib/X64/Thunk16.S @@ -30,31 +30,37 @@ ASM_GLOBAL ASM_PFX(mTransition) ASM_GLOBAL ASM_PFX(InternalAsmThunk16)
# define the structure of IA32_REGS
-.set _EDI, 0 #size 4
-.set _ESI, 4 #size 4
-.set _EBP, 8 #size 4
-.set _ESP, 12 #size 4
-.set _EBX, 16 #size 4
-.set _EDX, 20 #size 4
-.set _ECX, 24 #size 4
-.set _EAX, 28 #size 4
-.set _DS, 32 #size 2
-.set _ES, 34 #size 2
-.set _FS, 36 #size 2
-.set _GS, 38 #size 2
-.set _EFLAGS, 40 #size 8
-.set _EIP, 48 #size 4
-.set _CS, 52 #size 2
-.set _SS, 54 #size 2
-.set IA32_REGS_SIZE, 56
+#define _EDI 0 // size 4
+#define _ESI 4 // size 4
+#define _EBP 8 // size 4
+#define _ESP 12 // size 4
+#define _EBX 16 // size 4
+#define _EDX 20 // size 4
+#define _ECX 24 // size 4
+#define _EAX 28 // size 4
+#define _DS 32 // size 2
+#define _ES 34 // size 2
+#define _FS 36 // size 2
+#define _GS 38 // size 2
+#define _EFLAGS 40 // size 8
+#define _EIP 48 // size 4
+#define _CS 52 // size 2
+#define _SS 54 // size 2
+#define IA32_REGS_SIZE 56
.data
-ASM_PFX(m16Size): .word ASM_PFX(InternalAsmThunk16) - ASM_PFX(m16Start)
-ASM_PFX(mThunk16Attr): .word _ThunkAttr - ASM_PFX(m16Start)
-ASM_PFX(m16Gdt): .word ASM_PFX(NullSeg) - ASM_PFX(m16Start)
-ASM_PFX(m16GdtrBase): .word _16GdtrBase - ASM_PFX(m16Start)
-ASM_PFX(mTransition): .word _EntryPoint - ASM_PFX(m16Start)
+.set L_m16SizeSym, ASM_PFX(InternalAsmThunk16) - ASM_PFX(m16Start)
+.set L_mThunk16AttrSym, _ThunkAttr - ASM_PFX(m16Start)
+.set L_m16GdtSym, ASM_PFX(NullSeg) - ASM_PFX(m16Start)
+.set L_m16GdtrBaseSym, _16GdtrBase - ASM_PFX(m16Start)
+.set L_mTransitionSym, _EntryPoint - ASM_PFX(m16Start)
+
+ASM_PFX(m16Size): .word L_m16SizeSym
+ASM_PFX(mThunk16Attr): .word L_mThunk16AttrSym
+ASM_PFX(m16Gdt): .word L_m16GdtSym
+ASM_PFX(m16GdtrBase): .word L_m16GdtrBaseSym
+ASM_PFX(mTransition): .word L_mTransitionSym
.text
@@ -118,7 +124,8 @@ L_2: shlw $4,%ax
lea (L_64BitCode - L_Base)(%ebx, %eax), %ax
.byte 0x66,0x2e,0x89,0x87 # mov cs:[bx + (L_64Eip - L_Base)], eax
- .word L_64Eip - L_Base
+.set EipOffset, L_64Eip - L_Base
+ .word EipOffset
.byte 0x66,0xb8 # mov eax, imm32
SavedCr4: .space 4
movq %rax, %cr4
@@ -147,7 +154,7 @@ SavedSp: .space 4 # restore stack _EntryPoint: .long ASM_PFX(ToUserCode) - ASM_PFX(m16Start)
.word CODE16
-_16Gdtr: .word GDT_SIZE - 1
+_16Gdtr: .word L_GDT_SIZE - 1
_16GdtrBase: .quad ASM_PFX(NullSeg)
_16Idtr: .word 0x3ff
.long 0
@@ -220,7 +227,7 @@ ASM_PFX(_32Data): .byte 0xcf # 16-bit segment, 4GB limit
.byte 0
-.set GDT_SIZE, . - ASM_PFX(NullSeg)
+.set L_GDT_SIZE, . - ASM_PFX(NullSeg)
#------------------------------------------------------------------------------
# IA32_REGISTER_SET *
@@ -301,7 +308,8 @@ ASM_PFX(InternalAsmThunk16): movw %r8w, (SavedCs - SavedCr4)(%rcx)
movl %esp, (SavedSp - SavedCr4)(%rcx)
.byte 0xff, 0x69 # jmp (_EntryPoint - SavedCr4)(%rcx)
- .byte _EntryPoint - SavedCr4
+.set EntryPointSavedCr4Offset, _EntryPoint - SavedCr4
+ .byte EntryPointSavedCr4Offset
L_RetFromRealMode:
popfq
lgdt 0x60(%rsp) # restore protected mode GDTR
diff --git a/UnixPkg/Sec/UgaX11.c b/UnixPkg/Sec/UgaX11.c index c1a2b2d7a5..0a9b0a314c 100644 --- a/UnixPkg/Sec/UgaX11.c +++ b/UnixPkg/Sec/UgaX11.c @@ -11,11 +11,10 @@ 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 <Common/UnixInclude.h> #include <sys/ipc.h> #include <sys/shm.h> -#include <stdio.h> -#include <stdlib.h> #include <PiPei.h> #include <Protocol/SimplePointer.h> diff --git a/UnixPkg/UnixSerialIoDxe/UnixSerialIo.c b/UnixPkg/UnixSerialIoDxe/UnixSerialIo.c index 0f3ac51f55..b197ae624a 100644 --- a/UnixPkg/UnixSerialIoDxe/UnixSerialIo.c +++ b/UnixPkg/UnixSerialIoDxe/UnixSerialIo.c @@ -108,7 +108,8 @@ ConvertBaud2Unix ( {
switch (BaudRate) {
case 0:
- return B0;
+ return 0; // Don't use B0 as it is also used in EFI #includes as a name so termios.h #define
+ // can break the build.
case 50:
return B50;
case 75:
diff --git a/UnixPkg/UnixSerialIoDxe/UnixSerialIo.h b/UnixPkg/UnixSerialIoDxe/UnixSerialIo.h index f58014eaa8..484a07c482 100644 --- a/UnixPkg/UnixSerialIoDxe/UnixSerialIo.h +++ b/UnixPkg/UnixSerialIoDxe/UnixSerialIo.h @@ -21,20 +21,10 @@ Abstract: #ifndef _UNIXPKG_SERIAL_IO_
#define _UNIXPKG_SERIAL_IO_
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdio.h>
-
-#ifdef __APPLE__
-#else
-#include <stdlib.h>
-#include <termio.h>
-#endif
-#include <fcntl.h>
-#include <errno.h>
+#include <Common/UnixInclude.h>
-#include "Uefi.h"
+#include <Uefi.h>
#include <Protocol/SerialIo.h>
#include <Protocol/DevicePath.h>
|