#include "userprog/process.h"
#include <debug.h>
#include <inttypes.h>
#include <round.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "userprog/gdt.h"
#include "userprog/pagedir.h"
#include "userprog/tss.h"
#include "filesys/directory.h"
#include "filesys/file.h"
#include "filesys/filesys.h"
#include "threads/flags.h"
#include "threads/init.h"
#include "threads/interrupt.h"
#include "threads/palloc.h"
#include "threads/thread.h"
#include "threads/vaddr.h"
Go to the source code of this file.
Data Structures | |
struct | Elf32_Ehdr |
struct | Elf32_Phdr |
Defines | |
#define | PE32Wx PRIx32 |
#define | PE32Ax PRIx32 |
#define | PE32Ox PRIx32 |
#define | PE32Hx PRIx16 |
#define | PT_NULL 0 |
#define | PT_LOAD 1 |
#define | PT_DYNAMIC 2 |
#define | PT_INTERP 3 |
#define | PT_NOTE 4 |
#define | PT_SHLIB 5 |
#define | PT_PHDR 6 |
#define | PT_STACK 0x6474e551 |
#define | PF_X 1 |
#define | PF_W 2 |
#define | PF_R 4 |
Typedefs | |
typedef uint32_t | Elf32_Word |
typedef uint32_t | Elf32_Addr |
typedef uint32_t | Elf32_Off |
typedef uint16_t | Elf32_Half |
Functions | |
static bool | load (const char *cmdline, void(**eip)(void), void **esp) |
tid_t | process_execute (const char *file_name) |
static void | start_process (void *file_name_) |
int | process_wait (tid_t child_tid UNUSED) |
void | process_exit (void) |
void | process_activate (void) |
static bool | setup_stack (void **esp) |
static bool | validate_segment (const struct Elf32_Phdr *, struct file *) |
static bool | load_segment (struct file *file, off_t ofs, uint8_t *upage, uint32_t read_bytes, uint32_t zero_bytes, bool writable) |
static bool | install_page (void *upage, void *kpage, bool writable) |
Variables | |
static thread_func start_process | NO_RETURN |
typedef uint32_t Elf32_Addr |
typedef uint16_t Elf32_Half |
typedef uint32_t Elf32_Word |
static bool install_page | ( | void * | upage, | |
void * | kpage, | |||
bool | writable | |||
) | [static] |
Definition at line 458 of file process.c.
References NULL, pagedir_get_page(), pagedir_set_page(), and thread_current().
Referenced by load_segment(), and setup_stack().
bool load | ( | const char * | cmdline, | |
void(**)(void) | eip, | |||
void ** | esp | |||
) | [static] |
Definition at line 210 of file process.c.
References Elf32_Ehdr::e_entry, Elf32_Ehdr::e_ident, Elf32_Ehdr::e_machine, Elf32_Ehdr::e_phentsize, Elf32_Ehdr::e_phnum, Elf32_Ehdr::e_phoff, Elf32_Ehdr::e_type, Elf32_Ehdr::e_version, file_close(), file_length(), file_read(), file_seek(), filesys_open(), load_segment(), memcmp(), NULL, Elf32_Phdr::p_filesz, Elf32_Phdr::p_flags, Elf32_Phdr::p_memsz, Elf32_Phdr::p_offset, Elf32_Phdr::p_type, Elf32_Phdr::p_vaddr, pagedir_create(), PF_W, PGMASK, PGSIZE, printf(), process_activate(), PT_DYNAMIC, PT_INTERP, PT_LOAD, PT_NOTE, PT_NULL, PT_PHDR, PT_SHLIB, PT_STACK, ROUND_UP, setup_stack(), thread_current(), and validate_segment().
Referenced by start_process().
static bool load_segment | ( | struct file * | file, | |
off_t | ofs, | |||
uint8_t * | upage, | |||
uint32_t | read_bytes, | |||
uint32_t | zero_bytes, | |||
bool | writable | |||
) | [static] |
Definition at line 384 of file process.c.
References ASSERT, file_read(), file_seek(), install_page(), memset(), NULL, PAL_USER, palloc_free_page(), palloc_get_page(), pg_ofs(), and PGSIZE.
Referenced by load().
void process_activate | ( | void | ) |
Definition at line 124 of file process.c.
References pagedir_activate(), thread_current(), and tss_update().
Referenced by load(), and schedule_tail().
tid_t process_execute | ( | const char * | file_name | ) |
Definition at line 30 of file process.c.
References NULL, palloc_free_page(), palloc_get_page(), PGSIZE, PRI_DEFAULT, start_process(), strlcpy(), thread_create(), thread::tid, and TID_ERROR.
Referenced by run_task().
void process_exit | ( | void | ) |
Definition at line 97 of file process.c.
References NULL, pagedir_activate(), pagedir_destroy(), and thread_current().
Referenced by thread_exit().
int process_wait | ( | tid_t child_tid | UNUSED | ) |
static bool setup_stack | ( | void ** | esp | ) | [static] |
Definition at line 431 of file process.c.
References install_page(), NULL, PAL_USER, PAL_ZERO, palloc_free_page(), palloc_get_page(), PGSIZE, and PHYS_BASE.
Referenced by load().
static void start_process | ( | void * | file_name_ | ) | [static] |
Definition at line 52 of file process.c.
References intr_frame::cs, intr_frame::ds, intr_frame::eflags, intr_frame::eip, intr_frame::es, intr_frame::esp, file_name, FLAG_IF, FLAG_MBS, intr_frame::fs, intr_frame::gs, load(), memset(), NOT_REACHED, palloc_free_page(), SEL_UCSEG, SEL_UDSEG, intr_frame::ss, and thread_exit().
Referenced by process_execute().
static bool validate_segment | ( | const struct Elf32_Phdr * | phdr, | |
struct file * | file | |||
) | [static] |
Definition at line 327 of file process.c.
References file_length(), is_user_vaddr(), Elf32_Phdr::p_filesz, Elf32_Phdr::p_memsz, Elf32_Phdr::p_offset, Elf32_Phdr::p_vaddr, PGMASK, and PGSIZE.
Referenced by load().
thread_func start_process NO_RETURN [static] |