xref: /netbsd-src/sys/arch/hppa/include/cpu.h (revision 7dfcf7edb8fcc72bb2c72ff5e819fae01bfe0c00)
1*7dfcf7edSriastradh /*	$NetBSD: cpu.h,v 1.13 2023/02/23 14:55:36 riastradh Exp $	*/
26d3ceb1dSskrll 
36d3ceb1dSskrll /*	$OpenBSD: cpu.h,v 1.55 2008/07/23 17:39:35 kettenis Exp $	*/
46d3ceb1dSskrll 
56d3ceb1dSskrll /*
66d3ceb1dSskrll  * Copyright (c) 2000-2004 Michael Shalayeff
76d3ceb1dSskrll  * All rights reserved.
86d3ceb1dSskrll  *
96d3ceb1dSskrll  * Redistribution and use in source and binary forms, with or without
106d3ceb1dSskrll  * modification, are permitted provided that the following conditions
116d3ceb1dSskrll  * are met:
126d3ceb1dSskrll  * 1. Redistributions of source code must retain the above copyright
136d3ceb1dSskrll  *    notice, this list of conditions and the following disclaimer.
146d3ceb1dSskrll  * 2. Redistributions in binary form must reproduce the above copyright
156d3ceb1dSskrll  *    notice, this list of conditions and the following disclaimer in the
166d3ceb1dSskrll  *    documentation and/or other materials provided with the distribution.
176d3ceb1dSskrll  *
186d3ceb1dSskrll  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
196d3ceb1dSskrll  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
206d3ceb1dSskrll  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
216d3ceb1dSskrll  * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
226d3ceb1dSskrll  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
236d3ceb1dSskrll  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
246d3ceb1dSskrll  * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
256d3ceb1dSskrll  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
266d3ceb1dSskrll  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
276d3ceb1dSskrll  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
286d3ceb1dSskrll  * THE POSSIBILITY OF SUCH DAMAGE.
296d3ceb1dSskrll  */
306d3ceb1dSskrll /*
316d3ceb1dSskrll  * Copyright (c) 1988-1994, The University of Utah and
326d3ceb1dSskrll  * the Computer Systems Laboratory at the University of Utah (CSL).
336d3ceb1dSskrll  * All rights reserved.
346d3ceb1dSskrll  *
356d3ceb1dSskrll  * Permission to use, copy, modify and distribute this software is hereby
366d3ceb1dSskrll  * granted provided that (1) source code retains these copyright, permission,
376d3ceb1dSskrll  * and disclaimer notices, and (2) redistributions including binaries
386d3ceb1dSskrll  * reproduce the notices in supporting documentation, and (3) all advertising
396d3ceb1dSskrll  * materials mentioning features or use of this software display the following
406d3ceb1dSskrll  * acknowledgement: ``This product includes software developed by the
416d3ceb1dSskrll  * Computer Systems Laboratory at the University of Utah.''
426d3ceb1dSskrll  *
436d3ceb1dSskrll  * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
446d3ceb1dSskrll  * IS" CONDITION.  THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
456d3ceb1dSskrll  * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
466d3ceb1dSskrll  *
476d3ceb1dSskrll  * CSL requests users of this software to return to csl-dist@cs.utah.edu any
486d3ceb1dSskrll  * improvements that they make and grant CSL redistribution rights.
496d3ceb1dSskrll  *
5056a44a0bSskrll  * 	Utah $Hdr: cpu.h 1.19 94/12/16$
516d3ceb1dSskrll  */
526d3ceb1dSskrll 
536d3ceb1dSskrll #ifndef	_MACHINE_CPU_H_
546d3ceb1dSskrll #define	_MACHINE_CPU_H_
556d3ceb1dSskrll 
566d3ceb1dSskrll #ifdef _KERNEL_OPT
576d3ceb1dSskrll #include "opt_cputype.h"
58567a3a02Sryo #include "opt_gprof.h"
596d3ceb1dSskrll #include "opt_multiprocessor.h"
606d3ceb1dSskrll #endif
616d3ceb1dSskrll 
626d3ceb1dSskrll #include <machine/trap.h>
636d3ceb1dSskrll #include <machine/frame.h>
646d3ceb1dSskrll #include <machine/reg.h>
656d3ceb1dSskrll #include <machine/intrdefs.h>
666d3ceb1dSskrll 
676d3ceb1dSskrll #ifndef __ASSEMBLER__
686d3ceb1dSskrll #include <machine/intr.h>
696d3ceb1dSskrll #endif
706d3ceb1dSskrll 
716d3ceb1dSskrll #ifndef _LOCORE
726d3ceb1dSskrll 
736d3ceb1dSskrll /* types */
746d3ceb1dSskrll enum hppa_cpu_type {
756d3ceb1dSskrll 	hpc_unknown,
766d3ceb1dSskrll 	hpcx,	/* PA7000 (x)		PA 1.0 */
776d3ceb1dSskrll 	hpcxs,	/* PA7000 (s)		PA 1.1a */
786d3ceb1dSskrll 	hpcxt,	/* PA7100 (t)		PA 1.1b */
796d3ceb1dSskrll 	hpcxl,	/* PA7100LC (l)		PA 1.1c */
806d3ceb1dSskrll 	hpcxtp,	/* PA7200 (t')		PA 1.1d */
816d3ceb1dSskrll 	hpcxl2,	/* PA7300LC (l2)	PA 1.1e */
826d3ceb1dSskrll 	hpcxu,	/* PA8000 (u)		PA 2.0 */
836d3ceb1dSskrll 	hpcxup,	/* PA8200 (u+)		PA 2.0 */
846d3ceb1dSskrll 	hpcxw,	/* PA8500 (w)		PA 2.0 */
856d3ceb1dSskrll 	hpcxwp,	/* PA8600 (w+)		PA 2.0 */
866d3ceb1dSskrll 	hpcxw2, /* PA8700 (piranha)	PA 2.0 */
876d3ceb1dSskrll 	mako	/* PA8800 (mako)	PA 2.0 */
886d3ceb1dSskrll };
896d3ceb1dSskrll 
90c441eba8Schristos #ifdef _KERNEL
916d3ceb1dSskrll /*
926d3ceb1dSskrll  * A CPU description.
936d3ceb1dSskrll  */
946d3ceb1dSskrll struct hppa_cpu_info {
956d3ceb1dSskrll 	/* The official name of the chip. */
966d3ceb1dSskrll 	const char *hci_chip_name;
976d3ceb1dSskrll 
986d3ceb1dSskrll 	/* The nickname for the chip. */
996d3ceb1dSskrll 	const char *hci_chip_nickname;
1006d3ceb1dSskrll 
1016d3ceb1dSskrll 	/* The type and PA-RISC specification of the chip. */
1026d3ceb1dSskrll 	const char hci_chip_type[8];
1036d3ceb1dSskrll 	enum hppa_cpu_type hci_cputype;
1046d3ceb1dSskrll 	int  hci_cpuversion;
1056d3ceb1dSskrll 	int  hci_features;		/* CPU types and features */
1066d3ceb1dSskrll #define	HPPA_FTRS_TLBU		0x00000001
1076d3ceb1dSskrll #define	HPPA_FTRS_BTLBU		0x00000002
1086d3ceb1dSskrll #define	HPPA_FTRS_HVT		0x00000004
1096d3ceb1dSskrll #define	HPPA_FTRS_W32B		0x00000008
1106d3ceb1dSskrll 
1116d3ceb1dSskrll 	const char *hci_chip_spec;
1126d3ceb1dSskrll 
1136d3ceb1dSskrll 	int (*desidhash)(void);
1146d3ceb1dSskrll 	const u_int *itlbh, *dtlbh, *itlbnah, *dtlbnah, *tlbdh;
1156d3ceb1dSskrll 	int (*dbtlbins)(int, pa_space_t, vaddr_t, paddr_t, vsize_t, u_int);
1166d3ceb1dSskrll 	int (*ibtlbins)(int, pa_space_t, vaddr_t, paddr_t, vsize_t, u_int);
1176d3ceb1dSskrll 	int (*btlbprg)(int);
1186d3ceb1dSskrll 	int (*hptinit)(vaddr_t, vsize_t);
1196d3ceb1dSskrll };
1206d3ceb1dSskrll 
1216d3ceb1dSskrll extern const struct hppa_cpu_info *hppa_cpu_info;
1226d3ceb1dSskrll extern int cpu_modelno;
1236d3ceb1dSskrll extern int cpu_revision;
1246d3ceb1dSskrll #endif
1256d3ceb1dSskrll #endif
1266d3ceb1dSskrll 
1276d3ceb1dSskrll /*
1286d3ceb1dSskrll  * COPR/SFUs
1296d3ceb1dSskrll  */
1306d3ceb1dSskrll #define	HPPA_FPUS	0xc0
1316d3ceb1dSskrll #define	HPPA_PMSFUS	0x20	/* ??? */
1326d3ceb1dSskrll 
1336d3ceb1dSskrll /*
1346d3ceb1dSskrll  * Exported definitions unique to hppa/PA-RISC cpu support.
1356d3ceb1dSskrll  */
1366d3ceb1dSskrll 
1376d3ceb1dSskrll /*
1386d3ceb1dSskrll  * COPR/SFUs
1396d3ceb1dSskrll  */
1406d3ceb1dSskrll #define	HPPA_FPUVER(w)	(((w) & 0x003ff800) >> 11)
1416d3ceb1dSskrll #define	HPPA_FPU_OP(w)	((w) >> 26)
1426d3ceb1dSskrll #define	HPPA_FPU_UNMPL	0x01	/* exception reg, the rest is << 1 */
1436d3ceb1dSskrll #define	HPPA_FPU_ILL	0x80	/* software-only */
1446d3ceb1dSskrll #define	HPPA_FPU_I	0x01
1456d3ceb1dSskrll #define	HPPA_FPU_U	0x02
1466d3ceb1dSskrll #define	HPPA_FPU_O	0x04
1476d3ceb1dSskrll #define	HPPA_FPU_Z	0x08
1486d3ceb1dSskrll #define	HPPA_FPU_V	0x10
1496d3ceb1dSskrll #define	HPPA_FPU_D	0x20
1506d3ceb1dSskrll #define	HPPA_FPU_T	0x40
1516d3ceb1dSskrll #define	HPPA_FPU_XMASK	0x7f
1526d3ceb1dSskrll #define	HPPA_FPU_T_POS	25
1536d3ceb1dSskrll #define	HPPA_FPU_RM	0x00000600
1546d3ceb1dSskrll #define	HPPA_FPU_CQ	0x00fff800
1556d3ceb1dSskrll #define	HPPA_FPU_C	0x04000000
1566d3ceb1dSskrll #define	HPPA_FPU_FLSH	27
1576d3ceb1dSskrll #define	HPPA_FPU_INIT	(0)
1586d3ceb1dSskrll #define	HPPA_FPU_FORK(s) ((s) & ~((uint64_t)(HPPA_FPU_XMASK) << 32))
1596d3ceb1dSskrll 
1606d3ceb1dSskrll /*
1616d3ceb1dSskrll  * definitions of cpu-dependent requirements
1626d3ceb1dSskrll  * referenced in generic code
1636d3ceb1dSskrll  */
1646d3ceb1dSskrll #if defined(HP8000_CPU) || defined(HP8200_CPU) || \
1656d3ceb1dSskrll     defined(HP8500_CPU) || defined(HP8600_CPU)
1666d3ceb1dSskrll 
1676d3ceb1dSskrll /* PA2.0 aliases */
1686d3ceb1dSskrll #define	HPPA_PGALIAS	0x00400000
1696d3ceb1dSskrll #define	HPPA_PGAMASK	0xffc00000	/* PA bits 0-9 not used in index */
1706d3ceb1dSskrll #define	HPPA_PGAOFF	0x003fffff
1716d3ceb1dSskrll 
1726d3ceb1dSskrll #else
1736d3ceb1dSskrll 
1746d3ceb1dSskrll /* PA1.x aliases */
1756d3ceb1dSskrll #define	HPPA_PGALIAS	0x00100000
1766d3ceb1dSskrll #define	HPPA_PGAMASK	0xfff00000	/* PA bits 0-11 not used in index */
1776d3ceb1dSskrll #define	HPPA_PGAOFF	0x000fffff
1786d3ceb1dSskrll 
1796d3ceb1dSskrll #endif
1806d3ceb1dSskrll 
1816d3ceb1dSskrll #define	HPPA_SPAMASK	0xf0f0f000	/* PA bits 0-3,8-11,16-19 not used */
1826d3ceb1dSskrll 
1836d3ceb1dSskrll #define	HPPA_IOSPACE	0xf0000000
1846d3ceb1dSskrll #define	HPPA_IOLEN      0x10000000
1856d3ceb1dSskrll #define	HPPA_PDC_LOW	0xef000000
1866d3ceb1dSskrll #define	HPPA_PDC_HIGH	0xf1000000
1876d3ceb1dSskrll #define	HPPA_IOBCAST	0xfffc0000
1886d3ceb1dSskrll #define	HPPA_LBCAST	0xfffc0000
1896d3ceb1dSskrll #define	HPPA_GBCAST	0xfffe0000
1906d3ceb1dSskrll #define	HPPA_FPA	0xfff80000
1916d3ceb1dSskrll #define	HPPA_FLEX_DATA	0xfff80001
1926d3ceb1dSskrll #define	HPPA_DMA_ENABLE	0x00000001
1936d3ceb1dSskrll #define	HPPA_SPA_ENABLE	0x00000020
1946d3ceb1dSskrll #define	HPPA_NMODSPBUS	64
1956d3ceb1dSskrll 
1966d3ceb1dSskrll #ifdef MULTIPROCESSOR
1976d3ceb1dSskrll 
1986d3ceb1dSskrll #define	GET_CURCPU(r)		mfctl CR_CURCPU, r
1996d3ceb1dSskrll #define	GET_CURCPU_SPACE(s, r)	GET_CURCPU(r)
2006d3ceb1dSskrll #define	GET_CURLWP(r)		mfctl CR_CURCPU, r ! ldw CI_CURLWP(r), r
2016d3ceb1dSskrll #define	GET_CURLWP_SPACE(s, r)	mfctl CR_CURCPU, r ! ldw CI_CURLWP(s, r), r
2026d3ceb1dSskrll 
203*7dfcf7edSriastradh /*
204*7dfcf7edSriastradh  * Issue barriers to coordinate mutex_exit on this CPU with
205*7dfcf7edSriastradh  * mutex_vector_enter on another CPU.
206*7dfcf7edSriastradh  *
207*7dfcf7edSriastradh  * 1. Any prior mutex_exit by oldlwp must be visible to other
208*7dfcf7edSriastradh  *    CPUs before we set ci_curlwp := newlwp on this one,
209*7dfcf7edSriastradh  *    requiring a store-before-store barrier.
210*7dfcf7edSriastradh  *
211*7dfcf7edSriastradh  * 2. ci_curlwp := newlwp must be visible on all other CPUs
212*7dfcf7edSriastradh  *    before any subsequent mutex_exit by newlwp can even test
213*7dfcf7edSriastradh  *    whether there might be waiters, requiring a
214*7dfcf7edSriastradh  *    store-before-load barrier.
215*7dfcf7edSriastradh  *
216*7dfcf7edSriastradh  * See kern_mutex.c for details -- this is necessary for
217*7dfcf7edSriastradh  * adaptive mutexes to detect whether the lwp is on the CPU in
218*7dfcf7edSriastradh  * order to safely block without requiring atomic r/m/w in
219*7dfcf7edSriastradh  * mutex_exit.
220*7dfcf7edSriastradh  */
221*7dfcf7edSriastradh #define	SET_CURLWP(r,t)		\
222*7dfcf7edSriastradh 	sync ! mfctl CR_CURCPU, t ! stw r, CI_CURLWP(t) ! sync
2236d3ceb1dSskrll 
2246d3ceb1dSskrll #else /*  MULTIPROCESSOR */
2256d3ceb1dSskrll 
2266d3ceb1dSskrll #define	GET_CURCPU(r)		mfctl CR_CURLWP, r ! ldw L_CPU(r), r
2276d3ceb1dSskrll #define	GET_CURCPU_SPACE(s, r)	mfctl CR_CURLWP, r ! ldw L_CPU(s, r), r
2286d3ceb1dSskrll #define	GET_CURLWP(r)		mfctl CR_CURLWP, r
2296d3ceb1dSskrll #define	GET_CURLWP_SPACE(s, r)	GET_CURLWP(r)
2306d3ceb1dSskrll 
2316d3ceb1dSskrll #define	SET_CURLWP(r,t) mtctl   r, CR_CURLWP
2326d3ceb1dSskrll 
2336d3ceb1dSskrll #endif /*  MULTIPROCESSOR */
2346d3ceb1dSskrll 
2356d3ceb1dSskrll #ifndef _LOCORE
2366d3ceb1dSskrll #ifdef _KERNEL
2376d3ceb1dSskrll 
2386d3ceb1dSskrll /*
2396d3ceb1dSskrll  * External definitions unique to PA-RISC cpu support.
2406d3ceb1dSskrll  * These are the "public" declarations - those needed in
2416d3ceb1dSskrll  * machine-independent source code.  The "private" ones
2426d3ceb1dSskrll  * are in machdep.h.
2436d3ceb1dSskrll  *
2446d3ceb1dSskrll  * Note that the name of this file is NOT meant to imply
2456d3ceb1dSskrll  * that it has anything to do with PA-RISC CPU stuff.
2466d3ceb1dSskrll  * The name "cpu" is historical, and used in the common
2476d3ceb1dSskrll  * code to identify machine-dependent functions, etc.
2486d3ceb1dSskrll  */
2496d3ceb1dSskrll 
2506d3ceb1dSskrll /* clockframe describes the system before we took an interrupt. */
2516d3ceb1dSskrll struct clockframe {
2526d3ceb1dSskrll 	int	cf_flags;
2536d3ceb1dSskrll 	int	cf_spl;
2546d3ceb1dSskrll 	u_int	cf_pc;
2556d3ceb1dSskrll };
2566d3ceb1dSskrll #define	CLKF_PC(framep)		((framep)->cf_pc)
2576d3ceb1dSskrll #define	CLKF_INTR(framep)	((framep)->cf_flags & TFF_INTR)
2586d3ceb1dSskrll #define	CLKF_USERMODE(framep)	((framep)->cf_flags & T_USER)
2596d3ceb1dSskrll 
2606d3ceb1dSskrll int	clock_intr(void *);
2616d3ceb1dSskrll 
2626d3ceb1dSskrll /*
2636d3ceb1dSskrll  * LWP_PC: the program counter for the given lwp.
2646d3ceb1dSskrll  */
2656d3ceb1dSskrll #define	LWP_PC(l)		((l)->l_md.md_regs->tf_iioq_head)
2666d3ceb1dSskrll 
2676d3ceb1dSskrll #define	cpu_signotify(l)	(setsoftast(l))
2686d3ceb1dSskrll #define	cpu_need_proftick(l)	((l)->l_pflag |= LP_OWEUPC, setsoftast(l))
2696d3ceb1dSskrll 
2706d3ceb1dSskrll #endif /* _KERNEL */
2716d3ceb1dSskrll 
2726d3ceb1dSskrll #ifndef __ASSEMBLER__
2736d3ceb1dSskrll #if defined(_KERNEL) || defined(_KMEMUSER)
2746d3ceb1dSskrll 
2756d3ceb1dSskrll #include <sys/cpu_data.h>
2766d3ceb1dSskrll #include <sys/evcnt.h>
2776d3ceb1dSskrll 
2786d3ceb1dSskrll /*
2796d3ceb1dSskrll  * Note that the alignment of ci_trap_save is important since we want to keep
2806d3ceb1dSskrll  * it within a single cache line.  As a result, it must be kept as the first
2816d3ceb1dSskrll  * entry within the cpu_info struct.
2826d3ceb1dSskrll  */
2836d3ceb1dSskrll struct cpu_info {
2846d3ceb1dSskrll 	/* Keep this first to simplify the trap handlers */
2856d3ceb1dSskrll 	register_t	ci_trapsave[16];/* the "phys" part of frame */
2866d3ceb1dSskrll 
2876d3ceb1dSskrll 	struct cpu_data ci_data;	/* MI per-cpu data */
2886d3ceb1dSskrll 
2896d3ceb1dSskrll #ifndef _KMEMUSER
2906d3ceb1dSskrll 	hppa_hpa_t	ci_hpa;
2916d3ceb1dSskrll 	register_t	ci_psw;		/* Processor Status Word. */
2926d3ceb1dSskrll 	paddr_t		ci_fpu_state;	/* LWP FPU state address, or zero. */
2936d3ceb1dSskrll 	u_long		ci_itmr;
2946d3ceb1dSskrll 
2956d3ceb1dSskrll 	int		ci_cpuid;	/* CPU index (see cpus[] array) */
2966d3ceb1dSskrll 	int		ci_mtx_count;
2976d3ceb1dSskrll 	int		ci_mtx_oldspl;
2986d3ceb1dSskrll 	int		ci_want_resched;
2996d3ceb1dSskrll 
3006d3ceb1dSskrll 	volatile int	ci_cpl;
3016d3ceb1dSskrll 	volatile int	ci_ipending;	/* The pending interrupts. */
3026d3ceb1dSskrll 	u_int		ci_intr_depth;	/* Nonzero iff running an interrupt. */
3036d3ceb1dSskrll 	u_int		ci_ishared;
3046d3ceb1dSskrll 	u_int		ci_eiem;
3056d3ceb1dSskrll 
3066d3ceb1dSskrll 	u_int		ci_imask[NIPL];
3076d3ceb1dSskrll 
3086d3ceb1dSskrll 	struct hppa_interrupt_register	ci_ir;
3096d3ceb1dSskrll 	struct hppa_interrupt_bit	ci_ib[HPPA_INTERRUPT_BITS];
3106d3ceb1dSskrll 
311f17d30aaSskrll 	struct lwp	*ci_onproc;	/* current user LWP / kthread */
3126d3ceb1dSskrll #if defined(MULTIPROCESSOR)
3136d3ceb1dSskrll 	struct lwp	*ci_curlwp;	/* CPU owner */
3146d3ceb1dSskrll 	paddr_t		ci_stack;	/* stack for spin up */
3156d3ceb1dSskrll 	volatile int	ci_flags;	/* CPU status flags */
3166d3ceb1dSskrll #define	CPUF_PRIMARY	0x0001		/* ... is monarch/primary */
3176d3ceb1dSskrll #define	CPUF_RUNNING	0x0002 		/* ... is running. */
3186d3ceb1dSskrll 
3196d3ceb1dSskrll 	volatile u_long	ci_ipi;		/* IPIs pending */
3206d3ceb1dSskrll 
3216d3ceb1dSskrll 	struct cpu_softc *ci_softc;
3226d3ceb1dSskrll #endif
323567a3a02Sryo #if defined(GPROF) && defined(MULTIPROCESSOR)
324567a3a02Sryo 	struct gmonparam *ci_gmon;	/* MI per-cpu GPROF */
325567a3a02Sryo #endif
3266d3ceb1dSskrll #endif /* !_KMEMUSER */
3276d3ceb1dSskrll } __aligned(64);
3286d3ceb1dSskrll 
3296d3ceb1dSskrll #endif /* _KERNEL || _KMEMUSER */
3306d3ceb1dSskrll #endif /* __ASSEMBLER__ */
3316d3ceb1dSskrll 
3326d3ceb1dSskrll #if defined(_KERNEL)
3336d3ceb1dSskrll 
3346d3ceb1dSskrll /*
3356d3ceb1dSskrll  * definitions of cpu-dependent requirements
3366d3ceb1dSskrll  * referenced in generic code
3376d3ceb1dSskrll  */
3386d3ceb1dSskrll 
3391b5cff8fSskrll void	cpu_proc_fork(struct proc *, struct proc *);
3406d3ceb1dSskrll 
341a8880e61Sskrll struct lwp *hppa_curlwp(void);
342a8880e61Sskrll struct cpu_info *hppa_curcpu(void);
3436d3ceb1dSskrll 
344a8880e61Sskrll #if defined(_MODULE)
345a8880e61Sskrll #define	curcpu()			hppa_curcpu()
346a8880e61Sskrll #define	curlwp				hppa_curlwp()
347a8880e61Sskrll #endif
348a8880e61Sskrll 
349a8880e61Sskrll #if defined(MULTIPROCESSOR) || defined(_MODULE)
3506d3ceb1dSskrll /* Number of CPUs in the system */
3516d3ceb1dSskrll extern int hppa_ncpu;
3526d3ceb1dSskrll 
3536d3ceb1dSskrll #define	HPPA_MAXCPUS	4
354a8880e61Sskrll 
3556d3ceb1dSskrll #define	cpu_number()			(curcpu()->ci_cpuid)
3566d3ceb1dSskrll 
3576d3ceb1dSskrll #define	CPU_IS_PRIMARY(ci)		((ci)->ci_cpuid == 0)
3586d3ceb1dSskrll #define	CPU_INFO_ITERATOR		int
3596d3ceb1dSskrll #define	CPU_INFO_FOREACH(cii, ci)	cii = 0, ci =  &cpus[0]; cii < hppa_ncpu; cii++, ci++
3606d3ceb1dSskrll 
3616d3ceb1dSskrll void	cpu_boot_secondary_processors(void);
3626d3ceb1dSskrll 
363a8880e61Sskrll #if !defined(_MODULE)
36433a78575Sryo static __inline __always_inline struct cpu_info *
_hppa_curcpu(void)365a8880e61Sskrll _hppa_curcpu(void)
3666d3ceb1dSskrll {
3676d3ceb1dSskrll 	struct cpu_info *ci;
3686d3ceb1dSskrll 
3696d3ceb1dSskrll 	__asm volatile("mfctl %1, %0" : "=r" (ci): "i" (CR_CURCPU));
3706d3ceb1dSskrll 
3716d3ceb1dSskrll 	return ci;
3726d3ceb1dSskrll }
3736d3ceb1dSskrll 
374a8880e61Sskrll #define	curcpu()			_hppa_curcpu()
375a8880e61Sskrll #endif
3766d3ceb1dSskrll 
3776d3ceb1dSskrll #else /*  MULTIPROCESSOR */
3786d3ceb1dSskrll 
3796d3ceb1dSskrll #define	HPPA_MAXCPUS	1
3806d3ceb1dSskrll #define	curcpu()			(&cpus[0])
3816d3ceb1dSskrll #define	cpu_number()			0
3826d3ceb1dSskrll 
3836d3ceb1dSskrll static __inline struct lwp *
_hppa_curlwp(void)384a8880e61Sskrll _hppa_curlwp(void)
3856d3ceb1dSskrll {
3866d3ceb1dSskrll 	struct lwp *l;
3876d3ceb1dSskrll 
3886d3ceb1dSskrll 	__asm volatile("mfctl %1, %0" : "=r" (l): "i" (CR_CURLWP));
3896d3ceb1dSskrll 
3906d3ceb1dSskrll 	return l;
3916d3ceb1dSskrll }
3926d3ceb1dSskrll 
393a8880e61Sskrll #define	curlwp				_hppa_curlwp()
3946d3ceb1dSskrll 
3956d3ceb1dSskrll #endif /* MULTIPROCESSOR */
3966d3ceb1dSskrll 
3976d3ceb1dSskrll extern struct cpu_info cpus[HPPA_MAXCPUS];
3986d3ceb1dSskrll 
3996d3ceb1dSskrll #define	DELAY(x) delay(x)
4006d3ceb1dSskrll 
4016d3ceb1dSskrll static __inline paddr_t
kvtop(const void * va)4026d3ceb1dSskrll kvtop(const void *va)
4036d3ceb1dSskrll {
4046d3ceb1dSskrll 	paddr_t pa;
4056d3ceb1dSskrll 
4066d3ceb1dSskrll 	__asm volatile ("lpa %%r0(%1), %0" : "=r" (pa) : "r" (va));
4076d3ceb1dSskrll 	return pa;
4086d3ceb1dSskrll }
4096d3ceb1dSskrll 
4106d3ceb1dSskrll extern int (*cpu_desidhash)(void);
4116d3ceb1dSskrll 
4126d3ceb1dSskrll static __inline bool
hppa_cpu_ispa20_p(void)4136d3ceb1dSskrll hppa_cpu_ispa20_p(void)
4146d3ceb1dSskrll {
4156d3ceb1dSskrll 
4166d3ceb1dSskrll 	return (hppa_cpu_info->hci_features & HPPA_FTRS_W32B) != 0;
4176d3ceb1dSskrll }
4186d3ceb1dSskrll 
4196d3ceb1dSskrll static __inline bool
hppa_cpu_hastlbu_p(void)4206d3ceb1dSskrll hppa_cpu_hastlbu_p(void)
4216d3ceb1dSskrll {
4226d3ceb1dSskrll 
4236d3ceb1dSskrll 	return (hppa_cpu_info->hci_features & HPPA_FTRS_TLBU) != 0;
4246d3ceb1dSskrll }
4256d3ceb1dSskrll 
4266d3ceb1dSskrll void	delay(u_int);
4276d3ceb1dSskrll void	hppa_init(paddr_t, void *);
4286d3ceb1dSskrll void	trap(int, struct trapframe *);
4296d3ceb1dSskrll void	hppa_ras(struct lwp *);
4306d3ceb1dSskrll int	spcopy(pa_space_t, const void *, pa_space_t, void *, size_t);
4316d3ceb1dSskrll int	spstrcpy(pa_space_t, const void *, pa_space_t, void *, size_t,
4326d3ceb1dSskrll     size_t *);
4336d3ceb1dSskrll int	copy_on_fault(void);
4346d3ceb1dSskrll void	lwp_trampoline(void);
4356d3ceb1dSskrll int	cpu_dumpsize(void);
4366d3ceb1dSskrll int	cpu_dump(void);
4376d3ceb1dSskrll 
4386d3ceb1dSskrll #ifdef MULTIPROCESSOR
4396d3ceb1dSskrll void	cpu_boot_secondary_processors(void);
4406d3ceb1dSskrll void	cpu_hw_init(void);
4416d3ceb1dSskrll void	cpu_hatch(void);
4426d3ceb1dSskrll #endif
4436d3ceb1dSskrll #endif	/* _KERNEL */
4446d3ceb1dSskrll 
4456d3ceb1dSskrll /*
4466d3ceb1dSskrll  * Boot arguments stuff
4476d3ceb1dSskrll  */
4486d3ceb1dSskrll 
4496d3ceb1dSskrll #define	BOOTARG_LEN	(PAGE_SIZE)
4506d3ceb1dSskrll #define	BOOTARG_OFF	(0x10000)
4516d3ceb1dSskrll 
4526d3ceb1dSskrll /*
4536d3ceb1dSskrll  * CTL_MACHDEP definitions.
4546d3ceb1dSskrll  */
4556d3ceb1dSskrll #define	CPU_CONSDEV		1	/* dev_t: console terminal device */
4566d3ceb1dSskrll #define	CPU_BOOTED_KERNEL	2	/* string: booted kernel name */
4576d3ceb1dSskrll #define	CPU_LCD_BLINK           3	/* int: twiddle heartbeat LED/LCD */
4586d3ceb1dSskrll 
4596d3ceb1dSskrll #ifdef _KERNEL
4606d3ceb1dSskrll #include <sys/queue.h>
4616d3ceb1dSskrll 
4626d3ceb1dSskrll struct blink_lcd {
4636d3ceb1dSskrll 	void (*bl_func)(void *, int);
4646d3ceb1dSskrll 	void *bl_arg;
4656d3ceb1dSskrll 	SLIST_ENTRY(blink_lcd) bl_next;
4666d3ceb1dSskrll };
4676d3ceb1dSskrll 
4686d3ceb1dSskrll extern void blink_lcd_register(struct blink_lcd *);
4696d3ceb1dSskrll #endif	/* _KERNEL */
4706d3ceb1dSskrll #endif	/* !_LOCORE */
4716d3ceb1dSskrll 
4726d3ceb1dSskrll #endif /* _MACHINE_CPU_H_ */
473