This commit is contained in:
Anish Athalye
2018-10-24 20:44:45 -04:00
parent da1f8392b1
commit c67463e23c
71 changed files with 4734 additions and 18 deletions

View File

@@ -76,6 +76,24 @@ KERN_BINFILES += user/idle \
user/pingpong \
user/pingpongs \
user/primes
# Binary files for LAB5
KERN_BINFILES += user/faultio\
user/spawnfaultio\
user/testfile \
user/spawnhello \
user/icode \
fs/fs
# Binary files for LAB5
KERN_BINFILES += user/testpteshare \
user/testfdsharing \
user/testpipe \
user/testpiperace \
user/testpiperace2 \
user/primespipe \
user/testkbd \
user/testshell
KERN_OBJFILES := $(patsubst %.c, $(OBJDIR)/%.o, $(KERN_SRCFILES))
KERN_OBJFILES := $(patsubst %.S, $(OBJDIR)/%.o, $(KERN_OBJFILES))
KERN_OBJFILES := $(patsubst $(OBJDIR)/lib/%, $(OBJDIR)/kern/%, $(KERN_OBJFILES))

View File

@@ -102,6 +102,9 @@ serial_init(void)
(void) inb(COM1+COM_IIR);
(void) inb(COM1+COM_RX);
// Enable serial interrupts
if (serial_exists)
irq_setmask_8259A(irq_mask_8259A & ~(1<<IRQ_SERIAL));
}

View File

@@ -258,7 +258,7 @@ env_alloc(struct Env **newenv_store, envid_t parent_id)
env_free_list = e->env_link;
*newenv_store = e;
cprintf("[%08x] new env %08x\n", curenv ? curenv->env_id : 0, e->env_id);
// cprintf("[%08x] new env %08x\n", curenv ? curenv->env_id : 0, e->env_id);
return 0;
}
@@ -353,6 +353,9 @@ void
env_create(uint8_t *binary, enum EnvType type)
{
// LAB 3: Your code here.
// If this is the file server (type == ENV_TYPE_FS) give it I/O privileges.
// LAB 5: Your code here.
}
//
@@ -372,7 +375,7 @@ env_free(struct Env *e)
lcr3(PADDR(kern_pgdir));
// Note the environment's demise.
cprintf("[%08x] free env %08x\n", curenv ? curenv->env_id : 0, e->env_id);
// cprintf("[%08x] free env %08x\n", curenv ? curenv->env_id : 0, e->env_id);
// Flush all mapped pages in the user portion of the address space
static_assert(UTOP % PTSIZE == 0);

View File

@@ -47,14 +47,20 @@ i386_init(void)
// Starting non-boot CPUs
boot_aps();
// Start fs.
ENV_CREATE(fs_fs, ENV_TYPE_FS);
#if defined(TEST)
// Don't touch -- used by grading script!
ENV_CREATE(TEST, ENV_TYPE_USER);
#else
// Touch all you want.
ENV_CREATE(user_primes, ENV_TYPE_USER);
ENV_CREATE(user_icode, ENV_TYPE_USER);
#endif // TEST*
// Should not be necessary - drains keyboard because interrupt has given up.
kbd_intr();
// Schedule and run the first user environment!
sched_yield();
}

View File

@@ -84,6 +84,8 @@ static void check_page_installed_pgdir(void);
// If we're out of memory, boot_alloc should panic.
// This function may ONLY be used during initialization,
// before the page_free_list list has been set up.
// Note that when this function is called, we are still using entry_pgdir,
// which only maps the first 4MB of physical memory.
static void *
boot_alloc(uint32_t n)
{

View File

@@ -21,7 +21,8 @@ sched_yield(void)
//
// If no envs are runnable, but the environment previously
// running on this CPU is still ENV_RUNNING, it's okay to
// choose that environment.
// choose that environment. Make sure curenv is not null before
// dereferencing it.
//
// Never choose an environment that's currently running on
// another CPU (env_status == ENV_RUNNING). If there are

View File

@@ -55,10 +55,6 @@ sys_env_destroy(envid_t envid)
if ((r = envid2env(envid, &e, 1)) < 0)
return r;
if (e == curenv)
cprintf("[%08x] exiting gracefully\n", curenv->env_id);
else
cprintf("[%08x] destroying %08x\n", curenv->env_id, e->env_id);
env_destroy(e);
return 0;
}
@@ -107,6 +103,22 @@ sys_env_set_status(envid_t envid, int status)
panic("sys_env_set_status not implemented");
}
// Set envid's trap frame to 'tf'.
// tf is modified to make sure that user environments always run at code
// protection level 3 (CPL 3), interrupts enabled, and IOPL of 0.
//
// Returns 0 on success, < 0 on error. Errors are:
// -E_BAD_ENV if environment envid doesn't currently exist,
// or the caller doesn't have permission to change envid.
static int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
// LAB 5: Your code here.
// Remember to check whether the user has supplied us with a good
// address!
panic("sys_env_set_trapframe not implemented");
}
// Set the page fault upcall for 'envid' by modifying the corresponding struct
// Env's 'env_pgfault_upcall' field. When 'envid' causes a page fault, the
// kernel will push a fault record onto the exception stack, then branch to

View File

@@ -190,6 +190,9 @@ trap_dispatch(struct Trapframe *tf)
// interrupt using lapic_eoi() before calling the scheduler!
// LAB 4: Your code here.
// Handle keyboard and serial interrupts.
// LAB 5: Your code here.
// Unexpected trap: The user process or the kernel has a bug.
print_trapframe(tf);
if (tf->tf_cs == GD_KT)