xref: /linux/arch/s390/include/asm/diag.h (revision 1ec2772e0c3ca3159035c03165355e355efc326b)
1c6557e7fSMartin Schwidefsky /*
2c6557e7fSMartin Schwidefsky  * s390 diagnose functions
3c6557e7fSMartin Schwidefsky  *
4c6557e7fSMartin Schwidefsky  * Copyright IBM Corp. 2007
5c6557e7fSMartin Schwidefsky  * Author(s): Michael Holzheu <holzheu@de.ibm.com>
6c6557e7fSMartin Schwidefsky  */
7c6557e7fSMartin Schwidefsky 
8c6557e7fSMartin Schwidefsky #ifndef _ASM_S390_DIAG_H
9c6557e7fSMartin Schwidefsky #define _ASM_S390_DIAG_H
10c6557e7fSMartin Schwidefsky 
11*1ec2772eSMartin Schwidefsky #include <linux/percpu.h>
12*1ec2772eSMartin Schwidefsky 
13*1ec2772eSMartin Schwidefsky enum diag_stat_enum {
14*1ec2772eSMartin Schwidefsky 	DIAG_STAT_X008,
15*1ec2772eSMartin Schwidefsky 	DIAG_STAT_X00C,
16*1ec2772eSMartin Schwidefsky 	DIAG_STAT_X010,
17*1ec2772eSMartin Schwidefsky 	DIAG_STAT_X014,
18*1ec2772eSMartin Schwidefsky 	DIAG_STAT_X044,
19*1ec2772eSMartin Schwidefsky 	DIAG_STAT_X064,
20*1ec2772eSMartin Schwidefsky 	DIAG_STAT_X09C,
21*1ec2772eSMartin Schwidefsky 	DIAG_STAT_X0DC,
22*1ec2772eSMartin Schwidefsky 	DIAG_STAT_X204,
23*1ec2772eSMartin Schwidefsky 	DIAG_STAT_X210,
24*1ec2772eSMartin Schwidefsky 	DIAG_STAT_X224,
25*1ec2772eSMartin Schwidefsky 	DIAG_STAT_X250,
26*1ec2772eSMartin Schwidefsky 	DIAG_STAT_X258,
27*1ec2772eSMartin Schwidefsky 	DIAG_STAT_X288,
28*1ec2772eSMartin Schwidefsky 	DIAG_STAT_X2C4,
29*1ec2772eSMartin Schwidefsky 	DIAG_STAT_X2FC,
30*1ec2772eSMartin Schwidefsky 	DIAG_STAT_X304,
31*1ec2772eSMartin Schwidefsky 	DIAG_STAT_X308,
32*1ec2772eSMartin Schwidefsky 	DIAG_STAT_X500,
33*1ec2772eSMartin Schwidefsky 	NR_DIAG_STAT
34*1ec2772eSMartin Schwidefsky };
35*1ec2772eSMartin Schwidefsky 
36*1ec2772eSMartin Schwidefsky struct diag_stat {
37*1ec2772eSMartin Schwidefsky 	unsigned int counter[NR_DIAG_STAT];
38*1ec2772eSMartin Schwidefsky };
39*1ec2772eSMartin Schwidefsky 
40*1ec2772eSMartin Schwidefsky DECLARE_PER_CPU(struct diag_stat, diag_stat);
41*1ec2772eSMartin Schwidefsky 
42*1ec2772eSMartin Schwidefsky static inline void diag_stat_inc(enum diag_stat_enum nr)
43*1ec2772eSMartin Schwidefsky {
44*1ec2772eSMartin Schwidefsky 	this_cpu_inc(diag_stat.counter[nr]);
45*1ec2772eSMartin Schwidefsky }
46*1ec2772eSMartin Schwidefsky 
47c6557e7fSMartin Schwidefsky /*
4883ace270SMichael Holzheu  * Diagnose 10: Release page range
49c6557e7fSMartin Schwidefsky  */
5083ace270SMichael Holzheu static inline void diag10_range(unsigned long start_pfn, unsigned long num_pfn)
5183ace270SMichael Holzheu {
5283ace270SMichael Holzheu 	unsigned long start_addr, end_addr;
5383ace270SMichael Holzheu 
5483ace270SMichael Holzheu 	start_addr = start_pfn << PAGE_SHIFT;
5583ace270SMichael Holzheu 	end_addr = (start_pfn + num_pfn - 1) << PAGE_SHIFT;
5683ace270SMichael Holzheu 
57*1ec2772eSMartin Schwidefsky 	diag_stat_inc(DIAG_STAT_X010);
5883ace270SMichael Holzheu 	asm volatile(
5983ace270SMichael Holzheu 		"0:	diag	%0,%1,0x10\n"
6083ace270SMichael Holzheu 		"1:\n"
6183ace270SMichael Holzheu 		EX_TABLE(0b, 1b)
6283ace270SMichael Holzheu 		EX_TABLE(1b, 1b)
6383ace270SMichael Holzheu 		: : "a" (start_addr), "a" (end_addr));
6483ace270SMichael Holzheu }
65c6557e7fSMartin Schwidefsky 
66c6557e7fSMartin Schwidefsky /*
67c6557e7fSMartin Schwidefsky  * Diagnose 14: Input spool file manipulation
68c6557e7fSMartin Schwidefsky  */
69c6557e7fSMartin Schwidefsky extern int diag14(unsigned long rx, unsigned long ry1, unsigned long subcode);
70c6557e7fSMartin Schwidefsky 
71c6557e7fSMartin Schwidefsky /*
72c6557e7fSMartin Schwidefsky  * Diagnose 210: Get information about a virtual device
73c6557e7fSMartin Schwidefsky  */
74c6557e7fSMartin Schwidefsky struct diag210 {
75c6557e7fSMartin Schwidefsky 	u16 vrdcdvno;	/* device number (input) */
76c6557e7fSMartin Schwidefsky 	u16 vrdclen;	/* data block length (input) */
77c6557e7fSMartin Schwidefsky 	u8 vrdcvcla;	/* virtual device class (output) */
78c6557e7fSMartin Schwidefsky 	u8 vrdcvtyp;	/* virtual device type (output) */
79c6557e7fSMartin Schwidefsky 	u8 vrdcvsta;	/* virtual device status (output) */
80c6557e7fSMartin Schwidefsky 	u8 vrdcvfla;	/* virtual device flags (output) */
81c6557e7fSMartin Schwidefsky 	u8 vrdcrccl;	/* real device class (output) */
82c6557e7fSMartin Schwidefsky 	u8 vrdccrty;	/* real device type (output) */
83c6557e7fSMartin Schwidefsky 	u8 vrdccrmd;	/* real device model (output) */
84c6557e7fSMartin Schwidefsky 	u8 vrdccrft;	/* real device feature (output) */
85c6557e7fSMartin Schwidefsky } __attribute__((packed, aligned(4)));
86c6557e7fSMartin Schwidefsky 
87c6557e7fSMartin Schwidefsky extern int diag210(struct diag210 *addr);
88c6557e7fSMartin Schwidefsky 
89c6557e7fSMartin Schwidefsky #endif /* _ASM_S390_DIAG_H */
90