1 /*
2 * UAE - The Un*x Amiga Emulator
3 *
4 * UAE Native Interface (UNI)
5 *
6 * Copyright 2013-2014 Frode Solheim
7 */
8 
9 #ifndef UAE_UNI_COMMON_H
10 #define UAE_UNI_COMMON_H
11 
12 #define UNI_VERSION 1
13 
14 #ifndef UNI_MIN_VERSION
15 // MIN_UNI_VERSION decides which callback functions are declared available.
16 // The default, unless overridden is to require the current UNI version.
17 #define UNI_MIN_VERSION UNI_VERSION
18 #endif
19 
20 #ifdef _WIN32
21 #ifdef UNI_IMPORT
22 #define UNIAPI __declspec(dllimport)
23 #else
24 #define UNIAPI __declspec(dllexport)
25 #endif
26 #define UNICALL __cdecl
27 #else
28 #define UNIAPI
29 #define UNICALL
30 #endif
31 
32 #define UNI_ERROR_NOT_ENABLED            0x70000001
33 #define UNI_ERROR_INVALID_LIBRARY        0x70000002
34 #define UNI_ERROR_INVALID_FUNCTION       0x70000002
35 #define UNI_ERROR_FUNCTION_NOT_FOUND     0x70000003
36 #define UNI_ERROR_LIBRARY_NOT_FOUND      0x70000004
37 #define UNI_ERROR_INVALID_FLAGS          0x70000005
38 #define UNI_ERROR_COULD_NOT_OPEN_LIBRARY 0x70000006
39 #define UNI_ERROR_ILLEGAL_LIBRARY_NAME   0x70000007
40 #define UNI_ERROR_LIBRARY_TOO_OLD        0x70000008
41 #define UNI_ERROR_INIT_FAILED            0x70000009
42 #define UNI_ERROR_INTERFACE_TOO_OLD      0x7000000a
43 
44 // these errors are only returned from the Amiga-side uni wrappers
45 #define UNI_ERROR_AMIGALIB_NOT_OPEN      0x71000000
46 
47 #include <stdint.h>
48 
49 typedef int8_t   uni_byte;
50 typedef uint8_t  uni_ubyte;
51 typedef int16_t  uni_word;
52 typedef uint16_t uni_uword;
53 typedef int32_t  uni_long;
54 typedef uint32_t uni_ulong;
55 
56 // deprecated typedefs
57 typedef int8_t   uni_char;
58 typedef uint8_t  uni_uchar;
59 typedef int16_t  uni_short;
60 typedef uint16_t uni_ushort;
61 
62 typedef int (UNICALL *uni_version_function)();
63 typedef void * (UNICALL *uni_resolve_function)(uni_ulong ptr);
64 typedef const char * (UNICALL *uni_uae_version_function)(void);
65 
66 struct uni {
67     uni_long d1;
68     uni_long d2;
69     uni_long d3;
70     uni_long d4;
71     uni_long d5;
72     uni_long d6;
73     uni_long d7;
74     uni_long a1;
75     uni_long a2;
76     uni_long a3;
77     uni_long a4;
78     uni_long a5;
79     uni_long a7;
80 
81 #if UNI_VERSION >= 2
82     // add new struct entries for version 2 here
83 #endif
84 
85 #ifdef CPUEMU_0  // UAE
86     uni_long result;
87     uni_long error;
88     uni_ulong function;
89     uni_ulong library;
90     void *native_function;
91     void *uaevar_compat;
92     int flags;
93     uaecptr task;
94 #endif
95 };
96 
97 #endif /* UAE_UNI_COMMON_H */
98