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