Transcript Chapter 12
Drivers and The Kernel
Chapter 12
Presentation by:
Kathleen Pensy
Purpose
Assembles:
• Processes
• Signals and semaphores
• Virtual Memory
• File System
• Interprocess Communication
Terms
• Device Driver -A program that extends the operating
system to support a device such as a disk or tape drive;
or a program that enables an application to use a
device such as a printer driver. Hardware devices such
as sound cards, printers, scanners, and CD-ROM drives
must each have the proper driver installed in order to
run. Does not actually have to be associated with a
device (ie pseudo terminal).
• Module- a piece of kernel code that can be arbitrarily
loaded and unloaded during run time. They can be
installed and uninstalled as needed. Modules can be
arbitrarily loaded at boot time.
• Loadable device drivers – a device driver that is
implemented as a module.
The Kernel
• Device drivers
– Automatic detection
– Load all
• Location of build directory
– Solaris
– BSD
– Linux
build
kernel
/usr/src/sys
/usr/src/linux
/kernel
/kernel
/boot/vmlinuz
Configuring the Kernel
• Why?
– Unwanted drivers
– Drivers not loaded
– New hardware
• Tailor System –good thing (NOT)
– Book’s wrong!!!
– Only if you have a really pathetic system
– Some exceptions # of tty’s or connections
– Brian’s Rule – the cost of more memory or disk space is far
less expensive and produces a much greater result than
that of the cost of time and pain you will spend trying to
optimize your current system.
– I.E reasons I don’t support sound cards, and certain
devices.
Solaris Kernel
• Probes and automatically loads
• Areas
–
–
–
–
/kernel – instructions
/platform/platformname (ie Ultra 5)
/platform/hardware sun4u
/usr/kernel
• uname - Print certain system information.
• Directories pg 227
Solaris continued…
• /etc/system –very important
–
–
–
–
–
–
rootfs – type of root
rootdev – root partition
forceload – load devices
exclude – do not load devices
moddir – new path to modules
set – set variables
• pt_cnt – number of available pty’s
• max_nproc – max num. of proc.
• maxuprc – max num. of user proc.
• Examples:
– Set the number of pty’s when too many users are
connecting. Had problems on sunserver1 when too many
users were trying to ssh in. TTY will be explained later.
– Set the number of processes a given user can execute
(too many users).
– Max_nproc bad idea. Generally
Debugging
• Prtconf-general
information
• Sysdef - prtconf on
steroids
• Modinfo – dynamically
loaded modules
Linux Kernel
• Configuration menus
–
–
–
–
make xconfig – graphical configuration
make menuconfig curses configuration
Make config command line
.config contains everything about the kernel.
Linux continued
• Entries in .config
– M = enabled as module
– Y = compiled into kernel
• Compiling kernel:
–
–
–
–
–
–
–
–
Cd /usr/src/linux*
mrproper (not mentioned in the book)
make menuconfig
make dep
make clean
make bzImage
make modules
make modules_install
Linux continued …
• lilo.conf specifies boot
process
• /sbin/lilo – installs boot
loader that will be
activated next time you
boot
• lilo – linux loader, master
boot program or
secondar.
• Always backup your
new image
• Boot dos/windows
partitions as well
Linux continued…
Purpose is to allow run-time kernel modification
• Fine tuning
/proc/sys/fs
–
–
–
–
–
–
–
–
–
–
–
–
binfmt_misc
dquot-nr
inode-nr
leases-enable
dentry-state
file-max
inode-state
overflowgid
dir-notify-enable
file-nr
lease-break-time
overflowuid
• Not remembered across
reboots
• Try scripts
• From program sysctl (not
mentioned in the book)
• Kat’s #1 Rule – man
page is your friend
FreeBSD
• Similar to linux
• Location
– /usr/src/sys = source
– /usr/src/sys/arch/conf = configuration of kernel
• Configuration
–
–
–
–
–
Edit conf
Config from conf
Make depend
Make |& tee error
Man –k is your other good friend
BSD continued…
• /kernel = the kernel
back it up
• Configuration consists of
– machine, cpu, ident, maxusers, options, config,
controller, disk, tape, device, pseudo-device
– example including nfs in config
•
•
•
•
options NFS
Disk wd0 at wdc0 disk 0
Options “CD9660”
Controller isa0
• You can also change configuration on
runtime through sysctl as well
Device Drivers
• Device driver - manages systems interaction w/ a particular
piece of hardware.
• Configuring a driver for more than 20 computers can be
painful - This is why kat thinks linux sucks
• New devices = more pain (haha) a new device driver
• Never upgrade a driver unless absolutely necessary
• Solaris = easier
• Linux = (Get the picture?) harder
• /dev – device files that may link to device drivers
• ls –l lists the major and minor
– Major = device type
– Minor = particular instance of a given device
The frustration caused by
trying to configure a
device driver with
certain OS’s
Device files
• Many devices
– correspond to device files contained in /dev
• Types:
– Block – written or read as one block
– Character – written one byte at a time
• Standard interfaces:
–
–
–
–
Attach
Read
Transmit
Write
Psize
Timeout
ioctl
select
Strategy
Dump
resize
probe
Close
Receive
open
stop
–
–
–
–
Solaris
HP-UX
Linux
FreeBsd
/kernel/drv/*conf
/stand/system
/usr/src/linux/.config
/usr/src/sys/i386/conf/kernel
• Configuration files
/kernel/drv/*
/usr/conf/*
/usr/src/linux/drivers/*
/sys/i386/conf/files*
Standard device files
• Examples:
– Pty –pseudo termnials (ssh,xterm, telnet, rlogin)
–
–
–
–
• A slave and master the slave is actually controlled by the ssh,
etc what have you.
Loopback – network interface to local host (send to self)
Rmt – tapes
Rst – scsi tapes
Console device
• r= stands for the raw device
• Conventions for each are in the hand out.
– From Essential Systems Administrators Hand book. ( more
clear)
• Controller this is where disk is pluged device is the number at
which it is attached on that controller. Partition is the slice on
that disk.
• Create your own device file:
– Mknod or makedev
Structure
Device Drivers
Modules
Static Device Drivers
Loadable device drivers
Solaris Specific
• Devices
– Add
• add_drv – loads driver into the kernel
• pkgadd – very easy interface
– Remove
• pkgrm – easy
• rem_drv – unload by hand
• Modules
– Add
• modload – loads into the running file system
– Remove
• modunload – unloads it
– Modules can be linked and removed while the kernel is running
– Modinfo as seen before shows modules hardwired into the
kernel afs, nfs, tcp
Linux Specific
• Devices
– Adding Device driver
• cd /usr/src/linux ; patch –p1 < driver.diff
• Modules
– Add
• insmod /path/to/object.o
• Modprobe – install or remove into the kernel (can load all
modules from a directory)
– List
– modprobe -a -t boot
• lsmod – list modules
– Remove
• rmmod – remove modules
– Modprobe
• Can generate dynamic /etc/modules.conf
Questions
• Anyone have any questions?