1 |
#ifndef MISC_H |
2 |
#define MISC_H |
3 |
|
4 |
/* |
5 |
* Copyright (C) 2003-2005 Anders Gavare. All rights reserved. |
6 |
* |
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 |
* $Id: misc.h,v 1.229 2005/04/16 02:02:28 debug Exp $ |
32 |
* |
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 |
/* |
49 |
* ENABLE_INSTRUCTION_DELAYS should be defined on the cc commandline using |
50 |
* -D if you want it. (This is done by ./configure --delays) |
51 |
* |
52 |
* ALWAYS_SIGNEXTEND_32 is enabled by ./configure --always32 |
53 |
*/ |
54 |
#define USE_TINY_CACHE |
55 |
/* #define HALT_IF_PC_ZERO */ |
56 |
|
57 |
|
58 |
#ifdef NO_MAP_ANON |
59 |
#ifdef mmap |
60 |
#undef mmap |
61 |
#endif |
62 |
#include <fcntl.h> |
63 |
#include <stdlib.h> |
64 |
#include <sys/mman.h> |
65 |
static void *no_map_anon_mmap(void *addr, size_t len, int prot, int flags, |
66 |
int nonsense_fd, off_t offset) |
67 |
{ |
68 |
void *p; |
69 |
int fd = open("/dev/zero", O_RDWR); |
70 |
if (fd < 0) { |
71 |
fprintf(stderr, "Could not open /dev/zero\n"); |
72 |
exit(1); |
73 |
} |
74 |
|
75 |
printf("addr=%p len=%lli prot=0x%x flags=0x%x nonsense_fd=%i " |
76 |
"offset=%16lli\n", addr, (long long) len, prot, flags, |
77 |
nonsense_fd, (long long) offset); |
78 |
|
79 |
p = mmap(addr, len, prot, flags, fd, offset); |
80 |
|
81 |
printf("p = %p\n", p); |
82 |
|
83 |
/* TODO: Close the descriptor? */ |
84 |
return p; |
85 |
} |
86 |
#define mmap no_map_anon_mmap |
87 |
#endif |
88 |
|
89 |
|
90 |
struct cpu; |
91 |
struct emul; |
92 |
struct machine; |
93 |
struct memory; |
94 |
|
95 |
|
96 |
#define NO_BYTE_ORDER_OVERRIDE -1 |
97 |
#define EMUL_LITTLE_ENDIAN 0 |
98 |
#define EMUL_BIG_ENDIAN 1 |
99 |
|
100 |
|
101 |
/* Debug stuff: */ |
102 |
#define DEBUG_BUFSIZE 1024 |
103 |
|
104 |
#ifndef DEFAULT_BINTRANS_SIZE_IN_MB |
105 |
#define DEFAULT_BINTRANS_SIZE_IN_MB 16 |
106 |
#endif |
107 |
|
108 |
|
109 |
/* dec_prom.c: */ |
110 |
int decstation_prom_emul(struct cpu *cpu); |
111 |
|
112 |
|
113 |
/* file.c: */ |
114 |
int file_n_executables_loaded(void); |
115 |
void file_load(struct machine *machine, struct memory *mem, |
116 |
char *filename, uint64_t *entrypointp, |
117 |
int arch, uint64_t *gpp, int *byte_order, uint64_t *tocp); |
118 |
|
119 |
|
120 |
/* main.c: */ |
121 |
void debug_indentation(int diff); |
122 |
void debug(char *fmt, ...); |
123 |
void fatal(char *fmt, ...); |
124 |
unsigned long long mystrtoull(const char *s, char **endp, int base); |
125 |
|
126 |
|
127 |
/* of.c: */ |
128 |
int of_emul(struct cpu *cpu); |
129 |
|
130 |
|
131 |
/* pc_bios.c: */ |
132 |
int pc_bios_emul(struct cpu *cpu); |
133 |
|
134 |
|
135 |
/* ps2_bios.c: */ |
136 |
int playstation2_sifbios_emul(struct cpu *cpu); |
137 |
|
138 |
|
139 |
/* useremul.c: */ |
140 |
void useremul_setup(struct cpu *, int, char **); |
141 |
void useremul_syscall(struct cpu *cpu, uint32_t code); |
142 |
void useremul_name_to_useremul(struct cpu *, char *name, |
143 |
int *arch, char **machine_name, char **cpu_name); |
144 |
void useremul_list_emuls(void); |
145 |
void useremul_init(void); |
146 |
|
147 |
|
148 |
#endif /* MISC_H */ |