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_RW,   /* Reader/writer sub-system            */
41   NFA_ID_CE,   /* Card-emulation sub-system           */
42   NFA_ID_HCI,  /* Host controller interface sub-system*/
43   NFA_ID_WLC,  /* WLC sub-system */
44 #if (NFA_DTA_INCLUDED == TRUE)
45   NFA_ID_DTA, /* Device Test Application sub-system  */
46 #endif
47   NFA_ID_MAX
48 };
49 typedef uint8_t tNFA_SYS_ID;
50 
51 /* enable function type */
52 typedef void(tNFA_SYS_ENABLE)(void);
53 
54 /* event handler function type */
55 typedef bool(tNFA_SYS_EVT_HDLR)(NFC_HDR* p_msg);
56 
57 /* disable function type */
58 typedef void(tNFA_SYS_DISABLE)(void);
59 
60 /* function type for processing the change of NFCC power mode */
61 typedef void(tNFA_SYS_PROC_NFCC_PWR_MODE)(uint8_t nfcc_power_mode);
62 
63 typedef void(tNFA_SYS_ENABLE_CBACK)(void);
64 typedef void(tNFA_SYS_PROC_NFCC_PWR_MODE_CMPL)(void);
65 
66 /* registration structure */
67 typedef struct {
68   tNFA_SYS_ENABLE* enable;
69   tNFA_SYS_EVT_HDLR* evt_hdlr;
70   tNFA_SYS_DISABLE* disable;
71   tNFA_SYS_PROC_NFCC_PWR_MODE* proc_nfcc_pwr_mode;
72 } tNFA_SYS_REG;
73 
74 /* system manager configuration structure */
75 typedef struct {
76   uint16_t mbox_evt;   /* GKI mailbox event */
77   uint8_t mbox;        /* GKI mailbox id */
78   uint8_t timer;       /* GKI timer id */
79 } tNFA_SYS_CFG;
80 
81 /*****************************************************************************
82 **  Global data
83 *****************************************************************************/
84 
85 /*****************************************************************************
86 **  Macros
87 *****************************************************************************/
88 
89 /* Calculate start of event enumeration; id is top 8 bits of event */
90 #define NFA_SYS_EVT_START(id) ((id) << 8)
91 
92 /*****************************************************************************
93 **  Function declarations
94 *****************************************************************************/
95 
96 extern void nfa_sys_init(void);
97 extern void nfa_sys_event(NFC_HDR* p_msg);
98 extern void nfa_sys_timer_update(void);
99 extern void nfa_sys_disable_timers(void);
100 
101 extern void nfa_sys_register(uint8_t id, const tNFA_SYS_REG* p_reg);
102 extern void nfa_sys_deregister(uint8_t id);
103 extern void nfa_sys_check_disabled(void);
104 extern bool nfa_sys_is_register(uint8_t id);
105 extern void nfa_sys_disable_subsystems(bool graceful);
106 extern void nfa_sys_enable_subsystems(void);
107 
108 extern bool nfa_sys_is_graceful_disable(void);
109 extern void nfa_sys_sendmsg(void* p_msg);
110 extern void nfa_sys_start_timer(TIMER_LIST_ENT* p_tle, uint16_t type,
111                                 int32_t timeout);
112 extern void nfa_sys_stop_timer(TIMER_LIST_ENT* p_tle);
113 
114 extern void nfa_sys_cback_reg_enable_complete(tNFA_SYS_ENABLE_CBACK* p_cback);
115 extern void nfa_sys_cback_notify_enable_complete(uint8_t id);
116 
117 extern void nfa_sys_notify_nfcc_power_mode(uint8_t nfcc_power_mode);
118 extern void nfa_sys_cback_reg_nfcc_power_mode_proc_complete(
119     tNFA_SYS_PROC_NFCC_PWR_MODE_CMPL* p_cback);
120 extern void nfa_sys_cback_notify_nfcc_power_mode_proc_complete(uint8_t id);
121 
122 #endif /* NFA_SYS_H */
123