my solution to lab5

This commit is contained in:
winPond
2019-07-11 19:40:12 +08:00
parent 1f043fb694
commit f78713349c
364 changed files with 8775 additions and 3249 deletions

22
lab/user/faultio.c Normal file
View File

@@ -0,0 +1,22 @@
// test user-level fault handler -- alloc pages to fix faults
#include <inc/lib.h>
#include <inc/x86.h>
void
umain(int argc, char **argv)
{
int x, r;
int nsecs = 1;
int secno = 0;
int diskno = 1;
if (read_eflags() & FL_IOPL_3)
cprintf("eflags wrong\n");
// this outb to select disk 1 should result in a general protection
// fault, because user-level code shouldn't be able to use the io space.
outb(0x1F6, 0xE0 | (1<<4));
cprintf("%s: made it here --- bug\n");
}