xref: /netbsd-src/sys/arch/vax/include/cpu.h (revision 23c8222edbfb0f0932d88a8351d3a0cf817dfb9e)
1 /*      $NetBSD: cpu.h,v 1.70 2004/09/22 11:32:03 yamt 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/queue.h>
59 #include <sys/device.h>
60 #include <sys/lock.h>
61 #include <sys/cpu_data.h>
62 
63 #include <machine/mtpr.h>
64 #include <machine/pcb.h>
65 #include <machine/uvax.h>
66 #include <machine/psl.h>
67 
68 #define enablertclock()
69 
70 /*
71  * All cpu-dependent info is kept in this struct. Pointer to the
72  * struct for the current cpu is set up in locore.c.
73  */
74 struct cpu_info;
75 
76 struct	cpu_dep {
77 	void	(*cpu_steal_pages)(void); /* pmap init before mm is on */
78 	int	(*cpu_mchk)(caddr_t);   /* Machine check handling */
79 	void	(*cpu_memerr)(void); /* Memory subsystem errors */
80 	    /* Autoconfiguration */
81 	void	(*cpu_conf)(void);
82 	int	(*cpu_clkread)(time_t);	/* Read cpu clock time */
83 	void	(*cpu_clkwrite)(void);	/* Write system time to cpu */
84 	short	cpu_vups;	/* speed of cpu */
85 	short	cpu_scbsz;	/* (estimated) size of system control block */
86 	void	(*cpu_halt)(void); /* Cpu dependent halt call */
87 	void	(*cpu_reboot)(int); /* Cpu dependent reboot call */
88 	void	(*cpu_clrf)(void); /* Clear cold/warm start flags */
89 	void	(*cpu_subconf)(struct device *);/*config cpu dep. devs */
90 	int     cpu_flags;
91 	void	(*cpu_badaddr)(void); /* cpu-specific badaddr() */
92 };
93 
94 #if defined(MULTIPROCESSOR)
95 /*
96  * All cpu-dependent calls for multicpu systems goes here.
97  */
98 struct cpu_mp_dep {
99 	void	(*cpu_startslave)(struct device *, struct cpu_info *);
100 	void	(*cpu_send_ipi)(struct device *dest);
101 	void	(*cpu_cnintr)(void);
102 };
103 /*
104  * NOTE: This is not bit mask, this is bit _number_.
105  */
106 #define	IPI_START_CNTX	1	/* Start console transmitter, proc out */
107 #define	IPI_SEND_CNCHAR	2	/* Write char to console, kernel printf */
108 #define	IPI_RUNNING	3	/* This CPU just started to run */
109 #define	IPI_TBIA	4	/* Flush the TLB */
110 #define	IPI_DDB		5	/* Jump into the DDB loop */
111 
112 #define	IPI_DEST_MASTER	-1	/* Destination is mastercpu */
113 #define	IPI_DEST_ALL	-2	/* Broadcast */
114 
115 extern struct cpu_mp_dep *mp_dep_call;
116 #endif /* defined(MULTIPROCESSOR) */
117 
118 #define	CPU_RAISEIPL	1	/* Must raise IPL until intr is handled */
119 
120 extern struct cpu_dep *dep_call; /* Holds pointer to current CPU struct. */
121 
122 struct clockframe {
123         int     pc;
124         int     ps;
125 };
126 
127 struct cpu_info {
128 	/*
129 	 * Public members.
130 	 */
131 	struct cpu_data ci_data;	/* MI per-cpu data */
132 	struct lwp *ci_curlwp;		/* current owner of the processor */
133 
134 	/*
135 	 * Private members.
136 	 */
137 	int ci_want_resched;		/* Should change process */
138 	struct device *ci_dev;		/* device struct for this cpu */
139 	long ci_exit;			/* Page to use while exiting */
140 #if defined(MULTIPROCESSOR)
141 	struct pcb *ci_pcb;		/* Idle PCB for this CPU */
142 	vaddr_t ci_istack;		/* Interrupt stack location */
143 	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 #if defined(MULTIPROCESSOR)
156 /*
157  * "helper" struct. All multicpu systems must have the first two field
158  * of its cpu softc like this. (used in multicpu.c).
159  */
160 struct cpu_mp_softc {
161 	struct device sc_dev;
162 	struct cpu_info sc_ci;
163 };
164 #endif /* defined(MULTIPROCESSOR) */
165 
166 #define	ci_cpuid		ci_dev->dv_unit
167 #define	curcpu()		((struct cpu_info *)mfpr(PR_SSP))
168 #define	curlwp			(curcpu()->ci_curlwp)
169 #define	cpu_number()		(curcpu()->ci_cpuid)
170 #define	need_resched(ci)			\
171 	do {					\
172 		(ci)->ci_want_resched = 1;	\
173 		mtpr(AST_OK,PR_ASTLVL);		\
174 	} while (/*CONSTCOND*/ 0)
175 #define	cpu_proc_fork(x, y)	do { } while (/*CONSCOND*/0)
176 #define	cpu_lwp_free(l, f)	do { } while (/*CONSCOND*/0)
177 #if defined(MULTIPROCESSOR)
178 #define	CPU_IS_PRIMARY(ci)	((ci)->ci_flags & CI_MASTERCPU)
179 
180 #define	CPU_INFO_ITERATOR	int
181 #define	CPU_INFO_FOREACH(cii, ci)	cii = 0, ci = SIMPLEQ_FIRST(&cpus); \
182 					ci != NULL; \
183 					ci = SIMPLEQ_NEXT(ci, ci_next)
184 
185 extern SIMPLEQ_HEAD(cpu_info_qh, cpu_info) cpus;
186 extern char tramp;
187 #endif
188 
189 /*
190  * Notify the current process (p) that it has a signal pending,
191  * process as soon as possible.
192  */
193 
194 #define signotify(p)     mtpr(AST_OK,PR_ASTLVL);
195 
196 
197 /*
198  * Give a profiling tick to the current process when the user profiling
199  * buffer pages are invalid.  On the hp300, request an ast to send us
200  * through trap, marking the proc as needing a profiling tick.
201  */
202 #define need_proftick(p) {(p)->p_flag |= P_OWEUPC; mtpr(AST_OK,PR_ASTLVL); }
203 
204 /*
205  * This defines the I/O device register space size in pages.
206  */
207 #define	IOSPSZ	((64*1024) / VAX_NBPG)	/* 64k == 128 pages */
208 
209 struct device;
210 struct buf;
211 struct pte;
212 
213 /* Some low-level prototypes */
214 #if defined(MULTIPROCESSOR)
215 void	cpu_slavesetup(struct device *);
216 void	cpu_boot_secondary_processors(void);
217 void	cpu_send_ipi(int, int);
218 void	cpu_handle_ipi(void);
219 #endif
220 int	badaddr(caddr_t, int);
221 void	dumpconf(void);
222 void	dumpsys(void);
223 void	swapconf(void);
224 void	disk_printtype(int, int);
225 void	disk_reallymapin(struct buf *, struct pte *, int, int);
226 vaddr_t	vax_map_physmem(paddr_t, int);
227 void	vax_unmap_physmem(vaddr_t, int);
228 void	ioaccess(vaddr_t, paddr_t, int);
229 void	iounaccess(vaddr_t, int);
230 void	findcpu(void);
231 #ifdef DDB
232 int	kdbrint(int);
233 #endif
234 #endif /* _KERNEL */
235 #ifdef _STANDALONE
236 void	findcpu(void);
237 #endif
238 #endif /* _VAX_CPU_H_ */
239