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