#ifndef _MACHINE_CPU_H_
#define _MACHINE_CPU_H_
#ifdef _KERNEL_OPT
#include "opt_cputype.h"
#include "opt_gprof.h"
#include "opt_multiprocessor.h"
#endif
#include <machine/trap.h>
#include <machine/frame.h>
#include <machine/reg.h>
#include <machine/intrdefs.h>
#ifndef __ASSEMBLER__
#include <machine/intr.h>
#endif
#ifndef _LOCORE
enum hppa_cpu_type {
hpc_unknown,
hpcx,
hpcxs,
hpcxt,
hpcxl,
hpcxtp,
hpcxl2,
hpcxu,
hpcxup,
hpcxw,
hpcxwp,
hpcxw2,
mako
};
#ifdef _KERNEL
struct hppa_cpu_info {
const char *hci_chip_name;
const char *hci_chip_nickname;
const char hci_chip_type[8];
enum hppa_cpu_type hci_cputype;
int hci_cpuversion;
int hci_features;
#define HPPA_FTRS_TLBU 0x00000001
#define HPPA_FTRS_BTLBU 0x00000002
#define HPPA_FTRS_HVT 0x00000004
#define HPPA_FTRS_W32B 0x00000008
const char *hci_chip_spec;
int (*desidhash)(void);
const u_int *itlbh, *dtlbh, *itlbnah, *dtlbnah, *tlbdh;
int (*dbtlbins)(int, pa_space_t, vaddr_t, paddr_t, vsize_t, u_int);
int (*ibtlbins)(int, pa_space_t, vaddr_t, paddr_t, vsize_t, u_int);
int (*btlbprg)(int);
int (*hptinit)(vaddr_t, vsize_t);
};
extern const struct hppa_cpu_info *hppa_cpu_info;
extern int cpu_modelno;
extern int cpu_revision;
#endif
#endif
#define HPPA_FPUS 0xc0
#define HPPA_PMSFUS 0x20
#define HPPA_FPUVER(w) (((w) & 0x003ff800) >> 11)
#define HPPA_FPU_OP(w) ((w) >> 26)
#define HPPA_FPU_UNMPL 0x01
#define HPPA_FPU_ILL 0x80
#define HPPA_FPU_I 0x01
#define HPPA_FPU_U 0x02
#define HPPA_FPU_O 0x04
#define HPPA_FPU_Z 0x08
#define HPPA_FPU_V 0x10
#define HPPA_FPU_D 0x20
#define HPPA_FPU_T 0x40
#define HPPA_FPU_XMASK 0x7f
#define HPPA_FPU_T_POS 25
#define HPPA_FPU_RM 0x00000600
#define HPPA_FPU_CQ 0x00fff800
#define HPPA_FPU_C 0x04000000
#define HPPA_FPU_FLSH 27
#define HPPA_FPU_INIT (0)
#define HPPA_FPU_FORK(s) ((s) & ~((uint64_t)(HPPA_FPU_XMASK) << 32))
#if defined(HP8000_CPU) || defined(HP8200_CPU) || \
defined(HP8500_CPU) || defined(HP8600_CPU)
#define HPPA_PGALIAS 0x00400000
#define HPPA_PGAMASK 0xffc00000
#define HPPA_PGAOFF 0x003fffff
#else
#define HPPA_PGALIAS 0x00100000
#define HPPA_PGAMASK 0xfff00000
#define HPPA_PGAOFF 0x000fffff
#endif
#define HPPA_SPAMASK 0xf0f0f000
#define HPPA_IOSPACE 0xf0000000
#define HPPA_IOLEN 0x10000000
#define HPPA_PDC_LOW 0xef000000
#define HPPA_PDC_HIGH 0xf1000000
#define HPPA_IOBCAST 0xfffc0000
#define HPPA_LBCAST 0xfffc0000
#define HPPA_GBCAST 0xfffe0000
#define HPPA_FPA 0xfff80000
#define HPPA_FLEX_DATA 0xfff80001
#define HPPA_DMA_ENABLE 0x00000001
#define HPPA_SPA_ENABLE 0x00000020
#define HPPA_NMODSPBUS 64
#ifdef MULTIPROCESSOR
#define GET_CURCPU(r) mfctl CR_CURCPU, r
#define GET_CURCPU_SPACE(s, r) GET_CURCPU(r)
#define GET_CURLWP(r) mfctl CR_CURCPU, r ! ldw CI_CURLWP(r), r
#define GET_CURLWP_SPACE(s, r) mfctl CR_CURCPU, r ! ldw CI_CURLWP(s, r), r
#define SET_CURLWP(r,t) \
sync ! mfctl CR_CURCPU, t ! stw r, CI_CURLWP(t) ! sync
#else
#define GET_CURCPU(r) mfctl CR_CURLWP, r ! ldw L_CPU(r), r
#define GET_CURCPU_SPACE(s, r) mfctl CR_CURLWP, r ! ldw L_CPU(s, r), r
#define GET_CURLWP(r) mfctl CR_CURLWP, r
#define GET_CURLWP_SPACE(s, r) GET_CURLWP(r)
#define SET_CURLWP(r,t) mtctl r, CR_CURLWP
#endif
#ifndef _LOCORE
#ifdef _KERNEL
struct clockframe {
int cf_flags;
int cf_spl;
u_int cf_pc;
};
#define CLKF_PC(framep) ((framep)->cf_pc)
#define CLKF_INTR(framep) ((framep)->cf_flags & TFF_INTR)
#define CLKF_USERMODE(framep) ((framep)->cf_flags & T_USER)
int clock_intr(void *);
#define LWP_PC(l) ((l)->l_md.md_regs->tf_iioq_head)
#define cpu_signotify(l) (setsoftast(l))
#define cpu_need_proftick(l) ((l)->l_pflag |= LP_OWEUPC, setsoftast(l))
#endif
#ifndef __ASSEMBLER__
#if defined(_KERNEL) || defined(_KMEMUSER)
#include <sys/cpu_data.h>
#include <sys/evcnt.h>
struct cpu_info {
register_t ci_trapsave[16];
struct cpu_data ci_data;
#ifndef _KMEMUSER
hppa_hpa_t ci_hpa;
register_t ci_psw;
paddr_t ci_fpu_state;
u_long ci_itmr;
int ci_cpuid;
int ci_mtx_count;
int ci_mtx_oldspl;
int ci_want_resched;
volatile int ci_cpl;
volatile int ci_ipending;
u_int ci_intr_depth;
u_int ci_ishared;
u_int ci_eiem;
u_int ci_imask[NIPL];
struct hppa_interrupt_register ci_ir;
struct hppa_interrupt_bit ci_ib[HPPA_INTERRUPT_BITS];
struct lwp *ci_onproc;
#if defined(MULTIPROCESSOR)
struct lwp *ci_curlwp;
paddr_t ci_stack;
volatile int ci_flags;
#define CPUF_PRIMARY 0x0001
#define CPUF_RUNNING 0x0002
volatile u_long ci_ipi;
struct cpu_softc *ci_softc;
#endif
#if defined(GPROF) && defined(MULTIPROCESSOR)
struct gmonparam *ci_gmon;
#endif
#endif
} __aligned(64);
#endif
#endif
#if defined(_KERNEL)
void cpu_proc_fork(struct proc *, struct proc *);
struct lwp *hppa_curlwp(void);
struct cpu_info *hppa_curcpu(void);
#if defined(_MODULE)
#define curcpu() hppa_curcpu()
#define curlwp hppa_curlwp()
#endif
#if defined(MULTIPROCESSOR) || defined(_MODULE)
extern int hppa_ncpu;
#define HPPA_MAXCPUS 4
#define cpu_number() (curcpu()->ci_cpuid)
#define CPU_IS_PRIMARY(ci) ((ci)->ci_cpuid == 0)
#define CPU_INFO_ITERATOR int
#define CPU_INFO_FOREACH(cii, ci) cii = 0, ci = &cpus[0]; cii < hppa_ncpu; cii++, ci++
void cpu_boot_secondary_processors(void);
#if !defined(_MODULE)
static __inline __always_inline struct cpu_info *
_hppa_curcpu(void)
{
struct cpu_info *ci;
__asm volatile("mfctl %1, %0" : "=r" (ci): "i" (CR_CURCPU));
return ci;
}
#define curcpu() _hppa_curcpu()
#endif
#else
#define HPPA_MAXCPUS 1
#define curcpu() (&cpus[0])
#define cpu_number() 0
static __inline struct lwp *
_hppa_curlwp(void)
{
struct lwp *l;
__asm volatile("mfctl %1, %0" : "=r" (l): "i" (CR_CURLWP));
return l;
}
#define curlwp _hppa_curlwp()
#endif
extern struct cpu_info cpus[HPPA_MAXCPUS];
#define DELAY(x) delay(x)
static __inline paddr_t
kvtop(const void *va)
{
paddr_t pa;
__asm volatile ("lpa %%r0(%1), %0" : "=r" (pa) : "r" (va));
return pa;
}
extern int (*cpu_desidhash)(void);
static __inline bool
hppa_cpu_ispa20_p(void)
{
return (hppa_cpu_info->hci_features & HPPA_FTRS_W32B) != 0;
}
static __inline bool
hppa_cpu_hastlbu_p(void)
{
return (hppa_cpu_info->hci_features & HPPA_FTRS_TLBU) != 0;
}
void delay(u_int);
void hppa_init(paddr_t, void *);
void trap(int, struct trapframe *);
void hppa_ras(struct lwp *);
int spcopy(pa_space_t, const void *, pa_space_t, void *, size_t);
int spstrcpy(pa_space_t, const void *, pa_space_t, void *, size_t,
size_t *);
int copy_on_fault(void);
void lwp_trampoline(void);
int cpu_dumpsize(void);
int cpu_dump(void);
#ifdef MULTIPROCESSOR
void cpu_boot_secondary_processors(void);
void cpu_hw_init(void);
void cpu_hatch(void);
#endif
#endif
#define BOOTARG_LEN (PAGE_SIZE)
#define BOOTARG_OFF (0x10000)
#define CPU_CONSDEV 1
#define CPU_BOOTED_KERNEL 2
#define CPU_LCD_BLINK 3
#ifdef _KERNEL
#include <sys/queue.h>
struct blink_lcd {
void (*bl_func)(void *, int);
void *bl_arg;
SLIST_ENTRY(blink_lcd) bl_next;
};
extern void blink_lcd_register(struct blink_lcd *);
#endif
#endif
#endif