diff options
author | Frans Kaashoek <[email protected]> | 2016-08-26 08:20:11 -0400 |
---|---|---|
committer | Frans Kaashoek <[email protected]> | 2016-08-26 08:20:11 -0400 |
commit | aff0c8d5c709dc02669fbaa4b5ff2cfdda122a61 (patch) | |
tree | f369242b79c3d6ac61d21ba5fbc526b815096260 /usertests.c | |
parent | 745a4d31a6221c2c4b2b78f308c84edcbfb471d5 (diff) | |
download | xv6-labs-aff0c8d5c709dc02669fbaa4b5ff2cfdda122a61.tar.gz xv6-labs-aff0c8d5c709dc02669fbaa4b5ff2cfdda122a61.tar.bz2 xv6-labs-aff0c8d5c709dc02669fbaa4b5ff2cfdda122a61.zip |
set iomb to forbid i/o instructions from user space
add to test that they indeed trap in user space
thanks to [email protected] and [email protected]
Diffstat (limited to 'usertests.c')
-rw-r--r-- | usertests.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/usertests.c b/usertests.c index 458f8ed..93f656b 100644 --- a/usertests.c +++ b/usertests.c @@ -1695,6 +1695,35 @@ fsfull() printf(1, "fsfull test finished\n"); } +void +uio() +{ + #define RTC_ADDR 0x70 + #define RTC_DATA 0x71 + + ushort port = 0; + uchar val = 0; + int pid; + + printf(1, "uio test\n"); + pid = fork(); + if(pid == 0){ + port = RTC_ADDR; + val = 0x09; /* year */ + /* http://wiki.osdev.org/Inline_Assembly/Examples */ + asm volatile("outb %0,%1"::"a"(val), "d" (port)); + port = RTC_DATA; + asm volatile("inb %1,%0" : "=a" (val) : "d" (port)); + printf(1, "uio: uio succeeded; test FAILED\n"); + exit(); + } else if(pid < 0){ + printf (1, "fork failed\n"); + exit(); + } + wait(); + printf(1, "uio test done\n"); +} + unsigned long randstate = 1; unsigned int rand() @@ -1751,6 +1780,9 @@ main(int argc, char *argv[]) iref(); forktest(); bigdir(); // slow + + uio(); + exectest(); exit(); |