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 *
22 *  This is the public interface file for the BTA system manager.
23 *
24 ******************************************************************************/
25#ifndef NFA_SYS_H
26#define NFA_SYS_H
27
28#include "nfc_target.h"
29#include "gki.h"
30#include "nfa_api.h"
31
32/*****************************************************************************
33**  Constants and data types
34*****************************************************************************/
35
36/* SW sub-systems */
37enum {
38    NFA_ID_SYS,         /* system manager                      */
39    NFA_ID_DM,          /* device manager                      */
40    NFA_ID_EE,          /* NFCEE sub-system                    */
41    NFA_ID_P2P,         /* Peer-to-Peer sub-system             */
42    NFA_ID_CHO,         /* Connection Handover sub-system      */
43    NFA_ID_SNEP,        /* SNEP sub-system                     */
44    NFA_ID_RW,          /* Reader/writer sub-system            */
45    NFA_ID_CE,          /* Card-emulation sub-system           */
46    NFA_ID_HCI,         /* Host controller interface sub-system*/
47#if (NFA_DTA_INCLUDED == TRUE)
48    NFA_ID_DTA,         /* Device Test Application sub-system  */
49#endif
50    NFA_ID_MAX
51};
52typedef UINT8 tNFA_SYS_ID;
53
54/* enable function type */
55typedef void (tNFA_SYS_ENABLE) (void);
56
57/* event handler function type */
58typedef BOOLEAN (tNFA_SYS_EVT_HDLR) (BT_HDR *p_msg);
59
60/* disable function type */
61typedef void (tNFA_SYS_DISABLE) (void);
62
63/* function type for processing the change of NFCC power mode */
64typedef void (tNFA_SYS_PROC_NFCC_PWR_MODE) (UINT8 nfcc_power_mode);
65
66typedef void (tNFA_SYS_CBACK) (void);
67typedef void (tNFA_SYS_ENABLE_CBACK) (void);
68typedef void (tNFA_SYS_PROC_NFCC_PWR_MODE_CMPL) (void);
69
70/* registration structure */
71typedef struct
72{
73    tNFA_SYS_ENABLE                 *enable;
74    tNFA_SYS_EVT_HDLR               *evt_hdlr;
75    tNFA_SYS_DISABLE                *disable;
76    tNFA_SYS_PROC_NFCC_PWR_MODE     *proc_nfcc_pwr_mode;
77} tNFA_SYS_REG;
78
79/* system manager configuration structure */
80typedef struct
81{
82    UINT16          mbox_evt;                       /* GKI mailbox event */
83    UINT8           mbox;                           /* GKI mailbox id */
84    UINT8           timer;                          /* GKI timer id */
85    UINT8           trace_level;                    /* initial trace level */
86} tNFA_SYS_CFG;
87
88
89/*****************************************************************************
90**  Global data
91*****************************************************************************/
92
93/*****************************************************************************
94**  Macros
95*****************************************************************************/
96
97/* Calculate start of event enumeration; id is top 8 bits of event */
98#define NFA_SYS_EVT_START(id)       ((id) << 8)
99
100
101/*****************************************************************************
102**  Function declarations
103*****************************************************************************/
104
105#ifdef __cplusplus
106extern "C" {
107#endif
108
109NFC_API extern void nfa_sys_init (void);
110NFC_API extern void nfa_sys_event (BT_HDR *p_msg);
111NFC_API extern void nfa_sys_timer_update (void);
112NFC_API extern void nfa_sys_disable_timers (void);
113NFC_API extern void nfa_sys_set_trace_level (UINT8 level);
114
115extern void nfa_sys_register (UINT8 id, const tNFA_SYS_REG *p_reg);
116extern void nfa_sys_deregister (UINT8 id);
117extern void nfa_sys_check_disabled (void);
118extern BOOLEAN nfa_sys_is_register (UINT8 id);
119extern void nfa_sys_disable_subsystems (BOOLEAN graceful);
120extern void nfa_sys_enable_subsystems (void);
121
122extern BOOLEAN nfa_sys_is_graceful_disable (void);
123extern void nfa_sys_sendmsg (void *p_msg);
124extern void nfa_sys_start_timer (TIMER_LIST_ENT *p_tle, UINT16 type, INT32 timeout);
125extern void nfa_sys_stop_timer (TIMER_LIST_ENT *p_tle);
126
127extern void nfa_sys_cback_reg_enable_complete (tNFA_SYS_ENABLE_CBACK *p_cback);
128extern void nfa_sys_cback_notify_enable_complete (UINT8 id);
129
130extern void nfa_sys_notify_nfcc_power_mode (UINT8 nfcc_power_mode);
131extern void nfa_sys_cback_reg_nfcc_power_mode_proc_complete (tNFA_SYS_PROC_NFCC_PWR_MODE_CMPL *p_cback);
132extern void nfa_sys_cback_notify_nfcc_power_mode_proc_complete (UINT8 id);
133
134#ifdef __cplusplus
135}
136#endif
137
138#endif /* NFA_SYS_H */
139