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