/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 44 - (hide annotations)
Mon Oct 8 16:22:56 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 7315 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1632 2007/09/11 21:46:35 debug Exp $
20070616	Implementing the MIPS32/64 revision 2 "ror" instruction.
20070617	Adding a struct for each physpage which keeps track of which
		ranges within that page (base offset, length) that are
		continuously translatable. When running with native code
		generation enabled (-b), a range is added after each read-
		ahead loop.
		Experimenting with using the physical program counter sample
		data (implemented 20070608) together with the "translatable
		range" information, to figure out which physical address ranges
		would be worth translating to native code (if the number of
		samples falling within a range is above a certain threshold).
20070618	Adding automagic building of .index comment files for
		src/file/, src/promemul/, src src/useremul/ as well.
		Adding a "has been translated" bit to the ranges, so that only
		not-yet-translated ranges will be sampled.
20070619	Moving src/cpu.c and src/memory_rw.c into src/cpus/,
		src/device.c into src/devices/, and src/machine.c into
		src/machines/.
		Creating a skeleton cc/ld native backend module; beginning on
		the function which will detect cc command line, etc.
20070620	Continuing on the native code generation infrastructure.
20070621	Moving src/x11.c and src/console.c into a new src/console/
		subdir (for everything that is console or framebuffer related).
		Moving src/symbol*.c into a new src/symbol/, which should
		contain anything that is symbol handling related.
20070624	Making the program counter sampling threshold a "settings
		variable" (sampling_threshold), i.e. it can now be changed
		during runtime.
		Switching the RELEASE notes format from plain text to HTML.
		If the TMPDIR environment variable is set, it is used instead
		of "/tmp" for temporary files.
		Continuing on the cc/ld backend: simple .c code is generated,
		the compiler and linker are called, etc.
		Adding detection of host architecture to the configure script
		(again), and adding icache invalidation support (only
		implemented for Alpha hosts so far).
20070625	Simplifying the program counter sampling mechanism.
20070626	Removing the cc/ld native code generation stuff, program
		counter sampling, etc; it would not have worked well in the
		general case.
20070627	Removing everything related to native code generation.
20070629	Removing the (practically unusable) support for multiple
		emulations. (The single emulation allowed now still supports
		multiple simultaneous machines, as before.)
		Beginning on PCCTWO and M88K interrupts.
20070723	Adding a dummy skeleton for emulation of M32R processors.
20070901	Fixing a warning found by "gcc version 4.3.0 20070817
		(experimental)" on amd64.
20070905	Removing some more traces of the old "multiple emulations"
		code.
		Also looking in /usr/local/include and /usr/local/lib for
		X11 libs, when running configure.
20070909	Minor updates to the guest OS install instructions, in
		preparation for the NetBSD 4.0 release.
20070918	More testing of NetBSD 4.0 RC1.

