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
106
107/******** ******** base virtual operations ******** ********/
112static __xwds_vop
114{
115 xwer_t rc;
116
117 XWDS_VALIDATE(soc->xwccfg, "nullptr", -EFAULT);
118
119 rc = xwds_device_vop_probe(&soc->dev);
120 return rc;
121}
122
127static __xwds_vop
129{
130 xwer_t rc;
131
132 rc = xwds_device_vop_remove(&soc->dev);
133 return rc;
134}
135
140static __xwds_vop
142{
143 xwer_t rc;
144
145 rc = xwds_device_vop_start(&soc->dev);
146 return rc;
147}
148
153static __xwds_vop
155{
156 xwer_t rc;
157
158 rc = xwds_device_vop_stop(&soc->dev);
159 return rc;
160}
161
162#if (defined(XWCDCFG_ds_PM)) && (1 == XWCDCFG_ds_PM)
163/******** ******** pm ******** ********/
168static __xwds_vop
170{
171 xwer_t rc;
172
173 rc = xwds_device_vop_suspend(&soc->dev);
174 return rc;
175}
176
181static __xwds_vop
183{
184 xwer_t rc;
185
186 rc = xwds_device_vop_resume(&soc->dev);
187 return rc;
188}
189#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_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:154
static xwer_t xwds_soc_vop_probe(struct xwds_soc *soc)
XWDS VOP:探测SOC
Definition chip.c:113
static xwer_t xwds_soc_vop_start(struct xwds_soc *soc)
XWDS VOP:启动SOC
Definition chip.c:141
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:182
static xwer_t xwds_soc_vop_remove(struct xwds_soc *soc)
XWDS VOP:移除SOC
Definition chip.c:128
static xwer_t xwds_soc_vop_suspend(struct xwds_soc *soc)
XWDS VOP:暂停SOC
Definition chip.c:169
玄武设备栈: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
SOC设备
Definition chip.h:161
struct xwds_device dev
Definition chip.h:162
const void * xwccfg
Definition chip.h:165
基本操作的虚函数表(类似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
玄武设备栈:顶级头文件