#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/timer.h>
#include <linux/tty.h>
#include <linux/tty_driver.h>
#include <linux/tty_flip.h>
#include <linux/module.h>
#include <linux/spinlock.h>
#include <linux/uaccess.h>
#include <linux/atomic.h>
#include <linux/usb.h>
#include <linux/usb/serial.h>
static int initial_mode = …;
#define GARMIN_VENDOR_ID …
#define VERSION_MAJOR …
#define VERSION_MINOR …
#define _STR(s) …
#define _DRIVER_VERSION(a, b) …
#define DRIVER_VERSION …
#define DRIVER_AUTHOR …
#define DRIVER_DESC …
#define EINVPKT …
#define GARMIN_PKTHDR_LENGTH …
#define MAX_SERIAL_PKT_SIZ …
#define MAX_SERIAL_PKT_SIZ_STUFFED …
#define GPS_IN_BUFSIZ …
#define GPS_OUT_BUFSIZ …
#define GSP_INITIAL_OFFSET …
#define PRIVPKTSIZ …
#define GARMIN_LAYERID_TRANSPORT …
#define GARMIN_LAYERID_APPL …
#define GARMIN_LAYERID_PRIVATE …
#define GARMIN_PKTID_PVT_DATA …
#define GARMIN_PKTID_L001_COMMAND_DATA …
#define CMND_ABORT_TRANSFER …
#define PRIV_PKTID_SET_DEBUG …
#define PRIV_PKTID_SET_MODE …
#define PRIV_PKTID_INFO_REQ …
#define PRIV_PKTID_INFO_RESP …
#define PRIV_PKTID_RESET_REQ …
#define PRIV_PKTID_SET_DEF_MODE …
#define ETX …
#define DLE …
#define ACK …
#define NAK …
struct garmin_packet { … };
struct garmin_data { … };
#define STATE_NEW …
#define STATE_INITIAL_DELAY …
#define STATE_TIMEOUT …
#define STATE_SESSION_REQ1 …
#define STATE_SESSION_REQ2 …
#define STATE_ACTIVE …
#define STATE_RESET …
#define STATE_DISCONNECTED …
#define STATE_WAIT_TTY_ACK …
#define STATE_GSP_WAIT_DATA …
#define MODE_NATIVE …
#define MODE_GARMIN_SERIAL …
#define FLAGS_SESSION_REPLY_MASK …
#define FLAGS_SESSION_REPLY1_SEEN …
#define FLAGS_SESSION_REPLY2_SEEN …
#define FLAGS_BULK_IN_ACTIVE …
#define FLAGS_BULK_IN_RESTART …
#define FLAGS_THROTTLED …
#define APP_REQ_SEEN …
#define APP_RESP_SEEN …
#define CLEAR_HALT_REQUIRED …
#define FLAGS_QUEUING …
#define FLAGS_DROP_DATA …
#define FLAGS_GSP_SKIP …
#define FLAGS_GSP_DLESEEN …
static int gsp_next_packet(struct garmin_data *garmin_data_p);
static int garmin_write_bulk(struct usb_serial_port *port,
const unsigned char *buf, int count,
int dismiss_ack);
static unsigned char const GARMIN_START_SESSION_REQ[]
= …;
static unsigned char const GARMIN_START_SESSION_REPLY[]
= …;
static unsigned char const GARMIN_BULK_IN_AVAIL_REPLY[]
= …;
static unsigned char const GARMIN_STOP_TRANSFER_REQ[]
= …;
static unsigned char const GARMIN_STOP_TRANSFER_REQ_V2[]
= …;
#if 0
static unsigned char const GARMIN_APP_LAYER_REPLY[]
= { 0x14, 0, 0, 0 };
static unsigned char const GARMIN_START_PVT_REQ[]
= { 20, 0, 0, 0, 10, 0, 0, 0, 2, 0, 0, 0, 49, 0 };
static unsigned char const GARMIN_STOP_PVT_REQ[]
= { 20, 0, 0, 0, 10, 0, 0, 0, 2, 0, 0, 0, 50, 0 };
static unsigned char const PRIVATE_REQ[]
= { 0x4B, 0x6E, 0x10, 0x01, 0xFF, 0, 0, 0, 0xFF, 0, 0, 0 };
#endif
static const struct usb_device_id id_table[] = …;
MODULE_DEVICE_TABLE(usb, id_table);
static inline int getLayerId(const __u8 *usbPacket)
{ … }
static inline int getPacketId(const __u8 *usbPacket)
{ … }
static inline int getDataLength(const __u8 *usbPacket)
{ … }
static inline int isAbortTrfCmnd(const unsigned char *buf)
{ … }
static void send_to_tty(struct usb_serial_port *port,
char *data, unsigned int actual_length)
{ … }
static int pkt_add(struct garmin_data *garmin_data_p,
unsigned char *data, unsigned int data_length)
{ … }
static struct garmin_packet *pkt_pop(struct garmin_data *garmin_data_p)
{ … }
static void pkt_clear(struct garmin_data *garmin_data_p)
{ … }
static int gsp_send_ack(struct garmin_data *garmin_data_p, __u8 pkt_id)
{ … }
static int gsp_rec_packet(struct garmin_data *garmin_data_p, int count)
{ … }
static int gsp_receive(struct garmin_data *garmin_data_p,
const unsigned char *buf, int count)
{ … }
static int gsp_send(struct garmin_data *garmin_data_p,
const unsigned char *buf, int count)
{ … }
static int gsp_next_packet(struct garmin_data *garmin_data_p)
{ … }
static int nat_receive(struct garmin_data *garmin_data_p,
const unsigned char *buf, int count)
{ … }
static void priv_status_resp(struct usb_serial_port *port)
{ … }
static int process_resetdev_request(struct usb_serial_port *port)
{ … }
static int garmin_clear(struct garmin_data *garmin_data_p)
{ … }
static int garmin_init_session(struct usb_serial_port *port)
{ … }
static int garmin_open(struct tty_struct *tty, struct usb_serial_port *port)
{ … }
static void garmin_close(struct usb_serial_port *port)
{ … }
static void garmin_write_bulk_callback(struct urb *urb)
{ … }
static int garmin_write_bulk(struct usb_serial_port *port,
const unsigned char *buf, int count,
int dismiss_ack)
{ … }
static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port,
const unsigned char *buf, int count)
{ … }
static unsigned int garmin_write_room(struct tty_struct *tty)
{ … }
static void garmin_read_process(struct garmin_data *garmin_data_p,
unsigned char *data, unsigned data_length,
int bulk_data)
{ … }
static void garmin_read_bulk_callback(struct urb *urb)
{ … }
static void garmin_read_int_callback(struct urb *urb)
{ … }
static int garmin_flush_queue(struct garmin_data *garmin_data_p)
{ … }
static void garmin_throttle(struct tty_struct *tty)
{ … }
static void garmin_unthrottle(struct tty_struct *tty)
{ … }
static void timeout_handler(struct timer_list *t)
{ … }
static int garmin_port_probe(struct usb_serial_port *port)
{ … }
static void garmin_port_remove(struct usb_serial_port *port)
{ … }
static struct usb_serial_driver garmin_device = …;
static struct usb_serial_driver * const serial_drivers[] = …;
module_usb_serial_driver(…);
MODULE_AUTHOR(…);
MODULE_DESCRIPTION(…);
MODULE_LICENSE(…) …;
module_param(initial_mode, int, 0444);
MODULE_PARM_DESC(…) …;