Linux i386 Boot Code HOWTO

Feiyun Wang

2004-01-23

Revision History
Revision 1.02004-02-19FW
Initial release, reviewed by LDP
Revision 0.3.32004-01-23fyw
Add decompress_kernel() details; Fix bugs reported in TLDP final review.
Revision 0.32003-12-07fyw
Add contents on SMP, GRUB and LILO; Fix and enhance.
Revision 0.22003-08-17fyw
Adapt to Linux 2.4.20.
Revision 0.12003-04-20fyw
Change to DocBook XML format.

Abstract

This document describes Linux i386 boot code, serving as a study guide and source commentary. In addition to C-like pseudocode source commentary, it also presents keynotes of toolchains and specs related to kernel development. It is designed to help:

  • kernel newbies to understand Linux i386 boot code, and

  • kernel veterans to recall Linux boot procedure.


Table of Contents

1. Introduction
1.1. Copyright and License
1.2. Disclaimer
1.3. Credits / Contributors
1.4. Feedback
1.5. Translations
2. Linux Makefiles
2.1. linux/Makefile
2.2. linux/arch/i386/vmlinux.lds
2.3. linux/arch/i386/Makefile
2.4. linux/arch/i386/boot/Makefile
2.5. linux/arch/i386/boot/compressed/Makefile
2.6. linux/arch/i386/tools/build.c
2.7. Reference
3. linux/arch/i386/boot/bootsect.S
3.1. Move Bootsect
3.2. Get Disk Parameters
3.3. Load Setup Code
3.4. Load Compressed Image
3.5. Go Setup
3.6. Read Disk
3.7. Bootsect Helper
3.8. Miscellaneous
3.9. Reference
4. linux/arch/i386/boot/setup.S
4.1. Header
4.2. Check Code Integrity
4.3. Check Loader Type
4.4. Get Memory Size
4.5. Hardware Support
4.6. APM Support
4.7. Prepare for Protected Mode
4.8. Enable A20
4.9. Switch to Protected Mode
4.10. Miscellaneous
4.11. Reference
5. linux/arch/i386/boot/compressed/head.S
5.1. Decompress Kernel
5.2. gunzip()
5.3. inflate()
5.4. Reference
6. linux/arch/i386/kernel/head.S
6.1. Enable Paging
6.2. Get Kernel Parameters
6.3. Check CPU Type
6.4. Go Start Kernel
6.5. Miscellaneous
6.6. Reference
7. linux/init/main.c
7.1. start_kernel()
7.2. init()
7.3. cpu_idle()
7.4. Reference
8. SMP Boot
8.1. Before smp_init()
8.2. smp_init()
8.3. linux/arch/i386/kernel/trampoline.S
8.4. initialize_secondary()
8.5. start_secondary()
8.6. Reference
A. Kernel Build Example
B. Internal Linker Script
C. GRUB and LILO
C.1. GNU GRUB
C.2. LILO
C.3. Reference
D. FAQ