X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Futils%2Fpintos;h=8b3b56d7fa2aeb4e5b5a33576181a830f51cd0fc;hb=f2e18d716109879cefc489049a0d8bef072bdd40;hp=9b3d0e7adecc1a5d29b21bacf270e1add5233b16;hpb=39ec0be2b12392f86bb7188e88b5ae863101de29;p=pintos-anon diff --git a/src/utils/pintos b/src/utils/pintos index 9b3d0e7..8b3b56d 100755 --- a/src/utils/pintos +++ b/src/utils/pintos @@ -8,9 +8,11 @@ our (@disks) = ("os.dsk", "fs.dsk", "scratch.dsk", "swap.dsk"); our ($sim); our ($debug); our ($vga); -our ($jitter); +our ($jitter, $realtime); use Getopt::Long qw(:config require_order bundling); +unshift (@ARGV, split (' ', $ENV{PINTOSOPTS})) + if defined $ENV{PINTOSOPTS}; GetOptions ("sim=s" => sub { set_sim (@_) }, "bochs" => sub { set_sim ("bochs") }, "qemu" => sub { set_sim ("qemu") }, @@ -24,7 +26,8 @@ GetOptions ("sim=s" => sub { set_sim (@_) }, "run|get|put|make-disk" => \&cmd_option, "m|memory=i" => \$mem, - "j|jitter=i" => \$jitter, + "j|jitter=i" => sub { set_jitter (@_) }, + "r|realtime" => sub { set_realtime () }, "v|no-vga" => sub { set_vga ('none'); }, "s|no-serial" => sub { $serial_out = 0; }, @@ -64,6 +67,19 @@ sub set_vga { $vga = $new_vga; } +sub set_jitter { + my ($new_jitter) = @_; + die "--realtime conflicts with --jitter\n" if defined $realtime; + die "different --jitter already defined\n" + if defined $jitter && $jitter != $new_jitter; + $jitter = $new_jitter; +} + +sub set_realtime { + die "--realtime conflicts with --jitter\n" if defined $jitter; + $realtime = 1; +} + sub cmd_option { # Force an end to option processing, as with --. die ("!FINISH"); @@ -96,12 +112,20 @@ if ($cmd eq 'run') { # Create scratch disk from file. die "$hostfn: $!\n" if ! -e $hostfn; my ($size) = -s _; - copy_pad ($hostfn, "scratch.dsk", 512); + if ($size) { + copy_pad ($hostfn, "scratch.dsk", 512); + } else { + open (SCRATCH, ">scratch.dsk") or die "scratch.dsk: create: $!\n"; + syswrite (SCRATCH, "\0" x 512); + close (SCRATCH); + } # Do copy. my (@cmd) = ("-ci", $guestfn, $size, "-q"); unshift (@cmd, "-f") if $format; run_vm ('EXEC', @cmd); + + exit 1; } elsif ($cmd eq 'get') { usage () if @ARGV != 1 && @ARGV != 2; my ($guestfn, $hostfn) = @ARGV; @@ -133,6 +157,8 @@ if ($cmd eq 'run') { print DST $src or die "$hostfn: write error\n"; close (DST); close (SRC); + + exit 1; } elsif ($cmd eq 'help') { usage (0); } else { @@ -165,6 +191,7 @@ sub usage { print " -t, --terminal Display VGA in terminal (Bochs only)\n"; print "VM options:\n"; print " -j SEED Randomize timer interrupts (Bochs only)\n"; + print " -r, --realtime Use realistic, but not reproducible, timings\n"; print " -m, --mem=MB Run VM with MB megabytes of physical memory\n"; print "Disk options:\n"; print " --os-disk=DISK Set OS disk file (default: os.dsk)\n"; @@ -195,6 +222,18 @@ sub run_vm { undef $disks[$i] if ! -e $disks[$i]; } + if (my ($project) = `pwd` =~ /\b(threads|userprog|vm|filesys)\b/) { + if ((grep ($project eq $_, qw (userprog vm filesys))) + && !defined ($disks[1])) { + print STDERR "warning: it looks like you're running the $project "; + print STDERR "project, but no file system disk is present\n"; + } + if ($project eq 'vm' && !defined $disks[3]) { + print STDERR "warning: it looks like you're running the $project "; + print STDERR "project, but no swap disk is present\n"; + } + } + write_cmd_line ($disks[0], @_); if ($sim eq 'bochs') { @@ -222,7 +261,11 @@ sub run_vm { print BOCHSRC bochs_disk_line ("ata1-slave", $disks[3]); print BOCHSRC "boot: c\n"; print BOCHSRC "ips: 1000000\n"; - print BOCHSRC "clock: sync=none, time0=0\n"; + if (!$realtime) { + print BOCHSRC "clock: sync=none, time0=0\n"; + } else { + print BOCHSRC "clock: sync=realtime, time0=0\n"; + } print BOCHSRC "megs: $mem\n"; print BOCHSRC "log: bochsout.txt\n"; if ($vga ne 'terminal') { @@ -255,6 +298,7 @@ sub run_vm { push (@cmd, '-S') if $debug eq 'monitor'; push (@cmd, '-s') if $debug eq 'gdb'; run_command (@cmd); + exit 1; } elsif ($sim eq 'gsx') { print "warning: VMware GSX Server doesn't support --$debug\n" if $debug ne 'no-debug'; @@ -272,6 +316,11 @@ sub run_vm { print VMX "guestOS = \"linux\"\n"; print VMX "floppy0.present = FALSE\n"; + unlink ("pintos.out"); + print VMX "serial0.present = TRUE\n"; + print VMX "serial0.fileType = \"file\"\n"; + print VMX "serial0.fileName = \"pintos.out\"\n"; + if (! -e 'null.bin') { open (NULL, ">null.bin") or die "null.bin: create: $!\n"; close (NULL); @@ -310,6 +359,8 @@ sub run_vm { system ("vmware-cmd $vmx stop hard >&/dev/null"); system ("vmware -l -G -x -q $vmx"); system ("vmware-cmd $vmx stop hard >&/dev/null"); + + exit 1; } }