linux Íø¿¨Çý¶¯
Tg3 Gbit NIC Driver Analysis
Ôڴ˽ö½öÌÖÂÛÍøÂçÉ豸Çý¶¯µÄÒ»°ãд·¨£¬ÓйØÓ²¼þ²¿·ÖµÄÏà¹Ø´úÂëÓÉÓÚÓ²¼þ¹æ¸ñ²»Í¬£¬ÓèÒÔÊ¡ÂÔ¡£ÓÐʲôµØ·½´íÎ󣬻ò²¹³ä£¬»¶Ó´ó¼ÒÌá³ö¡£
1, Çý¶¯Ä£¿éµÄ¼ÓÔغÍжÔØ
Èç¹ûÍøÂçÉ豸£¨°üÀ¨wireless£©ÊÇPCI¹æ·¶µÄ£¬ÔòÏÈÊÇÏòÄÚºË×¢²á¸ÃPCIÉ豸(pci_register_driver)£¬È»ºóÓÉpci_driverÊý¾Ý½á¹¹ÖеÄprobeº¯ÊýÖ¸ÕëËùÖ¸ÏòµÄÕì²âº¯ÊýÀ´³õʼ»¯¸ÃPCIÉ豸£¬²¢ÇÒͬʱע²áºÍ³õʼ»¯¸ÃÍøÂçÉ豸¡£
Èç¹ûÍøÂçÉ豸£¨°üÀ¨wireless£©ÊÇPCMCIA¹æ·¶µÄ£¬ÔòÏÈÊÇÏòÄÚºË×¢²á¸ÃPCMCIAÉ豸(register_pccard_driver)£¬È»ºódriver_info_tÊý¾Ý½á¹¹ÖеÄattachº¯ÊýÖ¸ÕëËùÖ¸ÏòµÄÕì²âº¯ÊýÀ´³õʼ»¯¸ÃPCMCIAÉ豸£¬²¢ÇÒͬʱע²áºÍ³õʼ»¯¸ÃÍøÂçÉ豸¡£
static int __init tg3_init(void)
{
//ÏÈ×¢²á³ÉPCIÉ豸£¬²¢³õʼ»¯£¬Èç¹ûÊÇÆäËûµÄESIA£¬PCMCIA£¬ÓÃÆäËûº¯Êý
return pci_module_init(&tg3_driver);
}
static void __exit tg3_cleanup(void)
{
pci_unregister_driver(&tg3_driver);//×¢ÏúPCIÉ豸
}
module_init(tg3_init); //Çý¶¯Ä£¿éµÄ¼ÓÔØ
module_exit(tg3_cleanup); //Çý¶¯Ä£¿éµÄжÔØ
ÉêÃ÷ΪPCIÉ豸£º
static struct pci_driver tg3_driver = {
.name = DRV_MODULE_NAME,
.id_table = tg3_pci_tbl, //´ËÇý¶¯ËùÖ§³ÖµÄÍø¿¨ÏµÁУ¬vendor_id, device_id
.probe = tg3_init_one, //³õʼ»¯ÍøÂçÉ豸µÄ»Øµ÷º¯Êý
.remove = __devexit_p(tg3_remove_one), //×¢ÏúÍøÂçÉ豸µÄ»Øµ÷º¯Êý
.suspend = tg3_suspend, //É豸¹ÒÆðº¯Êý
.resume = tg3_resume //É豸»Ö¸´º¯Êý
};
2£¬PCIÉ豸̽²âº¯Êýprobe£¬³õʼ»¯ÍøÂçÉ豸
static int __devinit tg3_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
//³õʼ»¯É豸£¬Ê¹I/O£¬memory¿ÉÓ㬻½ÐÑÉ豸
pci_enable_device(pdev);
//ÉêÇëÄÚ´æ¿Õ¼ä£¬ÅäÖÃÍø¿¨µÄI/O£¬memory×ÊÔ´
pci_request_regions(pdev, DRV_MODULE_NAME);
pci_set_master(pdev);
//ÉèÖÃDMAÊôÐÔ
pci_set_dma_mask(pdev, (u64) 0xffffffffffffffff);
//Íø¿¨ I/O,memory×ÊÔ´µÄÆôʼµØÖ·
tg3reg_base = pci_resource_start(pdev, 0);
//Íø¿¨I/O,memory×ÊÔ´µÄ´óС
tg3reg_len = pci_resource_len(pdev, 0);
//·ÖÅä²¢ÉèÖÃÍøÂçÉ豸
dev = alloc_etherdev(sizeof(*tp));
//ÉêÃ÷ΪÄÚºËÉ豸ģ¿é
SET_MODULE_OWNER(dev);
//³õʼ»¯Ë½ÓнṹÖеĸ÷³ÉÔ±Öµ
tp = dev->priv
Ïà¹ØÎĵµ£º
Service Discovery Protocol(SDP)ÌṩһÖÖÄÜÁ¦£¬ÈÃÓ¦ÓóÌÐòÓз½·¨·¢ÏÖÄÄÖÖ·þÎñ¿ÉÓÃÒÔ¼°ÕâÖÖ·þÎñµÄÌØÐÔ¡£
·þÎñ·¢ÏÖÐÒé(SDP»òBluetooth SDP)ÔÚÀ¶ÑÀÐÒéÕ»ÖжÔÀ¶ÑÀ»·¾³ÖеÄÓ¦ÓóÌÐòÓÐÌØÊâµÄº¬Ò⣬·¢ÏÖÄĸö·þÎñÊÇ¿ÉÓõĺÍÈ·¶¨ÕâЩ¿ÉÓ÷þÎñµÄÌØÕ÷¡£SDP¶¨ÒåÁËbluetooth client·¢ÏÖ¿ÉÓÃbluetooth server·þÎñºÍËüÃǵÄÌØÕ÷µÄ·½·¨¡£ ......
~ µ±Ç°Óû§Ä¿Â¼µÄËõд
cd ~
cd /home/<user-name>/
--help »ñÈ¡°ïÖú
vi --help
tab ×Ô¶¯²¹È«¡£Ë«»÷tab¸ø³ö²¹È«Ìáʾ¡£
Èôµ±Ç°ÃüÁîÎÞÆçÒ壬ÔòÍêÕû²¹È«¡£ÈôÓÐÆçÒåË«»÷¿ÉÁгöÌáʾѡÏî¡£
cd /e [tab], ²¹È«Îªcd /etc/
cd /b [tab-tab], ÁгöÑ¡Ïîbin/ bo ......
SambaÊÇÒ»¸öÍøÂç·þÎñÆ÷£¬ÓÃÓÚLinuxºÍWindows¹²ÏíÎļþÖ®Óã»Samba ¼´¿ÉÒÔÓÃÓÚWindowsºÍLinuxÖ®¼äµÄ¹²ÏíÎļþ£¬Ò²Ò»ÑùÓÃÓÚLinuxºÍLinuxÖ®¼äµÄ¹²ÏíÎļþ£»²»¹ý¶ÔÓÚLinuxºÍLinuxÖ®¼ä¹²ÏíÎļþÓиüºÃµÄÍøÂçÎļþϵͳNFS£¨NFSÒ²ÊÇÐèÒª¼ÜÉè·þÎñÆ÷µÄ£©¡£Samba¿ÉÒÔ¶¨Î»ÎªÒ»Ì×¹¦Äܼ«ÎªÇ¿´óµÄÎļþ·þÎñÆ÷Èí¼þ£¬ËùÎ ......
1.Æô¶¯À¶ÑÀÉ豸
sudo /etc/init.d/bluetooth restart
»òÕß
sudo /etc/init.d/bluez-utils restart
2.ʹÓÃhcitool dev²é¿´¼ÆËã»úÉϵÄÀ¶ÑÀÉ豸
teapot@teapot:~$ hcitool dev
Devices:
hci0 00:16:CF:DB:B4:BF
teapot@teapot:~$
3.°²×°É豸
²éѯÉ豸µØÖ·
teapot@teapot:~$ sudo hidd - ......
Linux Äں˱àÒëÅäÖÃÑ¡Ïî¼ò½é
×÷Õߣº½ð²½¹ú
°æȨÉùÃ÷
±¾ÎÄ×÷ÕßÊÇһλ×ÔÓÉÈí¼þ°®ºÃÕߣ¬ËùÒÔ±¾ÎÄËäÈ»²»ÊÇÈí¼þ£¬µ«ÊDZ¾×Å GPL
µÄ¾«Éñ·¢²¼¡£ÈκÎÈ˶¼¿ÉÒÔ×ÔÓÉʹÓá¢×ªÔØ¡¢¸´ÖƺÍÔÙ·Ö·¢£¬µ«±ØÐë±£Áô×÷ÕßÊðÃû£¬Ò಻µÃ¶ÔÉùÃ÷ÖеÄÈκÎÌõ¿î×÷ÈκÎÐÎʽµÄÐ޸ģ¬Ò²²»µÃ¸½¼ÓÈκÎÆäËüÌõ¼þ¡£Äú¿É
ÒÔ×ÔÓÉÁ´½Ó¡¢ÏÂÔØ¡¢´«²¥´ËÎĵµ ......