Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _HVSI_H
0003 #define _HVSI_H
0004 
0005 #define VS_DATA_PACKET_HEADER           0xff
0006 #define VS_CONTROL_PACKET_HEADER        0xfe
0007 #define VS_QUERY_PACKET_HEADER          0xfd
0008 #define VS_QUERY_RESPONSE_PACKET_HEADER 0xfc
0009 
0010 /* control verbs */
0011 #define VSV_SET_MODEM_CTL    1 /* to service processor only */
0012 #define VSV_MODEM_CTL_UPDATE 2 /* from service processor only */
0013 #define VSV_CLOSE_PROTOCOL   3
0014 
0015 /* query verbs */
0016 #define VSV_SEND_VERSION_NUMBER 1
0017 #define VSV_SEND_MODEM_CTL_STATUS 2
0018 
0019 /* yes, these masks are not consecutive. */
0020 #define HVSI_TSDTR 0x01
0021 #define HVSI_TSCD  0x20
0022 
0023 #define HVSI_MAX_OUTGOING_DATA 12
0024 #define HVSI_VERSION 1
0025 
0026 struct hvsi_header {
0027     uint8_t  type;
0028     uint8_t  len;
0029     __be16 seqno;
0030 } __attribute__((packed));
0031 
0032 struct hvsi_data {
0033     struct hvsi_header hdr;
0034     uint8_t  data[HVSI_MAX_OUTGOING_DATA];
0035 } __attribute__((packed));
0036 
0037 struct hvsi_control {
0038     struct hvsi_header hdr;
0039     __be16 verb;
0040     /* optional depending on verb: */
0041     __be32 word;
0042     __be32 mask;
0043 } __attribute__((packed));
0044 
0045 struct hvsi_query {
0046     struct hvsi_header hdr;
0047     __be16 verb;
0048 } __attribute__((packed));
0049 
0050 struct hvsi_query_response {
0051     struct hvsi_header hdr;
0052     __be16 verb;
0053     __be16 query_seqno;
0054     union {
0055         uint8_t  version;
0056         __be32 mctrl_word;
0057     } u;
0058 } __attribute__((packed));
0059 
0060 /* hvsi lib struct definitions */
0061 #define HVSI_INBUF_SIZE     255
0062 struct tty_struct;
0063 struct hvsi_priv {
0064     unsigned int    inbuf_len;  /* data in input buffer */
0065     unsigned char   inbuf[HVSI_INBUF_SIZE];
0066     unsigned int    inbuf_cur;  /* Cursor in input buffer */
0067     unsigned int    inbuf_pktlen;   /* packet length from cursor */
0068     atomic_t    seqno;      /* packet sequence number */
0069     unsigned int    opened:1;   /* driver opened */
0070     unsigned int    established:1;  /* protocol established */
0071     unsigned int    is_console:1;   /* used as a kernel console device */
0072     unsigned int    mctrl_update:1; /* modem control updated */
0073     unsigned short  mctrl;      /* modem control */
0074     struct tty_struct *tty;     /* tty structure */
0075     int (*get_chars)(uint32_t termno, char *buf, int count);
0076     int (*put_chars)(uint32_t termno, const char *buf, int count);
0077     uint32_t    termno;
0078 };
0079 
0080 /* hvsi lib functions */
0081 struct hvc_struct;
0082 extern void hvsilib_init(struct hvsi_priv *pv,
0083              int (*get_chars)(uint32_t termno, char *buf, int count),
0084              int (*put_chars)(uint32_t termno, const char *buf,
0085                       int count),
0086              int termno, int is_console);
0087 extern int hvsilib_open(struct hvsi_priv *pv, struct hvc_struct *hp);
0088 extern void hvsilib_close(struct hvsi_priv *pv, struct hvc_struct *hp);
0089 extern int hvsilib_read_mctrl(struct hvsi_priv *pv);
0090 extern int hvsilib_write_mctrl(struct hvsi_priv *pv, int dtr);
0091 extern void hvsilib_establish(struct hvsi_priv *pv);
0092 extern int hvsilib_get_chars(struct hvsi_priv *pv, char *buf, int count);
0093 extern int hvsilib_put_chars(struct hvsi_priv *pv, const char *buf, int count);
0094 
0095 #endif /* _HVSI_H */