$headless = 0;
while (@ARGV) {
my ($arg) = shift (@ARGV);
- if ($arg =~ /--(bochs|qemu|vmware)$/) {
+ if ($arg =~ /--(bochs|qemu|gsx)$/) {
$sim = $1;
} elsif ($arg =~ /--(monitor|gdb)$/) {
$debug = $1;
close (SRC);
exit 0;
+ } else {
+ die "unknown option `$arg'\n";
}
}
usage ();
print "Available options:\n";
print " --bochs Use Bochs as simulator (default)\n";
print " --qemu Use qemu as simulator\n";
- print " --vmware Use VMware Workstation as simulator\n";
+ print " --gsx Use VMware GSX Server 3.x as simulator\n";
print " --monitor Debug with simulator's monitor\n";
print " --gdb Debug with gdb\n";
print " --mem=MB Run VM with MB megabytes of physical memory\n";
push (@cmd, '-S') if $debug eq 'monitor';
push (@cmd, '-s') if $debug eq 'gdb';
run_command (@cmd);
- }
+ } elsif ($sim eq 'gsx') {
+ print "warning: --$debug not supported by VMware GSX Server, ignoring"
+ if $debug ne '';
+
+ open (VMX, ">pintos.vmx") or die "pintos.vmx: create: $!\n";
+ chmod 0777 & ~umask, "pintos.vmx";
+ print VMX "#! /usr/bin/vmware -G\n";
+ print VMX "config.version = 6\n";
+ print VMX "guestOS = \"linux\"\n";
+ print VMX "floppy0.present = FALSE\n";
+
+ if (! -e 'null.bin') {
+ open (NULL, ">null.bin") or die "null.bin: create: $!\n";
+ close (NULL);
+ }
+
+ for (my ($i) = 0; $i < 4; $i++) {
+ my ($dsk) = $disks[$i];
+ next if !defined $dsk;
+ $device = "ide" . int ($i / 2) . ":" . ($i % 2);
+
+ my ($pln) = $dsk;
+ $pln =~ s/\.dsk//;
+ $pln .= ".pln";
+
+ print VMX "\n$device.present = TRUE\n";
+ print VMX "$device.deviceType = \"plainDisk\"\n";
+ print VMX "$device.fileName = \"$pln\"\n";
+
+ my (%geom) = disk_geometry ($dsk);
+ open (PLN, ">$pln") or die "$pln: create: $!\n";
+ print PLN "DRIVETYPE ide\n";
+ print PLN "#vm|VERSION 2\n";
+ print PLN "#vm|TOOLSVERSION 2\n";
+ print PLN "CYLINDERS $geom{C}\n";
+ print PLN "HEADS $geom{H}\n";
+ print PLN "SECTORS $geom{S}\n";
+ print PLN "#vm|CAPACITY $geom{CAPACITY}\n";
+ print PLN "ACCESS \"$dsk\" 0 $geom{CAPACITY}\n";
+ close (PLN);
+ }
+ close (VMX);
+
+ use Cwd;
+ $vmx = getcwd () . "/pintos.vmx";
+ system ("vmware-cmd -s register $vmx >&/dev/null");
+ system ("vmware-cmd $vmx stop hard >&/dev/null");
+ system ("vmware -l -G -x -q $vmx");
+ system ("vmware-cmd $vmx stop hard >&/dev/null");
+ }
}
sub write_cmd_line {
sub bochs_disk_line {
my ($device, $file) = @_;
return "" if !defined $file;
+ my (%geom) = disk_geometry ($file);
+ return "$device: type=disk, path=$file, mode=flat, "
+ . " cylinders=$geom{C}, heads=$geom{H}, spt=$geom{S}, "
+ . "translation=none\n";
+}
+
+sub disk_geometry {
+ my ($file) = @_;
my ($size) = -s $file;
die "$file: stat: $!\n" if !defined $size;
die "$file: size not a multiple of 512 bytes\n" if $size % 512;
$cylinders = int ($size / (512 * 16 * 63));
$cylinders++ if $size % (512 * 16 * 63);
- return "$device: type=disk, path=$file, mode=flat, cylinders=$cylinders, "
- . "heads=16, spt=63, translation=none\n";
+
+ return (CAPACITY => $size / 512,
+ C => $cylinders,
+ H => 16,
+ S => 63);
}