/[gxemul]/trunk/src/include/misc.h
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/include/misc.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4 by dpavlin, Mon Oct 8 16:18:00 2007 UTC revision 44 by dpavlin, Mon Oct 8 16:22:56 2007 UTC
# Line 2  Line 2 
2  #define MISC_H  #define MISC_H
3    
4  /*  /*
5   *  Copyright (C) 2003-2005  Anders Gavare.  All rights reserved.   *  Copyright (C) 2003-2007  Anders Gavare.  All rights reserved.
6   *   *
7   *  Redistribution and use in source and binary forms, with or without   *  Redistribution and use in source and binary forms, with or without
8   *  modification, are permitted provided that the following conditions are met:   *  modification, are permitted provided that the following conditions are met:
# Line 28  Line 28 
28   *  SUCH DAMAGE.   *  SUCH DAMAGE.
29   *   *
30   *   *
31   *  $Id: misc.h,v 1.229 2005/04/16 02:02:28 debug Exp $   *  $Id: misc.h,v 1.259 2007/06/23 21:04:17 debug Exp $
32   *   *
33   *  Misc. definitions for gxemul.   *  Misc. definitions for gxemul.
34   */   */
# Line 45  Line 45 
45    
46  #include "../../config.h"  #include "../../config.h"
47    
48  /*    
49   *  ENABLE_INSTRUCTION_DELAYS should be defined on the cc commandline using  #ifdef NO_C99_PRINTF_DEFINES
50   *  -D if you want it. (This is done by ./configure --delays)  /*
51   *   *  This is a SUPER-UGLY HACK which happens to work on some machines.
52   *  ALWAYS_SIGNEXTEND_32 is enabled by ./configure --always32   *  The correct solution is to upgrade your compiler to C99.
53   */   */
54  #define USE_TINY_CACHE  #ifdef NO_C99_64BIT_LONGLONG
55  /*  #define HALT_IF_PC_ZERO  */  #define PRIi8           "i"
56    #define PRIi16          "i"
57    #define PRIi32          "i"
58    #define PRIi64          "lli"
59    #define PRIx8           "x"
60    #define PRIx16          "x"
61    #define PRIx32          "x"
62    #define PRIx64          "llx"
63    #else
64    #define PRIi8           "i"
65    #define PRIi16          "i"
66    #define PRIi32          "i"
67    #define PRIi64          "li"
68    #define PRIx8           "x"
69    #define PRIx16          "x"
70    #define PRIx32          "x"
71    #define PRIx64          "lx"
72    #endif
73    #endif
74    
75    
76  #ifdef NO_MAP_ANON  #ifdef NO_MAP_ANON
# Line 87  static void *no_map_anon_mmap(void *addr Line 105  static void *no_map_anon_mmap(void *addr
105  #endif  #endif
106    
107    
108    /*  tmp dir to use if the TMPDIR environment variable isn't set:  */
109    #define DEFAULT_TMP_DIR         "/tmp"
110    
111    
112  struct cpu;  struct cpu;
113  struct emul;  struct emul;
114  struct machine;  struct machine;
115  struct memory;  struct memory;
116    
117    
118  #define NO_BYTE_ORDER_OVERRIDE          -1  #define NO_BYTE_ORDER_OVERRIDE          -1
119  #define EMUL_LITTLE_ENDIAN              0  #define EMUL_UNDEFINED_ENDIAN           0
120  #define EMUL_BIG_ENDIAN                 1  #define EMUL_LITTLE_ENDIAN              1
121    #define EMUL_BIG_ENDIAN                 2
122    
123    #ifdef HOST_LITTLE_ENDIAN
124    #define LE16_TO_HOST(x)     (x)
125    #define BE16_TO_HOST(x)     ((((x) & 0xff00) >> 8) | (((x)&0xff) << 8))
126    #else
127    #define LE16_TO_HOST(x)     ((((x) & 0xff00) >> 8) | (((x)&0xff) << 8))
128    #define BE16_TO_HOST(x)     (x)
129    #endif
130    
131    #ifdef HOST_LITTLE_ENDIAN
132    #define LE32_TO_HOST(x)     (x)
133    #define BE32_TO_HOST(x)     ((((x) & 0xff000000) >> 24) | (((x)&0xff) << 24) | \
134                                 (((x) & 0xff0000) >> 8) | (((x) & 0xff00) << 8))
135    #else
136    #define LE32_TO_HOST(x)     ((((x) & 0xff000000) >> 24) | (((x)&0xff) << 24) | \
137                                 (((x) & 0xff0000) >> 8) | (((x) & 0xff00) << 8))
138    #define BE32_TO_HOST(x)     (x)
139    #endif
140    
141    #ifdef HOST_LITTLE_ENDIAN
142    #define LE64_TO_HOST(x)     (x)
143    #define BE64_TO_HOST(x)     (   (((x) >> 56) & 0xff) +                  \
144                                    ((((x) >> 48) & 0xff) << 8) +           \
145                                    ((((x) >> 40) & 0xff) << 16) +          \
146                                    ((((x) >> 32) & 0xff) << 24) +          \
147                                    ((((x) >> 24) & 0xff) << 32) +          \
148                                    ((((x) >> 16) & 0xff) << 40) +          \
149                                    ((((x) >> 8) & 0xff) << 48) +           \
150                                    (((x) & 0xff) << 56)  )
151    #else
152    #define BE64_TO_HOST(x)     (x)
153    #define LE64_TO_HOST(x)     (   (((x) >> 56) & 0xff) +                  \
154                                    ((((x) >> 48) & 0xff) << 8) +           \
155                                    ((((x) >> 40) & 0xff) << 16) +          \
156                                    ((((x) >> 32) & 0xff) << 24) +          \
157                                    ((((x) >> 24) & 0xff) << 32) +          \
158                                    ((((x) >> 16) & 0xff) << 40) +          \
159                                    ((((x) >> 8) & 0xff) << 48) +           \
160                                    (((x) & 0xff) << 56)  )
161    #endif
162    
163    
164  /*  Debug stuff:  */  /*  Debug stuff:  */
165  #define DEBUG_BUFSIZE           1024  #define DEBUG_BUFSIZE           1024
166    #define DEBUG_INDENTATION       4
167    
168  #ifndef DEFAULT_BINTRANS_SIZE_IN_MB  
169  #define DEFAULT_BINTRANS_SIZE_IN_MB     16  #ifdef HAVE___FUNCTION__
170  #endif  
171    #define FAILURE(error_msg)                                      {       \
172                    char where_msg[400];                                    \
173                    snprintf(where_msg, sizeof(where_msg),                  \
174                        "%s, line %i, function %s().\n",                    \
175                        __FILE__, __LINE__, __FUNCTION__);                  \
176                    fprintf(stderr, "\n%s, in %s\n", error_msg, where_msg); \
177                    exit(1);                                                \
178            }
179    
180    #else
181    
182    #define FAILURE(error_msg)                                      {       \
183                    char where_msg[400];                                    \
184                    snprintf(where_msg, sizeof(where_msg),                  \
185                        "%s, line %i\n", __FILE__, __LINE__);               \
186                    fprintf(stderr, "\n%s, in %s.\n", error_msg, where_msg);\
187                    exit(1);                                                \
188            }
189    
190    #endif  /*  !HAVE___FUNCTION__  */
191    
192    
193    #define CHECK_ALLOCATION(ptr)                                   {       \
194                    if ((ptr) == NULL)                                      \
195                            FAILURE("Out of memory");                       \
196            }
197    
198    
199    /*  bootblock.c:  */
200    int load_bootblock(struct machine *m, struct cpu *cpu,
201            int *n_loadp, char ***load_namesp);
202    
203    
204    /*  bootblock_apple.c:  */
205    int apple_load_bootblock(struct machine *m, struct cpu *cpu,
206            int disk_id, int disk_type, int *n_loadp, char ***load_namesp);
207    
208    
209    /*  bootblock_iso9660.c:  */
210    int iso_load_bootblock(struct machine *m, struct cpu *cpu,
211            int disk_id, int disk_type, int iso_type, unsigned char *buf,
212            int *n_loadp, char ***load_namesp);
213    
214    
215  /*  dec_prom.c:  */  /*  dec_prom.c:  */
216  int decstation_prom_emul(struct cpu *cpu);  int decstation_prom_emul(struct cpu *cpu);
217    
218    
219    /*  dreamcast.c:  */
220    void dreamcast_machine_setup(struct machine *);
221    int dreamcast_emul(struct cpu *cpu);
222    
223    
224    /*  dreamcast_scramble.c:  */
225    void dreamcast_descramble(char *from, char *to);
226    
227    
228  /*  file.c:  */  /*  file.c:  */
229  int file_n_executables_loaded(void);  int file_n_executables_loaded(void);
230  void file_load(struct machine *machine, struct memory *mem,  void file_load(struct machine *machine, struct memory *mem,
# Line 121  void file_load(struct machine *machine, Line 236  void file_load(struct machine *machine,
236  void debug_indentation(int diff);  void debug_indentation(int diff);
237  void debug(char *fmt, ...);  void debug(char *fmt, ...);
238  void fatal(char *fmt, ...);  void fatal(char *fmt, ...);
 unsigned long long mystrtoull(const char *s, char **endp, int base);  
239    
240    
241  /*  of.c:  */  /*  misc.c:  */
242  int of_emul(struct cpu *cpu);  unsigned long long mystrtoull(const char *s, char **endp, int base);
243    int mymkstemp(char *template);
244    #ifdef USE_STRLCPY_REPLACEMENTS
245    size_t mystrlcpy(char *dst, const char *src, size_t size);
246    size_t mystrlcat(char *dst, const char *src, size_t size);
247    #endif
248    void print_separator_line(void);
249    
250    
251  /*  pc_bios.c:  */  /*  mvmeprom.c:  */
252  int pc_bios_emul(struct cpu *cpu);  void mvmeprom_init(struct machine *machine);
253    int mvmeprom_emul(struct cpu *cpu);
254    
255    
256  /*  ps2_bios.c:  */  /*  ps2_bios.c:  */
257  int playstation2_sifbios_emul(struct cpu *cpu);  int playstation2_sifbios_emul(struct cpu *cpu);
258    
259    
260  /*  useremul.c:  */  /*  sh_ipl_g.c:  */
261  void useremul_setup(struct cpu *, int, char **);  void sh_ipl_g_emul_init(struct machine *machine);
262  void useremul_syscall(struct cpu *cpu, uint32_t code);  int sh_ipl_g_emul(struct cpu *);
263  void useremul_name_to_useremul(struct cpu *, char *name,  
264          int *arch, char **machine_name, char **cpu_name);  
265  void useremul_list_emuls(void);  /*  yamon.c:  */
266  void useremul_init(void);  void yamon_machine_setup(struct machine *machine, uint64_t env);
267    int yamon_emul(struct cpu *);
268    
269    
270  #endif  /*  MISC_H  */  #endif  /*  MISC_H  */

Legend:
Removed from v.4  
changed lines
  Added in v.44

  ViewVC Help
Powered by ViewVC 1.1.26