The Linux Kernel
From Wikibooks, the open-content textbooks collection
Contents |
[edit] Introduction
"The Linux Kernel" is intended to be the sequel to Updating the Linux kernel, going beyond user-level options and discussing details of interest to programmers.
[edit] System
System means general functions used to support and manage other kernel functionality. Synonym: infrastructure.
[edit] Booting and Halting
Booting
- wikipedia:Booting
- http://tldp.org/HOWTO/Linux-i386-Boot-Code-HOWTO/
- http://www.tldp.org/LDP/lki/lki-1.html
- http://www.tldp.org/HOWTO/KernelAnalysis-HOWTO-4.html
cat /proc/cmdline arch/i386/boot/bootsect.S arch/i386/kernel/head.S: calls start_kernel In init/main.c: start_kernel, rest_init, init, run_init_process
Halting and rebooting
- wikipedia:Shutdown
- "Linux for PowerPC Embedded Systems HOWTO: Boot Sequence" by Boas Betzler
- "Embedded Linux Howto" by Sebastien Huet
- "Migrating from x86 to PowerPC, Part 2: Anatomy of the Linux boot process" by Lewin Edwards
- "Inside the Linux boot process" by M. Tim Jones
- "Reducing OS Boot Times for In-Car Computer Applications" by Damien Stolarz
sys_reboot calls machine_restart or machine_halt or machine_power_off
[edit] Userspace communication
syscall, /proc, /dev, /sys
linux/proc_fs.h create_proc_entry etc
[edit] Devices
ls /dev cat /proc/devices
[edit] Char devices
Chapter 13. I/O Architecture and Device Drivers
[edit] DMA
- Documentation/DMA-mapping.txt
- DMA-able memory: pci_alloc_consistent __get_free_page kmalloc kmem_cache_alloc
- pci_pool
- LDD3:Memory Mapping and DMA
- http://www.xml.com/ldd/chapter/book/ch13.html mmap and DMA
SAC Single Address Cycle
[edit] Modules
lsmod cat /proc/modules
- kernel/kmod.c
- LDD3: Building and Running Modules
- http://www.xml.com/ldd/chapter/book/ch02.html
- http://www.tldp.org/LDP/tlk/modules/modules.html
- http://www.tldp.org/LDP/lkmpg/2.6/html/ The Linux Kernel Module Programming Guide
[edit] Hardware interfaces
[edit] I/O ports and registers
#include <asm/io.h> #include <linux/io.h> include/linux/ioport.h inb, outb etc
- LDD3:Communicating with Hardware
- http://www.xml.com/ldd/chapter/book/ch06.html
- ULK3 Chapter 13. I/O Architecture and Device Drivers
[edit] Hardware Device Drivers
Hardware Device Drivers are different from char and block devices.
or just Device Drivers
Keywords: kobjects, sysfs, buses, devices, drivers, classes, firmware, hotplug
- http://www.tldp.org/LDP/tlk/dd/drivers.html
- http://www.xml.com/ldd/chapter/book/
- http://examples.oreilly.com/linuxdrive2/
[edit] Busses: input, PCI, USB
Input bus: keyboard and mouse
cat /proc/bus/input/devices
PCI bus
pci_register_driver
lspci cat /proc/pci cat /proc/bus/pci/devices
- #include <linux/pci.h>
- Documentation/pci.txt
USB bus
lsusb cat /proc/bus/usb/devices
[edit] Debugging
- LDD3:Debugging Techniques
- http://www.xml.com/ldd/chapter/book/ch04.html
- http://www.kernelhacking.org/docs/kernelhacking-HOWTO/indexs09.html (no longer exists)
oops
- http://lxr.linux.no/source/Documentation/oops-tracing.txt
- http://www.urbanmyth.org/linux/oops/ Good presentation
- http://www.mulix.org/lectures/kernel_oopsing/kernel_oopsing.pdf
printk
linux/arch/i386/kernel/traps.c dump_stack show_registers die printk cat /proc/kmsg
SysRq, SysInfo (C/A/S - Scrol Lock) keys
KDB (Built-in Kernel Debugger) Local debugging.
- http://www-106.ibm.com/developerworks/linux/library/l-kdbug/?ca=dgr-wikiaKDB
- http://oss.sgi.com/projects/kdb/
- ftp://oss.sgi.com/www/projects/kdb/download/
Other
- http://user-mode-linux.sourceforge.net/
- CONFIG_MAGIC_SYSRQ, handle_sysrq
- http://lkcd.sourceforge.net/ Linux Kernel Crash Dump
KGDB Remote GDB debugging.
# gdb -q vmlinux (gdb) target remote /dev/ttyS0
Loading a module file in gdb with kgdb 1.8 and earlier
[edit] Processing
Processing: from process to CPU Processes and Tasks
- ULK3 Chapter 3. Processes
- ULK3 Chapter 4. Interrupts and Exceptions
- ULK3 Chapter 5. Kernel Synchronization
- ULK3 Chapter 6. Timing Measurements
- ULK3 Chapter 7. Process Scheduling
current task_struct cat /proc/self/
Synchronization
semaphore spinlock_t, timer_list, wait_queue_head_t
- LDD3:Concurrency and Race Conditions
- http://www.tldp.org/LDP/tlk/kernel/kernel.html
- http://www.tldp.org/LDP/lki/lki-2.html
Time and Timers
jiffies, irq0, timer_interrupt, do_timer_interrupt
Interrupts
/proc/interrupts
- http://www.tldp.org/LDP/tlk/dd/interrupts.html
- LDD3:Interrupt Handling
- http://www.xml.com/ldd/chapter/book/ch09.html
Bottom Halves
IPC
ls /proc/sysvipc/
[edit] Memory
Memory: from sys_bkr, sys_mmap2 to RAM
http://linux-mm.org/LinuxMM
cat /proc/meminfo include/linux/sched.h mm_struct #include <linux/mm.h> #include <linux/malloc.h> kmalloc, kfree
#include <linux/vmalloc.h> vmalloc, vfree
#include <asm/io.h>
ioremap, iounmap
Internal representation:
page at #include <linux/mm.h>
- ULK3 Chapter 2. Memory Addressing
- ULK3 Chapter 8. Memory Management
- ULK3 Chapter 9. Process Address Space
- LDD3:Allocating Memory
- LDD3:Data Types in the Kernel
- http://www.tldp.org/LDP/tlk/mm/memory.html
- http://www.tldp.org/LDP/lki/lki-4.html
- http://www.xml.com/ldd/chapter/book/ch07.html Getting Hold of Memory
- http://www.xml.com/ldd/chapter/book/ch13.html mmap and DMA
- http://www.tldp.org/HOWTO/KernelAnalysis-HOWTO-7.html
Cache
[edit] Storage
Storage: from file to hard disk
cat /proc/filesystems
VFS
See also: #NFS, #procfs, #sysfs
[edit] Block devices
[edit] Networking
Networking: from socket to network card
netif_rx
- include/linux/if.h netif_carrier_on ...
- include/linux/skbuff.h
- {{linux file|include/linux/etherdevice.h} ether_setup
- register_netdev
- Example of ethernet drivers: e100_probe, e1000_probe
Transport layer and TCP
ls /proc/net/ socket @ include/linux/net.h
Application layer and NFS
ls /proc/fs/
[edit] See also
[edit] External links
- kernelnewbies.org - information for (beginning) Linux kernel developers
- Email lists for linux kernel developers
- Linux Kernel Trace Seminar
- Kernel Build HOWTO
- http://tldp.org/HOWTO/HOWTO-INDEX/os.html#OSKERNEL
- http://tldp.org/HOWTO/Kernel-HOWTO/
- http://www.tldp.org/HOWTO/KernelAnalysis-HOWTO.html March 26, 2003
- http://lxr.linux.no/source/
- http://fxr.watson.org/ FreeBSD/Linux kernel cross-reference
Books (paper and ebooks):
- Linux Device Drivers, 3rd Edition HTML, pdf@Open Book pdf@lwn.net @amazon
- Linux Kernel Development (2nd Edition) by Robert Love
- Understanding the Linux Kernel, Third Edition, @safari.oreilly.com
- Interactive Linux kernel map
- "The Linux Kernel HOWTO" by Al Dev (Alavoor Vasudevan) 2003
- Linux Technology Reference
Linux kernel based projects:
Historical books:
- Linux Kernel 2.4 Internals, Tigran Aivazian, 7 August 2002, GPL
- The Linux Kernel 2.0.33, David A Rusling, 1996-1999, need permission or notice
- Kernel Hacking HOWTO, Andrew Ebling, 2002-3-27
- Index of Documentation
Embedded Linux references: using Linux in an Embedded Systems:
- Embedded Systems/Linux
- "Flash Filesystems for Embedded Linux Systems" by Cliff Brake and Jeff Sutherland
- "Flash Filesystems for Embedded Linux Systems" by Cliff Brake
- "Embedded Linux: Hardware, Software, and Interfacing" book by Craig Hollabaugh
- "Embedded Linux" book by John Lombardo
- "Embedded Linux Primer" book by Christopher Hallinan