> Date: Mon, 26 Jul 2021 18:45:31 +1000
> From: Jonathan Gray <j...@jsg.id.au>
> 
> Follow what was done with riscv64 and replace efibind.h with just the
> defines we need.
> 
> Tested on armv7 arm64 and amd64 (bootx64).

ok kettenis@
 
> Index: sys/stand/efi/include/amd64/efibind.h
> ===================================================================
> RCS file: /cvs/src/sys/stand/efi/include/amd64/efibind.h,v
> retrieving revision 1.2
> diff -u -p -r1.2 efibind.h
> --- sys/stand/efi/include/amd64/efibind.h     4 Jun 2021 00:09:34 -0000       
> 1.2
> +++ sys/stand/efi/include/amd64/efibind.h     26 Jul 2021 05:39:34 -0000
> @@ -1,271 +1,22 @@
> -/* $FreeBSD: head/sys/boot/efi/include/amd64/efibind.h 279038 2015-02-20 
> 01:40:55Z imp $ */
> -/*++
> +/* Public Domain. */
>  
> -Copyright (c)  1999 - 2003 Intel Corporation. All rights reserved
> -This software and associated documentation (if any) is furnished
> -under a license and may only be used or copied in accordance
> -with the terms of the license. Except as permitted by such
> -license, no part of this software or documentation may be
> -reproduced, stored in a retrieval system, or transmitted in any
> -form or by any means without the express written consent of
> -Intel Corporation.
> -
> -Module Name:
> -
> -    efefind.h
> -
> -Abstract:
> -
> -    EFI to compile bindings
> -
> -
> -
> -
> -Revision History
> -
> ---*/
> -
> -#pragma pack()
> -
> -
> -#if defined(__FreeBSD__) || defined(__OpenBSD__)
>  #include <sys/stdint.h>
> -#else
> -//
> -// Basic int types of various widths
> -//
> -
> -#if (__STDC_VERSION__ < 199901L )
> -
> -    // No ANSI C 1999/2000 stdint.h integer width declarations
> -
> -    #if _MSC_EXTENSIONS
> -
> -        // Use Microsoft C compiler integer width declarations
> -
> -        typedef unsigned __int64    uint64_t;
> -        typedef __int64             int64_t;
> -        typedef unsigned __int32    uint32_t;
> -        typedef __int32             int32_t;
> -        typedef unsigned short      uint16_t;
> -        typedef short               int16_t;
> -        typedef unsigned char       uint8_t;
> -        typedef char                int8_t;
> -    #else
> -        #ifdef UNIX_LP64
> -
> -            // Use LP64 programming model from C_FLAGS for integer width 
> declarations
> -
> -            typedef unsigned long       uint64_t;
> -            typedef long                int64_t;
> -            typedef unsigned int        uint32_t;
> -            typedef int                 int32_t;
> -            typedef unsigned short      uint16_t;
> -            typedef short               int16_t;
> -            typedef unsigned char       uint8_t;
> -            typedef char                int8_t;
> -        #else
> -
> -            // Assume P64 programming model from C_FLAGS for integer width 
> declarations
> -
> -            typedef unsigned long long  uint64_t;
> -            typedef long long           int64_t;
> -            typedef unsigned int        uint32_t;
> -            typedef int                 int32_t;
> -            typedef unsigned short      uint16_t;
> -            typedef short               int16_t;
> -            typedef unsigned char       uint8_t;
> -            typedef char                int8_t;
> -        #endif
> -    #endif
> -#endif
> -#endif       /* __FreeBSD__ || __OpenBSD__ */
> -
> -//
> -// Basic EFI types of various widths
> -//
> -
> -#ifndef ACPI_THREAD_ID               /* ACPI's definitions are fine */
> -#define ACPI_USE_SYSTEM_INTTYPES 1   /* Tell ACPI we've defined types */
> -
> -typedef uint64_t   UINT64;
> -typedef int64_t    INT64;
> -
> -#ifndef _BASETSD_H_
> -    typedef uint32_t   UINT32;
> -    typedef int32_t    INT32;
> -#endif
> -
> -typedef uint16_t   UINT16;
> -typedef int16_t    INT16;
> -typedef uint8_t    UINT8;
> -typedef int8_t     INT8;
> -
> -#endif
> -
> -#undef VOID
> -#define VOID    void
> -
> -
> -typedef int64_t    INTN;
> -typedef uint64_t   UINTN;
> -
> -#ifdef EFI_NT_EMULATOR
> -    #define POST_CODE(_Data)
> -#else
> -    #ifdef EFI_DEBUG
> -#define POST_CODE(_Data)    __asm mov eax,(_Data) __asm out 0x80,al
> -    #else
> -        #define POST_CODE(_Data)
> -    #endif
> -#endif
> -
> -#define EFIERR(a)           (0x8000000000000000 | a)
> -#define EFI_ERROR_MASK      0x8000000000000000
> -#define EFIERR_OEM(a)       (0xc000000000000000 | a)
> -
> -
> -#define BAD_POINTER         0xFBFBFBFBFBFBFBFB
> -#define MAX_ADDRESS         0xFFFFFFFFFFFFFFFF
> -
> -#define BREAKPOINT()        __asm { int 3 }
> -
> -//
> -// Pointers must be aligned to these address to function
> -//
> -
> -#define MIN_ALIGNMENT_SIZE  4
> -
> -#define ALIGN_VARIABLE(Value ,Adjustment) \
> -            (UINTN)Adjustment = 0; \
> -            if((UINTN)Value % MIN_ALIGNMENT_SIZE) \
> -                (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % 
> MIN_ALIGNMENT_SIZE); \
> -            Value = (UINTN)Value + (UINTN)Adjustment
> -
> -
> -//
> -// Define macros to build data structure signatures from characters.
> -//
> -
> -#define EFI_SIGNATURE_16(A,B)             ((A) | (B<<8))
> -#define EFI_SIGNATURE_32(A,B,C,D)         (EFI_SIGNATURE_16(A,B)     | 
> (EFI_SIGNATURE_16(C,D)     << 16))
> -#define EFI_SIGNATURE_64(A,B,C,D,E,F,G,H) (EFI_SIGNATURE_32(A,B,C,D) | 
> ((UINT64)(EFI_SIGNATURE_32(E,F,G,H)) << 32))
> -
> -//
> -// EFIAPI - prototype calling convention for EFI function pointers
> -// BOOTSERVICE - prototype for implementation of a boot service interface
> -// RUNTIMESERVICE - prototype for implementation of a runtime service 
> interface
> -// RUNTIMEFUNCTION - prototype for implementation of a runtime function that 
> is not a service
> -// RUNTIME_CODE - pragma macro for declaring runtime code
> -//
> -
> -#ifdef       __amd64__
> -#define      EFIAPI  __attribute((ms_abi))
> -#endif
> -
> -#ifndef EFIAPI                  // Forces EFI calling conventions 
> reguardless of compiler options
> -    #if _MSC_EXTENSIONS
> -        #define EFIAPI __cdecl  // Force C calling convention for Microsoft 
> C compiler
> -    #else
> -        #define EFIAPI          // Substitute expression to force C calling 
> convention
> -    #endif
> -#endif
> -
> -#define BOOTSERVICE
> -//#define RUNTIMESERVICE(proto,a)    alloc_text("rtcode",a); proto a
> -//#define RUNTIMEFUNCTION(proto,a)   alloc_text("rtcode",a); proto a
> -#define RUNTIMESERVICE
> -#define RUNTIMEFUNCTION
> -
> -
> -#define RUNTIME_CODE(a)         alloc_text("rtcode", a)
> -#define BEGIN_RUNTIME_DATA()    data_seg("rtdata")
> -#define END_RUNTIME_DATA()      data_seg("")
> -
> -#define VOLATILE    volatile
> -
> -#define MEMORY_FENCE()
> -
> -#ifdef EFI_NO_INTERFACE_DECL
> -  #define EFI_FORWARD_DECLARATION(x)
> -  #define EFI_INTERFACE_DECL(x)
> -#else
> -  #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x
> -  #define EFI_INTERFACE_DECL(x) typedef struct x
> -#endif
> -
> -#ifdef EFI_NT_EMULATOR
> -
> -//
> -// To help ensure proper coding of integrated drivers, they are
> -// compiled as DLLs.  In NT they require a dll init entry pointer.
> -// The macro puts a stub entry point into the DLL so it will load.
> -//
> -
> -#define EFI_DRIVER_ENTRY_POINT(InitFunction)            \
> -    EFI_STATUS                                          \
> -    InitFunction (                                      \
> -      EFI_HANDLE  ImageHandle,                          \
> -      EFI_SYSTEM_TABLE  *SystemTable                    \
> -      );                                                \
> -                                                        \
> -    UINTN                                               \
> -    __stdcall                                           \
> -    _DllMainCRTStartup (                                \
> -        UINTN    Inst,                                  \
> -        UINTN    reason_for_call,                       \
> -        VOID    *rserved                                \
> -        )                                               \
> -    {                                                   \
> -        return 1;                                       \
> -    }                                                   \
> -                                                        \
> -    int                                                 \
> -    __declspec( dllexport )                             \
> -    __cdecl                                             \
> -    InitializeDriver (                                  \
> -        void *ImageHandle,                              \
> -        void *SystemTable                               \
> -        )                                               \
> -    {                                                   \
> -        return InitFunction(ImageHandle, SystemTable);  \
> -    }
> -
> -
> -    #define LOAD_INTERNAL_DRIVER(_if, type, name, entry)      \
> -        (_if)->LoadInternal(type, name, NULL)
> -
> -#else // EFI_NT_EMULATOR
> -
> -//
> -// When build similiar to FW, then link everything together as
> -// one big module.
> -//
> -
> -    #define EFI_DRIVER_ENTRY_POINT(InitFunction)
> -
> -    #define LOAD_INTERNAL_DRIVER(_if, type, name, entry)    \
> -            (_if)->LoadInternal(type, name, entry)
>  
> -#endif // EFI_FW_NT
> +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 void         VOID;
>  
> -#if defined(__FreeBSD__) || defined(__OpenBSD__)
> -#define INTERFACE_DECL(x) struct x
> -#else
> -//
> -// Some compilers don't support the forward reference construct:
> -//  typedef struct XXXXX
> -//
> -// The following macro provide a workaround for such cases.
> -//
> -#ifdef NO_INTERFACE_DECL
> -#define INTERFACE_DECL(x)
> -#else
> -#define INTERFACE_DECL(x) typedef struct x
> -#endif
> -#endif       /* __FreeBSD__ || __OpenBSD__ */
> +typedef int64_t              INTN;
> +typedef uint64_t     UINTN;
>  
> -#if _MSC_EXTENSIONS
> -#pragma warning ( disable : 4731 )  // Suppress warnings about modification 
> of EBP
> -#endif
> +#define INTERFACE_DECL(x)    struct x
> +#define EFIAPI                       __attribute((ms_abi))
>  
> +#define EFIERR(x)    (0x8000000000000000 | x)
> Index: sys/stand/efi/include/arm/efibind.h
> ===================================================================
> RCS file: /cvs/src/sys/stand/efi/include/arm/efibind.h,v
> retrieving revision 1.1
> diff -u -p -r1.1 efibind.h
> --- sys/stand/efi/include/arm/efibind.h       11 May 2016 09:07:32 -0000      
> 1.1
> +++ sys/stand/efi/include/arm/efibind.h       26 Jul 2021 05:53:40 -0000
> @@ -1,165 +1,22 @@
> -/* $FreeBSD: head/sys/boot/efi/include/arm/efibind.h 298826 2016-04-30 
> 00:26:38Z pfg $ */
> -/*++
> +/* Public Domain. */
>  
> -Copyright (c) 2004 - 2012, Intel Corporation. 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:
> -
> -  EfiBind.h
> -
> -Abstract:
> -
> -  Processor or Compiler specific defines and types for IA-32.
> -  We are using the ANSI C 2000 _t type definitions for basic types.
> -  This it technically a violation of the coding standard, but they
> -  are used to make EfiTypes.h portable. Code other than EfiTypes.h
> -  should never use any ANSI C 2000 _t integer types.
> -
> ---*/
> -
> -#ifndef _EFI_BIND_H_
> -#define _EFI_BIND_H_
> -
> -
> -#define EFI_DRIVER_ENTRY_POINT(InitFunction)
> -#define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT
> -
> -
> -//
> -// Make sure we are using the correct packing rules per EFI specification
> -//
> -#ifndef __GNUC__
> -#pragma pack()
> -#endif
> -
> -
> -#if defined(__FreeBSD__) || defined(__OpenBSD__)
>  #include <sys/stdint.h>
> -#else
> -//
> -// Assume standard IA-32 alignment.
> -// BugBug: Need to check portability of long long
> -//
> -typedef unsigned long long  uint64_t;
> -typedef long long           int64_t;
> -typedef unsigned int        uint32_t;
> -typedef int                 int32_t;
> -typedef unsigned short      uint16_t;
> -typedef short               int16_t;
> -typedef unsigned char       uint8_t;
> -typedef signed char         int8_t;
> -#endif
> -
> -typedef uint64_t   UINT64;
> -typedef int64_t    INT64;
> -typedef uint32_t   UINT32;
> -typedef int32_t    INT32;
> -typedef uint16_t   UINT16;
> -typedef int16_t    INT16;
> -typedef uint8_t    UINT8;
> -typedef int8_t     INT8;
> -
> -#undef VOID
> -#define VOID    void
> -
> -//
> -// Native integer size in stdint.h
> -//
> -typedef uint32_t  UINTN;
> -typedef int32_t   INTN;
> -
> -#define EFIERR(a)           (0x80000000 | a)
> -#define EFI_ERROR_MASK      0x80000000
> -#define EFIERR_OEM(a)       (0xc0000000 | a)
> -
> -//
> -// Processor specific defines
> -//
> -#define EFI_MAX_BIT       0x80000000
> -#define MAX_2_BITS        0xC0000000
> -
> -//
> -// Maximum legal IA-32 address
> -//
> -#define EFI_MAX_ADDRESS   0xFFFFFFFF
> -
> -//
> -//  Bad pointer value to use in check builds.
> -//  if you see this value you are using uninitialized or free'ed data
> -//
> -#define EFI_BAD_POINTER          0xAFAFAFAF
> -#define EFI_BAD_POINTER_AS_BYTE  0xAF
> -
> -#define EFI_DEADLOOP()    { volatile UINTN __iii; __iii = 1; while (__iii); }
> -
> -//
> -// Inject a break point in the code to assist debugging for NT Emulation 
> Environment
> -// For real hardware, just put in a halt loop. Don't do a while(1) because 
> the
> -// compiler will optimize away the rest of the function following, so that 
> you run out in
> -// the weeds if you skip over it with a debugger.
> -//
> -#define EFI_BREAKPOINT EFI_DEADLOOP()
> -
> -
> -//
> -// Memory Fence forces serialization, and is needed to support out of order
> -//  memory transactions. The Memory Fence is mainly used to make sure IO
> -//  transactions complete in a deterministic sequence, and to syncronize 
> locks
> -//  an other MP code. Currently no memory fencing is required.
> -//
> -#define MEMORY_FENCE()
> -
> -//
> -// Some compilers don't support the forward reference construct:
> -//  typedef struct XXXXX. The forward reference is required for
> -//  ANSI compatibility.
> -//
> -// The following macro provide a workaround for such cases.
> -//
> -
> -
> -#ifdef EFI_NO_INTERFACE_DECL
> -  #define EFI_FORWARD_DECLARATION(x)
> -#else
> -  #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x
> -#endif
> -
> -
> -//
> -// Some C compilers optimize the calling conventions to increase performance.
> -// EFIAPI is used to make all public APIs follow the standard C calling
> -// convention.
> -//
> -#define EFIAPI
>  
> +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 void         VOID;
>  
> -//
> -// For symbol name in GNU assembly code, an extra "_" is necessary
> -//
> -#if defined(__GNUC__)
> -  ///
> -  /// Private worker functions for ASM_PFX()
> -  ///
> -  #define _CONCATENATE(a, b)  __CONCATENATE(a, b)
> -  #define __CONCATENATE(a, b) a ## b
> -
> -  ///
> -  /// The __USER_LABEL_PREFIX__ macro predefined by GNUC represents the 
> prefix
> -  /// on symbols in assembly language.
> -  ///
> -  #define ASM_PFX(name) _CONCATENATE (__USER_LABEL_PREFIX__, name)
> +typedef int32_t              INTN;
> +typedef uint32_t     UINTN;
>  
> -#endif
> -
> -#define INTERFACE_DECL(x) struct x
> +#define INTERFACE_DECL(x)    struct x
> +#define EFIAPI
>  
> -#endif
> +#define EFIERR(x)    (0x80000000 | x)
> Index: sys/stand/efi/include/arm64/efibind.h
> ===================================================================
> RCS file: /cvs/src/sys/stand/efi/include/arm64/efibind.h,v
> retrieving revision 1.1
> diff -u -p -r1.1 efibind.h
> --- sys/stand/efi/include/arm64/efibind.h     13 Dec 2016 18:23:16 -0000      
> 1.1
> +++ sys/stand/efi/include/arm64/efibind.h     26 Jul 2021 05:52:16 -0000
> @@ -1,165 +1,22 @@
> -/* $OpenBSD: efibind.h,v 1.1 2016/12/13 18:23:16 patrick Exp $ */
> -/** @file
> +/* Public Domain. */
>  
> -  Copyright (c) 2013, ARM Ltd. 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:
> -
> -  EfiBind.h
> -
> -Abstract:
> -
> -  Processor or Compiler specific defines and types for AArch64.
> -  We are using the ANSI C 2000 _t type definitions for basic types.
> -  This it technically a violation of the coding standard, but they
> -  are used to make EfiTypes.h portable. Code other than EfiTypes.h
> -  should never use any ANSI C 2000 _t integer types.
> -
> -**/
> -
> -
> -#ifndef _EFI_BIND_H_
> -#define _EFI_BIND_H_
> -
> -
> -#define EFI_DRIVER_ENTRY_POINT(InitFunction)
> -#define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT
> -
> -
> -//
> -// Make sure we are using the correct packing rules per EFI specification.
> -//
> -#ifndef __GNUC__
> -#pragma pack()
> -#endif
> -
> -
> -#if defined(__FreeBSD__) || defined(__OpenBSD__)
>  #include <sys/stdint.h>
> -#else
> -//
> -// Assume standard AArch64 alignment.
> -// BugBug: Need to check portability of long long
> -//
> -typedef unsigned long long  uint64_t;
> -typedef long long           int64_t;
> -typedef unsigned int        uint32_t;
> -typedef int                 int32_t;
> -typedef unsigned short      uint16_t;
> -typedef short               int16_t;
> -typedef unsigned char       uint8_t;
> -typedef signed char         int8_t;
> -#endif /* __FreeBSD__ */
> -
> -typedef uint64_t   UINT64;
> -typedef int64_t    INT64;
> -typedef uint32_t   UINT32;
> -typedef int32_t    INT32;
> -typedef uint16_t   UINT16;
> -typedef int16_t    INT16;
> -typedef uint8_t    UINT8;
> -typedef int8_t     INT8;
> -
> -#undef VOID
> -#define VOID    void
> -
> -//
> -// Native integer size in stdint.h
> -//
> -typedef uint64_t  UINTN;
> -typedef int64_t   INTN;
> -
> -#define EFIERR(a)           (0x8000000000000000 | a)
> -#define EFI_ERROR_MASK      0x8000000000000000
> -#define EFIERR_OEM(a)       (0xc000000000000000 | a)
> -
> -//
> -// Processor specific defines
> -//
> -#define EFI_MAX_BIT       0x8000000000000000
> -#define MAX_2_BITS        0xC000000000000000
> -
> -//
> -// Maximum legal AArch64 address
> -//
> -#define EFI_MAX_ADDRESS   0xFFFFFFFFFFFFFFFF
> -
> -//
> -//  Bad pointer value to use in check builds.
> -//  if you see this value you are using uninitialized or free'ed data
> -//
> -#define EFI_BAD_POINTER          0xAFAFAFAFAFAFAFAF
> -#define EFI_BAD_POINTER_AS_BYTE  0xAF
> -
> -#define EFI_DEADLOOP()    { volatile UINTN __iii; __iii = 1; while (__iii); }
> -
> -//
> -// For real hardware, just put in a halt loop. Don't do a while(1) because 
> the
> -// compiler will optimize away the rest of the function following, so that 
> you run out in
> -// the weeds if you skip over it with a debugger.
> -//
> -#define EFI_BREAKPOINT EFI_DEADLOOP()
> -
> -
> -//
> -// Memory Fence forces serialization, and is needed to support out of order
> -//  memory transactions. The Memory Fence is mainly used to make sure IO
> -//  transactions complete in a deterministic sequence, and to syncronize 
> locks
> -//  an other MP code. Currently no memory fencing is required.
> -//
> -#define MEMORY_FENCE()
> -
> -//
> -// Some compilers don't support the forward reference construct:
> -//  typedef struct XXXXX. The forward reference is required for
> -//  ANSI compatibility.
> -//
> -// The following macro provide a workaround for such cases.
> -//
> -
> -
> -#ifdef EFI_NO_INTERFACE_DECL
> -  #define EFI_FORWARD_DECLARATION(x)
> -#else
> -  #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x
> -#endif
> -
> -
> -//
> -// Some C compilers optimize the calling conventions to increase performance.
> -// EFIAPI is used to make all public APIs follow the standard C calling
> -// convention.
> -//
> -#define EFIAPI
>  
> +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 void         VOID;
>  
> -//
> -// For symbol name in GNU assembly code, an extra "_" is necessary
> -//
> -#if defined(__GNUC__)
> -  ///
> -  /// Private worker functions for ASM_PFX()
> -  ///
> -  #define _CONCATENATE(a, b)  __CONCATENATE(a, b)
> -  #define __CONCATENATE(a, b) a ## b
> -
> -  ///
> -  /// The __USER_LABEL_PREFIX__ macro predefined by GNUC represents the 
> prefix
> -  /// on symbols in assembly language.
> -  ///
> -  #define ASM_PFX(name) _CONCATENATE (__USER_LABEL_PREFIX__, name)
> +typedef int64_t              INTN;
> +typedef uint64_t     UINTN;
>  
> -#endif
> -
> -#define INTERFACE_DECL(x) struct x
> +#define INTERFACE_DECL(x)    struct x
> +#define EFIAPI
>  
> -#endif
> +#define EFIERR(x)    (0x8000000000000000 | x)
> Index: sys/stand/efi/include/i386/efibind.h
> ===================================================================
> RCS file: /cvs/src/sys/stand/efi/include/i386/efibind.h,v
> retrieving revision 1.1
> diff -u -p -r1.1 efibind.h
> --- sys/stand/efi/include/i386/efibind.h      11 May 2016 08:30:58 -0000      
> 1.1
> +++ sys/stand/efi/include/i386/efibind.h      26 Jul 2021 05:48:38 -0000
> @@ -1,267 +1,22 @@
> -/* $FreeBSD: head/sys/boot/efi/include/i386/efibind.h 279038 2015-02-20 
> 01:40:55Z imp $ */
> -/*++
> +/* Public Domain. */
>  
> -Copyright (c)  1999 - 2003 Intel Corporation. All rights reserved
> -This software and associated documentation (if any) is furnished
> -under a license and may only be used or copied in accordance
> -with the terms of the license. Except as permitted by such
> -license, no part of this software or documentation may be
> -reproduced, stored in a retrieval system, or transmitted in any
> -form or by any means without the express written consent of
> -Intel Corporation.
> -
> -Module Name:
> -
> -    efefind.h
> -
> -Abstract:
> -
> -    EFI to compile bindings
> -
> -
> -
> -
> -Revision History
> -
> ---*/
> -
> -#pragma pack()
> -
> -
> -#if defined(__FreeBSD__) || defined(__OpenBSD__)
>  #include <sys/stdint.h>
> -#else
> -//
> -// Basic int types of various widths
> -//
> -
> -#if (__STDC_VERSION__ < 199901L )
> -
> -    // No ANSI C 1999/2000 stdint.h integer width declarations
> -
> -    #if _MSC_EXTENSIONS
> -
> -        // Use Microsoft C compiler integer width declarations
> -
> -        typedef unsigned __int64    uint64_t;
> -        typedef __int64             int64_t;
> -        typedef unsigned __int32    uint32_t;
> -        typedef __int32             int32_t;
> -        typedef unsigned short      uint16_t;
> -        typedef short               int16_t;
> -        typedef unsigned char       uint8_t;
> -        typedef char                int8_t;
> -    #else
> -        #ifdef UNIX_LP64
> -
> -            // Use LP64 programming model from C_FLAGS for integer width 
> declarations
> -
> -            typedef unsigned long       uint64_t;
> -            typedef long                int64_t;
> -            typedef unsigned int        uint32_t;
> -            typedef int                 int32_t;
> -            typedef unsigned short      uint16_t;
> -            typedef short               int16_t;
> -            typedef unsigned char       uint8_t;
> -            typedef char                int8_t;
> -        #else
> -
> -            // Assume P64 programming model from C_FLAGS for integer width 
> declarations
> -
> -            typedef unsigned long long  uint64_t;
> -            typedef long long           int64_t;
> -            typedef unsigned int        uint32_t;
> -            typedef int                 int32_t;
> -            typedef unsigned short      uint16_t;
> -            typedef short               int16_t;
> -            typedef unsigned char       uint8_t;
> -            typedef char                int8_t;
> -        #endif
> -    #endif
> -#endif
> -#endif       /* __FreeBSD__ || __OpenBSD__ */
> -
> -//
> -// Basic EFI types of various widths
> -//
> -
> -#ifndef ACPI_THREAD_ID               /* ACPI's definitions are fine, use 
> those */
> -#define ACPI_USE_SYSTEM_INTTYPES 1   /* Tell ACPI we've defined types */
> -
> -typedef uint64_t   UINT64 __attribute__((__aligned__(8)));
> -typedef int64_t    INT64 __attribute__((__aligned__(8)));
> -
> -#ifndef _BASETSD_H_
> -    typedef uint32_t   UINT32;
> -    typedef int32_t    INT32;
> -#endif
> -
> -typedef uint16_t   UINT16;
> -typedef int16_t    INT16;
> -typedef uint8_t    UINT8;
> -typedef int8_t     INT8;
> -
> -#endif
> -
> -#undef VOID
> -#define VOID    void
> -
> -
> -typedef int32_t    INTN;
> -typedef uint32_t   UINTN;
> -
> -#ifdef EFI_NT_EMULATOR
> -    #define POST_CODE(_Data)
> -#else
> -    #ifdef EFI_DEBUG
> -#define POST_CODE(_Data)    __asm mov eax,(_Data) __asm out 0x80,al
> -    #else
> -        #define POST_CODE(_Data)
> -    #endif
> -#endif
> -
> -#define EFIERR(a)           (0x80000000 | a)
> -#define EFI_ERROR_MASK      0x80000000
> -#define EFIERR_OEM(a)       (0xc0000000 | a)
> -
> -
> -#define BAD_POINTER         0xFBFBFBFB
> -#define MAX_ADDRESS         0xFFFFFFFF
> -
> -#define BREAKPOINT()        __asm { int 3 }
> -
> -//
> -// Pointers must be aligned to these address to function
> -//
> -
> -#define MIN_ALIGNMENT_SIZE  4
> -
> -#define ALIGN_VARIABLE(Value ,Adjustment) \
> -            (UINTN)Adjustment = 0; \
> -            if((UINTN)Value % MIN_ALIGNMENT_SIZE) \
> -                (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % 
> MIN_ALIGNMENT_SIZE); \
> -            Value = (UINTN)Value + (UINTN)Adjustment
> -
> -
> -//
> -// Define macros to build data structure signatures from characters.
> -//
> -
> -#define EFI_SIGNATURE_16(A,B)             ((A) | (B<<8))
> -#define EFI_SIGNATURE_32(A,B,C,D)         (EFI_SIGNATURE_16(A,B)     | 
> (EFI_SIGNATURE_16(C,D)     << 16))
> -#define EFI_SIGNATURE_64(A,B,C,D,E,F,G,H) (EFI_SIGNATURE_32(A,B,C,D) | 
> ((UINT64)(EFI_SIGNATURE_32(E,F,G,H)) << 32))
> -
> -//
> -// EFIAPI - prototype calling convention for EFI function pointers
> -// BOOTSERVICE - prototype for implementation of a boot service interface
> -// RUNTIMESERVICE - prototype for implementation of a runtime service 
> interface
> -// RUNTIMEFUNCTION - prototype for implementation of a runtime function that 
> is not a service
> -// RUNTIME_CODE - pragma macro for declaring runtime code
> -//
> -
> -#ifndef EFIAPI                  // Forces EFI calling conventions 
> reguardless of compiler options
> -    #if _MSC_EXTENSIONS
> -        #define EFIAPI __cdecl  // Force C calling convention for Microsoft 
> C compiler
> -    #else
> -        #define EFIAPI          // Substitute expression to force C calling 
> convention
> -    #endif
> -#endif
> -
> -#define BOOTSERVICE
> -//#define RUNTIMESERVICE(proto,a)    alloc_text("rtcode",a); proto a
> -//#define RUNTIMEFUNCTION(proto,a)   alloc_text("rtcode",a); proto a
> -#define RUNTIMESERVICE
> -#define RUNTIMEFUNCTION
> -
> -
> -#define RUNTIME_CODE(a)         alloc_text("rtcode", a)
> -#define BEGIN_RUNTIME_DATA()    data_seg("rtdata")
> -#define END_RUNTIME_DATA()      data_seg()
> -
> -#define VOLATILE    volatile
> -
> -#define MEMORY_FENCE()
> -
> -#ifdef EFI_NO_INTERFACE_DECL
> -  #define EFI_FORWARD_DECLARATION(x)
> -  #define EFI_INTERFACE_DECL(x)
> -#else
> -  #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x
> -  #define EFI_INTERFACE_DECL(x) typedef struct x
> -#endif
> -
> -#ifdef EFI_NT_EMULATOR
> -
> -//
> -// To help ensure proper coding of integrated drivers, they are
> -// compiled as DLLs.  In NT they require a dll init entry pointer.
> -// The macro puts a stub entry point into the DLL so it will load.
> -//
> -
> -#define EFI_DRIVER_ENTRY_POINT(InitFunction)            \
> -    EFI_STATUS                                          \
> -    InitFunction (                                      \
> -      EFI_HANDLE  ImageHandle,                          \
> -      EFI_SYSTEM_TABLE  *SystemTable                    \
> -      );                                                \
> -                                                        \
> -    UINTN                                               \
> -    __stdcall                                           \
> -    _DllMainCRTStartup (                                \
> -        UINTN    Inst,                                  \
> -        UINTN    reason_for_call,                       \
> -        VOID    *rserved                                \
> -        )                                               \
> -    {                                                   \
> -        return 1;                                       \
> -    }                                                   \
> -                                                        \
> -    int                                                 \
> -    __declspec( dllexport )                             \
> -    __cdecl                                             \
> -    InitializeDriver (                                  \
> -        void *ImageHandle,                              \
> -        void *SystemTable                               \
> -        )                                               \
> -    {                                                   \
> -        return InitFunction(ImageHandle, SystemTable);  \
> -    }
> -
> -
> -    #define LOAD_INTERNAL_DRIVER(_if, type, name, entry)      \
> -        (_if)->LoadInternal(type, name, NULL)
> -
> -#else // EFI_NT_EMULATOR
> -
> -//
> -// When build similiar to FW, then link everything together as
> -// one big module.
> -//
> -
> -    #define EFI_DRIVER_ENTRY_POINT(InitFunction)
> -
> -    #define LOAD_INTERNAL_DRIVER(_if, type, name, entry)    \
> -            (_if)->LoadInternal(type, name, entry)
>  
> -#endif // EFI_FW_NT
> +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 __attribute__((__aligned__(8)));
> +typedef uint64_t     UINT64 __attribute__((__aligned__(8)));
> +
> +typedef void         VOID;
>  
> -#if defined(__FreeBSD__) || defined(__OpenBSD__)
> -#define INTERFACE_DECL(x) struct x
> -#else
> -//
> -// Some compilers don't support the forward reference construct:
> -//  typedef struct XXXXX
> -//
> -// The following macro provide a workaround for such cases.
> -//
> -#ifdef NO_INTERFACE_DECL
> -#define INTERFACE_DECL(x)
> -#else
> -#define INTERFACE_DECL(x) typedef struct x
> -#endif
> -#endif       /* __FreeBSD__ || __OpenBSD__ */
> +typedef int32_t              INTN;
> +typedef uint32_t     UINTN;
>  
> -#if _MSC_EXTENSIONS
> -#pragma warning ( disable : 4731 )  // Suppress warnings about modification 
> of EBP
> -#endif
> +#define INTERFACE_DECL(x)    struct x
> +#define EFIAPI
>  
> +#define EFIERR(x)    (0x80000000 | x)
> 
> 

Reply via email to