FreeBSD kernel kern code
init_main.c File Reference
#include <sys/cdefs.h>
#include "opt_ddb.h"
#include "opt_kdb.h"
#include "opt_init_path.h"
#include "opt_verbose_sysinit.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/boottrace.h>
#include <sys/conf.h>
#include <sys/cpuset.h>
#include <sys/dtrace_bsd.h>
#include <sys/epoch.h>
#include <sys/eventhandler.h>
#include <sys/exec.h>
#include <sys/file.h>
#include <sys/filedesc.h>
#include <sys/imgact.h>
#include <sys/jail.h>
#include <sys/kernel.h>
#include <sys/ktr.h>
#include <sys/lock.h>
#include <sys/loginclass.h>
#include <sys/malloc.h>
#include <sys/mount.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/racct.h>
#include <sys/reboot.h>
#include <sys/resourcevar.h>
#include <sys/sched.h>
#include <sys/signalvar.h>
#include <sys/sx.h>
#include <sys/syscallsubr.h>
#include <sys/sysctl.h>
#include <sys/sysent.h>
#include <sys/sysproto.h>
#include <sys/unistd.h>
#include <sys/vmmeter.h>
#include <sys/vnode.h>
#include <machine/cpu.h>
#include <security/audit/audit.h>
#include <security/mac/mac_framework.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_extern.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
#include <sys/copyright.h>
#include <ddb/ddb.h>
#include <ddb/db_sym.h>

Go to the source code of this file.

Macros

#define BOOTHOWTO   0
 
#define BOOTVERBOSE   0
 
#define INIT_SHUTDOWN_TIMEOUT   120
 

Functions

 __FBSDID ("$FreeBSD$")
 
void mi_startup (void)
 
struct thread0_storage thread0_st __aligned (32)
 
int linux_alloc_current_noop (struct thread *td __unused, int flags __unused)
 
 SYSCTL_INT (_debug, OID_AUTO, boothowto, CTLFLAG_RD, &boothowto, 0, "Boot control flags, passed from loader")
 
 SYSCTL_INT (_debug, OID_AUTO, bootverbose, CTLFLAG_RW, &bootverbose, 0, "Control the output of verbose kernel messages")
 
 SYSINIT (placeholder, SI_SUB_DUMMY, SI_ORDER_ANY, NULL, NULL)
 
 SET_DECLARE (sysinit_set, struct sysinit)
 
void sysinit_add (struct sysinit **set, struct sysinit **set_end)
 
static void print_caddr_t (void *data)
 
static void print_version (void *data __unused)
 
 SYSINIT (announce, SI_SUB_COPYRIGHT, SI_ORDER_FIRST, print_caddr_t, copyright)
 
 SYSINIT (trademark, SI_SUB_COPYRIGHT, SI_ORDER_SECOND, print_caddr_t, trademark)
 
 SYSINIT (version, SI_SUB_COPYRIGHT, SI_ORDER_THIRD, print_version, NULL)
 
static int null_fetch_syscall_args (struct thread *td __unused)
 
static void null_set_syscall_retval (struct thread *td __unused, int error __unused)
 
static void null_set_fork_retval (struct thread *td __unused)
 
static void proc0_init (void *dummy __unused)
 
 SYSINIT (p0init, SI_SUB_INTRINSIC, SI_ORDER_FIRST, proc0_init, NULL)
 
static void proc0_post (void *dummy __unused)
 
 SYSINIT (p0post, SI_SUB_INTRINSIC_POST, SI_ORDER_FIRST, proc0_post, NULL)
 
 SYSCTL_STRING (_kern, OID_AUTO, init_path, CTLFLAG_RD, init_path, 0, "Path used to search the init process")
 
 SYSCTL_INT (_kern, OID_AUTO, init_shutdown_timeout, CTLFLAG_RW, &init_shutdown_timeout, 0, "Shutdown timeout of init(8). " "Unused within kernel, but used to control init(8)")
 
static void start_init (void *dummy)
 
static void create_init (const void *udata __unused)
 
 SYSINIT (init, SI_SUB_CREATE_INIT, SI_ORDER_FIRST, create_init, NULL)
 
static void kick_init (const void *udata __unused)
 
 SYSINIT (kickinit, SI_SUB_KTHREAD_INIT, SI_ORDER_MIDDLE, kick_init, NULL)
 

Variables

static struct session session0
 
