35 #include <sys/types.h> 44 #include "../../config.h" 46 #define COPYRIGHT_MSG "Copyright (C) 2003-2018 Anders Gavare" 54 #define SECONDARY_MSG "" 72 using std::stringstream;
88 #ifdef NO_C99_PRINTF_DEFINES 93 #ifdef NO_C99_64BIT_LONGLONG 121 #include <sys/mman.h> 122 static void *no_map_anon_mmap(
void *
addr,
size_t len,
int prot,
int flags,
123 int nonsense_fd, off_t offset)
126 int fd = open(
"/dev/zero", O_RDWR);
128 fprintf(stderr,
"Could not open /dev/zero\n");
132 printf(
"addr=%p len=%lli prot=0x%x flags=0x%x nonsense_fd=%i " 133 "offset=%16lli\n", addr, (
long long) len, prot, flags,
134 nonsense_fd, (
long long) offset);
136 p = mmap(addr, len, prot, flags, fd, offset);
138 printf(
"p = %p\n", p);
143 #define mmap no_map_anon_mmap 148 #define DEFAULT_TMP_DIR "/tmp" 162 #define NO_BYTE_ORDER_OVERRIDE -1 163 #define EMUL_UNDEFINED_ENDIAN 0 164 #define EMUL_LITTLE_ENDIAN 1 165 #define EMUL_BIG_ENDIAN 2 167 #define SWAP32(x) ((((x) & 0xff000000) >> 24) | (((x)&0xff) << 24) | \ 168 (((x) & 0xff0000) >> 8) | (((x) & 0xff00) << 8)) 169 #define SWAP16(x) ((((x) & 0xff00) >> 8) | (((x)&0xff) << 8)) 171 #ifdef HOST_LITTLE_ENDIAN 172 #define LE16_TO_HOST(x) (x) 173 #define BE16_TO_HOST(x) (SWAP16(x)) 175 #define LE16_TO_HOST(x) (SWAP16(x)) 176 #define BE16_TO_HOST(x) (x) 179 #ifdef HOST_LITTLE_ENDIAN 180 #define LE32_TO_HOST(x) (x) 181 #define BE32_TO_HOST(x) (SWAP32(x)) 183 #define LE32_TO_HOST(x) (SWAP32(x)) 184 #define BE32_TO_HOST(x) (x) 187 #ifdef HOST_LITTLE_ENDIAN 188 #define LE64_TO_HOST(x) (x) 189 #define BE64_TO_HOST(x) ( (((x) >> 56) & 0xff) + \ 190 ((((x) >> 48) & 0xff) << 8) + \ 191 ((((x) >> 40) & 0xff) << 16) + \ 192 ((((x) >> 32) & 0xff) << 24) + \ 193 ((((x) >> 24) & 0xff) << 32) + \ 194 ((((x) >> 16) & 0xff) << 40) + \ 195 ((((x) >> 8) & 0xff) << 48) + \ 196 (((x) & 0xff) << 56) ) 198 #define BE64_TO_HOST(x) (x) 199 #define LE64_TO_HOST(x) ( (((x) >> 56) & 0xff) + \ 200 ((((x) >> 48) & 0xff) << 8) + \ 201 ((((x) >> 40) & 0xff) << 16) + \ 202 ((((x) >> 32) & 0xff) << 24) + \ 203 ((((x) >> 24) & 0xff) << 32) + \ 204 ((((x) >> 16) & 0xff) << 40) + \ 205 ((((x) >> 8) & 0xff) << 48) + \ 206 (((x) & 0xff) << 56) ) 211 #define DEBUG_BUFSIZE 1024 212 #define DEBUG_INDENTATION 4 215 #ifdef HAVE___FUNCTION__ 217 #define FAILURE(error_msg) { \ 218 char where_msg[400]; \ 219 snprintf(where_msg, sizeof(where_msg), \ 220 "%s, line %i, function %s().\n", \ 221 __FILE__, __LINE__, __FUNCTION__); \ 222 fprintf(stderr, "\n%s, in %s\n", error_msg, where_msg); \ 228 #define FAILURE(error_msg) { \ 229 char where_msg[400]; \ 230 snprintf(where_msg, sizeof(where_msg), \ 231 "%s, line %i\n", __FILE__, __LINE__); \ 232 fprintf(stderr, "\n%s, in %s.\n", error_msg, where_msg);\ 239 #define CHECK_ALLOCATION(ptr) { \ 241 FAILURE("Out of memory"); \ 247 int *n_loadp,
char ***load_namesp);
252 int disk_id,
int disk_type,
int *n_loadp,
char ***load_namesp);
257 int disk_id,
int disk_type,
int iso_type,
unsigned char *buf,
258 int *n_loadp,
char ***load_namesp);
277 char *filename, uint64_t *entrypointp,
278 int arch, uint64_t *gpp,
int *byte_order, uint64_t *tocp);
288 void debug(
const char *fmt, ...);
289 void fatal(
const char *fmt, ...);
293 unsigned long long mystrtoull(
const char *s,
char **endp,
int base);
295 #ifdef USE_STRLCPY_REPLACEMENTS 296 size_t mystrlcpy(
char *dst,
const char *src,
size_t size);
297 size_t mystrlcat(
char *dst,
const char *src,
size_t size);
int load_bootblock(struct machine *m, struct cpu *cpu, int *n_loadp, char ***load_namesp)
void fatal(const char *fmt,...)
void sh_ipl_g_emul_init(struct machine *machine)
void print_separator_line(void)
int yamon_emul(struct cpu *)
void debug(const char *fmt,...)
int playstation2_sifbios_emul(struct cpu *cpu)
int file_n_executables_loaded(void)
void dreamcast_machine_setup(struct machine *)
unsigned long long mystrtoull(const char *s, char **endp, int base)
int sh_ipl_g_emul(struct cpu *)
int iso_load_bootblock(struct machine *m, struct cpu *cpu, int disk_id, int disk_type, int iso_type, unsigned char *buf, int *n_loadp, char ***load_namesp)
size_t mystrlcpy(char *dst, const char *src, size_t size)
void yamon_machine_setup(struct machine *machine, uint64_t env)
int mymkstemp(char *templ)
int decstation_prom_emul(struct cpu *cpu)
void file_load(struct machine *machine, struct memory *mem, char *filename, uint64_t *entrypointp, int arch, uint64_t *gpp, int *byte_order, uint64_t *tocp)
void debug_indentation(int diff)
void dreamcast_emul(struct cpu *cpu)
int apple_load_bootblock(struct machine *m, struct cpu *cpu, int disk_id, int disk_type, int *n_loadp, char ***load_namesp)
int mvmeprom_emul(struct cpu *cpu)
size_t mystrlcat(char *dst, const char *src, size_t size)
void mvmeprom_init(struct machine *machine)
int luna88kprom_emul(struct cpu *cpu)
void luna88kprom_init(struct machine *machine)
void dreamcast_descramble(char *from, char *to)