hvsi.h 2.7 KB

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