You are on page 1of 74

Linux QQ1142985060 email1142985060@qq.

com

Linux
Word

Linux
http://www.farsight.com.cn/zt-webcasts2/linux.aspx

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

.......................................................................................................................4
........................................................................................................6
LINUX .............................................................................................................................6
...................................................................................................................6
...................................................................................................................8
LINUX .....................................................................................................................8
19911998 ....................................................................................9
LINUX .............................................................................................................................9
.....................................................................................................................10
19992002 ..................................................................................11
.....................................................................................................................11
LINUX................................................................................................................12
20032006 ..................................................................................12
UBUNTU 4.10..............................................................................................................................12
RICHARD STALLMAN ................................................................................................13
20072009 ..................................................................................15
.....................................................................................................................15
ANDROID ...................................................................................................................18
LINUX ............................................................................................................................18
KERNEL KCONFIG MAKEFILE......................................................................................19
MAKEFILE MAKE LOVE........................................................................................................19
KCONFIG MAKEFILE ..............................................................................20
.....................................................................................22
README........................................................................................................................22
KCONFIG MAKEFILE........................................................................................................24
.....................................................................................27
....................................................................................28
...........................................................................................................33
...........................................................................................................33
..................................................................................................................................34
.................................................................................................................................35
..................................................................................................................................36
.........................................................................................................................36
HELLO WORLD!................................................................................................37

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

....................................................................................................................39
....................................................................................................................44
USB ....................................................................................................44
USB ........................................................................................................45
SPEC DATASHEET ..............................................................46
LINUX ..................................................................47
LINUX .......................................................................................................47
LINUX ...............................................................................................................49
LINUX 14 ...................51
LINUX 15
..................................................................................................................................55
LINUX 16
.......................................................................................................................................59
LINUX 17 PCI
..............................................................................................................................63
LINUX 18 .......................66
LINUX 19 API...........67
LINUX 20 GIT ...................69
LINUX 21 PRINTK().........72
.........................................................................................................72
PRINTK().....................................................................................................................................73

Linux 18 18

Linux

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

Linus Torvalds Linus


1991 1 2
3500 Linux

Linux Linus
Linus

Linus Just for Fun

Linux

Linux
Linux
1 Linux 18

3
Kconfig
Makefile USB
411


Email maintainer

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

6
IRQ
7

7
8 O(1)
CFS
9

10 VFS

11 specdatasheet

12
13 12
tips

+++
+XY

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

Linux

Linux

Linux
Linux

google
top10

19911998
19992002
20032006
20072009

Kernel Goggle Goggle


Kernel
Kernel Kconfig Makefile
Kconfig Makefile
Linux Kconfig Makefile
Linux


Kconfig Makefile Linux Kernel
Kconfig Makefile Kernel

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

kernel


USB
0.1

Linux

Linux
Linux
Linux

Linus

Linux

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

Hello World!

Linux Linux

reboot
insmod
rmmod

IT

Linux
specdatasheet

spec usb
datasheet

Linux

Linux ,

Linux

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

19911998
Linux 18 18
Linux
Linux Linux
Linux

Linux
1987
MINIX
4 Linux
1991
Linus Torvalds UNIX
Linux 10 5
Linux 0.01
1992
4 Linux comp.os.linux10 Linux
SLS
1993
8 Linux Linux Installation and Getting Started Version 1

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

1994
Linux 1.0 GPLGNU General Public License
Linus Torvalds Linus

1995
4 Linux Linux

1996
Linux 2.0 SMP Linux
350
1997
Linux Bliss 160 Alpha
105 Linux
1998
1 Linux Netscape
Linux
2 Eric Raymond open source
opensource.org Linux
4 Linux Linux

5 Google
Linux Linux
6 LinuxLinux
6 25 PC
7 KDE GNOME Linus
KDE KDE1.0 OracleInformixSybase
LinuxLinux
9 Dave Whitinge Dwight Johnson LinuxToday.com
Internet.com Linux
12 IDC Linux 1998 200%
150%Linux 17%

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

19992002

1999
1 Linux 2.2 Linus Torvalds
3 LinuxWorld Linux
Linux
8 SG Red Hat
Red Hat 50
Lineo Linux
Sun Sun Sun Community Source License StarOffice

9 Red Hat 135


10 Sun Sun Solaris
12 VA Linux Systems 30 /
300 NASDAQ
QQmud
2000
1 VA Linux Systems SourceForge
SourceForge 12000 92000
2 IDC Linux
1999 25% Windows NT 38%
NetWare 19%IDC Linux 2002 2003 2

3 Linux Embedded Linux Consortium


8 HPIntelIBM NEC OSDLOpen Source
Development Lab
9 Trolltech GPL Qt
11 IBM 2001 10 Linux Linux IMT-2000

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

Linux
2001
1 Linux 2.4
3 Linux2.5 Linux hacker

4 IBM LinuxPeace, Love and Linux

6 Sharp Lineo Linux PDA


IT 9.11

2002
Linus Torvalds Linux 2.4 18 Marcelo Tosatti
Linux 2.5

20032006
Ubuntu 4.10
2003
1 NEC Linux Linux
6 IDC 2003 Linux 18.2 2007
19
8 IBM
IBM eServer Linux
9 Linux CDMA SCH-i519
11 Linux 2.6 Linux
2001

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

2004
1 X.Org
2 Linux 2.0 Linux
5 Linux
10 20 Ubuntu Ubuntu Linux

11 Firefox 1.0 IE 1
Firefox IE

2005
10 Firefox 1

11 Sun Java

12 Red Hat 43.6% 114%


IQ

Richard Stallman
2006
6 Richard Stallman http://www.stallman.org/

I'm a single atheist white man, 52, reputedly intelligent, with unusual interests in politics, science,
music and dance.
I'd like to meet a woman with varied interests, curious about the world, comfortable expressing
her likes and dislikes (I hate struggling to guess), delighting in her ability to fascinate a man and
in being loved tenderly, who values joy, truth, beauty and justice more than "success"--so we can
share bouts of intense, passionately kind awareness of each other, alternating with tolerant
warmth while we're absorbed in other aspects of life.
My 22-year-old child, the Free Software Movement, occupies most of my life, leaving no room for
more children, but I still have room to love a sweetheart. I spend a lot of my time traveling to give

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

speeches, often to Europe, Asia and Latin America; it would be nice if you were free to travel with
me some of the time.
If you are interested, write to rms at stallman dot org and we'll see where it leads.

52

22

