1 /* 2 * Simulator of microcontrollers (sim.src/hwcl.h) 3 * 4 * Copyright (C) 1999,99 Drotos Daniel, Talker Bt. 5 * 6 * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu 7 * 8 */ 9 10 /* This file is part of microcontroller simulator: ucsim. 11 12 UCSIM is free software; you can redistribute it and/or modify 13 it under the terms of the GNU General Public License as published by 14 the Free Software Foundation; either version 2 of the License, or 15 (at your option) any later version. 16 17 UCSIM is distributed in the hope that it will be useful, 18 but WITHOUT ANY WARRANTY; without even the implied warranty of 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 GNU General Public License for more details. 21 22 You should have received a copy of the GNU General Public License 23 along with UCSIM; see the file COPYING. If not, write to the Free 24 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 25 02111-1307, USA. */ 26 /*@1@*/ 27 28 /* Abstract hw element. It can be a timer, serial line or whatever */ 29 30 #ifndef SIM_HWCL_HEADER 31 #define SIM_HWCL_HEADER 32 33 #include "stypes.h" 34 #include "pobjcl.h" 35 #include "guiobjcl.h" 36 37 // cmd.src 38 #include "newcmdcl.h" 39 #include "newcmdposixcl.h" 40 41 // local 42 #include "memcl.h" 43 #include "uccl.h" 44 45 46 class cl_hw; 47 48 class cl_hw_io: public cl_console 49 { 50 protected: 51 class cl_hw *hw; 52 public: 53 cl_hw_io(class cl_hw *ihw); 54 virtual int init(void); 55 56 virtual int proc_input(class cl_cmdset *cmdset); prevent_quit(void)57 virtual bool prevent_quit(void) { return get_fin() && get_fin()->tty; } print_prompt(void)58 virtual void print_prompt(void) {} 59 60 virtual void convert2console(void); 61 virtual void pass2hw(class cl_hw *new_hw); 62 }; 63 64 65 class cl_hw: public cl_guiobj 66 { 67 public: 68 int flags; 69 class cl_uc *uc; 70 enum hw_cath cathegory; 71 int id; 72 const char *id_string; 73 bool on; 74 protected: 75 class cl_list *partners; 76 class cl_address_space *cfg; 77 class cl_hw_io *io; 78 int cache_run; 79 unsigned int cache_time; 80 public: 81 cl_hw(class cl_uc *auc, enum hw_cath cath, int aid, const char *aid_string); 82 virtual ~cl_hw(void); 83 84 virtual int init(void); cfg_size(void)85 virtual int cfg_size(void) { return 1; } 86 87 virtual void new_hw_adding(class cl_hw *new_hw); 88 virtual void new_hw_added(class cl_hw *new_hw); added_to_uc(void)89 virtual void added_to_uc(void) {} 90 virtual class cl_hw *make_partner(enum hw_cath cath, int id); 91 92 virtual t_mem read(class cl_memory_cell *cell); 93 virtual void write(class cl_memory_cell *cell, t_mem *val); 94 virtual bool conf(class cl_memory_cell *cell, t_mem *val); 95 virtual t_mem conf_op(cl_memory_cell *cell, t_addr addr, t_mem *val); 96 virtual void cfg_set(t_addr addr, t_mem val); 97 virtual void cfg_write(t_addr addr, t_mem val); 98 virtual t_mem cfg_get(t_addr addr); 99 virtual t_mem cfg_read(t_addr addr); 100 virtual char *cfg_help(t_addr addr); 101 102 virtual void set_cmd(class cl_cmdline *cmdline, class cl_console_base *con); 103 virtual class cl_memory_cell *register_cell(class cl_address_space *mem, 104 t_addr addr); 105 virtual class cl_memory_cell *register_cell(class cl_memory_cell *cell); 106 virtual void unregister_cell(class cl_memory_cell *cell); 107 108 virtual int tick(int cycles); reset(void)109 virtual void reset(void) {} happen(class cl_hw *,enum hw_event,void *)110 virtual void happen(class cl_hw * /*where*/, enum hw_event /*he*/, 111 void * /*params*/) {} 112 virtual void inform_partners(enum hw_event he, void *params); 113 virtual void touch(void); 114 115 virtual void make_io(void); 116 virtual void new_io(class cl_f *f_in, class cl_f *f_out); 117 virtual void new_i(class cl_f *f_in); 118 virtual void new_o(class cl_f *f_out); 119 virtual cl_hw_io *get_io(void); 120 virtual bool proc_input(void); 121 virtual bool handle_input(int c); 122 virtual void refresh_display(bool force); 123 virtual void draw_display(void); 124 virtual cl_hw *next_displayer(void); 125 126 virtual void print_info(class cl_console_base *con); 127 virtual void print_cfg_info(class cl_console_base *con); 128 }; 129 130 class cl_hws: public cl_list 131 { 132 public: cl_hws(void)133 cl_hws(void): cl_list(2, 2, cchars("hws")) {} 134 virtual t_index add(void *item); 135 virtual cl_hw *next_displayer(class cl_hw *hw); 136 }; 137 138 139 class cl_partner_hw: public cl_base 140 { 141 protected: 142 class cl_uc *uc; 143 enum hw_cath cathegory; 144 int id; 145 class cl_hw *partner; 146 public: 147 cl_partner_hw(class cl_uc *auc, enum hw_cath cath, int aid); 148 149 virtual class cl_hw *get_partner(void); 150 virtual void refresh(void); 151 virtual void refresh(class cl_hw *new_hw); 152 153 virtual void happen(class cl_hw *where, enum hw_event he, void *params); 154 }; 155 156 157 #endif 158 159 /* End of hwcl.h */ 160