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