]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/blob - qnx/src/ipc3x_dev/ti/syslink/inc/knl/OsalKfile.h
Merge remote-tracking branch 'vincent/3.00.00.11_eng' into tmp
[ipc/ipcdev.git] / qnx / src / ipc3x_dev / ti / syslink / inc / knl / OsalKfile.h
1 /**
2  *  @file   OsalKfile.h
3  *
4  *  @brief      Kernel File operation interface definitions.
5  *
6  *              This abstracts the file operation interface in the Kernel
7  *              code. All the usual operations like open, close, read, write,
8  *              seek and tell will be supported.
9  *
10  *
11  *  @ver        02.00.00.46_alpha1
12  *
13  *  ============================================================================
14  *
15  *  Copyright (c) 2008-2009, Texas Instruments Incorporated
16  *
17  *  Redistribution and use in source and binary forms, with or without
18  *  modification, are permitted provided that the following conditions
19  *  are met:
20  *
21  *  *  Redistributions of source code must retain the above copyright
22  *     notice, this list of conditions and the following disclaimer.
23  *
24  *  *  Redistributions in binary form must reproduce the above copyright
25  *     notice, this list of conditions and the following disclaimer in the
26  *     documentation and/or other materials provided with the distribution.
27  *
28  *  *  Neither the name of Texas Instruments Incorporated nor the names of
29  *     its contributors may be used to endorse or promote products derived
30  *     from this software without specific prior written permission.
31  *
32  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
34  *  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
35  *  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
36  *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
37  *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
38  *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
39  *  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
40  *  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
41  *  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
42  *  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43  *  Contact information for paper mail:
44  *  Texas Instruments
45  *  Post Office Box 655303
46  *  Dallas, Texas 75265
47  *  Contact information:
48  *  http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
49  *  DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
50  *  ============================================================================
51  *
52  */
55 #ifndef OSALKFILE_H_0x3046
56 #define OSALKFILE_H_0x3046
59 /* OSAL and utils */
62 #if defined (__cplusplus)
63 extern "C" {
64 #endif
67 /*!
68  *  @def    OSALKFILE_MODULEID
69  *  @brief  Module ID for OsalKfile OSAL module.
70  */
71 #define OSALKFILE_MODULEID                 (UInt16) 0x3046
73 /* =============================================================================
74  *  All success and failure codes for the module
75  * =============================================================================
76  */
77 /*!
78 * @def   OSALKFILE_STATUSCODEBASE
79 * @brief Stauts code base for MEMORY module.
80 */
81 #define OSALKFILE_STATUSCODEBASE      (OSALKFILE_MODULEID << 12u)
83 /*!
84 * @def   OSALKFILE_MAKE_FAILURE
85 * @brief Convert to failure code.
86 */
87 #define OSALKFILE_MAKE_FAILURE(x)    ((Int) (0x80000000  \
88                                       + (OSALKFILE_STATUSCODEBASE + (x))))
89 /*!
90 * @def   OSALKFILE_MAKE_SUCCESS
91 * @brief Convert to success code.
92 */
93 #define OSALKFILE_MAKE_SUCCESS(x)      (OSALKFILE_STATUSCODEBASE + (x))
95 /*!
96 * @def   OSALKFILE_E_MEMORY
97 * @brief Indicates OsalKfile alloc/free failure.
98 */
99 #define OSALKFILE_E_MEMORY             OSALKFILE_MAKE_FAILURE(1)
101 /*!
102 * @def   OSALKFILE_E_INVALIDARG
103 * @brief Invalid argument provided
104 */
105 #define OSALKFILE_E_INVALIDARG         OSALKFILE_MAKE_FAILURE(2)
107 /*!
108 * @def   OSALKFILE_E_FAIL
109 * @brief Generic failure
110 */
111 #define OSALKFILE_E_FAIL               OSALKFILE_MAKE_FAILURE(3)
113 /*!
114 * @def   OSALKFILE_E_OUTOFRANGE
115 * @brief Indicates that specified value is out of range
116 */
117 #define OSALKFILE_E_OUTOFRANGE         OSALKFILE_MAKE_FAILURE(4)
119 /*!
120  *  @def    OSALKFILE_E_FILEOPEN
121  *  @brief  Failure to open the file.
122  */
123 #define OSALKFILE_E_FILEOPEN           OSALKFILE_MAKE_FAILURE(5)
125 /*!
126  *  @def    OSALKFILE_E_FILEREAD
127  *  @brief  Failure to read from the file.
128  */
129 #define OSALKFILE_E_FILEREAD           OSALKFILE_MAKE_FAILURE(6)
131 /*!
132  *  @def    OSALKFILE_E_HANDLE
133  *  @brief  Invalid handle provided
134  */
135 #define OSALKFILE_E_HANDLE             OSALKFILE_MAKE_FAILURE(7)
137 /*!
138 * @def   OSALKFILE_SUCCESS
139 * @brief Operation successfully completed
140 */
141 #define OSALKFILE_SUCCESS              OSALKFILE_MAKE_SUCCESS(0)
144 /* =============================================================================
145  *  Macros and types
146  * =============================================================================
147  */
148 /*!
149  *  @brief  Declaration for the OsalKfile object handle.
150  *          Definition of OsalKfile_Object is not exposed.
151  */
152 typedef struct OsalKfile_Object * OsalKfile_Handle;
154 /*!
155  *  @brief   Enumerates the values used for repositioning the file position
156  *           indicator.
157  */
158 typedef enum {
159     OsalKfile_Pos_SeekSet  = 0x0,
160     /* !< Seek from beginning of file. */
161     OsalKfile_Pos_SeekCur  = 0x1,
162     /* !< Seek from current position. */
163     OsalKfile_Pos_SeekEnd  = 0x2,
164     /* !< Seek from end of file. */
165     OsalKfile_Pos_EndValue = 0x3
166     /*!< End delimiter indicating start of invalid values for this enum */
167 } OsalKfile_Pos;
170 /* =============================================================================
171  *  APIs
172  * =============================================================================
173  */
174 /* Opens the file object. */
175 Int OsalKfile_open (String             fileName,
176                     Char *             fileMode,
177                     OsalKfile_Handle * fileHandle);
179 /* Closes the underlying file. */
180 Int OsalKfile_close (OsalKfile_Handle * fileHandle);
182 /* Reads the block of data from current position in the file. */
183 Int OsalKfile_read (OsalKfile_Handle fileHandle,
184                     Char *           buffer,
185                     UInt32           size,
186                     UInt32           count);
188 /* Repositions the file pointer according to specified arguments.*/
189 Int OsalKfile_seek (OsalKfile_Handle fileHandle,
190                     Int32            offset,
191                     OsalKfile_Pos    pos);
193 /* Returns the current file pointer position for a specified file handle. */
194 UInt32 OsalKfile_tell (OsalKfile_Handle fileHandle);
197 #if defined (__cplusplus)
199 #endif /* defined (__cplusplus) */
201 #endif /* ifndef OSALKFILE_H_0x3046 */