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/>.
28 #include "emul_generic.h"
29 #include "emul_netbsd.h"
30 #include "emul_unix.h"
31 #include "emul_chirp.h"
32 #include "emul_bugapi.h"
34 static const os_emul
*(os_emulations
[]) = {
46 os_emul_create(const char *file_name
,
49 const char *emulation_name
= NULL
;
51 os_emul
*chosen_emulation
= NULL
;
53 bfd_init(); /* would never hurt */
56 image
= bfd_openr(file_name
, NULL
);
58 bfd_perror(file_name
);
59 error("nothing loaded\n");
62 /* check it is an executable */
63 if (!bfd_check_format(image
, bfd_object
)) {
65 ("FIXME - should check more than just bfd_check_format\n"));
67 ("%s not an executable, assumeing a device file\n", file_name
));
72 /* if a device file, load that before trying the emulations on */
74 psim_merge_device_file(root
, file_name
);
77 /* see if the device tree already specifies the required emulation */
78 if (tree_find_property(root
, "/openprom/options/os-emul") != NULL
)
80 tree_find_string_property(root
, "/openprom/options/os-emul");
82 emulation_name
= NULL
;
84 /* go through each emulation to see if they reconize it. FIXME -
85 should have some sort of imported table from a separate file */
87 os_emul_data
*emul_data
;
88 const os_emul
**possible_emulation
;
89 chosen_emulation
= NULL
;
90 for (possible_emulation
= os_emulations
, emul_data
= NULL
;
91 *possible_emulation
!= NULL
&& emul_data
== NULL
;
92 possible_emulation
++) {
93 emul_data
= (*possible_emulation
)->create(root
,
96 if (emul_data
!= NULL
) {
97 chosen_emulation
= ZALLOC(os_emul
);
98 *chosen_emulation
= **possible_emulation
;
99 chosen_emulation
->data
= emul_data
;
107 return chosen_emulation
;
112 os_emul_init(os_emul
*emulation
,
115 if (emulation
!= (os_emul
*)0)
116 emulation
->init(emulation
->data
, nr_cpus
);
121 os_emul_system_call(cpu
*processor
,
124 os_emul
*emulation
= cpu_os_emulation(processor
);
125 if (emulation
!= (os_emul
*)0 && emulation
->system_call
!= 0)
126 emulation
->system_call(processor
, cia
, emulation
->data
);
128 error("System call emulation not available\n");
133 os_emul_instruction_call(cpu
*processor
,
137 os_emul
*emulation
= cpu_os_emulation(processor
);
138 if (emulation
!= (os_emul
*)0 && emulation
->instruction_call
!= 0)
139 return emulation
->instruction_call(processor
, cia
, ra
, emulation
->data
);
145 #endif /* _OS_EMUL_C_ */
This page took 0.032552 seconds and 4 git commands to generate.