Home | History | Annotate | Line # | Download | only in include
cpu.h revision 1.67
      1 /*      $NetBSD: cpu.h,v 1.67 2004/01/04 11:33:31 jdolecek 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 #define	CTL_MACHDEP_NAMES { \
     48 	{ 0, 0 }, \
     49 	{ "printfataltraps", CTLTYPE_INT }, \
     50 	{ "console_device", CTLTYPE_STRUCT }, \
     51 	{ "booted_device", CTLTYPE_STRING }, \
     52 	{ "booted_kernel", CTLTYPE_STRING }, \
     53 }
     54 
     55 #ifdef _KERNEL
     56 
     57 #include <sys/cdefs.h>
     58 #include <sys/device.h>
     59 #include <sys/lock.h>
     60 #include <sys/sched.h>
     61 
     62 #include <machine/mtpr.h>
     63 #include <machine/pcb.h>
     64 #include <machine/uvax.h>
     65 #include <machine/psl.h>
     66 
     67 #define enablertclock()
     68 
     69 /*
     70  * All cpu-dependent info is kept in this struct. Pointer to the
     71  * struct for the current cpu is set up in locore.c.
     72  */
     73 struct cpu_info;
     74 
     75 struct	cpu_dep {
     76 	void	(*cpu_steal_pages)(void); /* pmap init before mm is on */
     77 	int	(*cpu_mchk)(caddr_t);   /* Machine check handling */
     78 	void	(*cpu_memerr)(void); /* Memory subsystem errors */
     79 	    /* Autoconfiguration */
     80 	void	(*cpu_conf)(void);
     81 	int	(*cpu_clkread)(time_t);	/* Read cpu clock time */
     82 	void	(*cpu_clkwrite)(void);	/* Write system time to cpu */
     83 	short	cpu_vups;	/* speed of cpu */
     84 	short	cpu_scbsz;	/* (estimated) size of system control block */
     85 	void	(*cpu_halt)(void); /* Cpu dependent halt call */
     86 	void	(*cpu_reboot)(int); /* Cpu dependent reboot call */
     87 	void	(*cpu_clrf)(void); /* Clear cold/warm start flags */
     88 	void	(*cpu_subconf)(struct device *);/*config cpu dep. devs */
     89 	int     cpu_flags;
     90 	void	(*cpu_badaddr)(void); /* cpu-specific badaddr() */
     91 };
     92 
     93 #if defined(MULTIPROCESSOR)
     94 /*
     95  * All cpu-dependent calls for multicpu systems goes here.
     96  */
     97 struct cpu_mp_dep {
     98 	void	(*cpu_startslave)(struct device *, struct cpu_info *);
     99 	void	(*cpu_send_ipi)(struct device *dest);
    100 	void	(*cpu_cnintr)(void);
    101 };
    102 /*
    103  * NOTE: This is not bit mask, this is bit _number_.
    104  */
    105 #define	IPI_START_CNTX	1	/* Start console transmitter, proc out */
    106 #define	IPI_SEND_CNCHAR	2	/* Write char to console, kernel printf */
    107 #define	IPI_RUNNING	3	/* This CPU just started to run */
    108 #define	IPI_TBIA	4	/* Flush the TLB */
    109 #define	IPI_DDB		5	/* Jump into the DDB loop */
    110 
    111 #define	IPI_DEST_MASTER	-1	/* Destination is mastercpu */
    112 #define	IPI_DEST_ALL	-2	/* Broadcast */
    113 
    114 extern struct cpu_mp_dep *mp_dep_call;
    115 #endif /* defined(MULTIPROCESSOR) */
    116 
    117 #define	CPU_RAISEIPL	1	/* Must raise IPL until intr is handled */
    118 
    119 extern struct cpu_dep *dep_call; /* Holds pointer to current CPU struct. */
    120 
    121 struct clockframe {
    122         int     pc;
    123         int     ps;
    124 };
    125 
    126 struct cpu_info {
    127 	/*
    128 	 * Public members.
    129 	 */
    130 	struct schedstate_percpu ci_schedstate; /* scheduler state */
    131 #if defined(DIAGNOSTIC) || defined(LOCKDEBUG)
    132 	u_long ci_spin_locks;           /* # of spin locks held */
    133 	u_long ci_simple_locks;         /* # of simple locks held */
    134 #endif
    135 
    136 	struct lwp *ci_curlwp;          /* current owner of the processor */
    137 
    138 	/*
    139 	 * Private members.
    140 	 */
    141 	int ci_want_resched;		/* Should change process */
    142 	struct device *ci_dev;		/* device struct for this cpu */
    143 	long ci_exit;			/* Page to use while exiting */
    144 #if defined(MULTIPROCESSOR)
    145 	struct pcb *ci_pcb;		/* Idle PCB for this CPU */
    146 	vaddr_t ci_istack;		/* Interrupt stack location */
    147 	int ci_flags;			/* See below */
    148 	long ci_ipimsgs;		/* Sent IPI bits */
    149 	struct trapframe *ci_ddb_regs;	/* Used by DDB */
    150 #endif
    151 };
    152 #define	CI_MASTERCPU	1		/* Set if master CPU */
    153 #define	CI_RUNNING	2		/* Set when a slave CPU is running */
    154 #define	CI_STOPPED	4		/* Stopped (in debugger) */
    155 
    156 extern int cpu_printfataltraps;
    157 
    158 #if defined(MULTIPROCESSOR)
    159 /*
    160  * "helper" struct. All multicpu systems must have the first two field
    161  * of its cpu softc like this. (used in multicpu.c).
    162  */
    163 struct cpu_mp_softc {
    164 	struct device sc_dev;
    165 	struct cpu_info sc_ci;
    166 };
    167 #endif /* defined(MULTIPROCESSOR) */
    168 
    169 #define	curcpu() ((struct cpu_info *)mfpr(PR_SSP))
    170 #define	curlwp	(curcpu()->ci_curlwp)
    171 #define	cpu_number() (curcpu()->ci_dev->dv_unit)
    172 #define	ci_cpuid ci_dev->dv_unit
    173 #define	need_resched(ci) {(ci)->ci_want_resched++; mtpr(AST_OK,PR_ASTLVL); }
    174 #define	cpu_proc_fork(x, y)
    175 #if defined(MULTIPROCESSOR)
    176 #define	CPU_IS_PRIMARY(ci)	((ci)->ci_flags & CI_MASTERCPU)
    177 
    178 extern char tramp;
    179 #endif
    180 
    181 /*
    182  * Notify the current process (p) that it has a signal pending,
    183  * process as soon as possible.
    184  */
    185 
    186 #define signotify(p)     mtpr(AST_OK,PR_ASTLVL);
    187 
    188 
    189 /*
    190  * Give a profiling tick to the current process when the user profiling
    191  * buffer pages are invalid.  On the hp300, request an ast to send us
    192  * through trap, marking the proc as needing a profiling tick.
    193  */
    194 #define need_proftick(p) {(p)->p_flag |= P_OWEUPC; mtpr(AST_OK,PR_ASTLVL); }
    195 
    196 /*
    197  * This defines the I/O device register space size in pages.
    198  */
    199 #define	IOSPSZ	((64*1024) / VAX_NBPG)	/* 64k == 128 pages */
    200 
    201 struct device;
    202 struct buf;
    203 struct pte;
    204 
    205 /* Some low-level prototypes */
    206 #if defined(MULTIPROCESSOR)
    207 void	cpu_slavesetup(struct device *);
    208 void	cpu_boot_secondary_processors(void);
    209 void	cpu_send_ipi(int, int);
    210 void	cpu_handle_ipi(void);
    211 #endif
    212 int	badaddr(caddr_t, int);
    213 void	dumpconf(void);
    214 void	dumpsys(void);
    215 void	swapconf(void);
    216 void	disk_printtype(int, int);
    217 void	disk_reallymapin(struct buf *, struct pte *, int, int);
    218 vaddr_t	vax_map_physmem(paddr_t, int);
    219 void	vax_unmap_physmem(vaddr_t, int);
    220 void	ioaccess(vaddr_t, paddr_t, int);
    221 void	iounaccess(vaddr_t, int);
    222 void	findcpu(void);
    223 #ifdef DDB
    224 int	kdbrint(int);
    225 #endif
    226 #endif /* _KERNEL */
    227 #ifdef _STANDALONE
    228 void	findcpu(void);
    229 #endif
    230 #endif /* _VAX_CPU_H_ */
    231