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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
/*
* Copyright (C) 2010 NXP Semiconductors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* \file phOsalNfc.h
* \brief OSAL Implementation.
*
* Project: NFC-FRI 1.1
* $Date: Fri Jun 26 14:41:31 2009 $
* $Author: ing04880 $
* $Revision: 1.21 $
* $Aliases: NFC_FRI1.1_WK926_R28_1,NFC_FRI1.1_WK928_R29_1,NFC_FRI1.1_WK930_R30_1,NFC_FRI1.1_WK934_PREP_1,NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $
*
*/
#ifndef PHOSALNFC_H
#define PHOSALNFC_H
/** \defgroup grp_osal_nfc OSAL Component
*
*\note: API listed here encompasses Operating System Abstraction Layer interfaces required to be mapped to underlying OS platforms.
*
*/
#include <phNfcTypes.h>
#ifdef PH_NFC_CUSTOMINTEGRATION
#include <phNfcCustomInt.h>
#else
#include <memory.h>
/**< OSAL Message Type */
#ifdef WIN32
//#define PH_OSALNFC_MESSAGE_BASE (WM_USER+0x3FF)
#define PH_OSALNFC_MESSAGE_BASE PH_LIBNFC_MESSAGE_BASE
#endif
/*!
* \ingroup grp_osal_nfc
*
* OSAL Message structure contains message specific details like
* message type, message specific data block details, etc.
*/
//typedef struct phOsalNfc_Message
//{
// uint32_t eMsgType;/**< Type of the message to be posted*/
// void * pMsgData;/**< Pointer to message specific data block in case any*/
// uint16_t Size;/**< Size of the datablock*/
//} phOsalNfc_Message_t,*pphOsalNfc_Message_t;
typedef phLibNfc_Message_t phOsalNfc_Message_t;
typedef pphLibNfc_Message_t pphOsalNfc_Message_t;
/*!
* \ingroup grp_osal_nfc
*
* Enum definition contains supported exception types
*/
typedef enum
{
phOsalNfc_e_NoMemory, /**<Memory allocation failed */
phOsalNfc_e_PrecondFailed, /**<precondition wasn't met */
phOsalNfc_e_InternalErr, /**<Unrecoverable error */
phOsalNfc_e_UnrecovFirmwareErr, /**<Unrecoverable firmware error */
phOsalNfc_e_DALerror, /**<Unrecoverable DAL error */
phOsalNfc_e_Noerror /**<No errortype */
} phOsalNfc_ExceptionType_t ;
/*!
* \ingroup grp_osal_nfc
*
* OSAL Exception structure containing exception type and reason.
*/
typedef struct phOsalNfc_Exception
{
phOsalNfc_ExceptionType_t eExceptionType;
uint16_t reason;
} phOsalNfc_Exception_t;
#ifdef ANDROID
extern phOsalNfc_Exception_t phOsalNfc_Exception;
#endif
/* OsalNfc Status Type */
/** \ingroup grp_retval1
A new semaphore could not be created due to
a system error. */
#define NFCSTATUS_SEMAPHORE_CREATION_ERROR (0x1010)
/** \ingroup grp_retval1
The given semaphore could not be released due to
a system error or invalid handle. */
#define NFCSTATUS_SEMAPHORE_PRODUCE_ERROR (0x1011)
/** \ingroup grp_retval11
The given semaphore could not be consumed due to a
system error or invalid handle. */
#define NFCSTATUS_SEMAPHORE_CONSUME_ERROR (0x1012)
/*!
* \ingroup grp_osal_nfc
* \brief Raises exception
*
* The program jumps out of the current execution flow, i.e. this function
* doesn't return. The given exception contains information on what has
* happened and how severe the error is. @warning This function should only be
* used for exceptional error situations where there is no means to recover.
*
* \param[in] eExceptiontype exception type.
* \param[in] reason additional reason value that gives a vendor specific reason
* code.
*
* \retval None
*/
void phOsalNfc_RaiseException(phOsalNfc_ExceptionType_t eExceptiontype,
uint16_t reason);
/*!
* \ingroup grp_osal_nfc
* \brief Output debug trace
*
* Outputs trace log of requested size as string
*
* \param[in] data Data block.
* \param[in] size buffer size of the data block.
*
* \retval None
*/
void phOsalNfc_DbgTrace(uint8_t data[], uint32_t size);
/*!
* \ingroup grp_osal_nfc
* \brief Print string
*
* Outputs given string to debug port.
*
* \param[in] pString pointer to buffer content to be displayed.
*
* \retval None
*/
void phOsalNfc_DbgString(const char *pString);
/*!
* \ingroup grp_osal_nfc
* \brief Print data buffer
*
* Outputs given string to debug port.
*
* \param[in] pString pointer to string to be displayed.
* \param[in] length number of bytes to be displayed.
* \param[in] pBuffer pointer to data bytes to be displayed.
*
* \retval None
*/
void phOsalNfc_PrintData(const char *pString, uint32_t length, uint8_t *pBuffer);
/*!
* \ingroup grp_osal_nfc
* \brief Allocates some memory
*
* \param[in] Size Size, in uint8_t, to be allocated
*
* \retval NON-NULL value: The memory was successfully allocated ; the return value points to the allocated memory location
* \retval NULL: The operation was not successful, certainly because of insufficient resources.
*
*/
extern void * phOsalNfc_GetMemory(uint32_t Size);
/*!
* \ingroup grp_osal_nfc
* \brief This API allows to free already allocated memory.
* \param[in] pMem Pointer to the memory block to deallocated
* \retval None
*/
void phOsalNfc_FreeMemory(void * pMem);
/*!
* \ingroup grp_osal_nfc
* \brief Compares the values stored in the source memory with the
* values stored in the destination memory.
*
* \param[in] src Pointer to the Source Memory
* \param[in] dest Pointer to the Destination Memory
* \param[in] n Number of bytes to be compared.
*
* \retval Zero value: The comparison was successful,
Both the memory areas contain the identical values.
* \retval Non-Zero Value: The comparison failed, both the memory
* areas are non-identical.
*
*/
int phOsalNfc_MemCompare(void *src, void *dest, unsigned int n);
#endif
#endif /* PHOSALNFC_H */
|