static struct pgrp pgrp0
 
struct proc proc0
 
struct vmspace vmspace0
 
struct proc * initproc
 
int(* lkpi_alloc_current )(struct thread *, int) = linux_alloc_current_noop
 
int boothowto = BOOTHOWTO
 
int bootverbose = BOOTVERBOSE
 
struct sysinit ** sysinit
 
struct sysinit ** sysinit_end
 
struct sysinit ** newsysinit
 
struct sysinit ** newsysinit_end
 
struct sysentvec null_sysvec
 
static char init_path [MAXPATHLEN]
 
static int init_shutdown_timeout = INIT_SHUTDOWN_TIMEOUT
 

Macro Definition Documentation

◆ BOOTHOWTO

#define BOOTHOWTO   0

Definition at line 122 of file init_main.c.

◆ BOOTVERBOSE

#define BOOTVERBOSE   0

Definition at line 129 of file init_main.c.

◆ INIT_SHUTDOWN_TIMEOUT

#define INIT_SHUTDOWN_TIMEOUT   120

Definition at line 708 of file init_main.c.

Function Documentation

◆ __aligned()

struct thread0_storage thread0_st __aligned ( 32  )

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ create_init()

static void create_init ( const void *udata  __unused)
static

Definition at line 808 of file init_main.c.

References crcopy(), crcowfree(), crcowget(), crfree(), crget(), fork1(), initproc, panic(), proc_set_cred(), proctree_lock, and start_init().

Here is the call graph for this function:

◆ kick_init()

static void kick_init ( const void *udata  __unused)
static

Definition at line 853 of file init_main.c.

References initproc, and sched_add().

Here is the call graph for this function:

◆ linux_alloc_current_noop()

int linux_alloc_current_noop ( struct thread *td  __unused,
int flags  __unused 
)

Definition at line 115 of file init_main.c.

◆ mi_startup()

void mi_startup ( void  )

Definition at line 231 of file init_main.c.

References boothowto, bootverbose, data, free(), Giant, newsysinit, newsysinit_end, printf(), symbol_name(), sysinit, and sysinit_end.

Here is the call graph for this function:

◆ null_fetch_syscall_args()

static int null_fetch_syscall_args ( struct thread *td  __unused)
static

Definition at line 397 of file init_main.c.

References panic().

Here is the call graph for this function:

◆ null_set_fork_retval()

static void null_set_fork_retval ( struct thread *td  __unused)
static

Definition at line 411 of file init_main.c.

◆ null_set_syscall_retval()

static void null_set_syscall_retval ( struct thread *td  __unused,
int error  __unused 
)
static

Definition at line 404 of file init_main.c.

References panic().

Here is the call graph for this function:

◆ print_caddr_t()

static void print_caddr_t ( void *  data)
static

Definition at line 354 of file init_main.c.

References data, and printf().

Here is the call graph for this function:

◆ print_version()

static void print_version ( void *data  __unused)
static

Definition at line 360 of file init_main.c.

References printf().

Here is the call graph for this function:

◆ proc0_init()

◆ proc0_post()

static void proc0_post ( void *dummy  __unused)
static

Definition at line 646 of file init_main.c.

References allproc_lock, cpu_ticks, microuptime(), rufetch(), and ticks.

Here is the call graph for this function:

◆ SET_DECLARE()

SET_DECLARE ( sysinit_set  ,
struct sysinit   
)

◆ start_init()

static void start_init ( void *  dummy)
static

Definition at line 720 of file init_main.c.

References boothowto, bootverbose, exec_alloc_args(), exec_args_add_arg(), exec_args_add_fname(), exec_cleanup(), free(), freeenv(), init_path, kern_execve(), kern_getenv(), kern_unsetenv(), panic(), path, printf(), and vfs_mountroot().

Referenced by create_init().

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

◆ SYSCTL_INT() [1/3]

SYSCTL_INT ( _debug  ,
OID_AUTO  ,
boothowto  ,
CTLFLAG_RD  ,
boothowto,
,
"Boot control  flags,
passed from loader"   
)

◆ SYSCTL_INT() [2/3]

SYSCTL_INT ( _debug  ,
OID_AUTO  ,
bootverbose  ,
CTLFLAG_RW  ,
bootverbose,
,
"Control the output of verbose kernel messages"   
)

◆ SYSCTL_INT() [3/3]

