• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_Common.h
19  *
20  * Project: NFC FRI / OSAL
21  *
22  * $Workfile:: phOsalNfc_Common.h                $
23  * $Modtime::                                    $
24  * $Author: frq09147 $
25  * $Revision: 1.1 $
26  *
27  */
28 
29 #ifndef PHOSALNFC_COMMON_H
30 #define PHOSALNFC_COMMON_H
31 #include <time.h>
32 #include <unistd.h>
33 #include <errno.h>
34 #include <pthread.h>
35 #include <semaphore.h>
36 #include <signal.h>
37 #include <sys/time.h>
38 #include <sys/sem.h>
39 
40 #define MAX_MESSAGE_SIZE 256
41 
42 typedef enum phOsalNfc_eHandleType
43 {
44      phOsalNfc_eHandleTypeInvalid   = 0,
45      phOsalNfc_eHandleTypeThread    = 1,
46      phOsalNfc_eHandleTypeSemaphore = 2,
47 
48 }phOsalNfc_eHandleType_t;
49 
50 typedef struct phOsalNfc_sMsg
51 {
52      phOsalNfc_Message_t Msg;
53      uint32_t sourceID; /* pthread_t = unsigned long int */
54      struct phOsalNfc_sMsg *nextMsg;
55 } phOsalNfc_sMsg_t;
56 
57 typedef struct phOsalNfc_sOsalHandle
58 {
59      phOsalNfc_eHandleType_t       HandleType;
60      pthread_t 	                  *pThread;
61      pphOsalNfc_ThreadFunction_t   pThreadFunction;
62      void                         *pParams;
63 
64      sem_t                        *pSemaphore;
65      sem_t                         handleSem;
66      int32_t                       semValue;
67      uint32_t                      semMax;
68 
69      struct sembuf                 semBuf;
70      int32_t                       semId;
71 
72      phOsalNfc_sMsg_t             *pMsg;
73      sem_t                         msgSem;
74      struct phOsalNfc_sOsalHandle *nextThread;
75 } phOsalNfc_sOsalHandle_t;
76 
77 
78 #endif /* PHOSALNFC_COMMON_H */
79