xref: /linux/drivers/s390/char/sclp_rw.h (revision ca55b2fef3a9373fcfc30f82fd26bc7fccbda732)
1 /*
2  * interface to the SCLP-read/write driver
3  *
4  * Copyright IBM Corporation 1999, 2009
5  *
6  * Author(s): Martin Peschke <mpeschke@de.ibm.com>
7  *	      Martin Schwidefsky <schwidefsky@de.ibm.com>
8  */
9 
10 #ifndef __SCLP_RW_H__
11 #define __SCLP_RW_H__
12 
13 #include <linux/list.h>
14 
15 struct mto {
16 	u16 length;
17 	u16 type;
18 	u16 line_type_flags;
19 	u8  alarm_control;
20 	u8  _reserved[3];
21 } __attribute__((packed));
22 
23 struct go {
24 	u16 length;
25 	u16 type;
26 	u32 domid;
27 	u8  hhmmss_time[8];
28 	u8  th_time[3];
29 	u8  reserved_0;
30 	u8  dddyyyy_date[7];
31 	u8  _reserved_1;
32 	u16 general_msg_flags;
33 	u8  _reserved_2[10];
34 	u8  originating_system_name[8];
35 	u8  job_guest_name[8];
36 } __attribute__((packed));
37 
38 struct mdb_header {
39 	u16 length;
40 	u16 type;
41 	u32 tag;
42 	u32 revision_code;
43 } __attribute__((packed));
44 
45 struct mdb {
46 	struct mdb_header header;
47 	struct go go;
48 } __attribute__((packed));
49 
50 struct msg_buf {
51 	struct evbuf_header header;
52 	struct mdb mdb;
53 } __attribute__((packed));
54 
55 struct write_sccb {
56 	struct sccb_header header;
57 	struct msg_buf msg_buf;
58 } __attribute__((packed));
59 
60 /* The number of empty mto buffers that can be contained in a single sccb. */
61 #define NR_EMPTY_MTO_PER_SCCB ((PAGE_SIZE - sizeof(struct sclp_buffer) - \
62 			sizeof(struct write_sccb)) / sizeof(struct mto))
63 
64 /*
65  * data structure for information about list of SCCBs (only for writing),
66  * will be located at the end of a SCCBs page
67  */
68 struct sclp_buffer {
69 	struct list_head list;		/* list_head for sccb_info chain */
70 	struct sclp_req request;
71 	struct write_sccb *sccb;
72 	char *current_line;
73 	int current_length;
74 	int retry_count;
75 	/* output format settings */
76 	unsigned short columns;
77 	unsigned short htab;
78 	/* statistics about this buffer */
79 	unsigned int mto_char_sum;	/* # chars in sccb */
80 	unsigned int mto_number;	/* # mtos in sccb */
81 	/* Callback that is called after reaching final status. */
82 	void (*callback)(struct sclp_buffer *, int);
83 };
84 
85 int sclp_rw_init(void);
86 struct sclp_buffer *sclp_make_buffer(void *, unsigned short, unsigned short);
87 void *sclp_unmake_buffer(struct sclp_buffer *);
88 int sclp_buffer_space(struct sclp_buffer *);
89 int sclp_write(struct sclp_buffer *buffer, const unsigned char *, int);
90 int sclp_emit_buffer(struct sclp_buffer *,void (*)(struct sclp_buffer *,int));
91 void sclp_set_columns(struct sclp_buffer *, unsigned short);
92 void sclp_set_htab(struct sclp_buffer *, unsigned short);
93 int sclp_chars_in_buffer(struct sclp_buffer *);
94 
95 #ifdef CONFIG_SCLP_CONSOLE
96 void sclp_console_pm_event(enum sclp_pm_event sclp_pm_event);
97 #else
98 static inline void sclp_console_pm_event(enum sclp_pm_event sclp_pm_event) { }
99 #endif
100 
101 #endif	/* __SCLP_RW_H__ */
102