2 * Implementation of s390 diagnose codes
4 * Copyright IBM Corp. 2007
5 * Author(s): Michael Holzheu <holzheu@de.ibm.com>
8 #include <linux/module.h>
10 #include <linux/seq_file.h>
11 #include <linux/debugfs.h>
14 DEFINE_PER_CPU(struct diag_stat, diag_stat);
15 EXPORT_PER_CPU_SYMBOL(diag_stat);
22 static const struct diag_desc diag_map[NR_DIAG_STAT] = {
23 [DIAG_STAT_X008] = { .code = 0x008, .name = "Console Function" },
24 [DIAG_STAT_X00C] = { .code = 0x00c, .name = "Pseudo Timer" },
25 [DIAG_STAT_X010] = { .code = 0x010, .name = "Release Pages" },
26 [DIAG_STAT_X014] = { .code = 0x014, .name = "Spool File Services" },
27 [DIAG_STAT_X044] = { .code = 0x044, .name = "Voluntary Timeslice End" },
28 [DIAG_STAT_X064] = { .code = 0x064, .name = "NSS Manipulation" },
29 [DIAG_STAT_X09C] = { .code = 0x09c, .name = "Relinquish Timeslice" },
30 [DIAG_STAT_X0DC] = { .code = 0x0dc, .name = "Appldata Control" },
31 [DIAG_STAT_X204] = { .code = 0x204, .name = "Logical-CPU Utilization" },
32 [DIAG_STAT_X210] = { .code = 0x210, .name = "Device Information" },
33 [DIAG_STAT_X224] = { .code = 0x224, .name = "EBCDIC-Name Table" },
34 [DIAG_STAT_X250] = { .code = 0x250, .name = "Block I/O" },
35 [DIAG_STAT_X258] = { .code = 0x258, .name = "Page-Reference Services" },
36 [DIAG_STAT_X288] = { .code = 0x288, .name = "Time Bomb" },
37 [DIAG_STAT_X2C4] = { .code = 0x2c4, .name = "FTP Services" },
38 [DIAG_STAT_X2FC] = { .code = 0x2fc, .name = "Guest Performance Data" },
39 [DIAG_STAT_X304] = { .code = 0x304, .name = "Partition-Resource Service" },
40 [DIAG_STAT_X308] = { .code = 0x308, .name = "List-Directed IPL" },
41 [DIAG_STAT_X500] = { .code = 0x500, .name = "Virtio Service" },
44 static int show_diag_stat(struct seq_file *m, void *v)
46 struct diag_stat *stat;
47 unsigned long n = (unsigned long) v - 1;
54 for_each_online_cpu(cpu) {
56 for (tmp = 10; cpu >= tmp; tmp *= 10)
58 seq_printf(m, "%*s%d", prec, "CPU", cpu);
61 } else if (n <= NR_DIAG_STAT) {
62 seq_printf(m, "diag %03x:", diag_map[n-1].code);
63 for_each_online_cpu(cpu) {
64 stat = &per_cpu(diag_stat, cpu);
65 seq_printf(m, " %10u", stat->counter[n-1]);
67 seq_printf(m, " %s\n", diag_map[n-1].name);
73 static void *show_diag_stat_start(struct seq_file *m, loff_t *pos)
75 return *pos <= nr_cpu_ids ? (void *)((unsigned long) *pos + 1) : NULL;
78 static void *show_diag_stat_next(struct seq_file *m, void *v, loff_t *pos)
81 return show_diag_stat_start(m, pos);
84 static void show_diag_stat_stop(struct seq_file *m, void *v)
88 static const struct seq_operations show_diag_stat_sops = {
89 .start = show_diag_stat_start,
90 .next = show_diag_stat_next,
91 .stop = show_diag_stat_stop,
92 .show = show_diag_stat,
95 static int show_diag_stat_open(struct inode *inode, struct file *file)
97 return seq_open(file, &show_diag_stat_sops);
100 static const struct file_operations show_diag_stat_fops = {
101 .open = show_diag_stat_open,
104 .release = seq_release,
108 static int __init show_diag_stat_init(void)
110 debugfs_create_file("diag_stat", 0400, NULL, NULL,
111 &show_diag_stat_fops);
115 device_initcall(show_diag_stat_init);
118 * Diagnose 14: Input spool file manipulation
120 static inline int __diag14(unsigned long rx, unsigned long ry1,
121 unsigned long subcode)
123 register unsigned long _ry1 asm("2") = ry1;
124 register unsigned long _ry2 asm("3") = subcode;
133 : "=d" (rc), "+d" (_ry2)
134 : "d" (rx), "d" (_ry1)
140 int diag14(unsigned long rx, unsigned long ry1, unsigned long subcode)
142 diag_stat_inc(DIAG_STAT_X014);
143 return __diag14(rx, ry1, subcode);
145 EXPORT_SYMBOL(diag14);
148 * Diagnose 210: Get information about a virtual device
150 int diag210(struct diag210 *addr)
153 * diag 210 needs its data below the 2GB border, so we
154 * use a static data area to be sure
156 static struct diag210 diag210_tmp;
157 static DEFINE_SPINLOCK(diag210_lock);
161 spin_lock_irqsave(&diag210_lock, flags);
164 diag_stat_inc(DIAG_STAT_X210);
173 : "=&d" (ccode) : "a" (&diag210_tmp) : "cc", "memory");
176 spin_unlock_irqrestore(&diag210_lock, flags);
180 EXPORT_SYMBOL(diag210);