initial commit with v2.6.9
[linux-2.6.9-moxart.git] / arch / s390 / kernel / cpcmd.c
blobd48351583ecb58ef2ec512eeaf006ed4ae7a2ca9
1 /*
2 * arch/s390/kernel/cpcmd.c
4 * S390 version
5 * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
7 */
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;
23 unsigned long flags;
24 int cmdlen;
26 spin_lock_irqsave(&cpcmd_lock, flags);
27 cmdlen = strlen(cmd);
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"
34 "LR 4,%1\n\t"
35 "O 4,%4\n\t"
36 "LRA 3,0(%2)\n\t"
37 "LR 5,%3\n\t"
38 ".long 0x83240008 # Diagnose 83\n\t"
39 : /* no output */
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"
45 " lgr 4,%1\n"
46 " o 4,%4\n"
47 " lrag 3,0(%2)\n"
48 " lgr 5,%3\n"
49 " sam31\n"
50 " .long 0x83240008 # Diagnose 83\n"
51 " sam64"
52 : /* no output */
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);
58 } else {
59 #ifndef CONFIG_ARCH_S390X
60 asm volatile ("LRA 2,0(%0)\n\t"
61 "LR 3,%1\n\t"
62 ".long 0x83230008 # Diagnose 83\n\t"
63 : /* no output */
64 : "a" (cpcmd_buf), "d" (cmdlen)
65 : "2", "3" );
66 #else /* CONFIG_ARCH_S390X */
67 asm volatile (" lrag 2,0(%0)\n"
68 " lgr 3,%1\n"
69 " sam31\n"
70 " .long 0x83230008 # Diagnose 83\n"
71 " sam64"
72 : /* no output */
73 : "a" (cpcmd_buf), "d" (cmdlen)
74 : "2", "3" );
75 #endif /* CONFIG_ARCH_S390X */
77 spin_unlock_irqrestore(&cpcmd_lock, flags);