lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #ifndef _HOTPLUG_H_ |
| 2 | #define _HOTPLUG_H_ |
| 3 | |
| 4 | #include <stdio.h> |
| 5 | #include <string.h> |
| 6 | #include <stdlib.h> |
| 7 | #include <sys/types.h> |
| 8 | #include <sys/stat.h> |
| 9 | #include <fcntl.h> |
| 10 | #include <netinet/in.h> |
| 11 | #include <unistd.h> |
| 12 | #include <sys/ipc.h> |
| 13 | #include <sys/msg.h> |
| 14 | #include <pthread.h> |
| 15 | #include <errno.h> |
| 16 | #include <signal.h> |
| 17 | #include <arpa/inet.h> |
| 18 | #include <netinet/in.h> |
| 19 | #include <sys/socket.h> |
| 20 | #include <syslog.h> |
| 21 | #include <sys/klog.h> |
| 22 | #include <assert.h> |
| 23 | #include <linux/netlink.h> |
| 24 | #include <rtc_timer.h> |
| 25 | #include "message.h" |
| 26 | #include "softap_api.h" |
| 27 | |
| 28 | #define UEVENT_BUFFER_SIZE 2048*3//Çý¶¯zte_drv_usb_ctrl.hÊÇ6K£¬ºóÆÚÒªÓÅ»¯¿ÉÄÜÕ»Òç³ö |
| 29 | |
| 30 | //#define MSG_ID_HOTPLUG 1024 |
| 31 | |
| 32 | |
| 33 | /*UEVENTʼþÀàÐÍ*/ |
| 34 | enum kobject_action { |
| 35 | KOBJ_ADD, |
| 36 | KOBJ_REMOVE, |
| 37 | KOBJ_CHANGE, |
| 38 | KOBJ_MOVE, |
| 39 | KOBJ_ONLINE, |
| 40 | KOBJ_OFFLINE, |
| 41 | KOBJ_MAX |
| 42 | }; |
| 43 | |
| 44 | |
| 45 | /*É豸ÀàÐÍ£¬ÓÃÓÚÇø·Ö½âÎöºÍ´¦Àí*/ |
| 46 | enum device_type { |
| 47 | DEVICE_TYPE_APP_RTC, /*Ó¦ÓÃRTC*/ |
| 48 | DEVICE_TYPE_APP_WIFI, /*Ó¦ÓÃWIFI*/ |
| 49 | DEVICE_TYPE_APP_SDCARD, /*Ó¦ÓÃSD*/ |
| 50 | DEVICE_TYPE_APP_MMI_BATTERY, /*Ó¦ÓÃMMI BATTERY*/ |
| 51 | DEVICE_TYPE_APP_MMI_OFFCHG, /*Ó¦ÓÃMMI¹Ø»ú³äµç*/ |
| 52 | |
| 53 | DEVICE_TYPE_USB, /*USBÍø¿Ú*/ |
| 54 | DEVICE_TYPE_RJ45, /*rj45Íø¿Ú*/ |
| 55 | DEV_TYPE_USB, /*Çý¶¯USB*/ |
| 56 | DEV_TYPE_SDCARD, /*Çý¶¯sdcard*/ |
| 57 | DEV_TYPE_VIRTUAL_SDCARD, /*Çý¶¯ÐéÄâT¿¨*/ |
| 58 | DEV_TYPE_SERIAL, /*Çý¶¯SERIAL*/ |
| 59 | DEV_TYPE_MBIM, |
| 60 | DEVICE_TYPE_MAX, |
| 61 | }; |
| 62 | |
| 63 | /*usbÏûÏ¢µÄʼþÀàÐÍ*/ |
| 64 | enum usb_event |
| 65 | { |
| 66 | USB_EVENT_CHARGE = 0, |
| 67 | USB_EVENT_DEVICE, |
| 68 | USB_EVENT_CDROMOBJ, |
| 69 | USB_EVENT_USER, |
| 70 | USB_EVENT_DEBUG, |
| 71 | USB_EVENT_FACTORY, |
| 72 | USB_EVENT_AMT, |
| 73 | USB_EVENT_EYE_DIAGRAM, |
| 74 | USB_EVENT_RESET, |
| 75 | USB_EVENT_MAX, |
| 76 | }; |
| 77 | |
| 78 | /*CMUXÏûÏ¢µÄʼþÀàÐÍ*/ |
| 79 | enum serial_event |
| 80 | { |
| 81 | SERIAL_EVENT_GSMTTY1 = 0, |
| 82 | SERIAL_EVENT_GSMTTY2, |
| 83 | SERIAL_EVENT_GSMTTY3, |
| 84 | SERIAL_EVENT_TTYGS0, |
| 85 | SERIAL_EVENT_TTYGS1, |
| 86 | SERIAL_EVENT_MAX, |
| 87 | }; |
| 88 | |
| 89 | |
| 90 | /*ÈȰβåÏûÏ¢½âÎö·µ»Ø*/ |
| 91 | struct hotplug_event { |
| 92 | int type; /*É豸ÀàÐÍ*/ |
| 93 | int action; /*¶¯×÷ÀàÐÍ£¬¶ÔÓ¦kobject_action*/ |
| 94 | |
| 95 | union { |
| 96 | struct net_dev { |
| 97 | char dev_name[NETIF_NAME_LEN]; |
| 98 | int dev_id; |
| 99 | } netdev; |
| 100 | struct usb_dev |
| 101 | { |
| 102 | int event_type; |
| 103 | } usb; |
| 104 | struct serial_dev |
| 105 | { |
| 106 | int event_type; |
| 107 | char dev_name[20]; |
| 108 | } serial; |
| 109 | } u; |
| 110 | }; |
| 111 | |
| 112 | extern char usbdev_name[1024]; |
| 113 | |
| 114 | typedef int (*hotplug_parse_func)(const char *msg, int msglen, struct hotplug_event *event); |
| 115 | typedef int (*hotplug_proc_func)(struct hotplug_event *event); |
| 116 | |
| 117 | int hotplug_parse_register(int device_type, hotplug_parse_func func); |
| 118 | |
| 119 | int hotplug_proc_register(int device_type, hotplug_proc_func func); |
| 120 | |
| 121 | void char_replace(char*buf, int count, char orig_char, char replace_char); |
| 122 | |
| 123 | void netdev_hotplug_init(); |
| 124 | |
| 125 | void drv_hotplug_init(void); |
| 126 | |
| 127 | #endif |
| 128 | |