-
Notifications
You must be signed in to change notification settings - Fork 5
/
config.cc
executable file
·3949 lines (3706 loc) · 137 KB
/
config.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/////////////////////////////////////////////////////////////////////////
// $Id$
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002-2009 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "bochs.h"
#include "iodev/iodev.h"
#include "param_names.h"
#include <assert.h>
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
#if defined(macintosh)
// Work around a bug in SDL 1.2.4 on MacOS X, which redefines getenv to
// SDL_getenv, but then neglects to provide SDL_getenv. It happens
// because we are defining -Dmacintosh.
#undef getenv
#endif
int bochsrc_include_count = 0;
#if BX_PLUGINS
Bit8u bx_user_plugin_count = 0;
#endif
#define LOG_THIS genlog->
extern bx_debug_t bx_dbg;
static const char *get_builtin_variable(const char *varname);
static int parse_line_unformatted(const char *context, char *line);
static int parse_line_formatted(const char *context, int num_params, char *params[]);
static int parse_bochsrc(const char *rcfile);
static int get_floppy_type_from_image(const char *filename);
static Bit64s bx_param_handler(bx_param_c *param, int set, Bit64s val)
{
char pname[BX_PATHNAME_LEN];
Bit8u channel, device;
bx_list_c *base = (bx_list_c*) param->get_parent();
base->get_param_path(pname, BX_PATHNAME_LEN);
if (!strncmp(pname, "ata.", 4)) {
channel = pname[4] - '0';
if (!strcmp(base->get_name(), "master")) {
device = 0;
} else {
device = 1;
}
if (!strcmp(param->get_name(), "status")) {
if ((set) && (SIM->get_init_done())) {
Bit32u handle = DEV_hd_get_device_handle(channel, device);
DEV_hd_set_cd_media_status(handle, val);
bx_gui->update_drive_status_buttons();
}
} else if (!strcmp(param->get_name(), "type")) {
if (set) {
switch (val) {
case BX_ATA_DEVICE_DISK:
((bx_param_filename_c*)SIM->get_param("path", base))->set_extension("img");
break;
case BX_ATA_DEVICE_CDROM:
((bx_param_filename_c*)SIM->get_param("path", base))->set_extension("iso");
break;
}
}
} else {
BX_PANIC(("bx_param_handler called with unknown parameter '%s.%s'", pname, param->get_name()));
return -1;
}
} else {
param->get_param_path(pname, BX_PATHNAME_LEN);
if ((!strcmp(pname, BXPN_FLOPPYA_TYPE)) ||
(!strcmp(pname, BXPN_FLOPPYB_TYPE))) {
if (set) {
if (val == BX_FLOPPY_AUTO) {
val = get_floppy_type_from_image(SIM->get_param_string("path", base)->getptr());
SIM->get_param_enum("type", base)->set(val);
} else if (!SIM->get_init_done() && (val != BX_FLOPPY_NONE)) {
switch (val) {
case BX_FLOPPY_2_88:
device = BX_FDD_350ED;
break;
case BX_FLOPPY_720K:
case BX_FLOPPY_1_44:
device = BX_FDD_350HD;
break;
default:
device = BX_FDD_525HD;
}
SIM->get_param_enum("devtype", base)->set(device);
}
}
} else if (!strcmp(pname, BXPN_FLOPPYA_STATUS)) {
if ((set) && (SIM->get_init_done())) {
DEV_floppy_set_media_status(0, val);
bx_gui->update_drive_status_buttons();
}
} else if (!strcmp(pname, BXPN_FLOPPYB_STATUS)) {
if ((set) && (SIM->get_init_done())) {
DEV_floppy_set_media_status(1, val);
bx_gui->update_drive_status_buttons();
}
} else if (!strcmp(pname, BXPN_FLOPPYA_READONLY)) {
if (set) {
DEV_floppy_set_media_readonly(0, val);
}
} else if (!strcmp(pname, BXPN_FLOPPYB_READONLY)) {
if (set) {
DEV_floppy_set_media_readonly(1, val);
}
} else if (!strcmp(pname, BXPN_MOUSE_ENABLED)) {
if ((set) && (SIM->get_init_done())) {
bx_gui->mouse_enabled_changed(val!=0);
DEV_mouse_enabled_changed(val!=0);
}
} else {
BX_PANIC(("bx_param_handler called with unknown parameter '%s'", pname));
return -1;
}
}
return val;
}
const char *bx_param_string_handler(bx_param_string_c *param, int set,
const char *oldval, const char *val, int maxlen)
{
char pname[BX_PATHNAME_LEN];
Bit8u channel, device;
int empty = 0;
if ((strlen(val) < 1) || !strcmp ("none", val)) {
empty = 1;
val = "none";
}
bx_list_c *base = (bx_list_c*) param->get_parent();
base->get_param_path(pname, BX_PATHNAME_LEN);
if (!strncmp(pname, "ata.", 4)) {
channel = pname[4] - '0';
if (!strcmp(base->get_name(), "master")) {
device = 0;
} else {
device = 1;
}
if (!strcmp(param->get_name(), "path")) {
if (set==1) {
if (SIM->get_init_done()) {
Bit32u handle = DEV_hd_get_device_handle(channel, device);
if (empty) {
DEV_hd_set_cd_media_status(handle, 0);
bx_gui->update_drive_status_buttons();
} else {
if (!SIM->get_param_num("present", base)->get()) {
BX_ERROR(("Cannot add a cdrom drive at runtime"));
SIM->get_param_num("present", base)->set(0);
}
if (SIM->get_param_num("type", base)->get() != BX_ATA_DEVICE_CDROM) {
BX_ERROR(("Device is not a cdrom drive"));
SIM->get_param_num("present", base)->set(0);
}
}
if (DEV_hd_present() &&
(SIM->get_param_num("status", base)->get() == 1) &&
(SIM->get_param_num("type", base)->get() == BX_ATA_DEVICE_CDROM)) {
// tell the device model that we removed, then inserted the cd
DEV_hd_set_cd_media_status(handle, 0);
DEV_hd_set_cd_media_status(handle, 1);
}
}
}
}
} else {
param->get_param_path(pname, BX_PATHNAME_LEN);
if (!strcmp(pname, BXPN_SCREENMODE)) {
if (set==1) {
BX_INFO(("Screen mode changed to %s", val));
}
} else if ((!strcmp(pname, BXPN_FLOPPYA_PATH)) ||
(!strcmp(pname, BXPN_FLOPPYB_PATH))) {
if (set==1) {
device = !strcmp(pname, BXPN_FLOPPYB_PATH);
if (SIM->get_init_done()) {
if (empty) {
DEV_floppy_set_media_status(device, 0);
bx_gui->update_drive_status_buttons();
} else {
if (SIM->get_param_enum("devtype", base)->get() == BX_FDD_NONE) {
BX_ERROR(("Cannot add a floppy drive at runtime"));
SIM->get_param_string("path", base)->set("none");
}
}
if ((DEV_floppy_present()) &&
(SIM->get_param_bool("status", base)->get() == 1)) {
// tell the device model that we removed, then inserted the disk
DEV_floppy_set_media_status(device, 0);
DEV_floppy_set_media_status(device, 1);
}
}
}
#if BX_PLUGINS
} else if (!strncmp(pname, "misc.user_plugin", 16)) {
if ((strlen(oldval) > 0) && (strcmp(oldval, "none"))) {
PLUG_unload_user_plugin(oldval);
}
if ((strlen(val) > 0) && (strcmp(val, "none"))) {
PLUG_load_user_plugin(val);
}
#endif
} else {
BX_PANIC(("bx_param_string_handler called with unknown parameter '%s'", pname));
}
}
return val;
}
void bx_init_options()
{
int i;
bx_list_c *menu;
bx_list_c *deplist;
bx_param_num_c *ioaddr, *ioaddr2, *irq;
bx_param_bool_c *enabled, *readonly, *status;
bx_param_enum_c *mode, *type, *ethmod, *toggle;
bx_param_string_c *macaddr, *ethdev;
bx_param_filename_c *path;
char name[BX_PATHNAME_LEN], descr[512], group[16], label[512];
bx_param_c *root_param = SIM->get_param(".");
// general options subtree
menu = new bx_list_c(root_param, "general", "", 11);
// config interface option, set in bochsrc or command line
static const char *config_interface_list[] = {
#ifdef WIN32
"win32config",
#endif
#if BX_USE_TEXTCONFIG
"textconfig",
#endif
#if BX_WITH_WX
"wx",
#endif
NULL
};
bx_param_enum_c *sel_config = new bx_param_enum_c(menu,
"config_interface", "Configuration interface",
"Select configuration interface",
config_interface_list,
0,
0);
sel_config->set_by_name(BX_DEFAULT_CONFIG_INTERFACE);
static const char *bochs_start_names[] = { "quick", "load", "edit", "run" };
// quick start option, set by command line arg
new bx_param_enum_c(menu,
"start_mode",
"Bochs start types",
"Bochs start types",
bochs_start_names,
BX_RUN_START,
BX_QUICK_START);
new bx_param_bool_c(menu,
"restore",
"Restore Bochs session",
"Restore Bochs session",
0);
new bx_param_string_c(menu,
"restore_path",
"Path to data for restore",
"Path to data for restore",
"",
BX_PATHNAME_LEN);
// benchmarking mode, set by command line arg
new bx_param_num_c(menu,
"benchmark",
"benchmark mode",
"set benchmark mode",
0, BX_MAX_BIT32U, 0);
// subtree for special menus
bx_list_c *special_menus = new bx_list_c(root_param, "menu", "");
#if BX_SUPPORT_SMP
#define BX_CPU_PROCESSORS_LIMIT 255
#define BX_CPU_CORES_LIMIT 8
#define BX_CPU_HT_THREADS_LIMIT 4
#else
#define BX_CPU_PROCESSORS_LIMIT 1
#define BX_CPU_CORES_LIMIT 1
#define BX_CPU_HT_THREADS_LIMIT 1
#endif
// cpu subtree
bx_list_c *cpu_param = new bx_list_c(root_param, "cpu", "CPU Options", 8 + BX_SUPPORT_SMP);
// cpu options
bx_param_num_c *nprocessors = new bx_param_num_c(cpu_param,
"n_processors", "Number of CPUs in SMP mode",
"Sets the number of CPUs for multiprocessor emulation",
1, BX_CPU_PROCESSORS_LIMIT,
1);
nprocessors->set_enabled(BX_CPU_PROCESSORS_LIMIT > 1);
bx_param_num_c *ncores = new bx_param_num_c(cpu_param,
"n_cores", "Number of processor cores in each CPU in SMP mode",
"Sets the number of processor cores per CPU for multiprocessor emulation",
1, BX_CPU_CORES_LIMIT,
1);
ncores->set_enabled(BX_CPU_CORES_LIMIT > 1);
bx_param_num_c *nthreads = new bx_param_num_c(cpu_param,
"n_threads", "Number of HT threads per each process core in SMP mode",
"Sets the number of HT (Intel(R) HyperThreading Technology) threads per core for multiprocessor emulation",
1, BX_CPU_HT_THREADS_LIMIT,
1);
nthreads->set_enabled(BX_CPU_HT_THREADS_LIMIT > 1);
new bx_param_num_c(cpu_param,
"ips", "Emulated instructions per second (IPS)",
"Emulated instructions per second, used to calibrate bochs emulated time with wall clock time.",
BX_MIN_IPS, BX_MAX_BIT32U,
4000000);
#if BX_SUPPORT_SMP
new bx_param_num_c(cpu_param,
"quantum", "Quantum ticks in SMP simulation",
"Maximum amount of instructions allowed to execute before returning control to another CPU.",
BX_SMP_QUANTUM_MIN, BX_SMP_QUANTUM_MAX,
5);
#endif
new bx_param_bool_c(cpu_param,
"reset_on_triple_fault", "Enable CPU reset on triple fault",
"Enable CPU reset if triple fault occured (highly recommended)",
1);
#if BX_CPU_LEVEL >= 5
new bx_param_bool_c(cpu_param,
"ignore_bad_msrs", "Ignore RDMSR/WRMSR to unknown MSR register",
"Ignore RDMSR/WRMSR to unknown MSR register",
1);
#endif
#if BX_CONFIGURE_MSRS
new bx_param_string_c(cpu_param,
"msrs",
"Configurable MSR definition file",
"Set path to the configurable MSR definition file",
"", BX_PATHNAME_LEN);
#endif
cpu_param->set_options(menu->SHOW_PARENT);
// cpuid subtree
bx_list_c *cpuid_param = new bx_list_c(root_param, "cpuid", "CPUID Options", 16);
new bx_param_bool_c(cpuid_param,
"cpuid_limit_winnt", "Limit max CPUID function to 3",
"Limit max CPUID function reported to 3 to workaround WinNT issue",
0);
new bx_param_string_c(cpuid_param,
"vendor_string",
"CPUID vendor string",
"Set the CPUID vendor string",
#if BX_CPU_VENDOR_INTEL
"GenuineIntel",
#else
"AuthenticAMD",
#endif
BX_CPUID_VENDOR_LEN+1);
new bx_param_string_c(cpuid_param,
"brand_string",
"CPUID brand string",
"Set the CPUID brand string",
#if BX_CPU_VENDOR_INTEL
" Intel(R) Pentium(R) 4 CPU ",
#else
"AMD Athlon(tm) processor",
#endif
BX_CPUID_BRAND_LEN+1);
new bx_param_num_c(cpuid_param,
"stepping", "Stepping ID",
"Processor 4-bits stepping ID",
0, 15,
3);
#if BX_CPU_LEVEL >= 5
new bx_param_bool_c(cpuid_param,
"mmx", "Support for MMX instruction set",
"Support for MMX instruction set",
1);
#endif
#if BX_CPU_LEVEL >= 6
// configure defaults to CPU_LEVEL = 6 with SSE2 enabled
static const char *sse_names[] = { "none", "sse", "sse2", "sse3", "ssse3", "sse4_1", "sse4_2", NULL };
new bx_param_enum_c(cpuid_param,
"sse", "Support for SSE instruction set",
"Support for SSE/SSE2/SSE3/SSSE3/SSE4_1/SSE4_2 instruction set",
sse_names,
BX_CPUID_SUPPORT_SSE2,
BX_CPUID_SUPPORT_NOSSE);
new bx_param_bool_c(cpuid_param,
"xapic", "Support for XAPIC extensions",
"Support for XAPIC extensions",
1);
new bx_param_bool_c(cpuid_param,
"sep", "Support for SYSENTER/SYSEXIT instructions",
"Support for SYSENTER/SYSEXIT instructions",
1);
new bx_param_bool_c(cpuid_param,
"movbe", "Support for MOVBE instruction",
"Support for MOVBE instruction",
0);
new bx_param_bool_c(cpuid_param,
"aes", "Support for AES instruction set",
"Support for AES instruction set",
0);
new bx_param_bool_c(cpuid_param,
"xsave", "Support for XSAVE extensions",
"Support for XSAVE extensions",
0);
#if BX_SUPPORT_X86_64
new bx_param_bool_c(cpuid_param,
"1g_pages", "1G pages support in long mode",
"Support for 1G pages in long mode",
0);
new bx_param_bool_c(cpuid_param,
"pcid", "PCID support in long mode",
"Support for process context ID (PCID) in long mode",
0);
new bx_param_bool_c(cpuid_param,
"fsgsbase", "FS/GS BASE access instructions support",
"FS/GS BASE access instructions support in long mode",
0);
#endif
#if BX_SUPPORT_MONITOR_MWAIT
new bx_param_bool_c(cpuid_param,
"mwait_is_nop", "MWAIT enter CPU to sleep state",
"Don't put CPU to sleep state by MWAIT",
0);
#endif
#endif
cpuid_param->set_options(menu->SHOW_PARENT);
// memory subtree
bx_list_c *memory = new bx_list_c(root_param, "memory", "Memory Options");
bx_list_c *stdmem = new bx_list_c(memory, "standard", "Standard Options");
bx_list_c *optrom = new bx_list_c(memory, "optrom", "Optional ROM Images");
bx_list_c *optram = new bx_list_c(memory, "optram", "Optional RAM Images");
bx_list_c *ram = new bx_list_c(stdmem, "ram", "");
bx_list_c *rom = new bx_list_c(stdmem, "rom", "");
bx_list_c *vgarom = new bx_list_c(stdmem, "vgarom", "");
// memory options (ram & rom)
bx_param_num_c *ramsize = new bx_param_num_c(ram,
"size",
"Memory size (megabytes)",
"Amount of RAM in megabytes",
1, ((Bit64u)(1) << BX_PHY_ADDRESS_WIDTH) / (1024*1024),
BX_DEFAULT_MEM_MEGS);
ramsize->set_ask_format("Enter memory size (MB): [%d] ");
ramsize->set_options(ramsize->USE_SPIN_CONTROL);
bx_param_num_c *host_ramsize = new bx_param_num_c(ram,
"host_size",
"Host allocated memory size (megabytes)",
"Amount of host allocated memory in megabytes",
1, 2048,
BX_DEFAULT_MEM_MEGS);
host_ramsize->set_ask_format("Enter memory size (MB): [%d] ");
host_ramsize->set_options(ramsize->USE_SPIN_CONTROL);
path = new bx_param_filename_c(rom,
"path",
"ROM BIOS image",
"Pathname of ROM image to load",
"", BX_PATHNAME_LEN);
path->set_format("Name of ROM BIOS image: %s");
sprintf(name, "%s/BIOS-bochs-latest", (char *)get_builtin_variable("BXSHARE"));
path->set_initial_val(name);
bx_param_num_c *romaddr = new bx_param_num_c(rom,
"addr",
"ROM BIOS address",
"The address at which the ROM image should be loaded",
0, BX_MAX_BIT32U,
0);
romaddr->set_base(16);
romaddr->set_format("0x%05x");
romaddr->set_long_format("ROM BIOS address: 0x%05x");
path = new bx_param_filename_c(vgarom,
"path",
"VGA BIOS image",
"Pathname of VGA ROM image to load",
"", BX_PATHNAME_LEN);
path->set_format("Name of VGA BIOS image: %s");
sprintf(name, "%s/VGABIOS-lgpl-latest", get_builtin_variable("BXSHARE"));
path->set_initial_val(name);
bx_param_num_c *optaddr;
for (i=0; i<BX_N_OPTROM_IMAGES; i++) {
sprintf(name, "%d", i+1);
sprintf(descr, "Pathname of optional ROM image #%d to load", i+1);
sprintf(label, "Optional ROM image #%d", i+1);
bx_list_c *optnum1 = new bx_list_c(optrom, name, label);
path = new bx_param_filename_c(optnum1,
"path",
"Path",
descr,
"", BX_PATHNAME_LEN);
sprintf(label, "Name of optional ROM image #%d", i+1);
strcat(label, " : %s");
path->set_format(strdup(label));
sprintf(descr, "The address at which the optional ROM image #%d should be loaded", i+1);
optaddr = new bx_param_num_c(optnum1,
"addr",
"Address",
descr,
0, BX_MAX_BIT32U,
0);
optaddr->set_base(16);
optaddr->set_format("0x%05x");
sprintf(label, "Optional ROM #%d address:", i+1);
strcat(label, " 0x%05x");
optaddr->set_long_format(strdup(label));
optnum1->set_options(optnum1->SHOW_PARENT | optnum1->USE_BOX_TITLE);
}
optrom->set_options(optrom->SHOW_PARENT);
for (i=0; i<BX_N_OPTRAM_IMAGES; i++) {
sprintf(name, "%d", i+1);
sprintf(descr, "Pathname of optional RAM image #%d to load", i+1);
sprintf(label, "Optional RAM image #%d", i+1);
bx_list_c *optnum2 = new bx_list_c(optram, name, label);
path = new bx_param_filename_c(optnum2,
"path",
"Path",
descr,
"", BX_PATHNAME_LEN);
sprintf(label, "Name of optional RAM image #%d", i+1);
strcat(label, " : %s");
path->set_format(strdup(label));
sprintf(descr, "The address at which the optional RAM image #%d should be loaded", i+1);
optaddr = new bx_param_num_c(optnum2,
"addr",
"Address",
descr,
0, BX_MAX_BIT32U,
0);
optaddr->set_base(16);
optaddr->set_format("0x%05x");
sprintf(label, "Optional RAM #%d address:", i+1);
strcat(label, " 0x%05x");
optaddr->set_long_format(strdup(label));
optnum2->set_options(optnum2->SHOW_PARENT | optnum2->USE_BOX_TITLE);
}
optrom->set_options(optrom->SHOW_PARENT);
memory->set_options(memory->USE_TAB_WINDOW);
bx_param_c *memory_init_list[] = {
SIM->get_param(BXPN_MEM_SIZE),
SIM->get_param(BXPN_ROM_PATH),
SIM->get_param(BXPN_ROM_ADDRESS),
SIM->get_param(BXPN_VGA_ROM_PATH),
SIM->get_param("memory.optrom"),
SIM->get_param("memory.optram"),
NULL
};
menu = new bx_list_c(special_menus, "memory", "Bochs Memory Options", memory_init_list);
menu->set_options(menu->SHOW_PARENT);
// clock & cmos subtree
bx_list_c *clock_cmos = new bx_list_c(root_param, "clock_cmos", "Clock & CMOS Options");
// clock & cmos options
static const char *clock_sync_names[] = { "none", "realtime", "slowdown", "both", NULL };
bx_param_enum_c *clock_sync = new bx_param_enum_c(clock_cmos,
"clock_sync", "Synchronisation method",
"Host to guest time synchronization method",
clock_sync_names,
BX_CLOCK_SYNC_NONE,
BX_CLOCK_SYNC_NONE);
bx_param_num_c *time0 = new bx_param_num_c(clock_cmos,
"time0",
"Initial CMOS time for Bochs\n(1:localtime, 2:utc, other:time in seconds)",
"Initial time for Bochs CMOS clock, used if you really want two runs to be identical",
0, BX_MAX_BIT32U,
BX_CLOCK_TIME0_LOCAL);
bx_list_c *cmosimage = new bx_list_c(clock_cmos, "cmosimage", "CMOS Image Options");
bx_param_bool_c *use_cmosimage = new bx_param_bool_c(cmosimage,
"enabled", "Use a CMOS image",
"Controls the usage of a CMOS image",
0);
path = new bx_param_filename_c(cmosimage,
"path", "Pathname of CMOS image",
"Pathname of CMOS image",
"", BX_PATHNAME_LEN);
bx_param_bool_c *rtc_init = new bx_param_bool_c(cmosimage,
"rtc_init", "Initialize RTC from image",
"Controls whether to initialize the RTC with values stored in the image",
0);
deplist = new bx_list_c(NULL, 2);
deplist->add(path);
deplist->add(rtc_init);
use_cmosimage->set_dependent_list(deplist);
time0->set_ask_format("Enter Initial CMOS time (1:localtime, 2:utc, other:time in seconds): [%d] ");
clock_sync->set_ask_format("Enter Synchronisation method: [%s] ");
clock_cmos->set_options(clock_cmos->SHOW_PARENT);
cmosimage->set_options(cmosimage->SHOW_PARENT);
// pci subtree
bx_list_c *pci = new bx_list_c(root_param, "pci", "PCI Options");
// pci options
bx_param_c *pci_deps_list[3+BX_N_PCI_SLOTS+2*BX_SUPPORT_PCIDEV];
bx_param_c **pci_deps_ptr = &pci_deps_list[0];
bx_param_bool_c *i440fx_support = new bx_param_bool_c(pci,
"i440fx_support",
"Enable i440FX PCI Support",
"Controls whether to emulate the i440FX PCI chipset",
BX_SUPPORT_PCI);
// pci slots
bx_list_c *slot = new bx_list_c(pci, "slot", "PCI Slots");
*pci_deps_ptr++ = slot;
for (i=0; i<BX_N_PCI_SLOTS; i++) {
sprintf(name, "%d", i+1);
sprintf (descr, "Name of the device connected to PCI slot #%d", i+1);
sprintf (label, "PCI slot #%d device", i+1);
bx_param_string_c *devname = new bx_param_string_c(slot,
name,
label,
descr,
"", BX_PATHNAME_LEN);
// add to deplist
*pci_deps_ptr++ = devname;
}
// pcidev options
bx_list_c *pcidev = new bx_list_c(pci, "pcidev", "Host PCI Device Mapping");
*pci_deps_ptr++ = pcidev;
bx_param_num_c *pcivid = new bx_param_num_c(pcidev,
"vendor",
"PCI Vendor ID",
"The vendor ID of the host PCI device to map",
0, 0xffff,
0xffff); // vendor id 0xffff = no pci device present
pcivid->set_base(16);
pcivid->set_format("0x%04x");
pcivid->set_long_format("PCI Vendor ID: 0x%04x");
#if BX_SUPPORT_PCIDEV
*pci_deps_ptr++ = pcivid;
#else
pcivid->set_enabled(0);
#endif
bx_param_num_c *pcidid = new bx_param_num_c(pcidev,
"device",
"PCI Device ID",
"The device ID of the host PCI device to map",
0, 0xffff,
0x0);
pcidid->set_base(16);
pcidid->set_format("0x%04x");
pcidid->set_long_format("PCI Device ID: 0x%04x");
#if BX_SUPPORT_PCIDEV
*pci_deps_ptr++ = pcidid;
#else
pcidid->set_enabled(0);
#endif
// add final NULL at the end, and build the menu
*pci_deps_ptr = NULL;
i440fx_support->set_dependent_list(new bx_list_c(NULL, "", "", pci_deps_list));
pci->set_options(pci->SHOW_PARENT);
slot->set_options(slot->SHOW_PARENT);
pcidev->set_options(pcidev->SHOW_PARENT | pcidev->USE_BOX_TITLE);
// display subtree
bx_list_c *display = new bx_list_c(root_param, "display", "Bochs Display & Interface Options", 7);
// this is a list of gui libraries that are known to be available at
// compile time. The one that is listed first will be the default,
// which is used unless the user overrides it on the command line or
// in a configuration file.
static const char *display_library_list[] = {
#if BX_WITH_X11
"x",
#endif
#if BX_WITH_WIN32
"win32",
#endif
#if BX_WITH_CARBON
"carbon",
#endif
#if BX_WITH_BEOS
"beos",
#endif
#if BX_WITH_MACOS
"macos",
#endif
#if BX_WITH_AMIGAOS
"amigaos",
#endif
#if BX_WITH_SDL
"sdl",
#endif
#if BX_WITH_SVGA
"svga",
#endif
#if BX_WITH_TERM
"term",
#endif
#if BX_WITH_RFB
"rfb",
#endif
#if BX_WITH_WX
"wx",
#endif
#if BX_WITH_NOGUI
"nogui",
#endif
NULL
};
bx_param_enum_c *sel_displaylib = new bx_param_enum_c(display,
"display_library", "VGA Display Library",
"Select VGA Display Library",
display_library_list,
0,
0);
sel_displaylib->set_by_name(BX_DEFAULT_DISPLAY_LIBRARY);
sel_displaylib->set_ask_format("Choose which library to use for the Bochs display: [%s] ");
new bx_param_string_c(display,
"displaylib_options", "Display Library options",
"Options passed to Display Library",
"",
BX_PATHNAME_LEN);
new bx_param_bool_c(display,
"private_colormap", "Use a private colormap",
"Request that the GUI create and use it's own non-shared colormap. This colormap will be used when in the bochs window. If not enabled, a shared colormap scheme may be used. Not implemented on all GUI's.",
0);
bx_param_bool_c *fullscreen = new bx_param_bool_c(display,
"fullscreen", "Use full screen mode",
"When enabled, bochs occupies the whole screen instead of just a window.",
0);
bx_param_string_c *screenmode = new bx_param_string_c(display,
"screenmode",
"Screen mode name",
"Screen mode name",
"", BX_PATHNAME_LEN);
screenmode->set_handler(bx_param_string_handler);
#if !BX_WITH_AMIGAOS
fullscreen->set_enabled(0);
screenmode->set_enabled(0);
#endif
bx_param_num_c *vga_update_interval = new bx_param_num_c(display,
"vga_update_interval",
"VGA Update Interval",
"Number of microseconds between VGA updates",
40000, BX_MAX_BIT32U,
50000);
vga_update_interval->set_ask_format ("Type a new value for VGA update interval: [%d] ");
bx_param_string_c *vga_extension = new bx_param_string_c(display,
"vga_extension",
"VGA Extension",
"Name of the VGA extension",
"none", BX_PATHNAME_LEN);
#if BX_SUPPORT_VBE
vga_extension->set_initial_val("vbe");
#elif BX_SUPPORT_CLGD54XX
vga_extension->set_initial_val("cirrus");
#endif
display->set_options(display->SHOW_PARENT);
// keyboard & mouse subtree
bx_list_c *kbd_mouse = new bx_list_c(root_param, "keyboard_mouse", "Keyboard & Mouse Options");
bx_list_c *keyboard = new bx_list_c(kbd_mouse, "keyboard", "Keyboard Options");
bx_list_c *mouse = new bx_list_c(kbd_mouse, "mouse", "Mouse Options");
static const char *keyboard_type_names[] = { "xt", "at", "mf", NULL };
// keyboard & mouse options
type = new bx_param_enum_c(keyboard,
"type", "Keyboard type",
"Keyboard type reported by the 'identify keyboard' command",
keyboard_type_names,
BX_KBD_MF_TYPE,
BX_KBD_XT_TYPE);
type->set_ask_format ("Enter keyboard type: [%s] ");
new bx_param_num_c(keyboard,
"serial_delay", "Keyboard serial delay",
"Approximate time in microseconds that it takes one character to be transfered from the keyboard to controller over the serial path.",
1, BX_MAX_BIT32U,
250);
new bx_param_num_c(keyboard,
"paste_delay", "Keyboard paste delay",
"Approximate time in microseconds between attemps to paste characters to the keyboard controller.",
1000, BX_MAX_BIT32U,
100000);
bx_param_bool_c *use_kbd_mapping = new bx_param_bool_c(keyboard,
"use_mapping", "Use keyboard mapping",
"Controls whether to use the keyboard mapping feature",
0);
bx_param_filename_c *keymap = new bx_param_filename_c(keyboard,
"keymap", "Keymap filename",
"Pathname of the keymap file used",
"", BX_PATHNAME_LEN);
keymap->set_extension("map");
deplist = new bx_list_c(NULL, 1);
deplist->add(keymap);
use_kbd_mapping->set_dependent_list(deplist);
bx_param_string_c *user_shortcut = new bx_param_string_c(keyboard,
"user_shortcut",
"Userbutton shortcut",
"Defines the keyboard shortcut to be sent when you press the 'user' button in the headerbar.",
"none", 20);
user_shortcut->set_runtime_param(1);
static const char *mouse_type_list[] = {
"none",
"ps2",
"imps2",
#if BX_SUPPORT_BUSMOUSE
"bus",
#endif
"serial",
"serial_wheel",
"serial_msys",
NULL
};
type = new bx_param_enum_c(mouse,
"type", "Mouse type",
"The mouse type can be one of these: 'none', 'ps2', 'imps2', 'serial', 'serial_wheel'"
#if BX_SUPPORT_BUSMOUSE
", 'bus'"
#endif
,
mouse_type_list,
BX_MOUSE_TYPE_PS2,
BX_MOUSE_TYPE_NONE);
type->set_ask_format("Choose the type of mouse [%s] ");
enabled = new bx_param_bool_c(mouse,
"enabled", "Enable mouse capture",
"Controls whether the mouse sends events to the guest. The hardware emulation is always enabled.",
0);
enabled->set_handler(bx_param_handler);
enabled->set_runtime_param(1);
static const char *mouse_toggle_list[] = {
"ctrl+mbutton",
"ctrl+f10",
"ctrl+alt",
"f12",
NULL
};
toggle = new bx_param_enum_c(mouse,
"toggle", "Mouse toggle method",
"The mouse toggle method can be one of these: 'ctrl+mbutton', 'ctrl+f10', 'ctrl+alt'",
mouse_toggle_list,
BX_MOUSE_TOGGLE_CTRL_MB,
BX_MOUSE_TOGGLE_CTRL_MB);
toggle->set_ask_format("Choose the mouse toggle method [%s] ");
kbd_mouse->set_options(kbd_mouse->SHOW_PARENT);
keyboard->set_options(keyboard->SHOW_PARENT);
mouse->set_options(mouse->SHOW_PARENT);
// boot parameter subtree
bx_list_c *boot_params = new bx_list_c(root_param, "boot_params", "Boot Options");
// boot sequence
for (i=0; i<3; i++) {
sprintf(name, "boot_drive%d", i+1);
sprintf(label, "Boot drive #%d", i+1);
sprintf(descr, "Name of drive #%d in boot sequence (A, C or CD)", i+1);
bx_param_enum_c *bootdrive = new bx_param_enum_c(boot_params,
name,
label,
descr,
&bochs_bootdisk_names[(i==0)?BX_BOOT_FLOPPYA:BX_BOOT_NONE],
(i==0)?BX_BOOT_FLOPPYA:BX_BOOT_NONE,
(i==0)?BX_BOOT_FLOPPYA:BX_BOOT_NONE);
bootdrive->set_ask_format("Boot from floppy drive, hard drive or cdrom ? [%s] ");
}
new bx_param_bool_c(boot_params,
"floppy_sig_check",
"Skip Floppy Boot Signature Check",
"Skips check for the 0xaa55 signature on floppy boot device.",
0);
// loader hack
bx_list_c *load32bitos = new bx_list_c(boot_params, "load32bitos", "32-bit OS Loader Hack");
static const char *loader_os_names[] = { "none", "linux", "nullkernel", NULL };
bx_param_enum_c *whichOS = new bx_param_enum_c(load32bitos,
"which",
"Which operating system?",
"Which OS to boot",
loader_os_names,
Load32bitOSNone,
Load32bitOSNone);
path = new bx_param_filename_c(load32bitos,
"path",
"Pathname of OS to load",
"Pathname of the 32-bit OS to load",
"", BX_PATHNAME_LEN);
bx_param_filename_c *iolog = new bx_param_filename_c(load32bitos,
"iolog",
"Pathname of I/O log file",
"I/O logfile used for initializing the hardware",
"", BX_PATHNAME_LEN);
bx_param_filename_c *initrd = new bx_param_filename_c(load32bitos,
"initrd",
"Pathname of initrd",
"Pathname of the initial ramdisk",
"", BX_PATHNAME_LEN);
whichOS->set_ask_format("Enter OS to load: [%s] ");
path->set_ask_format("Enter pathname of OS: [%s]");
iolog->set_ask_format("Enter pathname of I/O log: [%s] ");
initrd->set_ask_format("Enter pathname of initrd: [%s] ");
load32bitos->set_options(menu->SERIES_ASK);
whichOS->set_dependent_list(load32bitos->clone(), 1);
whichOS->set_dependent_bitmap(Load32bitOSNone, 0);
whichOS->set(Load32bitOSNone);
boot_params->set_options(menu->SHOW_PARENT);
// floppy subtree
bx_list_c *floppy = new bx_list_c(root_param, "floppy", "Floppy Options");
bx_list_c *floppya = new bx_list_c(floppy, "0", "First Floppy Drive");
bx_list_c *floppyb = new bx_list_c(floppy, "1", "Second Floppy Drive");
bx_param_enum_c *devtype;
// floppy options
devtype = new bx_param_enum_c(floppya,
"devtype",
"Type of floppy drive",
"Type of floppy drive",
floppy_devtype_names,
BX_FDD_NONE,
BX_FDD_NONE);
devtype->set_ask_format("What type of floppy drive? [%s] ");
path = new bx_param_filename_c(floppya,
"path",
"First floppy image/device",
"Pathname of first floppy image file or device. If you're booting from floppy, this should be a bootable floppy.",
"", BX_PATHNAME_LEN);
path->set_ask_format("Enter new filename, or 'none' for no disk: [%s] ");
path->set_extension("img");
path->set_handler(bx_param_string_handler);
path->set_initial_val("none");
path->set_runtime_param(1);
type = new bx_param_enum_c(floppya,
"type",
"Type of floppy media",
"Type of floppy media",
floppy_type_names,
BX_FLOPPY_NONE,
BX_FLOPPY_NONE);
type->set_ask_format("What type of floppy media? (auto=detect) [%s] ");
type->set_handler(bx_param_handler);
type->set_runtime_param(1);
readonly = new bx_param_bool_c(floppya,
"readonly",
"Write Protection",
"Floppy media write protection",
0);
readonly->set_ask_format("Is media write protected? [%s] ");
readonly->set_handler(bx_param_handler);