aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorklaar36 <klas.arvidsson@liu.se>2019-04-02 18:26:51 +0200
committerklaar36 <klas.arvidsson@liu.se>2019-04-02 18:26:51 +0200
commitc3ce00fe7d5a88560864167d769a559c578115f4 (patch)
treeda54f6fe65c3fcb439fe361173a673713446c39d /src
parent06f60bd120bbf7e57b46401d3708d83bd37053e7 (diff)
parent6ca20446c77fd6dec9ca10713a63233c97e7e977 (diff)
downloadpintos-rs-c3ce00fe7d5a88560864167d769a559c578115f4.tar.gz
Merge remote-tracking branch 'skel/master'
Diffstat (limited to 'src')
-rw-r--r--src/Make.config2
-rw-r--r--src/tests/filst/sc-bad-write.c14
-rw-r--r--src/threads/init.c8
-rwxr-xr-xsrc/utils/pintos25
4 files changed, 40 insertions, 9 deletions
diff --git a/src/Make.config b/src/Make.config
index 69914d8..f6e3ccf 100644
--- a/src/Make.config
+++ b/src/Make.config
@@ -48,7 +48,7 @@ WARNINGS = -Wall -W -Wstrict-prototypes -Wmissing-prototypes -Wsystem-headers
# klaar36@ida 2015-03: -fno-omit-frame-pointer to get working backtrace
# klaar36@ida 2016-05: -ffreestanding to assert freestanding environment
# klaar36@ida 2016-05: -fno-inline to ease debugging
-CFLAGS = -std=gnu99 -ggdb -msoft-float -fno-omit-frame-pointer -ffreestanding -fno-inline -O $(CFLAG_STACK_PROTECTOR)
+CFLAGS = -std=gnu99 -ggdb -msoft-float -fno-omit-frame-pointer -ffreestanding -fno-inline -fno-pic -O $(CFLAG_STACK_PROTECTOR)
CPPFLAGS = -nostdinc -I$(SRCDIR) -I$(SRCDIR)/lib
ASFLAGS = -Wa,--gstabs
LDFLAGS =
diff --git a/src/tests/filst/sc-bad-write.c b/src/tests/filst/sc-bad-write.c
index 4d04155..fbd6260 100644
--- a/src/tests/filst/sc-bad-write.c
+++ b/src/tests/filst/sc-bad-write.c
@@ -23,6 +23,12 @@ static inline void *pg_round_up (const void *va) {
*/
extern int _end_bss;
+/**
+ * String constants used in the asm blocks.
+ */
+const char *WORKS = "WORKS\n";
+const char *FAIL = "FAIL\n";
+
void test_main(void)
{
// Get the addres of the first unmapped page in the system.
@@ -38,14 +44,14 @@ void test_main(void)
"movl %1, (%%esp);" // Try to call SYS_WRITE
"movl %2, 4(%%esp);" // Write to STDOUT
"movl %3, 8(%%esp);" // Load buffer.
- "movl $6, 12(%%esp);" // Write length of string
+ "movl $6, 12(%%esp);" // Write length of string
"int $0x30;"
"movl %%edi, %%esp;" // Restore esp.
:
: "r" (base),
"i" (SYS_WRITE),
"i" (STDOUT_FILENO),
- "i" ("WORKS\n")
+ "r" (WORKS)
: "%esp", "%eax", "%edi");
@@ -59,14 +65,14 @@ void test_main(void)
"movl %1, (%%esp);" // Try to call SYS_WRITE
"movl %2, 4(%%esp);" // Write to STDOUT
"movl %3, 8(%%esp);" // Load buffer.
- //"movl $6, 12(%%esp);" // Can not write the last parameter as we would get a pagefault.
+ //"movl $5, 12(%%esp);" // Can not write the last parameter as we would get a pagefault.
"int $0x30;"
"movl %%edi, %%esp;" // Restore esp in case we do not crash (as we should).
:
: "r" (base),
"i" (SYS_WRITE),
"i" (STDOUT_FILENO),
- "i" ("FAIL!\n")
+ "r" (FAIL)
: "%esp", "%eax", "%edi");
fail("should have died.");
diff --git a/src/threads/init.c b/src/threads/init.c
index 16be95d..ee05db1 100644
--- a/src/threads/init.c
+++ b/src/threads/init.c
@@ -410,10 +410,16 @@ hard_power_off (void)
ACPI shutdown should use:
outw(PM1a_CNT, SLP_TYPa | SLP_EN );
Gathering of the corect values for the parameters is not easy.
- This works for QEMU and Bochs. It's not portable.
+ This works for QEMU and Bochs. It's not portable (and does not work in the latest QEMU).
*/
outw(0xB004, 0x2000);
+ /* Even more recent versions of QEMU needs other measures for shutdown.
+ * See: https://wiki.osdev.org/Shutdown
+ * Exit code is the value to outb * 2 + 1, so we can not exit cleanly...
+ */
+ outb(0xF4, 0x30);
+
/* This is APM Shutdown */
for (p = s; *p != '\0'; p++)
outb (0x8900, *p);
diff --git a/src/utils/pintos b/src/utils/pintos
index 546b152..e0cc5ac 100755
--- a/src/utils/pintos
+++ b/src/utils/pintos
@@ -484,10 +484,13 @@ sub run_qemu {
my (@cmd) = ('qemu-system-i386'); # klaar@ida 2015-02-13
for my $iface (0...3) {
+ # filst@ida 2018-04-18:
+ # Use -drive file=<file>,index=<index>,format=raw to avoid warnings on newer Qemu
my ($option) = ('-hda', '-hdb', '-hdc', '-hdd')[$iface];
- push (@cmd, $option, $disks_by_iface[$iface]{FILE_NAME})
+ push (@cmd, '-drive', "file=" . $disks_by_iface[$iface]{FILE_NAME} . ",index=$iface,format=raw")
if defined $disks_by_iface[$iface]{FILE_NAME};
}
+
# klaar@ida 2015-03-18:
# '-p' is not supported on modern qemu
# '-s' is default for '-gdb tcp:1234' on modern qemu
@@ -504,7 +507,23 @@ sub run_qemu {
# push (@cmd, '-s', '-S') if $debug eq 'gdb'; # replaced by above
push (@cmd, '-monitor', 'null') if $vga eq 'none' && $debug eq 'none';
push (@cmd, '-nographic') if $vga eq 'none';
- run_command (@cmd);
+
+ # Insert a device that lets us shutdown Pintos. See https://wiki.osdev.org/Shutdown for details
+ push (@cmd, '-device', 'isa-debug-exit,iobase=0xf4,iosize=0x04');
+
+ # When using isa-debug-exit, we can not exit QEMU cleanly. We exit with 0x30, which will make QEMU exit
+ # with the code 0x30*2 + 1 = 97, and therefore we treat 97 as success as well.
+ print join (' ', @cmd), "\n";
+ my ($exit) = xsystem (@cmd);
+ if (WIFEXITED($exit)) {
+ $exit = WEXITSTATUS($exit);
+ if ($exit == 97) {
+ # We use this code to exit cleanly from within Pintos (see https://wiki.osdev.org/Shutdown)
+ # since we can not exit with code 0 using the debug shutdown device in QEMU.
+ $exit = 0;
+ }
+ }
+ die "command failed\n" if $exit;
}
# player_unsup($flag)
@@ -867,7 +886,7 @@ sub get_load_average {
# Calls setitimer to set a timeout, then execs what was passed to us.
sub exec_setitimer {
if (defined $timeout) {
- if ($ ge 5.8.0) {
+ if ($^V ge 5.8.0) {
eval "
use Time::HiRes qw(setitimer ITIMER_VIRTUAL);
setitimer (ITIMER_VIRTUAL, $timeout, 0);