805d5e5a24a052ad9223707a3a58359851fd8a5c
2 /*
3 Copyright (c) 2018, 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 #include <string.h> // for memset
37 #include <xdc/std.h>
38 #include <xdc/cfg/global.h>
39 #include <xdc/runtime/Error.h>
40 #include <xdc/runtime/Log.h>
41 #include <xdc/runtime/Memory.h>
43 #include <ti/sysbios/BIOS.h>
44 #include <ti/sysbios/knl/Semaphore.h>
46 #include "sio.h"
48 #include "inpbuf.h"
49 #include "outbuf.h"
51 #include "pafsio.h"
53 #include "paftyp.h"
54 #include "pafdec.h"
56 #include "paf_heapMgr.h"
58 #include "fwkPort.h"
59 #include "dbgDib.h"
61 // stub for SIO create()
62 SIO_Handle SIO_create(
63 String name,
64 Int mode,
65 size_t size,
66 SIO_Attrs *attrs
67 )
68 {
69 SIO_Handle stream;
71 Log_info2("SIO_create():mode=%d, size=%d", mode, size);
72 SIO2_Attrs attrs2;
73 attrs2.nbufs = attrs->nbufs;
74 attrs2.bufSeg = (IHeap_Handle)pafHeapMgr_readHeapHandle(attrs->segid);
75 attrs2.align = attrs->align;
76 attrs2.flush = attrs->flush;
77 attrs2.model = attrs->model;
78 attrs2.timeout = attrs->timeout;
79 attrs2.callback = attrs->callback;
80 stream = SIO2_create(name, mode, size, &attrs2);
82 return stream;
83 }
85 // stub for SIO_ctrl()
86 SIO_ctrl(
87 SIO_Handle stream,
88 Uns cmd,
89 Arg arg
90 )
91 {
92 return SIO2_ctrl(stream, cmd, arg);
93 }
95 // stub for _SIO_idle
96 Int _SIO_idle(
97 SIO_Handle stream,
98 Bool flush
99 )
100 {
101 return _SIO2_idle(stream, flush);
102 }
104 // stub for SIO_issue()
105 Int SIO_issue(
106 SIO_Handle stream,
107 Ptr pbuf,
108 size_t nbytes,
109 Arg arg
110 )
111 {
112 return SIO2_issue(stream, pbuf, nbytes, arg);
113 }
115 // stub for SIO_reclaim()
116 Int SIO_reclaim(
117 SIO_Handle stream,
118 Ptr *ppbuf,
119 Arg *parg
120 )
121 {
122 DEV2_Handle device; /* == stream */
124 /* first field in SIO_Obj is a DEV_Obj */
125 device = (DEV2_Handle)stream;
126 Log_info4("SIO_reclaim:stream=0x%x, ppbuf=0x%x, parg=0x%x, mode=%d", (IArg)stream, (IArg)ppbuf, (IArg)parg, device->mode);
128 return SIO2_reclaim(stream, ppbuf, parg);
129 }