1 /* --COPYRIGHT--,BSD
2 * Copyright (c) $(CPYYEAR), Texas Instruments Incorporated
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 * --/COPYRIGHT--*/
32 /*
33 * ======== sio2.h ========
34 * Stream I/O Manager
35 */
37 #ifndef SIO2_
38 #define SIO2_
40 #include <stddef.h>
42 #include <xdc/runtime/IHeap.h>
44 #include <ti/sysbios/knl/Queue.h>
46 #include "dev2.h"
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
52 #define SIO2_OK 0 /* To replace SYS_OK */
53 #define SIO2_ENOMEM (-1) /* To replace SYS_EALLOC */
54 #define SIO2_EINVAL (-2) /* To replace SYS_EINVAL */
55 #define SIO2_ENODEV (-3) /* To replace SYS_ENODEV */
56 #define SIO2_EBADIO (-4) /* Replace SYS_EBADIO */
57 #define SIO2_ETIMEOUT (-5) /* Replace SYS_ETIMEOUT */
58 #define SIO2_EALLOC (-6) /* Replace SYS_EALLOC */
59 #define SIO2_EBUSY (-7) /* Replace SYS_EBUSY */
60 #define SIO2_EMODE (-8) /* Replace SYS_EMODE */
62 #define SIO2_INPUT DEV2_INPUT /* input stream */
63 #define SIO2_OUTPUT DEV2_OUTPUT /* output stream */
65 #define SIO2_STANDARD 0
66 #define SIO2_ISSUERECLAIM 1
68 typedef DEV2_Callback SIO2_Callback; /* for callback mode */
70 typedef struct SIO2_Attrs { /* stream attributes */
71 Int nbufs; /* number of buffers */
72 xdc_runtime_IHeap_Handle bufSeg; /* buffer segment */
73 size_t align; /* buffer alignment */
74 Bool flush; /* TRUE -> don't block in DEV2_idle() */
75 Uns model; /* SIO_STANDARD, SIO_ISSUERECLAIM */
76 Uns timeout; /* passed to all calls to DEV2_reclaim() */
77 SIO2_Callback *callback; /* initializes callback in DEV2_Obj */
78 } SIO2_Attrs;
80 typedef struct SIO2_Obj { /* stream object */
81 DEV2_Obj dobj; /* device object */
82 Bool flush; /* flush */
83 Queue_Struct framelist; /* start of frame list */
84 DEV2_Frame *standardFrame; /* frame for use in SIO_STANDARD model only */
85 Uns model; /* SIO_STANDARD or SIO_ISSUERECLAIM */
86 DEV2_Fxns *pfxns; /* pointer to DEV2_Fxns for static stream init */
87 } SIO2_Obj, *SIO2_Handle;
89 extern __FAR__ SIO2_Attrs SIO2_ATTRS; /* default attributes */
91 extern Int _SIO2_idle(SIO2_Handle stream, Bool flush);
92 #define SIO2_idle(stream) _SIO2_idle(stream, 0)
93 #define SIO2_flush(stream) _SIO2_idle(stream, 1)
95 #define SIO2_ctrl(stream, cmd, arg) DEV2_ctrl((DEV2_Handle)stream, cmd, arg)
96 #define SIO2_ready(stream) DEV2_ready((DEV2_Handle)stream, NULL)
98 #define SIO2_segid(stream) ((stream)->dobj.segid)
99 #define SIO2_bufsize(stream) ((stream)->dobj.bufsize)
100 #define SIO2_nbufs(stream) ((stream)->dobj.nbufs)
102 extern SIO2_Handle SIO2_create(String name, Int mode, size_t size, SIO2_Attrs *attrs);
103 extern Int SIO2_delete(SIO2_Handle stream);
104 extern Int SIO2_get(SIO2_Handle stream, Ptr *buf);
105 extern Int SIO2_staticbuf(SIO2_Handle stream, Ptr *buf);
106 extern Int SIO2_put(SIO2_Handle stream, Ptr *buf, size_t nbytes);
107 extern Uns SIO2_select(SIO2_Handle streamtab[], Int n, Uns timeout);
108 extern Int SIO2_issue(SIO2_Handle stream, Ptr pbuf, size_t nbytes, Arg arg);
109 extern Int SIO2_reclaim(SIO2_Handle stream, Ptr *ppbuf, Arg *parg);
110 extern Int SIO2_reclaimx(SIO2_Handle stream, Ptr *ppbuf, Arg *parg, Int *pfstatus);
112 #ifdef __cplusplus
113 }
114 #endif /* extern "C" */
116 #endif /* SIO2_ */