xref: /freebsd/stand/efi/include/arm64/efibind.h (revision 7c43148a974877188a930e4078a164f83da8e652)
1 /*++
2 
3 Copyright (c)  1999 - 2003 Intel Corporation. All rights reserved
4 This software and associated documentation (if any) is furnished
5 under a license and may only be used or copied in accordance
6 with the terms of the license. Except as permitted by such
7 license, no part of this software or documentation may be
8 reproduced, stored in a retrieval system, or transmitted in any
9 form or by any means without the express written consent of
10 Intel Corporation.
11 
12 Module Name:
13 
14     efefind.h
15 
16 Abstract:
17 
18     EFI to compile bindings
19 
20 
21 
22 
23 Revision History
24 
25 --*/
26 
27 #pragma pack()
28 
29 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30 // BugBug: Code to debug
31 //
32 #define BIT63   0x8000000000000000
33 
34 #define PLATFORM_IOBASE_ADDRESS   (0xffffc000000 | BIT63)
35 #define PORT_TO_MEMD(_Port) (PLATFORM_IOBASE_ADDRESS | ( ( ( (_Port) & 0xfffc) << 10 ) | ( (_Port) & 0x0fff) ) )
36 
37 //
38 // Macro's with casts make this much easier to use and read.
39 //
40 #define PORT_TO_MEM8D(_Port)  (*(UINT8  *)(PORT_TO_MEMD(_Port)))
41 #define POST_CODE(_Data)  (PORT_TO_MEM8D(0x80) = (_Data))
42 //
43 // BugBug: End Debug Code!!!
44 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
45 
46 #define EFIERR(a)           (0x8000000000000000 | a)
47 #define EFI_ERROR_MASK      0x8000000000000000
48 #define EFIERR_OEM(a)       (0xc000000000000000 | a)
49 
50 #define BAD_POINTER         0xFBFBFBFBFBFBFBFB
51 #define MAX_ADDRESS         0xFFFFFFFFFFFFFFFF
52 
53 #define BREAKPOINT()  __break(0)
54 
55 //
56 // Pointers must be aligned to these address to function
57 //  you will get an alignment fault if this value is less than 8
58 //
59 #define MIN_ALIGNMENT_SIZE  8
60 
61 #define ALIGN_VARIABLE(Value , Adjustment) \
62             (UINTN) Adjustment = 0; \
63             if((UINTN)Value % MIN_ALIGNMENT_SIZE) \
64                 (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \
65             Value = (UINTN)Value + (UINTN)Adjustment
66 
67 //
68 // Define macros to create data structure signatures.
69 //
70 
71 #define EFI_SIGNATURE_16(A,B)             ((A) | (B<<8))
72 #define EFI_SIGNATURE_32(A,B,C,D)         (EFI_SIGNATURE_16(A,B)     | (EFI_SIGNATURE_16(C,D)     << 16))
73 #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))
74 
75 //
76 // EFIAPI - prototype calling convention for EFI function pointers
77 // BOOTSERVICE - prototype for implementation of a boot service interface
78 // RUNTIMESERVICE - prototype for implementation of a runtime service interface
79 // RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service
80 // RUNTIME_CODE - pragma macro for declaring runtime code
81 //
82 
83 #ifndef EFIAPI                  // Forces EFI calling conventions reguardless of compiler options
84     #ifdef _MSC_EXTENSIONS
85         #define EFIAPI __cdecl  // Force C calling convention for Microsoft C compiler
86     #else
87         #define EFIAPI          // Substitute expresion to force C calling convention
88     #endif
89 #endif
90 
91 #define BOOTSERVICE
92 #define RUNTIMESERVICE
93 #define RUNTIMEFUNCTION
94 
95 #define RUNTIME_CODE(a)         alloc_text("rtcode", a)
96 #define BEGIN_RUNTIME_DATA()    data_seg("rtdata")
97 #define END_RUNTIME_DATA()      data_seg()
98 
99 #define VOLATILE    volatile
100 
101 //
102 // BugBug: Need to find out if this is portable across compilers.
103 //
104 void __mfa (void);
105 #define MEMORY_FENCE()    __mfa()
106 
107 #ifdef EFI_NO_INTERFACE_DECL
108   #define EFI_FORWARD_DECLARATION(x)
109   #define EFI_INTERFACE_DECL(x)
110 #else
111   #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x
112   #define EFI_INTERFACE_DECL(x) typedef struct x
113 #endif
114 
115 //
116 // When build similar to FW, then link everything together as
117 // one big module.
118 //
119 
120 #define EFI_DRIVER_ENTRY_POINT(InitFunction)
121 
122 #define LOAD_INTERNAL_DRIVER(_if, type, name, entry)    \
123             (_if)->LoadInternal(type, name, entry)
124 //        entry(NULL, ST)
125 
126 #ifdef __FreeBSD__
127 #define INTERFACE_DECL(x) struct x
128 #else
129 //
130 // Some compilers don't support the forward reference construct:
131 //  typedef struct XXXXX
132 //
133 // The following macro provide a workaround for such cases.
134 //
135 #ifdef NO_INTERFACE_DECL
136 #define INTERFACE_DECL(x)
137 #else
138 #define INTERFACE_DECL(x) typedef struct x
139 #endif
140 #endif
141