#ifndef _EMUL_GENERIC_H_
#define _EMUL_GENERIC_H_
#include "cpu.h"
#include "idecode.h"
#include "os_emul.h"
#include "tree.h"
#include "bfd.h"
#ifndef INLINE_EMUL_GENERIC
#define INLINE_EMUL_GENERIC
#endif
enum {
emul_call_instruction = 0x1,
emul_loop_instruction = 0x48000000,
emul_rfi_instruction = 0x4c000064,
emul_blr_instruction = 0x4e800020,
};
typedef struct _os_emul_data os_emul_data;
typedef os_emul_data *(os_emul_create_handler)
(device *tree,
bfd *image,
const char *emul_name);
typedef void (os_emul_init_handler)
(os_emul_data *emul_data,
int nr_cpus);
typedef void (os_emul_system_call_handler)
(cpu *processor,
unsigned_word cia,
os_emul_data *emul_data);
typedef int (os_emul_instruction_call_handler)
(cpu *processor,
unsigned_word cia,
unsigned_word ra,
os_emul_data *emul_data);
struct _os_emul {
const char *name;
os_emul_create_handler *create;
os_emul_init_handler *init;
os_emul_system_call_handler *system_call;
os_emul_instruction_call_handler *instruction_call;
os_emul_data *data;
};
typedef struct _emul_syscall emul_syscall;
typedef struct _emul_syscall_descriptor emul_syscall_descriptor;
typedef void (emul_syscall_handler)
(os_emul_data *emul_data,
unsigned call,
const int arg0,
cpu *processor,
unsigned_word cia);
struct _emul_syscall_descriptor {
emul_syscall_handler *handler;
const char *name;
};
struct _emul_syscall {
emul_syscall_descriptor *syscall_descriptor;
int nr_system_calls;
char **error_names;
int nr_error_names;
char **signal_names;
int nr_signal_names;
};
INLINE_EMUL_GENERIC void emul_do_system_call
(os_emul_data *emul_data,
emul_syscall *syscall,
unsigned call,
const int arg0,
cpu *processor,
unsigned_word cia);
INLINE_EMUL_GENERIC unsigned64 emul_read_gpr64
(cpu *processor,
int g);
INLINE_EMUL_GENERIC void emul_write_gpr64
(cpu *processor,
int g,
unsigned64 val);
INLINE_EMUL_GENERIC void emul_write_status
(cpu *processor,
int status,
int errno);
INLINE_EMUL_GENERIC void emul_write2_status
(cpu *processor,
int status1,
int status2,
int errno);
INLINE_EMUL_GENERIC char *emul_read_string
(char *dest,
unsigned_word addr,
unsigned nr_bytes,
cpu *processor,
unsigned_word cia);
INLINE_EMUL_GENERIC unsigned_word emul_read_word
(unsigned_word addr,
cpu *processor,
unsigned_word cia);
INLINE_EMUL_GENERIC void emul_write_word
(unsigned_word addr,
unsigned_word buf,
cpu *processor,
unsigned_word cia);
INLINE_EMUL_GENERIC void emul_read_buffer
(void *dest,
unsigned_word addr,
unsigned nr_bytes,
cpu *processor,
unsigned_word cia);
INLINE_EMUL_GENERIC void emul_write_buffer
(const void *source,
unsigned_word addr,
unsigned nr_bytes,
cpu *processor,
unsigned_word cia);
INLINE_EMUL_GENERIC void emul_add_tree_options
(device *tree,
bfd *image,
const char *emul,
const char *env,
int oea_interrupt_prefix);
INLINE_EMUL_GENERIC void emul_add_tree_hardware
(device *tree);
#endif