- 博客(0)
- 资源 (5)
空空如也
linux编程白皮书
非常多的资料,绝对物有所值~
第1章Hello, World
如果第一个程序员是一个山顶洞人,它在山洞壁(第一台计算机)上凿出的第一个程序应该
是用羚羊图案构成的一个字符串“ Hello, Wo r l d”。罗马的编程教科书也应该是以程序“ S a l u t ,
M u n d i”开始的。我不知道如果打破这个传统会带来什么后果,至少我还没有勇气去做第一个
吃螃蟹的人。
内核模块至少必须有两个函数: i n i t m o d u l e和c l e a n u p m o d u l e。第一个函数是在把模块插
入内核时调用的;第二个函数则在删除该模块时调用。一般来说, i n i t m o d u l e可以为内核的
某些东西注册一个处理程序,或者也可以用自身的代码来取代某个内核函数(通常是先干点别
的什么事,然后再调用原来的函数)。函数c l e a n u p m o d u l e的任务是清除掉i n i t m o d u l e所做的
一切,这样,这个模块就可以安全地卸载了。
第2章内存管理
内存管理子系统是操作系统最重要的部分之一。从早期计算开始,系统的内存大小就难以
满足人们的需要。为了解决这个问题,可利用虚拟内存。虚拟内存通过当需要时在竞争的进
程之间共享内存,使系统显得有比实际上更多的内存空间。
虚拟内存不仅仅使机器上的内存变多,内存管理子系统还提供以下功能:
• 大地址空间操作系统使系统显得它有比实际上大得多的内存。虚拟内存可以比系统中
的物理内存大许多倍。
• 保护系统中每个进程有自己的虚拟地址空间。这些虚拟地址空间相互之间完全分离,
所以运行一个应用的进程不能影响其他的进程。同样,硬件的虚拟内存机制允许内存区
域被写保护。这样保护了代码和数据不被恶意应用重写
2018-10-10
Unreliable Guide To Hacking The Linux Kernel
Table of Contents
1. Introduction................................................................................................................5
2. The Players .................................................................................................................6
2.1. User Context .....................................................................................................6
2.2. Hardware Interrupts (Hard IRQs) .....................................................................7
2.3. Software Interrupt Context: Bottom Halves, Tasklets, softirqs ........................7
3. Some Basic Rules........................................................................................................9
4. ioctls: Not writing a new system call ......................................................................10
5. Recipes for Deadlock ...............................................................................................12
6. Common Routines....................................................................................................13
6.1. printk() include/linux/kernel.h.......................................................13
6.2. copy_[to/from]_user() / get_user() / put_user()
include/asm/uaccess.h..........................................................................13
6.3. kmalloc()/kfree() include/linux/slab.h.........................................14
6.4. current include/asm/current.h...........................................................15
6.5. local_irq_save()/local_irq_restore() include/asm/system.h15
6.6. local_bh_disable()/local_bh_enable() include/asm/softirq.h
16
6.7. smp_processor_id()/cpu_[number/logical]_map()
include/asm/smp.h...................................................................................16
6.8. __init/__exit/__initdata include/linux/init.h.......................................16
6.9. __initcall()/module_init() include/linux/init.h .....................17
6.10. module_exit() include/linux/init.h ..............................................17
6.11. MOD_INC_USE_COUNT/MOD_DEC_USE_COUNT include/linux/module.h
18
7. Wait Queues include/linux/wait.h .................................................................20
7.1. Declaring.........................................................................................................20
7.2. Queuing...........................................................................................................20
7.3. Waking Up Queued Tasks...............................................................................20
8. Atomic Operations...................................................................................................22
9. Symbols .....................................................................................................................23
3
9.1. EXPORT_SYMBOL() include/linux/module.h........................................23
9.2. EXPORT_SYMTAB ............................................................................................23
10. Routines and Conventions.....................................................................................24
10.1. Double-linked lists include/linux/list.h............................................24
10.2. Return Conventions.......................................................................................24
10.3. Breaking Compilation...................................................................................24
10.4. Initializing structure members ......................................................................24
10.5. GNU Extensions ...........................................................................................25
10.6. C++ ...............................................................................................................26
10.7. #if ..................................................................................................................26
11. Putting Your Stuff in the Kernel...........................................................................27
12. Kernel Cantrips......................................................................................................29
13. Thanks.....................................................................................................................31
2018-10-10
Linux内核的中断机制
本文主要从内核实现的角度分析了Linux 2.4.0内核的设备中断流程。本文是为那些想要了解Linux I/O子系统的读者和Linux驱动程序开发人员而写的。
2018-10-10
The_Linux_Networking_Architecture
Design and Implementation of Network Protocols in the Linux Kernel
Part I: The Linux Kernel 1
Chapter 1. Motivation 3
Section 1.1. The Linux Operating System 4
Section 1.2. What is Linux? 5
Section 1.3. Reasons for Using Linux 6
Chapter 2. The Kernel Structure 9
Section 2.1. Monolithic Architectures and Microkernels 11
Section 2.2. Activities in the Linux Kernel 12
Section 2.3. Locking—Atomic Operations 17
Section 2.4. Kernel Modules 23
Section 2.5. Device Drivers 29
Section 2.6. Memory Management in the Kernel 31
Section 2.7. Timing in the Linux Kernel 35
Section 2.8. The Proc File System 40
Section 2.9. Versioning 43
Part II: Architecture of Network Implementation 45
Chapter 3. The Architecture of Communication Systems 47
Section 3.1. Layer-Based Communication Models 47
Section 3.2. Services and Protocols 52
Chapter 4. Managing Network Packets in the Kernel 55
Section 4.1. Socket Buffers 55
Section 4.2. Socket-Buffer Queues 66
Chapter 5. Network Devices 71
Section 5.1. The net_device Interface 73
Section 5.2. Managing Network Devices 82
Section 5.3. Network Drivers 92
Part III: Layer I + II—Medium Access and Logical Link Layer 115
Chapter 6. Introduction to the Data-Link Layer 117
Section 6.1. Structure of the Data-Link Layer 117
Section 6.2. Processes on the Data-Link Layer 119
Section 6.3. Managing Layer-3 Protocols 127
Chapter 7. The Serial-Line Internet Protocol (SLIP) 132
Section 7.1. Introduction 132
Section 7.2. Slip Implementation in the Linux Kernel 134
Chapter 8. The Point-to-Point Protocol (PPP) 145
Section 8.1. Introduction 145
Section 8.2. PPP Configuration in Linux 148
Section 8.3. PPP Implementation in the Linux Kernel 150
Section 8.4. Implementing the PPP Daemon 158
Chapter 9. PPP over Ethernet 161
Section 9.1. Introduction 161
Section 9.2. PPPOE Specification in RFC 2516 161
Section 9.3. Implementation in the User Space 163
Section 9.4. Implementation in the Linux Kernel 164
Chapter 10. Asynchronous Transfer Mode—ATM 168
Section 10.1. Introduction 168
Section 10.2. Implementing ATM in Linux 169
Section 10.3. Configuration 177
Chapter 11. Bluetooth in Linux 179
Section 11.1. Host Controller Interface (HCI) 181
Section 11.2. L2CAP 185
Section 11.3. Other Protocols 188
Chapter 12. Transparent Bridges 189
Section 12.1. Introduction 189
Section 12.2. Basics 190
Section 12.3. Configuring a Bridge in Linux 199
Section 12.4. Implementation 202
Part IV: Network Layer 221
Chapter 13. The TCP/IP Protocols 223
Section 13.1. The Internet Protocol Suite 224
Chapter 14. The Internet Protocol V4 227
Section 14.1. Properties of the Internet Protocol 228
Section 14.2. Implementing the Internet Protocol 233
Section 14.3. IP Options 250
Section 14.4. Internet Control Message Protocol (ICMP) 262
Chapter 15. Address Resolution Protocol (ARP) 273
Section 15.1. Using the Address Resolution Protocol 274
Section 15.2. The ARP Command 276
Section 15.3. Implementing the ARP Instance in the Linux Kernel 277
Chapter 16. IP Routing 293
Section 16.1. Introduction 293
Section 16.2. Configuration 301
Section 16.3. Implementation 309
Chapter 17. IP Multicast for Group Communication 330
Section 17.1. Group Communication 331
Section 17.2. IP Multicast 333
Section 17.3. Internet Group Management Protocol (IGMP) 339
Section 17.4. Multicast Data Path in the Linux Kernel 345
Section 17.5. Multicasting in Today's Internet 355
Section 17.6. Multicast Transport Protocols 364
Chapter 18. Using Traffic Control to Support Quality of Service (QoS) 366
Section 18.1. Introduction 366
Section 18.2. Basic Structure of Traffic Control in Linux 367
Section 18.3. Traffic Control in the Outgoing Direction 367
Section 18.4. Kernel Structures and Interfaces 369
Section 18.5. Ingress Policing 378
Section 18.6. Implementing a Queuing Discipline 378
Section 18.7. Configuration 381
Chapter 19. Packet Filters and Firewalls 383
Section 19.1. Introduction 383
Section 19.2. The Ipchains Architecture of Linux 2.2 386
Section 19.3. The Netfilter Architecture of Linux 2.4 391
Chapter 20. Connection Tracking 399
Section 20.1. Introduction 399
Section 20.2. Implementation 400
Chapter 21. Network Address Translation (NAT) 410
Section 21.1. Introduction 410
Section 21.2. Configuring NAT in Linux 414
Section 21.3. Implementing the NAT Module 416
Section 21.4. Interfaces to Extend the NAT Module 422
Chapter 22. Extending the Linux Network Architecture Functionality—KIDS 426
Section 22.1. Managing Dynamically Extendable Functionalities 426
Section 22.2. Structure of the KIDS Construction System 428
Section 22.3. Using the KIDS Example to Extend the Linux Network Architecture 431
Chapter 23. IPv6—Internet Protocol Version 6 443
Section 23.1. Introduction 443
Section 23.2. IPv6 Features 443
Section 23.3. IPv6 Implementation 450
Part V: Layer IV—Transport Layer 455
Chapter 24. Transmission Control Protocol (TCP) 457
Section 24.1. Overview 457
Section 24.2. Implementing The TCP Protocol Instance 460
Section 24.3. Connection Management 476
Section 24.4. Protocol Mechanisms For Data Exchange 486
Section 24.5. Timer Management In TCP 508
Chapter 25. User Datagram Protocol (UDP) 513
Section 25.1. Introduction 513
Section 25.2. Data Structures 514
Section 25.3. Sending and Receiving UDP Datagrams 519
Chapter 26. The Concept of Sockets 522
Section 26.1. Introduction 522
Section 26.2. BSD Sockets 522
Section 26.3. Protocol-Specific Sockets
2018-10-10
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人