1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
/*
* User Mode Init manager - For shared transport
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program;if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef UIM_H
#define UIM_H
/* Paramaters to set the baud rate*/
#define FLOW_CTL 0x0001
#define BOTHER 0x00001000
#define ARM_NCCS 19
#define TCGETS2 _IOR('T',0x2A, struct termios2)
#define TCSETS2 _IOW('T',0x2B, struct termios2)
/*HCI Command and Event information*/
#define HCI_HDR_OPCODE 0xff36
#define WRITE_BD_ADDR_OPCODE 0xFC06
#define RESP_PREFIX 0x04
#define MAX_TRY 10
/* HCI Packet types */
#define HCI_COMMAND_PKT 0x01
#define HCI_EVENT_PKT 0x04
/* HCI command macros*/
#define HCI_EVENT_HDR_SIZE 2
#define HCI_COMMAND_HDR_SIZE 3
#define UIM_WRITE_BD_ADDR_CP_SIZE 6
/* HCI event macros*/
#define EVT_CMD_COMPLETE_SIZE 3
#define EVT_CMD_STATUS_SIZE 4
#define EVT_CMD_COMPLETE 0x0E
#define EVT_CMD_STATUS 0x0F
#define VERBOSE
#ifndef ANDROID
#define LOGE printf
#endif /* ANDROID */
#define LOG_TAG "uim-rfkill: "
#define UIM_ERR(fmt, arg...) LOGE("uim:"fmt"\n" , ##arg)
#if defined(UIM_DEBUG) /* limited debug messages */
#define UIM_START_FUNC() LOGE("uim: Inside %s\n", __FUNCTION__)
#define UIM_DBG(fmt, arg...) LOGE("uim:"fmt"\n" , ## arg)
#define UIM_VER(fmt, arg...)
#elif defined(VERBOSE) /* very verbose */
#define UIM_START_FUNC() LOGE("uim: Inside %s\n", __FUNCTION__)
#define UIM_DBG(fmt, arg...) LOGE("uim:"fmt"\n" , ## arg)
#define UIM_VER(fmt, arg...) LOGE("uim:"fmt"\n" , ## arg)
#else /* error msgs only */
#define UIM_START_FUNC()
#define UIM_DBG(fmt, arg...)
#define UIM_VER(fmt, arg...)
#endif
/*Termios2 structure for setting the Custom baud rate*/
struct termios2 {
tcflag_t c_iflag; /* input mode flags */
tcflag_t c_oflag; /* output mode flags */
tcflag_t c_cflag; /* control mode flags */
tcflag_t c_lflag; /* local mode flags */
cc_t c_line; /* line discipline */
cc_t c_cc[ARM_NCCS]; /* control characters */
speed_t c_ispeed; /* input speed */
speed_t c_ospeed; /* output speed */
};
/* HCI command header*/
typedef struct {
uint16_t opcode; /* OCF & OGF */
uint8_t plen;
} __attribute__ ((packed)) hci_command_hdr;
/* HCI event header*/
typedef struct {
uint8_t evt;
uint8_t plen;
} __attribute__ ((packed)) hci_event_hdr;
/* HCI command complete event*/
typedef struct {
uint8_t ncmd;
uint16_t opcode;
} __attribute__ ((packed)) evt_cmd_complete;
/* HCI event status*/
typedef struct {
uint8_t status;
uint8_t ncmd;
uint16_t opcode;
} __attribute__ ((packed)) evt_cmd_status;
/* HCI Event structure to set the cusrom baud rate*/
typedef struct {
uint8_t uart_prefix;
hci_event_hdr hci_hdr;
evt_cmd_complete cmd_complete;
uint8_t status;
uint8_t data[16];
} __attribute__ ((packed)) command_complete_t;
/* HCI Command structure to set the cusrom baud rate*/
typedef struct {
uint8_t uart_prefix;
hci_command_hdr hci_hdr;
uint32_t speed;
} __attribute__ ((packed)) uim_speed_change_cmd;
/* BD address structure to set the uim BD address*/
typedef struct {
unsigned char b[6];
} __attribute__((packed)) bdaddr_t;
/* HCI Command structure to set the uim BD address*/
typedef struct {
uint8_t uart_prefix;
hci_command_hdr hci_hdr;
bdaddr_t addr;
} __attribute__ ((packed)) uim_bdaddr_change_cmd;
/* Signal received from KIM will install line discipline at first,
* the next signal received from KIM will un-install the
* line discipline*/
enum {
/* expecting signal from KIM to setup uart fd for ST */
INSTALL_N_TI_WL,
/* expecting signal from KIM to close uart fd */
UNINSTALL_N_TI_WL,
};
/* Functions to insert and remove the kernel modules from the system*/
extern int init_module(void *, unsigned int, const char *);
extern int delete_module(const char *, unsigned int);
extern int load_file(const char *, unsigned int *);
#endif /* UIM_H */
|