diff options
| author | erikchan <[email protected]> | 2023-07-25 13:50:50 +0800 |
|---|---|---|
| committer | guo <[email protected]> | 2023-07-27 11:16:55 +0800 |
| commit | 0eaa757cffe21231ee6b57e0e2c9681f966e6f56 (patch) | |
| tree | 134704ab3f9b80b5e3972202fb84c50633c807d3 /components/drivers/include/core | |
| parent | c1cc1332e98fd8ba55a4fef9fbcacf45f4081b36 (diff) | |
【dd2.0】move the core header files to include/drivers/core
Diffstat (limited to 'components/drivers/include/core')
| -rw-r--r-- | components/drivers/include/core/bus.h | 54 | ||||
| -rw-r--r-- | components/drivers/include/core/device.h | 89 | ||||
| -rw-r--r-- | components/drivers/include/core/dm.h | 35 | ||||
| -rw-r--r-- | components/drivers/include/core/driver.h | 56 |
4 files changed, 0 insertions, 234 deletions
diff --git a/components/drivers/include/core/bus.h b/components/drivers/include/core/bus.h deleted file mode 100644 index 10e7fa10ea..0000000000 --- a/components/drivers/include/core/bus.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2006-2023, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2023-04-12 ErikChan the first version - */ - -#ifndef __BUS_H__ -#define __BUS_H__ - -#include <rthw.h> -#include <drivers/core/device.h> -#include <drivers/core/driver.h> - -typedef struct rt_bus *rt_bus_t; - -struct rt_bus -{ - struct rt_object parent; /**< inherit from rt_object */ - - char *name; - struct rt_bus *bus; - - rt_list_t list; - rt_list_t children; - rt_list_t dev_list; - rt_list_t drv_list; - - struct rt_spinlock spinlock; - - rt_bool_t (*match)(rt_driver_t drv, rt_device_t dev); - rt_err_t (*probe)(rt_device_t dev); -}; - -rt_bus_t rt_bus_root(void); - -rt_err_t rt_bus_for_each_dev(rt_bus_t bus, rt_driver_t drv, int (*fn)(rt_driver_t drv, rt_device_t dev)); -rt_err_t rt_bus_for_each_drv(rt_bus_t bus, rt_device_t dev, int (*fn)(rt_driver_t drv, rt_device_t dev)); - -rt_err_t rt_bus_add(rt_bus_t bus); -rt_err_t rt_bus_add_driver(rt_bus_t bus, rt_driver_t drv); -rt_err_t rt_bus_add_device(rt_bus_t bus, rt_device_t dev); -rt_err_t rt_bus_remove_driver(rt_driver_t drv); -rt_err_t rt_bus_remove_device(rt_device_t dev); - -rt_bus_t rt_bus_find_by_name(char *name); -rt_err_t rt_bus_reload_driver_device(rt_bus_t new_bus, rt_device_t dev); - -rt_err_t rt_bus_register(rt_bus_t bus); - -#endif /* __BUS_H__ */ diff --git a/components/drivers/include/core/device.h b/components/drivers/include/core/device.h deleted file mode 100644 index 87019a3797..0000000000 --- a/components/drivers/include/core/device.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2006-2023, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2023-04-12 ErikChan the first version - */ - -#ifndef __DEVICE_H__ -#define __DEVICE_H__ - -#include <rtdef.h> - -typedef struct rt_driver *rt_driver_t; -typedef struct rt_device *rt_device_t; - -/** - * Notify structure - */ -struct rt_device_notify -{ - void (*notify)(rt_device_t dev); - struct rt_device *dev; -}; - -/** - * Device structure - */ -struct rt_device -{ - struct rt_object parent; /**< inherit from rt_object */ - rt_list_t node; - struct rt_bus *bus; - void *priv; - -#ifdef RT_USING_DM - rt_driver_t drv; - void *ofw_node; -#endif - enum rt_device_class_type type; /**< device type */ - rt_uint16_t flag; /**< device flag */ - rt_uint16_t open_flag; /**< device open flag */ - - rt_uint8_t ref_count; /**< reference count */ - rt_uint8_t device_id; /**< 0 - 255 */ - - /* device call back */ - rt_err_t (*rx_indicate)(rt_device_t dev, rt_size_t size); - rt_err_t (*tx_complete)(rt_device_t dev, void *buffer); - -#ifdef RT_USING_DEVICE_OPS - const struct rt_device_ops *ops; -#else - /* common device interface */ - rt_err_t (*init) (rt_device_t dev); - rt_err_t (*open) (rt_device_t dev, rt_uint16_t oflag); - rt_err_t (*close) (rt_device_t dev); - rt_ssize_t (*read) (rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size); - rt_ssize_t (*write) (rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size); - rt_err_t (*control)(rt_device_t dev, int cmd, void *args); -#endif /* RT_USING_DEVICE_OPS */ - -#ifdef RT_USING_POSIX_DEVIO - const struct dfs_file_ops *fops; - struct rt_wqueue wait_queue; -#endif /* RT_USING_POSIX_DEVIO */ - - void *user_data; /**< device private data */ -}; - -#ifdef RT_USING_DEVICE_OPS -/** - * operations set for device object - */ -struct rt_device_ops -{ - /* common device interface */ - rt_err_t (*init) (rt_device_t dev); - rt_err_t (*open) (rt_device_t dev, rt_uint16_t oflag); - rt_err_t (*close) (rt_device_t dev); - rt_ssize_t (*read) (rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size); - rt_ssize_t (*write) (rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size); - rt_err_t (*control)(rt_device_t dev, int cmd, void *args); -}; -#endif /* RT_USING_DEVICE_OPS */ - -#endif /* __DEVICE_H__ */ diff --git a/components/drivers/include/core/dm.h b/components/drivers/include/core/dm.h deleted file mode 100644 index fc7d0d3a30..0000000000 --- a/components/drivers/include/core/dm.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2006-2021, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2023-04-20 ErikChan the first version - */ - -#ifndef __RT_DM_H__ -#define __RT_DM_H__ - -#include <rthw.h> -#include <rtdef.h> -#include <drivers/misc.h> -#include <drivers/byteorder.h> - -#ifndef RT_CPUS_NR -#define RT_CPUS_NR 1 -#endif - -#ifndef RT_USING_SMP -extern int rt_hw_cpu_id(void); -#endif - -void rt_dm_secondary_cpu_init(void); - -int rt_dm_set_dev_name_auto(rt_device_t dev, const char *prefix); -int rt_dm_get_dev_name_id(rt_device_t dev); - -int rt_dm_set_dev_name(rt_device_t dev, const char *format, ...); -const char *rt_dm_get_dev_name(rt_device_t dev); - -#endif /* __RT_DM_H__ */ diff --git a/components/drivers/include/core/driver.h b/components/drivers/include/core/driver.h deleted file mode 100644 index 60661a2cfb..0000000000 --- a/components/drivers/include/core/driver.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2006-2023, RT-Thread Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2023-04-12 ErikChan the first version - */ - -#ifndef __DRIVER_H__ -#define __DRIVER_H__ - -#include <drivers/core/device.h> - -struct rt_driver -{ - struct rt_bus *bus; - rt_list_t node; - -#ifdef RT_USING_DEVICE_OPS - const struct rt_device_ops *dev_ops; -#else - /* common device interface */ - rt_err_t (*init) (rt_device_t dev); - rt_err_t (*open) (rt_device_t dev, rt_uint16_t oflag); - rt_err_t (*close) (rt_device_t dev); - rt_ssize_t (*read) (rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size); - rt_ssize_t (*write) (rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size); - rt_err_t (*control)(rt_device_t dev, int cmd, void *args); -#endif - - const struct filesystem_ops *fops; - - const char *name; - - int (*probe)(struct rt_device *dev); - int (*remove)(struct rt_device *dev); - - void *priv; -}; - -int rt_driver_probe_device(struct rt_driver *drv, struct rt_device *dev); - -rt_err_t rt_driver_register(rt_driver_t drv); -rt_err_t rt_driver_unregister(rt_driver_t drv); - -#define RT_DRIVER_EXPORT(driver, bus_name, mode) \ -static int ___##driver##_register(void) \ -{ \ - rt_##bus_name##_driver_register(&driver); \ - return 0; \ -} \ -INIT_DEVICE_EXPORT(___##driver##_register); \ - -#endif /* __DRIVER_H__ */ |
