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/string.h>
10 #include <linux/spinlock.h>
11 #include <asm/cpcmd.h>
12 #include <asm/ebcdic.h>
13 #include <asm/system.h>
15 static spinlock_t cpcmd_lock = SPIN_LOCK_UNLOCKED;
16 static char cpcmd_buf[128];
18 void cpcmd(char *cmd, char *response, int rlen)
20 const int mask = 0x40000000L;
24 spin_lock_irqsave(&cpcmd_lock, flags);
26 strcpy(cpcmd_buf, cmd);
27 ASCEBC(cpcmd_buf, cmdlen);
29 if (response != NULL && rlen > 0) {
30 asm volatile (" lrag 2,0(%0)\n"
36 " .long 0x83240008 # Diagnose 83\n"
39 : "a" (cpcmd_buf), "d" (cmdlen),
40 "a" (response), "d" (rlen), "m" (mask)
41 : "2", "3", "4", "5" );
42 EBCASC(response, rlen);
44 asm volatile (" lrag 2,0(%0)\n"
47 " .long 0x83230008 # Diagnose 83\n"
50 : "a" (cpcmd_buf), "d" (cmdlen)
53 spin_unlock_irqrestore(&cpcmd_lock, flags);