> Date: Mon, 29 Aug 2022 11:33:19 -0500
> From: Scott Cheloha <[email protected]>
> 
> On Fri, Aug 19, 2022 at 01:24:47PM +0200, Mark Kettenis wrote:
> >
> > This is one of those annoying corners where there is too much
> > unecessary MD variation. Currently travelling without a laptop, so I
> > can't easily check the tree. But one note I wanted to make is that the
> > definition of struct clockframe and the CLKF_XXX macros should stay
> > together. 
> 
> Sure.  Here's a version that consolidates the CLKF macros into frame.h
> alongside the clockframe definitions.
> 
> Notes by arch:
> 
> alpha, amd64, hppa, i386, m88k, mips64, powerpc64, sh, sparc64:
> 
> - clockframe is defined in cpu.h with CLKF macros.
> 
> - Move clockframe definition and CLKF macros from cpu.h to frame.h.
> 
> arm, powerpc:
> 
> - clockframe is defined in frame.h.
> 
> - CLKF macros are defined in cpu.h.
> 
> - Move CLKF macros from cpu.h to frame.h.
> 
> arm64, riscv64:
> 
> - clockframe is defined in cpu.h with CLKF macros.
> 
> - clockframe is *also* defined in frame.h.
> 
> - Delete clockframe definition from frame.h
> 
> - Move (other) clockframe definition and CLKF macros from cpu.h to frame.h.
> 
> sparc64 remains the only one that looks not-quite-right because
> trapframe64 is defined in reg.h, not frame.h.

Yes, that is not going to work.

We really should be getting rid f the xxx32 stuff and rename the xxx64
ones to xxx.  And move trapframe (and possibly rwindow) to frame.h.

