XWOS API  4.0
XWOS C/C++ API参考手册
载入中...
搜索中...
未找到
device.h
浏览该文件的文档.
1
26#ifndef __xwcd_ds_device_h__
27#define __xwcd_ds_device_h__
28
29#include <xwcd/ds/standard.h>
30#include <xwos/lib/xwaop.h>
31#include <xwos/lib/bclst.h>
32#include <xwos/osal/lock/mtx.h>
33#include <xwcd/ds/object.h>
34
44#define xwds_itr_next_device(ds, p) \
45 xwlib_bclst_itr_next_entry(p, &(ds)->devhead, \
46 struct xwds_device, obj.node)
47
51#define xwds_itr_prev_device(ds, p) \
52 xwlib_bclst_itr_prev_entry(p, &(ds)->devhead, \
53 struct xwds_device, obj.node)
54
58#define xwds_itr_next_device_safe(ds, p, n) \
59 xwlib_bclst_itr_next_entry_safe(p, n, &(ds)->devhead, \
60 struct xwds_device, obj.node)
61
65#define xwds_itr_prev_device_safe(ds, p, n) \
66 xwlib_bclst_itr_prev_entry_safe(p, n, &(ds)->devhead, \
67 struct xwds_device, obj.node)
68
69#define __IOC_NRBITS 8
70#define __IOC_TYPEBITS 8
71#define __IOC_SIZEBITS 14
72#define __IOC_DIRBITS 2
73
74#define __IOC_NRMASK ((1 << __IOC_NRBITS) - 1)
75#define __IOC_TYPEMASK ((1 << __IOC_TYPEBITS) - 1)
76#define __IOC_SIZEMASK ((1 << __IOC_SIZEBITS) - 1)
77#define __IOC_DIRMASK ((1 << __IOC_DIRBITS) - 1)
78
79#define __IOC_NRSHIFT 0
80#define __IOC_TYPESHIFT (__IOC_NRSHIFT + __IOC_NRBITS)
81#define __IOC_SIZESHIFT (__IOC_TYPESHIFT + __IOC_TYPEBITS)
82#define __IOC_DIRSHIFT (__IOC_SIZESHIFT + __IOC_SIZEBITS)
83
84#define __IOC_CTRL 0U
85#define __IOC_WRITE 1U
86#define __IOC_READ 2U
87
88#define __IOC(dir, type, nr, size) \
89 (((dir) << __IOC_DIRSHIFT) | \
90 ((type) << __IOC_TYPESHIFT) | \
91 ((nr) << __IOC_NRSHIFT) | \
92 ((size) << __IOC_SIZESHIFT))
93
94struct xwds_device;
95
100 xwer_t (* probe)(struct xwds_device *);
101 xwer_t (* remove)(struct xwds_device *);
102 xwer_t (* start)(struct xwds_device *);
103 xwer_t (* stop)(struct xwds_device *);
104#if defined(XWCDCFG_ds_PM) && (1 == XWCDCFG_ds_PM)
105 xwer_t (* suspend)(struct xwds_device *);
106 xwer_t (* resume)(struct xwds_device *);
107#endif
108};
109
114 /* public */
115 const char * name;
116 xwer_t (* probe)(struct xwds_device *);
117 xwer_t (* remove)(struct xwds_device *);
118 xwer_t (* start)(struct xwds_device *);
119 xwer_t (* stop)(struct xwds_device *);
120 xwer_t (* suspend)(struct xwds_device *);
121 xwer_t (* resume)(struct xwds_device *);
122};
123
129 /* attribute */
130 const char * name;
132 const struct xwds_resources * resources;
133 const struct xwds_driver * drv;
134 void * data;
136 /* private */
137 struct xwds * ds;
139};
140
145
146#if defined(XWCDCFG_ds_PM) && (1 == XWCDCFG_ds_PM)
149#endif
150
155void xwds_device_construct(struct xwds_device * dev);
156
161void xwds_device_destruct(struct xwds_device * dev);
162
174xwer_t xwds_device_probe(struct xwds * ds, struct xwds_device * dev,
175 xwobj_gc_f gcfunc);
176
187
198
207
208#if defined(XWCDCFG_ds_PM) && (1 == XWCDCFG_ds_PM)
217
226
235xwer_t xwds_device_suspend_all(struct xwds * ds, bool ign_err);
236
245xwer_t xwds_device_resume_all(struct xwds * ds, bool ign_err);
246#endif
247
255{
256 return xwds_obj_get_tik(&dev->obj);
257}
258
259#if defined(XWCDCFG_ds_LITE) && (1 == XWCDCFG_ds_LITE)
260
269{
270 XWOS_UNUSED(dev);
271 return XWOK;
272}
273
282{
283 XWOS_UNUSED(dev);
284 return XWOK;
285}
286
294{
295 return xwds_obj_get_refcnt(&dev->obj);
296}
297
298#else
299
308{
309 return xwds_obj_grab(&dev->obj);
310}
311
320{
321 return xwds_obj_put(&dev->obj);
322}
323
331{
332 return xwds_obj_get_refcnt(&dev->obj);
333}
334#endif
335
340#endif /* xwcd/ds/device.h */
XWOS通用库:双循环链表
static xwer_t xwds_device_grab(struct xwds_device *dev)
XWDS API:增加对象的引用计数
Definition device.h:268
xwer_t xwds_device_vop_start(struct xwds_device *dev)
设备基本操作函数:启动设备
Definition device.c:105
xwer_t xwds_device_suspend_all(struct xwds *ds, bool ign_err)
XWDS API:暂停所有设备
Definition device.c:398
static xwsq_t xwds_device_get_refcnt(struct xwds_device *dev)
XWDS API:得到对象的引用计数
Definition device.h:293
void xwds_device_construct(struct xwds_device *dev)
XWDS API:设备的构造函数
Definition device.c:48
void xwds_device_destruct(struct xwds_device *dev)
XWDS API:设备的析构函数
Definition device.c:56
xwer_t xwds_device_probe(struct xwds *ds, struct xwds_device *dev, xwobj_gc_f gcfunc)
XWDS API:探测设备
Definition device.c:213
xwer_t xwds_device_stop(struct xwds_device *dev)
XWDS API:停止设备
Definition device.c:301
static xwsq_t xwds_device_get_tik(struct xwds_device *dev)
XWDS API:获取设备对象的标签
Definition device.h:254
static xwer_t xwds_device_put(struct xwds_device *dev)
XWDS API:减少对象的引用计数
Definition device.h:281
xwer_t xwds_device_resume_all(struct xwds *ds, bool ign_err)
XWDS API:继续所有设备
Definition device.c:425
xwer_t xwds_device_vop_stop(struct xwds_device *dev)
设备基本操作函数:停止设备
Definition device.c:124
xwer_t xwds_device_suspend(struct xwds_device *dev)
XWDS API:暂停设备
Definition device.c:334
xwer_t xwds_device_vop_remove(struct xwds_device *dev)
设备基本操作函数:删除设备
Definition device.c:86
xwer_t xwds_device_remove(struct xwds_device *dev)
XWDS API:删除设备
Definition device.c:261
xwer_t xwds_device_vop_resume(struct xwds_device *dev)
设备基本操作函数:继续设备
Definition device.c:163
xwer_t xwds_device_resume(struct xwds_device *dev)
XWDS API:继续设备
Definition device.c:366
xwer_t xwds_device_start(struct xwds_device *dev)
XWDS API:启动设备
Definition device.c:269
xwer_t xwds_device_vop_probe(struct xwds_device *dev)
设备基本操作函数:探测设备
Definition device.c:67
xwer_t xwds_device_vop_suspend(struct xwds_device *dev)
设备基本操作函数:暂停设备
Definition device.c:144
xwer_t xwds_obj_put(struct xwds_object *obj)
Definition object.c:152
xwsq_t xwds_obj_get_tik(struct xwds_object *obj)
Definition object.c:45
xwsq_t xwds_obj_get_refcnt(struct xwds_object *obj)
Definition object.c:166
xwer_t xwds_obj_grab(struct xwds_object *obj)
Definition object.c:138
#define __xwds_inline_api
Definition standard.h:35
#define XWOK
No error
Definition errno.h:182
signed long xwer_t
Definition type.h:554
unsigned long xwid_t
Definition type.h:481
unsigned long xwsq_t
Definition type.h:445
xwer_t(* xwobj_gc_f)(struct xwos_object *)
垃圾回收函数指针类型
Definition object.h:42
#define XWOS_UNUSED(x)
Definition standard.h:66
操作系统抽象层:互斥锁
设备(所有设备的基类)
Definition device.h:127
const char * name
Definition device.h:130
const struct xwds_driver * drv
Definition device.h:133
xwid_t id
Definition device.h:131
const struct xwds_virtual_operation * vop
Definition device.h:138
void * data
Definition device.h:134
struct xwds * ds
Definition device.h:137
struct xwds_object obj
Definition device.h:128
const struct xwds_resources * resources
Definition device.h:132
基本驱动函数表(所有设备驱动的基类)
Definition device.h:113
xwer_t(* start)(struct xwds_device *)
Definition device.h:118
xwer_t(* resume)(struct xwds_device *)
Definition device.h:121
xwer_t(* probe)(struct xwds_device *)
Definition device.h:116
const char * name
Definition device.h:115
xwer_t(* suspend)(struct xwds_device *)
Definition device.h:120
xwer_t(* stop)(struct xwds_device *)
Definition device.h:119
xwer_t(* remove)(struct xwds_device *)
Definition device.h:117
设备栈对象
Definition object.h:49
设备栈资源
Definition standard.h:130
基本操作的虚函数表(类似C++的虚函数表)
Definition device.h:99
xwer_t(* suspend)(struct xwds_device *)
Definition device.h:105
xwer_t(* start)(struct xwds_device *)
Definition device.h:102
xwer_t(* stop)(struct xwds_device *)
Definition device.h:103
xwer_t(* remove)(struct xwds_device *)
Definition device.h:101
xwer_t(* probe)(struct xwds_device *)
Definition device.h:100
xwer_t(* resume)(struct xwds_device *)
Definition device.h:106
设备栈
Definition xwds.h:37
XWOS通用库:原子操作
玄武设备栈:对象
玄武设备栈:顶级头文件