1 /******************************************************************************
2  *
3  *  Copyright (C) 2003-2014 Broadcom Corporation
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 
19 /******************************************************************************
20  *
21  *  This is the public interface file for the BTA system manager.
22  *
23  ******************************************************************************/
24 #ifndef NFA_SYS_H
25 #define NFA_SYS_H
26 
27 #include "gki.h"
28 #include "nfa_api.h"
29 #include "nfc_target.h"
30 
31 /*****************************************************************************
32 **  Constants and data types
33 *****************************************************************************/
34 
35 /* SW sub-systems */
36 enum {
37   NFA_ID_SYS,  /* system manager                      */
38   NFA_ID_DM,   /* device manager                      */
39   NFA_ID_EE,   /* NFCEE sub-system                    */
40   NFA_ID_P2P,  /* Peer-to-Peer sub-system             */
41   NFA_ID_SNEP, /* SNEP sub-system                     */
42   NFA_ID_RW,   /* Reader/writer sub-system            */
43   NFA_ID_CE,   /* Card-emulation sub-system           */
44   NFA_ID_HCI,  /* Host controller interface sub-system*/
45 #if (NFA_DTA_INCLUDED == TRUE)
46   NFA_ID_DTA, /* Device Test Application sub-system  */
47 #endif
48   NFA_ID_MAX
49 };
50 typedef uint8_t tNFA_SYS_ID;
51 
52 /* enable function type */
53 typedef void(tNFA_SYS_ENABLE)(void);
54 
55 /* event handler function type */
56 typedef bool(tNFA_SYS_EVT_HDLR)(NFC_HDR* p_msg);
57 
58 /* disable function type */
59 typedef void(tNFA_SYS_DISABLE)(void);
60 
61 /* function type for processing the change of NFCC power mode */
62 typedef void(tNFA_SYS_PROC_NFCC_PWR_MODE)(uint8_t nfcc_power_mode);
63 
64 typedef void(tNFA_SYS_ENABLE_CBACK)(void);
65 typedef void(tNFA_SYS_PROC_NFCC_PWR_MODE_CMPL)(void);
66 
67 /* registration structure */
68 typedef struct {
69   tNFA_SYS_ENABLE* enable;
70   tNFA_SYS_EVT_HDLR* evt_hdlr;
71   tNFA_SYS_DISABLE* disable;
72   tNFA_SYS_PROC_NFCC_PWR_MODE* proc_nfcc_pwr_mode;
73 } tNFA_SYS_REG;
74 
75 /* system manager configuration structure */
76 typedef struct {
77   uint16_t mbox_evt;   /* GKI mailbox event */
78   uint8_t mbox;        /* GKI mailbox id */
79   uint8_t timer;       /* GKI timer id */
80 } tNFA_SYS_CFG;
81 
82 /*****************************************************************************
83 **  Global data
84 *****************************************************************************/
85 
86 /*****************************************************************************
87 **  Macros
88 *****************************************************************************/
89 
90 /* Calculate start of event enumeration; id is top 8 bits of event */
91 #define NFA_SYS_EVT_START(id) ((id) << 8)
92 
93 /*****************************************************************************
94 **  Function declarations
95 *****************************************************************************/
96 
97 extern void nfa_sys_init(void);
98 extern void nfa_sys_event(NFC_HDR* p_msg);
99 extern void nfa_sys_timer_update(void);
100 extern void nfa_sys_disable_timers(void);
101 
102 extern void nfa_sys_register(uint8_t id, const tNFA_SYS_REG* p_reg);
103 extern void nfa_sys_deregister(uint8_t id);
104 extern void nfa_sys_check_disabled(void);
105 extern bool nfa_sys_is_register(uint8_t id);
106 extern void nfa_sys_disable_subsystems(bool graceful);
107 extern void nfa_sys_enable_subsystems(void);
108 
109 extern bool nfa_sys_is_graceful_disable(void);
110 extern void nfa_sys_sendmsg(void* p_msg);
111 extern void nfa_sys_start_timer(TIMER_LIST_ENT* p_tle, uint16_t type,
112                                 int32_t timeout);
113 extern void nfa_sys_stop_timer(TIMER_LIST_ENT* p_tle);
114 
115 extern void nfa_sys_cback_reg_enable_complete(tNFA_SYS_ENABLE_CBACK* p_cback);
116 extern void nfa_sys_cback_notify_enable_complete(uint8_t id);
117 
118 extern void nfa_sys_notify_nfcc_power_mode(uint8_t nfcc_power_mode);
119 extern void nfa_sys_cback_reg_nfcc_power_mode_proc_complete(
120     tNFA_SYS_PROC_NFCC_PWR_MODE_CMPL* p_cback);
121 extern void nfa_sys_cback_notify_nfcc_power_mode_proc_complete(uint8_t id);
122 
123 #endif /* NFA_SYS_H */
124