3 ###APPAUTHOR: xiaoranzzz
4 ###APPDATE: Sat Oct 20 07:53:54 2007
6 ###APPDESC: bochs configure
7 ###APPUSAGE: [-hd{a,b,c,d} hdimage] [-cd{a,b} cdiso] [-fd{a,b} fdimage] [-boot {a,c,d}]
8 ###APPOPTION: -rom filename:Specify bios rom image|-vgabios:Specify vga bios rom image|-mem number:Memory|-display {x,sdl,wx}:Display mode|-interface {textconfig,wx}:Config Interface|-edit:Edit template
10 $ARGV[0]="-h" unless(@ARGV);
12 exit(system("plhelp",$0,@ARGV)) if($_ eq "-h" || $_ eq "--help");
26 $result{noname
}=$last if($last);
48 my %OPTS=getOpt
(@ARGV);
51 $OPTS{-hda
}=$OPTS{noname
} if($OPTS{noname
} && !$OPTS{-hda
});
52 foreach(keys(%OPTS)) {
53 print STDERR
("$_\t:\t$OPTS{$_}\n");
56 my $dir_bochs="/usr/share/bochs";
57 my $dir_vgabios="/usr/share/vgabios/";
66 "/share/appdata/bochs/config-template",
67 "~/.getopts/config-template",
72 "$dir_bochs/BIOS-bochs-latest",
73 "/share/appdata/bochs/bios.rom",
78 "$dir_bochs/VGABIOS-lgpl-latest",
79 "$dir_vgabios/vgabios.bin",
80 "$dir_vgabios/vgabios.cirrus.bin",
84 my $template=pickBest
(@prop_template);
85 die("Template not found in :\n" . join("\n",@prop_template)) unless(-f
$template);
88 system("vim",$template);
91 my $rom=pickBest
(@prop_rom);
92 die("Bios rom not found in :\n" . join("\n",@prop_rom)) unless(-f
$rom);
94 my $vgarom=pickBest
(@prop_vgarom);
95 die("VGA Bios rom not found in :\n" . join("\n",@prop_vgarom)) unless(-f
$vgarom);
98 my $interface = "textconfig";
99 $interface=$OPTS{-interface
} if($OPTS{-interface
});
102 $display=$OPTS{-display
} if($OPTS{-display
});
105 $mem=$OPTS{-mem
} if($OPTS{-mem
});
107 my $boot="floppy, cdrom , disk";
110 $boot="floppy, cdrom, disk" if($c eq "a");
111 $boot="disk, floppy, cdrom" if($c eq "c");
112 $boot="cdrom, floppy, disk" if($c eq "d");
115 my $cdroma="/dev/cdrom";
116 $cdroma=$OPTS{-cda
} if($OPTS{-cda
});
119 open(TEMPLATE
,"<",$template) or die("$!\n");
124 print "config_interface: $interface\n" if($interface);
125 print "display_library: $display\n" if($display);
126 print "megs: $mem\n" if($mem);
127 print "romimage: file=\"$rom\"\n" if($rom);
128 print "vgaromimage: file=\"$vgarom\"\n" if($vgarom);
131 print "boot: $boot\n" if($boot);
134 print "floppya: 1_44=\"$OPTS{-fda}\", status=inserted\n" if($OPTS{-fda
});
135 print "floppya: 1_44=\"$OPTS{-fdb}\", status=inserted\n" if($OPTS{-fdb
});
138 print "ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14\n" if($OPTS{-hda
} or $OPTS{-hdb
});
139 print "ata1: enabled=1, ioaddr1=0x170, ioaddr2=0x370, irq=15\n" if($OPTS{-cda
} or $OPTS{-cdb
});
140 print "ata2: enabled=1, ioaddr1=0x1e8, ioaddr2=0x3e0, irq=2\n" if($OPTS{-hdc
} or $OPTS{-hdd
});
141 print "ata3: enabled=1, ioaddr1=0x168, ioaddr2=0x360, irq=3\n" if($OPTS{-hde
} or $OPTS{-hdf
});
145 print ("ata0-master: type=disk, mode=flat, translation=auto, path=\"" . $OPTS{-hda
} . "\", cylinders=0, heads=16, spt=63, biosdetect=auto, model=\"Generic 1234\"\n") if($OPTS{-hda
});
146 print "ata0-slave: type=disk, mode=flat, translation=auto, path=\"$OPTS{-hdb}\", cylinders=0, heads=16, spt=63, biosdetect=auto, model=\"Generic 1234\"\n" if($OPTS{-hdb
});
149 print "ata2-master: type=disk, mode=flat, translation=auto, path=\"$OPTS{-hdc}\", cylinders=0, heads=16, spt=63, biosdetect=auto, model=\"Generic 1234\"\n" if($OPTS{-hdc
});
150 print "ata2-slave: type=disk, mode=flat, translation=auto, path=\"$OPTS{-hdd}\", cylinders=0, heads=16, spt=63, biosdetect=auto, model=\"Generic 1234\"\n" if($OPTS{-hdd
});
153 #print "ata1: enabled=1, ioaddr1=0x170, ioaddr2=0x370, irq=3\n";
154 print "ata1-master: type=cdrom, path=\"$cdroma\", status=inserted, biosdetect=auto, model=\"Generic 1234\"\n";
155 print "ata1-slave: type=cdrom, path=\"$OPTS{-cdb}\", status=inserted, biosdetect=auto, model=\"Generic 1234\"\n" if($OPTS{-cdb
});