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