2011-06-16 23:08:12 +08:00
|
|
|
#ifndef _HVSI_H
|
|
|
|
#define _HVSI_H
|
|
|
|
|
|
|
|
#define VS_DATA_PACKET_HEADER 0xff
|
|
|
|
#define VS_CONTROL_PACKET_HEADER 0xfe
|
|
|
|
#define VS_QUERY_PACKET_HEADER 0xfd
|
|
|
|
#define VS_QUERY_RESPONSE_PACKET_HEADER 0xfc
|
|
|
|
|
|
|
|
/* control verbs */
|
|
|
|
#define VSV_SET_MODEM_CTL 1 /* to service processor only */
|
|
|
|
#define VSV_MODEM_CTL_UPDATE 2 /* from service processor only */
|
|
|
|
#define VSV_CLOSE_PROTOCOL 3
|
|
|
|
|
|
|
|
/* query verbs */
|
|
|
|
#define VSV_SEND_VERSION_NUMBER 1
|
|
|
|
#define VSV_SEND_MODEM_CTL_STATUS 2
|
|
|
|
|
|
|
|
/* yes, these masks are not consecutive. */
|
|
|
|
#define HVSI_TSDTR 0x01
|
|
|
|
#define HVSI_TSCD 0x20
|
|
|
|
|
|
|
|
#define HVSI_MAX_OUTGOING_DATA 12
|
|
|
|
#define HVSI_VERSION 1
|
|
|
|
|
|
|
|
struct hvsi_header {
|
|
|
|
uint8_t type;
|
|
|
|
uint8_t len;
|
2013-09-23 10:05:07 +08:00
|
|
|
__be16 seqno;
|
2011-06-16 23:08:12 +08:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct hvsi_data {
|
2011-06-16 23:08:24 +08:00
|
|
|
struct hvsi_header hdr;
|
2011-06-16 23:08:12 +08:00
|
|
|
uint8_t data[HVSI_MAX_OUTGOING_DATA];
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct hvsi_control {
|
2011-06-16 23:08:24 +08:00
|
|
|
struct hvsi_header hdr;
|
2013-09-23 10:05:07 +08:00
|
|
|
__be16 verb;
|
2011-06-16 23:08:12 +08:00
|
|
|
/* optional depending on verb: */
|
2013-09-23 10:05:07 +08:00
|
|
|
__be32 word;
|
|
|
|
__be32 mask;
|
2011-06-16 23:08:12 +08:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct hvsi_query {
|
2011-06-16 23:08:24 +08:00
|
|
|
struct hvsi_header hdr;
|
2013-09-23 10:05:07 +08:00
|
|
|
__be16 verb;
|
2011-06-16 23:08:12 +08:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
struct hvsi_query_response {
|
2011-06-16 23:08:24 +08:00
|
|
|
struct hvsi_header hdr;
|
2013-09-23 10:05:07 +08:00
|
|
|
__be16 verb;
|
|
|
|
__be16 query_seqno;
|
2011-06-16 23:08:12 +08:00
|
|
|
union {
|
|
|
|
uint8_t version;
|
2013-09-23 10:05:07 +08:00
|
|
|
__be32 mctrl_word;
|
2011-06-16 23:08:12 +08:00
|
|
|
} u;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2011-04-29 14:44:24 +08:00
|
|
|
/* hvsi lib struct definitions */
|
|
|
|
#define HVSI_INBUF_SIZE 255
|
|
|
|
struct tty_struct;
|
|
|
|
struct hvsi_priv {
|
|
|
|
unsigned int inbuf_len; /* data in input buffer */
|
|
|
|
unsigned char inbuf[HVSI_INBUF_SIZE];
|
|
|
|
unsigned int inbuf_cur; /* Cursor in input buffer */
|
|
|
|
unsigned int inbuf_pktlen; /* packet lenght from cursor */
|
|
|
|
atomic_t seqno; /* packet sequence number */
|
|
|
|
unsigned int opened:1; /* driver opened */
|
|
|
|
unsigned int established:1; /* protocol established */
|
|
|
|
unsigned int is_console:1; /* used as a kernel console device */
|
|
|
|
unsigned int mctrl_update:1; /* modem control updated */
|
|
|
|
unsigned short mctrl; /* modem control */
|
|
|
|
struct tty_struct *tty; /* tty structure */
|
|
|
|
int (*get_chars)(uint32_t termno, char *buf, int count);
|
|
|
|
int (*put_chars)(uint32_t termno, const char *buf, int count);
|
|
|
|
uint32_t termno;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* hvsi lib functions */
|
|
|
|
struct hvc_struct;
|
2011-07-01 11:10:21 +08:00
|
|
|
extern void hvsilib_init(struct hvsi_priv *pv,
|
|
|
|
int (*get_chars)(uint32_t termno, char *buf, int count),
|
|
|
|
int (*put_chars)(uint32_t termno, const char *buf,
|
|
|
|
int count),
|
|
|
|
int termno, int is_console);
|
|
|
|
extern int hvsilib_open(struct hvsi_priv *pv, struct hvc_struct *hp);
|
|
|
|
extern void hvsilib_close(struct hvsi_priv *pv, struct hvc_struct *hp);
|
|
|
|
extern int hvsilib_read_mctrl(struct hvsi_priv *pv);
|
|
|
|
extern int hvsilib_write_mctrl(struct hvsi_priv *pv, int dtr);
|
|
|
|
extern void hvsilib_establish(struct hvsi_priv *pv);
|
|
|
|
extern int hvsilib_get_chars(struct hvsi_priv *pv, char *buf, int count);
|
|
|
|
extern int hvsilib_put_chars(struct hvsi_priv *pv, const char *buf, int count);
|
2011-06-16 23:08:12 +08:00
|
|
|
|
|
|
|
#endif /* _HVSI_H */
|