-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathData.cs
637 lines (535 loc) · 16.2 KB
/
Data.cs
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
using System;
using System.Collections;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
using System.Windows.Forms;
namespace Qemu_GUI
{
public enum Platforms
{
x86 = 0,
x86_ISA = 1,
x64 = 2,
x64_ISA = 3,
ARM_integratorcp926 = 4,
ARM_integratorcp1026 = 5,
ARM_versatilepb = 6,
ARM_versatileab = 7,
PPC_g3bw = 8,
PPC_mac99 = 9,
PPC_prep = 10,
Sparc_sun4m = 11
}
[XmlRoot("Settings")]
public class Data : IDisposable
{
private General m_Gen = new General();
private Floppies m_Floppies = new Floppies();
private Harddisks m_Harddisks = new Harddisks();
private Audio m_Audio = new Audio();
private Debug m_Debug = new Debug();
private Paths m_Paths = new Paths();
private CDROM m_CDROM = new CDROM();
private Tools m_Tools = new Tools();
private Network m_Net = new Network();
private Other m_Other = new Other();
public Data()
{
}
public void Dispose()
{
Dispose();
}
[XmlElement("General")]
public General General
{
get { return m_Gen; }
set { this.m_Gen = value; }
}
[XmlElement("Tools")]
public Tools Tools
{
get { return m_Tools; }
set { this.m_Tools = value; }
}
[XmlElement("Floppies")]
public Floppies Floppies
{
get { return m_Floppies; }
set { this.m_Floppies = value; }
}
[XmlElement("CDROM")]
public CDROM CDROM
{
get { return m_CDROM; }
set { this.m_CDROM = value; }
}
[XmlElement("Harddisks")]
public Harddisks Harddisks
{
get { return m_Harddisks; }
set { this.m_Harddisks = value; }
}
[XmlElement("Audio")]
public Audio Audio
{
get { return m_Audio; }
set { this.m_Audio = value; }
}
[XmlElement("Paths")]
public Paths Paths
{
get { return m_Paths; }
set { this.m_Paths = value; }
}
[XmlElement("Debug")]
public Debug Debug
{
get { return m_Debug;}
set { this.m_Debug = value;}
}
[XmlElement("Network")]
public Network Network
{
get { return m_Net; }
set { this.m_Net = value; }
}
[XmlElement("Other")]
public Other Other
{
get { return m_Other; }
set { this.m_Other = value; }
}
public string GetArgv()
{
/* qemu BIOS path */
string arg;
if(this.Other.ABios.Length > 0)
arg = "-L \"" + this.Other.ABios + "\" ";
else
arg = "-L \"" + this.Paths.Qemu + "\" ";
arg += General.ToString();
arg += Floppies.ToString();
arg += Harddisks.ToString();
arg += CDROM.ToString();
arg += Audio.ToString();
arg += Debug.ToString();
arg += Network.ToString();
arg += Other.ToString();
return arg;
}
}
public class Harddisks
{
private Drive[] m_HardDisks = new Drive[4];
public Harddisks()
{
/* init array */
for (int i = 0; i < 4; i++)
m_HardDisks[i] = new Drive();
}
public override string ToString()
{
string buffer = "";
for (int i = 0; i < 4; i++)
{
if (this.HDD[i].Enabled && (this.HDD[i].Path.Length > 0))
buffer += "-hd" + Convert.ToChar('a' + i) + " \"" + this.HDD[i].Path + "\" ";
}
return buffer;
}
[XmlElement("Harddisk")]
public Drive[] HDD
{
get { return this.m_HardDisks; }
set { this.m_HardDisks = value; }
}
}
public class Floppies
{
private Drive[] m_Floppies = new Drive[2];
public Floppies()
{
/* init array */
for (int i = 0; i < 2; i++)
m_Floppies[i] = new Drive();
}
public override string ToString()
{
string buffer = "";
if (this.FDD[0].Enabled && (this.FDD[0].Path.Length > 0))
buffer += "-fda \"" + this.FDD[0].Path + "\" ";
if (this.FDD[1].Enabled && (this.FDD[1].Path.Length > 0))
buffer += "-fdb \"" + this.FDD[1].Path + "\" ";
return buffer;
}
[XmlElement("Floppy")]
public Drive[] FDD
{
get { return this.m_Floppies; }
set { this.m_Floppies = value; }
}
}
public class Paths
{
[XmlElement("Qemu")]
public string Qemu = "";
[XmlElement("VDK")]
public string VDK = "";
public Paths()
{
}
}
public class General
{
[XmlElement("Machine")]
public Platforms Machine;
[XmlElement("Memory")]
public int Memory;
[XmlElement("CPUs")]
public int CPUs;
[XmlElement("BootFrom")]
public string BootFrom;
[XmlElement("SetClock")]
public bool SetClock;
[XmlElement("Fullscreen")]
public bool Fullscreen;
[XmlElement("VGA")]
public bool VGA;
[XmlElement("KQEmu")]
public bool KQEmu;
[XmlElement("ACPI")]
public bool ACPI;
private bool KqemuAllowed = false;
public override string ToString()
{
/* Memory settings */
string buffer = "-m " + this.Memory.ToString() + " ";
/* SMP settings */
if(this.CPUs > 1)
buffer += "-smp " + this.CPUs.ToString() + " ";
/* Set clock */
if (this.SetClock)
buffer += "-localtime ";
/* No vga output */
if (this.VGA)
buffer += "-nographic "; //doesnt seem to work on windows
/* Fullscreen */
if (this.Fullscreen)
buffer += "-full-screen ";
if (!this.ACPI)
buffer += "-no-acpi ";
/* Machine settings */
switch (this.Machine)
{
case Platforms.x86:
buffer += "-M pc ";
KqemuAllowed = true;
break;
case Platforms.x86_ISA:
buffer += "-M isapc ";
KqemuAllowed = true;
break;
case Platforms.x64:
buffer += "-M pc ";
KqemuAllowed = false;
break;
case Platforms.x64_ISA:
buffer += "-M isapc ";
KqemuAllowed = false;
break;
case Platforms.ARM_integratorcp926:
buffer += "-M integratorcp926 ";
KqemuAllowed = false;
break;
case Platforms.ARM_integratorcp1026:
buffer += "-M integratorcp1026 ";
KqemuAllowed = false;
break;
case Platforms.ARM_versatilepb:
buffer += "-M versatilepb ";
KqemuAllowed = false;
break;
case Platforms.ARM_versatileab:
buffer += "-M versatileab ";
KqemuAllowed = false;
break;
case Platforms.PPC_g3bw:
buffer += "-M g3bw ";
KqemuAllowed = false;
break;
case Platforms.PPC_mac99:
buffer += "-M mac99 ";
KqemuAllowed = false;
break;
case Platforms.PPC_prep:
buffer += "-M prep ";
KqemuAllowed = false;
break;
}
/* KQEmu */
if(KqemuAllowed == true)
if (this.KQEmu)
buffer += "-kernel-kqemu ";
else
buffer += "-no-kqemu ";
/* Boot options */
switch (this.BootFrom)
{
case "Floppy":
buffer += "-boot a ";
break;
case "Harddisk":
buffer += "-boot c ";
break;
case "CD-ROM":
buffer += "-boot d ";
break;
default:
break;
}
return buffer;
}
public General()
{
}
}
public class Tools
{
private VDK m_VDK = new VDK();
[XmlElement("VDK")]
public VDK vdk
{
get { return this.m_VDK; }
set { this.m_VDK = value; }
}
public Tools()
{
}
}
public class VDK
{
[XmlElement("Image")]
public string Image = "";
[XmlElement("DriveLetter")]
public string DriveLetter = "";
public VDK()
{
}
}
public class Audio
{
[XmlElement("Soundblaster")]
public bool Soundblaster;
[XmlElement("OPL2")]
public bool OPL2;
[XmlElement("ES1370")]
public bool ES1370;
[XmlElement("Speaker")]
public bool Speaker;
public Audio()
{
}
public override string ToString()
{
bool audio_on = (this.ES1370 | this.OPL2 | this.Soundblaster | this.Speaker);
if (!audio_on)
return "";
string buffer = "-soundhw ";
if (this.Speaker)
buffer += "pcspk,";
if (this.Soundblaster)
buffer += "sb16,";
if (this.OPL2)
buffer += "adlib,";
if (this.ES1370)
buffer += "es1370,";
return buffer.Substring(0, buffer.Length - 1) + " ";
}
}
public class Debug
{
[XmlElement("ParPort")]
public ParPort ParallelPort = new ParPort();
[XmlElement("SerPort")]
public SerPort SerialPort = new SerPort();
[XmlElement("VBE3")]
public bool VBE3;
[XmlElement("GDBPort")]
public int GDBPort;
public bool EnableSavedState;
public string SavedStatePath;
public override string ToString()
{
string buffer = "";
/* Serial port */
if (this.SerialPort.FRedirect)
{
if (this.SerialPort.FileName.Length > 0)
buffer = "-serial file:\"" + this.SerialPort.FileName + "\" ";
}
else if (this.SerialPort.PRedirect)
{
if (this.SerialPort.PipeName.Length > 0)
buffer = "-serial pipe:" + this.SerialPort.PipeName + " ";
}
else if (this.SerialPort.SRedirect)
{
//if (this.SerialPort.FileName.Length > 0)
buffer = "-serial pipe:\"com_1\" ";
}
/* Parallel port */
if (this.ParallelPort.FRedirect)
{
if (this.ParallelPort.FileName.Length > 0)
buffer += "-parallel file:\"" + this.ParallelPort.FileName + "\" ";
}
else if (this.ParallelPort.PRedirect)
{
if (this.ParallelPort.PipeName.Length > 0)
buffer += "-parallel pipe:\"" + this.ParallelPort.PipeName + "\" ";
}
/* Saved VM state */
if (this.EnableSavedState)
{
if (this.SavedStatePath.Length > 0)
{
buffer += "-loadvm \"" + this.SavedStatePath + "\" ";
}
}
/* Standard VGA */
if (this.VBE3)
buffer += "-std-vga ";
if (this.GDBPort != 1234)
buffer += "-p " + this.GDBPort.ToString() + " ";
return buffer;
}
public Debug()
{
}
}
public class SerPort
{
[XmlAttribute("SRedirect")]
public bool SRedirect;
[XmlAttribute("FRedirect")]
public bool FRedirect;
[XmlAttribute("FileName")]
public string FileName;
[XmlAttribute("PRedirect")]
public bool PRedirect;
[XmlAttribute("PipeName")]
public string PipeName;
public SerPort()
{
}
}
public class ParPort
{
[XmlAttribute("FRedirect")]
public bool FRedirect;
[XmlAttribute("FileName")]
public string FileName;
[XmlAttribute("PRedirect")]
public bool PRedirect;
[XmlAttribute("PipeName")]
public string PipeName;
public ParPort()
{
}
}
public class CDROM
{
[XmlAttribute("Image")]
public string Image;
[XmlAttribute("Enabled")]
public bool Enabled;
public override string ToString()
{
string buffer = "";
if (this.Enabled)
{
if (this.Image.Length > 0)
buffer = "-cdrom \"" + this.Image + "\" ";
}
return buffer;
}
public CDROM()
{
}
}
public class Drive
{
[XmlAttribute("Path")]
public string Path;
[XmlAttribute("Enabled")]
public bool Enabled;
public Drive()
{
}
}
public class Network
{
[XmlAttribute("Enabled")]
public bool Enabled;
[XmlAttribute("Count")]
public int Count;
[XmlArray("VNicStrings")]
[XmlArrayItem("VNicString")]
public string[] VNicStrings;
public Network()
{
VNicStrings = new string[1];
Count = 0;
}
public void AddNetString(string lan)
{
Enabled = true;
Count++;
string[] temp = new string[Count];
for (int i = 0; i < Count; i++)
{
if (i == Count - 1)
temp[i] = lan;
else
temp[i] = VNicStrings[i];
}
VNicStrings = temp;
}
public string[] GetNetStrings()
{
return VNicStrings;
}
public override string ToString()
{
string buffer = "";
foreach(string lan in VNicStrings)
buffer += lan;
return buffer;
}
}
public class Other
{
[XmlAttribute("LKernel")]
public string LKernel;
[XmlAttribute("ABios")]
public string ABios;
[XmlAttribute("AppendCmdLine")]
public string AppendCmdLine;
public override string ToString()
{
string buffer = "";
if (LKernel.Length > 0)
buffer += "-kernel " + LKernel + " ";
if (AppendCmdLine.Length > 0)
buffer += "-append " + AppendCmdLine + " ";
return buffer;
/* ABios is a special value that is handled in GetArgv()*/
}
public Other()
{
}
}
}