<div dir="ltr"><div dir="ltr"><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Michael Ellerman <<a href="mailto:mpe@ellerman.id.au">mpe@ellerman.id.au</a>> 于2021年3月31日周三 下午5:58写道:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Xiongwei Song <<a href="mailto:sxwjean@me.com" target="_blank">sxwjean@me.com</a>> writes:<br>
> From: Xiongwei Song <<a href="mailto:sxwjean@gmail.com" target="_blank">sxwjean@gmail.com</a>><br>
><br>
> Create a new header named traps.h, define macros to list ppc exception<br>
> types in traps.h, replace the reference of the real trap values with<br>
> these macros.<br>
<br>
Personally I find the hex values easier to recognise, but I realise<br>
that's probably not true of other people :)<br>
<br></blockquote><div>I'm one of the "other people". </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
...<br>
> diff --git a/arch/powerpc/include/asm/traps.h b/arch/powerpc/include/asm/traps.h<br>
> new file mode 100644<br>
> index 000000000000..a31b6122de23<br>
> --- /dev/null<br>
> +++ b/arch/powerpc/include/asm/traps.h<br>
> @@ -0,0 +1,19 @@<br>
> +/* SPDX-License-Identifier: GPL-2.0 */<br>
> +#ifndef _ASM_PPC_TRAPS_H<br>
> +#define _ASM_PPC_TRAPS_H<br>
> +<br>
> +#define TRAP_RESET 0x100 /* System reset */<br>
> +#define TRAP_MCE 0x200 /* Machine check */<br>
> +#define TRAP_DSI 0x300 /* Data storage */<br>
> +#define TRAP_DSEGI 0x380 /* Data segment */<br>
> +#define TRAP_ISI 0x400 /* Instruction storage */<br>
> +#define TRAP_ISEGI 0x480 /* Instruction segment */<br>
> +#define TRAP_ALIGN 0x600 /* Alignment */<br>
> +#define TRAP_PROG 0x700 /* Program */<br>
> +#define TRAP_DEC 0x900 /* Decrementer */<br>
> +#define TRAP_SYSCALL 0xc00 /* System call */<br>
> +#define TRAP_TRACEI 0xd00 /* Trace */<br>
> +#define TRAP_FPA 0xe00 /* Floating-point Assist */<br>
> +#define TRAP_PMI 0xf00 /* Performance monitor */<br>
<br>
I know the macro is called TRAP and the field in pt_regs is called trap,<br>
but the terminology in the architecture is "exception", and we already<br>
have many uses of that. In particular we have a lot of uses of "exc" as<br>
an abbreviation for "exception". So I think I'd rather we use that than<br>
"TRAP".<br></blockquote><div>Ok.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
I think we should probably use the names from the ISA, unless they are<br>
really over long.<br>
<br>
Which are:<br>
<br>
0x100 System Reset<br>
0x200 Machine Check<br>
0x300 Data Storage<br>
0x380 Data Segment<br>
0x400 Instruction Storage<br>
0x480 Instruction Segment<br>
0x500 External<br>
0x600 Alignment<br>
0x700 Program<br>
0x800 Floating-Point Unavailable<br>
0x900 Decrementer<br>
0x980 Hypervisor Decrementer<br>
0xA00 Directed Privileged Doorbell<br>
0xC00 System Call<br>
0xD00 Trace<br>
0xE00 Hypervisor Data Storage<br>
0xE20 Hypervisor Instruction Storage<br>
0xE40 Hypervisor Emulation Assistance<br>
0xE60 Hypervisor Maintenance<br>
0xE80 Directed Hypervisor Doorbell<br>
0xEA0 Hypervisor Virtualization<br>
0xF00 Performance Monitor<br>
0xF20 Vector Unavailable<br>
0xF40 VSX Unavailable<br>
0xF60 Facility Unavailable<br>
0xF80 Hypervisor Facility Unavailable<br>
0xFA0 Directed Ultravisor Doorbell<br>
<br>
<br>
So perhaps:<br>
<br>
EXC_SYSTEM_RESET<br>
EXC_MACHINE_CHECK<br>
EXC_DATA_STORAGE<br>
EXC_DATA_SEGMENT<br>
EXC_INST_STORAGE<br>
EXC_INST_SEGMENT<br>
EXC_EXTERNAL_INTERRUPT<br>
EXC_ALIGNMENT<br>
EXC_PROGRAM_CHECK<br>
EXC_FP_UNAVAILABLE<br>
EXC_DECREMENTER<br>
EXC_HV_DECREMENTER<br>
EXC_SYSTEM_CALL<br>
EXC_HV_DATA_STORAGE<br>
EXC_PERF_MONITOR<br>
<br></blockquote><div>Thanks for the suggestions. I'm ok with the prefix. Let me change.</div></div></div>