¿éÉ豸Çý¶¯ÏòLINUXÒÆÖ²µÄ³£¹æ²½Öè¼°INITRDµÄʹÓÃ
ÕâÀïÌáµ½µÄ¿éÉ豸·ºÖ¸¸÷ÖÖ¿ÉÒÔʵÏ̶ֹ¨´óСÊý¾ÝËæ»ú´«ÊäµÄÉ豸£¬ÈçFLASH¡¢SD Card¡¢RAMDISKµÈ£¬¿éÉ豸Çý¶¯ÒÆÖ²µÄ¹ý³Ìʵ¼ÊÉÏÊǽ«Ó²¼þ³§ÉÌÌṩµÄµ×²ãÇý¶¯´úÂëÓëLINUXϵͳ¼¯³ÉÆðÀ´µÄ¹ý³Ì¡£
ÔÚLINUXÖУ¬¿éÉ豸Äܹ»ÒÔÎļþϵͳµÄÐÎʽΪOSËù·ÃÎÊ£¬Æä´óÌå¼Ü¹¹ÈçÏ£º
LINUX Application
---------------------------------- system call
LINUX VFS
----------------------------------
File System (vfat/ext2/cramfs..)
----------------------------------
Block Device Driver
---------------------------------- <-- Our working scope
LLD from vendor
----------------------------------
Hardware
ÒÆÖ²µÄ³£¹æ¹ý³ÌΪ£º
1. ÀûÓÃmodule_initºê½«É豸µÄ³õʼ»¯º¯Êýmydev_init×¢²áµ½kernel¾µÏñµÄ.init¶Î¡£µ±È»£¬»¹ÒªÀûÓÃmodule_exitºê×¢²áÈ¥³õʼ»¯º¯Êýmydev_cleanup¡£(ref: linux/init.h)
2. Ìî³ä³õʼ»¯º¯Êýmydev_init£¬Íê³ÉÒÔÏÂÈýÏ×÷
2.1 ʹÓÃregister_blkdev×¢²á¿éÉ豸ºÅºÍÉ豸Ãû¡£¡¡(ref: drivers/block/genhd.c)
2.2 ÉèÖÃqueue£ºÖ÷ÒªÊÇ»ñÈ¡queue²¢ÉèÖÃrequestº¯Êý£¬ÉèÖÃsector´óСµÈ¡£¡¡(ref: drivers/block/ll_rw_blk.c)
2.3 Ìí¼Ódisk£ºadd_disk¡£ (ref: drivers/block/genhd.c)
Éæ¼°µ½µÄÊý¾Ý½á¹¹°üÀ¨£º
a) struct request_queue (ref: linux/blkdev.h)£¬ 2.2ÖеÄqueue½á¹¹
b) struct gendisk (ref: linux/genhd.h)£¬ 2.3ÖеÄdisk½á¹¹£¬¹Ø×¢³ÉÔ± ->
major/first_minor/minors <- É豸ºÅ;
fopsÖ¸Õë <- ¿éÉ豸²Ù×÷º¯ÊýÖ¸Õë×é
queueÖ¸Õë <- 2.2ÖеÄqueue
private_dataÖ¸Õë <- ´æ´¢Óë¾ßÌåÉ豸Ïà¹ØµÄÊý¾Ý½á¹¹
c) struct mydev_dev,¼´b)ÖеľßÌåÉ豸Ïà¹ØµÄÊý¾Ý½á¹¹£¬Í¨³£°üº¬³ÉÔ±
size <- É豸ÖÐsectorµÄÊýÄ¿
users <- ʹÓÃÉ豸µÄÓû§ÊýÄ¿
media_change <- media change񈬀
lock <- ×ÔÐýËø
queue Ö¸Õë <- É豸µÄstruct request_queueÖ¸Õë
disk Ö¸Õë <- É豸µÄstruct gendiskÖ¸Õë
3. LINUX¿éÉ豸Çý¶¯µÄ²Ù×÷º¯ÊýÖ¸Õë×é
open: É豸´ò¿ªÊ±±»µ÷Óã¬Ö÷Òª¹¦ÄÜΪ³õʼ»¯µ×²ãÉ豸£»»òÈ¡µ×²ãÉ豸ÐÅÏ¢
release: É豸¹Ø±Õʱ±»µ÷Óá£
ioctl: ʵÏÖioctlϵͳµ÷Óõĺ¯Êý£¬ÓÉÓÚ´óÁ¿µÄ±ê×¼ÇëÇóΪÉϲã½ØÈ¡£¬Ò»°ã¿éÉ豸µÄioctl±È½Ï¶ÌС¡£
media_changed: Äں˵÷Óøú¯ÊýÒÔ¼ì²éÓû§ÊÇ·ñ¸ü»»ÁËÇý¶¯Æ÷ÄڵĽéÖÊ£¬Èç¹ûÓû§¸ü»»ÁË£¬ÄÇô·µ»ØÒ»¸ö·ÇÁãµÄÖµ¡£ÕâÊÇÕë¶Ô¿ÉÒƶ¯½éÖʵġ£
revalidate_dis
Ïà¹ØÎĵµ£º
ÐÂÊÖÈëÃÅ£ºÇ³Ì¸LinuxµÄÎļþϵͳ
ØýÃû / 2008-09-18
Èç¹ûÄúÊÇһλÐÂÊÖ£¬Ò²Ðí Äú»¹²»ÖªµÀÈçºÎ°ÑÎļþ´ÓWindows¿½±´µ½LinuxÉÏ°É?ÏÂÃ棬ÎÒÃǽ«ËµÃ÷UnixÎļþϵͳÒÔ¼°mountµÄ¹¤×÷¹ý³Ì£¬È»ºóÔٱȽÏÏêϸµØÌÖÂÛ
¡¡¡¡mountµÄʹÓúÍÓйØÑ¡Ïî¡£Èç¹ûÄúÒѾÁ˽âUnixÎļþϵͳÊÇÈçºÎ¹¤×÷µÄ£¬ÄÇô¿ÉÒÔÌø¹ýÏÂÃæÒ»½Ú¡£·ñÔò£¬Äú×îº ......
ǶÈëʽlinuxÆô¶¯ÐÅÏ¢×¢ÊÍÖ®bootloader
¡¡¡¡×÷ΪһÃûǶÈëϵͳ¿ª·¢Õߣ¬ÄãÒ»¶¨Óöµ½¹ýÏÂÃæµÄÇé¾°£º
¡¡¡¡ÔÚijÂÛ̳ÉÏ¿´µ½Ò»ÆªÌû×Ó£¬ÉÏÃæÌù×ÅǶÈëʽlinux¿ª·¢°åÆô¶¯Ê±µÄÓйØÐÅÏ¢£¬È»ºó´ó¼ÒÔÚÌû×ÓÀïÌÖÂÛ×ÅÕâ¸öÆô¶¯¹ý³ÌÖгöÏÖµÄÎÊÌ⣬Ëæ»ú¾ÙÀýÈçÏ£º
Linux version 2.4.20-uc0 (root@Local) (gcc version 2.95.3 20 ......
¿´µ½¹«Ë¾µÄÀÏÍⶼÊÇÓÃLinux±àÒëAVRµÄ³ÌÐò£¬¸Ð¾õºÜÇ¿£¬¶øÇÒ±¾ÈËÒ²ºÜϲ»¶linux£¬ËùÒÔ¾ö¶¨½øÐÐѧϰ£¬ÏּǼһÏÂѧϰ¹ý³Ì£º
1.±àÒëÎÒÃǵÄËã·¨Îļþ£¬Ò²¾ÍÊÇÀÏÍâÒÔÇ°·¢¸øÎÒÃÇÕâ±ßµÄ¹ØÓÚËã·¨µÄ.oÎļþ¡£Óöµ½Ð¡À§ÄÑ£¬Ìáʾfor' loop initial declaration used outside C99 mode
£¬ ......
ÔÚLinuxÖУ¬Èç¹ûÒªÈýø³ÌÔÚºǫ́ÔËÐУ¬Ò»°ãÇé¿öÏ£¬ÎÒÃÇÔÚÃüÁîºóÃæ¼ÓÉÏ&¼´¿É£¬Êµ¼ÊÉÏ£¬ÕâÑùÊǽ«ÃüÁî·ÅÈëµ½Ò»¸ö×÷Òµ¶ÓÁÐÖÐÁË£º
$ ./test.sh &
[1] 17208
$ jobs -l
[1]+ 17208 Running ./test.sh &
¶ÔÓÚÒѾÔÚǰִ̨ÐеÄÃüÁҲ¿ÉÒÔÖØзŵ½ºǫִ́ÐУ¬Ê×ÏÈ°´ctrl+zÔÝÍ ......
LinuxϵÄshellÓëmake
Ò»¡¢shell
1.1 ʲôÊÇshell
¡ñ Óû§ÓëLinuxµÄ½Ó¿Ú
¡ñ ÃüÁî½âÊÍÆ÷
¡ñ Ö§³Ö¶àÓû§
¡ñ Ö§³Ö¸´Ôӵıà³ÌÓïÑÔ
¡ñ ShellÓкܶàÖÖ£¬È磺csh,tcsh,pdksh,ash,sash,zsh,bashµÈ¡£LinuxµÄȱʡShellΪbash(Bourne Again Shell)¡£
ShellÊÇÓû§ºÍ²Ù×÷ϵͳ֮¼ä×îÖ÷Òª½Ó¿Ú¡£Í¨¹ýShell£¬¿ÉÒÔͬʱÔÚºǫ́ÔËÐжà¸öÓ ......