/*
* 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
/* the line discipline ideally should be coming
* from tty.h
*/
#define N_TI_WL 22
/* Paramaters to set the baud rate*/
#define FLOW_CTL 0x0001
#define ARM_NCCS 19
#ifndef TCGETS2
#define TCGETS2 _IOR('T',0x2A, struct termios2)
#endif
#ifndef TCSETS2
#define TCSETS2 _IOW('T',0x2B, struct termios2)
#endif
/*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 HCI_COMMAND_HDR_SIZE 3
/* 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
/* use it for string lengths and buffers */
#define UART_DEV_NAME_LEN 32
/* BD address length in format xx:xx:xx:xx:xx:xx */
#define BD_ADDR_LEN 17
/* the sysfs entries with device configuration set by
* shared transport driver
*/
#define INSTALL_SYSFS_ENTRY "/sys/devices/platform/kim/install"
#define DEV_NAME_SYSFS "/sys/devices/platform/kim/dev_name"
#define BAUD_RATE_SYSFS "/sys/devices/platform/kim/baud_rate"
#define FLOW_CTRL_SYSFS "/sys/devices/platform/kim/flow_cntrl"
#define INSTALL_SYSFS_ENTRY_OLD "/sys/devices/kim/install"
#define DEV_NAME_SYSFS_OLD "/sys/devices/kim/dev_name"
#define BAUD_RATE_SYSFS_OLD "/sys/devices/kim/baud_rate"
#define FLOW_CTRL_SYSFS_OLD "/sys/devices/kim/flow_cntrl"
#define VERBOSE
/*Debug logs*/
#define UIM_ERR(fmt, arg...) printf("uim:"fmt"\n" , ##arg)
#if defined(UIM_DEBUG) /* limited debug messages */
#define UIM_START_FUNC() printf("uim: Inside %s", __FUNCTION__)
#define UIM_DBG(fmt, arg...) printf("uim:"fmt"\n" , ## arg)
#define UIM_VER(fmt, arg...)
#elif defined(VERBOSE) /* very verbose */
#define UIM_START_FUNC() printf("uim:@ %s\n", __FUNCTION__)
#define UIM_DBG(fmt, arg...) printf("uim:"fmt"\n" , ## arg)
#define UIM_VER(fmt, arg...) printf("uim:"fmt"\n" , ## arg)
#else /* error msgs only */
#define UIM_START_FUNC()
#define UIM_DBG(fmt, arg...)
#define UIM_VER(fmt, arg...)
#endif
/* 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;\
#endif /* UIM_H */