2 Copyright (C) 1996, 1997 Free Software Foundation, Inc.
3 Contributed by Cygnus Support.
5 This file is part of GDB, the GNU debugger.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
23 #include "sim-options.h"
25 /* List of all modules. */
26 static MODULE_INSTALL_FN
* const modules
[] = {
34 #ifdef SIM_HAVE_MODEL /* FIXME: temporary */
37 /* Configured in [simulator specific] additional modules. */
44 /* Functions called from sim_open. */
46 /* Initialize common parts before argument processing. */
49 sim_pre_argv_init (SIM_DESC sd
, const char *myname
)
51 STATE_MY_NAME (sd
) = myname
+ strlen (myname
);
52 while (STATE_MY_NAME (sd
) > myname
&& STATE_MY_NAME (sd
)[-1] != '/')
55 /* Install all configured in modules. */
56 if (sim_module_install (sd
) != SIM_RC_OK
)
62 /* Initialize common parts after argument processing. */
65 sim_post_argv_init (SIM_DESC sd
)
69 if (sim_module_init (sd
) != SIM_RC_OK
)
72 /* Set the cpu->state backlinks for each cpu. */
73 for (i
= 0; i
< MAX_NR_PROCESSORS
; ++i
)
74 CPU_STATE (STATE_CPU (sd
, i
)) = sd
;
79 /* Install all modules. */
82 sim_module_install (SIM_DESC sd
)
84 MODULE_INSTALL_FN
* const *modp
;
86 for (modp
= modules
; *modp
!= NULL
; ++modp
)
88 if ((*modp
) (sd
) != SIM_RC_OK
)
94 /* Called after all modules have been installed and after argv
95 has been processed. */
98 sim_module_init (SIM_DESC sd
)
100 MODULE_INIT_LIST
*modp
;
102 for (modp
= STATE_INIT_LIST (sd
); modp
!= NULL
; modp
= modp
->next
)
104 if ((*modp
->fn
) (sd
) != SIM_RC_OK
)
110 /* Uninstall installed modules, called by sim_close. */
113 sim_module_uninstall (SIM_DESC sd
)
115 MODULE_UNINSTALL_LIST
*modp
;
117 /* Uninstall the modules. */
118 for (modp
= STATE_UNINSTALL_LIST (sd
); modp
!= NULL
; modp
= modp
->next
)
122 /* Add FN to the init handler list. */
125 sim_module_add_init_fn (SIM_DESC sd
, MODULE_INIT_FN fn
)
127 MODULE_INIT_LIST
*l
=
128 (MODULE_INIT_LIST
*) xmalloc (sizeof (MODULE_INIT_LIST
));
131 l
->next
= STATE_INIT_LIST (sd
);
132 STATE_INIT_LIST (sd
) = l
;
135 /* Add FN to the uninstall handler list. */
138 sim_module_add_uninstall_fn (SIM_DESC sd
, MODULE_UNINSTALL_FN fn
)
140 MODULE_UNINSTALL_LIST
*l
=
141 (MODULE_UNINSTALL_LIST
*) xmalloc (sizeof (MODULE_UNINSTALL_LIST
));
144 l
->next
= STATE_UNINSTALL_LIST (sd
);
145 STATE_UNINSTALL_LIST (sd
) = l
;