> Index: alpha/include/cpu.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/alpha/include/cpu.h,v
> retrieving revision 1.66
> diff -u -p -r1.66 cpu.h
> --- alpha/include/cpu.h       10 Aug 2022 10:41:35 -0000      1.66
> +++ alpha/include/cpu.h       29 Aug 2022 16:28:56 -0000
> @@ -297,25 +297,6 @@ cpu_rnd_messybits(void)
>  }
>  
>  /*
> - * Arguments to hardclock and gatherstats encapsulate the previous
> - * machine state in an opaque clockframe.  On the Alpha, we use
> - * what we push on an interrupt (a trapframe).
> - */
> -struct clockframe {
> -     struct trapframe        cf_tf;
> -};
> -#define      CLKF_USERMODE(framep)                                           
> \
> -     (((framep)->cf_tf.tf_regs[FRAME_PS] & ALPHA_PSL_USERMODE) != 0)
> -#define      CLKF_PC(framep)         ((framep)->cf_tf.tf_regs[FRAME_PC])
> -
> -/*
> - * This isn't perfect; if the clock interrupt comes in before the
> - * r/m/w cycle is complete, we won't be counted... but it's not
> - * like this statistic has to be extremely accurate.
> - */
> -#define      CLKF_INTR(framep)       (curcpu()->ci_intrdepth)
> -
> -/*
>   * This is used during profiling to integrate system time.
>   */
>  #define      PROC_PC(p)      ((p)->p_md.md_tf->tf_regs[FRAME_PC])
> Index: alpha/include/frame.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/alpha/include/frame.h,v
> retrieving revision 1.4
> diff -u -p -r1.4 frame.h
> --- alpha/include/frame.h     23 Mar 2011 16:54:34 -0000      1.4
> +++ alpha/include/frame.h     29 Aug 2022 16:28:56 -0000
> @@ -92,4 +92,23 @@ struct trapframe {
>       unsigned long   tf_regs[FRAME_SIZE];    /* See above */
>  };
>  
> +/*
> + * Arguments to hardclock and gatherstats encapsulate the previous
> + * machine state in an opaque clockframe.  On the Alpha, we use
> + * what we push on an interrupt (a trapframe).
> + */
> +struct clockframe {
> +     struct trapframe        cf_tf;
> +};
> +#define      CLKF_USERMODE(framep)                                           
> \
> +     (((framep)->cf_tf.tf_regs[FRAME_PS] & ALPHA_PSL_USERMODE) != 0)
> +#define      CLKF_PC(framep)         ((framep)->cf_tf.tf_regs[FRAME_PC])
> +
> +/*
> + * This isn't perfect; if the clock interrupt comes in before the
> + * r/m/w cycle is complete, we won't be counted... but it's not
> + * like this statistic has to be extremely accurate.
> + */
> +#define      CLKF_INTR(framep)       (curcpu()->ci_intrdepth)
> +
>  #endif /* _MACHINE_FRAME_H_ */
> Index: amd64/include/cpu.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/amd64/include/cpu.h,v
> retrieving revision 1.149
> diff -u -p -r1.149 cpu.h
> --- amd64/include/cpu.h       25 Aug 2022 17:25:25 -0000      1.149
> +++ amd64/include/cpu.h       29 Aug 2022 16:28:56 -0000
> @@ -336,17 +336,6 @@ cpu_rnd_messybits(void)
>  #define curpcb               curcpu()->ci_curpcb
>  
>  /*
> - * Arguments to hardclock, softclock and statclock
> - * encapsulate the previous machine state in an opaque
> - * clockframe; for now, use generic intrframe.
> - */
> -#define clockframe intrframe
> -
> -#define      CLKF_USERMODE(frame)    USERMODE((frame)->if_cs, 
> (frame)->if_rflags)
> -#define CLKF_PC(frame)               ((frame)->if_rip)
> -#define CLKF_INTR(frame)     (curcpu()->ci_idepth > 1)
> -
> -/*
>   * Give a profiling tick to the current process when the user profiling
>   * buffer pages are invalid.  On the i386, request an ast to send us
>   * through usertrap(), marking the proc as needing a profiling tick.
> Index: amd64/include/frame.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/amd64/include/frame.h,v
> retrieving revision 1.10
> diff -u -p -r1.10 frame.h
> --- amd64/include/frame.h     10 Jul 2018 08:57:44 -0000      1.10
> +++ amd64/include/frame.h     29 Aug 2022 16:28:56 -0000
> @@ -171,4 +171,14 @@ struct callframe {
>       long                    f_arg0;
>  };
>  
> +/*
> + * Arguments to hardclock, softclock and statclock
> + * encapsulate the previous machine state in an opaque
> + * clockframe; for now, use generic intrframe.
> + */
> +#define clockframe intrframe
> +#define CLKF_USERMODE(frame) USERMODE((frame)->if_cs, (frame)->if_rflags)
> +#define CLKF_PC(frame)               ((frame)->if_rip)
> +#define CLKF_INTR(frame)     (curcpu()->ci_idepth > 1)
> +
>  #endif  /* _MACHINE_FRAME_H_ */
> Index: arm/include/cpu.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/arm/include/cpu.h,v
> retrieving revision 1.61
> diff -u -p -r1.61 cpu.h
> --- arm/include/cpu.h 6 Jul 2021 09:34:06 -0000       1.61
> +++ arm/include/cpu.h 29 Aug 2022 16:28:56 -0000
> @@ -104,25 +104,6 @@
>  /* 1 == use cpu_sleep(), 0 == don't */
>  extern int cpu_do_powersave;
>  
> -/* All the CLKF_* macros take a struct clockframe * as an argument. */
> -
> -/*
> - * CLKF_USERMODE: Return TRUE/FALSE (1/0) depending on whether the
> - * frame came from USR mode or not.
> - */
> -#define CLKF_USERMODE(frame) ((frame->if_spsr & PSR_MODE) == PSR_USR32_MODE)
> -
> -/*
> - * CLKF_INTR: True if we took the interrupt from inside another
> - * interrupt handler.
> - */
> -#define CLKF_INTR(frame)     (curcpu()->ci_idepth > 1) 
> -
> -/*
> - * CLKF_PC: Extract the program counter from a clockframe
> - */
> -#define CLKF_PC(frame)               (frame->if_pc)
> -
>  /*
>   * PROC_PC: Find out the program counter for the given process.
>   */
> Index: arm/include/frame.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/arm/include/frame.h,v
> retrieving revision 1.13
> diff -u -p -r1.13 frame.h
> --- arm/include/frame.h       30 Jun 2018 15:23:37 -0000      1.13
> +++ arm/include/frame.h       29 Aug 2022 16:28:56 -0000
> @@ -144,7 +144,25 @@ typedef struct irqframe {
>       unsigned int if_pad;
>  } irqframe_t;
>  
> +/* All the CLKF_* macros take a struct clockframe * as an argument. */
>  #define clockframe irqframe
> +
> +/*
> + * CLKF_USERMODE: Return TRUE/FALSE (1/0) depending on whether the
> + * frame came from USR mode or not.
> + */
> +#define CLKF_USERMODE(frame) ((frame->if_spsr & PSR_MODE) == PSR_USR32_MODE)
> +
> +/*
> + * CLKF_INTR: True if we took the interrupt from inside another
> + * interrupt handler.
> + */
> +#define CLKF_INTR(frame)     (curcpu()->ci_idepth > 1) 
> +
> +/*
> + * CLKF_PC: Extract the program counter from a clockframe
> + */
> +#define CLKF_PC(frame)               (frame->if_pc)
>  
>  /*
>   * Switch frame
> Index: arm64/include/cpu.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/arm64/include/cpu.h,v
> retrieving revision 1.28
> diff -u -p -r1.28 cpu.h
> --- arm64/include/cpu.h       29 Aug 2022 02:01:18 -0000      1.28
> +++ arm64/include/cpu.h       29 Aug 2022 16:28:56 -0000
> @@ -47,26 +47,6 @@
>  #include <machine/frame.h>
>  #include <machine/armreg.h>
>  
> -/* All the CLKF_* macros take a struct clockframe * as an argument. */
> -
> -#define clockframe trapframe
> -/*
> - * CLKF_USERMODE: Return TRUE/FALSE (1/0) depending on whether the
> - * frame came from USR mode or not.
> - */
> -#define CLKF_USERMODE(frame) ((frame->tf_elr & (1ul << 63)) == 0)
> -
> -/*
> - * CLKF_INTR: True if we took the interrupt from inside another
> - * interrupt handler.
> - */
> -#define CLKF_INTR(frame)     (curcpu()->ci_idepth > 1)
> -
> -/*
> - * CLKF_PC: Extract the program counter from a clockframe
> - */
> -#define CLKF_PC(frame)               (frame->tf_elr)
> -
>  /*
>   * PROC_PC: Find out the program counter for the given process.
>   */
> Index: arm64/include/frame.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/arm64/include/frame.h,v
> retrieving revision 1.3
> diff -u -p -r1.3 frame.h
> --- arm64/include/frame.h     30 Jun 2018 15:23:37 -0000      1.3
> +++ arm64/include/frame.h     29 Aug 2022 16:28:56 -0000
> @@ -26,7 +26,6 @@
>  /*
>   * Exception/Trap Stack Frame
>   */
> -#define clockframe trapframe
>  typedef struct trapframe {
>       register_t tf_sp;
>       register_t tf_lr;
> @@ -34,6 +33,26 @@ typedef struct trapframe {
>       register_t tf_spsr;
>       register_t tf_x[30];
>  } trapframe_t;
> +
> +/* All the CLKF_* macros take a struct clockframe * as an argument. */
> +#define clockframe trapframe
> +
> +/*
> + * CLKF_USERMODE: Return TRUE/FALSE (1/0) depending on whether the
> + * frame came from USR mode or not.
> + */
> +#define CLKF_USERMODE(frame) ((frame->tf_elr & (1ul << 63)) == 0)
> +
> +/*
> + * CLKF_INTR: True if we took the interrupt from inside another
> + * interrupt handler.
> + */
> +#define CLKF_INTR(frame)     (curcpu()->ci_idepth > 1)
> +
> +/*
> + * CLKF_PC: Extract the program counter from a clockframe
> + */
> +#define CLKF_PC(frame)               (frame->tf_elr)
>  
>  /*
>   * pushed on stack for signal delivery
> Index: hppa/include/cpu.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/hppa/include/cpu.h,v
> retrieving revision 1.95
> diff -u -p -r1.95 cpu.h
> --- hppa/include/cpu.h        6 Jul 2021 09:34:06 -0000       1.95
> +++ hppa/include/cpu.h        29 Aug 2022 16:28:56 -0000
> @@ -210,12 +210,6 @@ extern int cpu_hvers;
>  #define      HPPA_SPA_ENABLE 0x00000020
>  #define      HPPA_NMODSPBUS  64
>  
> -#define      clockframe              trapframe
> -#define      CLKF_PC(framep)         ((framep)->tf_iioq_head)
> -#define      CLKF_INTR(framep)       ((framep)->tf_flags & TFF_INTR)
> -#define      CLKF_USERMODE(framep)   ((framep)->tf_flags & T_USER)
> -#define      CLKF_SYSCALL(framep)    ((framep)->tf_flags & TFF_SYS)
> -
>  #define      need_proftick(p)        setsoftast(p)
>  #define      PROC_PC(p)              ((p)->p_md.md_regs->tf_iioq_head & 
> ~HPPA_PC_PRIV_MASK)
>  #define      PROC_STACK(p)           ((p)->p_md.md_regs->tf_sp)
> Index: hppa/include/frame.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/hppa/include/frame.h,v
> retrieving revision 1.19
> diff -u -p -r1.19 frame.h
> --- hppa/include/frame.h      21 Jun 2012 00:56:59 -0000      1.19
> +++ hppa/include/frame.h      29 Aug 2022 16:28:56 -0000
> @@ -136,6 +136,12 @@ struct trapframe {
>       unsigned long   tf_pad[3];      /* pad to 256 bytes */
>  };
>  
> +#define      clockframe              trapframe
> +#define      CLKF_PC(framep)         ((framep)->tf_iioq_head)
> +#define      CLKF_INTR(framep)       ((framep)->tf_flags & TFF_INTR)
> +#define      CLKF_USERMODE(framep)   ((framep)->tf_flags & T_USER)
> +#define      CLKF_SYSCALL(framep)    ((framep)->tf_flags & TFF_SYS)
> +
>  #ifdef _KERNEL
>  int  setstack(struct trapframe *, u_long, register_t);
>  #endif /* _KERNEL */
> Index: i386/include/cpu.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/i386/include/cpu.h,v
> retrieving revision 1.179
> diff -u -p -r1.179 cpu.h
> --- i386/include/cpu.h        29 Aug 2022 02:58:13 -0000      1.179
> +++ i386/include/cpu.h        29 Aug 2022 16:28:56 -0000
> @@ -55,15 +55,6 @@
>  
>  #endif /* _KERNEL */
>  
> -/*
> - * Arguments to hardclock, softclock and statclock
> - * encapsulate the previous machine state in an opaque
> - * clockframe; for now, use generic intrframe.
> - *
> - * XXX intrframe has a lot of gunk we don't need.
> - */
> -#define clockframe intrframe
> -
>  #include <sys/device.h>
>  #include <sys/sched.h>
>  #include <sys/sensors.h>
> @@ -274,10 +265,6 @@ unsigned int cpu_rnd_messybits(void);
>   */
>  extern void need_resched(struct cpu_info *);
>  #define clear_resched(ci) (ci)->ci_want_resched = 0
> -
> -#define      CLKF_USERMODE(frame)    USERMODE((frame)->if_cs, 
> (frame)->if_eflags)
> -#define      CLKF_PC(frame)          ((frame)->if_eip)
> -#define      CLKF_INTR(frame)        (IDXSEL((frame)->if_cs) == GICODE_SEL)
>  
>  /*
>   * This is used during profiling to integrate system time.
> Index: i386/include/frame.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/i386/include/frame.h,v
> retrieving revision 1.13
> diff -u -p -r1.13 frame.h
> --- i386/include/frame.h      15 Jun 2018 17:58:41 -0000      1.13
> +++ i386/include/frame.h      29 Aug 2022 16:28:56 -0000
> @@ -170,4 +170,17 @@ struct sigframe {
>       struct  sigcontext sf_sc;
>       siginfo_t sf_si;
>  };
> +
> +/*
> + * Arguments to hardclock, softclock and statclock
> + * encapsulate the previous machine state in an opaque
> + * clockframe; for now, use generic intrframe.
> + *
> + * XXX intrframe has a lot of gunk we don't need.
> + */
> +#define clockframe intrframe
> +#define      CLKF_USERMODE(frame)    USERMODE((frame)->if_cs, 
> (frame)->if_eflags)
> +#define      CLKF_PC(frame)          ((frame)->if_eip)
> +#define      CLKF_INTR(frame)        (IDXSEL((frame)->if_cs) == GICODE_SEL)
> +
>  #endif
> Index: m88k/include/cpu.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/m88k/include/cpu.h,v
> retrieving revision 1.70
> diff -u -p -r1.70 cpu.h
> --- m88k/include/cpu.h        6 Jul 2021 09:34:06 -0000       1.70
> +++ m88k/include/cpu.h        29 Aug 2022 16:28:56 -0000
> @@ -250,22 +250,6 @@ unsigned int cpu_rnd_messybits(void);
>  #include <sys/mplock.h>
>  #endif
>  
> -/*
> - * Arguments to hardclock and gatherstats encapsulate the previous
> - * machine state in an opaque clockframe. CLKF_INTR is only valid
> - * if the process is in kernel mode. Clockframe is really trapframe,
> - * so pointer to clockframe can be safely cast into a pointer to
> - * trapframe.
> - */
> -struct clockframe {
> -     struct trapframe tf;
> -};
> -
> -#define      CLKF_USERMODE(framep)   (((framep)->tf.tf_epsr & PSR_MODE) == 0)
> -#define      CLKF_PC(framep)         ((framep)->tf.tf_sxip & XIP_ADDR)
> -#define      CLKF_INTR(framep) \
> -     (((struct cpu_info *)(framep)->tf.tf_cpu)->ci_intrdepth > 1)
> -
>  #define      aston(p)                ((p)->p_md.md_astpending = 1)
>  
>  /*
> Index: m88k/include/frame.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/m88k/include/frame.h,v
> retrieving revision 1.4
> diff -u -p -r1.4 frame.h
> --- m88k/include/frame.h      15 Nov 2007 21:24:12 -0000      1.4
> +++ m88k/include/frame.h      29 Aug 2022 16:28:56 -0000
> @@ -87,4 +87,20 @@ struct trapframe {
>  #define      tf_fprl         tf_regs.fprl
>  #define      tf_fpit         tf_regs.fpit
>  
> +/*
> + * Arguments to hardclock and gatherstats encapsulate the previous
> + * machine state in an opaque clockframe. CLKF_INTR is only valid
> + * if the process is in kernel mode. Clockframe is really trapframe,
> + * so pointer to clockframe can be safely cast into a pointer to
> + * trapframe.
> + */
> +struct clockframe {
> +     struct trapframe tf;
> +};
> +
> +#define      CLKF_USERMODE(framep)   (((framep)->tf.tf_epsr & PSR_MODE) == 0)
> +#define      CLKF_PC(framep)         ((framep)->tf.tf_sxip & XIP_ADDR)
> +#define      CLKF_INTR(framep) \
> +     (((struct cpu_info *)(framep)->tf.tf_cpu)->ci_intrdepth > 1)
> +
>  #endif /* _M88K_FRAME_H_ */
> Index: mips64/include/cpu.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/mips64/include/cpu.h,v
> retrieving revision 1.139
> diff -u -p -r1.139 cpu.h
> --- mips64/include/cpu.h      22 Aug 2022 00:35:06 -0000      1.139
> +++ mips64/include/cpu.h      29 Aug 2022 16:28:56 -0000
> @@ -265,17 +265,6 @@ unsigned int cpu_rnd_messybits(void);
>  #include <machine/frame.h>
>  
>  /*
> - * Arguments to hardclock encapsulate the previous machine state in
> - * an opaque clockframe.
> - */
> -#define      clockframe trapframe    /* Use normal trap frame */
> -
> -#define      SR_KSU_USER             0x00000010
> -#define      CLKF_USERMODE(framep)   ((framep)->sr & SR_KSU_USER)
> -#define      CLKF_PC(framep)         ((framep)->pc)
> -#define      CLKF_INTR(framep)       (curcpu()->ci_intrdepth > 1)    /* XXX 
> */
> -
> -/*
>   * This is used during profiling to integrate system time.
>   */
>  #define      PROC_PC(p)      ((p)->p_md.md_regs->pc)
> Index: mips64/include/frame.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/mips64/include/frame.h,v
> retrieving revision 1.8
> diff -u -p -r1.8 frame.h
> --- mips64/include/frame.h    29 Apr 2021 12:49:19 -0000      1.8
> +++ mips64/include/frame.h    29 Aug 2022 16:28:56 -0000
> @@ -111,4 +111,14 @@ struct trapframe {
>       register_t      fsr;
>  };
>  
> +/*
> + * Arguments to hardclock encapsulate the previous machine state in
> + * an opaque clockframe.
> + */
> +#define      clockframe trapframe    /* Use normal trap frame */
> +#define      SR_KSU_USER             0x00000010
> +#define      CLKF_USERMODE(framep)   ((framep)->sr & SR_KSU_USER)
> +#define      CLKF_PC(framep)         ((framep)->pc)
> +#define      CLKF_INTR(framep)       (curcpu()->ci_intrdepth > 1)    /* XXX 
> */
> +
>  #endif       /* !_MIPS64_FRAME_H_ */
> Index: powerpc/include/cpu.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/powerpc/include/cpu.h,v
> retrieving revision 1.72
> diff -u -p -r1.72 cpu.h
> --- powerpc/include/cpu.h     24 Jul 2022 00:28:09 -0000      1.72
> +++ powerpc/include/cpu.h     29 Aug 2022 16:28:56 -0000
> @@ -155,10 +155,6 @@ void cpu_unidle(struct cpu_info *);
>  
>  extern struct cpu_info cpu_info[PPC_MAXPROCS];
>  
> -#define      CLKF_USERMODE(frame)    (((frame)->srr1 & PSL_PR) != 0)
> -#define      CLKF_PC(frame)          ((frame)->srr0)
> -#define      CLKF_INTR(frame)        ((frame)->depth != 0)
> -
>  extern int ppc_cpuidle;
>  extern int ppc_proc_is_64b;
>  extern int ppc_nobat;
> Index: powerpc/include/frame.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/powerpc/include/frame.h,v
> retrieving revision 1.7
> diff -u -p -r1.7 frame.h
> --- powerpc/include/frame.h   6 Jan 2006 18:53:05 -0000       1.7
> +++ powerpc/include/frame.h   29 Aug 2022 16:28:56 -0000
> @@ -55,6 +55,10 @@ struct clockframe {
>       int depth;
>  };
>  
> +#define      CLKF_USERMODE(frame)    (((frame)->srr1 & PSL_PR) != 0)
> +#define      CLKF_PC(frame)          ((frame)->srr0)
> +#define      CLKF_INTR(frame)        ((frame)->depth != 0)
> +
>  /*
>   * Call frame for PowerPC used during fork.
>   */
> Index: powerpc64/include/cpu.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/powerpc64/include/cpu.h,v
> retrieving revision 1.32
> diff -u -p -r1.32 cpu.h
> --- powerpc64/include/cpu.h   9 Aug 2022 04:40:08 -0000       1.32
> +++ powerpc64/include/cpu.h   29 Aug 2022 16:28:56 -0000
> @@ -161,12 +161,6 @@ void     mp_setperf(int);
>  
>  #endif
>  
> -#define clockframe trapframe
> -
> -#define CLKF_INTR(frame)     (curcpu()->ci_idepth > 1)
> -#define CLKF_USERMODE(frame) (frame->srr1 & PSL_PR)
> -#define CLKF_PC(frame)               (frame->srr0)
> -
>  #define aston(p)             ((p)->p_md.md_astpending = 1)
>  #define need_proftick(p)     aston(p)
>  
> Index: powerpc64/include/frame.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/powerpc64/include/frame.h,v
> retrieving revision 1.5
> diff -u -p -r1.5 frame.h
> --- powerpc64/include/frame.h 13 Jul 2020 22:37:37 -0000      1.5
> +++ powerpc64/include/frame.h 29 Aug 2022 16:28:56 -0000
> @@ -101,4 +101,9 @@ struct switchframe {
>       register_t      sf_r31;
>  };
>  
> +#define clockframe trapframe
> +#define CLKF_INTR(frame)     (curcpu()->ci_idepth > 1)
> +#define CLKF_USERMODE(frame) (frame->srr1 & PSL_PR)
> +#define CLKF_PC(frame)               (frame->srr0)
> +
>  #endif /* _MACHDEP_FRAME_H_ */
> Index: riscv64/include/cpu.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/riscv64/include/cpu.h,v
> retrieving revision 1.14
> diff -u -p -r1.14 cpu.h
> --- riscv64/include/cpu.h     29 Aug 2022 02:01:18 -0000      1.14
> +++ riscv64/include/cpu.h     29 Aug 2022 16:28:56 -0000
> @@ -42,26 +42,6 @@
>  #include <machine/frame.h>
>  #include <machine/riscvreg.h>
>  
> -/* All the CLKF_* macros take a struct clockframe * as an argument. */
> -
> -#define clockframe trapframe
> -/*
> - * CLKF_USERMODE: Return TRUE/FALSE (1/0) depending on whether the
> - * frame came from USR mode or not.
> - */
> -#define CLKF_USERMODE(frame) ((frame->tf_sstatus & SSTATUS_SPP) == 0)
> -
> -/*
> - * CLKF_INTR: True if we took the interrupt from inside another
> - * interrupt handler.
> - */
> -#define CLKF_INTR(frame)     (curcpu()->ci_idepth > 1)
> -
> -/*
> - * CLKF_PC: Extract the program counter from a clockframe
> - */
> -#define CLKF_PC(frame)               (frame->tf_sepc)
> -
>  /*
>   * PROC_PC: Find out the program counter for the given process.
>   */
> Index: riscv64/include/frame.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/riscv64/include/frame.h,v
> retrieving revision 1.3
> diff -u -p -r1.3 frame.h
> --- riscv64/include/frame.h   24 Feb 2022 14:19:10 -0000      1.3
> +++ riscv64/include/frame.h   29 Aug 2022 16:28:56 -0000
> @@ -49,7 +49,6 @@
>  /*
>   * Exception/Trap Stack Frame
>   */
> -#define clockframe trapframe
>  typedef struct trapframe {
>       /* Standard Registers */
>       register_t tf_ra;
> @@ -66,6 +65,26 @@ typedef struct trapframe {
>       register_t tf_scause;
>       register_t tf_pad;
>  } trapframe_t;
> +
> +/* All the CLKF_* macros take a struct clockframe * as an argument. */
> +#define clockframe trapframe
> +
> +/*
> + * CLKF_USERMODE: Return TRUE/FALSE (1/0) depending on whether the
> + * frame came from USR mode or not.
> + */
> +#define CLKF_USERMODE(frame) ((frame->tf_sstatus & SSTATUS_SPP) == 0)
> +
> +/*
> + * CLKF_INTR: True if we took the interrupt from inside another
> + * interrupt handler.
> + */
> +#define CLKF_INTR(frame)     (curcpu()->ci_idepth > 1)
> +
> +/*
> + * CLKF_PC: Extract the program counter from a clockframe
> + */
> +#define CLKF_PC(frame)               (frame->tf_sepc)
>  
>  /*
>   * pushed on stack for signal delivery
> Index: sh/include/cpu.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/sh/include/cpu.h,v
> retrieving revision 1.33
> diff -u -p -r1.33 cpu.h
> --- sh/include/cpu.h  21 Feb 2022 10:44:58 -0000      1.33
> +++ sh/include/cpu.h  29 Aug 2022 16:28:56 -0000
> @@ -88,21 +88,6 @@ extern struct cpu_info cpu_info_store;
>  
>  #define CPU_BUSY_CYCLE()     do {} while (0)
>  
> -
> -/*
> - * Arguments to hardclock and gatherstats encapsulate the previous
> - * machine state in an opaque clockframe.
> - */
> -struct clockframe {
> -     int     spc;    /* program counter at time of interrupt */
> -     int     ssr;    /* status register at time of interrupt */
> -     int     ssp;    /* stack pointer at time of interrupt */
> -};
> -
> -#define      CLKF_USERMODE(cf)       (!KERNELMODE((cf)->ssr))
> -#define      CLKF_PC(cf)             ((cf)->spc)
> -#define      CLKF_INTR(cf)           0       /* XXX */
> -
>  /*
>   * This is used during profiling to integrate system time.  It can safely
>   * assume that the process is resident.
> Index: sh/include/frame.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/sh/include/frame.h,v
> retrieving revision 1.3
> diff -u -p -r1.3 frame.h
> --- sh/include/frame.h        18 May 2016 20:21:13 -0000      1.3
> +++ sh/include/frame.h        29 Aug 2022 16:28:56 -0000
> @@ -130,4 +130,18 @@ struct switchframe {
>       int     sf_mach;
>  };
>  
> +/*
> + * Arguments to hardclock and gatherstats encapsulate the previous
> + * machine state in an opaque clockframe.
> + */
> +struct clockframe {
> +     int     spc;    /* program counter at time of interrupt */
> +     int     ssr;    /* status register at time of interrupt */
> +     int     ssp;    /* stack pointer at time of interrupt */
> +};
> +
> +#define      CLKF_USERMODE(cf)       (!KERNELMODE((cf)->ssr))
> +#define      CLKF_PC(cf)             ((cf)->spc)
> +#define      CLKF_INTR(cf)           0       /* XXX */
> +
>  #endif /* !_SH_FRAME_H_ */
> Index: sparc64/include/cpu.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/sparc64/include/cpu.h,v
> retrieving revision 1.98
> diff -u -p -r1.98 cpu.h
> --- sparc64/include/cpu.h     6 Jul 2021 09:34:07 -0000       1.98
> +++ sparc64/include/cpu.h     29 Aug 2022 16:28:56 -0000
> @@ -265,20 +265,6 @@ do {                                                     
>                 \
>               : : : "memory");                                        \
>  } while (0)
>  
> -/*
> - * Arguments to hardclock, softclock and gatherstats encapsulate the
> - * previous machine state in an opaque clockframe.  The ipl is here
> - * as well for strayintr (see locore.s:interrupt and intr.c:strayintr).
> - */
> -struct clockframe {
> -     struct trapframe64 t;
> -     int saved_intr_level;
> -};
> -
> -#define      CLKF_USERMODE(framep)   (((framep)->t.tf_tstate & TSTATE_PRIV) 
> == 0)
> -#define      CLKF_PC(framep)         ((framep)->t.tf_pc)
> -#define      CLKF_INTR(framep)       ((framep)->saved_intr_level != 0)
> -
>  extern void (*cpu_start_clock)(void);
>  
>  #define aston(p)     ((p)->p_md.md_astpending = 1)
> Index: sparc64/include/frame.h
> ===================================================================
> RCS file: /cvs/src/sys/arch/sparc64/include/frame.h,v
> retrieving revision 1.6
> diff -u -p -r1.6 frame.h
> --- sparc64/include/frame.h   23 Mar 2011 16:54:37 -0000      1.6
> +++ sparc64/include/frame.h   29 Aug 2022 16:28:56 -0000
> @@ -116,4 +116,19 @@ struct frame64 {
>   */
>  #define BIAS (2048-1)
>  
> +/*
> + * Arguments to hardclock, softclock and gatherstats encapsulate the
> + * previous machine state in an opaque clockframe.  The ipl is here
> + * as well for strayintr (see locore.s:interrupt and intr.c:strayintr).
> + */
> +struct trapframe64;
> +struct clockframe {
> +     struct trapframe64 t;
> +     int saved_intr_level;
> +};
> +
> +#define      CLKF_USERMODE(framep)   (((framep)->t.tf_tstate & TSTATE_PRIV) 
> == 0)
> +#define      CLKF_PC(framep)         ((framep)->t.tf_pc)
> +#define      CLKF_INTR(framep)       ((framep)->saved_intr_level != 0)
> +
>  #endif /* _MACHINE_FRAME_H_ */
> 

Reply via email to