aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/fw/cfe/cfe_api.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2007-10-29 10:23:43 -0400
committerRalf Baechle <ralf@linux-mips.org>2008-01-29 05:14:55 -0500
commit417345d8f5bacc291138c99a292a8ca69947530e (patch)
treea8a5e61b0466fd0a914bef82fc266a87eccaa016 /arch/mips/fw/cfe/cfe_api.c
parent8b6c2324bf2b023e26d53052bbcddcbf2f2c97ee (diff)
[MIPS] CFE: Make code remotely resemble Linux code.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/fw/cfe/cfe_api.c')
-rw-r--r--arch/mips/fw/cfe/cfe_api.c184
1 files changed, 57 insertions, 127 deletions
diff --git a/arch/mips/fw/cfe/cfe_api.c b/arch/mips/fw/cfe/cfe_api.c
index a9f69e4e40ac..717db74f7c6e 100644
--- a/arch/mips/fw/cfe/cfe_api.c
+++ b/arch/mips/fw/cfe/cfe_api.c
@@ -16,19 +16,16 @@
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */ 17 */
18 18
19/* ********************************************************************* 19/*
20 * 20 *
21 * Broadcom Common Firmware Environment (CFE) 21 * Broadcom Common Firmware Environment (CFE)
22 * 22 *
23 * Device Function stubs File: cfe_api.c 23 * This module contains device function stubs (small routines to
24 * 24 * call the standard "iocb" interface entry point to CFE).
25 * This module contains device function stubs (small routines to 25 * There should be one routine here per iocb function call.
26 * call the standard "iocb" interface entry point to CFE). 26 *
27 * There should be one routine here per iocb function call. 27 * Authors: Mitch Lichtenberg, Chris Demetriou
28 * 28 */
29 * Authors: Mitch Lichtenberg, Chris Demetriou
30 *
31 ********************************************************************* */
32 29
33#include <asm/fw/cfe/cfe_api.h> 30#include <asm/fw/cfe/cfe_api.h>
34#include "cfe_api_int.h" 31#include "cfe_api_int.h"
@@ -37,12 +34,8 @@
37#define XPTR_FROM_NATIVE(n) ((cfe_xptr_t) (intptr_t) (n)) 34#define XPTR_FROM_NATIVE(n) ((cfe_xptr_t) (intptr_t) (n))
38#define NATIVE_FROM_XPTR(x) ((void *) (intptr_t) (x)) 35#define NATIVE_FROM_XPTR(x) ((void *) (intptr_t) (x))
39 36
40#ifdef CFE_API_IMPL_NAMESPACE 37int cfe_iocb_dispatch(struct cfe_xiocb *xiocb);
41#define cfe_iocb_dispatch(a) __cfe_iocb_dispatch(a)
42#endif
43int cfe_iocb_dispatch(cfe_xiocb_t * xiocb);
44 38
45#if defined(CFE_API_common) || defined(CFE_API_ALL)
46/* 39/*
47 * Declare the dispatch function with args of "intptr_t". 40 * Declare the dispatch function with args of "intptr_t".
48 * This makes sure whatever model we're compiling in 41 * This makes sure whatever model we're compiling in
@@ -53,27 +46,25 @@ int cfe_iocb_dispatch(cfe_xiocb_t * xiocb);
53 */ 46 */
54 47
55static int (*cfe_dispfunc) (intptr_t handle, intptr_t xiocb) = 0; 48static int (*cfe_dispfunc) (intptr_t handle, intptr_t xiocb) = 0;
56static cfe_xuint_t cfe_handle = 0; 49static u64 cfe_handle = 0;
57 50
58int cfe_init(cfe_xuint_t handle, cfe_xuint_t ept) 51int cfe_init(u64 handle, u64 ept)
59{ 52{
60 cfe_dispfunc = NATIVE_FROM_XPTR(ept); 53 cfe_dispfunc = NATIVE_FROM_XPTR(ept);
61 cfe_handle = handle; 54 cfe_handle = handle;
62 return 0; 55 return 0;
63} 56}
64 57
65int cfe_iocb_dispatch(cfe_xiocb_t * xiocb) 58int cfe_iocb_dispatch(struct cfe_xiocb * xiocb)
66{ 59{
67 if (!cfe_dispfunc) 60 if (!cfe_dispfunc)
68 return -1; 61 return -1;
69 return (*cfe_dispfunc) ((intptr_t) cfe_handle, (intptr_t) xiocb); 62 return (*cfe_dispfunc) ((intptr_t) cfe_handle, (intptr_t) xiocb);
70} 63}
71#endif /* CFE_API_common || CFE_API_ALL */
72 64
73#if defined(CFE_API_close) || defined(CFE_API_ALL)
74int cfe_close(int handle) 65int cfe_close(int handle)
75{ 66{
76 cfe_xiocb_t xiocb; 67 struct cfe_xiocb xiocb;
77 68
78 xiocb.xiocb_fcode = CFE_CMD_DEV_CLOSE; 69 xiocb.xiocb_fcode = CFE_CMD_DEV_CLOSE;
79 xiocb.xiocb_status = 0; 70 xiocb.xiocb_status = 0;
@@ -86,18 +77,16 @@ int cfe_close(int handle)
86 return xiocb.xiocb_status; 77 return xiocb.xiocb_status;
87 78
88} 79}
89#endif /* CFE_API_close || CFE_API_ALL */
90 80
91#if defined(CFE_API_cpu_start) || defined(CFE_API_ALL)
92int cfe_cpu_start(int cpu, void (*fn) (void), long sp, long gp, long a1) 81int cfe_cpu_start(int cpu, void (*fn) (void), long sp, long gp, long a1)
93{ 82{
94 cfe_xiocb_t xiocb; 83 struct cfe_xiocb xiocb;
95 84
96 xiocb.xiocb_fcode = CFE_CMD_FW_CPUCTL; 85 xiocb.xiocb_fcode = CFE_CMD_FW_CPUCTL;
97 xiocb.xiocb_status = 0; 86 xiocb.xiocb_status = 0;
98 xiocb.xiocb_handle = 0; 87 xiocb.xiocb_handle = 0;
99 xiocb.xiocb_flags = 0; 88 xiocb.xiocb_flags = 0;
100 xiocb.xiocb_psize = sizeof(xiocb_cpuctl_t); 89 xiocb.xiocb_psize = sizeof(struct xiocb_cpuctl);
101 xiocb.plist.xiocb_cpuctl.cpu_number = cpu; 90 xiocb.plist.xiocb_cpuctl.cpu_number = cpu;
102 xiocb.plist.xiocb_cpuctl.cpu_command = CFE_CPU_CMD_START; 91 xiocb.plist.xiocb_cpuctl.cpu_command = CFE_CPU_CMD_START;
103 xiocb.plist.xiocb_cpuctl.gp_val = gp; 92 xiocb.plist.xiocb_cpuctl.gp_val = gp;
@@ -109,18 +98,16 @@ int cfe_cpu_start(int cpu, void (*fn) (void), long sp, long gp, long a1)
109 98
110 return xiocb.xiocb_status; 99 return xiocb.xiocb_status;
111} 100}
112#endif /* CFE_API_cpu_start || CFE_API_ALL */
113 101
114#if defined(CFE_API_cpu_stop) || defined(CFE_API_ALL)
115int cfe_cpu_stop(int cpu) 102int cfe_cpu_stop(int cpu)
116{ 103{
117 cfe_xiocb_t xiocb; 104 struct cfe_xiocb xiocb;
118 105
119 xiocb.xiocb_fcode = CFE_CMD_FW_CPUCTL; 106 xiocb.xiocb_fcode = CFE_CMD_FW_CPUCTL;
120 xiocb.xiocb_status = 0; 107 xiocb.xiocb_status = 0;
121 xiocb.xiocb_handle = 0; 108 xiocb.xiocb_handle = 0;
122 xiocb.xiocb_flags = 0; 109 xiocb.xiocb_flags = 0;
123 xiocb.xiocb_psize = sizeof(xiocb_cpuctl_t); 110 xiocb.xiocb_psize = sizeof(struct xiocb_cpuctl);
124 xiocb.plist.xiocb_cpuctl.cpu_number = cpu; 111 xiocb.plist.xiocb_cpuctl.cpu_number = cpu;
125 xiocb.plist.xiocb_cpuctl.cpu_command = CFE_CPU_CMD_STOP; 112 xiocb.plist.xiocb_cpuctl.cpu_command = CFE_CPU_CMD_STOP;
126 113
@@ -128,18 +115,16 @@ int cfe_cpu_stop(int cpu)
128 115
129 return xiocb.xiocb_status; 116 return xiocb.xiocb_status;
130} 117}
131#endif /* CFE_API_cpu_stop || CFE_API_ALL */
132 118
133#if defined(CFE_API_enumenv) || defined(CFE_API_ALL)
134int cfe_enumenv(int idx, char *name, int namelen, char *val, int vallen) 119int cfe_enumenv(int idx, char *name, int namelen, char *val, int vallen)
135{ 120{
136 cfe_xiocb_t xiocb; 121 struct cfe_xiocb xiocb;
137 122
138 xiocb.xiocb_fcode = CFE_CMD_ENV_SET; 123 xiocb.xiocb_fcode = CFE_CMD_ENV_SET;
139 xiocb.xiocb_status = 0; 124 xiocb.xiocb_status = 0;
140 xiocb.xiocb_handle = 0; 125 xiocb.xiocb_handle = 0;
141 xiocb.xiocb_flags = 0; 126 xiocb.xiocb_flags = 0;
142 xiocb.xiocb_psize = sizeof(xiocb_envbuf_t); 127 xiocb.xiocb_psize = sizeof(struct xiocb_envbuf);
143 xiocb.plist.xiocb_envbuf.enum_idx = idx; 128 xiocb.plist.xiocb_envbuf.enum_idx = idx;
144 xiocb.plist.xiocb_envbuf.name_ptr = XPTR_FROM_NATIVE(name); 129 xiocb.plist.xiocb_envbuf.name_ptr = XPTR_FROM_NATIVE(name);
145 xiocb.plist.xiocb_envbuf.name_length = namelen; 130 xiocb.plist.xiocb_envbuf.name_length = namelen;
@@ -150,20 +135,17 @@ int cfe_enumenv(int idx, char *name, int namelen, char *val, int vallen)
150 135
151 return xiocb.xiocb_status; 136 return xiocb.xiocb_status;
152} 137}
153#endif /* CFE_API_enumenv || CFE_API_ALL */
154 138
155#if defined(CFE_API_enummem) || defined(CFE_API_ALL)
156int 139int
157cfe_enummem(int idx, int flags, cfe_xuint_t * start, cfe_xuint_t * length, 140cfe_enummem(int idx, int flags, u64 *start, u64 *length, u64 *type)
158 cfe_xuint_t * type)
159{ 141{
160 cfe_xiocb_t xiocb; 142 struct cfe_xiocb xiocb;
161 143
162 xiocb.xiocb_fcode = CFE_CMD_FW_MEMENUM; 144 xiocb.xiocb_fcode = CFE_CMD_FW_MEMENUM;
163 xiocb.xiocb_status = 0; 145 xiocb.xiocb_status = 0;
164 xiocb.xiocb_handle = 0; 146 xiocb.xiocb_handle = 0;
165 xiocb.xiocb_flags = flags; 147 xiocb.xiocb_flags = flags;
166 xiocb.xiocb_psize = sizeof(xiocb_meminfo_t); 148 xiocb.xiocb_psize = sizeof(struct xiocb_meminfo);
167 xiocb.plist.xiocb_meminfo.mi_idx = idx; 149 xiocb.plist.xiocb_meminfo.mi_idx = idx;
168 150
169 cfe_iocb_dispatch(&xiocb); 151 cfe_iocb_dispatch(&xiocb);
@@ -177,30 +159,26 @@ cfe_enummem(int idx, int flags, cfe_xuint_t * start, cfe_xuint_t * length,
177 159
178 return 0; 160 return 0;
179} 161}
180#endif /* CFE_API_enummem || CFE_API_ALL */
181 162
182#if defined(CFE_API_exit) || defined(CFE_API_ALL)
183int cfe_exit(int warm, int status) 163int cfe_exit(int warm, int status)
184{ 164{
185 cfe_xiocb_t xiocb; 165 struct cfe_xiocb xiocb;
186 166
187 xiocb.xiocb_fcode = CFE_CMD_FW_RESTART; 167 xiocb.xiocb_fcode = CFE_CMD_FW_RESTART;
188 xiocb.xiocb_status = 0; 168 xiocb.xiocb_status = 0;
189 xiocb.xiocb_handle = 0; 169 xiocb.xiocb_handle = 0;
190 xiocb.xiocb_flags = warm ? CFE_FLG_WARMSTART : 0; 170 xiocb.xiocb_flags = warm ? CFE_FLG_WARMSTART : 0;
191 xiocb.xiocb_psize = sizeof(xiocb_exitstat_t); 171 xiocb.xiocb_psize = sizeof(struct xiocb_exitstat);
192 xiocb.plist.xiocb_exitstat.status = status; 172 xiocb.plist.xiocb_exitstat.status = status;
193 173
194 cfe_iocb_dispatch(&xiocb); 174 cfe_iocb_dispatch(&xiocb);
195 175
196 return xiocb.xiocb_status; 176 return xiocb.xiocb_status;
197} 177}
198#endif /* CFE_API_exit || CFE_API_ALL */
199 178
200#if defined(CFE_API_flushcache) || defined(CFE_API_ALL)
201int cfe_flushcache(int flg) 179int cfe_flushcache(int flg)
202{ 180{
203 cfe_xiocb_t xiocb; 181 struct cfe_xiocb xiocb;
204 182
205 xiocb.xiocb_fcode = CFE_CMD_FW_FLUSHCACHE; 183 xiocb.xiocb_fcode = CFE_CMD_FW_FLUSHCACHE;
206 xiocb.xiocb_status = 0; 184 xiocb.xiocb_status = 0;
@@ -212,34 +190,30 @@ int cfe_flushcache(int flg)
212 190
213 return xiocb.xiocb_status; 191 return xiocb.xiocb_status;
214} 192}
215#endif /* CFE_API_flushcache || CFE_API_ALL */
216 193
217#if defined(CFE_API_getdevinfo) || defined(CFE_API_ALL)
218int cfe_getdevinfo(char *name) 194int cfe_getdevinfo(char *name)
219{ 195{
220 cfe_xiocb_t xiocb; 196 struct cfe_xiocb xiocb;
221 197
222 xiocb.xiocb_fcode = CFE_CMD_DEV_GETINFO; 198 xiocb.xiocb_fcode = CFE_CMD_DEV_GETINFO;
223 xiocb.xiocb_status = 0; 199 xiocb.xiocb_status = 0;
224 xiocb.xiocb_handle = 0; 200 xiocb.xiocb_handle = 0;
225 xiocb.xiocb_flags = 0; 201 xiocb.xiocb_flags = 0;
226 xiocb.xiocb_psize = sizeof(xiocb_buffer_t); 202 xiocb.xiocb_psize = sizeof(struct xiocb_buffer);
227 xiocb.plist.xiocb_buffer.buf_offset = 0; 203 xiocb.plist.xiocb_buffer.buf_offset = 0;
228 xiocb.plist.xiocb_buffer.buf_ptr = XPTR_FROM_NATIVE(name); 204 xiocb.plist.xiocb_buffer.buf_ptr = XPTR_FROM_NATIVE(name);
229 xiocb.plist.xiocb_buffer.buf_length = cfe_strlen(name); 205 xiocb.plist.xiocb_buffer.buf_length = strlen(name);
230 206
231 cfe_iocb_dispatch(&xiocb); 207 cfe_iocb_dispatch(&xiocb);
232 208
233 if (xiocb.xiocb_status < 0) 209 if (xiocb.xiocb_status < 0)
234 return xiocb.xiocb_status; 210 return xiocb.xiocb_status;
235 return xiocb.plist.xiocb_buffer.buf_devflags; 211 return xiocb.plist.xiocb_buffer.buf_ioctlcmd;
236} 212}
237#endif /* CFE_API_getdevinfo || CFE_API_ALL */
238 213
239#if defined(CFE_API_getenv) || defined(CFE_API_ALL)
240int cfe_getenv(char *name, char *dest, int destlen) 214int cfe_getenv(char *name, char *dest, int destlen)
241{ 215{
242 cfe_xiocb_t xiocb; 216 struct cfe_xiocb xiocb;
243 217
244 *dest = 0; 218 *dest = 0;
245 219
@@ -247,10 +221,10 @@ int cfe_getenv(char *name, char *dest, int destlen)
247 xiocb.xiocb_status = 0; 221 xiocb.xiocb_status = 0;
248 xiocb.xiocb_handle = 0; 222 xiocb.xiocb_handle = 0;
249 xiocb.xiocb_flags = 0; 223 xiocb.xiocb_flags = 0;
250 xiocb.xiocb_psize = sizeof(xiocb_envbuf_t); 224 xiocb.xiocb_psize = sizeof(struct xiocb_envbuf);
251 xiocb.plist.xiocb_envbuf.enum_idx = 0; 225 xiocb.plist.xiocb_envbuf.enum_idx = 0;
252 xiocb.plist.xiocb_envbuf.name_ptr = XPTR_FROM_NATIVE(name); 226 xiocb.plist.xiocb_envbuf.name_ptr = XPTR_FROM_NATIVE(name);
253 xiocb.plist.xiocb_envbuf.name_length = cfe_strlen(name); 227 xiocb.plist.xiocb_envbuf.name_length = strlen(name);
254 xiocb.plist.xiocb_envbuf.val_ptr = XPTR_FROM_NATIVE(dest); 228 xiocb.plist.xiocb_envbuf.val_ptr = XPTR_FROM_NATIVE(dest);
255 xiocb.plist.xiocb_envbuf.val_length = destlen; 229 xiocb.plist.xiocb_envbuf.val_length = destlen;
256 230
@@ -258,18 +232,16 @@ int cfe_getenv(char *name, char *dest, int destlen)
258 232
259 return xiocb.xiocb_status; 233 return xiocb.xiocb_status;
260} 234}
261#endif /* CFE_API_getenv || CFE_API_ALL */
262 235
263#if defined(CFE_API_getfwinfo) || defined(CFE_API_ALL)
264int cfe_getfwinfo(cfe_fwinfo_t * info) 236int cfe_getfwinfo(cfe_fwinfo_t * info)
265{ 237{
266 cfe_xiocb_t xiocb; 238 struct cfe_xiocb xiocb;
267 239
268 xiocb.xiocb_fcode = CFE_CMD_FW_GETINFO; 240 xiocb.xiocb_fcode = CFE_CMD_FW_GETINFO;
269 xiocb.xiocb_status = 0; 241 xiocb.xiocb_status = 0;
270 xiocb.xiocb_handle = 0; 242 xiocb.xiocb_handle = 0;
271 xiocb.xiocb_flags = 0; 243 xiocb.xiocb_flags = 0;
272 xiocb.xiocb_psize = sizeof(xiocb_fwinfo_t); 244 xiocb.xiocb_psize = sizeof(struct xiocb_fwinfo);
273 245
274 cfe_iocb_dispatch(&xiocb); 246 cfe_iocb_dispatch(&xiocb);
275 247
@@ -292,12 +264,10 @@ int cfe_getfwinfo(cfe_fwinfo_t * info)
292 264
293 return 0; 265 return 0;
294} 266}
295#endif /* CFE_API_getfwinfo || CFE_API_ALL */
296 267
297#if defined(CFE_API_getstdhandle) || defined(CFE_API_ALL)
298int cfe_getstdhandle(int flg) 268int cfe_getstdhandle(int flg)
299{ 269{
300 cfe_xiocb_t xiocb; 270 struct cfe_xiocb xiocb;
301 271
302 xiocb.xiocb_fcode = CFE_CMD_DEV_GETHANDLE; 272 xiocb.xiocb_fcode = CFE_CMD_DEV_GETHANDLE;
303 xiocb.xiocb_status = 0; 273 xiocb.xiocb_status = 0;
@@ -311,23 +281,17 @@ int cfe_getstdhandle(int flg)
311 return xiocb.xiocb_status; 281 return xiocb.xiocb_status;
312 return xiocb.xiocb_handle; 282 return xiocb.xiocb_handle;
313} 283}
314#endif /* CFE_API_getstdhandle || CFE_API_ALL */
315 284
316#if defined(CFE_API_getticks) || defined(CFE_API_ALL)
317int64_t 285int64_t
318#ifdef CFE_API_IMPL_NAMESPACE
319__cfe_getticks(void)
320#else
321cfe_getticks(void) 286cfe_getticks(void)
322#endif
323{ 287{
324 cfe_xiocb_t xiocb; 288 struct cfe_xiocb xiocb;
325 289
326 xiocb.xiocb_fcode = CFE_CMD_FW_GETTIME; 290 xiocb.xiocb_fcode = CFE_CMD_FW_GETTIME;
327 xiocb.xiocb_status = 0; 291 xiocb.xiocb_status = 0;
328 xiocb.xiocb_handle = 0; 292 xiocb.xiocb_handle = 0;
329 xiocb.xiocb_flags = 0; 293 xiocb.xiocb_flags = 0;
330 xiocb.xiocb_psize = sizeof(xiocb_time_t); 294 xiocb.xiocb_psize = sizeof(struct xiocb_time);
331 xiocb.plist.xiocb_time.ticks = 0; 295 xiocb.plist.xiocb_time.ticks = 0;
332 296
333 cfe_iocb_dispatch(&xiocb); 297 cfe_iocb_dispatch(&xiocb);
@@ -335,18 +299,16 @@ cfe_getticks(void)
335 return xiocb.plist.xiocb_time.ticks; 299 return xiocb.plist.xiocb_time.ticks;
336 300
337} 301}
338#endif /* CFE_API_getticks || CFE_API_ALL */
339 302
340#if defined(CFE_API_inpstat) || defined(CFE_API_ALL)
341int cfe_inpstat(int handle) 303int cfe_inpstat(int handle)
342{ 304{
343 cfe_xiocb_t xiocb; 305 struct cfe_xiocb xiocb;
344 306
345 xiocb.xiocb_fcode = CFE_CMD_DEV_INPSTAT; 307 xiocb.xiocb_fcode = CFE_CMD_DEV_INPSTAT;
346 xiocb.xiocb_status = 0; 308 xiocb.xiocb_status = 0;
347 xiocb.xiocb_handle = handle; 309 xiocb.xiocb_handle = handle;
348 xiocb.xiocb_flags = 0; 310 xiocb.xiocb_flags = 0;
349 xiocb.xiocb_psize = sizeof(xiocb_inpstat_t); 311 xiocb.xiocb_psize = sizeof(struct xiocb_inpstat);
350 xiocb.plist.xiocb_inpstat.inp_status = 0; 312 xiocb.plist.xiocb_inpstat.inp_status = 0;
351 313
352 cfe_iocb_dispatch(&xiocb); 314 cfe_iocb_dispatch(&xiocb);
@@ -355,20 +317,18 @@ int cfe_inpstat(int handle)
355 return xiocb.xiocb_status; 317 return xiocb.xiocb_status;
356 return xiocb.plist.xiocb_inpstat.inp_status; 318 return xiocb.plist.xiocb_inpstat.inp_status;
357} 319}
358#endif /* CFE_API_inpstat || CFE_API_ALL */
359 320
360#if defined(CFE_API_ioctl) || defined(CFE_API_ALL)
361int 321int
362cfe_ioctl(int handle, unsigned int ioctlnum, unsigned char *buffer, 322cfe_ioctl(int handle, unsigned int ioctlnum, unsigned char *buffer,
363 int length, int *retlen, cfe_xuint_t offset) 323 int length, int *retlen, u64 offset)
364{ 324{
365 cfe_xiocb_t xiocb; 325 struct cfe_xiocb xiocb;
366 326
367 xiocb.xiocb_fcode = CFE_CMD_DEV_IOCTL; 327 xiocb.xiocb_fcode = CFE_CMD_DEV_IOCTL;
368 xiocb.xiocb_status = 0; 328 xiocb.xiocb_status = 0;
369 xiocb.xiocb_handle = handle; 329 xiocb.xiocb_handle = handle;
370 xiocb.xiocb_flags = 0; 330 xiocb.xiocb_flags = 0;
371 xiocb.xiocb_psize = sizeof(xiocb_buffer_t); 331 xiocb.xiocb_psize = sizeof(struct xiocb_buffer);
372 xiocb.plist.xiocb_buffer.buf_offset = offset; 332 xiocb.plist.xiocb_buffer.buf_offset = offset;
373 xiocb.plist.xiocb_buffer.buf_ioctlcmd = ioctlnum; 333 xiocb.plist.xiocb_buffer.buf_ioctlcmd = ioctlnum;
374 xiocb.plist.xiocb_buffer.buf_ptr = XPTR_FROM_NATIVE(buffer); 334 xiocb.plist.xiocb_buffer.buf_ptr = XPTR_FROM_NATIVE(buffer);
@@ -380,21 +340,19 @@ cfe_ioctl(int handle, unsigned int ioctlnum, unsigned char *buffer,
380 *retlen = xiocb.plist.xiocb_buffer.buf_retlen; 340 *retlen = xiocb.plist.xiocb_buffer.buf_retlen;
381 return xiocb.xiocb_status; 341 return xiocb.xiocb_status;
382} 342}
383#endif /* CFE_API_ioctl || CFE_API_ALL */
384 343
385#if defined(CFE_API_open) || defined(CFE_API_ALL)
386int cfe_open(char *name) 344int cfe_open(char *name)
387{ 345{
388 cfe_xiocb_t xiocb; 346 struct cfe_xiocb xiocb;
389 347
390 xiocb.xiocb_fcode = CFE_CMD_DEV_OPEN; 348 xiocb.xiocb_fcode = CFE_CMD_DEV_OPEN;
391 xiocb.xiocb_status = 0; 349 xiocb.xiocb_status = 0;
392 xiocb.xiocb_handle = 0; 350 xiocb.xiocb_handle = 0;
393 xiocb.xiocb_flags = 0; 351 xiocb.xiocb_flags = 0;
394 xiocb.xiocb_psize = sizeof(xiocb_buffer_t); 352 xiocb.xiocb_psize = sizeof(struct xiocb_buffer);
395 xiocb.plist.xiocb_buffer.buf_offset = 0; 353 xiocb.plist.xiocb_buffer.buf_offset = 0;
396 xiocb.plist.xiocb_buffer.buf_ptr = XPTR_FROM_NATIVE(name); 354 xiocb.plist.xiocb_buffer.buf_ptr = XPTR_FROM_NATIVE(name);
397 xiocb.plist.xiocb_buffer.buf_length = cfe_strlen(name); 355 xiocb.plist.xiocb_buffer.buf_length = strlen(name);
398 356
399 cfe_iocb_dispatch(&xiocb); 357 cfe_iocb_dispatch(&xiocb);
400 358
@@ -402,27 +360,21 @@ int cfe_open(char *name)
402 return xiocb.xiocb_status; 360 return xiocb.xiocb_status;
403 return xiocb.xiocb_handle; 361 return xiocb.xiocb_handle;
404} 362}
405#endif /* CFE_API_open || CFE_API_ALL */
406 363
407#if defined(CFE_API_read) || defined(CFE_API_ALL)
408int cfe_read(int handle, unsigned char *buffer, int length) 364int cfe_read(int handle, unsigned char *buffer, int length)
409{ 365{
410 return cfe_readblk(handle, 0, buffer, length); 366 return cfe_readblk(handle, 0, buffer, length);
411} 367}
412#endif /* CFE_API_read || CFE_API_ALL */
413 368
414#if defined(CFE_API_readblk) || defined(CFE_API_ALL) 369int cfe_readblk(int handle, s64 offset, unsigned char *buffer, int length)
415int
416cfe_readblk(int handle, cfe_xint_t offset, unsigned char *buffer,
417 int length)
418{ 370{
419 cfe_xiocb_t xiocb; 371 struct cfe_xiocb xiocb;
420 372
421 xiocb.xiocb_fcode = CFE_CMD_DEV_READ; 373 xiocb.xiocb_fcode = CFE_CMD_DEV_READ;
422 xiocb.xiocb_status = 0; 374 xiocb.xiocb_status = 0;
423 xiocb.xiocb_handle = handle; 375 xiocb.xiocb_handle = handle;
424 xiocb.xiocb_flags = 0; 376 xiocb.xiocb_flags = 0;
425 xiocb.xiocb_psize = sizeof(xiocb_buffer_t); 377 xiocb.xiocb_psize = sizeof(struct xiocb_buffer);
426 xiocb.plist.xiocb_buffer.buf_offset = offset; 378 xiocb.plist.xiocb_buffer.buf_offset = offset;
427 xiocb.plist.xiocb_buffer.buf_ptr = XPTR_FROM_NATIVE(buffer); 379 xiocb.plist.xiocb_buffer.buf_ptr = XPTR_FROM_NATIVE(buffer);
428 xiocb.plist.xiocb_buffer.buf_length = length; 380 xiocb.plist.xiocb_buffer.buf_length = length;
@@ -433,62 +385,41 @@ cfe_readblk(int handle, cfe_xint_t offset, unsigned char *buffer,
433 return xiocb.xiocb_status; 385 return xiocb.xiocb_status;
434 return xiocb.plist.xiocb_buffer.buf_retlen; 386 return xiocb.plist.xiocb_buffer.buf_retlen;
435} 387}
436#endif /* CFE_API_readblk || CFE_API_ALL */
437 388
438#if defined(CFE_API_setenv) || defined(CFE_API_ALL)
439int cfe_setenv(char *name, char *val) 389int cfe_setenv(char *name, char *val)
440{ 390{
441 cfe_xiocb_t xiocb; 391 struct cfe_xiocb xiocb;
442 392
443 xiocb.xiocb_fcode = CFE_CMD_ENV_SET; 393 xiocb.xiocb_fcode = CFE_CMD_ENV_SET;
444 xiocb.xiocb_status = 0; 394 xiocb.xiocb_status = 0;
445 xiocb.xiocb_handle = 0; 395 xiocb.xiocb_handle = 0;
446 xiocb.xiocb_flags = 0; 396 xiocb.xiocb_flags = 0;
447 xiocb.xiocb_psize = sizeof(xiocb_envbuf_t); 397 xiocb.xiocb_psize = sizeof(struct xiocb_envbuf);
448 xiocb.plist.xiocb_envbuf.enum_idx = 0; 398 xiocb.plist.xiocb_envbuf.enum_idx = 0;
449 xiocb.plist.xiocb_envbuf.name_ptr = XPTR_FROM_NATIVE(name); 399 xiocb.plist.xiocb_envbuf.name_ptr = XPTR_FROM_NATIVE(name);
450 xiocb.plist.xiocb_envbuf.name_length = cfe_strlen(name); 400 xiocb.plist.xiocb_envbuf.name_length = strlen(name);
451 xiocb.plist.xiocb_envbuf.val_ptr = XPTR_FROM_NATIVE(val); 401 xiocb.plist.xiocb_envbuf.val_ptr = XPTR_FROM_NATIVE(val);
452 xiocb.plist.xiocb_envbuf.val_length = cfe_strlen(val); 402 xiocb.plist.xiocb_envbuf.val_length = strlen(val);
453 403
454 cfe_iocb_dispatch(&xiocb); 404 cfe_iocb_dispatch(&xiocb);
455 405
456 return xiocb.xiocb_status; 406 return xiocb.xiocb_status;
457} 407}
458#endif /* CFE_API_setenv || CFE_API_ALL */
459
460#if (defined(CFE_API_strlen) || defined(CFE_API_ALL)) \
461 && !defined(CFE_API_STRLEN_CUSTOM)
462int cfe_strlen(char *name)
463{
464 int count = 0;
465
466 while (*name++)
467 count++;
468 408
469 return count;
470}
471#endif /* CFE_API_strlen || CFE_API_ALL */
472
473#if defined(CFE_API_write) || defined(CFE_API_ALL)
474int cfe_write(int handle, unsigned char *buffer, int length) 409int cfe_write(int handle, unsigned char *buffer, int length)
475{ 410{
476 return cfe_writeblk(handle, 0, buffer, length); 411 return cfe_writeblk(handle, 0, buffer, length);
477} 412}
478#endif /* CFE_API_write || CFE_API_ALL */
479 413
480#if defined(CFE_API_writeblk) || defined(CFE_API_ALL) 414int cfe_writeblk(int handle, s64 offset, unsigned char *buffer, int length)
481int
482cfe_writeblk(int handle, cfe_xint_t offset, unsigned char *buffer,
483 int length)
484{ 415{
485 cfe_xiocb_t xiocb; 416 struct cfe_xiocb xiocb;
486 417
487 xiocb.xiocb_fcode = CFE_CMD_DEV_WRITE; 418 xiocb.xiocb_fcode = CFE_CMD_DEV_WRITE;
488 xiocb.xiocb_status = 0; 419 xiocb.xiocb_status = 0;
489 xiocb.xiocb_handle = handle; 420 xiocb.xiocb_handle = handle;
490 xiocb.xiocb_flags = 0; 421 xiocb.xiocb_flags = 0;
491 xiocb.xiocb_psize = sizeof(xiocb_buffer_t); 422 xiocb.xiocb_psize = sizeof(struct xiocb_buffer);
492 xiocb.plist.xiocb_buffer.buf_offset = offset; 423 xiocb.plist.xiocb_buffer.buf_offset = offset;
493 xiocb.plist.xiocb_buffer.buf_ptr = XPTR_FROM_NATIVE(buffer); 424 xiocb.plist.xiocb_buffer.buf_ptr = XPTR_FROM_NATIVE(buffer);
494 xiocb.plist.xiocb_buffer.buf_length = length; 425 xiocb.plist.xiocb_buffer.buf_length = length;
@@ -499,4 +430,3 @@ cfe_writeblk(int handle, cfe_xint_t offset, unsigned char *buffer,
499 return xiocb.xiocb_status; 430 return xiocb.xiocb_status;
500 return xiocb.plist.xiocb_buffer.buf_retlen; 431 return xiocb.plist.xiocb_buffer.buf_retlen;
501} 432}
502#endif /* CFE_API_writeblk || CFE_API_ALL */