1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 21da177e4SLinus Torvalds /* 31da177e4SLinus Torvalds * interface to the SCLP-read/write driver 41da177e4SLinus Torvalds * 562b74942SMichael Holzheu * Copyright IBM Corporation 1999, 2009 662b74942SMichael Holzheu * 71da177e4SLinus Torvalds * Author(s): Martin Peschke <mpeschke@de.ibm.com> 81da177e4SLinus Torvalds * Martin Schwidefsky <schwidefsky@de.ibm.com> 91da177e4SLinus Torvalds */ 101da177e4SLinus Torvalds 111da177e4SLinus Torvalds #ifndef __SCLP_RW_H__ 121da177e4SLinus Torvalds #define __SCLP_RW_H__ 131da177e4SLinus Torvalds 141da177e4SLinus Torvalds #include <linux/list.h> 151da177e4SLinus Torvalds 161da177e4SLinus Torvalds struct mto { 171da177e4SLinus Torvalds u16 length; 181da177e4SLinus Torvalds u16 type; 191da177e4SLinus Torvalds u16 line_type_flags; 201da177e4SLinus Torvalds u8 alarm_control; 211da177e4SLinus Torvalds u8 _reserved[3]; 221da177e4SLinus Torvalds } __attribute__((packed)); 231da177e4SLinus Torvalds 241da177e4SLinus Torvalds struct go { 251da177e4SLinus Torvalds u16 length; 261da177e4SLinus Torvalds u16 type; 271da177e4SLinus Torvalds u32 domid; 281da177e4SLinus Torvalds u8 hhmmss_time[8]; 291da177e4SLinus Torvalds u8 th_time[3]; 301da177e4SLinus Torvalds u8 reserved_0; 311da177e4SLinus Torvalds u8 dddyyyy_date[7]; 321da177e4SLinus Torvalds u8 _reserved_1; 331da177e4SLinus Torvalds u16 general_msg_flags; 341da177e4SLinus Torvalds u8 _reserved_2[10]; 351da177e4SLinus Torvalds u8 originating_system_name[8]; 361da177e4SLinus Torvalds u8 job_guest_name[8]; 371da177e4SLinus Torvalds } __attribute__((packed)); 381da177e4SLinus Torvalds 391da177e4SLinus Torvalds struct mdb_header { 401da177e4SLinus Torvalds u16 length; 411da177e4SLinus Torvalds u16 type; 421da177e4SLinus Torvalds u32 tag; 431da177e4SLinus Torvalds u32 revision_code; 441da177e4SLinus Torvalds } __attribute__((packed)); 451da177e4SLinus Torvalds 461da177e4SLinus Torvalds struct mdb { 471da177e4SLinus Torvalds struct mdb_header header; 481da177e4SLinus Torvalds struct go go; 4918d1a7f6SMartin Schwidefsky struct mto mto; 501da177e4SLinus Torvalds } __attribute__((packed)); 511da177e4SLinus Torvalds 521da177e4SLinus Torvalds struct msg_buf { 531da177e4SLinus Torvalds struct evbuf_header header; 541da177e4SLinus Torvalds struct mdb mdb; 551da177e4SLinus Torvalds } __attribute__((packed)); 561da177e4SLinus Torvalds 571da177e4SLinus Torvalds /* The number of empty mto buffers that can be contained in a single sccb. */ 5818d1a7f6SMartin Schwidefsky #define NR_EMPTY_MSG_PER_SCCB ((PAGE_SIZE - sizeof(struct sclp_buffer) - \ 5918d1a7f6SMartin Schwidefsky sizeof(struct sccb_header)) / sizeof(struct msg_buf)) 601da177e4SLinus Torvalds 611da177e4SLinus Torvalds /* 621da177e4SLinus Torvalds * data structure for information about list of SCCBs (only for writing), 631da177e4SLinus Torvalds * will be located at the end of a SCCBs page 641da177e4SLinus Torvalds */ 651da177e4SLinus Torvalds struct sclp_buffer { 661da177e4SLinus Torvalds struct list_head list; /* list_head for sccb_info chain */ 671da177e4SLinus Torvalds struct sclp_req request; 6818d1a7f6SMartin Schwidefsky void *sccb; 6918d1a7f6SMartin Schwidefsky struct msg_buf *current_msg; 701da177e4SLinus Torvalds char *current_line; 711da177e4SLinus Torvalds int current_length; 721da177e4SLinus Torvalds int retry_count; 731da177e4SLinus Torvalds /* output format settings */ 741da177e4SLinus Torvalds unsigned short columns; 751da177e4SLinus Torvalds unsigned short htab; 761da177e4SLinus Torvalds /* statistics about this buffer */ 7718d1a7f6SMartin Schwidefsky unsigned int char_sum; /* # chars in sccb */ 7818d1a7f6SMartin Schwidefsky unsigned int messages; /* # messages in sccb */ 791da177e4SLinus Torvalds /* Callback that is called after reaching final status. */ 801da177e4SLinus Torvalds void (*callback)(struct sclp_buffer *, int); 811da177e4SLinus Torvalds }; 821da177e4SLinus Torvalds 831da177e4SLinus Torvalds int sclp_rw_init(void); 841da177e4SLinus Torvalds struct sclp_buffer *sclp_make_buffer(void *, unsigned short, unsigned short); 851da177e4SLinus Torvalds void *sclp_unmake_buffer(struct sclp_buffer *); 861da177e4SLinus Torvalds int sclp_buffer_space(struct sclp_buffer *); 871da177e4SLinus Torvalds int sclp_write(struct sclp_buffer *buffer, const unsigned char *, int); 881da177e4SLinus Torvalds int sclp_emit_buffer(struct sclp_buffer *,void (*)(struct sclp_buffer *,int)); 89*fff4ef17SJiri Slaby unsigned int sclp_chars_in_buffer(struct sclp_buffer *); 901da177e4SLinus Torvalds 911da177e4SLinus Torvalds #endif /* __SCLP_RW_H__ */ 92