2 * arch/s390/kernel/cpcmd.c
5 * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
9 #include <linux/stddef.h>
10 #include <linux/kernel.h>
11 #include <linux/string.h>
12 #include <asm/ebcdic.h>
13 #include <linux/spinlock.h>
14 #include <asm/cpcmd.h>
15 #include <asm/system.h>
17 static spinlock_t cpcmd_lock = SPIN_LOCK_UNLOCKED;
18 static char cpcmd_buf[128];
20 void cpcmd(char *cmd, char *response, int rlen)
22 const int mask = 0x40000000L;
26 spin_lock_irqsave(&cpcmd_lock, flags);
28 strcpy(cpcmd_buf, cmd);
29 ASCEBC(cpcmd_buf, cmdlen);
31 if (response != NULL && rlen > 0) {
32 #ifndef CONFIG_ARCH_S390X
33 asm volatile ("LRA 2,0(%0)\n\t"
38 ".long 0x83240008 # Diagnose 83\n\t"
40 : "a" (cpcmd_buf), "d" (cmdlen),
41 "a" (response), "d" (rlen), "m" (mask)
42 : "2", "3", "4", "5" );
43 #else /* CONFIG_ARCH_S390X */
44 asm volatile (" lrag 2,0(%0)\n"
50 " .long 0x83240008 # Diagnose 83\n"
53 : "a" (cpcmd_buf), "d" (cmdlen),
54 "a" (response), "d" (rlen), "m" (mask)
55 : "2", "3", "4", "5" );
56 #endif /* CONFIG_ARCH_S390X */
57 EBCASC(response, rlen);
59 #ifndef CONFIG_ARCH_S390X
60 asm volatile ("LRA 2,0(%0)\n\t"
62 ".long 0x83230008 # Diagnose 83\n\t"
64 : "a" (cpcmd_buf), "d" (cmdlen)
66 #else /* CONFIG_ARCH_S390X */
67 asm volatile (" lrag 2,0(%0)\n"
70 " .long 0x83230008 # Diagnose 83\n"
73 : "a" (cpcmd_buf), "d" (cmdlen)
75 #endif /* CONFIG_ARCH_S390X */
77 spin_unlock_irqrestore(&cpcmd_lock, flags);