#ifndef _VAX_CPU_H_
#define _VAX_CPU_H_
#if defined(_KERNEL_OPT)
#include "opt_gprof.h"
#include "opt_multiprocessor.h"
#include "opt_lockdebug.h"
#endif
#define CPU_PRINTFATALTRAPS 1
#define CPU_CONSDEV 2
#define CPU_BOOTED_DEVICE 3
#define CPU_BOOTED_KERNEL 4
#ifdef _KERNEL
#include <sys/cdefs.h>
#include <sys/queue.h>
#include <sys/device_if.h>
#include <sys/cpu_data.h>
#include <machine/mtpr.h>
#include <machine/pcb.h>
#include <machine/uvax.h>
#include <machine/psl.h>
#define enablertclock()
struct cpu_info;
struct cpu_dep {
void (*cpu_steal_pages)(void);
int (*cpu_mchk)(void *);
void (*cpu_memerr)(void);
void (*cpu_conf)(void);
int (*cpu_gettime)(struct timeval *);
void (*cpu_settime)(struct timeval *);
short cpu_vups;
short cpu_scbsz;
void (*cpu_halt)(void);
void (*cpu_reboot)(int);
void (*cpu_clrf)(void);
const char * const *cpu_devs;
void (*cpu_attach_cpu)(device_t);
int cpu_flags;
void (*cpu_badaddr)(void);
};
#if defined(MULTIPROCESSOR)
struct cpu_mp_dep {
void (*cpu_startslave)(struct cpu_info *);
void (*cpu_send_ipi)(struct cpu_info *);
void (*cpu_cnintr)(void);
};
#define IPI_START_CNTX 1
#define IPI_SEND_CNCHAR 2
#define IPI_RUNNING 3
#define IPI_TBIA 4
#define IPI_DDB 5
#define IPI_XCALL 6
#define IPI_GENERIC 7
#define IPI_DEST_MASTER -1
#define IPI_DEST_ALL -2
extern const struct cpu_mp_dep *mp_dep_call;
#endif
#define CPU_RAISEIPL 1
extern const struct cpu_dep *dep_call;
struct clockframe {
int pc;
int ps;
};
struct cpu_info {
struct cpu_data ci_data;
device_t ci_dev;
int ci_mtx_oldspl;
int ci_mtx_count;
int ci_cpuid;
int ci_want_resched;
#if defined(__HAVE_FAST_SOFTINTS)
lwp_t *ci_softlwps[SOFTINT_COUNT];
#endif
vaddr_t ci_istack;
const char *ci_cpustr;
int ci_slotid;
struct lwp *ci_onproc;
#if defined(MULTIPROCESSOR)
struct lwp *ci_curlwp;
volatile int ci_flags;
long ci_ipimsgs;
struct trapframe *ci_ddb_regs;
SIMPLEQ_ENTRY(cpu_info) ci_next;
#endif
uintptr_t ci_cas_addr;
#if defined(GPROF) && defined(MULTIPROCESSOR)
struct gmonparam *ci_gmon;
#endif
};
#define CI_MASTERCPU 1
#define CI_RUNNING 2
#define CI_STOPPED 4
extern int cpu_printfataltraps;
#define curcpu() (curlwp->l_cpu + 0)
#define curlwp ((struct lwp *)mfpr(PR_SSP))
#define cpu_number() (curcpu()->ci_cpuid)
#define cpu_need_resched(ci, l, flags) \
do { \
struct pcb *pcb = lwp_getpcb(curlwp); \
__USE(flags); \
pcb->P0LR = (pcb->P0LR & ~AST_MASK) | AST_ON; \
mtpr(AST_OK,PR_ASTLVL); \
} while ( 0)
#define cpu_proc_fork(x, y) do { } while (0)
static inline void
cpu_idle(void)
{
int ipl = mfpr(PR_IPL);
mtpr(1, PR_IPL);
mtpr(ipl, PR_IPL);
}
static inline bool
cpu_intr_p(void)
{
register_t psl;
__asm("movpsl %0" : "=g"(psl));
return (psl & PSL_IS) != 0;
}
#if defined(MULTIPROCESSOR)
#define CPU_IS_PRIMARY(ci) ((ci)->ci_flags & CI_MASTERCPU)
#define CPU_INFO_ITERATOR int __unused
#define CPU_INFO_FOREACH(cii, ci) ci = SIMPLEQ_FIRST(&cpus); \
ci != NULL; \
ci = SIMPLEQ_NEXT(ci, ci_next)
extern SIMPLEQ_HEAD(cpu_info_qh, cpu_info) cpus;
extern char vax_mp_tramp;
#endif
#define cpu_signotify(l) \
do { \
struct pcb *pcb = lwp_getpcb(l); \
pcb->P0LR = (pcb->P0LR & ~AST_MASK) | AST_ON; \
mtpr(AST_OK,PR_ASTLVL); \
} while ( 0)
#define cpu_need_proftick(l) \
do { \
struct pcb *pcb = lwp_getpcb(l); \
(l)->l_pflag |= LP_OWEUPC; \
pcb->P0LR = (pcb->P0LR & ~AST_MASK) | AST_ON; \
mtpr(AST_OK,PR_ASTLVL); \
} while ( 0)
#define IOSPSZ ((64*1024) / VAX_NBPG)
#define LWP_PC(l) cpu_lwp_pc(l)
struct buf;
struct pte;
#include <sys/lwp.h>
#if defined(MULTIPROCESSOR)
void cpu_slavesetup(device_t, int);
void cpu_boot_secondary_processors(void);
void cpu_send_ipi(int, int);
void cpu_handle_ipi(void);
#endif
vaddr_t cpu_lwp_pc(struct lwp *);
int badaddr(volatile void *, int);
void dumpsys(void);
void swapconf(void);
void disk_printtype(int, int);
void disk_reallymapin(struct buf *, struct pte *, int, int);
vaddr_t vax_map_physmem(paddr_t, size_t);
void vax_unmap_physmem(vaddr_t, size_t);
void ioaccess(vaddr_t, paddr_t, size_t);
void iounaccess(vaddr_t, size_t);
void findcpu(void);
#ifdef DDB
int kdbrint(int);
#endif
#endif
#ifdef _STANDALONE
void findcpu(void);
#endif
#endif