18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * interface to the SCLP-read/write driver
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright IBM Corporation 1999, 2009
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Author(s): Martin Peschke <mpeschke@de.ibm.com>
88c2ecf20Sopenharmony_ci *	      Martin Schwidefsky <schwidefsky@de.ibm.com>
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#ifndef __SCLP_RW_H__
128c2ecf20Sopenharmony_ci#define __SCLP_RW_H__
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#include <linux/list.h>
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_cistruct mto {
178c2ecf20Sopenharmony_ci	u16 length;
188c2ecf20Sopenharmony_ci	u16 type;
198c2ecf20Sopenharmony_ci	u16 line_type_flags;
208c2ecf20Sopenharmony_ci	u8  alarm_control;
218c2ecf20Sopenharmony_ci	u8  _reserved[3];
228c2ecf20Sopenharmony_ci} __attribute__((packed));
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_cistruct go {
258c2ecf20Sopenharmony_ci	u16 length;
268c2ecf20Sopenharmony_ci	u16 type;
278c2ecf20Sopenharmony_ci	u32 domid;
288c2ecf20Sopenharmony_ci	u8  hhmmss_time[8];
298c2ecf20Sopenharmony_ci	u8  th_time[3];
308c2ecf20Sopenharmony_ci	u8  reserved_0;
318c2ecf20Sopenharmony_ci	u8  dddyyyy_date[7];
328c2ecf20Sopenharmony_ci	u8  _reserved_1;
338c2ecf20Sopenharmony_ci	u16 general_msg_flags;
348c2ecf20Sopenharmony_ci	u8  _reserved_2[10];
358c2ecf20Sopenharmony_ci	u8  originating_system_name[8];
368c2ecf20Sopenharmony_ci	u8  job_guest_name[8];
378c2ecf20Sopenharmony_ci} __attribute__((packed));
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_cistruct mdb_header {
408c2ecf20Sopenharmony_ci	u16 length;
418c2ecf20Sopenharmony_ci	u16 type;
428c2ecf20Sopenharmony_ci	u32 tag;
438c2ecf20Sopenharmony_ci	u32 revision_code;
448c2ecf20Sopenharmony_ci} __attribute__((packed));
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_cistruct mdb {
478c2ecf20Sopenharmony_ci	struct mdb_header header;
488c2ecf20Sopenharmony_ci	struct go go;
498c2ecf20Sopenharmony_ci	struct mto mto;
508c2ecf20Sopenharmony_ci} __attribute__((packed));
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_cistruct msg_buf {
538c2ecf20Sopenharmony_ci	struct evbuf_header header;
548c2ecf20Sopenharmony_ci	struct mdb mdb;
558c2ecf20Sopenharmony_ci} __attribute__((packed));
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci/* The number of empty mto buffers that can be contained in a single sccb. */
588c2ecf20Sopenharmony_ci#define NR_EMPTY_MSG_PER_SCCB ((PAGE_SIZE - sizeof(struct sclp_buffer) - \
598c2ecf20Sopenharmony_ci			sizeof(struct sccb_header)) / sizeof(struct msg_buf))
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci/*
628c2ecf20Sopenharmony_ci * data structure for information about list of SCCBs (only for writing),
638c2ecf20Sopenharmony_ci * will be located at the end of a SCCBs page
648c2ecf20Sopenharmony_ci */
658c2ecf20Sopenharmony_cistruct sclp_buffer {
668c2ecf20Sopenharmony_ci	struct list_head list;		/* list_head for sccb_info chain */
678c2ecf20Sopenharmony_ci	struct sclp_req request;
688c2ecf20Sopenharmony_ci	void *sccb;
698c2ecf20Sopenharmony_ci	struct msg_buf *current_msg;
708c2ecf20Sopenharmony_ci	char *current_line;
718c2ecf20Sopenharmony_ci	int current_length;
728c2ecf20Sopenharmony_ci	int retry_count;
738c2ecf20Sopenharmony_ci	/* output format settings */
748c2ecf20Sopenharmony_ci	unsigned short columns;
758c2ecf20Sopenharmony_ci	unsigned short htab;
768c2ecf20Sopenharmony_ci	/* statistics about this buffer */
778c2ecf20Sopenharmony_ci	unsigned int char_sum;		/* # chars in sccb */
788c2ecf20Sopenharmony_ci	unsigned int messages;		/* # messages in sccb */
798c2ecf20Sopenharmony_ci	/* Callback that is called after reaching final status. */
808c2ecf20Sopenharmony_ci	void (*callback)(struct sclp_buffer *, int);
818c2ecf20Sopenharmony_ci};
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ciint sclp_rw_init(void);
848c2ecf20Sopenharmony_cistruct sclp_buffer *sclp_make_buffer(void *, unsigned short, unsigned short);
858c2ecf20Sopenharmony_civoid *sclp_unmake_buffer(struct sclp_buffer *);
868c2ecf20Sopenharmony_ciint sclp_buffer_space(struct sclp_buffer *);
878c2ecf20Sopenharmony_ciint sclp_write(struct sclp_buffer *buffer, const unsigned char *, int);
888c2ecf20Sopenharmony_ciint sclp_emit_buffer(struct sclp_buffer *,void (*)(struct sclp_buffer *,int));
898c2ecf20Sopenharmony_ciint sclp_chars_in_buffer(struct sclp_buffer *);
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci#ifdef CONFIG_SCLP_CONSOLE
928c2ecf20Sopenharmony_civoid sclp_console_pm_event(enum sclp_pm_event sclp_pm_event);
938c2ecf20Sopenharmony_ci#else
948c2ecf20Sopenharmony_cistatic inline void sclp_console_pm_event(enum sclp_pm_event sclp_pm_event) { }
958c2ecf20Sopenharmony_ci#endif
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci#endif	/* __SCLP_RW_H__ */
98