Home | History | Annotate | Line # | Download | only in include
cpu.h revision 1.87
      1 /*      $NetBSD: cpu.h,v 1.87 2009/12/12 14:44:09 tsutsui Exp $      */
      2 
      3 /*
      4  * Copyright (c) 1994 Ludd, University of Lule}, Sweden
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *      This product includes software developed at Ludd, University of Lule}
     18  * 4. The name of the author may not be used to endorse or promote products
     19  *    derived from this software without specific prior written permission
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  */
     32 
     33 #ifndef _VAX_CPU_H_
     34 #define _VAX_CPU_H_
     35 
     36 #if defined(_KERNEL_OPT)
     37 #include "opt_multiprocessor.h"
     38 #include "opt_lockdebug.h"
     39 #endif
     40 
     41 #define	CPU_PRINTFATALTRAPS	1
     42 #define	CPU_CONSDEV		2
     43 #define	CPU_BOOTED_DEVICE	3
     44 #define	CPU_BOOTED_KERNEL	4
     45 #define CPU_MAXID		5
     46 
     47 #ifdef _KERNEL
     48 
     49 #include <sys/cdefs.h>
     50 #include <sys/queue.h>
     51 #include <sys/device.h>
     52 #include <sys/cpu_data.h>
     53 
     54 #include <machine/mtpr.h>
     55 #include <machine/pcb.h>
     56 #include <machine/uvax.h>
     57 #include <machine/psl.h>
     58 
     59 #define enablertclock()
     60 
     61 /*
     62  * All cpu-dependent info is kept in this struct. Pointer to the
     63  * struct for the current cpu is set up in locore.c.
     64  */
     65 struct cpu_info;
     66 
     67 struct cpu_dep {
     68 	void	(*cpu_steal_pages)(void); /* pmap init before mm is on */
     69 	int	(*cpu_mchk)(void *);   /* Machine check handling */
     70 	void	(*cpu_memerr)(void); /* Memory subsystem errors */
     71 	    /* Autoconfiguration */
     72 	void	(*cpu_conf)(void);
     73 	int	(*cpu_gettime)(struct timeval *); /* Read cpu clock time */
     74 	void	(*cpu_settime)(struct timeval *); /* Write system time to cpu */
     75 	short	cpu_vups;		/* speed of cpu */
     76 	short	cpu_scbsz;		/* (estimated) size of SCB */
     77 	void	(*cpu_halt)(void);	/* Cpu dependent halt call */
     78 	void	(*cpu_reboot)(int);	/* Cpu dependent reboot call */
     79 	void	(*cpu_clrf)(void);	/* Clear cold/warm start flags */
     80 	const char * const *cpu_devs;	/* mainbus devices */
     81 	void	(*cpu_attach_cpu)(device_t);	/* print CPU info */
     82 	void	(*cpu_subconf)(device_t, void *, cfprint_t);	/* attach dep. dev */
     83 	int     cpu_flags;
     84 	void	(*cpu_badaddr)(void);	/* cpu-specific badaddr() */
     85 };
     86 
     87 #if defined(MULTIPROCESSOR)
     88 /*
     89  * All cpu-dependent calls for multicpu systems goes here.
     90  */
     91 struct cpu_mp_dep {
     92 	void	(*cpu_startslave)(struct cpu_info *);
     93 	void	(*cpu_send_ipi)(struct cpu_info *);
     94 	void	(*cpu_cnintr)(void);
     95 };
     96 /*
     97  * NOTE: This is not bit mask, this is bit _number_.
     98  */
     99 #define	IPI_START_CNTX	1	/* Start console transmitter, proc out */
    100 #define	IPI_SEND_CNCHAR	2	/* Write char to console, kernel printf */
    101 #define	IPI_RUNNING	3	/* This CPU just started to run */
    102 #define	IPI_TBIA	4	/* Flush the TLB */
    103 #define	IPI_DDB		5	/* Jump into the DDB loop */
    104 
    105 #define	IPI_DEST_MASTER	-1	/* Destination is mastercpu */
    106 #define	IPI_DEST_ALL	-2	/* Broadcast */
    107 
    108 extern const struct cpu_mp_dep *mp_dep_call;
    109 #endif /* defined(MULTIPROCESSOR) */
    110 
    111 #define	CPU_RAISEIPL	1	/* Must raise IPL until intr is handled */
    112 
    113 extern const struct cpu_dep *dep_call;
    114 				/* Holds pointer to current CPU struct. */
    115 
    116 struct clockframe {
    117         int     pc;
    118         int     ps;
    119 };
    120 
    121 struct cpu_info {
    122 	/*
    123 	 * Public members.
    124 	 */
    125 	struct cpu_data ci_data;	/* MI per-cpu data */
    126 	struct device *ci_dev;		/* device struct for this cpu */
    127 	int ci_mtx_oldspl;		/* saved spl */
    128 	int ci_mtx_count;		/* negative count of mutexes */
    129 	int ci_cpuid;			/* h/w specific cpu id */
    130 	int ci_want_resched;		/* Should change process */
    131 
    132 	/*
    133 	 * Private members.
    134 	 */
    135 #if defined(__HAVE_FAST_SOFTINTS)
    136 	lwp_t *ci_softlwps[SOFTINT_COUNT];
    137 #endif
    138 	vaddr_t ci_istack;		/* Interrupt stack location */
    139 	const char *ci_cpustr;
    140 	int ci_slotid;			/* cpu slot */
    141 #if defined(MULTIPROCESSOR)
    142 	struct lwp *ci_curlwp;		/* current lwp (for other cpus) */
    143 	volatile int ci_flags;		/* See below */
    144 	long ci_ipimsgs;		/* Sent IPI bits */
    145 	struct trapframe *ci_ddb_regs;	/* Used by DDB */
    146 	SIMPLEQ_ENTRY(cpu_info) ci_next; /* next cpu_info */
    147 #endif
    148 };
    149 #define	CI_MASTERCPU	1		/* Set if master CPU */
    150 #define	CI_RUNNING	2		/* Set when a slave CPU is running */
    151 #define	CI_STOPPED	4		/* Stopped (in debugger) */
    152 
    153 extern int cpu_printfataltraps;
    154 
    155 #define	curcpu()		(curlwp->l_cpu + 0)
    156 #define	curlwp			((struct lwp *)mfpr(PR_SSP))
    157 #define	cpu_number()		(curcpu()->ci_cpuid)
    158 #define	cpu_need_resched(ci, flags)		\
    159 	do {					\
    160 		(ci)->ci_want_resched = 1;	\
    161 		mtpr(AST_OK,PR_ASTLVL);		\
    162 	} while (/*CONSTCOND*/ 0)
    163 #define	cpu_proc_fork(x, y)	do { } while (/*CONSCOND*/0)
    164 #define	cpu_idle()		do { } while (/*CONSCOND*/0)
    165 static inline bool
    166 cpu_intr_p(void)
    167 {
    168 	register_t psl;
    169 	__asm("movpsl %0" : "=g"(psl));
    170 	return (psl & PSL_IS) != 0;
    171 }
    172 #if defined(MULTIPROCESSOR)
    173 #define	CPU_IS_PRIMARY(ci)	((ci)->ci_flags & CI_MASTERCPU)
    174 
    175 #define	CPU_INFO_ITERATOR	int
    176 #define	CPU_INFO_FOREACH(cii, ci)	cii = 0, ci = SIMPLEQ_FIRST(&cpus); \
    177 					ci != NULL; \
    178 					ci = SIMPLEQ_NEXT(ci, ci_next)
    179 
    180 extern SIMPLEQ_HEAD(cpu_info_qh, cpu_info) cpus;
    181 extern char vax_mp_tramp;
    182 #endif
    183 
    184 /*
    185  * Notify the current process (p) that it has a signal pending,
    186  * process as soon as possible.
    187  */
    188 
    189 #define cpu_signotify(l)     mtpr(AST_OK,PR_ASTLVL)
    190 
    191 
    192 /*
    193  * Give a profiling tick to the current process when the user profiling
    194  * buffer pages are invalid.  On the hp300, request an ast to send us
    195  * through trap, marking the proc as needing a profiling tick.
    196  */
    197 #define cpu_need_proftick(l) do { (l)->l_pflag |= LP_OWEUPC; mtpr(AST_OK,PR_ASTLVL); } while (/*CONSTCOND*/ 0)
    198 
    199 /*
    200  * This defines the I/O device register space size in pages.
    201  */
    202 #define	IOSPSZ	((64*1024) / VAX_NBPG)	/* 64k == 128 pages */
    203 
    204 struct device;
    205 struct buf;
    206 struct pte;
    207 
    208 #include <sys/lwp.h>
    209 
    210 /* Some low-level prototypes */
    211 #if defined(MULTIPROCESSOR)
    212 void	cpu_slavesetup(device_t, int);
    213 void	cpu_boot_secondary_processors(void);
    214 void	cpu_send_ipi(int, int);
    215 void	cpu_handle_ipi(void);
    216 #endif
    217 int	badaddr(volatile void *, int);
    218 void	dumpconf(void);
    219 void	dumpsys(void);
    220 void	swapconf(void);
    221 void	disk_printtype(int, int);
    222 void	disk_reallymapin(struct buf *, struct pte *, int, int);
    223 vaddr_t	vax_map_physmem(paddr_t, size_t);
    224 void	vax_unmap_physmem(vaddr_t, size_t);
    225 void	ioaccess(vaddr_t, paddr_t, size_t);
    226 void	iounaccess(vaddr_t, size_t);
    227 void	findcpu(void);
    228 #ifdef DDB
    229 int	kdbrint(int);
    230 #endif
    231 #endif /* _KERNEL */
    232 #ifdef _STANDALONE
    233 void	findcpu(void);
    234 #endif
    235 #endif /* _VAX_CPU_H_ */
    236