1 dpavlin 4 #ifndef MISC_H
2     #define MISC_H
3    
4     /*
5 dpavlin 34 * Copyright (C) 2003-2007 Anders Gavare. All rights reserved.
6 dpavlin 4 *
7     * Redistribution and use in source and binary forms, with or without
8     * modification, are permitted provided that the following conditions are met:
9     *
10     * 1. Redistributions of source code must retain the above copyright
11     * notice, this list of conditions and the following disclaimer.
12     * 2. Redistributions in binary form must reproduce the above copyright
13     * notice, this list of conditions and the following disclaimer in the
14     * documentation and/or other materials provided with the distribution.
15     * 3. The name of the author may not be used to endorse or promote products
16     * derived from this software without specific prior written permission.
17     *
18     * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19     * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20     * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21     * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22     * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23     * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24     * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25     * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26     * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27     * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28     * SUCH DAMAGE.
29     *
30     *
31 dpavlin 44 * $Id: misc.h,v 1.259 2007/06/23 21:04:17 debug Exp $
32 dpavlin 4 *
33     * Misc. definitions for gxemul.
34     */
35    
36    
37     #include <sys/types.h>
38     #include <inttypes.h>
39    
40     /*
41     * ../../config.h contains #defines set by the configure script. Some of these
42     * might reduce speed of the emulator, so don't enable them unless you
43     * need them.
44     */
45    
46     #include "../../config.h"
47    
48 dpavlin 24
49     #ifdef NO_C99_PRINTF_DEFINES
50     /*
51     * This is a SUPER-UGLY HACK which happens to work on some machines.
52     * The correct solution is to upgrade your compiler to C99.
53 dpavlin 4 */
54 dpavlin 24 #ifdef NO_C99_64BIT_LONGLONG
55 dpavlin 32 #define PRIi8 "i"
56 dpavlin 24 #define PRIi16 "i"
57     #define PRIi32 "i"
58     #define PRIi64 "lli"
59 dpavlin 32 #define PRIx8 "x"
60 dpavlin 24 #define PRIx16 "x"
61     #define PRIx32 "x"
62     #define PRIx64 "llx"
63     #else
64 dpavlin 32 #define PRIi8 "i"
65 dpavlin 24 #define PRIi16 "i"
66     #define PRIi32 "i"
67     #define PRIi64 "li"
68 dpavlin 32 #define PRIx8 "x"
69 dpavlin 24 #define PRIx16 "x"
70     #define PRIx32 "x"
71     #define PRIx64 "lx"
72     #endif
73     #endif
74 dpavlin 4
75    
76     #ifdef NO_MAP_ANON
77     #ifdef mmap
78     #undef mmap
79     #endif
80     #include <fcntl.h>
81     #include <stdlib.h>
82     #include <sys/mman.h>
83     static void *no_map_anon_mmap(void *addr, size_t len, int prot, int flags,
84     int nonsense_fd, off_t offset)
85     {
86     void *p;
87     int fd = open("/dev/zero", O_RDWR);
88     if (fd < 0) {
89     fprintf(stderr, "Could not open /dev/zero\n");
90     exit(1);
91     }
92    
93     printf("addr=%p len=%lli prot=0x%x flags=0x%x nonsense_fd=%i "
94     "offset=%16lli\n", addr, (long long) len, prot, flags,
95     nonsense_fd, (long long) offset);
96    
97     p = mmap(addr, len, prot, flags, fd, offset);
98    
99     printf("p = %p\n", p);
100    
101     /* TODO: Close the descriptor? */
102     return p;
103     }
104     #define mmap no_map_anon_mmap
105     #endif
106    
107    
108 dpavlin 44 /* tmp dir to use if the TMPDIR environment variable isn't set: */
109     #define DEFAULT_TMP_DIR "/tmp"
110    
111    
112 dpavlin 4 struct cpu;
113     struct emul;
114     struct machine;
115     struct memory;
116    
117    
118 dpavlin 32 #define NO_BYTE_ORDER_OVERRIDE -1
119     #define EMUL_UNDEFINED_ENDIAN 0
120     #define EMUL_LITTLE_ENDIAN 1
121     #define EMUL_BIG_ENDIAN 2
122 dpavlin 4
123 dpavlin 22 #ifdef HOST_LITTLE_ENDIAN
124 dpavlin 30 #define LE16_TO_HOST(x) (x)
125 dpavlin 32 #define BE16_TO_HOST(x) ((((x) & 0xff00) >> 8) | (((x)&0xff) << 8))
126 dpavlin 30 #else
127 dpavlin 32 #define LE16_TO_HOST(x) ((((x) & 0xff00) >> 8) | (((x)&0xff) << 8))
128 dpavlin 30 #define BE16_TO_HOST(x) (x)
129     #endif
130    
131     #ifdef HOST_LITTLE_ENDIAN
132 dpavlin 22 #define LE32_TO_HOST(x) (x)
133 dpavlin 32 #define BE32_TO_HOST(x) ((((x) & 0xff000000) >> 24) | (((x)&0xff) << 24) | \
134 dpavlin 22 (((x) & 0xff0000) >> 8) | (((x) & 0xff00) << 8))
135     #else
136 dpavlin 32 #define LE32_TO_HOST(x) ((((x) & 0xff000000) >> 24) | (((x)&0xff) << 24) | \
137 dpavlin 22 (((x) & 0xff0000) >> 8) | (((x) & 0xff00) << 8))
138     #define BE32_TO_HOST(x) (x)
139     #endif
140 dpavlin 4
141 dpavlin 32 #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 dpavlin 30
163 dpavlin 32
164 dpavlin 4 /* Debug stuff: */
165     #define DEBUG_BUFSIZE 1024
166 dpavlin 22 #define DEBUG_INDENTATION 4
167 dpavlin 4
168    
169 dpavlin 42 #ifdef HAVE___FUNCTION__
170    
171     #define FAILURE(error_msg) { \
172     char where_msg[400]; \
173     snprintf(where_msg, sizeof(where_msg), \
174 dpavlin 44 "%s, line %i, function %s().\n", \
175 dpavlin 42 __FILE__, __LINE__, __FUNCTION__); \
176 dpavlin 44 fprintf(stderr, "\n%s, in %s\n", error_msg, where_msg); \
177 dpavlin 42 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 dpavlin 44 fprintf(stderr, "\n%s, in %s.\n", error_msg, where_msg);\
187 dpavlin 42 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 dpavlin 36 /* 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 dpavlin 4 /* dec_prom.c: */
216     int decstation_prom_emul(struct cpu *cpu);
217    
218    
219 dpavlin 32 /* dreamcast.c: */
220     void dreamcast_machine_setup(struct machine *);
221     int dreamcast_emul(struct cpu *cpu);
222    
223    
224 dpavlin 34 /* dreamcast_scramble.c: */
225     void dreamcast_descramble(char *from, char *to);
226    
227    
228 dpavlin 4 /* file.c: */
229     int file_n_executables_loaded(void);
230     void file_load(struct machine *machine, struct memory *mem,
231     char *filename, uint64_t *entrypointp,
232     int arch, uint64_t *gpp, int *byte_order, uint64_t *tocp);
233    
234    
235     /* main.c: */
236     void debug_indentation(int diff);
237     void debug(char *fmt, ...);
238     void fatal(char *fmt, ...);
239 dpavlin 10
240    
241     /* misc.c: */
242 dpavlin 4 unsigned long long mystrtoull(const char *s, char **endp, int base);
243 dpavlin 10 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 dpavlin 42 void print_separator_line(void);
249 dpavlin 4
250    
251 dpavlin 42 /* mvmeprom.c: */
252     void mvmeprom_init(struct machine *machine);
253     int mvmeprom_emul(struct cpu *cpu);
254 dpavlin 4
255    
256     /* ps2_bios.c: */
257     int playstation2_sifbios_emul(struct cpu *cpu);
258    
259    
260 dpavlin 36 /* sh_ipl_g.c: */
261     void sh_ipl_g_emul_init(struct machine *machine);
262     int sh_ipl_g_emul(struct cpu *);
263    
264    
265 dpavlin 10 /* yamon.c: */
266 dpavlin 32 void yamon_machine_setup(struct machine *machine, uint64_t env);
267     int yamon_emul(struct cpu *);
268 dpavlin 10
269    
270 dpavlin 4 #endif /* MISC_H */

  ViewVC Help
Powered by ViewVC 1.1.26