diff options
Diffstat (limited to 'arch/s390/kernel/dis.c')
-rw-r--r-- | arch/s390/kernel/dis.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/arch/s390/kernel/dis.c b/arch/s390/kernel/dis.c index 1f6b428e2762..c02310b8db09 100644 --- a/arch/s390/kernel/dis.c +++ b/arch/s390/kernel/dis.c | |||
@@ -1468,6 +1468,33 @@ static struct insn *find_insn(unsigned char *code) | |||
1468 | return NULL; | 1468 | return NULL; |
1469 | } | 1469 | } |
1470 | 1470 | ||
1471 | /** | ||
1472 | * insn_to_mnemonic - decode an s390 instruction | ||
1473 | * @instruction: instruction to decode | ||
1474 | * @buf: buffer to fill with mnemonic | ||
1475 | * | ||
1476 | * Decode the instruction at @instruction and store the corresponding | ||
1477 | * mnemonic into @buf. | ||
1478 | * @buf is left unchanged if the instruction could not be decoded. | ||
1479 | * Returns: | ||
1480 | * %0 on success, %-ENOENT if the instruction was not found. | ||
1481 | */ | ||
1482 | int insn_to_mnemonic(unsigned char *instruction, char buf[8]) | ||
1483 | { | ||
1484 | struct insn *insn; | ||
1485 | |||
1486 | insn = find_insn(instruction); | ||
1487 | if (!insn) | ||
1488 | return -ENOENT; | ||
1489 | if (insn->name[0] == '\0') | ||
1490 | snprintf(buf, sizeof(buf), "%s", | ||
1491 | long_insn_name[(int) insn->name[1]]); | ||
1492 | else | ||
1493 | snprintf(buf, sizeof(buf), "%.5s", insn->name); | ||
1494 | return 0; | ||
1495 | } | ||
1496 | EXPORT_SYMBOL_GPL(insn_to_mnemonic); | ||
1497 | |||
1471 | static int print_insn(char *buffer, unsigned char *code, unsigned long addr) | 1498 | static int print_insn(char *buffer, unsigned char *code, unsigned long addr) |
1472 | { | 1499 | { |
1473 | struct insn *insn; | 1500 | struct insn *insn; |