Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

LinuxÄÚºËÉ豸ģÐÍ(3)

ÒëÕߣº¹ùÉÙ±¯
2009/12/01
Ô­ÎÄ£ºlinux-2.6/Documentation/driver-model/bus.txt
×ÜÏßÀàÐÍ
¶¨Òå
~~~~
struct bus_type {
    char            * name;
    struct subsystem    subsys;
    struct kset        drivers;
    struct kset        devices;
    struct bus_attribute    * bus_attrs;
    struct device_attribute    * dev_attrs;
    struct driver_attribute    * drv_attrs;
    int        (*match)(struct device * dev, struct device_driver * drv);
    int        (*hotplug) (struct device *dev, char **envp,
                    int num_envp, char *buffer, int buffer_size);
    int        (*suspend)(struct device * dev, pm_message_t state);
    int        (*resume)(struct device * dev);
};
int bus_register(struct bus_type * bus);
ÉùÃ÷
~~~~
ÄÚºËÀïµÄÿһ¸ö×ÜÏßÀàÐÍ£¨PCI£¬USB£¬µÈ£©Ó¦µ±ÉùÃ÷Ò»¸ö¾²Ì¬µÄ¶ÔÏó¡£ËüÃDZØÐë³õʼ
»¯nameÓò£¬ÓÐʱҲ³õʼ»¯match()»Øµ÷º¯Êý¡£
struct bus_type pci_bus_type = {
       .name    = "pci",
       .match    = pci_bus_match,
};
¸ÃÊý¾Ý½á¹¹Ó¦µ±±»°üº¬ÔÚÒ»¸öÍ·ÎļþÀÏòÏà¹ØµÄÇý¶¯µ¼³ö:
extern struct bus_type pci_bus_type;
×¢²á
~~~~~
×ÜÏßÇý¶¯ÔÚ³õʼ»¯µÄʱºò£¬»áµ÷ÓÃbus_register()¡£Ëü³õʼ»¯×ÜÏß¶ÔÏóµÄÆäÓàµÄÓò£¬
²¢½«×ÜÏß¶ÔÏó²åÈëµ½×ÜÏßÀàÐ͵ÄÈ«¾ÖÁ´±íÀï¡£Ò»µ©×ÜÏß¶ÔÏó±»×¢²á£¬
ËüµÄÿ¸öÓò¶ÔÓÚ×ÜÏßÇý¶¯¶¼ÊÇ¿ÉÓõġ£
»Øµ÷º¯Êý
~~~~~~~~
match():¹ØÁªÇý¶¯µ½É豸
~~~~~~~~~~~~~~~~~~~~~~
É豸µÄIDÊý¾Ý½á¹¹µÄ¸ñʽºÍ±È½ÏÓï·¨ÓÉÆä×ÜÏß×Ô¼º¹æ¶¨¡£Çý¶


Ïà¹ØÎĵµ£º

ʵսLinux Bluetooth±à³Ì£¨Èý£© HCI²ã±à³Ì

1. HCI²ãЭÒé¸ÅÊö£º
HCIÌṩһÌ×ͳһµÄ·½·¨À´·ÃÎÊBluetoothµ×²ã¡£ÈçͼËùʾ£º
´ÓͼÉÏ¿ÉÒÔ¿´³ö£¬Host Controller Interface(HCI)  ¾ÍÊÇÓÃÀ´¹µÍ¨HostºÍModule¡£Hostͨ³£¾ÍÊÇPC£¬ ModuleÔòÊÇÒÔ¸÷ÖÖÎïÀíÁ¬½ÓÐÎʽ£¨USB,serial,pc-cardµÈ£©Á¬½Óµ½PCÉϵÄbluetooth Dongle¡£
ÔÚHostÕâÒ»¶Ë£ºapplication,SDP,L2capµÈЭÒé ......

ʵսLinux Bluetooth±à³Ì(Áù) L2CAP±à³ÌʵÀý

ÀýÒ»£º·¢ËÍSignaling Packet£º
Signaling CommandÊÇ2¸öBluetoothʵÌåÖ®¼äµÄL2CAP²ãÃüÁî´«Êä¡£ËùÒÔµÃSignaling CommandʹÓÃCID 0x0001.
¶à¸öCommand¿ÉÒÔÔÚÒ»¸öC-frame£¨control frame£©Öз¢ËÍ¡£
 Èç¹ûÒªÖ±½Ó·¢ËÍSignaling Command.ÐèÒª½¨Á¢SOCK_RAWÀàÐ͵ÄL2CAPÁ¬½ÓSocket¡£ÕâÑù²ÅÓлú»á×Ô¼ºÌî³äCommand Code£¬Identi ......

[תÌû]LinuxÇý¶¯¿ª·¢Ñ§Ï°µÄһЩ±ØÒª²½Öè

 1. ѧ»áд¼òµ¥µÄmakefile
2. ±àһЩӦÓÃ
³ÌÐò
£¬¿ÉÒÔÓÃmakefileÅÜÆðÀ´
3. ѧ»áдÇý¶¯
µÄmakefile
4. дһ¼òµ¥charÇý¶¯£¬makefile±àÒëͨ¹ý£¬¿ÉÒÔinsmod£¬ lsmod£¬ rmmod. ÔÚÇý¶¯µÄinitº¯ÊýÀï´òÓ¡hello world£¬insmodºóÓ¦¸ÃÄܹ»Í¨¹ýdmesg¿´µ½Êä³ö
¡£
5. дһÍêÕûÇý¶¯£¬ ¼ÓÉÏread£¬ write£¬ ioctl£¬ pollingµÈ¸ ......

˫ϵͳ°²×°Ê±£¬Linux´ÓÓ²ÅÌÆô¶¯

˫ϵͳ°²×°Ê±£¬Linux´ÓÓ²ÅÌÆô¶¯£º
°²×°windows¾Í²»ÔÙ½²ÁË¡£
ÏÂÔØLinuxϵͳ¾µÏñ£¬ÎÒÏÂÔØµÄÊÇCentOS5.3¡£½«Linux¾µÏñ½âѹµ½Ò»¸öfat32·ÖÇøÄ¿Â¼£¨ÎÒµÄÊÇFÅÌ£©¡£
²¢½«¾µÏñÖÐisolinuxĿ¼ÏµÄvmlinuxzºÍinitrd.imgÁ½¸öÎļþcopyµ½FÅÌ£¨ÎÒµÄÊÇFÅÌ£©¡£ÏÂÔØwingrub£¬Ë«»÷°²×°¡£°²×°ºó´ò¿ªwingrub³öÀ´Ò»½çÃæchoose driverÈÃÄãÑ¡ÔñÅÌ ......

linuxÇý¶¯Ñ§Ï°

Ò»¡¢ioctl
´ó²¿·ÖÉ豸³ýÁ˶ÁдÄÜÁ¦£¬»¹¿É½øÐг¬³ö¼òµ¥µÄÊý¾Ý´«ÊäÖ®ÍâµÄ²Ù×÷£¬ËùÒÔÉ豸Çý¶¯Ò²±ØÐë¾ß±¸½øÐи÷ÖÖÓ²¼þ¿ØÖƲÙ×÷µÄÄÜÁ¦. ÕâЩ²Ù×÷³£³£Í¨¹ý ioctl ·½·¨À´Ö§³Ö£¬ËüÓкÍÓû§¿Õ¼ä°æ±¾²»Í¬µÄÔ­ÐÍ:
int (*ioctl) (struct inode *inode, struct file *filp,
         &n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