rms@stallman.org
7 Ubuntu PC World 2006 World Class Award Ubuntu 2006
100 Ubuntu
Canonical
Sun Linux
8 Linux Linuspire Kevin Carmony
Freespire 1.0 Linux
27 http://linux.inet.hr/poll_filesystem.html Your favorite file system?

9 16 SFDSoftware Freedom Day 2006


10 Oracle Unbreakable Linux Oralce Linux
17 FSG
O'Reilly Media Linux
MSDN LSB (Linux Standard Base) Developer Network

11 Novell Linux
1.1

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

1.1 + Novell

20072009

2007
1 Second Life Linux OSDL Free
Standard Group Linux FoundationLinux
Linux
2 Bill Xu
ActiveX

Firefox
3 Novell Mac vs PCLinux
Novell Novell Linux PC
www.youtube.com 15 Novell
Linux Windows
4 Dell Ubuntu
5 Linux 42
65 OpenOffice.org 45 83
Get the Facts 1.2
Linux The Highly Reliable
Times

Linux

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

Windows Server 2003

1.2 Get the Facts


5 Firefox Linux
1.3

1.3 Firefox
6 5 Linux Xandros

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

Red HatUbuntu Mandriva 28 Google Linux


1.4 29 GNU GPLv3

1.4 Google Linux


7 Fcitx Linux
Fcitx

8 SCO Linux SCO


Linux Caldera Systems Santa Cruz Operation Unix
SCO Linux IBMNovell
IBM Unix SCO Unix Linux
Jim Zemlin Linux
Linux RedHat

10 Acacia Research IP Innovation RedHat Novell


RedHat Linux Novell SUSE Linux Enterprise Desktop SUSE Linux
Enterprise Server 2007

11 Google Linux AndroidPhoronix ATI


Linux Vista Linux
Windows

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

blog.csdn.net/fudan_abc Linux

Android
2008
1 Nokia Qt Trolltech
2 Google Linux Photoshop
4 Sun Java
7 QQ for Linux 1.0 Preview

9 Google T-MobileHTC Android G1Google


Chrome 2%
10 OpenOffice3.0 Linux Ubuntu 8.10
Fedora 10
12 Linux

Linux
2009
1 Linux Unix Longene
Linux Linux
Windows Linux Windows
Linux Windows
2 GPS Tomtom 8 Tomtom GPS
Linux Linux
Linux
3 Adobe Reader 9.1 for Linux UltraEdit Linux UEX
UltraEdit for Linux
4 IDC Linux 2009
Linux 2008 21% 2009
2%
5 Nokia Qt Qt

6 ENAC Linux iPhone Multi-touch

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

7 Linux CardPartner UMBrella Visa


Linux 1.5 Linux 50
Linux 1%

1.5 Linux
8 Unbutu
9 2.6.31 Linux USB3.0

10 Ubuntu 9.10
11 Vim Bram Moolenaar Zimbu
Moolenaar Zimbu
Zimbu OS kernel
GUI

Kernel Kconfig Makefile


Makefile Make Love

Makefile Make Love

Kconfig Makefile
Linux Kconfig Makefile
Linux

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com


Kconfig Makefile Linux Kernel
Kconfig Makefile Kernel
kernel

Kconfig Makefile
Kconfig Makefile

U U storage
drivers/usb/storage/
Kconfig Makefile
Kconfig
34 config USB_STORAGE_DATAFAB
35

bool "Datafab Compact Flash Reader support (EXPERIMENTAL)"

36

depends on USB_STORAGE && EXPERIMENTAL

37

help

38

Support for certain Datafab CompactFlash readers.

39

Datafab has a web page at <http://www.datafabusa.com/>.

Datafab
CompactFlash reader flash U
drivers/usb/storage usb mass storage
U usb mass storage
101 config USB_STORAGE_SDDR55
102

bool "SanDisk SDDR-55 SmartMedia support (EXPERIMENTAL)"

103

depends on USB_STORAGE && EXPERIMENTAL

104

help

105

Say

here

to

include

additional

code

to

support

the

Sandisk SDDR-55
106

SmartMedia reader in the USB Mass Storage driver.

SanDisk SM U

CONFIG_USB_STORAGE

9 config USB_STORAGE
10

tristate "USB Mass Storage support"

11

depends on USB && SCSI

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

12
13

---help--Say Y here if you want to connect USB mass storage devices to

your
14

computer's USB port. This is the driver you need for USB

15

floppy drives, USB hard disks, USB tape drives, USB CD-ROMs,

16

USB flash devices, and memory sticks, along with

17

similar devices. This driver may also be used for some cameras

18

and card readers.

19
20

This option depends on 'SCSI' support being enabled, but you

21

probably also need 'SCSI device support: SCSI disk support'

22

(BLK_DEV_SD) for most USB storage devices.

23
24

To compile this driver as a module, choose M here: the

25

module will be called usb-storage.

Makefile
0 #
1 # Makefile for the USB Mass Storage device drivers.
2 #
3 # 15 Aug 2000, Christoph Hellwig <hch@infradead.org>
4 # Rewritten to use lists instead of if-statements.
5 #
6
7 EXTRA_CFLAGS := -Idrivers/scsi
8
9 obj-$(CONFIG_USB_STORAGE)

+= usb-storage.o

10
11 usb-storage-obj-$(CONFIG_USB_STORAGE_DEBUG) += debug.o
12 usb-storage-obj-$(CONFIG_USB_STORAGE_USBAT) += shuttle_usbat.o
13 usb-storage-obj-$(CONFIG_USB_STORAGE_SDDR09)

+= sddr09.o

14 usb-storage-obj-$(CONFIG_USB_STORAGE_SDDR55)

+= sddr55.o

15 usb-storage-obj-$(CONFIG_USB_STORAGE_FREECOM)

+= freecom.o

16 usb-storage-obj-$(CONFIG_USB_STORAGE_DPCM) += dpcm.o
17 usb-storage-obj-$(CONFIG_USB_STORAGE_ISD200)

+= isd200.o

18 usb-storage-obj-$(CONFIG_USB_STORAGE_DATAFAB)

+= datafab.o

19 usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT) += jumpshot.o
20 usb-storage-obj-$(CONFIG_USB_STORAGE_ALAUDA)

+= alauda.o

21 usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH) += onetouch.o
22 usb-storage-obj-$(CONFIG_USB_STORAGE_KARMA) += karma.o
23
24 usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \
25

initializers.o $(usb-storage-obj-y)

26

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

27 ifneq ($(CONFIG_USB_LIBUSUAL),)
28

