1/* Module support. 2 Copyright (C) 1996, 1997, 2007, 2008, 2009, 2010, 2011 3 Free Software Foundation, Inc. 4 Contributed by Cygnus Support. 5 6This file is part of GDB, the GNU debugger. 7 8This program is free software; you can redistribute it and/or modify 9it under the terms of the GNU General Public License as published by 10the Free Software Foundation; either version 3 of the License, or 11(at your option) any later version. 12 13This program is distributed in the hope that it will be useful, 14but WITHOUT ANY WARRANTY; without even the implied warranty of 15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16GNU General Public License for more details. 17 18You should have received a copy of the GNU General Public License 19along with this program. If not, see <http://www.gnu.org/licenses/>. */ 20 21/* This file is intended to be included by sim-base.h. */ 22 23#ifndef SIM_MODULES_H 24#define SIM_MODULES_H 25 26/* Modules are addons to the simulator that perform a specific function 27 (e.g. tracing, profiling, memory subsystem, etc.). Some modules are 28 builtin, and others are added at configure time. The intent is to 29 provide a uniform framework for all of the pieces that make up the 30 simulator. 31 32 TODO: Add facilities for saving/restoring state to/from a file. */ 33 34 35/* Various function types. */ 36 37typedef SIM_RC (MODULE_INSTALL_FN) (SIM_DESC); 38typedef SIM_RC (MODULE_INIT_FN) (SIM_DESC); 39typedef SIM_RC (MODULE_RESUME_FN) (SIM_DESC); 40typedef SIM_RC (MODULE_SUSPEND_FN) (SIM_DESC); 41typedef void (MODULE_UNINSTALL_FN) (SIM_DESC); 42typedef void (MODULE_INFO_FN) (SIM_DESC, int); 43 44 45/* Lists of installed handlers. */ 46 47typedef struct module_init_list { 48 struct module_init_list *next; 49 MODULE_INIT_FN *fn; 50} MODULE_INIT_LIST; 51 52typedef struct module_resume_list { 53 struct module_resume_list *next; 54 MODULE_RESUME_FN *fn; 55} MODULE_RESUME_LIST; 56 57typedef struct module_suspend_list { 58 struct module_suspend_list *next; 59 MODULE_SUSPEND_FN *fn; 60} MODULE_SUSPEND_LIST; 61 62typedef struct module_uninstall_list { 63 struct module_uninstall_list *next; 64 MODULE_UNINSTALL_FN *fn; 65} MODULE_UNINSTALL_LIST; 66 67typedef struct module_info_list { 68 struct module_info_list *next; 69 MODULE_INFO_FN *fn; 70} MODULE_INFO_LIST; 71 72 73/* Functions to register module with various handler lists */ 74 75SIM_RC sim_module_install (SIM_DESC); 76void sim_module_uninstall (SIM_DESC); 77void sim_module_add_init_fn (SIM_DESC sd, MODULE_INIT_FN fn); 78void sim_module_add_resume_fn (SIM_DESC sd, MODULE_RESUME_FN fn); 79void sim_module_add_suspend_fn (SIM_DESC sd, MODULE_SUSPEND_FN fn); 80void sim_module_add_uninstall_fn (SIM_DESC sd, MODULE_UNINSTALL_FN fn); 81void sim_module_add_info_fn (SIM_DESC sd, MODULE_INFO_FN fn); 82 83 84/* Initialize installed modules before argument processing. 85 Called by sim_open. */ 86SIM_RC sim_pre_argv_init (SIM_DESC sd, const char *myname); 87 88/* Initialize installed modules after argument processing. 89 Called by sim_open. */ 90SIM_RC sim_post_argv_init (SIM_DESC sd); 91 92/* Re-initialize the module. Called by sim_create_inferior. */ 93SIM_RC sim_module_init (SIM_DESC sd); 94 95/* Suspend/resume modules. Called by sim_run or sim_resume */ 96SIM_RC sim_module_suspend (SIM_DESC sd); 97SIM_RC sim_module_resume (SIM_DESC sd); 98 99/* Report general information on module */ 100void sim_module_info (SIM_DESC sd, int verbose); 101 102 103/* Module private data */ 104 105struct module_list { 106 107 /* List of installed module `init' handlers */ 108 MODULE_INIT_LIST *init_list; 109 110 /* List of installed module `uninstall' handlers. */ 111 MODULE_UNINSTALL_LIST *uninstall_list; 112 113 /* List of installed module `resume' handlers. */ 114 MODULE_RESUME_LIST *resume_list; 115 116 /* List of installed module `suspend' handlers. */ 117 MODULE_SUSPEND_LIST *suspend_list; 118 119 /* List of installed module `info' handlers. */ 120 MODULE_INFO_LIST *info_list; 121 122}; 123 124 125#endif /* SIM_MODULES_H */ 126