]> git.proxmox.com Git - mirror_edk2.git/commitdiff
2nd wave of r11105 checkin.2nd wave of r11105 checkin.
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 1 Dec 2010 00:41:31 +0000 (00:41 +0000)
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 1 Dec 2010 00:41:31 +0000 (00:41 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11106 6f19259b-4bc3-4df7-8a09-765794883524

UnixPkg/Include/Common/UnixInclude.h
UnixPkg/Include/Protocol/UnixThunk.h
UnixPkg/Library/UnixBaseLib/X64/Thunk16.S
UnixPkg/Sec/UgaX11.c
UnixPkg/UnixSerialIoDxe/UnixSerialIo.c
UnixPkg/UnixSerialIoDxe/UnixSerialIo.h

index cc02353cd24ced54ddbfc9731bbf1a588e6b77dd..8cfa2a3deb766fdcd271a8189dfea2c56e3c57f7 100644 (file)
@@ -1,7 +1,7 @@
 /*++\r
 \r
 Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
-Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
+Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -20,21 +20,164 @@ Abstract:
 \r
 #ifndef __UNIX_INCLUDE_H__\r
 #define __UNIX_INCLUDE_H__\r
+\r
+// #include <sys/poll.h>\r
+// #include <dirent.h>\r
+\r
+//\r
+// Name mangle to prevent build errors. I.e conflicts between EFI and OS\r
+//\r
+#define NTOHL   _UNIX_EFI_NAME_MANGLE_NTOHL_\r
+#define HTONL   _UNIX_EFI_NAME_MANGLE_HTONL_\r
+#define NTOHS   _UNIX_EFI_NAME_MANGLE_NTOHS_\r
+#define HTONS   _UNIX_EFI_NAME_MANGLE_HTOHS_\r
+#define B0      _UNIX_EFI_NAME_MANGLE_B0_\r
+\r
+\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+\r
 #include <sys/types.h>\r
 #include <sys/stat.h>\r
+#include <sys/termios.h>\r
+#include <sys/time.h>\r
+\r
+#if __CYGWIN__\r
+#include <sys/dirent.h>\r
+#else\r
+#include <sys/dir.h>\r
+#endif\r
+\r
+#include <unistd.h>\r
+#include <poll.h>\r
+#include <fcntl.h>\r
+#include <time.h>\r
+#include <signal.h>\r
+#include <errno.h>\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <sys/ioctl.h>\r
+\r
+#include <sys/socket.h>\r
+#include <netdb.h>\r
+#include <netinet/in.h>\r
+#include <net/if.h>\r
+#include <net/if_dl.h>\r
+#include <ifaddrs.h>\r
+#include <net/bpf.h>\r
 \r
 #ifdef __APPLE__\r
 #include <sys/param.h>\r
 #include <sys/mount.h>\r
+#define _XOPEN_SOURCE\r
+#ifndef _Bool\r
+  #define _Bool char // for clang debug\r
+#endif\r
 #else\r
+#include <termio.h>\r
 #include <sys/vfs.h>\r
 #endif \r
 \r
-#include <sys/poll.h>\r
-#include <dirent.h>\r
-#include <errno.h>\r
-#include <fcntl.h>\r
-#include <time.h>\r
 #include <utime.h>\r
-#include <unistd.h>\r
+\r
+#if __APPLE__\r
+//\r
+// EFI packing is not compatible witht he default OS packing for struct stat.\r
+// st_size is 64-bit but starts on a 32-bit offset in the structure. The compiler\r
+// flags used to produce compatible EFI images, break struct stat\r
+//\r
+#ifdef MDE_CPU_IA32\r
+#pragma pack(4)\r
 #endif\r
+\r
+#if defined(__DARWIN_64_BIT_INO_T)\r
+\r
+\r
+typedef struct {\r
+  UINTN        tv_sec;         /* seconds */\r
+       UINTN   tv_nsec;        /* and nanoseconds */\r
+} EFI_timespec;\r
+\r
+\r
+\r
+typedef struct stat_fix { \\r
+       dev_t           st_dev;                 /* [XSI] ID of device containing file */ \r
+       mode_t          st_mode;                /* [XSI] Mode of file (see below) */ \r
+       nlink_t         st_nlink;               /* [XSI] Number of hard links */ \r
+       __darwin_ino64_t st_ino;                /* [XSI] File serial number */ \r
+       uid_t           st_uid;                 /* [XSI] User ID of the file */ \r
+       gid_t           st_gid;                 /* [XSI] Group ID of the file */ \r
+       dev_t           st_rdev;                /* [XSI] Device ID */ \r
+\r
+  // clang for X64 ABI follows Windows and a long is 32-bits\r
+  // this breaks system inlcude files so that is why we need\r
+  // to redefine timespec as EFI_timespec \r
+  EFI_timespec  st_atimespec;\r
+  EFI_timespec  st_mtimespec;\r
+  EFI_timespec  st_ctimespec;\r
+  EFI_timespec  st_birthtimespec;\r
+\r
+       off_t           st_size;                /* [XSI] file size, in bytes */ \r
+       blkcnt_t        st_blocks;              /* [XSI] blocks allocated for file */ \r
+       blksize_t       st_blksize;             /* [XSI] optimal blocksize for I/O */ \r
+       __uint32_t      st_flags;               /* user defined flags for file */ \r
+       __uint32_t      st_gen;                 /* file generation number */ \r
+       __int32_t       st_lspare;              /* RESERVED: DO NOT USE! */ \r
+       __int64_t       st_qspare[2];           /* RESERVED: DO NOT USE! */ \r
+} STAT_FIX;\r
+\r
+#else /* !__DARWIN_64_BIT_INO_T */\r
+\r
+typedef struct stat_fix {\r
+       dev_t           st_dev;         /* [XSI] ID of device containing file */\r
+       ino_t           st_ino;         /* [XSI] File serial number */\r
+       mode_t          st_mode;        /* [XSI] Mode of file (see below) */\r
+       nlink_t         st_nlink;       /* [XSI] Number of hard links */\r
+       uid_t           st_uid;         /* [XSI] User ID of the file */\r
+       gid_t           st_gid;         /* [XSI] Group ID of the file */\r
+       dev_t           st_rdev;        /* [XSI] Device ID */\r
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)\r
+       struct  timespec st_atimespec;  /* time of last access */\r
+       struct  timespec st_mtimespec;  /* time of last data modification */\r
+       struct  timespec st_ctimespec;  /* time of last status change */\r
+#else\r
+       time_t          st_atime;       /* [XSI] Time of last access */\r
+       long            st_atimensec;   /* nsec of last access */\r
+       time_t          st_mtime;       /* [XSI] Last data modification time */\r
+       long            st_mtimensec;   /* last data modification nsec */\r
+       time_t          st_ctime;       /* [XSI] Time of last status change */\r
+       long            st_ctimensec;   /* nsec of last status change */\r
+#endif\r
+       off_t           st_size;        /* [XSI] file size, in bytes */\r
+       blkcnt_t        st_blocks;      /* [XSI] blocks allocated for file */\r
+       blksize_t       st_blksize;     /* [XSI] optimal blocksize for I/O */\r
+       __uint32_t      st_flags;       /* user defined flags for file */\r
+       __uint32_t      st_gen;         /* file generation number */\r
+       __int32_t       st_lspare;      /* RESERVED: DO NOT USE! */\r
+       __int64_t       st_qspare[2];   /* RESERVED: DO NOT USE! */\r
+} STAT_FIX;\r
+\r
+#endif\r
+\r
+#ifdef MDE_CPU_IA32\r
+#pragma pack(4)\r
+#endif\r
+\r
+#else \r
+\r
+  typedef struct stat STAT_FIX;\r
+\r
+#endif\r
+\r
+//\r
+// Undo name mangling\r
+//\r
+#undef NTOHL\r
+#undef HTONL\r
+#undef NTOHS\r
+#undef HTONS\r
+#undef B0\r
+\r
+\r
+#endif\r
+\r
index a5383be29e20b7b943c2e8586e1e4228bb74fb37..85ac5f90862c7eb6c535d84b2cd6dc2b673d8178 100644 (file)
@@ -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 \
   { \
index 049ec86355fd21f5355af42a5c8b0fd5795910f8..0ec71cd4b0e4c320d429895311a89cd48c2e8c67 100644 (file)
@@ -30,31 +30,37 @@ ASM_GLOBAL ASM_PFX(mTransition)
 ASM_GLOBAL ASM_PFX(InternalAsmThunk16)\r
 \r
 # define the structure of IA32_REGS\r
-.set  _EDI, 0       #size 4\r
-.set  _ESI, 4       #size 4\r
-.set  _EBP, 8       #size 4\r
-.set  _ESP, 12      #size 4\r
-.set  _EBX, 16      #size 4\r
-.set  _EDX, 20      #size 4\r
-.set  _ECX, 24      #size 4\r
-.set  _EAX, 28      #size 4\r
-.set  _DS,  32      #size 2\r
-.set  _ES,  34      #size 2\r
-.set  _FS,  36      #size 2\r
-.set  _GS,  38      #size 2\r
-.set  _EFLAGS, 40   #size 8\r
-.set  _EIP, 48      #size 4\r
-.set  _CS, 52       #size 2\r
-.set  _SS, 54       #size 2\r
-.set  IA32_REGS_SIZE, 56\r
+#define  _EDI  0       // size 4\r
+#define  _ESI  4       // size 4\r
+#define  _EBP  8       // size 4\r
+#define  _ESP  12      // size 4\r
+#define  _EBX  16      // size 4\r
+#define  _EDX  20      // size 4\r
+#define  _ECX  24      // size 4\r
+#define  _EAX  28      // size 4\r
+#define  _DS   32      // size 2\r
+#define  _ES   34      // size 2\r
+#define  _FS   36      // size 2\r
+#define  _GS   38      // size 2\r
+#define  _EFLAGS  40   // size 8\r
+#define  _EIP  48      // size 4\r
+#define  _CS  52       // size 2\r
+#define  _SS  54       // size 2\r
+#define  IA32_REGS_SIZE  56\r
 \r
     .data\r
 \r
-ASM_PFX(m16Size):         .word      ASM_PFX(InternalAsmThunk16) - ASM_PFX(m16Start)\r
-ASM_PFX(mThunk16Attr):    .word      _ThunkAttr - ASM_PFX(m16Start)\r
-ASM_PFX(m16Gdt):          .word      ASM_PFX(NullSeg) - ASM_PFX(m16Start)\r
-ASM_PFX(m16GdtrBase):     .word      _16GdtrBase - ASM_PFX(m16Start)\r
-ASM_PFX(mTransition):     .word      _EntryPoint - ASM_PFX(m16Start)\r
+.set L_m16SizeSym,      ASM_PFX(InternalAsmThunk16) - ASM_PFX(m16Start)\r
+.set L_mThunk16AttrSym, _ThunkAttr - ASM_PFX(m16Start)\r
+.set L_m16GdtSym,       ASM_PFX(NullSeg) - ASM_PFX(m16Start)\r
+.set L_m16GdtrBaseSym,  _16GdtrBase - ASM_PFX(m16Start)\r
+.set L_mTransitionSym,  _EntryPoint - ASM_PFX(m16Start)\r
+\r
+ASM_PFX(m16Size):         .word      L_m16SizeSym\r
+ASM_PFX(mThunk16Attr):    .word      L_mThunk16AttrSym\r
+ASM_PFX(m16Gdt):          .word      L_m16GdtSym\r
+ASM_PFX(m16GdtrBase):     .word      L_m16GdtrBaseSym\r
+ASM_PFX(mTransition):     .word      L_mTransitionSym\r
 \r
     .text\r
 \r
@@ -118,7 +124,8 @@ L_2:
     shlw    $4,%ax\r
     lea     (L_64BitCode - L_Base)(%ebx, %eax), %ax\r
     .byte 0x66,0x2e,0x89,0x87           # mov cs:[bx + (L_64Eip - L_Base)], eax\r
-    .word   L_64Eip - L_Base\r
+.set EipOffset,  L_64Eip - L_Base\r
+    .word   EipOffset\r
     .byte 0x66,0xb8                     # mov eax, imm32\r
 SavedCr4:   .space  4\r
     movq    %rax, %cr4\r
@@ -147,7 +154,7 @@ SavedSp:    .space 4                   # restore stack
 \r
 _EntryPoint: .long      ASM_PFX(ToUserCode) - ASM_PFX(m16Start)\r
              .word      CODE16\r
-_16Gdtr:     .word      GDT_SIZE - 1\r
+_16Gdtr:     .word      L_GDT_SIZE - 1\r
 _16GdtrBase: .quad      ASM_PFX(NullSeg)\r
 _16Idtr:     .word      0x3ff\r
              .long      0\r
@@ -220,7 +227,7 @@ ASM_PFX(_32Data):
             .byte 0xcf                  # 16-bit segment, 4GB limit\r
             .byte 0\r
 \r
-.set  GDT_SIZE, . - ASM_PFX(NullSeg)\r
+.set  L_GDT_SIZE, . - ASM_PFX(NullSeg)\r
 \r
 #------------------------------------------------------------------------------\r
 # IA32_REGISTER_SET *\r
@@ -301,7 +308,8 @@ ASM_PFX(InternalAsmThunk16):
     movw    %r8w, (SavedCs - SavedCr4)(%rcx)\r
     movl    %esp, (SavedSp - SavedCr4)(%rcx)\r
     .byte   0xff, 0x69                  #  jmp (_EntryPoint - SavedCr4)(%rcx)\r
-    .byte   _EntryPoint - SavedCr4\r
+.set EntryPointSavedCr4Offset, _EntryPoint - SavedCr4\r
+    .byte   EntryPointSavedCr4Offset\r
 L_RetFromRealMode: \r
     popfq\r
     lgdt    0x60(%rsp)                  # restore protected mode GDTR\r
index c1a2b2d7a54c533f9791b46cee726aebc0e5b7bf..0a9b0a314cd004701cb10fd946ffe346e0d06652 100644 (file)
@@ -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>
index 0f3ac51f55b8c56bee049f7748745c3cbfeda6b7..b197ae624a86d8262913b7eac854e937609a0797 100644 (file)
@@ -108,7 +108,8 @@ ConvertBaud2Unix (
 {\r
   switch (BaudRate) {\r
   case 0:\r
-    return B0;\r
+    return 0; // Don't use B0 as it is also used in EFI #includes as a name so termios.h #define \r
+              // can break the build.\r
   case 50:\r
     return B50;\r
   case 75:\r
index f58014eaa8defc6a6373039feb2212c44e0e292f..484a07c482c9f59414182b6236111b72d9caaf6e 100644 (file)
@@ -21,20 +21,10 @@ Abstract:
 \r
 #ifndef _UNIXPKG_SERIAL_IO_\r
 #define _UNIXPKG_SERIAL_IO_\r
-#include <sys/types.h>\r
-#include <sys/stat.h>\r
-#include <stdio.h>\r
-\r
-#ifdef __APPLE__\r
-#else\r
-#include <stdlib.h>\r
-#include <termio.h>\r
-#endif\r
 \r
-#include <fcntl.h>\r
-#include <errno.h>\r
+#include <Common/UnixInclude.h>\r
 \r
-#include "Uefi.h"\r
+#include <Uefi.h>\r
 #include <Protocol/SerialIo.h>\r
 #include <Protocol/DevicePath.h>\r
 \r