Linux内核介绍
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
arch
init
drivers
kernel
lib
include
CPU Arch
net
fs
block
cryto
Mach (Platform)
usr
ipc
mm
sound
scripts
Documentation
virt
Vendors Products
security
samples
ຫໍສະໝຸດ Baidu
Linux kernel subsystems
linux-2.6.x arch arm mach-at91 AT91SAM Products config AT91SAM AT91SAM AT91SAM Products Products Default Config 13 Vendors Vendors Products Kconfig Products Vendors Vendors Products Makefile Products init fs Sub-dirs Sub-dirs drivers net
10
Generated Linux Image
®
vmlinux
Non compressed elf format Can be used for debug
arch/arm/boot/Image
Binary kernel image
arch/arm/boot/zImage
zlib compressed kernel image Default image on arm
®
Minimum: 32 bit processors, with or without MMU 32 bit architectures:
alpha, arm, AVR32, cris, h8300, i386, m68k, m68knommu, mips, parisc, ppc, s390, sh, sparc, um, v850
Block devices
Can be accessed only as multiples of a block. Like char devices, block device are accessed by filesystem nodes A block device is device (e.g. disk) that can host a filesystem. Block drivers have a completely different interface to the kernel than char drivers
Create a ./.config file by using the default symbol values from arch/$ARCH/defconfig.
8
Cross-compile Environments
®
What is cross compiler?
Cross compiler is a compiler capable of creating executable code for a platform other than the one on which the compiler is running. Cross compiler tools are used to generate executables for embedded system or multiple platforms. Add Cross compiler path to Linux Environment Variable
other compressed formats available
11
Access to Linux kernel
®
Download sources from http://kernel.org/:
wget http://kernel.org/pub/linux/kernel/v2.6/linux2.6.xx.tar.bz2
2.6.33
2.6.33-rc3 2.6.33-rc4 2.6.33-rc2 Stabilization phase (6-8 weeks) release candidate revisions 2.6.32 stable branch 2.6.32.1 4
Supported Hardware Architectures
Hardware
All kinds of devices
Application
User space
System call interface Kernel Driver
Kernel space
Hardware 14
I/O Device
®
Character devices
Can be accessed as a stream of bytes( like a file) Character driver implements at least the open, close, read, and write system calls. Char device are accessed by means of filesystem nodes, such as /dev/tty1.
Linux is a modern fully-fledged Unix
3
Linux Version Rules
®
Previous name rules
Stable releases are versioned as x.<even>.z
- Examples: 2.0.40, 2.2.26, 2.4.27
Useful kernel source links:
Linux daily source snapshots:
http://www.kernel.org/pub/linux/kernel/v2.6/snapshots/
Useful version control system -- git:
Git is a distributed version control system Git is free and open source Learn more from http://git-scm.com/ TortoiseGit
2
Linux Kernel General Information
®
Linux is a POSIX compatible operating system
Linux is Opensource
Built by the community and under GPL license
Linux Kernel provides an interface to the hardware
Plain text interface.
"make menuconfig"
Text based color menus, radiolists & dialog
"make xconfig"
X windows (Qt) based configuration tool.
"make defconfig"
12
Linux Kernel with AT91 Patches
®
Latest enhancements, not published yet to Linux mainline Modify source code, Makefiles and Configuration files Let users make Linux kernel image for AT91 products easily Support the latest AT91 devices
Linux system overview
®
Applications
CUI, GUI, text editor…
Driver Kernel
System call interface for applications Define the driver framework and interface Make kernel to control the hardware
®
Device Drivers
Memory Management
Networking Stack
Kernel
Vendors Architecture
I/O Systems
File System
7
Interfaces Used to Configure Linux Kernel
®
"make config"
run (ARM example):
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-
Hint: create an “alias” to save your time
Example: Add command line in .bashrc alias mlx=‘make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- ’ Then Use command in terminal mlx
64 bit architectures:
ia64, mips64, ppc64 sh64, sparc64, x86_64
Check the arch/ or Documentation/arch/README for details
5
Linux source code structure
®
linux-2.6.xx
Network interfaces
In charge of sending and receiving data packets. Network interfaces are not stream-oriented and therefore, are not easily mapped to a node in the filesystem. Communication between the kernel and network driver is not through read/write, but rather through packet transmission functions.
Development branch as x.<odd>.z
- Examples: 2.3.42, 2.5.74 …
Present name rules (since 2.6) Development window (2 weeks) 2.6.32 2.6.33-rc1
Linear development process Stable kernel updates are named: 2.6.z.w
export PATH=$PATH:<cross compile path>
9
Makefile Modification
®
Update the version as usual You should change the default target platform, e.g.:
ARCH ?= arm ?= arm-none-linux-gnueabiCROSS_COMPILE
SAM9G45 SAM9M10 Linux Seminar
®
SAM9M10 Linux Kernel Introduction
Outline
®
Linux Kernel General Information Linux Kernel source code structure Configure the Linux Kernel Cross-Compile Environments Linux Kernel with AT91 Patches Linux Device User Space / Kernel Space Communication
15
How User Space Communicate with Kernel
®
Procfs, Sysfs, and Similar Kernel Interfaces
Linux kernel provides a couple of RAM based file systems to let user space communicate with kernel space. Procfs, Sysfs, Configfs, Debugfs, and Sysctl.