s390/dis: Instruction decoding interface
[deliverable/linux.git] / arch / s390 / kernel / dis.c
index 3221c6fca8bb77ceedd9c6ee00b9c2018d45251d..c02310b8db09e651424f4b08b63a3e0247679bde 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * arch/s390/kernel/dis.c
- *
  * Disassemble s390 instructions.
  *
  * Copyright IBM Corp. 2007
@@ -613,6 +611,7 @@ static struct insn opcode_b2[] = {
        { "sie", 0x14, INSTR_S_RD },
        { "pc", 0x18, INSTR_S_RD },
        { "sac", 0x19, INSTR_S_RD },
+       { "servc", 0x20, INSTR_RRE_RR },
        { "cfc", 0x1a, INSTR_S_RD },
        { "ipte", 0x21, INSTR_RRE_RR },
        { "ipm", 0x22, INSTR_RRE_R0 },
@@ -1469,6 +1468,33 @@ static struct insn *find_insn(unsigned char *code)
        return NULL;
 }
 
+/**
+ * insn_to_mnemonic - decode an s390 instruction
+ * @instruction: instruction to decode
+ * @buf: buffer to fill with mnemonic
+ *
+ * Decode the instruction at @instruction and store the corresponding
+ * mnemonic into @buf.
+ * @buf is left unchanged if the instruction could not be decoded.
+ * Returns:
+ *  %0 on success, %-ENOENT if the instruction was not found.
+ */
+int insn_to_mnemonic(unsigned char *instruction, char buf[8])
+{
+       struct insn *insn;
+
+       insn = find_insn(instruction);
+       if (!insn)
+               return -ENOENT;
+       if (insn->name[0] == '\0')
+               snprintf(buf, sizeof(buf), "%s",
+                        long_insn_name[(int) insn->name[1]]);
+       else
+               snprintf(buf, sizeof(buf), "%.5s", insn->name);
+       return 0;
+}
+EXPORT_SYMBOL_GPL(insn_to_mnemonic);
+
 static int print_insn(char *buffer, unsigned char *code, unsigned long addr)
 {
        struct insn *insn;
This page took 0.02597 seconds and 5 git commands to generate.