xref: /openbmc/linux/arch/s390/kernel/diag.c (revision 6189f1b0)
1 /*
2  * Implementation of s390 diagnose codes
3  *
4  * Copyright IBM Corp. 2007
5  * Author(s): Michael Holzheu <holzheu@de.ibm.com>
6  */
7 
8 #include <linux/module.h>
9 #include <asm/diag.h>
10 
11 /*
12  * Diagnose 14: Input spool file manipulation
13  */
14 int diag14(unsigned long rx, unsigned long ry1, unsigned long subcode)
15 {
16 	register unsigned long _ry1 asm("2") = ry1;
17 	register unsigned long _ry2 asm("3") = subcode;
18 	int rc = 0;
19 
20 	asm volatile(
21 		"   sam31\n"
22 		"   diag    %2,2,0x14\n"
23 		"   sam64\n"
24 		"   ipm     %0\n"
25 		"   srl     %0,28\n"
26 		: "=d" (rc), "+d" (_ry2)
27 		: "d" (rx), "d" (_ry1)
28 		: "cc");
29 
30 	return rc;
31 }
32 EXPORT_SYMBOL(diag14);
33 
34 /*
35  * Diagnose 210: Get information about a virtual device
36  */
37 int diag210(struct diag210 *addr)
38 {
39 	/*
40 	 * diag 210 needs its data below the 2GB border, so we
41 	 * use a static data area to be sure
42 	 */
43 	static struct diag210 diag210_tmp;
44 	static DEFINE_SPINLOCK(diag210_lock);
45 	unsigned long flags;
46 	int ccode;
47 
48 	spin_lock_irqsave(&diag210_lock, flags);
49 	diag210_tmp = *addr;
50 
51 	asm volatile(
52 		"	lhi	%0,-1\n"
53 		"	sam31\n"
54 		"	diag	%1,0,0x210\n"
55 		"0:	ipm	%0\n"
56 		"	srl	%0,28\n"
57 		"1:	sam64\n"
58 		EX_TABLE(0b, 1b)
59 		: "=&d" (ccode) : "a" (&diag210_tmp) : "cc", "memory");
60 
61 	*addr = diag210_tmp;
62 	spin_unlock_irqrestore(&diag210_lock, flags);
63 
64 	return ccode;
65 }
66 EXPORT_SYMBOL(diag210);
67