XWOS API  4.0
XWOS C/C++ API参考手册
载入中...
搜索中...
未找到
chip.c
浏览该文件的文档.
1
21#include <xwcd/ds/standard.h>
22#include <string.h>
23#include <xwcd/ds/soc/chip.h>
24
25static __xwds_vop
27
28static __xwds_vop
30
31static __xwds_vop
33
34static __xwds_vop
36
37#if defined(XWCDCFG_ds_PM) && (1 == XWCDCFG_ds_PM)
38static __xwds_vop
40
41static __xwds_vop
43#endif
44
46 .probe = (void *)xwds_soc_vop_probe,
47 .remove = (void *)xwds_soc_vop_remove,
48 .start = (void *)xwds_soc_vop_start,
49 .stop = (void *)xwds_soc_vop_stop,
50#if defined(XWCDCFG_ds_PM) && (1 == XWCDCFG_ds_PM)
51 .suspend = (void *)xwds_soc_vop_suspend,
52 .resume = (void *)xwds_soc_vop_resume,
53#endif
54};
55
56/******** ******** ******** constructor & destructor ******** ******** ********/
58void xwds_soc_construct(struct xwds_soc * soc)
59{
61 soc->dev.vop = &xwds_soc_vop;
62}
63
65void xwds_soc_destruct(struct xwds_soc * soc)
66{
68}
69
72{
73 return xwds_device_grab(&soc->dev);
74}
75
78{
79 return xwds_device_put(&soc->dev);
80}
81
84{
85 const struct xwds_soc_driver * drv;
86 xwer_t rc;
87
88 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
89 XWDS_VALIDATE(reason, "nullptr", -EFAULT);
90
91 rc = xwds_soc_grab(soc);
92 if (rc < 0) {
93 goto err_soc_grab;
94 }
95 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
96 if ((drv) && (drv->get_reset_reason)) {
97 rc = drv->get_reset_reason(soc, reason);
98 } else {
99 rc = -ENOSYS;
100 }
101 xwds_soc_put(soc);
102err_soc_grab:
103 return rc;
104}
105
108{
109 const struct xwds_soc_driver * drv;
110 xwer_t rc;
111
112 XWDS_VALIDATE(soc, "nullptr", -EFAULT);
113 XWDS_VALIDATE(source, "nullptr", -EFAULT);
114
115 rc = xwds_soc_grab(soc);
116 if (rc < 0) {
117 goto err_soc_grab;
118 }
119 drv = xwds_cast(const struct xwds_soc_driver *, soc->dev.drv);
120 if ((drv) && (drv->get_wkup_source)) {
121 rc = drv->get_wkup_source(soc, source);
122 } else {
123 rc = -ENOSYS;
124 }
125 xwds_soc_put(soc);
126err_soc_grab:
127 return rc;
128}
129
130/******** ******** base virtual operations ******** ********/
135static __xwds_vop
137{
138 xwer_t rc;
139
140 XWDS_VALIDATE(soc->xwccfg, "nullptr", -EFAULT);
141
142 rc = xwds_device_vop_probe(&soc->dev);
143 return rc;
144}
145
150static __xwds_vop
152{
153 xwer_t rc;
154
155 rc = xwds_device_vop_remove(&soc->dev);
156 return rc;
157}
158
163static __xwds_vop
165{
166 xwer_t rc;
167
168 rc = xwds_device_vop_start(&soc->dev);
169 return rc;
170}
171
176static __xwds_vop
178{
179 xwer_t rc;
180
181 rc = xwds_device_vop_stop(&soc->dev);
182 return rc;
183}
184
185#if (defined(XWCDCFG_ds_PM)) && (1 == XWCDCFG_ds_PM)
186/******** ******** pm ******** ********/
191static __xwds_vop
193{
194 xwer_t rc;
195
196 rc = xwds_device_vop_suspend(&soc->dev);
197 return rc;
198}
199
204static __xwds_vop
206{
207 xwer_t rc;
208
209 rc = xwds_device_vop_resume(&soc->dev);
210 return rc;
211}
212#endif
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
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
static xwer_t xwds_device_put(struct xwds_device *dev)
XWDS API:减少对象的引用计数
Definition device.h:281
xwer_t xwds_device_vop_stop(struct xwds_device *dev)
设备基本操作函数:停止设备
Definition device.c:124
xwer_t xwds_device_vop_remove(struct xwds_device *dev)
设备基本操作函数:删除设备
Definition device.c:86
xwer_t xwds_device_vop_resume(struct xwds_device *dev)
设备基本操作函数:继续设备
Definition device.c:163
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
void xwds_soc_destruct(struct xwds_soc *soc)
XWDS API:SOC对象的析构函数
Definition chip.c:65
xwer_t xwds_soc_get_wkup_source(struct xwds_soc *soc, xwu64_t *source)
XWDS API:获取唤醒源
Definition chip.c:107
xwer_t xwds_soc_grab(struct xwds_soc *soc)
XWDS API:增加对象的引用计数
Definition chip.c:71
xwer_t xwds_soc_put(struct xwds_soc *soc)
XWDS API:减少对象的引用计数
Definition chip.c:77
void xwds_soc_construct(struct xwds_soc *soc)
XWDS API:SOC构造函数
Definition chip.c:58
xwer_t xwds_soc_get_reset_reason(struct xwds_soc *soc, xwu64_t *reason)
XWDS API:获取复位原因
Definition chip.c:83
#define xwds_cast(type, dev)
Definition standard.h:40
#define __xwds_vop
Definition standard.h:36
#define __xwds_api
Definition standard.h:33
#define XWDS_VALIDATE(exp, errstr,...)
Definition standard.h:51
#define __xwds_rodata
Definition standard.h:38
#define EFAULT
Bad address
Definition errno.h:44
#define ENOSYS
Function not implemented
Definition errno.h:110
signed long xwer_t
Definition type.h:554
uint64_t xwu64_t
Definition type.h:303
static xwer_t xwds_soc_vop_stop(struct xwds_soc *soc)
XWDS VOP:停止SOC
Definition chip.c:177
static xwer_t xwds_soc_vop_probe(struct xwds_soc *soc)
XWDS VOP:探测SOC
Definition chip.c:136
static xwer_t xwds_soc_vop_start(struct xwds_soc *soc)
XWDS VOP:启动SOC
Definition chip.c:164
const struct xwds_virtual_operation xwds_soc_vop
Definition chip.c:45
static xwer_t xwds_soc_vop_resume(struct xwds_soc *soc)
XWDS VOP:继续SOC
Definition chip.c:205
static xwer_t xwds_soc_vop_remove(struct xwds_soc *soc)
XWDS VOP:移除SOC
Definition chip.c:151
static xwer_t xwds_soc_vop_suspend(struct xwds_soc *soc)
XWDS VOP:暂停SOC
Definition chip.c:192
玄武设备栈:SOC
const struct xwds_driver * drv
Definition device.h:133
const struct xwds_virtual_operation * vop
Definition device.h:138
BSP中需要提供的SOC设备驱动函数表
Definition chip.h:51
xwer_t(* get_reset_reason)(struct xwds_soc *, xwu64_t *)
Definition chip.h:53
xwer_t(* get_wkup_source)(struct xwds_soc *, xwu64_t *)
Definition chip.h:55
SOC设备
Definition chip.h:167
struct xwds_device dev
Definition chip.h:168
const void * xwccfg
Definition chip.h:171
基本操作的虚函数表(类似C++的虚函数表)
Definition device.h:99
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
玄武设备栈:顶级头文件