hvsi.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _HVSI_H
  3. #define _HVSI_H
  4. #define VS_DATA_PACKET_HEADER 0xff
  5. #define VS_CONTROL_PACKET_HEADER 0xfe
  6. #define VS_QUERY_PACKET_HEADER 0xfd
  7. #define VS_QUERY_RESPONSE_PACKET_HEADER 0xfc
  8. /* control verbs */
  9. #define VSV_SET_MODEM_CTL 1 /* to service processor only */
  10. #define VSV_MODEM_CTL_UPDATE 2 /* from service processor only */
  11. #define VSV_CLOSE_PROTOCOL 3
  12. /* query verbs */
  13. #define VSV_SEND_VERSION_NUMBER 1
  14. #define VSV_SEND_MODEM_CTL_STATUS 2
  15. /* yes, these masks are not consecutive. */
  16. #define HVSI_TSDTR 0x01
  17. #define HVSI_TSCD 0x20
  18. #define HVSI_MAX_OUTGOING_DATA 12
  19. #define HVSI_VERSION 1
  20. struct hvsi_header {
  21. uint8_t type;
  22. uint8_t len;
  23. __be16 seqno;
  24. } __attribute__((packed));
  25. struct hvsi_data {
  26. struct hvsi_header hdr;
  27. uint8_t data[HVSI_MAX_OUTGOING_DATA];
  28. } __attribute__((packed));
  29. struct hvsi_control {
  30. struct hvsi_header hdr;
  31. __be16 verb;
  32. /* optional depending on verb: */
  33. __be32 word;
  34. __be32 mask;
  35. } __attribute__((packed));
  36. struct hvsi_query {
  37. struct hvsi_header hdr;
  38. __be16 verb;
  39. } __attribute__((packed));
  40. struct hvsi_query_response {
  41. struct hvsi_header hdr;
  42. __be16 verb;
  43. __be16 query_seqno;
  44. union {
  45. uint8_t version;
  46. __be32 mctrl_word;
  47. } u;
  48. } __attribute__((packed));
  49. /* hvsi lib struct definitions */
  50. #define HVSI_INBUF_SIZE 255
  51. struct tty_struct;
  52. struct hvsi_priv {
  53. unsigned int inbuf_len; /* data in input buffer */
  54. unsigned char inbuf[HVSI_INBUF_SIZE];
  55. unsigned int inbuf_cur; /* Cursor in input buffer */
  56. unsigned int inbuf_pktlen; /* packet length from cursor */
  57. atomic_t seqno; /* packet sequence number */
  58. unsigned int opened:1; /* driver opened */
  59. unsigned int established:1; /* protocol established */
  60. unsigned int is_console:1; /* used as a kernel console device */
  61. unsigned int mctrl_update:1; /* modem control updated */
  62. unsigned short mctrl; /* modem control */
  63. struct tty_struct *tty; /* tty structure */
  64. int (*get_chars)(uint32_t termno, char *buf, int count);
  65. int (*put_chars)(uint32_t termno, const char *buf, int count);
  66. uint32_t termno;
  67. };
  68. /* hvsi lib functions */
  69. struct hvc_struct;
  70. extern void hvsilib_init(struct hvsi_priv *pv,
  71. int (*get_chars)(uint32_t termno, char *buf, int count),
  72. int (*put_chars)(uint32_t termno, const char *buf,
  73. int count),
  74. int termno, int is_console);
  75. extern int hvsilib_open(struct hvsi_priv *pv, struct hvc_struct *hp);
  76. extern void hvsilib_close(struct hvsi_priv *pv, struct hvc_struct *hp);
  77. extern int hvsilib_read_mctrl(struct hvsi_priv *pv);
  78. extern int hvsilib_write_mctrl(struct hvsi_priv *pv, int dtr);
  79. extern void hvsilib_establish(struct hvsi_priv *pv);
  80. extern int hvsilib_get_chars(struct hvsi_priv *pv, char *buf, int count);
  81. extern int hvsilib_put_chars(struct hvsi_priv *pv, const char *buf, int count);
  82. #endif /* _HVSI_H */