obj-$(CONFIG_USB)

+= libusual.o

29 endif

Kconfig CONFIG_USB_STORAGE
Makefile CONFIG_USB_STORAGE 9
usb-storage
Kconfig Makefile 11~22

24

scsiglue.cprotocol.ctransport.cusb.cinitializers.c .h
Kconfig Makefile
Linux Kconfig
Makefile

1.5% 80
USB
USB

README
USB drivers/usb
ls
atm

class

Makefile

core

gadget

host

image

misc

mon

serial

storage Kconfig

README usb-skeleton.c

drivers/usb 10 4 usb-skeleton.c
USB driver
ppmm

KconfigMakefileREADME
README

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

read read

23

Here

is

list

of

what

each

subdirectory

here

is,

and

what

is

contained in
24 them.
25
26 core/

- This is for the core USB host code, including the

27

usbfs files and the hub class driver ("khubd").

28
29 host/

- This is for USB host controller drivers.

This

30

includes UHCI, OHCI, EHCI, and others that might

31

be used with more specialized "embedded" systems.

32
33 gadget/
34

- This is for USB peripheral controller drivers and


the various gadget drivers which talk to them.

35
36
37 Individual USB driver directories.

A new driver should be added to

the
38 first subdirectory in the list below that it fits into.
39
40 image/
41

- This is for still image drivers, like scanners or


digital cameras.

42 input/
43

- This is for any driver that uses the input subsystem,


like keyboard, mice, touchscreens, tablets, etc.

44 media/

- This is for multimedia drivers, like video cameras,

45

radios, and any other drivers that talk to the v4l

46

subsystem.

47 net/

- This is for network drivers.

48 serial/

- This is for USB to serial drivers.

49 storage/ - This is for USB mass-storage drivers.


50 class/

- This is for all USB device drivers that do not fit

51

into any of the above categories, and work for a range

52

of USB Class specified devices.

53 misc/
54

- This is for all USB device drivers that do not fit


into any of the above categories.

README ls 10
USB CoreLinux

USB Core

Linux
drivers/usb/USB Core

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

drivers/usb/ core
USB Root Hub
host USB

core
host
USB gadget gadget Linux
PDA USB USB Device Controller
PC master slave USB
USB USB USB
gadget USB
SD USB PC SD
U USB gadget
USB U storage
USB input
README USB
Kconfig
Makefile
USB host
controller USB Core
core

Kconfig Makefile
drivers/usb/core ls
Kconfig

Makefile

endpoint.c
inode.c
usb.c

file.c

message.c

buffer.c
generic.c
notify.c

usb.h

wc
# wc l ./*
148 buffer.c
607 config.c
706 devices.c
1677 devio.c
1569 driver.c
357 endpoint.c
248 file.c
238 generic.c
1759 hcd.c
458 hcd.h
433 hcd-pci.c

config.c

blog.csdn.net/fudan_abc

devices.c

hcd-pci.c

hcd.c

otg_whitelist.h

devio.c
hcd.h

quirks.c

driver.c

hub.c

hub.h

sysfs.c

urb.c

Linux QQ1142985060 email1142985060@qq.com

3046 hub.c
195 hub.h
758 inode.c
144 Kconfig
21 Makefile
1732 message.c
68 notify.c
112 otg_whitelist.h
161 quirks.c
710 sysfs.c
589 urb.c
984 usb.c
160 usb.h
16880 total

drivers/usb/core 24 16880 core core

Kconfig
15 config USB_DEVICEFS
16

bool "USB device filesystem"

17

depends on USB

18

---help---

19

If you say Y here (and to "/proc file system support" in

the "File
20

systems"

section,

above),

you

will

get

file

/proc/bus/usb/devices
21

which lists the devices currently connected to your USB bus

22

busses, and for every connected device a file named

or
23

"/proc/bus/usb/xxx/yyy", where xxx is the bus number and

yyy the
24

device number; the latter files can be used by user space

programs
25

to talk directly to the device. These files are "virtual",

meaning
26

they are generated on the fly and not stored on the hard

drive.
27
28

You may need to mount the usbfs file system to see the

files, use
29

mount -t usbfs none /proc/bus/usb

30
31

For the format of the various /proc/bus/usb/ files, please

read

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

32

<file:Documentation/usb/proc_usb_info.txt>.

33
34

Usbfs files can't handle Access Control Lists (ACL), which

are the
35

default way to grant access to USB devices for untrusted

users of a
36

desktop system. The usbfs functionality is replaced by real

37

device-nodes managed by udev. These nodes live in

/dev/bus/usb and
38

are used by libusb.

USB_DEVICEFS usbfs usbfs /proc/bus/usb


USB USB
/proc/bus/usb/xxx/yyyxxx
yyy

002/027 002/048
mm
100
100
usbfs USB

74 config USB_SUSPEND
75

bool "USB selective suspend/resume and wakeup (EXPERIMENTAL)"

76

depends on USB && PM && EXPERIMENTAL

77

help

78

If you say Y here, you can use driver calls or the sysfs

79

"power/state" file to suspend or resume individual USB

80

peripherals.

81
82

Also, USB "remote wakeup" signaling is supported, whereby some

83

USB devices (like keyboards and network adapters) can wake up

84

their parent hub.

85

could wake the system from states like suspend-to-RAM.

That wakeup cascades up the USB tree, and

86
87

If you are unsure about this, say N here.

USB USB

non-idle
USB

Makefile

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

5 usbcore-objs

:= usb.o hub.o hcd.o urb.o message.o driver.o \

config.o file.o buffer.o sysfs.o endpoint.o \

devio.o notify.o generic.o quirks.o

8
9 ifeq ($(CONFIG_PCI),y)
10

usbcore-objs

+= hcd-pci.o

11 endif
12
13 ifeq ($(CONFIG_USB_DEVICEFS),y)
14

usbcore-objs

+= inode.o devices.o

15 endif
16
17 obj-$(CONFIG_USB)

+= usbcore.o

18
19 ifeq ($(CONFIG_USB_DEBUG),y)
20 EXTRA_CFLAGS += -DDEBUG
21 endif

Makefile Kconfig money


CONFIG_PCI USB Root Hub
PCI hcd-pci hcd
HCDIHCD host
CONFIG_USB_DEVICEFS Kconfig
usbfs inode.c devices.c
USB
buffer.c config.c driver.c endpoint.c file.c generic.c hcd.c
hcd.hhub.cmessage.cnotify.cotg_whitelist.hquirks.csysfs.curb.c usb.c
USB
Core