SYSCTL_INT ( _kern  ,
OID_AUTO  ,
init_shutdown_timeout  ,
CTLFLAG_RW  ,
init_shutdown_timeout,
,
"Shutdown timeout of init(8). " "Unused within  kernel,
but used to control init(8)"   
)

◆ SYSCTL_STRING()

SYSCTL_STRING ( _kern  ,
OID_AUTO  ,
init_path  ,
CTLFLAG_RD  ,
init_path  ,
,
"Path used to search the init process"   
)

◆ SYSINIT() [1/8]

SYSINIT ( announce  ,
SI_SUB_COPYRIGHT  ,
SI_ORDER_FIRST  ,
print_caddr_t  ,
copyright   
)

◆ SYSINIT() [2/8]

SYSINIT ( init  ,
SI_SUB_CREATE_INIT  ,
SI_ORDER_FIRST  ,
create_init  ,
NULL   
)

◆ SYSINIT() [3/8]

SYSINIT ( kickinit  ,
SI_SUB_KTHREAD_INIT  ,
SI_ORDER_MIDDLE  ,
kick_init  ,
NULL   
)

◆ SYSINIT() [4/8]

SYSINIT ( p0init  ,
SI_SUB_INTRINSIC  ,
SI_ORDER_FIRST  ,
proc0_init  ,
NULL   
)

◆ SYSINIT() [5/8]

SYSINIT ( p0post  ,
SI_SUB_INTRINSIC_POST  ,
SI_ORDER_FIRST  ,
proc0_post  ,
NULL   
)

◆ SYSINIT() [6/8]

SYSINIT ( placeholder  ,
SI_SUB_DUMMY  ,
SI_ORDER_ANY  ,
NULL  ,
NULL   
)

◆ SYSINIT() [7/8]

SYSINIT ( trademark  ,
SI_SUB_COPYRIGHT  ,
SI_ORDER_SECOND  ,
print_caddr_t  ,
trademark   
)

◆ SYSINIT() [8/8]

SYSINIT ( version  ,
SI_SUB_COPYRIGHT  ,
SI_ORDER_THIRD  ,
print_version  ,
NULL   
)

◆ sysinit_add()

void sysinit_add ( struct sysinit **  set,
struct sysinit **  set_end 
)

Definition at line 171 of file init_main.c.

References count, free(), malloc(), newsysinit, newsysinit_end, panic(), set, sysinit, and sysinit_end.

Referenced by linker_preload().

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

Variable Documentation

◆ boothowto

int boothowto = BOOTHOWTO

Definition at line 124 of file init_main.c.

Referenced by cninit(), mi_startup(), start_init(), and vfs_mountroot_conf0().

◆ bootverbose

◆ init_path

char init_path[MAXPATHLEN]
static
Initial value:
=
"/sbin/init:/sbin/oinit:/sbin/init.bak:/rescue/init"

Definition at line 694 of file init_main.c.

Referenced by start_init().

◆ init_shutdown_timeout

int init_shutdown_timeout = INIT_SHUTDOWN_TIMEOUT
static

Definition at line 710 of file init_main.c.

◆ initproc

◆ lkpi_alloc_current

int(* lkpi_alloc_current) (struct thread *, int) ( struct thread *  ,
int   
) = linux_alloc_current_noop

Definition at line 119 of file init_main.c.

◆ newsysinit

struct sysinit** newsysinit

Definition at line 164 of file init_main.c.

Referenced by mi_startup(), and sysinit_add().

◆ newsysinit_end

struct sysinit ** newsysinit_end

Definition at line 164 of file init_main.c.

Referenced by mi_startup(), and sysinit_add().

◆ null_sysvec

struct sysentvec null_sysvec

Definition at line 416 of file init_main.c.

Referenced by proc0_init().

◆ pgrp0

struct pgrp pgrp0
static

Definition at line 108 of file init_main.c.

Referenced by proc0_init().

◆ proc0

struct proc proc0

◆ session0

struct session session0
static

Definition at line 107 of file init_main.c.

Referenced by proc0_init().

◆ sysinit

struct sysinit** sysinit

◆ sysinit_end

struct sysinit ** sysinit_end

Definition at line 163 of file init_main.c.

Referenced by mi_startup(), and sysinit_add().

◆ vmspace0

struct vmspace vmspace0

Definition at line 111 of file init_main.c.

Referenced by proc0_init().