1 |
2 |
alfik |
/////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// $Id: paramtree.h 11655 2013-03-17 17:16:45Z vruppert $
|
3 |
|
|
/////////////////////////////////////////////////////////////////////////
|
4 |
|
|
//
|
5 |
|
|
// Copyright (C) 2010-2013 The Bochs Project
|
6 |
|
|
//
|
7 |
|
|
// This library is free software; you can redistribute it and/or
|
8 |
|
|
// modify it under the terms of the GNU Lesser General Public
|
9 |
|
|
// License as published by the Free Software Foundation; either
|
10 |
|
|
// version 2 of the License, or (at your option) any later version.
|
11 |
|
|
//
|
12 |
|
|
// This library 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 GNU
|
15 |
|
|
// Lesser General Public License for more details.
|
16 |
|
|
//
|
17 |
|
|
// You should have received a copy of the GNU Lesser General Public
|
18 |
|
|
// License along with this library; if not, write to the Free Software
|
19 |
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
20 |
|
|
//
|
21 |
|
|
/////////////////////////////////////////////////////////////////////////
|
22 |
|
|
|
23 |
|
|
#ifndef BX_PARAM_TREE_H
|
24 |
|
|
#define BX_PARAM_TREE_H
|
25 |
|
|
|
26 |
|
|
////////////////////////////////////////////////////////////////////
|
27 |
|
|
// parameter classes: bx_param_c and family
|
28 |
|
|
////////////////////////////////////////////////////////////////////
|
29 |
|
|
//
|
30 |
|
|
// All variables that can be configured through the CI are declared as
|
31 |
|
|
// "parameters" or objects of type bx_param_*. There is a bx_param_*
|
32 |
|
|
// class for each type of data that the user would need to see and
|
33 |
|
|
// edit, e.g. integer, boolean, enum, string, filename, or list of
|
34 |
|
|
// other parameters. The purpose of the bx_param_* class, in addition
|
35 |
|
|
// to storing the parameter's value, is to hold the name, description,
|
36 |
|
|
// and constraints on the value. The bx_param_* class should hold
|
37 |
|
|
// everything that the CI would need to display the value and allow
|
38 |
|
|
// the user to modify it. For integer parameters, the minimum and
|
39 |
|
|
// maximum allowed value can be defined, and the base in which it
|
40 |
|
|
// should be displayed and interpreted. For enums, the
|
41 |
|
|
// bx_param_enum_c structure includes the list of values which the
|
42 |
|
|
// parameter can have.
|
43 |
|
|
//
|
44 |
|
|
// Also, some parameter classes support get/set callback functions to
|
45 |
|
|
// allow arbitrary code to be executed when the parameter is get/set.
|
46 |
|
|
// An example of where this is useful: if you disable the NE2K card,
|
47 |
|
|
// the set() handler for that parameter can tell the user interface
|
48 |
|
|
// that the NE2K's irq, I/O address, and mac address should be
|
49 |
|
|
// disabled (greyed out, hidden, or made inaccessible). The get/set
|
50 |
|
|
// methods can also check if the set() value is acceptable using
|
51 |
|
|
// whatever means and override it.
|
52 |
|
|
//
|
53 |
|
|
// The parameter concept is similar to the use of parameters in JavaBeans.
|
54 |
|
|
|
55 |
|
|
// list of possible types for bx_param_c and descendant objects
|
56 |
|
|
typedef enum {
|
57 |
|
|
BXT_OBJECT = 201,
|
58 |
|
|
BXT_PARAM,
|
59 |
|
|
BXT_PARAM_NUM,
|
60 |
|
|
BXT_PARAM_BOOL,
|
61 |
|
|
BXT_PARAM_ENUM,
|
62 |
|
|
BXT_PARAM_STRING,
|
63 |
|
|
BXT_PARAM_DATA,
|
64 |
|
|
BXT_PARAM_FILEDATA,
|
65 |
|
|
BXT_LIST
|
66 |
|
|
} bx_objtype;
|
67 |
|
|
|
68 |
|
|
class bx_object_c;
|
69 |
|
|
class bx_param_c;
|
70 |
|
|
class bx_param_num_c;
|
71 |
|
|
class bx_param_enum_c;
|
72 |
|
|
class bx_param_bool_c;
|
73 |
|
|
class bx_param_string_c;
|
74 |
|
|
class bx_param_filename_c;
|
75 |
|
|
class bx_list_c;
|
76 |
|
|
|
77 |
|
|
class BOCHSAPI bx_object_c {
|
78 |
|
|
private:
|
79 |
|
|
Bit32u id;
|
80 |
|
|
bx_objtype type;
|
81 |
|
|
protected:
|
82 |
|
|
void set_type(bx_objtype _type) { type = _type; }
|
83 |
|
|
public:
|
84 |
|
|
bx_object_c(Bit32u _id): id(_id), type(BXT_OBJECT) {}
|
85 |
|
|
virtual ~bx_object_c() {}
|
86 |
|
|
Bit32u get_id() const { return id; }
|
87 |
|
|
Bit8u get_type() const { return type; }
|
88 |
|
|
};
|
89 |
|
|
|
90 |
|
|
#define BASE_DEC 10
|
91 |
|
|
#define BASE_HEX 16
|
92 |
|
|
|
93 |
|
|
class BOCHSAPI bx_param_c : public bx_object_c {
|
94 |
|
|
BOCHSAPI_CYGONLY static const char *default_text_format;
|
95 |
|
|
protected:
|
96 |
|
|
bx_list_c *parent;
|
97 |
|
|
char *name;
|
98 |
|
|
char *description;
|
99 |
|
|
char *label; // label string for text menus and gui dialogs
|
100 |
|
|
const char *text_format; // printf format string. %d for ints, %s for strings, etc.
|
101 |
|
|
const char *long_text_format; // printf format string. %d for ints, %s for strings, etc.
|
102 |
|
|
char *ask_format; // format string for asking for a new value
|
103 |
|
|
char *group_name; // name of the group the param belongs to
|
104 |
|
|
int runtime_param;
|
105 |
|
|
int enabled;
|
106 |
|
|
Bit32u options;
|
107 |
|
|
// The dependent_list is initialized to NULL. If dependent_list is modified
|
108 |
|
|
// to point to a bx_list_c of other parameters, the set() method of the
|
109 |
|
|
// parameter type will enable those parameters when the enable condition is
|
110 |
|
|
// true, and disable them it is false.
|
111 |
|
|
bx_list_c *dependent_list;
|
112 |
|
|
void *device;
|
113 |
|
|
public:
|
114 |
|
|
enum {
|
115 |
|
|
// If set, this parameter is available in CI only. In bochsrc, it is set
|
116 |
|
|
// indirectly from one or more other options (e.g. cpu count)
|
117 |
|
|
CI_ONLY = (1<<31)
|
118 |
|
|
} bx_param_opt_bits;
|
119 |
|
|
bx_param_c(Bit32u id, const char *name, const char *description);
|
120 |
|
|
bx_param_c(Bit32u id, const char *name, const char *label, const char *description);
|
121 |
|
|
virtual ~bx_param_c();
|
122 |
|
|
bx_param_c *get_parent() { return (bx_param_c *) parent; }
|
123 |
|
|
int get_param_path(char *path_out, int maxlen);
|
124 |
|
|
void set_format(const char *format) {text_format = format;}
|
125 |
|
|
const char *get_format() const {return text_format;}
|
126 |
|
|
void set_long_format(const char *format) {long_text_format = format;}
|
127 |
|
|
const char *get_long_format() const {return long_text_format;}
|
128 |
|
|
void set_ask_format(const char *format);
|
129 |
|
|
const char *get_ask_format() const {return ask_format;}
|
130 |
|
|
void set_label(const char *text);
|
131 |
|
|
void set_description(const char *text);
|
132 |
|
|
const char *get_label() const {return label;}
|
133 |
|
|
void set_runtime_param(int val) { runtime_param = val; }
|
134 |
|
|
int get_runtime_param() { return runtime_param; }
|
135 |
|
|
void set_group(const char *group);
|
136 |
|
|
const char *get_group() const {return group_name;}
|
137 |
|
|
const char *get_name() const { return name; }
|
138 |
|
|
const char *get_description() const { return description; }
|
139 |
|
|
int get_enabled() const { return enabled; }
|
140 |
|
|
virtual void set_enabled(int enabled) { this->enabled = enabled; }
|
141 |
|
|
virtual void reset() {}
|
142 |
|
|
int getint() const {return -1;}
|
143 |
|
|
static const char* set_default_format(const char *f);
|
144 |
|
|
static const char *get_default_format() { return default_text_format; }
|
145 |
|
|
bx_list_c *get_dependent_list() { return dependent_list; }
|
146 |
|
|
void set_options(Bit32u options) { this->options = options; }
|
147 |
|
|
Bit32u get_options() const { return options; }
|
148 |
|
|
void set_device_param(void *dev) { device = dev; }
|
149 |
|
|
void *get_device_param() { return device; }
|
150 |
|
|
#if BX_USE_TEXTCONFIG
|
151 |
|
|
virtual void text_print(FILE *fp) {}
|
152 |
|
|
virtual int text_ask(FILE *fpin, FILE *fpout) {return -1;}
|
153 |
|
|
#endif
|
154 |
|
|
};
|
155 |
|
|
|
156 |
|
|
typedef Bit64s (*param_event_handler)(class bx_param_c *, int set, Bit64s val);
|
157 |
|
|
typedef Bit64s (*param_save_handler)(void *devptr, class bx_param_c *);
|
158 |
|
|
typedef void (*param_restore_handler)(void *devptr, class bx_param_c *, Bit64s val);
|
159 |
|
|
typedef int (*param_enable_handler)(class bx_param_c *, int en);
|
160 |
|
|
|
161 |
|
|
class BOCHSAPI bx_param_num_c : public bx_param_c {
|
162 |
|
|
BOCHSAPI_CYGONLY static Bit32u default_base;
|
163 |
|
|
void update_dependents();
|
164 |
|
|
protected:
|
165 |
|
|
Bit64s min, max, initial_val;
|
166 |
|
|
union _uval_ {
|
167 |
|
|
Bit64s number; // used by bx_param_num_c
|
168 |
|
|
Bit64s *p64bit; // used by bx_shadow_num_c
|
169 |
|
|
Bit32s *p32bit; // used by bx_shadow_num_c
|
170 |
|
|
Bit16s *p16bit; // used by bx_shadow_num_c
|
171 |
|
|
Bit8s *p8bit; // used by bx_shadow_num_c
|
172 |
|
|
bx_bool *pbool; // used by bx_shadow_bool_c
|
173 |
|
|
} val;
|
174 |
|
|
param_event_handler handler;
|
175 |
|
|
void *sr_devptr;
|
176 |
|
|
param_save_handler save_handler;
|
177 |
|
|
param_restore_handler restore_handler;
|
178 |
|
|
param_enable_handler enable_handler;
|
179 |
|
|
int base;
|
180 |
|
|
bx_bool is_shadow;
|
181 |
|
|
public:
|
182 |
|
|
enum {
|
183 |
|
|
// When a bx_param_num_c is displayed in dialog, USE_SPIN_CONTROL controls
|
184 |
|
|
// whether a spin control should be used instead of a simple text control.
|
185 |
|
|
USE_SPIN_CONTROL = (1<<0)
|
186 |
|
|
} bx_numopt_bits;
|
187 |
|
|
bx_param_num_c(bx_param_c *parent,
|
188 |
|
|
const char *name,
|
189 |
|
|
const char *label,
|
190 |
|
|
const char *description,
|
191 |
|
|
Bit64s min, Bit64s max, Bit64s initial_val,
|
192 |
|
|
bx_bool is_shadow = 0);
|
193 |
|
|
virtual void reset() { val.number = initial_val; }
|
194 |
|
|
void set_handler(param_event_handler handler);
|
195 |
|
|
void set_sr_handlers(void *devptr, param_save_handler save, param_restore_handler restore);
|
196 |
|
|
void set_enable_handler(param_enable_handler handler) { enable_handler = handler; }
|
197 |
|
|
void set_dependent_list(bx_list_c *l);
|
198 |
|
|
virtual void set_enabled(int enabled);
|
199 |
|
|
virtual Bit32s get() { return (Bit32s) get64(); }
|
200 |
|
|
virtual Bit64s get64();
|
201 |
|
|
virtual void set(Bit64s val);
|
202 |
|
|
void set_base(int base) { this->base = base; }
|
203 |
|
|
void set_initial_val(Bit64s initial_val);
|
204 |
|
|
int get_base() const { return base; }
|
205 |
|
|
void set_range(Bit64u min, Bit64u max);
|
206 |
|
|
Bit64s get_min() { return min; }
|
207 |
|
|
Bit64s get_max() { return max; }
|
208 |
|
|
static Bit32u set_default_base(Bit32u val);
|
209 |
|
|
static Bit32u get_default_base() { return default_base; }
|
210 |
|
|
#if BX_USE_TEXTCONFIG
|
211 |
|
|
virtual void text_print(FILE *fp);
|
212 |
|
|
virtual int text_ask(FILE *fpin, FILE *fpout);
|
213 |
|
|
#endif
|
214 |
|
|
};
|
215 |
|
|
|
216 |
|
|
// a bx_shadow_num_c is like a bx_param_num_c except that it doesn't
|
217 |
|
|
// store the actual value with its data. Instead, it uses val.p32bit
|
218 |
|
|
// to keep a pointer to the actual data. This is used to register
|
219 |
|
|
// existing variables as parameters, without having to access it via
|
220 |
|
|
// set/get methods.
|
221 |
|
|
class BOCHSAPI bx_shadow_num_c : public bx_param_num_c {
|
222 |
|
|
Bit8u varsize; // must be 64, 32, 16, or 8
|
223 |
|
|
Bit8u lowbit; // range of bits associated with this param
|
224 |
|
|
Bit64u mask; // mask is ANDed with value before it is returned from get
|
225 |
|
|
public:
|
226 |
|
|
bx_shadow_num_c(bx_param_c *parent,
|
227 |
|
|
const char *name,
|
228 |
|
|
Bit64s *ptr_to_real_val,
|
229 |
|
|
int base = BASE_DEC,
|
230 |
|
|
Bit8u highbit = 63,
|
231 |
|
|
Bit8u lowbit = 0);
|
232 |
|
|
bx_shadow_num_c(bx_param_c *parent,
|
233 |
|
|
const char *name,
|
234 |
|
|
Bit64u *ptr_to_real_val,
|
235 |
|
|
int base = BASE_DEC,
|
236 |
|
|
Bit8u highbit = 63,
|
237 |
|
|
Bit8u lowbit = 0);
|
238 |
|
|
bx_shadow_num_c(bx_param_c *parent,
|
239 |
|
|
const char *name,
|
240 |
|
|
Bit32s *ptr_to_real_val,
|
241 |
|
|
int base = BASE_DEC,
|
242 |
|
|
Bit8u highbit = 31,
|
243 |
|
|
Bit8u lowbit = 0);
|
244 |
|
|
bx_shadow_num_c(bx_param_c *parent,
|
245 |
|
|
const char *name,
|
246 |
|
|
Bit32u *ptr_to_real_val,
|
247 |
|
|
int base = BASE_DEC,
|
248 |
|
|
Bit8u highbit = 31,
|
249 |
|
|
Bit8u lowbit = 0);
|
250 |
|
|
bx_shadow_num_c(bx_param_c *parent,
|
251 |
|
|
const char *name,
|
252 |
|
|
Bit16s *ptr_to_real_val,
|
253 |
|
|
int base = BASE_DEC,
|
254 |
|
|
Bit8u highbit = 15,
|
255 |
|
|
Bit8u lowbit = 0);
|
256 |
|
|
bx_shadow_num_c(bx_param_c *parent,
|
257 |
|
|
const char *name,
|
258 |
|
|
Bit16u *ptr_to_real_val,
|
259 |
|
|
int base = BASE_DEC,
|
260 |
|
|
Bit8u highbit = 15,
|
261 |
|
|
Bit8u lowbit = 0);
|
262 |
|
|
bx_shadow_num_c(bx_param_c *parent,
|
263 |
|
|
const char *name,
|
264 |
|
|
Bit8s *ptr_to_real_val,
|
265 |
|
|
int base = BASE_DEC,
|
266 |
|
|
Bit8u highbit = 7,
|
267 |
|
|
Bit8u lowbit = 0);
|
268 |
|
|
bx_shadow_num_c(bx_param_c *parent,
|
269 |
|
|
const char *name,
|
270 |
|
|
Bit8u *ptr_to_real_val,
|
271 |
|
|
int base = BASE_DEC,
|
272 |
|
|
Bit8u highbit = 7,
|
273 |
|
|
Bit8u lowbit = 0);
|
274 |
|
|
virtual Bit64s get64();
|
275 |
|
|
virtual void set(Bit64s val);
|
276 |
|
|
virtual void reset();
|
277 |
|
|
};
|
278 |
|
|
|
279 |
|
|
class BOCHSAPI bx_param_bool_c : public bx_param_num_c {
|
280 |
|
|
// many boolean variables are used to enable/disable modules. In the
|
281 |
|
|
// user interface, the enable variable should enable/disable all the
|
282 |
|
|
// other parameters associated with that module.
|
283 |
|
|
public:
|
284 |
|
|
bx_param_bool_c(bx_param_c *parent,
|
285 |
|
|
const char *name,
|
286 |
|
|
const char *label,
|
287 |
|
|
const char *description,
|
288 |
|
|
Bit64s initial_val,
|
289 |
|
|
bx_bool is_shadow = 0);
|
290 |
|
|
#if BX_USE_TEXTCONFIG
|
291 |
|
|
virtual void text_print(FILE *fp);
|
292 |
|
|
virtual int text_ask(FILE *fpin, FILE *fpout);
|
293 |
|
|
#endif
|
294 |
|
|
};
|
295 |
|
|
|
296 |
|
|
// a bx_shadow_bool_c is a shadow param based on bx_param_bool_c.
|
297 |
|
|
class BOCHSAPI bx_shadow_bool_c : public bx_param_bool_c {
|
298 |
|
|
// each bit of a bitfield can be a separate value. bitnum tells which
|
299 |
|
|
// bit is used. get/set will only modify that bit.
|
300 |
|
|
Bit8u bitnum;
|
301 |
|
|
public:
|
302 |
|
|
bx_shadow_bool_c(bx_param_c *parent,
|
303 |
|
|
const char *name,
|
304 |
|
|
const char *label,
|
305 |
|
|
bx_bool *ptr_to_real_val,
|
306 |
|
|
Bit8u bitnum = 0);
|
307 |
|
|
bx_shadow_bool_c(bx_param_c *parent,
|
308 |
|
|
const char *name,
|
309 |
|
|
bx_bool *ptr_to_real_val,
|
310 |
|
|
Bit8u bitnum = 0);
|
311 |
|
|
virtual Bit64s get64();
|
312 |
|
|
virtual void set(Bit64s val);
|
313 |
|
|
};
|
314 |
|
|
|
315 |
|
|
|
316 |
|
|
class BOCHSAPI bx_param_enum_c : public bx_param_num_c {
|
317 |
|
|
const char **choices;
|
318 |
|
|
Bit64u *deps_bitmap;
|
319 |
|
|
void update_dependents();
|
320 |
|
|
public:
|
321 |
|
|
bx_param_enum_c(bx_param_c *parent,
|
322 |
|
|
const char *name,
|
323 |
|
|
const char *label,
|
324 |
|
|
const char *description,
|
325 |
|
|
const char **choices,
|
326 |
|
|
Bit64s initial_val,
|
327 |
|
|
Bit64s value_base = 0);
|
328 |
|
|
virtual ~bx_param_enum_c();
|
329 |
|
|
const char *get_choice(int n) { return choices[n]; }
|
330 |
|
|
const char *get_selected() { return choices[val.number - min]; }
|
331 |
|
|
int find_by_name(const char *string);
|
332 |
|
|
virtual void set(Bit64s val);
|
333 |
|
|
bx_bool set_by_name(const char *string);
|
334 |
|
|
void set_dependent_list(bx_list_c *l, bx_bool enable_all);
|
335 |
|
|
void set_dependent_bitmap(Bit64s value, Bit64u bitmap);
|
336 |
|
|
Bit64u get_dependent_bitmap(Bit64s value);
|
337 |
|
|
virtual void set_enabled(int enabled);
|
338 |
|
|
#if BX_USE_TEXTCONFIG
|
339 |
|
|
virtual void text_print(FILE *fp);
|
340 |
|
|
virtual int text_ask(FILE *fpin, FILE *fpout);
|
341 |
|
|
#endif
|
342 |
|
|
};
|
343 |
|
|
|
344 |
|
|
typedef const char* (*param_string_event_handler)(class bx_param_string_c *,
|
345 |
|
|
int set, const char *oldval, const char *newval, int maxlen);
|
346 |
|
|
|
347 |
|
|
class BOCHSAPI bx_param_string_c : public bx_param_c {
|
348 |
|
|
int maxsize;
|
349 |
|
|
char *val, *initial_val;
|
350 |
|
|
param_string_event_handler handler;
|
351 |
|
|
param_enable_handler enable_handler;
|
352 |
|
|
char separator;
|
353 |
|
|
void update_dependents();
|
354 |
|
|
public:
|
355 |
|
|
enum {
|
356 |
|
|
RAW_BYTES = 1, // use binary text editor, like MAC addr
|
357 |
|
|
IS_FILENAME = 2, // 1=yes it's a filename, 0=not a filename.
|
358 |
|
|
// Some guis have a file browser. This
|
359 |
|
|
// bit suggests that they use it.
|
360 |
|
|
SAVE_FILE_DIALOG = 4, // Use save dialog opposed to open file dialog
|
361 |
|
|
SELECT_FOLDER_DLG = 8 // Use folder selection dialog
|
362 |
|
|
} bx_string_opt_bits;
|
363 |
|
|
bx_param_string_c(bx_param_c *parent,
|
364 |
|
|
const char *name,
|
365 |
|
|
const char *label,
|
366 |
|
|
const char *description,
|
367 |
|
|
const char *initial_val,
|
368 |
|
|
int maxsize=-1);
|
369 |
|
|
virtual ~bx_param_string_c();
|
370 |
|
|
virtual void reset();
|
371 |
|
|
void set_handler(param_string_event_handler handler);
|
372 |
|
|
void set_enable_handler(param_enable_handler handler);
|
373 |
|
|
virtual void set_enabled(int enabled);
|
374 |
|
|
void set_dependent_list(bx_list_c *l);
|
375 |
|
|
Bit32s get(char *buf, int len);
|
376 |
|
|
char *getptr() {return val; }
|
377 |
|
|
const char *getptr() const {return val; }
|
378 |
|
|
void set(const char *buf);
|
379 |
|
|
bx_bool equals(const char *buf);
|
380 |
|
|
void set_separator(char sep) {separator = sep; }
|
381 |
|
|
char get_separator() const {return separator; }
|
382 |
|
|
int get_maxsize() const {return maxsize; }
|
383 |
|
|
void set_initial_val(const char *buf);
|
384 |
|
|
bx_bool isempty();
|
385 |
|
|
int sprint(char *buf, int buflen, bx_bool dquotes);
|
386 |
|
|
#if BX_USE_TEXTCONFIG
|
387 |
|
|
virtual void text_print(FILE *fp);
|
388 |
|
|
virtual int text_ask(FILE *fpin, FILE *fpout);
|
389 |
|
|
#endif
|
390 |
|
|
};
|
391 |
|
|
|
392 |
|
|
// Declare a filename class. It is identical to a string, except that
|
393 |
|
|
// it initializes the options differently. This is just a shortcut
|
394 |
|
|
// for declaring a string param and setting the options with IS_FILENAME.
|
395 |
|
|
class BOCHSAPI bx_param_filename_c : public bx_param_string_c {
|
396 |
|
|
const char *ext;
|
397 |
|
|
public:
|
398 |
|
|
bx_param_filename_c(bx_param_c *parent,
|
399 |
|
|
const char *name,
|
400 |
|
|
const char *label,
|
401 |
|
|
const char *description,
|
402 |
|
|
const char *initial_val,
|
403 |
|
|
int maxsize=-1);
|
404 |
|
|
const char *get_extension() const {return ext;}
|
405 |
|
|
void set_extension(const char *newext) {ext = newext;}
|
406 |
|
|
};
|
407 |
|
|
|
408 |
|
|
class BOCHSAPI bx_shadow_data_c : public bx_param_c {
|
409 |
|
|
Bit32u data_size;
|
410 |
|
|
Bit8u *data_ptr;
|
411 |
|
|
public:
|
412 |
|
|
bx_shadow_data_c(bx_param_c *parent,
|
413 |
|
|
const char *name,
|
414 |
|
|
Bit8u *ptr_to_data,
|
415 |
|
|
Bit32u data_size);
|
416 |
|
|
Bit8u *getptr() {return data_ptr;}
|
417 |
|
|
Bit32u get_size() const {return data_size;}
|
418 |
|
|
};
|
419 |
|
|
|
420 |
|
|
typedef void (*filedata_save_handler)(void *devptr, FILE *save_fp);
|
421 |
|
|
typedef void (*filedata_restore_handler)(void *devptr, FILE *save_fp);
|
422 |
|
|
|
423 |
|
|
class BOCHSAPI bx_shadow_filedata_c : public bx_param_c {
|
424 |
|
|
protected:
|
425 |
|
|
FILE **scratch_fpp; // Point to scratch file used for backing store
|
426 |
|
|
void *sr_devptr;
|
427 |
|
|
filedata_save_handler save_handler;
|
428 |
|
|
filedata_restore_handler restore_handler;
|
429 |
|
|
|
430 |
|
|
public:
|
431 |
|
|
bx_shadow_filedata_c(bx_param_c *parent,
|
432 |
|
|
const char *name, FILE **scratch_file_ptr_ptr);
|
433 |
|
|
void set_sr_handlers(void *devptr, filedata_save_handler save, filedata_restore_handler restore);
|
434 |
|
|
FILE **get_fpp() {return scratch_fpp;}
|
435 |
|
|
void save(FILE *save_file);
|
436 |
|
|
void restore(FILE *save_file);
|
437 |
|
|
};
|
438 |
|
|
|
439 |
|
|
typedef struct _bx_listitem_t {
|
440 |
|
|
bx_param_c *param;
|
441 |
|
|
struct _bx_listitem_t *next;
|
442 |
|
|
} bx_listitem_t;
|
443 |
|
|
|
444 |
|
|
class BOCHSAPI bx_list_c : public bx_param_c {
|
445 |
|
|
protected:
|
446 |
|
|
// chained list of bx_listitem_t
|
447 |
|
|
bx_listitem_t *list;
|
448 |
|
|
int size;
|
449 |
|
|
// for a menu, the value of choice before the call to "ask" is default.
|
450 |
|
|
// After ask, choice holds the value that the user chose. Choice defaults
|
451 |
|
|
// to 1 in the constructor.
|
452 |
|
|
Bit32u choice; // type Bit32u is compatible with ask_uint
|
453 |
|
|
// title of the menu or series
|
454 |
|
|
char *title;
|
455 |
|
|
void init(const char *list_title);
|
456 |
|
|
public:
|
457 |
|
|
enum {
|
458 |
|
|
// When a bx_list_c is displayed as a menu, SHOW_PARENT controls whether or
|
459 |
|
|
// not the menu shows a "Return to parent menu" choice or not.
|
460 |
|
|
SHOW_PARENT = (1<<0),
|
461 |
|
|
// Some lists are best displayed shown as menus, others as a series of
|
462 |
|
|
// related questions. This bit suggests to the CI that the series of
|
463 |
|
|
// questions format is preferred.
|
464 |
|
|
SERIES_ASK = (1<<1),
|
465 |
|
|
// When a bx_list_c is displayed in a dialog, USE_TAB_WINDOW suggests
|
466 |
|
|
// to the CI that each item in the list should be shown as a separate
|
467 |
|
|
// tab. This would be most appropriate when each item is another list
|
468 |
|
|
// of parameters.
|
469 |
|
|
USE_TAB_WINDOW = (1<<2),
|
470 |
|
|
// When a bx_list_c is displayed in a dialog, the list name is used as the
|
471 |
|
|
// label of the group box if USE_BOX_TITLE is set. This is only necessary if
|
472 |
|
|
// more than one list appears in a dialog box.
|
473 |
|
|
USE_BOX_TITLE = (1<<3),
|
474 |
|
|
// When a bx_list_c is displayed as a menu, SHOW_GROUP_NAME controls whether
|
475 |
|
|
// or not the name of group the item belongs to is added to the name of the
|
476 |
|
|
// item (used in the runtime menu).
|
477 |
|
|
SHOW_GROUP_NAME = (1<<4),
|
478 |
|
|
// When a bx_list_c is displayed in a dialog, USE_SCROLL_WINDOW suggests
|
479 |
|
|
// to the CI that the list items should be displayed in a scrollable dialog
|
480 |
|
|
// window. Large lists can make the dialog unusable and using this flag
|
481 |
|
|
// can force the CI to limit the dialog height with all items accessible.
|
482 |
|
|
USE_SCROLL_WINDOW = (1<<5)
|
483 |
|
|
} bx_listopt_bits;
|
484 |
|
|
bx_list_c(bx_param_c *parent);
|
485 |
|
|
bx_list_c(bx_param_c *parent, const char *name);
|
486 |
|
|
bx_list_c(bx_param_c *parent, const char *name, const char *title);
|
487 |
|
|
bx_list_c(bx_param_c *parent, const char *name, const char *title, bx_param_c **init_list);
|
488 |
|
|
virtual ~bx_list_c();
|
489 |
|
|
bx_list_c *clone();
|
490 |
|
|
void add(bx_param_c *param);
|
491 |
|
|
bx_param_c *get(int index);
|
492 |
|
|
bx_param_c *get_by_name(const char *name);
|
493 |
|
|
int get_size() const { return size; }
|
494 |
|
|
int get_choice() const { return choice; }
|
495 |
|
|
void set_choice(int new_choice) { choice = new_choice; }
|
496 |
|
|
char *get_title() { return title; }
|
497 |
|
|
void set_parent(bx_param_c *newparent);
|
498 |
|
|
bx_param_c *get_parent() { return parent; }
|
499 |
|
|
virtual void reset();
|
500 |
|
|
virtual void clear();
|
501 |
|
|
virtual void remove(const char *name);
|
502 |
|
|
#if BX_USE_TEXTCONFIG
|
503 |
|
|
virtual void text_print(FILE *);
|
504 |
|
|
virtual int text_ask(FILE *fpin, FILE *fpout);
|
505 |
|
|
#endif
|
506 |
|
|
};
|
507 |
|
|
|
508 |
|
|
#endif
|