2 /*
3 Copyright (c) 2016, Texas Instruments Incorporated - http://www.ti.com/
4 All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the
16 * distribution.
17 *
18 * Neither the name of Texas Instruments Incorporated nor the names of
19 * its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 */
36 /*
37 * ======== sio.h ========
38 * Stream I/O Manager
39 *
40 */
42 #ifndef SIO_
43 #define SIO_
45 #include <stddef.h>
46 //#include <ti/bios/include/dev.h>
47 //#include <ti/bios/include/que.h>
49 //Use unit test w/ sio only sine generation
50 //#define SIMULATE_SIO
52 #ifndef SIMULATE_SIO
53 #include "sio2.h"
54 #endif
56 //typedef DEV_Callback SIO_Callback; /* for callback mode */
57 typedef void * SIO_Callback; // FL: redef, remove dev dependency
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
63 #ifdef SIMULATE_SIO
64 //#define SIO_INPUT DEV_INPUT /* input stream */
65 //#define SIO_OUTPUT DEV_OUTPUT /* output stream */
66 #define SIO_INPUT (0) // DEV_INPUT // FL: redef, remove dev dependency
67 #define SIO_OUTPUT (1) // DEV_OUTPUT // FL: redef, remove dev dependency
69 #define SIO_STANDARD 0
70 #define SIO_ISSUERECLAIM 1
72 // stub for DEV_Obj, included for mode
73 typedef struct DEV_Obj *DEV_Handle;
75 typedef struct DEV_Obj { /* must be first field in device object */
76 Int mode; /* DEV_INPUT/DEV_OUTPUT */
77 } DEV_Obj;
79 //typedef void * SIO_Callback; // FL: redef, remove dev dependency
81 typedef struct SIO_Attrs { /* stream attributes */
82 Int nbufs; /* number of buffers */
83 Int segid; /* buffer segment */
84 size_t align; /* buffer alignment */
85 Bool flush; /* TRUE -> don't block in DEV_idle() */
86 Uns model; /* SIO_STANDARD, SIO_ISSUERECLAIM */
87 Uns timeout; /* passed to all calls to DEV_reclaim() */
88 SIO_Callback *callback; /* initializes callback in DEV_Obj */
89 } SIO_Attrs;
91 typedef struct SIO_Obj { /* stream object */
92 DEV_Obj dobj; /* device object */ // FL: remove dev dependency
93 Bool flush; /* flush */
94 //QUE_Obj framelist; /* start of frame list */ // FL: remove que dependency
95 //DEV_Frame *standardFrame; /* frame for use in SIO_STANDARD model only */ // FL: remove dev dependency
96 Uns model; /* SIO_STANDARD or SIO_ISSUERECLAIM */
97 //DEV_Fxns *pfxns; /* pointer to DEV_Fxns for static stream init */ // FL: remove dev dependency
98 } SIO_Obj, *SIO_Handle;
99 #else
100 typedef struct SIO_Attrs { /* stream attributes */
101 Int nbufs; /* number of buffers */
102 Int segid; /* buffer segment */
103 size_t align; /* buffer alignment */
104 Bool flush; /* TRUE -> don't block in DEV_idle() */
105 Uns model; /* SIO_STANDARD, SIO_ISSUERECLAIM */
106 Uns timeout; /* passed to all calls to DEV_reclaim() */
107 SIO_Callback *callback; /* initializes callback in DEV_Obj */
108 } SIO_Attrs;
110 #define SIO_INPUT SIO2_INPUT
111 #define SIO_OUTPUT SIO2_OUTPUT
112 #define SIO_STANDARD SIO2_STANDARD
113 #define SIO_ISSUERECLAIM SIO2_ISSUERECLAIM
115 // stub for DEV_Obj, included for mode
116 typedef struct DEV2_Obj DEV_Obj;
117 typedef struct SIO2_Obj SIO_Obj;
118 typedef SIO2_Handle SIO_Handle;
119 typedef DEV2_Handle DEV_Handle;
121 //typedef struct SIO2_Attrs SIO_Attrs;
123 //#define SIO_ATTRS SIO2_ATTRS
125 #endif
127 extern SIO_Attrs SIO_ATTRS; /* default attributes */
129 extern Int _SIO_idle(SIO_Handle stream, Bool flush);
130 #define SIO_idle(stream) _SIO_idle(stream, 0)
131 //#define SIO_flush(stream) _SIO_idle(stream, 1) // FL: not used
133 //#define SIO_ctrl(stream, cmd, arg) DEV_ctrl((DEV_Handle)stream, cmd, arg)
134 extern Int SIO_ctrl(SIO_Handle stream, Uns cmd, Arg arg); // FL: redef, remove dev dependency
136 //#define SIO_ready(stream) DEV_ready((DEV_Handle)stream, NULL) // FL: not used
138 //#define SIO_segid(stream) ((stream)->dobj.segid) // FL: not used
139 //#define SIO_bufsize(stream) ((stream)->dobj.bufsize) // FL: not used
140 //#define SIO_nbufs(stream) ((stream)->dobj.nbufs) // FL: not used
142 extern SIO_Handle SIO_create(String name, Int mode, size_t size, SIO_Attrs *attrs);
143 //extern Int SIO_delete(SIO_Handle stream); // FL: not used
144 //extern Int SIO_get(SIO_Handle stream, Ptr *buf); // FL: not used
145 //extern Int SIO_staticbuf(SIO_Handle stream, Ptr *buf); // FL: not used
146 //extern Int SIO_put(SIO_Handle stream, Ptr *buf, size_t nbytes); // FL: not used
147 //extern Uns SIO_select(SIO_Handle streamtab[], Int n, Uns timeout); // FL: not used
148 extern Int SIO_issue(SIO_Handle stream, Ptr pbuf, size_t nbytes, Arg arg);
149 extern Int SIO_reclaim(SIO_Handle stream, Ptr *ppbuf, Arg *parg);
150 //extern Int SIO_reclaimx(SIO_Handle stream, Ptr *ppbuf, Arg *parg, Int *pfstatus); // FL: not used
152 #ifdef __cplusplus
153 }
154 #endif /* extern "C" */
156 #endif /* SIO_ */
157 /*
158 * @(#) ti.bios; 5, 6, 0,334; 10-15-2009 11:08:18; /db/vtree/library/trees/avala/avala-m15x/src/
159 */