#ifndef _OR1K_CPU_H_
#define _OR1K_CPU_H_
#if defined(_KERNEL) || defined(_KMEMUSER)
struct clockframe {
uintptr_t cf_pc;
uint32_t cf_sr;
int cf_intr_depth;
};
#define CLKF_USERMODE(cf) (((cf)->cf_sr & 1) == 0)
#define CLKF_PC(cf) ((cf)->cf_pc)
#define CLKF_INTR(cf) ((cf)->cf_intr_depth > 0)
#include <sys/cpu_data.h>
#include <sys/device_if.h>
#include <sys/intr.h>
struct cpu_info {
struct cpu_data ci_data;
device_t ci_dev;
cpuid_t ci_cpuid;
struct lwp *ci_curlwp;
struct lwp *ci_onproc;
struct lwp *ci_softlwps[SOFTINT_COUNT];
uint64_t ci_lastintr;
int ci_mtx_oldspl;
int ci_mtx_count;
int ci_want_resched;
int ci_cpl;
u_int ci_softints;
volatile u_int ci_intr_depth;
#if defined(GPROF) && defined(MULTIPROCESSOR)
struct gmonparam *ci_gmon;
#endif
};
register struct lwp *or1k_curlwp __asm("r10");
#define curlwp or1k_curlwp
static __inline struct cpu_info *
curcpu(void)
{
return curlwp->l_cpu;
}
static __inline cpuid_t
cpu_number(void)
{
#ifdef MULTIPROCESSOR
return curcpu()->ci_cpuid;
#else
return 0;
#endif
}
void cpu_proc_fork(struct proc *, struct proc *);
void cpu_signotify(struct lwp *);
void cpu_need_proftick(struct lwp *l);
void cpu_boot_secondary_processors(void);
#define CPU_INFO_ITERATOR cpuid_t
#ifdef MULTIPROCESSOR
#define CPU_INFO_FOREACH(cii, ci) \
(cii) = 0; ((ci) = cpu_infos[cii]) != NULL; (cii)++
#else
#define CPU_INFO_FOREACH(cii, ci) \
(cii) = 0; (cii) == 0 && (ci) = curcpu(); (cii)++
#endif
static __inline void
cpu_dosoftints(void)
{
extern void dosoftints(void);
struct cpu_info * const ci = curcpu();
if (ci->ci_intr_depth == 0
&& (ci->ci_data.cpu_softints >> ci->ci_cpl) > 0)
dosoftints();
}
static __inline bool
cpu_intr_p(void)
{
return curcpu()->ci_intr_depth > 0;
}
#endif
#endif