From owner-svn-doc-all@FreeBSD.ORG Tue Jan 14 23:45:41 2014 Return-Path: Delivered-To: svn-doc-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9171FA66; Tue, 14 Jan 2014 23:45:41 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 712AE16C3; Tue, 14 Jan 2014 23:45:41 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0ENjfTY026921; Tue, 14 Jan 2014 23:45:41 GMT (envelope-from wblock@svn.freebsd.org) Received: (from wblock@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0ENjfbS026920; Tue, 14 Jan 2014 23:45:41 GMT (envelope-from wblock@svn.freebsd.org) Message-Id: <201401142345.s0ENjfbS026920@svn.freebsd.org> From: Warren Block Date: Tue, 14 Jan 2014 23:45:41 +0000 (UTC) To: doc-committers@freebsd.org, svn-doc-all@freebsd.org, svn-doc-head@freebsd.org Subject: svn commit: r43527 - head/en_US.ISO8859-1/books/arch-handbook/boot X-SVN-Group: doc-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-doc-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire doc trees \(except for " user" , " projects" , and " translations" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jan 2014 23:45:41 -0000 Author: wblock Date: Tue Jan 14 23:45:40 2014 New Revision: 43527 URL: http://svnweb.freebsd.org/changeset/doc/43527 Log: Whitespace-only fixes, translators please ignore. Modified: head/en_US.ISO8859-1/books/arch-handbook/boot/chapter.xml Modified: head/en_US.ISO8859-1/books/arch-handbook/boot/chapter.xml ============================================================================== --- head/en_US.ISO8859-1/books/arch-handbook/boot/chapter.xml Tue Jan 14 22:21:52 2014 (r43526) +++ head/en_US.ISO8859-1/books/arch-handbook/boot/chapter.xml Tue Jan 14 23:45:40 2014 (r43527) @@ -6,13 +6,26 @@ Copyright (c) 2002 Sergey Lyubka - - Bootstrapping and Kernel Initialization + + + + + Bootstrapping and Kernel Initialization + - SergeyLyubkaContributed by + + + Sergey + Lyubka + + + Contributed by + + - Synopsis @@ -77,11 +90,11 @@ F5 Disk 2 >>FreeBSD/i386 BOOT Default: 1:ad(1,a)/boot/loader boot: - boot2This - prompt will appear if the user presses a key just - after selecting an OS to boot at the - boot0 - stage. + boot2 + This prompt will appear if the user + presses a key just after selecting an OS to boot + at the boot0 + stage. @@ -440,7 +453,7 @@ struct bootinfo { nbyte) are used to read the content of a file into memory. /boot/loader is an ELF binary, but where the ELF header is prepended with a.out's struct - exec structure. load() scans the + exec structure. load() scans the loader's ELF header, loading the content of /boot/loader into memory, and passing the execution to the loader's entry: @@ -680,8 +693,7 @@ begin: from the environment: /usr/src/sys/sys/kernel.h: -#define TUNABLE_INT_FETCH(path, var) getenv_int((path), (var)) - +#define TUNABLE_INT_FETCH(path, var) getenv_int((path), (var)) Sysctl kern.hz is the system clock tick. Additionally, these sysctls are set by @@ -689,8 +701,10 @@ begin: kern.maxbcache, kern.maxtsiz, kern.dfldsiz, kern.maxdsiz, kern.dflssiz, kern.maxssiz, kern.sgrowsiz. - Global Descriptors Table - (GDT) + + Global Descriptors Table (GDT) + + Then init386() prepares the Global Descriptors Table (GDT). Every task on an x86 is running in its own virtual address space, and this space is addressed by @@ -703,8 +717,9 @@ begin: virtual address for this example would just be the value of EIP. Segment registers such as CS, DS etc are the selectors, i.e., indexes, into GDT (to be more precise, an index is not a - selector itself, but the INDEX field of a selector). FreeBSD's - GDT holds descriptors for 15 selectors per CPU: + selector itself, but the INDEX field of a selector). + FreeBSD's GDT holds descriptors for 15 selectors per + CPU: sys/i386/i386/machdep.c: union descriptor gdt[NGDT * MAXCPU]; /* global descriptor table */ @@ -739,33 +754,32 @@ union descriptor gdt[NGDT * MAXCPU]; /* The next step is to initialize the Interrupt Descriptor Table (IDT). This table is referenced by the processor when a software or hardware interrupt occurs. For example, to make a - system call, user application issues the INT - 0x80 instruction. This is a software interrupt, so - the processor's hardware looks up a record with index 0x80 in - the IDT. This record points to the routine that handles this - interrupt, in this particular case, this will be the kernel's - syscall gate. The IDT may have a maximum of 256 (0x100) - records. The kernel allocates NIDT records for the IDT, where - NIDT is the maximum (256): + system call, user application issues the + INT 0x80 instruction. This is a software + interrupt, so the processor's hardware looks up a record with + index 0x80 in the IDT. This record points to the routine that + handles this interrupt, in this particular case, this will be + the kernel's syscall gate. The IDT may have a maximum of 256 + (0x100) records. The kernel allocates NIDT records for the + IDT, where NIDT is the maximum (256): sys/i386/i386/machdep.c: static struct gate_descriptor idt0[NIDT]; -struct gate_descriptor *idt = &idt0[0]; /* interrupt descriptor table */ - +struct gate_descriptor *idt = &idt0[0]; /* interrupt descriptor table */ For each interrupt, an appropriate handler is set. The syscall gate for INT 0x80 is set as well: sys/i386/i386/machdep.c: - setidt(0x80, &IDTVEC(int0x80_syscall), + setidt(0x80, &IDTVEC(int0x80_syscall), SDT_SYS386TGT, SEL_UPL, GSEL(GCODE_SEL, SEL_KPL)); - So when a userland application issues the INT - 0x80 instruction, control will transfer to the - function _Xint0x80_syscall, which is in - the kernel code segment and will be executed with supervisor - privileges. + So when a userland application issues the + INT 0x80 instruction, control will transfer + to the function _Xint0x80_syscall, which + is in the kernel code segment and will be executed with + supervisor privileges. Console and DDB are then initialized: DDB @@ -798,14 +812,13 @@ struct gate_descriptor *idt = &idt0[ /* separate stack, es,fs,gs sels ? */ /* #define LPOSIXCALLS_SEL 5*/ /* notyet */ #define LBSDICALLS_SEL 16 /* BSDI system call gate */ -#define NLDT (LBSDICALLS_SEL + 1) - +#define NLDT (LBSDICALLS_SEL + 1) - Next, proc0's Process Control Block (struct - pcb) structure is initialized. proc0 is a - struct proc structure that describes a - kernel process. It is always present while the kernel is - running, therefore it is declared as global: + Next, proc0's Process Control Block + (struct pcb) structure is initialized. + proc0 is a struct proc structure that + describes a kernel process. It is always present while the + kernel is running, therefore it is declared as global: sys/kern/kern_init.c: struct proc proc0; @@ -834,8 +847,8 @@ struct gate_descriptor *idt = &idt0[ /* ... skipped ... */ } - Although the sysinit framework is described in the - Developers' + Although the sysinit framework is described in the Developers' Handbook, I will discuss the internals of it. sysinit objects @@ -911,7 +924,7 @@ __asm(".previous"); structure, and that is what the second __asm is. The third __asm instruction marks the end of a - section. If a directive with the same section name occurred + section. If a directive with the same section name occurred before, the content, i.e., the 32-bit value, will be appended to the existing section, so forming an array of 32-bit pointers.