The Linux Kernel/System

From Wikibooks, open books for an open world
< The Linux Kernel
Jump to: navigation, search

System means general functions used to support and manage other kernel functionality. Synonym: infrastructure.

Booting and Halting[edit]

Booting


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


sys_reboot calls machine_restart or machine_halt or machine_power_off

Userspace communication[edit]

syscall, /proc, /dev, /sys
linux/proc_fs.h
create_proc_entry etc

Devices[edit]

ls /dev
cat /proc/devices

Char devices[edit]

Chapter 13. I/O Architecture and Device Drivers

DMA[edit]

SAC Single Address Cycle

Modules[edit]

lsmod
cat /proc/modules

Hardware interfaces[edit]

I/O ports and registers[edit]

Modern functions for port I/O:

ioport_map

ioread8 iowrite8

ioread16 iowrite16

ioread32 iowrite32

#include <linux/ioport.h>

Functions for memory mapped registers:

ioremap

readb writeb

readw writew

readl writel

The {in,out}[bwl] macros are for emulating x86-style PCI/ISA IO space:

inb outb

inw outw

inl outl

Hardware Device Drivers[edit]

Hardware Device Drivers are different from char and block devices.

or just Device Drivers

Keywords: kobjects, sysfs, buses, devices, drivers, classes, firmware, hotplug

Busses: input, PCI, USB[edit]

Input bus: keyboard and mouse

cat /proc/bus/input/devices

PCI bus

pci_register_driver
lspci
cat /proc/pci
cat /proc/bus/pci/devices

USB bus

lsusb
cat /proc/bus/usb/devices

Building and Updating[edit]

Debugging[edit]

  • git bisect ...

oops

printk

linux/arch/i386/kernel/traps.c
[1]

KDB (Built-in Kernel Debugger) Local debugging.

Other

KGDB Remote GDB debugging.

# gdb -q vmlinux
(gdb) target remote /dev/ttyS0