CS318 - Pintos
Pintos source browser for JHU CS318 course
Functions | Variables
init.c File Reference
#include "threads/init.h"
#include <console.h>
#include <debug.h>
#include <inttypes.h>
#include <limits.h>
#include <random.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "devices/kbd.h"
#include "devices/input.h"
#include "devices/serial.h"
#include "devices/shutdown.h"
#include "devices/timer.h"
#include "devices/vga.h"
#include "devices/rtc.h"
#include "threads/interrupt.h"
#include "threads/io.h"
#include "threads/loader.h"
#include "threads/malloc.h"
#include "threads/palloc.h"
#include "threads/pte.h"
#include "threads/thread.h"
#include "tests/threads/tests.h"
Include dependency graph for init.c:

Go to the source code of this file.

Functions

static void bss_init (void)
 Clear the "BSS", a segment that should be initialized to zeros. More...
 
static void paging_init (void)
 Populates the base page directory and page table with the kernel virtual mapping, and then sets up the CPU to use the new page directory. More...
 
static char ** read_command_line (void)
 Breaks the kernel command line into words and returns them as an argv-like array. More...
 
static char ** parse_options (char **argv)
 Parses options in ARGV[] and returns the first non-option argument. More...
 
static void run_actions (char **argv)
 Executes all of the actions specified in ARGV[] up to the null pointer sentinel. More...
 
static void usage (void)
 Prints a kernel command line help message and powers off the machine. More...
 
int pintos_init (void)
 Pintos main entry point. More...
 
static void run_task (char **argv)
 Runs the task specified in ARGV[1]. More...
 

Variables

uint32_tinit_page_dir
 Page directory with kernel mappings only. More...
 
static size_t user_page_limit = SIZE_MAX
 -ul: Maximum number of pages to put into palloc's user pool. More...
 

Function Documentation

◆ bss_init()

static void bss_init ( void  )
static

Clear the "BSS", a segment that should be initialized to zeros.

It isn't actually stored on disk or zeroed by the kernel loader, so we have to zero it ourselves.

The start and end of the BSS segment is recorded by the linker as _start_bss and _end_bss. See kernel.lds.

Definition at line 151 of file init.c.

References memset().

Referenced by pintos_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ paging_init()

static void paging_init ( void  )
static

Populates the base page directory and page table with the kernel virtual mapping, and then sets up the CPU to use the new page directory.

Points init_page_dir to the page directory it creates.

Definition at line 162 of file init.c.

References _start(), init_page_dir, init_ram_pages, NULL, PAL_ASSERT, PAL_ZERO, palloc_get_page(), pd_no(), pde_create(), PGSIZE, pt_no(), pte_create_kernel(), ptov(), and vtop().

Referenced by pintos_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_options()

static char ** parse_options ( char **  argv)
static

Parses options in ARGV[] and returns the first non-option argument.

Definition at line 233 of file init.c.

References atoi(), name, NULL, PANIC, random_init(), rtc_get_time(), shutdown_configure(), SHUTDOWN_POWER_OFF, SHUTDOWN_REBOOT, strcmp(), strtok_r(), thread_mlfqs, usage(), and user_page_limit.

Referenced by pintos_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pintos_init()

int pintos_init ( void  )

◆ read_command_line()

static char ** read_command_line ( void  )
static

Breaks the kernel command line into words and returns them as an argv-like array.

Definition at line 198 of file init.c.

References arc4::i, LOADER_ARG_CNT, LOADER_ARGS, LOADER_ARGS_LEN, NULL, PANIC, printf(), ptov(), strchr(), and strnlen().

Referenced by pintos_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_actions()

static void run_actions ( char **  argv)
static

Executes all of the actions specified in ARGV[] up to the null pointer sentinel.

< Action name.

< # of args, including action name.

< Function to execute action.

Definition at line 302 of file init.c.

References fsutil_append(), fsutil_cat(), fsutil_extract(), fsutil_ls(), fsutil_rm(), name, NULL, PANIC, run_task(), and strcmp().

Referenced by pintos_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_task()

static void run_task ( char **  argv)
static

Runs the task specified in ARGV[1].

Definition at line 286 of file init.c.

References printf(), process_execute(), process_wait(), and run_test().

Referenced by run_actions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ usage()

static void usage ( void  )
static

Prints a kernel command line help message and powers off the machine.

Definition at line 353 of file init.c.

References printf(), and shutdown_power_off().

Referenced by parse_options().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ init_page_dir

uint32_t* init_page_dir

Page directory with kernel mappings only.

FILESYS

Definition at line 42 of file init.c.

Referenced by pagedir_activate(), pagedir_create(), pagedir_destroy(), pagedir_set_page(), and paging_init().

◆ user_page_limit

size_t user_page_limit = SIZE_MAX
static

-ul: Maximum number of pages to put into palloc's user pool.

Definition at line 58 of file init.c.

Referenced by palloc_init(), parse_options(), and pintos_init().