2 * Copyright (C) 2010 NXP Semiconductors
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 * \brief OSAL Implementation.
21 * Project: NFC-FRI 1.1
22 * $Date: Fri Jun 26 14:41:31 2009 $
25 * $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 $
32 /** \defgroup grp_osal_nfc OSAL Component
34 *\note: API listed here encompasses Operating System Abstraction Layer interfaces required to be mapped to underlying OS platforms.
37 #include <phNfcTypes.h>
39 #ifdef PH_NFC_CUSTOMINTEGRATION
40 #include <phNfcCustomInt.h>
44 /**< OSAL Message Type */
46 //#define PH_OSALNFC_MESSAGE_BASE (WM_USER+0x3FF)
47 #define PH_OSALNFC_MESSAGE_BASE PH_LIBNFC_MESSAGE_BASE
51 * \ingroup grp_osal_nfc
53 * OSAL Message structure contains message specific details like
54 * message type, message specific data block details, etc.
56 //typedef struct phOsalNfc_Message
58 // uint32_t eMsgType;/**< Type of the message to be posted*/
59 // void * pMsgData;/**< Pointer to message specific data block in case any*/
60 // uint16_t Size;/**< Size of the datablock*/
61 //} phOsalNfc_Message_t,*pphOsalNfc_Message_t;
62 typedef phLibNfc_Message_t phOsalNfc_Message_t;
63 typedef pphLibNfc_Message_t pphOsalNfc_Message_t;
66 * \ingroup grp_osal_nfc
68 * Enum definition contains supported exception types
72 phOsalNfc_e_NoMemory, /**<Memory allocation failed */
73 phOsalNfc_e_PrecondFailed, /**<precondition wasn't met */
74 phOsalNfc_e_InternalErr, /**<Unrecoverable error */
75 phOsalNfc_e_UnrecovFirmwareErr, /**<Unrecoverable firmware error */
76 phOsalNfc_e_DALerror, /**<Unrecoverable DAL error */
77 phOsalNfc_e_Noerror /**<No errortype */
78 } phOsalNfc_ExceptionType_t ;
81 * \ingroup grp_osal_nfc
83 * OSAL Exception structure containing exception type and reason.
85 typedef struct phOsalNfc_Exception
87 phOsalNfc_ExceptionType_t eExceptionType;
89 } phOsalNfc_Exception_t;
92 extern phOsalNfc_Exception_t phOsalNfc_Exception;
95 /* OsalNfc Status Type */
97 /** \ingroup grp_retval1
98 A new semaphore could not be created due to
100 #define NFCSTATUS_SEMAPHORE_CREATION_ERROR (0x1010)
102 /** \ingroup grp_retval1
103 The given semaphore could not be released due to
104 a system error or invalid handle. */
105 #define NFCSTATUS_SEMAPHORE_PRODUCE_ERROR (0x1011)
107 /** \ingroup grp_retval11
108 The given semaphore could not be consumed due to a
109 system error or invalid handle. */
110 #define NFCSTATUS_SEMAPHORE_CONSUME_ERROR (0x1012)
114 * \ingroup grp_osal_nfc
115 * \brief Raises exception
117 * The program jumps out of the current execution flow, i.e. this function
118 * doesn't return. The given exception contains information on what has
119 * happened and how severe the error is. @warning This function should only be
120 * used for exceptional error situations where there is no means to recover.
122 * \param[in] eExceptiontype exception type.
123 * \param[in] reason additional reason value that gives a vendor specific reason
128 void phOsalNfc_RaiseException(phOsalNfc_ExceptionType_t eExceptiontype,
132 * \ingroup grp_osal_nfc
133 * \brief Output debug trace
135 * Outputs trace log of requested size as string
137 * \param[in] data Data block.
138 * \param[in] size buffer size of the data block.
142 void phOsalNfc_DbgTrace(uint8_t data[], uint32_t size);
146 * \ingroup grp_osal_nfc
147 * \brief Print string
149 * Outputs given string to debug port.
151 * \param[in] pString pointer to buffer content to be displayed.
155 void phOsalNfc_DbgString(const char *pString);
158 * \ingroup grp_osal_nfc
159 * \brief Print data buffer
161 * Outputs given string to debug port.
163 * \param[in] pString pointer to string to be displayed.
164 * \param[in] length number of bytes to be displayed.
165 * \param[in] pBuffer pointer to data bytes to be displayed.
169 void phOsalNfc_PrintData(const char *pString, uint32_t length, uint8_t *pBuffer,
173 * \ingroup grp_osal_nfc
174 * \brief Allocates some memory
176 * \param[in] Size Size, in uint8_t, to be allocated
178 * \retval NON-NULL value: The memory was successfully allocated ; the return value points to the allocated memory location
179 * \retval NULL: The operation was not successful, certainly because of insufficient resources.
182 extern void * phOsalNfc_GetMemory(uint32_t Size);
186 * \ingroup grp_osal_nfc
187 * \brief This API allows to free already allocated memory.
188 * \param[in] pMem Pointer to the memory block to deallocated
191 void phOsalNfc_FreeMemory(void * pMem);
194 * \ingroup grp_osal_nfc
195 * \brief Compares the values stored in the source memory with the
196 * values stored in the destination memory.
198 * \param[in] src Pointer to the Source Memory
199 * \param[in] dest Pointer to the Destination Memory
200 * \param[in] n Number of bytes to be compared.
202 * \retval Zero value: The comparison was successful,
203 Both the memory areas contain the identical values.
204 * \retval Non-Zero Value: The comparison failed, both the memory
205 * areas are non-identical.
208 int phOsalNfc_MemCompare(void *src, void *dest, unsigned int n);
211 #endif /* PHOSALNFC_H */