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 2 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, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 #include "emul_generic.h"
30 #include "emul_netbsd.h"
31 #include "emul_unix.h"
32 #include "emul_chirp.h"
33 #include "emul_bugapi.h"
35 static const os_emul
*(os_emulations
[]) = {
47 os_emul_create(const char *file_name
,
50 const char *emulation_name
= NULL
;
52 os_emul
*chosen_emulation
= NULL
;
54 bfd_init(); /* would never hurt */
57 image
= bfd_openr(file_name
, NULL
);
59 bfd_perror(file_name
);
60 error("nothing loaded\n");
63 /* check it is an executable */
64 if (!bfd_check_format(image
, bfd_object
)) {
66 ("FIXME - should check more than just bfd_check_format\n"));
68 ("%s not an executable, assumeing a device file\n", file_name
));
73 /* if a device file, load that before trying the emulations on */
75 psim_merge_device_file(root
, file_name
);
78 /* see if the device tree already specifies the required emulation */
79 if (tree_find_property(root
, "/openprom/options/os-emul") != NULL
)
81 tree_find_string_property(root
, "/openprom/options/os-emul");
83 emulation_name
= NULL
;
85 /* go through each emulation to see if they reconize it. FIXME -
86 should have some sort of imported table from a separate file */
88 os_emul_data
*emul_data
;
89 const os_emul
**possible_emulation
;
90 chosen_emulation
= NULL
;
91 for (possible_emulation
= os_emulations
, emul_data
= NULL
;
92 *possible_emulation
!= NULL
&& emul_data
== NULL
;
93 possible_emulation
++) {
94 emul_data
= (*possible_emulation
)->create(root
,
97 if (emul_data
!= NULL
) {
98 chosen_emulation
= ZALLOC(os_emul
);
99 *chosen_emulation
= **possible_emulation
;
100 chosen_emulation
->data
= emul_data
;
108 return chosen_emulation
;
113 os_emul_init(os_emul
*emulation
,
116 if (emulation
!= (os_emul
*)0)
117 emulation
->init(emulation
->data
, nr_cpus
);
122 os_emul_system_call(cpu
*processor
,
125 os_emul
*emulation
= cpu_os_emulation(processor
);
126 if (emulation
!= (os_emul
*)0 && emulation
->system_call
!= 0)
127 emulation
->system_call(processor
, cia
, emulation
->data
);
129 error("System call emulation not available\n");
134 os_emul_instruction_call(cpu
*processor
,
138 os_emul
*emulation
= cpu_os_emulation(processor
);
139 if (emulation
!= (os_emul
*)0 && emulation
->instruction_call
!= 0)
140 return emulation
->instruction_call(processor
, cia
, ra
, emulation
->data
);
146 #endif /* _OS_EMUL_C_ */
This page took 0.037333 seconds and 4 git commands to generate.