1 /** 2 * Copyright (C) 2015-2021 Alibaba Group Holding Limited 3 */ 4 5 #ifndef _U_DEVICE_INFO_H_ 6 #define _U_DEVICE_INFO_H_ 7 8 #include "aos/list.h" 9 10 #include <drivers/u_io.h> 11 12 struct u_bus_info; 13 struct u_device_info; 14 struct u_driver_info; 15 16 typedef unsigned int u_dev_t; 17 18 typedef struct u_bus_info { 19 bus_type_e type; 20 /*TODO: const*/ char *name; 21 struct dlist_s bus_node; 22 struct slist_s bus_dev_head; 23 struct u_driver_info *drv; 24 } u_bus_info_t; 25 26 typedef enum device_state { 27 DEV_STATE_IDLE = 0x71, /* idle, not bind with any driver */ 28 DEV_STATE_BINDED, /* binded with the driver */ 29 DEV_STATE_SHARED, /* shared state */ 30 DEV_STATE__MAX, 31 } device_state_e; 32 33 /** 34 * struct u_device_info - the base device struct 35 * @parent: The device's parent, usually it points to device's bus 36 * NULL is not allowed for non-bus type device, if the device is not 37 * attached to any bus, attach to virtual bus named platform 38 * @dev_name: device's name 39 * @id: device id 40 * @dev_res: device resource list 41 * @devt: 42 * @state: device state, idle/binded 43 * @bus: bus of the device 44 * @drv: driver for this device 45 * @dev_node: device list 46 * @bus_dev_node: device list of the same bus 47 * @drv_dev_node: device list of the same driver 48 * 49 * */ 50 typedef struct u_device_info { 51 struct u_device_info *parent; 52 53 /*TODO: const*/ char *dev_name; 54 unsigned int id; 55 56 struct dev_res *res; 57 u_dev_t devt; 58 59 unsigned int state; 60 61 struct u_bus_info *bus; 62 struct u_driver_info *drv; 63 64 struct dlist_s dev_node; 65 struct slist_s bus_dev_node; 66 struct slist_s drv_dev_node; 67 } u_device_info_t; 68 69 /** 70 * struct u_driver - device driver information 71 * @name: driver's name, should be compatible with dev_name (in struct u_device_info) 72 * of the device it drives 73 * @path: driver path in file system 74 * @pid: id of the process in which the driver is loaded, used for IPC 75 * @tid: id of the thread belongs to the driver, used for IPC 76 * @drv_dev_node: device list which this driver drives 77 * @ 78 * */ 79 typedef struct u_driver_info { 80 /*TODO: const*/ char name[128]; /* TODO: use char* and malloc memory dynamic later */ 81 /*TODO: const*/ char *path; /* driver binary file path */ 82 int type; /* bus, device or subsystem */ 83 int bus_type; /* bus driver's type, platform, sdio, usb and etc. */ 84 unsigned int pid; 85 unsigned int tid; 86 87 struct slist_s drv_dev_head; 88 struct dlist_s drv_node; 89 90 } u_driver_info_t; 91 92 93 typedef enum drv_type { 94 DRV_TYPE_MIN, 95 DRV_TYPE_BUS, 96 DRV_TYPE_SUBSYS, 97 DRV_TYPE_CHAR_DEV, 98 DRV_TYPE_BLOCK_DEV, 99 DRV_TYPE_NET_DEV, 100 DRV_TYPE_MAX 101 } drv_type_e; 102 103 typedef struct u_driver_bin_info { 104 int type; /* bus, device or subsystem */ 105 int bus_type; /* bus_type_e */ 106 char *name; /* driver name got from binary */ 107 } u_driver_bin_info_t; 108 109 #endif //_U_DEVICE_INFO_H_ 110