1 /* $OpenBSD: efibind.h,v 1.1 2016/12/13 18:23:16 patrick Exp $ */ 2 /** @file 3 4 Copyright (c) 2013, ARM Ltd. All rights reserved. 5 6 This program and the accompanying materials 7 are licensed and made available under the terms and conditions of the BSD License 8 which accompanies this distribution. The full text of the license may be found at 9 http://opensource.org/licenses/bsd-license.php 10 11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 13 14 Module Name: 15 16 EfiBind.h 17 18 Abstract: 19 20 Processor or Compiler specific defines and types for AArch64. 21 We are using the ANSI C 2000 _t type definitions for basic types. 22 This it technically a violation of the coding standard, but they 23 are used to make EfiTypes.h portable. Code other than EfiTypes.h 24 should never use any ANSI C 2000 _t integer types. 25 26 **/ 27 28 29 #ifndef _EFI_BIND_H_ 30 #define _EFI_BIND_H_ 31 32 33 #define EFI_DRIVER_ENTRY_POINT(InitFunction) 34 #define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT 35 36 37 // 38 // Make sure we are using the correct packing rules per EFI specification. 39 // 40 #ifndef __GNUC__ 41 #pragma pack() 42 #endif 43 44 45 #if defined(__FreeBSD__) || defined(__OpenBSD__) 46 #include <sys/stdint.h> 47 #else 48 // 49 // Assume standard AArch64 alignment. 50 // BugBug: Need to check portability of long long 51 // 52 typedef unsigned long long uint64_t; 53 typedef long long int64_t; 54 typedef unsigned int uint32_t; 55 typedef int int32_t; 56 typedef unsigned short uint16_t; 57 typedef short int16_t; 58 typedef unsigned char uint8_t; 59 typedef signed char int8_t; 60 #endif /* __FreeBSD__ */ 61 62 typedef uint64_t UINT64; 63 typedef int64_t INT64; 64 typedef uint32_t UINT32; 65 typedef int32_t INT32; 66 typedef uint16_t UINT16; 67 typedef int16_t INT16; 68 typedef uint8_t UINT8; 69 typedef int8_t INT8; 70 71 #undef VOID 72 #define VOID void 73 74 // 75 // Native integer size in stdint.h 76 // 77 typedef uint64_t UINTN; 78 typedef int64_t INTN; 79 80 #define EFIERR(a) (0x8000000000000000 | a) 81 #define EFI_ERROR_MASK 0x8000000000000000 82 #define EFIERR_OEM(a) (0xc000000000000000 | a) 83 84 // 85 // Processor specific defines 86 // 87 #define EFI_MAX_BIT 0x8000000000000000 88 #define MAX_2_BITS 0xC000000000000000 89 90 // 91 // Maximum legal AArch64 address 92 // 93 #define EFI_MAX_ADDRESS 0xFFFFFFFFFFFFFFFF 94 95 // 96 // Bad pointer value to use in check builds. 97 // if you see this value you are using uninitialized or free'ed data 98 // 99 #define EFI_BAD_POINTER 0xAFAFAFAFAFAFAFAF 100 #define EFI_BAD_POINTER_AS_BYTE 0xAF 101 102 #define EFI_DEADLOOP() { volatile UINTN __iii; __iii = 1; while (__iii); } 103 104 // 105 // For real hardware, just put in a halt loop. Don't do a while(1) because the 106 // compiler will optimize away the rest of the function following, so that you run out in 107 // the weeds if you skip over it with a debugger. 108 // 109 #define EFI_BREAKPOINT EFI_DEADLOOP() 110 111 112 // 113 // Memory Fence forces serialization, and is needed to support out of order 114 // memory transactions. The Memory Fence is mainly used to make sure IO 115 // transactions complete in a deterministic sequence, and to syncronize locks 116 // an other MP code. Currently no memory fencing is required. 117 // 118 #define MEMORY_FENCE() 119 120 // 121 // Some compilers don't support the forward reference construct: 122 // typedef struct XXXXX. The forward reference is required for 123 // ANSI compatibility. 124 // 125 // The following macro provide a workaround for such cases. 126 // 127 128 129 #ifdef EFI_NO_INTERFACE_DECL 130 #define EFI_FORWARD_DECLARATION(x) 131 #else 132 #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x 133 #endif 134 135 136 // 137 // Some C compilers optimize the calling conventions to increase performance. 138 // EFIAPI is used to make all public APIs follow the standard C calling 139 // convention. 140 // 141 #define EFIAPI 142 143 144 145 // 146 // For symbol name in GNU assembly code, an extra "_" is necessary 147 // 148 #if defined(__GNUC__) 149 /// 150 /// Private worker functions for ASM_PFX() 151 /// 152 #define _CONCATENATE(a, b) __CONCATENATE(a, b) 153 #define __CONCATENATE(a, b) a ## b 154 155 /// 156 /// The __USER_LABEL_PREFIX__ macro predefined by GNUC represents the prefix 157 /// on symbols in assembly language. 158 /// 159 #define ASM_PFX(name) _CONCATENATE (__USER_LABEL_PREFIX__, name) 160 161 #endif 162 163 #define INTERFACE_DECL(x) struct x 164 165 #endif 166