1 |
|
/* |
2 |
|
* sysdeps.h - System dependent definitions for Unix |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-1999 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2002 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
42 |
|
#include <stdio.h> |
43 |
|
#include <stdlib.h> |
44 |
|
#include <string.h> |
45 |
– |
#include <pthread.h> |
45 |
|
|
46 |
|
#ifdef HAVE_FCNTL_H |
47 |
|
# include <fcntl.h> |
59 |
|
#endif |
60 |
|
|
61 |
|
|
62 |
< |
/* Are the Mac and the host address space the same? */ |
62 |
> |
#ifdef ENABLE_NATIVE_M68K |
63 |
> |
|
64 |
> |
/* Mac and host address space are the same */ |
65 |
> |
#define REAL_ADDRESSING 1 |
66 |
> |
|
67 |
> |
/* Using 68k natively */ |
68 |
> |
#define EMULATED_68K 0 |
69 |
> |
|
70 |
> |
/* Mac ROM is not write protected */ |
71 |
> |
#define ROM_IS_WRITE_PROTECTED 0 |
72 |
> |
#define USE_SCRATCHMEM_SUBTERFUGE 1 |
73 |
> |
|
74 |
> |
#else |
75 |
> |
|
76 |
> |
/* Mac and host address space are distinct */ |
77 |
> |
#ifndef REAL_ADDRESSING |
78 |
|
#define REAL_ADDRESSING 0 |
79 |
+ |
#endif |
80 |
|
|
81 |
< |
/* Are we using a 68k emulator or the real thing? */ |
81 |
> |
/* Using 68k emulator */ |
82 |
|
#define EMULATED_68K 1 |
83 |
|
|
84 |
< |
/* Is the Mac ROM write protected? */ |
85 |
< |
#define ROM_IS_WRITE_PROTECTED 1 |
84 |
> |
/* The m68k emulator uses a prefetch buffer ? */ |
85 |
> |
#define USE_PREFETCH_BUFFER 0 |
86 |
> |
|
87 |
> |
/* Mac ROM is write protected when banked memory is used */ |
88 |
> |
#if REAL_ADDRESSING || DIRECT_ADDRESSING |
89 |
> |
# define ROM_IS_WRITE_PROTECTED 0 |
90 |
> |
# define USE_SCRATCHMEM_SUBTERFUGE 1 |
91 |
> |
#else |
92 |
> |
# define ROM_IS_WRITE_PROTECTED 1 |
93 |
> |
#endif |
94 |
> |
|
95 |
> |
#endif |
96 |
> |
|
97 |
> |
/* Direct Addressing requires Video on SEGV signals */ |
98 |
> |
#if DIRECT_ADDRESSING && !ENABLE_VOSF |
99 |
> |
# undef ENABLE_VOSF |
100 |
> |
# define ENABLE_VOSF 1 |
101 |
> |
#endif |
102 |
|
|
103 |
|
/* ExtFS is supported */ |
104 |
|
#define SUPPORTS_EXTFS 1 |
105 |
|
|
106 |
+ |
/* BSD socket API supported */ |
107 |
+ |
#define SUPPORTS_UDP_TUNNEL 1 |
108 |
+ |
|
109 |
+ |
|
110 |
|
/* Data types */ |
111 |
|
typedef unsigned char uint8; |
112 |
|
typedef signed char int8; |
131 |
|
#if SIZEOF_LONG == 8 |
132 |
|
typedef unsigned long uint64; |
133 |
|
typedef long int64; |
134 |
+ |
#define VAL64(a) (a ## l) |
135 |
+ |
#define UVAL64(a) (a ## ul) |
136 |
|
#elif SIZEOF_LONG_LONG == 8 |
137 |
|
typedef unsigned long long uint64; |
138 |
|
typedef long long int64; |
139 |
+ |
#define VAL64(a) (a ## LL) |
140 |
+ |
#define UVAL64(a) (a ## uLL) |
141 |
|
#else |
142 |
|
#error "No 8 byte type, you lose." |
143 |
|
#endif |
144 |
+ |
#if SIZEOF_VOID_P == 4 |
145 |
+ |
typedef uint32 uintptr; |
146 |
+ |
typedef int32 intptr; |
147 |
+ |
#elif SIZEOF_VOID_P == 8 |
148 |
+ |
typedef uint64 uintptr; |
149 |
+ |
typedef int64 intptr; |
150 |
+ |
#else |
151 |
+ |
#error "Unsupported size of pointer" |
152 |
+ |
#endif |
153 |
|
|
154 |
|
/* Time data type for Time Manager emulation */ |
155 |
|
#ifdef HAVE_CLOCK_GETTIME |
158 |
|
typedef struct timeval tm_time_t; |
159 |
|
#endif |
160 |
|
|
161 |
< |
/* Offset Mac->Unix time in seconds */ |
162 |
< |
#define TIME_OFFSET 0x7c25b080 |
161 |
> |
/* Define codes for all the float formats that we know of. |
162 |
> |
* Though we only handle IEEE format. */ |
163 |
> |
#define UNKNOWN_FLOAT_FORMAT 0 |
164 |
> |
#define IEEE_FLOAT_FORMAT 1 |
165 |
> |
#define VAX_FLOAT_FORMAT 2 |
166 |
> |
#define IBM_FLOAT_FORMAT 3 |
167 |
> |
#define C4X_FLOAT_FORMAT 4 |
168 |
|
|
169 |
|
/* UAE CPU data types */ |
170 |
|
#define uae_s8 int8 |
173 |
|
#define uae_u16 uint16 |
174 |
|
#define uae_s32 int32 |
175 |
|
#define uae_u32 uint32 |
176 |
+ |
#define uae_s64 int64 |
177 |
+ |
#define uae_u64 uint64 |
178 |
|
typedef uae_u32 uaecptr; |
179 |
|
|
180 |
|
/* Alignment restrictions */ |
182 |
|
# define CPU_CAN_ACCESS_UNALIGNED |
183 |
|
#endif |
184 |
|
|
185 |
+ |
/* Timing functions */ |
186 |
+ |
extern uint64 GetTicks_usec(void); |
187 |
+ |
extern void Delay_usec(uint32 usec); |
188 |
+ |
|
189 |
+ |
#ifdef HAVE_PTHREADS |
190 |
+ |
/* Centralized pthread attribute setup */ |
191 |
+ |
void Set_pthread_attr(pthread_attr_t *attr, int priority); |
192 |
+ |
#endif |
193 |
+ |
|
194 |
|
/* UAE CPU defines */ |
195 |
|
#ifdef WORDS_BIGENDIAN |
196 |
|
|
249 |
|
#else |
250 |
|
static inline void do_put_mem_word(uae_u16 *a, uae_u32 v) {__asm__ ("rolw $8,%0" : "=r" (v) : "0" (v) : "cc"); *a = v;} |
251 |
|
#endif |
252 |
+ |
#define HAVE_OPTIMIZED_BYTESWAP_32 |
253 |
+ |
/* bswap doesn't affect condition codes */ |
254 |
+ |
static inline uae_u32 do_byteswap_32(uae_u32 v) {__asm__ ("bswap %0" : "=r" (v) : "0" (v)); return v;} |
255 |
+ |
#define HAVE_OPTIMIZED_BYTESWAP_16 |
256 |
+ |
#ifdef X86_PPRO_OPT |
257 |
+ |
static inline uae_u32 do_byteswap_16(uae_u32 v) {__asm__ ("bswapl %0" : "=&r" (v) : "0" (v << 16) : "cc"); return v;} |
258 |
+ |
#else |
259 |
+ |
static inline uae_u32 do_byteswap_16(uae_u32 v) {__asm__ ("rolw $8,%0" : "=r" (v) : "0" (v) : "cc"); return v;} |
260 |
+ |
#endif |
261 |
|
|
262 |
|
#elif defined(CPU_CAN_ACCESS_UNALIGNED) |
263 |
|
|
279 |
|
|
280 |
|
#endif /* WORDS_BIGENDIAN */ |
281 |
|
|
282 |
+ |
#ifndef HAVE_OPTIMIZED_BYTESWAP_32 |
283 |
+ |
static inline uae_u32 do_byteswap_32(uae_u32 v) |
284 |
+ |
{ return (((v >> 24) & 0xff) | ((v >> 8) & 0xff00) | ((v & 0xff) << 24) | ((v & 0xff00) << 8)); } |
285 |
+ |
#endif |
286 |
+ |
|
287 |
+ |
#ifndef HAVE_OPTIMIZED_BYTESWAP_16 |
288 |
+ |
static inline uae_u32 do_byteswap_16(uae_u32 v) |
289 |
+ |
{ return (((v >> 8) & 0xff) | ((v & 0xff) << 8)); } |
290 |
+ |
#endif |
291 |
+ |
|
292 |
|
#define do_get_mem_byte(a) ((uae_u32)*((uae_u8 *)(a))) |
293 |
|
#define do_put_mem_byte(a, v) (*(uae_u8 *)(a) = (v)) |
294 |
|
|
296 |
|
#define call_mem_put_func(func, addr, v) ((*func)(addr, v)) |
297 |
|
#define __inline__ inline |
298 |
|
#define CPU_EMU_SIZE 0 |
216 |
– |
#undef USE_MAPPED_MEMORY |
217 |
– |
#undef CAN_MAP_MEMORY |
299 |
|
#undef NO_INLINE_MEMORY_ACCESS |
300 |
|
#undef MD_HAVE_MEM_1_FUNCS |
220 |
– |
#undef USE_COMPILER |
301 |
|
#define ENUMDECL typedef enum |
302 |
|
#define ENUMNAME(name) name |
303 |
|
#define write_log printf |