1/* $FreeBSD: head/sys/boot/efi/include/ia64/efibind.h 143250 2005-03-07 15:38:37Z stefanf $ */
| 1/* $FreeBSD: head/sys/boot/efi/include/ia64/efibind.h 163898 2006-11-02 02:42:48Z marcel $ */
|
2/*++ 3
| 2/*++ 3
|
4Copyright (c) 1998 Intel Corporation
| 4Copyright (c) 1999 - 2003 Intel Corporation. All rights reserved 5This software and associated documentation (if any) is furnished 6under a license and may only be used or copied in accordance 7with the terms of the license. Except as permitted by such 8license, no part of this software or documentation may be 9reproduced, stored in a retrieval system, or transmitted in any 10form or by any means without the express written consent of 11Intel Corporation.
|
5 6Module Name: 7 8 efefind.h 9 10Abstract: 11 12 EFI to compile bindings 13 14 15 16 17Revision History 18 19--*/ 20
| 12 13Module Name: 14 15 efefind.h 16 17Abstract: 18 19 EFI to compile bindings 20 21 22 23 24Revision History 25 26--*/ 27
|
| 28#pragma pack() 29 30 31#ifdef __FreeBSD__
|
21#include <sys/stdint.h>
| 32#include <sys/stdint.h>
|
| 33#else 34// 35// Basic int types of various widths 36//
|
22
| 37
|
23/* Basic EFI types of various widths. */
| 38#if (__STDC_VERSION__ < 199901L )
|
24
| 39
|
| 40 // No ANSI C 1999/2000 stdint.h integer width declarations 41 42 #if _MSC_EXTENSIONS 43 44 // Use Microsoft C compiler integer width declarations 45 46 typedef unsigned __int64 uint64_t; 47 typedef __int64 int64_t; 48 typedef unsigned __int32 uint32_t; 49 typedef __int32 int32_t; 50 typedef unsigned __int16 uint16_t; 51 typedef __int16 int16_t; 52 typedef unsigned __int8 uint8_t; 53 typedef __int8 int8_t; 54 #else 55 #ifdef UNIX_LP64 56 57 // Use LP64 programming model from C_FLAGS for integer width declarations 58 59 typedef unsigned long uint64_t; 60 typedef long int64_t; 61 typedef unsigned int uint32_t; 62 typedef int int32_t; 63 typedef unsigned short uint16_t; 64 typedef short int16_t; 65 typedef unsigned char uint8_t; 66 typedef char int8_t; 67 #else 68 69 // Assume P64 programming model from C_FLAGS for integer width declarations 70 71 typedef unsigned long long uint64_t; 72 typedef long long int64_t; 73 typedef unsigned int uint32_t; 74 typedef int int32_t; 75 typedef unsigned short uint16_t; 76 typedef short int16_t; 77 typedef unsigned char uint8_t; 78 typedef char int8_t; 79 #endif 80 #endif 81#endif 82#endif /* __FreeBSD__ */ 83 84// 85// Basic EFI types of various widths 86// 87 88
|
25typedef uint64_t UINT64; 26typedef int64_t INT64; 27typedef uint32_t UINT32; 28typedef int32_t INT32; 29typedef uint16_t UINT16; 30typedef int16_t INT16; 31typedef uint8_t UINT8; 32typedef int8_t INT8; 33 34 35#undef VOID 36#define VOID void 37 38 39typedef int64_t INTN; 40typedef uint64_t UINTN; 41
| 89typedef uint64_t UINT64; 90typedef int64_t INT64; 91typedef uint32_t UINT32; 92typedef int32_t INT32; 93typedef uint16_t UINT16; 94typedef int16_t INT16; 95typedef uint8_t UINT8; 96typedef int8_t INT8; 97 98 99#undef VOID 100#define VOID void 101 102 103typedef int64_t INTN; 104typedef uint64_t UINTN; 105
|
42/* 43 *XXX BugBug: Code to debug 44 */
| 106//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 107// BugBug: Code to debug 108//
|
45#define BIT63 0x8000000000000000 46
| 109#define BIT63 0x8000000000000000 110
|
47#define PLATFORM_IOBASE_ADDRESS (0xffffc000000 | BIT63)
| 111#define PLATFORM_IOBASE_ADDRESS (0xffffc000000 | BIT63)
|
48#define PORT_TO_MEMD(_Port) (PLATFORM_IOBASE_ADDRESS | ( ( ( (_Port) & 0xfffc) << 10 ) | ( (_Port) & 0x0fff) ) )
| 112#define PORT_TO_MEMD(_Port) (PLATFORM_IOBASE_ADDRESS | ( ( ( (_Port) & 0xfffc) << 10 ) | ( (_Port) & 0x0fff) ) )
|
49 50/* Macro's with casts make this much easier to use and read. */
| 113 114// 115// Macro's with casts make this much easier to use and read. 116//
|
51#define PORT_TO_MEM8D(_Port) (*(UINT8 *)(PORT_TO_MEMD(_Port))) 52#define POST_CODE(_Data) (PORT_TO_MEM8D(0x80) = (_Data))
| 117#define PORT_TO_MEM8D(_Port) (*(UINT8 *)(PORT_TO_MEMD(_Port))) 118#define POST_CODE(_Data) (PORT_TO_MEM8D(0x80) = (_Data))
|
| 119// 120// BugBug: End Debug Code!!! 121//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
53 54#define EFIERR(a) (0x8000000000000000 | a) 55#define EFI_ERROR_MASK 0x8000000000000000 56#define EFIERR_OEM(a) (0xc000000000000000 | a) 57 58#define BAD_POINTER 0xFBFBFBFBFBFBFBFB 59#define MAX_ADDRESS 0xFFFFFFFFFFFFFFFF 60
| 122 123#define EFIERR(a) (0x8000000000000000 | a) 124#define EFI_ERROR_MASK 0x8000000000000000 125#define EFIERR_OEM(a) (0xc000000000000000 | a) 126 127#define BAD_POINTER 0xFBFBFBFBFBFBFBFB 128#define MAX_ADDRESS 0xFFFFFFFFFFFFFFFF 129
|
61#define BREAKPOINT() while (TRUE)
| 130#pragma intrinsic (__break) 131#define BREAKPOINT() __break(0)
|
62
| 132
|
63/* 64 * Pointers must be aligned to these address to function 65 * you will get an alignment fault if this value is less than 8 66 */
| 133// 134// Pointers must be aligned to these address to function 135// you will get an alignment fault if this value is less than 8 136//
|
67#define MIN_ALIGNMENT_SIZE 8 68 69#define ALIGN_VARIABLE(Value , Adjustment) \ 70 (UINTN) Adjustment = 0; \ 71 if((UINTN)Value % MIN_ALIGNMENT_SIZE) \ 72 (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \ 73 Value = (UINTN)Value + (UINTN)Adjustment 74
| 137#define MIN_ALIGNMENT_SIZE 8 138 139#define ALIGN_VARIABLE(Value , Adjustment) \ 140 (UINTN) Adjustment = 0; \ 141 if((UINTN)Value % MIN_ALIGNMENT_SIZE) \ 142 (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \ 143 Value = (UINTN)Value + (UINTN)Adjustment 144
|
75/* 76 * Define macros to create data structure signatures. 77 */
| 145// 146// Define macros to create data structure signatures. 147//
|
78 79#define EFI_SIGNATURE_16(A,B) ((A) | (B<<8)) 80#define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16(A,B) | (EFI_SIGNATURE_16(C,D) << 16)) 81#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)) 82
| 148 149#define EFI_SIGNATURE_16(A,B) ((A) | (B<<8)) 150#define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16(A,B) | (EFI_SIGNATURE_16(C,D) << 16)) 151#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)) 152
|
83/* 84 * To export & import functions in the EFI emulator environment 85 */
| 153// 154// EFIAPI - prototype calling convention for EFI function pointers 155// BOOTSERVICE - prototype for implementation of a boot service interface 156// RUNTIMESERVICE - prototype for implementation of a runtime service interface 157// RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service 158// RUNTIME_CODE - pragma macro for declaring runtime code 159//
|
86
| 160
|
87#define EXPORTAPI 88 89/* 90 * EFIAPI - prototype calling convention for EFI function pointers 91 * BOOTSERVICE - prototype for implementation of a boot service interface 92 * RUNTIMESERVICE - prototype for implementation of a runtime service interface 93 * RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service 94 * RUNTIME_CODE - pragma macro for declaring runtime code 95 */ 96 97#ifndef EFIAPI /* Forces EFI calling conventions reguardless of compiler options */ 98#if _MSC_EXTENSIONS 99#define EFIAPI __cdecl 100#else 101#define EFIAPI
| 161#ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options 162 #if _MSC_EXTENSIONS 163 #define EFIAPI __cdecl // Force C calling convention for Microsoft C compiler 164 #else 165 #define EFIAPI // Substitute expresion to force C calling convention 166 #endif
|
102#endif
| 167#endif
|
103#endif
| |
104 105#define BOOTSERVICE 106#define RUNTIMESERVICE 107#define RUNTIMEFUNCTION 108 109#define RUNTIME_CODE(a) alloc_text("rtcode", a) 110#define BEGIN_RUNTIME_DATA() data_seg("rtdata")
| 168 169#define BOOTSERVICE 170#define RUNTIMESERVICE 171#define RUNTIMEFUNCTION 172 173#define RUNTIME_CODE(a) alloc_text("rtcode", a) 174#define BEGIN_RUNTIME_DATA() data_seg("rtdata")
|
111#define END_RUNTIME_DATA() data_seg("")
| 175#define END_RUNTIME_DATA() data_seg()
|
112 113#define VOLATILE volatile 114
| 176 177#define VOLATILE volatile 178
|
115/* 116 * XXX Need to find out if this is portable across compilers. 117 */ 118void __mf (void); 119#ifndef __GNUC__ 120#pragma intrinsic (__mf)
| 179// 180// BugBug: Need to find out if this is portable accross compliers. 181// 182void __mfa (void); 183#pragma intrinsic (__mfa) 184#define MEMORY_FENCE() __mfa() 185 186#ifdef EFI_NO_INTERFACE_DECL 187 #define EFI_FORWARD_DECLARATION(x) 188 #define EFI_INTERFACE_DECL(x) 189#else 190 #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x 191 #define EFI_INTERFACE_DECL(x) typedef struct x
|
121#endif
| 192#endif
|
122#define MEMORY_FENCE() __mf()
| |
123
| 193
|
124/* 125 * When build similiar to FW, then link everything together as 126 * one big module. 127 */
| 194// 195// When build similiar to FW, then link everything together as 196// one big module. 197//
|
128 129#define EFI_DRIVER_ENTRY_POINT(InitFunction) 130 131#define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \
| 198 199#define EFI_DRIVER_ENTRY_POINT(InitFunction) 200 201#define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \
|
132 (_if)->LoadInternal(type, name, entry)
| 202 (_if)->LoadInternal(type, name, entry) 203// entry(NULL, ST)
|
133
| 204
|
| 205#ifdef __FreeBSD__
|
134#define INTERFACE_DECL(x) struct x
| 206#define INTERFACE_DECL(x) struct x
|
| 207#else 208// 209// Some compilers don't support the forward reference construct: 210// typedef struct XXXXX 211// 212// The following macro provide a workaround for such cases. 213// 214#ifdef NO_INTERFACE_DECL 215#define INTERFACE_DECL(x) 216#else 217#define INTERFACE_DECL(x) typedef struct x 218#endif 219#endif
|
| |