Home | History | Annotate | Download | only in src
      1 /*
      2  * Copyright (C) 2010 NXP Semiconductors
      3  *
      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
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     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.
     15  */
     16 
     17 /*
     18  * \file  phOsalNfc.h
     19  * \brief OSAL Implementation.
     20  *
     21  * Project: NFC-FRI 1.1
     22  * $Date: Fri Jun 26 14:41:31 2009 $
     23  * $Author: ing04880 $
     24  * $Revision: 1.21 $
     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 $
     26  *
     27  */
     28 #ifndef PHOSALNFC_H
     29 #define PHOSALNFC_H
     30 
     31 
     32 /** \defgroup grp_osal_nfc OSAL Component
     33  *
     34  *\note: API listed here encompasses Operating System Abstraction Layer interfaces required to be mapped to underlying OS platforms.
     35  *
     36  */
     37 #include <phNfcTypes.h>
     38 
     39 #ifdef PH_NFC_CUSTOMINTEGRATION
     40 #include <phNfcCustomInt.h>
     41 #else
     42 #include <memory.h>
     43 
     44 /**< OSAL Message Type */
     45 #ifdef WIN32
     46 //#define PH_OSALNFC_MESSAGE_BASE  (WM_USER+0x3FF)
     47 #define PH_OSALNFC_MESSAGE_BASE  PH_LIBNFC_MESSAGE_BASE
     48 #endif
     49 
     50 /*!
     51  * \ingroup grp_osal_nfc
     52  *
     53  * OSAL Message structure contains message specific details like
     54  * message type, message specific data block details, etc.
     55  */
     56 //typedef struct phOsalNfc_Message
     57 //{
     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;
     64 
     65 /*!
     66  * \ingroup grp_osal_nfc
     67  *
     68  * Enum definition contains  supported exception types
     69   */
     70 typedef enum
     71 {
     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 ;
     79 
     80 /*!
     81  * \ingroup grp_osal_nfc
     82  *
     83  * OSAL Exception structure containing exception type and reason.
     84  */
     85 typedef struct phOsalNfc_Exception
     86 {
     87    phOsalNfc_ExceptionType_t eExceptionType;
     88    uint16_t reason;
     89 } phOsalNfc_Exception_t;
     90 
     91 #ifdef ANDROID
     92 extern phOsalNfc_Exception_t phOsalNfc_Exception;
     93 #endif
     94 
     95 /* OsalNfc Status Type */
     96 
     97 /** \ingroup grp_retval1
     98     A new semaphore could not be created due to
     99     a system error. */
    100 #define NFCSTATUS_SEMAPHORE_CREATION_ERROR                      (0x1010)
    101 
    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)
    106 
    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)
    111 
    112 
    113 /*!
    114  * \ingroup grp_osal_nfc
    115  * \brief Raises exception
    116  *
    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.
    121  *
    122  * \param[in] eExceptiontype exception type.
    123  * \param[in] reason additional reason value that gives a vendor specific reason
    124  * code.
    125  *
    126  * \retval  None
    127  */
    128 void phOsalNfc_RaiseException(phOsalNfc_ExceptionType_t  eExceptiontype,
    129                               uint16_t                   reason);
    130 
    131 /*!
    132  * \ingroup grp_osal_nfc
    133  * \brief Output debug trace
    134  *
    135  * Outputs trace log of requested size as string
    136  *
    137  * \param[in] data Data block.
    138  * \param[in] size buffer size of the data block.
    139  *
    140  * \retval None
    141  */
    142 void phOsalNfc_DbgTrace(uint8_t data[], uint32_t size);
    143 
    144 
    145 /*!
    146  * \ingroup grp_osal_nfc
    147  * \brief Print string
    148  *
    149  * Outputs given string to debug port.
    150  *
    151  * \param[in] pString pointer to buffer content to be displayed.
    152  *
    153  * \retval None
    154  */
    155 void phOsalNfc_DbgString(const char *pString);
    156 
    157 /*!
    158  * \ingroup grp_osal_nfc
    159  * \brief Print data buffer
    160  *
    161  * Outputs given string to debug port.
    162  *
    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.
    166  *
    167  * \retval None
    168  */
    169 void phOsalNfc_PrintData(const char *pString, uint32_t length, uint8_t *pBuffer,
    170         int verbosity);
    171 
    172 /*!
    173  * \ingroup grp_osal_nfc
    174  * \brief Allocates some memory
    175  *
    176  * \param[in] Size   Size, in uint8_t, to be allocated
    177  *
    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.
    180  *
    181  */
    182 extern void * phOsalNfc_GetMemory(uint32_t Size);
    183 
    184 
    185 /*!
    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
    189  * \retval None
    190  */
    191 void   phOsalNfc_FreeMemory(void * pMem);
    192 
    193 /*!
    194  * \ingroup grp_osal_nfc
    195  * \brief Compares the values stored in the source memory with the
    196  * values stored in the destination memory.
    197  *
    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.
    201  *
    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.
    206  *
    207  */
    208 int phOsalNfc_MemCompare(void *src, void *dest, unsigned int n);
    209 
    210 #endif
    211 #endif /*  PHOSALNFC_H  */
    212