Escolar Documentos
Profissional Documentos
Cultura Documentos
Agenda
System Initialization
Root File System
Kernels Last Boot Steps
init Process
Initial RAM Disk and use of initramfs
init Process
/sbin/init is spawned by the kernel on boot and becomes the first user
space program to run.
Kernel does following:
1. Mount the root file system
2. Spawn the first user program, init
Init is the ultimate parent of all user space processes in Linux system.
init provides the default set of environment parameters for all other
processes to inherit, e.g. PATH and CONSOLE
init processs primary role is to spawn additional process under the
direction of a special configuration file.
This configuration file is usually stored at/etc/inittab
Init has concept of a runlevel. A runlevel can be thought of as a system
state.
init Process
Each runlevel is defined by the services enabled and programs
spawned upon entry to that runlevel.
init can exist in a single runlevel at any given time.
Runlevels used by init includes runlevels from 0 to 6 and a special
runlevel S
For each runlevel, a set of startup and shutsown scripts is usually
provided that define the action a system should take for each runlevel.
Action to perform for a given runlevel are determined by the /etc/inittab
configuration file.
The runlevel scripts are commonly found under a directory called
/etc/rc.d/init.d
In this directory, most of the scripts are found to enable and disable
individual services, e.g. nfs service.
init Process
10
11
12
13
14
Device Driver
Device drivers are installed by default in /lib/modules/<kernel-version>/
directory.
This can be change by INSTALL_MOD_PATH directive.
Make arch=arm CROSS_COMPILE=mipsse64INSTALL_MOD_PATH=/hme/saurabh/sandbox/embedded-linux/
module_install
Loading and unloading of module is done by modprobe command.
modprobe hello1
modprobe r hello1
15
$ insmod
/lib/modules/2.6.14/kernel/drivers/char/examples/hello1.ko
16
17
$modprobe r ext3
18
$modprobe r ext3
19
Driver Methods
The open() method is used to prepare the driver for subsequent operations.
read()/ write() routines are used for reading and writing to the driver.
A release() routine is used to clean up after operations are completed, basically a close()
call.
A special system call is provided for non-standard communication to the driver. This is
called ioctl().
20
Driver Methods
21
Driver Methods
22
Driver Methods
23
The above command creates a new file /dev/hello1, that represents sample device driver
shown in earlier slides.
$ ls l /dev/hello1
crw-rr--
1 root root
/dev/hello1
The parameters passed to mknod include the name, type major and minor numbers for
/dev/hello1 device.
If an application process issues an open() system call with this device node as the path
parameter, the kernel searches for a valid device driver registered with a major number
that matches the device node, in this case, 234, This is the mechanism by which kernel
associates particular device driver to device node.
Proprietary & Confidential. Aricent Group 2011
24
25
26
Thanks