xref: /netbsd-src/sys/arch/powerpc/booke/genassym.cf (revision cb861154c176d3dcc8ff846f449e3c16a5f5edb5)
1#	$NetBSD: genassym.cf,v 1.2 2011/01/18 01:02:52 matt Exp $
2
3#-
4# Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
5# All rights reserved.
6#
7# This code is derived from software contributed to The NetBSD Foundation
8# by Raytheon BBN Technologies Corp and Defense Advanced Research Projects
9# Agency and which was developed by Matt Thomas of 3am Software Foundry.
10#
11# This material is based upon work supported by the Defense Advanced Research
12# Projects Agency and Space and Naval Warfare Systems Center, Pacific, under
13# Contract No. N66001-09-C-2073.
14# Approved for Public Release, Distribution Unlimited
15#
16# Copyright (c) 2010 The NetBSD Foundation, Inc.
17# All rights reserved.
18#
19# This code is derived from software contributed to The NetBSD Foundation
20# by Matt Thomas of 3am Software Foundry.
21#
22# Redistribution and use in source and binary forms, with or without
23# modification, are permitted provided that the following conditions
24# are met:
25# 1. Redistributions of source code must retain the above copyright
26#    notice, this list of conditions and the following disclaimer.
27# 2. Redistributions in binary form must reproduce the above copyright
28#    notice, this list of conditions and the following disclaimer in the
29#    documentation and/or other materials provided with the distribution.
30#
31# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
32# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
33# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
34# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
35# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
36# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
39# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41# POSSIBILITY OF SUCH DAMAGE.
42#+
43
44include "opt_ppcarch.h"
45
46quote #define __MUTEX_PRIVATE
47quote #define __RWLOCK_PRIVATE
48quote #define __INTR_PRIVATE
49
50include <sys/param.h>
51include <sys/time.h>
52include <sys/mutex.h>
53include <sys/rwlock.h>
54include <sys/proc.h>
55include <sys/bitops.h>
56
57include <uvm/uvm_extern.h>
58
59include <machine/pcb.h>
60include <machine/frame.h>
61include <machine/pmap.h>
62
63include <powerpc/cpu.h>
64include <powerpc/booke/trap.h>
65include <powerpc/booke/pte.h>
66
67define	FRAMELEN	FRAMELEN
68define	FRAME_TF	offsetof(struct ktrapframe, ktf_tf)
69define	FRAME_0		offsetof(struct ktrapframe, ktf_tf.tf_fixreg[0])
70define	FRAME_1		offsetof(struct ktrapframe, ktf_tf.tf_fixreg[1])
71define	FRAME_2		offsetof(struct ktrapframe, ktf_tf.tf_fixreg[2])
72define	FRAME_3		offsetof(struct ktrapframe, ktf_tf.tf_fixreg[3])
73define	FRAME_4		offsetof(struct ktrapframe, ktf_tf.tf_fixreg[4])
74define	FRAME_5		offsetof(struct ktrapframe, ktf_tf.tf_fixreg[5])
75define	FRAME_6		offsetof(struct ktrapframe, ktf_tf.tf_fixreg[6])
76define	FRAME_7		offsetof(struct ktrapframe, ktf_tf.tf_fixreg[7])
77define	FRAME_8		offsetof(struct ktrapframe, ktf_tf.tf_fixreg[8])
78define	FRAME_9		offsetof(struct ktrapframe, ktf_tf.tf_fixreg[9])
79define	FRAME_10	offsetof(struct ktrapframe, ktf_tf.tf_fixreg[10])
80define	FRAME_11	offsetof(struct ktrapframe, ktf_tf.tf_fixreg[11])
81define	FRAME_12	offsetof(struct ktrapframe, ktf_tf.tf_fixreg[12])
82define	FRAME_13	offsetof(struct ktrapframe, ktf_tf.tf_fixreg[13])
83define	FRAME_14	offsetof(struct ktrapframe, ktf_tf.tf_fixreg[14])
84define	FRAME_15	offsetof(struct ktrapframe, ktf_tf.tf_fixreg[15])
85define	FRAME_16	offsetof(struct ktrapframe, ktf_tf.tf_fixreg[16])
86define	FRAME_17	offsetof(struct ktrapframe, ktf_tf.tf_fixreg[17])
87define	FRAME_18	offsetof(struct ktrapframe, ktf_tf.tf_fixreg[18])
88define	FRAME_19	offsetof(struct ktrapframe, ktf_tf.tf_fixreg[19])
89define	FRAME_20	offsetof(struct ktrapframe, ktf_tf.tf_fixreg[20])
90define	FRAME_21	offsetof(struct ktrapframe, ktf_tf.tf_fixreg[21])
91define	FRAME_22	offsetof(struct ktrapframe, ktf_tf.tf_fixreg[22])
92define	FRAME_23	offsetof(struct ktrapframe, ktf_tf.tf_fixreg[23])
93define	FRAME_24	offsetof(struct ktrapframe, ktf_tf.tf_fixreg[24])
94define	FRAME_25	offsetof(struct ktrapframe, ktf_tf.tf_fixreg[25])
95define	FRAME_26	offsetof(struct ktrapframe, ktf_tf.tf_fixreg[26])
96define	FRAME_27	offsetof(struct ktrapframe, ktf_tf.tf_fixreg[27])
97define	FRAME_28	offsetof(struct ktrapframe, ktf_tf.tf_fixreg[28])
98define	FRAME_29	offsetof(struct ktrapframe, ktf_tf.tf_fixreg[29])
99define	FRAME_30	offsetof(struct ktrapframe, ktf_tf.tf_fixreg[30])
100define	FRAME_31	offsetof(struct ktrapframe, ktf_tf.tf_fixreg[31])
101define	FRAME_LR	offsetof(struct ktrapframe, ktf_tf.tf_lr)
102define	FRAME_CR	offsetof(struct ktrapframe, ktf_tf.tf_cr)
103define	FRAME_CTR	offsetof(struct ktrapframe, ktf_tf.tf_ctr)
104define	FRAME_XER	offsetof(struct ktrapframe, ktf_tf.tf_xer)
105define	FRAME_CF	offsetof(struct ktrapframe, ktf_tf.tf_cf)
106define	FRAME_SRR0	offsetof(struct ktrapframe, ktf_tf.tf_srr0)
107define	FRAME_SRR1	offsetof(struct ktrapframe, ktf_tf.tf_srr1)
108define	FRAME_IDEPTH	offsetof(struct ktrapframe, ktf_tf.tf_idepth)
109define	FRAME_DEAR	offsetof(struct ktrapframe, ktf_tf.tf_dear)
110define	FRAME_ESR	offsetof(struct ktrapframe, ktf_tf.tf_esr)
111define	FRAME_EXC	offsetof(struct ktrapframe, ktf_tf.tf_exc)
112define	FRAME_MCSR	offsetof(struct ktrapframe, ktf_tf.tf_mcsr)
113define	FRAME_MCAR	offsetof(struct ktrapframe, ktf_tf.tf_mcar)
114define	FRAME_SPRG1	offsetof(struct ktrapframe, ktf_tf.tf_sprg1)
115define	FRAME_SPEFSCR	offsetof(struct ktrapframe, ktf_tf.tf_spefscr)
116
117define	CALLFRAMELEN	CALLFRAMELEN
118define	CFRAME_SP	offsetof(struct callframe, cf_sp)
119define	CFRAME_LR	offsetof(struct callframe, cf_lr)
120define	CFRAME_R30	offsetof(struct callframe, cf_r30)
121define	CFRAME_R31	offsetof(struct callframe, cf_r31)
122
123define	SFRAMELEN	SFRAMELEN
124define	SFRAME_SP	offsetof(struct switchframe, sf_sp)
125define	SFRAME_LR	offsetof(struct switchframe, sf_lr)
126define	SFRAME_USER_SR	offsetof(struct switchframe, sf_user_sr)
127define	SFRAME_CR	offsetof(struct switchframe, sf_cr)
128define	SFRAME_R2	offsetof(struct switchframe, sf_fixreg2)
129define	SFRAME_R13	offsetof(struct switchframe, sf_fixreg[0])
130define	SFRAME_R14	offsetof(struct switchframe, sf_fixreg[1])
131define	SFRAME_R15	offsetof(struct switchframe, sf_fixreg[2])
132define	SFRAME_R16	offsetof(struct switchframe, sf_fixreg[3])
133define	SFRAME_R17	offsetof(struct switchframe, sf_fixreg[4])
134define	SFRAME_R18	offsetof(struct switchframe, sf_fixreg[5])
135define	SFRAME_R19	offsetof(struct switchframe, sf_fixreg[6])
136define	SFRAME_R20	offsetof(struct switchframe, sf_fixreg[7])
137define	SFRAME_R21	offsetof(struct switchframe, sf_fixreg[8])
138define	SFRAME_R22	offsetof(struct switchframe, sf_fixreg[9])
139define	SFRAME_R23	offsetof(struct switchframe, sf_fixreg[10])
140define	SFRAME_R24	offsetof(struct switchframe, sf_fixreg[11])
141define	SFRAME_R25	offsetof(struct switchframe, sf_fixreg[12])
142define	SFRAME_R26	offsetof(struct switchframe, sf_fixreg[13])
143define	SFRAME_R27	offsetof(struct switchframe, sf_fixreg[14])
144define	SFRAME_R28	offsetof(struct switchframe, sf_fixreg[15])
145define	SFRAME_R29	offsetof(struct switchframe, sf_fixreg[16])
146define	SFRAME_R30	offsetof(struct switchframe, sf_fixreg[17])
147define	SFRAME_R31	offsetof(struct switchframe, sf_fixreg[18])
148
149define	PCB_PM		offsetof(struct pcb, pcb_pm)
150define	PCB_SP		offsetof(struct pcb, pcb_sp)
151define	PCB_ONFAULT	offsetof(struct pcb, pcb_onfault)
152define	PCB_USPRG0	offsetof(struct pcb, pcb_usprg0)
153
154define	L_PCB		offsetof(struct lwp, l_addr)
155define	L_CPU		offsetof(struct lwp, l_cpu)
156define	L_CTXSWTCH	offsetof(struct lwp, l_ctxswtch)
157define	L_MD_UTF	offsetof(struct lwp, l_md.md_utf)
158define	L_PROC		offsetof(struct lwp, l_proc)
159
160define	P_MD_SYSCALL	offsetof(struct proc, p_md.md_syscall)
161
162define	CI_SIZE		sizeof(struct cpu_info)
163define	CI_CURLWP	offsetof(struct cpu_info, ci_curlwp)
164define	CI_CURPCB	offsetof(struct cpu_info, ci_curpcb)
165define	CI_CURPM	offsetof(struct cpu_info, ci_curpm)
166define	CI_ASTPENDING	offsetof(struct cpu_info, ci_astpending)
167define	CI_WANT_RESCHED	offsetof(struct cpu_info, ci_want_resched)
168define	CI_CPL		offsetof(struct cpu_info, ci_cpl)
169define	CI_IDEPTH	offsetof(struct cpu_info, ci_idepth)
170define	CI_IDLESPIN	offsetof(struct cpu_info, ci_idlespin)
171define	CI_MTX_COUNT	offsetof(struct cpu_info, ci_mtx_count)
172define	CI_MTX_OLDSPL	offsetof(struct cpu_info, ci_mtx_oldspl)
173define	CI_SAVELIFO	offsetof(struct cpu_info, ci_savelifo)
174define	CI_PMAP_SEGTAB	offsetof(struct cpu_info, ci_pmap_segtabs[0])
175define	CI_EV_TLBMISS_SOFT offsetof(struct cpu_info, ci_ev_tlbmiss_soft.ev_count)
176
177define	FB_PC		offsetof(struct faultbuf, fb_pc)
178define	FB_MSR		offsetof(struct faultbuf, fb_msr)
179define	FB_SP		offsetof(struct faultbuf, fb_sp)
180define	FB_R2		offsetof(struct faultbuf, fb_r2)
181define	FB_CR		offsetof(struct faultbuf, fb_cr)
182define	FB_R13		offsetof(struct faultbuf, fb_fixreg[0])
183define	FB_R14		offsetof(struct faultbuf, fb_fixreg[1])
184define	FB_R15		offsetof(struct faultbuf, fb_fixreg[2])
185define	FB_R16		offsetof(struct faultbuf, fb_fixreg[3])
186define	FB_R17		offsetof(struct faultbuf, fb_fixreg[4])
187define	FB_R18		offsetof(struct faultbuf, fb_fixreg[5])
188define	FB_R19		offsetof(struct faultbuf, fb_fixreg[6])
189define	FB_R20		offsetof(struct faultbuf, fb_fixreg[7])
190define	FB_R21		offsetof(struct faultbuf, fb_fixreg[8])
191define	FB_R22		offsetof(struct faultbuf, fb_fixreg[9])
192define	FB_R23		offsetof(struct faultbuf, fb_fixreg[10])
193define	FB_R24		offsetof(struct faultbuf, fb_fixreg[11])
194define	FB_R25		offsetof(struct faultbuf, fb_fixreg[12])
195define	FB_R26		offsetof(struct faultbuf, fb_fixreg[13])
196define	FB_R27		offsetof(struct faultbuf, fb_fixreg[14])
197define	FB_R28		offsetof(struct faultbuf, fb_fixreg[15])
198define	FB_R29		offsetof(struct faultbuf, fb_fixreg[16])
199define	FB_R30		offsetof(struct faultbuf, fb_fixreg[17])
200define	FB_R31		offsetof(struct faultbuf, fb_fixreg[18])
201
202define	CACHELINESIZE	CACHELINESIZE
203
204define	CPU_CI		offsetof(struct cpu_info, ci_ci)
205
206define	PAGE_SIZE	PAGE_SIZE
207define	PAGE_MASK	PAGE_MASK
208define	PAGE_SHIFT	PAGE_SHIFT
209define	KERNEL_PID	KERNEL_PID
210define	USPACE		USPACE
211
212define	T_CRITIAL_INPUT		T_CRITIAL_INPUT
213define	T_MACHINE_CHECK		T_MACHINE_CHECK
214define	T_DSI			T_DSI
215define	T_ISI			T_ISI
216define	T_EXTERNAL_INPUT	T_EXTERNAL_INPUT
217define	T_ALIGNMENT		T_ALIGNMENT
218define	T_PROGRAM		T_PROGRAM
219define	T_FP_UNAVAILABLE	T_FP_UNAVAILABLE
220define	T_SYSTEM_CALL		T_SYSTEM_CALL
221define	T_AP_UNAVAILABLE	T_AP_UNAVAILABLE
222define	T_DECREMENTER		T_DECREMENTER
223define	T_FIXED_INTERVAL	T_FIXED_INTERVAL
224define	T_WATCHDOG		T_WATCHDOG
225define	T_DATA_TLB_ERROR	T_DATA_TLB_ERROR
226define	T_INSTRUCTION_TLB_ERROR	T_INSTRUCTION_TLB_ERROR
227define	T_DEBUG			T_DEBUG
228define	T_SPE_UNAVAILABLE	T_SPE_UNAVAILABLE
229define	T_EMBEDDED_FP_DATA	T_EMBEDDED_FP_DATA
230define	T_EMBEDDED_FP_ROUND	T_EMBEDDED_FP_ROUND
231define	T_EMBEDDED_PERF_MONITOR	T_EMBEDDED_PERF_MONITOR
232define	T_AST			T_AST
233
234ifdef	__HAVE_FAST_SOFTINTS
235define	__HAVE_FAST_SOFTINTS	__HAVE_FAST_SOFTINTS
236endif
237
238define	INTRSW_CRITINTR		offsetof(struct intrsw, intrsw_critintr)
239define	INTRSW_DECRINTR		offsetof(struct intrsw, intrsw_decrintr)
240define	INTRSW_FITINTR		offsetof(struct intrsw, intrsw_fitintr)
241define	INTRSW_WDOGINTR		offsetof(struct intrsw, intrsw_wdogintr)
242define	INTRSW_EXTINTR		offsetof(struct intrsw, intrsw_extintr)
243
244define	IPL_HIGH		IPL_HIGH
245define	IPL_SCHED		IPL_SCHED
246define	IPL_VM			IPL_VM
247
248ifdef	__HAVE_MUTEX_STUBS
249define	__HAVE_MUTEX_STUBS	__HAVE_MUTEX_STUBS
250endif
251ifdef	__HAVE_MUTEX_SPIN_STUBS
252define	__HAVE_MUTEX_SPIN_STUBS	__HAVE_MUTEX_SPIN_STUBS
253endif
254define	MTX_OWNER	offsetof(struct kmutex, mtx_owner)
255define	MTX_LOCK	offsetof(struct kmutex, mtx_lock)
256define	MTX_IPL		offsetof(struct kmutex, mtx_ipl)
257
258ifdef	__HAVE_RW_STUBS
259define	__HAVE_RW_STUBS	__HAVE_RW_STUBS
260endif
261define	RW_OWNER	offsetof(struct krwlock, rw_owner)
262define	RW_WRITE_LOCKED	RW_WRITE_LOCKED
263define	RW_READ_INCR	RW_READ_INCR
264define	RW_READER	RW_READER
265
266##define	USPACE		USPACE
267
268define	PTE_SCALESHIFT	ilog2(sizeof(pt_entry_t))
269define	PTR_SCALESHIFT	ilog2(sizeof(void *))
270define	PSL_CE		PSL_CE
271define	PSL_DE		PSL_DE
272define	PSL_EE		PSL_EE
273define	PSL_ME		PSL_ME
274define	PSL_PR		PSL_PR
275define	MSR_PR		31 - ilog2(PSL_PR)
276define	PSL_DS		PSL_DS
277define	MSR_DS		31 - ilog2(PSL_DS)
278define	PSL_IS		PSL_IS
279define	MSR_IS		31 - ilog2(PSL_IS)
280
281define	NSEGPG_SCALESHIFT	PAGE_SHIFT - ilog2(sizeof(void *))
282define	NPTEPG_SCALESHIFT	PAGE_SHIFT - ilog2(sizeof(pt_entry_t))
283