USB
0.1

Linux

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

5000

Kconfig Makefile
USB
USB
subsys_initcall module_init
drivers/usb/core/usb.c
940 subsys_initcall(usb_init);
941 module_exit(usb_exit);

subsys_initcall module_init

usbcore USB
Linux PCI
SCSI drivers/

subsys_initcall(usb_init) usb_init USB


usb_exit() USB USB
usb_init
865 static int __init usb_init(void)
866 {
867

int retval;

868

if (nousb) {

869

pr_info("%s: USB support disabled\n", usbcore_name);

870

return 0;

871

872
873

retval = ksuspend_usb_init();

874

if (retval)

875

goto out;

876

retval = bus_register(&usb_bus_type);

877

if (retval)

878
879
880

goto bus_register_failed;
retval = usb_host_init();
if (retval)

881

goto host_init_failed;

882

retval = usb_major_init();

883

if (retval)

884
885

goto major_init_failed;
retval = usb_register(&usbfs_driver);

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

886

if (retval)

887

goto driver_register_failed;

888

retval = usb_devio_init();

889

if (retval)

890

goto usb_devio_init_failed;

891

retval = usbfs_init();

892

if (retval)

893

goto fs_init_failed;

894

retval = usb_hub_init();

895

if (retval)

896
897

goto hub_init_failed;
retval

usb_register_device_driver(&usb_generic_driver,

THIS_MODULE);
898

if (!retval)

899

goto out;

900
901
902

usb_hub_cleanup();
hub_init_failed:

903

usbfs_cleanup();

904 fs_init_failed:
905

usb_devio_cleanup();

906 usb_devio_init_failed:
907

usb_deregister(&usbfs_driver);

908 driver_register_failed:
909

usb_major_cleanup();

910 major_init_failed:
911

usb_host_cleanup();

912 host_init_failed:
913

bus_unregister(&usb_bus_type);

914 bus_register_failed:
915

ksuspend_usb_cleanup();

916 out:
917

return retval;

918 }

1__init
usb_init 865 __init

USB
__init include/linux/init.h

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

43 #define __init

__attribute__ ((__section__ (".init.text")))

__attribute__Linux
GNU C GNU C GNU C

__attribute__

GNU C section
GCC
section ("section-name")'
Normally, the compiler places the code it generates in the `text'
section.Sometimes, however, you need additional sections, or you
need certain particular functions to appear in special sections.
The `section' attribute specifies that a function lives in a
particular section.For example, the declaration:
extern void foobar (void) __attribute__ ((section ("bar")));
puts the function foobar' in the bar' section.
Some file formats do not support arbitrary sections so the
section' attribute is not available on all platforms.If you
need to map the entire contents of a module to a particular
section, consider using the facilities of the linker instead.

.text .data .bss section


__init
.init.text __init
.init.text
__init
subsys_initcall include/linux/init.h

125 #define subsys_initcall(fn)

__define_initcall("4",fn,4)

__define_initcall fn initcall.init
subsys_initcall fn .initcall.init .initcall4.init
.initcall.init.init.text .initcall4.init

init bass

vmlinux.lds arch/<target>/

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

vmlinux.lds
initcall.init

__inicall_start = .;
.initcall.init : AT(ADDR(.initcall.init) 0xC0000000) {
*(.initcall1.init)
*(.initcall2.init)
*(.initcall3.init)
*(.initcall4.init)
*(.initcall5.init)
*(.initcall6.init)
*(.initcall7.init)
}
__initcall_end = .;

__initcall_start .initcall.init __initcall_end


.initcall.init 7
.initcall1.init
.initcall2.init
.initcall3.init
.initcall4.init
.initcall5.init
.initcall6.init
.initcall7.init

subsys_initcall .initcall4.init
core_initcall .initcall1.init device_initcall
.initcall6.init include/linux/init.h
.initcall1.init .initcall2.init
__init .initcall.init

/init/main.c
do_initcalls __initcall_start__initcall_end

2
usb_init 868 nousb
C nousb
nousb USB Linux
USB
nousb nousb
USB support disabled usb_init

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

nousb drivers/usb/core/usb.c
static int nousb;

/* Disable USB when built into kernel image */

module_param_named(autosuspend, usb_autosuspend_delay, int, 0644);


MODULE_PARM_DESC(autosuspend, "default autosuspend delay");

nousb

grub kernel
kernel

/boot/vmlinuz-2.6.18-kdb

root=/dev/sda1

ro

splash=silent

vga=0x314

rootsplashvga
kernel .=
modprobe usbcore autosuspend=2

kernel

usbcore.autosuspend=2

modinfo -p ${modulename}
/sys/module/$
{modulename}/parameters/ echo -n ${value} >
/sys/module/${modulename}/parameters/${parm}
3
usb_init pr_info
pr_info printk include/linux/kernel.h

242 #define pr_info(fmt,arg...) \


243

printk(KERN_INFO fmt,##arg)

99 ISO C
#define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)

__VA_ARGS__GCC

#define debug(format, args...) fprintf (stderr, format, args)

pr_info ##

##
debug ("A message");

##

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

usb_init usb

Kernel

Linux
Linux
Linux

Linus

XXX

XXX

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

Linux

README
Linux

Documentation/Changes

Documentation/CodingStyle

Documentation/SubmittingPatches
Documentation/SubmittingDrivers
Documentation/SubmitChecklist
SubmittingPatches
SubmittingDrivers 2.4 2.6
SubmitChecklist check
Documentation/stable_api_nonsense.txt
API
Linux
Linux
Documentation/stable_kernel_rules.txt
stable releases
Documentation/SecurityBugs

bug

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

Documentation/kernel-docs.txt

Documentation/applying-patches.txt

Documentation/bug-hunting
bug
Documentation/HOWTO

5 2+1+2 2 2
1 1 2 2
1 1 1
Linux
LKD

Linux
ULK LKD ULK

Linux
LDD
Linux
LVMM Linux
Linux
LINUX
Linux

5
LKD ULK

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

LDD

Email maintainer

Linux
Linux Kernel Mailing
ListLKML http://vger.kernel.org/vger-lists.html#linux-kernel

LKML
USB http://www.linux-usb.org/mailing.html

http://www.kernel.org/
bug
http://kerneltrap.org
LinuxBSDLKMLkerneltrap

http://lwn.net/
Linux weekly news1997Linux

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

http://zh-kernel.org/mailman/listinfo/linux-kernel
Herbert
Xu,Mingming CaoBryan Wu
http://linux.chinaunix.net/
Linux/Unix

Hello World!

Linux Linux

reboot
insmod
rmmod

"Hello World!"

hello world
Linux
Helloworld
Goodbyecruel
world !
/************ hello.c *********************/
1 #include <linux/init.h>

/* Needed for the macros */

2 #include <linux/module.h> /* Needed for all modules */


3 MODULE_LICENSE("Dual BSD/GPL");
4 MODULE_AUTHOR("fudan_abc");
5
6 static int __init hello_init(void)
7 {
8

printk(KERN_ALERT "Hello, world!\n");

return 0;

10 }
11
12 static void __exit hello_exit(void)

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

13 {
14

printk(KERN_ALERT "Goodbye, cruel world\n");

15 }
16
17 module_init(hello_init);
18 module_exit(hello_exit);

module_init() module_exit()
Linux Kernel 2.6

module_init() insmod
module_init() rmmod
module_exit() module_init()(driver
initialization entry point)
Makefile
1 # To build modules outside of the kernel tree, we run "make"
2 # in the kernel source tree; the Makefile these then includes this
3 # Makefile once again.
4 # This conditional selects whether we are being included from the
5 # kernel Makefile or not.
6 ifeq ($(KERNELRELEASE),)
7
8

# Assume the source tree is where the running kernel was built

# You should set KERNELDIR in the environment if it's elsewhere

10

KERNELDIR ?= /lib/modules/$(shell uname -r)/build

11

# The current directory is passed to sub-makes as argument

12

PWD := $(shell pwd)

13
14 modules:
15

$(MAKE) -C $(KERNELDIR) M=$(PWD) modules

16
17 modules_install:
18

$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install

19
20 clean:
21

rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions

22
23 .PHONY: modules modules_install clean
24
25 else
26

# called from kernel build system: just declare what our modules

27

obj-m := hello.o

are

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

28 endif

lwn.net
make Linux Kernel 2.6
make make
make
make Makefile make make
hello.ko

#insmod hello.ko

tail -f /var/log/messages Hello


world
#rmmod hello.ko

Goodbyecruel world
Linux

2.6 module_init module_exit

1+1 2
B A

IT

Linux
busdevicedriver
include/linux/device.h

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

52 struct bus_type {
53

const char

* name;

54

struct module

* owner;

56

struct kset

subsys;

57

struct kset

drivers;

55

58

struct kset

devices;

59

struct klist

klist_devices;

60

struct klist

klist_drivers;

61
62

struct blocking_notifier_head bus_notifier;

63
64

struct bus_attribute

65

* bus_attrs;

struct device_attribute * dev_attrs;

66

struct driver_attribute * drv_attrs;

67

struct bus_attribute drivers_autoprobe_attr;

68

struct bus_attribute drivers_probe_attr;

69
70

int (*match)(struct device * dev, struct device_driver * drv);

71

int (*uevent)(struct device *dev, char **envp,

72

int num_envp, char *buffer, int buffer_size);

73

int

(*probe)(struct device * dev);

74

int

(*remove)(struct device * dev);

75

void

(*shutdown)(struct device * dev);

76
77

int (*suspend)(struct device * dev, pm_message_t state);

78

int (*suspend_late)(struct device * dev, pm_message_t state);

79

int (*resume_early)(struct device * dev);

80

int (*resume)(struct device * dev);

81
82

unsigned int drivers_autoprobe:1;

83 };
124 struct device_driver {
125
126

const char

* name;

struct bus_type

* bus;

128

struct kobject

kobj;

129

struct klist

klist_devices;

130

struct klist_node

knode_bus;

132

struct module

* owner;

133

const char

127

131

modules */

blog.csdn.net/fudan_abc

* mod_name;

/* used for built-in

Linux QQ1142985060 email1142985060@qq.com

134

struct module_kobject

* mkobj;

135
136

int

(*probe)

(struct device * dev);

137

int

(*remove)

(struct device * dev);

138
139

void
int

(*shutdown)

(struct device * dev);

(*suspend)

(struct device * dev, pm_message_t

state);
140

int

(*resume)

(struct device * dev);

141 };
407 struct device {
408

struct klist

klist_children;

409

struct klist_node

knode_parent;

410

struct klist_node

knode_driver;

411

struct klist_node

knode_bus;

412

struct device

*parent;

/* node in sibling list */

413
414

struct kobject kobj;

415

char

416

struct device_type *type;

417

unsigned

is_registered:1;

418

unsigned

uevent_suppress:1;

bus_id[BUS_ID_SIZE];

/* position on parent bus */

419
420

struct semaphore

sem;

/* semaphore to synchronize calls to

421

* its driver.

422

*/

423
424

struct bus_type * bus;

425

struct device_driver *driver;

426

/* type of bus device is on */


/* which driver has allocated this

device */

427

void

*driver_data;

428

void

*platform_data; /* Platform specific data, device

429
430

/* data private to the driver */

core doesn't touch it */


struct dev_pm_info power;

431
432 #ifdef CONFIG_NUMA
433

int

numa_node;

/* NUMA node this device is close to */


/* dma mask (if dma'able device) */

434 #endif
435

u64

*dma_mask;

436

u64

coherent_dma_mask;/* Like dma_mask, but for

437

alloc_coherent mappings as

438

not all hardware supports

439

64 bit addresses for consistent

440

allocations such descriptors. */

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

441
442

struct list_head

dma_pools;

/* dma pools (if dma'ble) */

443
444

struct dma_coherent_mem *dma_mem; /* internal for coherent mem

445

override */

446

/* arch specific additions */

447

struct dev_archdata archdata;

448
449

spinlock_t

devres_lock;

450

struct list_head

devres_head;

451
452

/* class_device migration path */

453

struct list_head

node;

454

struct class

*class;

455

dev_t

456

struct attribute_group **groups;

devt;

/* dev_t, creates the sysfs "dev" */


/* optional groups */

457
458

void

(*release)(struct device * dev);

459 };

Q 80
21

struct bus_type struct kset drivers struct kset devices struct


device struct bus_type * bus struct device_driver *driverstruct device_driver
struct bus_type * bus struct klist klist_devices klistkset

struct device bus


driver struct device_driver bus
klist_devices device
liststruct
bus_type drivers devices
klistkset device driver
kobject
kobject kset Linux kobjcetklist

kobject kset

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

Linux OO
kobject
kset kobject C
C++ class kobject
kobject
13 kobject parent
kobject kset
struct bus_type drivers devices

klist
2.6.11 struct device_driver devices

struct device
struct device_driver
device devices driver drivers

devices drivers
devices drivers

struct device
devices struct device_driver
devices ()
struct device struct device_driver
device_bind_driver
struct device struct device_driver driver
struct device_driver driver struct device struct klist klist_devices
busdevice driver

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

struct device bus


drivers struct device_driver
bus devices OK
device_bind_driver

USB
USB

USB
USB drivers/usb
core usbcore
lsmod usbcore
localhost:/usr/src/linux-2.6.23/drivers/usb/core # lsmod
Module

Size

Used by

af_packet

55820

raw

89504

nfs

230840

lockd

87536

2 nfs

nfs_acl

20352

1 nfs

sunrpc

172360

4 nfs,lockd,nfs_acl

ipv6

329728

36

button

24224

battery

27272

ac

22152

apparmor

73760

aamatch_pcre

30720

1 apparmor

loop

32784

usbhid

60832

dm_mod

77232

ide_cd

57120

hw_random

22440

ehci_hcd

47624

cdrom

52392

1 ide_cd

uhci_hcd

48544

shpchp

61984

bnx2

157296

usbcore

149288

4 usbhid,ehci_hcd,uhci_hcd

e1000

130872

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

pci_hotplug
reiserfs

44800

1 shpchp

239616

edd

26760

fan

21896

usbcore core USB


usbcore
usbcore ehci_hcd uhci_hcd USB
USB
usbcore
USB core
USB

USB core
HCD USB HCD
USB USB HCD
usbcoreusbcore HCD
HCD
core USB core
core HCD

USB
busdevicedriver

struct bus_type devices drivers

USB USB coreUSB core USB

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

struct bus_type usb_bus_type USB


USB Root Hub USB USB
struct device struct device
devices
Root Hub Hub Hub struct
device Hub
usb_bus_type devices

drivers bus driver bus


USB USB
struct usb_driver struct device_driver driver USB core
struct device_driver driver usb_bus_type
drivers usb_register
usb_deregister drivers
struct bus_type match USB usb_device_match
USB USB USB
BBS match

USB core USB


USB
usb_register USB core
USB USB
USB core

specdatasheet

spec usb datasheet

specdatasheet

specdatasheet

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

USB USB
USB
USB spec USB
datasheet spec datasheet

drivers/input/touchscreen

spec
spec

Linux

Linux

Linux
2010 3 24
5 Linux Linux

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

fudan_abc

change

2010 3 23
3 1. 2.
3. linux kernel
hust_tulip
fudan_abc
linux
linux

4
hust_tulip
fudan_abc
lkd ulk

lkd

Email maintainer
LINUX
Linux usb
Linux

linux

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

2010 3 22
1
fudan_abc

Linux

Kconfig Makefile

2
albcamus
1

timesharedreal-timeCPU

2 C
C C
C gcc C
3 CPU

Linux
1.
Linux Linux
Linus

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

9
2.

3.

USB
0.1

67
4. Kconfig Makefile
Kconfig Makefile
Linux Kconfig Makefile
Linux

Kconfig Makefile Linux Kernel


Kconfig Makefile Kernel
kernel
Kconfig Makefile
5Kernel Kconfig Makefile

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

Linux
14

USB U urb USB


USB USB
USB
C
Linux

include/linux/list.h

21 struct list_head {
22 struct list_head *next, *prev;
23 };
list_head list_head prev next

struct list_node {
struct list_node *next;
ElemType data;
};

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com


hub struct usb_hub hub hub

hub

1
LIST_HEAD
INIT_LIST_HEAD()
25 #define LIST_HEAD_INIT(name) { &(name), &(name) }
26
27 #define LIST_HEAD(name) \
28 struct list_head name = LIST_HEAD_INIT(name)
29
30 static inline void INIT_LIST_HEAD(struct list_head *list)
31 {
32 list->next = list;
33 list->prev = list;
34 }
nextprev

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

298 static inline int list_empty(const struct list_head *head)


299 {
300 return head->next == head;
301 }
3

list_add() list_add_tail()

67 static inline void list_add(struct list_head *new, struct list_head


*head)
68 {
69 __list_add(new, head, head->next);
70 }
84 static inline void list_add_tail(struct list_head *new, struct
list_head *head)
85 {
86 __list_add(new, head ->prev, head);
87 }
list_add() head list_add_tail()
head->prev nextprev
list_add() list_add_tail()

list_del_init()

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

254 static inline void list_del_init(struct list_head *entry)


255 {
256

__list_del(entry->prev, entry->next);

257 INIT_LIST_HEAD(entry);
258 }
list_del_init()
5
list_head

list_entry
425 #define list_entry(ptr, type, member) \
426 container_of(ptr, type, member)
list_entry() Linux

list_entry() Linux

list_entry

list_entry() hub
hub hub
list_entry struct list_head event_list
struct usb_hub
struct list_head *tmp;
struct usb_hub *hub;
tmp = hub_event_list.next;

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

hub = list_entry(tmp, struct usb_hub, event_list);


hub_event_list tmp tmp
struct usb_hub

Linux
15

Linux
parse_args
parse_args =

= grub
kernel
kernel /boot/vmlinuz-2.6.18 root=/dev/sda1 ro splash=silent
vga=0x314 pci=noacpi
pci=noacpi
=

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

.=
usbcore autosuspend 2
$ modprobe usbcore autosuspend=2

usbcore.autosuspend=2
Documentation/kernel-parameters.txt
PCI
pci=option[,option...] [PCI] various PCI subsystem options:
off [X86-32] don't probe for the PCI bus
bios [X86-32] force use of PCI BIOS, don't access
the hardware directly. Use this if your machine
has a non-standard PCI host bridge.
nobios [X86-32] disallow use of PCI BIOS, only direct
hardware access methods are allowed. Use this
if you experience crashes upon bootup and you
suspect they are caused by the BIOS.
conf1 [X86-32] Force use of PCI Configuration
Mechanism 1.
conf2 [X86-32] Force use of PCI Configuration
Mechanism 2.
nommconf [X86-32,X86_64] Disable use of MMCONFIG for PCI
Configuration
nomsi [MSI] If the PCI_MSI kernel config parameter is
enabled, this kernel boot option can be used to
disable the use of MSI interrupts system-wide.
nosort [X86-32] Don't sort PCI devices according to
order given by the PCI BIOS. This sorting is
done to get a device order compatible with
older kernels.
biosirq [X86-32] Use PCI BIOS calls to get the interrupt
routing table. These calls are known to be buggy
on several machines and they hang the machine
when used, but on other computers it's the only
way to get the interrupt routing table. Try
this option if the kernel is unable to allocate
IRQs or discover secondary PCI buses on your
motherboard.
rom [X86-32] Assign address space to expansion ROMs.
Use with caution as certain devices share
address decoders between ROMs and other

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

resources.
irqmask=0xMMMM [X86-32] Set a bit mask of IRQs allowed to be
assigned automatically to PCI devices. You can
make the kernel exclude IRQs of your ISA cards
this way.
pirqaddr=0xAAAAA [X86-32] Specify the physical address
of the PIRQ table (normally generated
by the BIOS) if it is outside the
F0000h-100000h range.
lastbus=N [X86-32] Scan all buses thru bus #N. Can be
useful if the kernel is unable to find your
secondary buses and you want to tell it
explicitly which ones they are.
assign-busses [X86-32] Always assign all PCI bus
numbers ourselves, overriding
whatever the firmware may have done.
usepirqmask [X86-32] Honor the possible IRQ mask stored
in the BIOS $PIR table. This is needed on
some systems with broken BIOSes, notably
some HP Pavilion N5400 and Omnibook XE3
notebooks. This will have no effect if ACPI
IRQ routing is enabled.
noacpi [X86-32] Do not use ACPI for IRQ routing
or for PCI scanning.
routeirq Do IRQ routing for all PCI devices.
This is normally done in pci_enable_device(),
so this option is a temporary workaround
for broken drivers that don't call it.
firmware [ARM] Do not re-enumerate the bus but instead
just use the configuration from the
bootloader. This is currently used on
IXP2000 systems where the bus has to be
configured a certain way for adjunct CPUs.
noearly [X86] Don't do any early type 1 scanning.
This might help on some broken boards which
machine check when some devices' config space
is read. But various workarounds are disabled
and some IOMMU drivers will not work.
bfsort Sort PCI devices into breadth-first order.
This sorting is done to get a device
order compatible with older (<= 2.4) kernels.
nobfsort Don't sort PCI devices into breadth-first order.
cbiosize=nn[KMG] The fixed amount of bus space which is
reserved for the CardBus bridge's IO window.

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

The default value is 256 bytes.


cbmemsize=nn[KMG] The fixed amount of bus space which is
reserved for the CardBus bridge's memory
window. The default value is 64 megabytes.

parse_args
module_param __setup
__setup include/linux/init.h
171 #define __setup(str, fn)
\
172 __setup_param(str, fn, fn, 0)
__setup str fn
__setup str
fnstr =
netdev ether
netdev_boot_setup
__setup early_param
early_param

__setup early_param
parse_args
parse_early_param();
parse_args("Booting kernel", static_command_line, __start___param,
__stop___param - __start___param,
&unknown_bootoption);
parse_args parse_early_param
parse_args

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

550

early_param
early_param
parse_early_param

Linux
16

USBPCI subsys_initcall

subsys_initcall PCI
117 #define
118
119 #define
120 #define
121 #define
122 #define
123 #define
124 #define
125 #define
126 #define
127 #define
128 #define
129 #define

pure_initcall(fn)

__define_initcall("0",fn,1)

core_initcall(fn)
__define_initcall("1",fn,1)
core_initcall_sync(fn)
__define_initcall("1s",fn,1s)
postcore_initcall(fn)
__define_initcall("2",fn,2)
postcore_initcall_sync(fn)
__define_initcall("2s",fn,2s)
arch_initcall(fn)
__define_initcall("3",fn,3)
arch_initcall_sync(fn)
__define_initcall("3s",fn,3s)
subsys_initcall(fn)
__define_initcall("4",fn,4)
subsys_initcall_sync(fn)
__define_initcall("4s",fn,4s)
fs_initcall(fn)
__define_initcall("5",fn,5)
fs_initcall_sync(fn)
__define_initcall("5s",fn,5s)
rootfs_initcall(fn)
__define_initcall("rootfs",fn,rootfs)

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

130 #define
131 #define
132 #define
133 #define
134
135 #define

device_initcall(fn)
__define_initcall("6",fn,6)
device_initcall_sync(fn)
__define_initcall("6s",fn,6s)
late_initcall(fn)
__define_initcall("7",fn,7)
late_initcall_sync(fn)
__define_initcall("7s",fn,7s)
__initcall(fn) device_initcall(fn)

__define_initcall

__define_initcall __define_initcall
.initcall.init

.initcall.init

init bass

vmlinux.lds
arch/<target>/
vmlinux.lds initcall.init

__inicall_start = .;
.initcall.init : AT(ADDR(.initcall.init) 0xC0000000) {
*(.initcall1.init)
*(.initcall2.init)
*(.initcall3.init)
*(.initcall4.init)
*(.initcall5.init)
*(.initcall6.init)
*(.initcall7.init)
}
__initcall_end = .;
.initcall.init 7 xxx_initcall
xxx_initcall __define_initcall
core_initcall .initcall1.init
device_initcall .initcall6.init
.initcall1.init .initcall2.init

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

do_initcalls()
do_initcalls
do_initcall for __initcall_start __initcall_end
__initcall_start
__initcall_end .initcall.init xxx_initcall
do_initcall

.initcall.init

do_initcalls
do_initcalls

flush_scheduled_work do_initcalls

666 static void __init do_initcalls(void)


667 {
668 initcall_t *call;
669 int count = preempt_count();
670
671 for (call = __initcall_start; call < __initcall_end; call++) {
672 ktime_t t0, t1, delta;
673 char *msg = NULL;
674 char msgbuf[40];
675 int result;
676
677 if (initcall_debug) {
678
printk("Calling initcall 0x%p", *call);
679
print_fn_descriptor_symbol(": %s()",
680
(unsigned long) *call);
681
printk("\n");
682
t0 = ktime_get();
683 }
684
685 result = (*call)();
686
687 if (initcall_debug) {

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

688
t1 = ktime_get();
689
delta = ktime_sub(t1, t0);
690
691
printk("initcall 0x%p", *call);
692
print_fn_descriptor_symbol(": %s()",
693
(unsigned long) *call);
694
printk(" returned %d.\n", result);
695
696
printk("initcall 0x%p ran for %Ld msecs: ",
697
*call, (unsigned long long)delta.tv64 >> 20);
698
print_fn_descriptor_symbol("%s()\n",
699
(unsigned long) *call);
700 }
701
702 if (result && result != -ENODEV && initcall_debug) {
703
sprintf(msgbuf, "error code %d", result);
704
msg = msgbuf;
705 }
706 if (preempt_count() != count) {
707
msg = "preemption imbalance";
708
preempt_count() = count;
709 }
710 if (irqs_disabled()) {
711
msg = "disabled interrupts";
712
local_irq_enable();
713 }
714 if (msg) {
715
printk(KERN_WARNING "initcall at 0x%p", *call);
716
print_fn_descriptor_symbol(": %s()",
717
(unsigned long) *call);
718
printk(": returned with %s\n", msg);
719 }
720 }
721
722 /* Make sure there is no pending stuff from the initcall sequence
*/
723 flush_scheduled_work();
724 }

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

Linux
17 PCI

Kconfig PCI
drivers/pci arch/i386/pci
drivers/pci arch/i386/pci PCI

PCI T

USBPCI subsys_initcall


subsys_initcall

PCI
subsys_initcall arch_initcallpostcore_initcall

arch/i386/pci/acpi.c
pci_acpi_init
subsys_initcall
.initcall4.init
arch/i386/pci/common.c
pcibios_init
subsys_initcall
.initcall4.init
arch/i386/pci/i386.c
pcibios_assign_resources
fs_initcall
.initcall5.init
arch/i386/pci/legacy.c
pci_legacy_init
subsys_initcall
.initcall4.init
drivers/pci/pci-acpi.c
acpi_pci_init
arch_initcall
.initcall3.init
drivers/pci/pci-driver.c
pci_driver_init

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

postcore_initcall
.initcall2.init
drivers/pci/pci-sysfs.c
pci_sysfs_init
late_initcall
.initcall7.init
drivers/pci/pci.c
pci_init
device_initcall
.initcall6.init
drivers/pci/probe.c
pcibus_class_init
postcore_initcall
.initcall2.init
drivers/pci/proc.c
pci_proc_init
__initcall
.initcall6.init
arch/i386/pci/init.c
pci_access_init
arch_initcall
.initcall3.init
xxx_initcall
keso
USB subsys_initcall

xxx_initcall .
initcall1.init .initcall2.init
.initcall2.init pcibus_class_init
pci_driver_init
pcibus_class_init pci_driver_init

do_initcalls .initcall.init for

gcc Using the GNU Compiler Collection

the linker searches and processes libraries and object files in the
order they are specified. Thus, foo.o -lz bar.o searches library z
after file foo.o but before bar.o.

drivers/pci/Makefile
5 obj-y
6

+= access.o bus.o probe.o remove.o pci.o quirks.o \


pci-driver.o search.o pci-sysfs.o rom.o setup-res.o

probe.o pci- driver.o probe.c pcibus_class_init


pci- driver.c pci_driver_init

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

Documents/kbuild/makefile.txt 3.2
The order of files in $(obj-y) is significant.
pcibus_class_init pci_driver_init
Makefile .initcall3.init
acpi_pci_init pci_access_init
acpi_pci_init drivers/pci/pci-acpi.c pci_access_init
arch/i386 /pci/init.c
pcibus_class_init pci_driver_init


2 13

80
arch/i386/pci Makefile drivers/pci
Makefile
kbuild
Makefile Makefile
Makefile
arch/*/Makefile arch
Makefile kbuild
arch/*/ Makefile
drivers/ Makefile
kbuild Makefile
arch/* /Makefile
Makefile
kbuild Make
Makefile Makefile

arch/i386/pci
Makefile drivers/pci Makefile
pci_access_init acpi_pci_init

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

Linux
18
Linux

600 Linux
http://en.wikipedia.org/wiki/List_of_Linux_distributions
300


1.
http://distrowatch.com/ 100 Linux
6

2. Linux
http://polishlinux.org/choose/comparison/
Ubuntu Mandriva

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

3. Linux Distribution Chooser


http://www.zegeniestudios.net/ldc/index.php?firsttime=true Linux Distribution Chooser
Linux

.gif" border="0" alt=" 03" width="244" height="195" />


4.

Linux
19 API
SB
API

bug
Linux
Linux

bug

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

USB

USB throughput
USB
USB Core
USB Core

USB

Linux

USB USB

Linux

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

Linux
20 Git


Git

1. Git
Git Linus
Git http://git-scm.com/ Git

Git
Git clone
repository
branching
merging

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

Git
PerlGnomeWine Ubuntu/debian gitcore git
2. Git
Linus 2002 2 BitKeeper
BitMover BitKeeper BitKeeper
GNU Richard
Stallman Linus BitKeeper
BitKeeper
BitMover
BitKeeper Linus
Git Linus
Git the stupid content tracker Git
Linus 2.6.12rc3 Git
3.
Git Linus Google
youtube Linus Git

Linus CVS SVN Linus


CVS
SVN SVN
CVS
SVN CVS

SVN

Git

Linus web of trust


Linus

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

dictator
lieutenants


4.
Git

http://www.ibm.com/developerworks/cn/linux/l-git/
Git
http://www.youtube.com/watch?v=4XpnKHJAok8

http://book.opensourceproject.org.cn/versioncontrol/git/gittutorcn.htm
Git
http://zh-cn.whygitisbetterthanx.com/#github
Kanru Git X Git

http://github.com/
GitHub Git

GitHub
fork Git

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

Linux
21 printk()

bug bug bug

10km
10km
200 AB
C AC BC
BC D BD CD CD E
7
50100m

bug

bug


bug
bug

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

printk()
printk()

printk()
printk()

1. printk() printf()
printf() printk()

printk() printf()
printf() printk()

printk()
2. printk()
printk() printf()
printk() 8

KERN_EMERG
KERN_ALERT
KERN_CRIT
KERN_ERR
KERN_WARNING
KERN_NOTICE
KERN_INFO
KERN_DEBUG

printk() DEFAULT_MESSAGE_LOGLEVEL
KERN_WARNING
3. console_loglevel
printk
include/linux/kernel.h
DEFAULT_CONSOLE_LOGLEVEL 7 KERN_DEBUG
printk()

blog.csdn.net/fudan_abc

Linux QQ1142985060 email1142985060@qq.com

printk()

$ echo 8 > /proc/sys/kernel/printk


4. printk()
include/linux/kernel.h printk() pr_debug pr_info

235 #define pr_debug(fmt,arg...) \


236 printk(KERN_DEBUG fmt,##arg)
244 #define pr_info(fmt,arg...) \
245 printk(KERN_INFO fmt,##arg)
5. printk()
printk()

printk() early_printk()
printk()

blog.csdn.net/fudan_abc