1 /****************************************************************************
3 (c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
4 www.systec-electronic.com
6 Project: Project independend shared buffer (linear + circular)
8 Description: Declaration of platform independend part for the
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions
17 1. Redistributions of source code must retain the above copyright
18 notice, this list of conditions and the following disclaimer.
20 2. Redistributions in binary form must reproduce the above copyright
21 notice, this list of conditions and the following disclaimer in the
22 documentation and/or other materials provided with the distribution.
24 3. Neither the name of SYSTEC electronic GmbH nor the names of its
25 contributors may be used to endorse or promote products derived
26 from this software without prior written permission. For written
27 permission, please contact info@systec-electronic.com.
29 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
32 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
33 COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
34 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
35 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
37 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
39 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40 POSSIBILITY OF SUCH DAMAGE.
44 If a provision of this License is or becomes illegal, invalid or
45 unenforceable in any jurisdiction, that shall not affect:
46 1. the validity or enforceability in that jurisdiction of any other
47 provision of this License; or
48 2. the validity or enforceability in other jurisdictions of that or
49 any other provision of this License.
51 -------------------------------------------------------------------------
53 2006/06/27 -rs: V 1.00 (initial version)
55 ****************************************************************************/
57 #ifndef _SHAREDBUFF_H_
58 #define _SHAREDBUFF_H_
60 //---------------------------------------------------------------------------
62 //---------------------------------------------------------------------------
66 kShbNoReadableData = 1,
67 kShbDataTruncated = 2,
69 kShbDataOutsideBufferArea = 4,
70 kShbBufferAlreadyCompleted = 5,
71 kShbMemUsedByOtherProcs = 6,
73 kShbInvalidBufferType = 8,
75 kShbBufferInvalid = 10,
77 kShbAlreadyReseting = 12,
78 kShbAlreadySignaling = 13,
79 kShbExceedDataSizeLimit = 14,
83 // 2006/08/24 d.k.: Priority for threads (new data, job signaling)
86 kShbPriorityNormal = 1,
91 unsigned int m_uiFullBlockSize; // real size of allocated block (incl. alignment fill bytes)
92 unsigned long m_ulAvailableSize; // still available size for data
93 unsigned long m_ulWrIndex; // current write index
94 unsigned int m_fBufferCompleted; // TRUE if allocated block is complete filled with data
98 typedef void *tShbInstance;
100 typedef void (*tShbCirSigHndlrNewData) (tShbInstance pShbInstance_p,
101 unsigned long ulDataBlockSize_p);
102 typedef void (*tShbCirSigHndlrReset) (tShbInstance pShbInstance_p,
103 unsigned int fTimeOut_p);
105 //---------------------------------------------------------------------------
107 //---------------------------------------------------------------------------
113 tShbError ShbInit(void);
114 tShbError ShbExit(void);
116 // Circular Shared Buffer
117 tShbError ShbCirAllocBuffer(unsigned long ulBufferSize_p,
118 const char *pszBufferID_p,
119 tShbInstance * ppShbInstance_p,
120 unsigned int *pfShbNewCreated_p);
121 tShbError ShbCirReleaseBuffer(tShbInstance pShbInstance_p);
124 tShbError ShbCirResetBuffer(tShbInstance pShbInstance_p,
125 unsigned long ulTimeOut_p,
127 pfnSignalHandlerReset_p);
128 tShbError ShbCirWriteDataBlock(tShbInstance pShbInstance_p,
129 const void *pSrcDataBlock_p,
130 unsigned long ulDataBlockSize_p);
131 tShbError ShbCirAllocDataBlock(tShbInstance pShbInstance_p,
132 tShbCirChunk * pShbCirChunk_p,
133 unsigned long ulDataBufferSize_p);
134 tShbError ShbCirWriteDataChunk(tShbInstance pShbInstance_p,
135 tShbCirChunk * pShbCirChunk_p,
136 const void *pSrcDataChunk_p,
137 unsigned long ulDataChunkSize_p,
138 unsigned int *pfBufferCompleted_p);
139 tShbError ShbCirReadDataBlock(tShbInstance pShbInstance_p,
140 void *pDstDataBlock_p,
141 unsigned long ulRdBuffSize_p,
142 unsigned long *pulDataBlockSize_p);
143 tShbError ShbCirGetReadDataSize(tShbInstance pShbInstance_p,
144 unsigned long *pulDataBlockSize_p);
145 tShbError ShbCirGetReadBlockCount(tShbInstance pShbInstance_p,
146 unsigned long *pulDataBlockCount_p);
147 tShbError ShbCirSetSignalHandlerNewData(tShbInstance pShbInstance_p,
148 tShbCirSigHndlrNewData
149 pfnShbSignalHandlerNewData_p,
150 tShbPriority ShbPriority_p);
153 // Linear Shared Buffer
154 tShbError ShbLinAllocBuffer(unsigned long ulBufferSize_p,
155 const char *pszBufferID_p,
156 tShbInstance * ppShbInstance_p,
157 unsigned int *pfShbNewCreated_p);
158 tShbError ShbLinReleaseBuffer(tShbInstance pShbInstance_p);
161 tShbError ShbLinWriteDataBlock(tShbInstance pShbInstance_p,
162 unsigned long ulDstBufferOffs_p,
163 const void *pSrcDataBlock_p,
164 unsigned long ulDataBlockSize_p);
165 tShbError ShbLinReadDataBlock(tShbInstance pShbInstance_p,
166 void *pDstDataBlock_p,
167 unsigned long ulSrcBufferOffs_p,
168 unsigned long ulDataBlockSize_p);
172 tShbError ShbCirTraceBuffer(tShbInstance pShbInstance_p);
173 tShbError ShbLinTraceBuffer(tShbInstance pShbInstance_p);
174 tShbError ShbTraceDump(const unsigned char *pabStartAddr_p,
175 unsigned long ulDataSize_p,
176 unsigned long ulAddrOffset_p,
177 const char *pszInfoText_p);
179 #define ShbCirTraceBuffer(p0)
180 #define ShbLinTraceBuffer(p0)
181 #define ShbTraceDump(p0, p1, p2, p3)
187 #endif // #ifndef _SHAREDBUFF_H_