summaryrefslogtreecommitdiffstats
path: root/security/tf_sdk/include/sst.h
blob: f84c25a24942881c8bd50288b02634044e64455e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/**
 * Copyright(c) 2011 Trusted Logic.   All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *  * Neither the name Trusted Logic nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef __SST_H__
#define __SST_H__

#ifdef __cplusplus
extern "C" {
#endif


#include "s_type.h"
#include "s_error.h"

#ifdef SST_EXPORTS
#define SST_EXPORT_API S_DLL_EXPORT
#else
#define SST_EXPORT_API S_DLL_IMPORT
#endif

/* -----------------------------------------------------------------------------
                          Service SST Types
----------------------------------------------------------------------------- */

#ifndef EXCLUDE_SERVICE_SST_TYPES

/** The SST_ERROR type */
typedef uint32_t  SST_ERROR;

/** The SST_HANDLE type */
typedef uint32_t  SST_HANDLE;

typedef struct SST_FILE_INFO
{
   char* pName;
   uint32_t nSize;
} SST_FILE_INFO;

#endif /* EXCLUDE_SERVICE_SST_TYPES */

typedef enum
{
   SST_SEEK_SET = 0,
   SST_SEEK_CUR,
   SST_SEEK_END
} SST_WHENCE;


/* -----------------------------------------------------------------------------
                          Constants
----------------------------------------------------------------------------- */

#ifndef EXCLUDE_SERVICE_SST_CONSTANTS

/** The Invalid SST_FILE_HANDLE */
#define SST_NULL_HANDLE     0

/* Legacy constant name */
#define SST_HANDLE_INVALID    SST_NULL_HANDLE

/** Max length for file names */
#define SST_MAX_FILENAME 0x40

/** Maximum pointer position in a file */
#define SST_MAX_FILE_POSITION    0xFFFFFFFF

/** File access modes */
#define SST_O_READ               0x00000001
#define SST_O_WRITE              0x00000002
#define SST_O_WRITE_META         0x00000004
#define SST_O_SHARE_READ         0x00000010
#define SST_O_SHARE_WRITE        0x00000020
#define SST_O_CREATE             0x00000200
#define SST_O_EXCLUSIVE          0x00000400


#endif /* EXCLUDE_SERVICE_SST_CONSTANTS */


/* -----------------------------------------------------------------------------
                        Functions
----------------------------------------------------------------------------- */

#ifndef EXCLUDE_SERVICE_SST_FUNCTIONS

SST_ERROR SST_EXPORT_API SSTInit(void);

SST_ERROR SST_EXPORT_API SSTTerminate(void);

SST_ERROR SST_EXPORT_API SSTOpen(const char*       pFilename,
                                 uint32_t    nFlags,
                                 uint32_t    nReserved,
                                 SST_HANDLE* phFile);

SST_ERROR SST_EXPORT_API SSTCloseHandle(SST_HANDLE  hFile);

SST_ERROR SST_EXPORT_API SSTWrite(SST_HANDLE hFile,
                                  const uint8_t*   pBuffer,
                                  uint32_t   nSize);

SST_ERROR SST_EXPORT_API SSTRead(SST_HANDLE  hFile,
                                 uint8_t*    pBuffer,
                                 uint32_t    nSize,
                                 uint32_t*   pnCount);

SST_ERROR SST_EXPORT_API SSTSeek(SST_HANDLE  hFile,
                                 int32_t     nOffset,
                                 SST_WHENCE  eWhence);

SST_ERROR SST_EXPORT_API SSTTell(SST_HANDLE  hFile,
                                 uint32_t*   pnPos);

SST_ERROR SST_EXPORT_API SSTGetSize(const char*        pFilename,
                                    uint32_t*    pnSize);

SST_ERROR SST_EXPORT_API SSTEof( SST_HANDLE   hFile,
                                 bool*        pbEof);

SST_ERROR SST_EXPORT_API SSTCloseAndDelete(SST_HANDLE hFile);

SST_ERROR SST_EXPORT_API SSTTruncate(  SST_HANDLE  hFile,
                                       uint32_t    nSize);

SST_ERROR SST_EXPORT_API SSTRename(SST_HANDLE hFile,
                                   const char* pNewFilename);

SST_ERROR SST_EXPORT_API SSTEnumerationStart(const char*     pFilenamePattern,
                                             uint32_t  nReserved1,
                                             uint32_t  nReserved2,
                                             SST_HANDLE* phFileEnumeration);

SST_ERROR SST_EXPORT_API SSTEnumerationCloseHandle(SST_HANDLE hFileEnumeration);

SST_ERROR SST_EXPORT_API SSTEnumerationGetNext(SST_HANDLE      hFileEnumeration,
                                               SST_FILE_INFO** ppFileInfo);

SST_ERROR SST_EXPORT_API SSTDestroyFileInfo(SST_FILE_INFO*   pFileInfo);

#endif /* EXCLUDE_SERVICE_SST_FUNCTIONS */

#ifdef __cplusplus
}
#endif

#endif /* __SST_H__ */