1 /* This file is part of the program psim.
3 Copyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #ifndef _EMUL_GENERIC_H_
22 #define _EMUL_GENERIC_H_
32 #ifndef INLINE_EMUL_GENERIC
33 #define INLINE_EMUL_GENERIC
36 /* various PowerPC instructions for writing into memory */
38 emul_call_instruction = 0x1,
39 emul_loop_instruction = 0x48000000, /* branch to . */
40 emul_rfi_instruction = 0x4c000064,
41 emul_blr_instruction = 0x4e800020,
45 /* emulation specific data */
47 typedef struct _os_emul_data os_emul_data;
49 typedef os_emul_data *(os_emul_create_handler)
52 const char *emul_name);
53 typedef void (os_emul_init_handler)
54 (os_emul_data *emul_data,
56 typedef void (os_emul_system_call_handler)
59 os_emul_data *emul_data);
60 typedef int (os_emul_instruction_call_handler)
64 os_emul_data *emul_data);
68 os_emul_create_handler *create;
69 os_emul_init_handler *init;
70 os_emul_system_call_handler *system_call;
71 os_emul_instruction_call_handler *instruction_call;
76 /* One class of emulation - system call is pretty general, provide a
77 common template for implementing this */
79 typedef struct _emul_syscall emul_syscall;
80 typedef struct _emul_syscall_descriptor emul_syscall_descriptor;
82 typedef void (emul_syscall_handler)
83 (os_emul_data *emul_data,
89 struct _emul_syscall_descriptor {
90 emul_syscall_handler *handler;
94 struct _emul_syscall {
95 emul_syscall_descriptor *syscall_descriptor;
104 INLINE_EMUL_GENERIC void emul_do_system_call
105 (os_emul_data *emul_data,
106 emul_syscall *syscall,
113 INLINE_EMUL_GENERIC unsigned64 emul_read_gpr64
117 INLINE_EMUL_GENERIC void emul_write_gpr64
122 INLINE_EMUL_GENERIC void emul_write_status
127 INLINE_EMUL_GENERIC void emul_write2_status
133 INLINE_EMUL_GENERIC char *emul_read_string
140 INLINE_EMUL_GENERIC unsigned_word emul_read_word
145 INLINE_EMUL_GENERIC void emul_write_word
151 INLINE_EMUL_GENERIC void emul_read_buffer
158 INLINE_EMUL_GENERIC void emul_write_buffer
165 /* Simplify the construction of device trees */
167 INLINE_EMUL_GENERIC void emul_add_tree_options
172 int oea_interrupt_prefix);
174 INLINE_EMUL_GENERIC void emul_add_tree_hardware
177 #endif /* _EMUL_GENERIC_H_ */