genassym.cf revision 1.60
1#	$NetBSD: genassym.cf,v 1.60 2008/01/04 15:55:31 yamt Exp $
2
3#
4# Copyright (c) 1998, 2006, 2007 The NetBSD Foundation, Inc.
5# All rights reserved.
6#
7# This code is derived from software contributed to The NetBSD Foundation
8# by Charles M. Hannum, and by Andrew Doran.
9#
10# Redistribution and use in source and binary forms, with or without
11# modification, are permitted provided that the following conditions
12# are met:
13# 1. Redistributions of source code must retain the above copyright
14#    notice, this list of conditions and the following disclaimer.
15# 2. Redistributions in binary form must reproduce the above copyright
16#    notice, this list of conditions and the following disclaimer in the
17#    documentation and/or other materials provided with the distribution.
18# 3. All advertising materials mentioning features or use of this software
19#    must display the following acknowledgement:
20#        This product includes software developed by the NetBSD
21#        Foundation, Inc. and its contributors.
22# 4. Neither the name of The NetBSD Foundation nor the names of its
23#    contributors may be used to endorse or promote products derived
24#    from this software without specific prior written permission.
25#
26# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36# POSSIBILITY OF SUCH DAMAGE.
37#
38
39#
40# Copyright (c) 1982, 1990 The Regents of the University of California.
41# All rights reserved.
42#
43# This code is derived from software contributed to Berkeley by
44# William Jolitz.
45#
46# Redistribution and use in source and binary forms, with or without
47# modification, are permitted provided that the following conditions
48# are met:
49# 1. Redistributions of source code must retain the above copyright
50#    notice, this list of conditions and the following disclaimer.
51# 2. Redistributions in binary form must reproduce the above copyright
52#    notice, this list of conditions and the following disclaimer in the
53#    documentation and/or other materials provided with the distribution.
54# 3. All advertising materials mentioning features or use of this software
55#    must display the following acknowledgement:
56#	This product includes software developed by the University of
57#	California, Berkeley and its contributors.
58# 4. Neither the name of the University nor the names of its contributors
59#    may be used to endorse or promote products derived from this software
60#    without specific prior written permission.
61#
62# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
63# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
64# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
65# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
66# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
67# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
68# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
69# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
70# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
71# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
72# SUCH DAMAGE.
73#
74#	@(#)genassym.c	5.11 (Berkeley) 5/10/91
75#
76
77if defined(_KERNEL_OPT)
78include "opt_compat_svr4.h"
79include "opt_compat_freebsd.h"
80include "opt_compat_linux.h"
81include "opt_compat_netbsd.h"
82include "opt_multiprocessor.h"
83endif
84
85quote #define __MUTEX_PRIVATE
86quote #define __RWLOCK_PRIVATE
87
88include <sys/param.h>
89include <sys/proc.h>
90include <sys/resourcevar.h>
91include <sys/device.h>
92include <sys/user.h>
93include <sys/mbuf.h>
94include <sys/mutex.h>
95include <sys/rwlock.h>
96
97include <netinet/in.h>
98include <netinet/in_systm.h>
99include <netinet/ip.h>
100include <netinet/ip6.h>
101include <netinet/ip_var.h>
102
103include <uvm/uvm.h>
104
105include <machine/trap.h>
106include <machine/pmap.h>
107include <machine/vmparam.h>
108include <machine/intr.h>
109include <machine/types.h>
110include <machine/segments.h>
111
112if defined(_KERNEL) && !defined(_LKM)
113include "ioapic.h"
114include "apmbios.h"
115endif
116if NAPMBIOS > 0
117include <machine/bioscall.h>
118include <machine/apmvar.h>
119endif
120
121include <compat/sys/signal.h>
122
123ifdef COMPAT_SVR4
124include <compat/svr4/svr4_ucontext.h>
125endif
126
127ifdef COMPAT_LINUX
128include <compat/linux/common/linux_signal.h>
129include <compat/linux/common/linux_machdep.h>
130endif
131
132ifdef COMPAT_FREEBSD
133include <machine/freebsd_machdep.h>
134endif
135
136ifdef MULTIPROCESSOR
137include <machine/cpu.h>
138endif
139
140if NIOAPIC > 0
141include <machine/i82093reg.h>
142include <machine/i82093var.h>
143endif
144
145if defined(_KERNEL) && !defined(_LKM)
146include "isa.h"
147endif
148if NISA > 0
149include <machine/isa_machdep.h>
150endif
151
152include <machine/tlog.h>
153
154include <x86/busdefs.h>
155
156define	PAGE_SIZE		PAGE_SIZE
157
158define	LSRUN			LSRUN
159define	LSONPROC		LSONPROC
160
161define	PTE_BASE		PTE_BASE
162define	UPAGES			UPAGES
163define	USPACE			USPACE
164define	KSTACK_SIZE		KSTACK_SIZE
165define	KERNBASE		KERNBASE
166define	KERNTEXTOFF		KERNTEXTOFF
167
168define	PG_RW			PG_RW
169define	PG_V			PG_V
170define	PG_KW			PG_KW
171define	PG_KR			PG_KR
172define	PGEX_U			PGEX_U
173
174define	L2_SLOT_KERNBASE	pl2_pi(KERNBASE)
175define	L1_SLOT_KERNBASE	pl1_pi(KERNBASE)
176
177define	PDIR_SLOT_PTE		PDIR_SLOT_PTE
178define	PTE_BASE		PTE_BASE
179
180define	IOMAPSIZE		IOMAPSIZE
181
182define	VM_MAXUSER_ADDRESS	(int)VM_MAXUSER_ADDRESS
183
184define	UVM_PAGE_IDLE_ZERO	offsetof(struct uvm, page_idle_zero)
185
186define	L_ADDR			offsetof(struct lwp, l_addr)
187define	L_FLAG			offsetof(struct lwp, l_flag)
188define	L_PROC			offsetof(struct lwp, l_proc)
189define	L_MD_REGS		offsetof(struct lwp, l_md.md_regs)
190define	L_CTXSWTCH		offsetof(struct lwp, l_ctxswtch)
191define	L_MD_ASTPENDING		offsetof(struct lwp, l_md.md_astpending)
192define	P_FLAG			offsetof(struct proc, p_flag)
193define	P_RASLIST		offsetof(struct proc, p_raslist)
194define	P_MD_SYSCALL		offsetof(struct proc, p_md.md_syscall)
195
196define	LW_SYSTEM		LW_SYSTEM
197
198define	GUFS_SEL		GUFS_SEL
199define	GUGS_SEL		GUGS_SEL
200
201define	M_DATA			offsetof(struct mbuf, m_data)
202define	M_LEN			offsetof(struct mbuf, m_len)
203define	M_NEXT			offsetof(struct mbuf, m_next)
204
205define	IP_SRC			offsetof(struct ip, ip_src)
206define	IP_DST			offsetof(struct ip, ip_dst)
207
208define	IP6_SRC			offsetof(struct ip6_hdr, ip6_src)
209define	IP6_DST			offsetof(struct ip6_hdr, ip6_dst)
210
211define	V_TRAP			offsetof(struct uvmexp, traps)
212define	V_INTR			offsetof(struct uvmexp, intrs)
213
214define	PCB_CR3			offsetof(struct pcb, pcb_cr3)
215define	PCB_EBP			offsetof(struct pcb, pcb_ebp)
216define	PCB_ESP			offsetof(struct pcb, pcb_esp)
217define	PCB_ESP0		offsetof(struct pcb, pcb_esp0)
218define	PCB_CR0			offsetof(struct pcb, pcb_cr0)
219define	PCB_LDT_SEL		offsetof(struct pcb, pcb_ldt_sel)
220define	PCB_ONFAULT		offsetof(struct pcb, pcb_onfault)
221define	PCB_FPCPU		offsetof(struct pcb, pcb_fpcpu)
222define	PCB_FSD			offsetof(struct pcb, pcb_fsd)
223define	PCB_GSD			offsetof(struct pcb, pcb_gsd)
224define	PCB_IOMAP		offsetof(struct pcb, pcb_iomap)
225
226define	TF_CS			offsetof(struct trapframe, tf_cs)
227define	TF_EIP			offsetof(struct trapframe, tf_eip)
228define	TF_ERR			offsetof(struct trapframe, tf_err)
229define	TF_TRAPNO		offsetof(struct trapframe, tf_trapno)
230define	TF_EFLAGS		offsetof(struct trapframe, tf_eflags)
231
232define	TF_GS			offsetof(struct trapframe, tf_gs)
233define	TF_FS			offsetof(struct trapframe, tf_fs)
234define	TF_ES			offsetof(struct trapframe, tf_es)
235define	TF_DS			offsetof(struct trapframe, tf_ds)
236define	TF_EDI			offsetof(struct trapframe, tf_edi)
237define	TF_ESI			offsetof(struct trapframe, tf_esi)
238define	TF_EBP			offsetof(struct trapframe, tf_ebp)
239define	TF_EBX			offsetof(struct trapframe, tf_ebx)
240define	TF_EDX			offsetof(struct trapframe, tf_edx)
241define	TF_ECX			offsetof(struct trapframe, tf_ecx)
242define	TF_EAX			offsetof(struct trapframe, tf_eax)
243
244define	TF_PUSHSIZE		offsetof(struct trapframe, tf_trapno)
245
246define	FRAMESIZE		sizeof(struct trapframe)
247
248ifdef COMPAT_SVR4
249define	SVR4_SIGF_HANDLER	offsetof(struct svr4_sigframe, sf_handler)
250define	SVR4_SIGF_UC		offsetof(struct svr4_sigframe, sf_uc)
251endif
252
253ifdef COMPAT_LINUX
254define	LINUX_SIGF_HANDLER	offsetof(struct linux_sigframe, sf_handler)
255define	LINUX_SIGF_SC		offsetof(struct linux_sigframe, sf_sc)
256define	LINUX_RT_SIGF_HANDLER	offsetof(struct linux_rt_sigframe, sf_handler)
257define	LINUX_RT_SIGF_UC	offsetof(struct linux_rt_sigframe, sf_uc)
258endif
259
260ifdef COMPAT_FREEBSD
261define	FREEBSD_SIGF_HANDLER	offsetof(struct freebsd_sigframe, sf_handler)
262define	FREEBSD_SIGF_SC		offsetof(struct freebsd_sigframe, sf_sc)
263endif
264
265define	IH_FUN			offsetof(struct intrhand, ih_fun)
266define	IH_ARG			offsetof(struct intrhand, ih_arg)
267define	IH_LEVEL		offsetof(struct intrhand, ih_level)
268define	IH_NEXT			offsetof(struct intrhand, ih_next)
269
270if NAPMBIOS > 0
271define	APM_CODE32		offsetof(struct apm_connect_info, apm_code32_seg_base)
272define	APM_CODE16		offsetof(struct apm_connect_info, apm_code16_seg_base)
273define	APM_DATA		offsetof(struct apm_connect_info, apm_data_seg_base)
274define	APM_CODE32_LEN		offsetof(struct apm_connect_info, apm_code32_seg_len)
275define	APM_DATA_LEN		offsetof(struct apm_connect_info, apm_data_seg_len)
276define	APM_ENTRY		offsetof(struct apm_connect_info, apm_entrypt)
277define	APM_DETAIL		offsetof(struct apm_connect_info, apm_detail)
278define	APM_SIZE		sizeof(struct apm_connect_info)
279define	BIOSCALLREG_EAX		offsetof(struct bioscallregs, EAX)
280define	BIOSCALLREG_EBX		offsetof(struct bioscallregs, EBX)
281define	BIOSCALLREG_ECX		offsetof(struct bioscallregs, ECX)
282define	BIOSCALLREG_EDX		offsetof(struct bioscallregs, EDX)
283define	BIOSCALLREG_ESI		offsetof(struct bioscallregs, ESI)
284define	BIOSCALLREG_EDI		offsetof(struct bioscallregs, EDI)
285define	BIOSCALLREG_EFLAGS	offsetof(struct bioscallregs, EFLAGS)
286endif
287
288define	CPU_INFO_SELF		offsetof(struct cpu_info, ci_self)
289define	CPU_INFO_RESCHED	offsetof(struct cpu_info, ci_want_resched)
290define	CPU_INFO_WANT_PMAPLOAD	offsetof(struct cpu_info, ci_want_pmapload)
291define	CPU_INFO_PMAP_CPU	offsetof(struct cpu_info, ci_pmap_cpu)
292define	CPU_INFO_TLBSTATE	offsetof(struct cpu_info, ci_tlbstate)
293define	TLBSTATE_VALID		TLBSTATE_VALID
294define	TLBSTATE_LAZY		TLBSTATE_LAZY
295define	TLBSTATE_STALE		TLBSTATE_STALE
296define	CPU_INFO_TLB_EVCNT	offsetof(struct cpu_info, ci_tlb_evcnt)
297define	CPU_INFO_CURLWP		offsetof(struct cpu_info, ci_curlwp)
298define	CPU_INFO_IDLELWP	offsetof(struct cpu_info, ci_data.cpu_idlelwp)
299define	CPU_INFO_PMAP		offsetof(struct cpu_info, ci_pmap)
300define	CPU_INFO_CPUMASK	offsetof(struct cpu_info, ci_cpumask)
301define	CPU_INFO_TSS		offsetof(struct cpu_info, ci_tss)
302define	CPU_INFO_TSS_SEL	offsetof(struct cpu_info, ci_tss_sel)
303define	CPU_INFO_ESP0		offsetof(struct cpu_info, ci_tss.tss_esp0)
304define	CPU_INFO_IOBASE		offsetof(struct cpu_info, ci_tss.tss_iobase)
305define	CPU_INFO_IOMAP		offsetof(struct cpu_info, ci_iomap)
306define	IOMAP_INVALOFF		IOMAP_INVALOFF
307
308define	CPU_INFO_LEVEL		offsetof(struct cpu_info, ci_cpuid_level)
309define	CPU_INFO_VENDOR		offsetof(struct cpu_info, ci_vendor[0])
310define	CPU_INFO_SIGNATURE	offsetof(struct cpu_info, ci_signature)
311define	CPU_INFO_FEATURES	offsetof(struct cpu_info, ci_feature_flags)
312define	CPU_INFO_BRAND		offsetof(struct cpu_info, ci_brand_id)
313
314define	CPU_TLOG_OFFSET		offsetof(struct cpu_info, ci_tlog_offset)
315define	CPU_TLOG_BASE		offsetof(struct cpu_info, ci_tlog_base)
316
317define	CPU_INFO_GDT		offsetof(struct cpu_info, ci_gdt)
318define	CPU_INFO_IPENDING	offsetof(struct cpu_info, ci_ipending)
319define	CPU_INFO_IMASK		offsetof(struct cpu_info, ci_imask)
320define	CPU_INFO_IUNMASK	offsetof(struct cpu_info, ci_iunmask)
321define	CPU_INFO_ILEVEL		offsetof(struct cpu_info, ci_ilevel)
322define	CPU_INFO_IDEPTH		offsetof(struct cpu_info, ci_idepth)
323define	CPU_INFO_ISOURCES	offsetof(struct cpu_info, ci_isources)
324define	CPU_INFO_MTX_COUNT	offsetof(struct cpu_info, ci_mtx_count)
325define	CPU_INFO_MTX_OLDSPL	offsetof(struct cpu_info, ci_mtx_oldspl)
326define	CPU_INFO_INTRSTACK	offsetof(struct cpu_info, ci_intrstack)
327define	CPU_INFO_ISTATE		offsetof(struct cpu_info, ci_istate)
328
329define	ACPI_SUSPEND_GDT		offsetof(struct cpu_info, ci_suspend_gdt)
330define	ACPI_SUSPEND_IDT		offsetof(struct cpu_info, ci_suspend_idt)
331define	ACPI_SUSPEND_TR			offsetof(struct cpu_info, ci_suspend_tr)
332define	ACPI_SUSPEND_LDT		offsetof(struct cpu_info, ci_suspend_ldt)
333define	ACPI_SUSPEND_FS			offsetof(struct cpu_info, ci_suspend_fs)
334define	ACPI_SUSPEND_GS			offsetof(struct cpu_info, ci_suspend_gs)
335
336define	ACPI_SUSPEND_EBX		offsetof(struct cpu_info, ci_suspend_ebx)
337define	ACPI_SUSPEND_ESI		offsetof(struct cpu_info, ci_suspend_esi)
338define	ACPI_SUSPEND_EDI		offsetof(struct cpu_info, ci_suspend_edi)
339define	ACPI_SUSPEND_EBP		offsetof(struct cpu_info, ci_suspend_ebp)
340define	ACPI_SUSPEND_ESP		offsetof(struct cpu_info, ci_suspend_esp)
341define	ACPI_SUSPEND_EFL		offsetof(struct cpu_info, ci_suspend_efl)
342define	ACPI_SUSPEND_CR0		offsetof(struct cpu_info, ci_suspend_cr0)
343define	ACPI_SUSPEND_CR2		offsetof(struct cpu_info, ci_suspend_cr2)
344define	ACPI_SUSPEND_CR3		offsetof(struct cpu_info, ci_suspend_cr3)
345define	ACPI_SUSPEND_CR4		offsetof(struct cpu_info, ci_suspend_cr4)
346
347if NIOAPIC > 0
348define		IOAPIC_SC_REG		offsetof(struct ioapic_softc, sc_reg)
349define		IOAPIC_SC_DATA		offsetof(struct ioapic_softc, sc_data)
350define		PIC_LOCK		offsetof(struct pic, pic_lock)
351endif
352
353define	SIZEOF_CPU_INFO		sizeof(struct cpu_info)
354
355define	SIZEOF_ISOURCE		sizeof(struct intrsource)
356define	SIZEOF_ISTUB		sizeof(struct intrstub)
357
358define	IS_RECURSE		offsetof(struct intrsource, is_recurse)
359define	IS_RESUME		offsetof(struct intrsource, is_resume)
360define	IS_EVCNTLO		offsetof(struct intrsource, is_evcnt.ev_count)
361define	IS_EVCNTHI		offsetof(struct intrsource, is_evcnt.ev_count)+4
362define	IS_HANDLERS		offsetof(struct intrsource, is_handlers)
363define	IS_PIC			offsetof(struct intrsource, is_pic)
364define	IS_FLAGS		offsetof(struct intrsource, is_flags)
365define	IS_PIN			offsetof(struct intrsource, is_pin)
366define	IS_TYPE			offsetof(struct intrsource, is_type)
367define	IS_MAXLEVEL		offsetof(struct intrsource, is_maxlevel)
368define	IS_LWP			offsetof(struct intrsource, is_lwp)
369
370define	TREC_SP			offsetof(struct trec, tr_sp)
371define	TREC_HPC		offsetof(struct trec, tr_hpc)
372define	TREC_IPC		offsetof(struct trec, tr_ipc)
373define	TREC_TSC		offsetof(struct trec, tr_tsc)
374define	TREC_LBF		offsetof(struct trec, tr_lbf)
375define	TREC_LBT		offsetof(struct trec, tr_lbt)
376define	TREC_IBF		offsetof(struct trec, tr_ibf)
377define	TREC_IBT		offsetof(struct trec, tr_ibt)
378
379define	SIZEOF_TREC		sizeof(struct trec)
380define	SIZEOF_TLOG		sizeof(struct tlog)
381
382define	IPL_NONE		IPL_NONE
383define	IPL_SCHED		IPL_SCHED
384define	IPL_CLOCK		IPL_CLOCK
385define	IPL_HIGH		IPL_HIGH
386define	IPL_IPI			IPL_IPI
387
388define	IPL_SOFTNET		IPL_SOFTNET
389define	IPL_SOFTCLOCK		IPL_SOFTCLOCK
390define	IPL_SOFTSERIAL		IPL_SOFTSERIAL
391
392define	LIR_IPI			LIR_IPI
393define	LIR_TIMER		LIR_TIMER
394
395define	SIR_NET			SIR_NET
396define	SIR_CLOCK		SIR_CLOCK
397define	SIR_SERIAL		SIR_SERIAL
398
399define	IREENT_MAGIC		IREENT_MAGIC
400
401define	PSL_AC			PSL_AC
402define	PSL_MBO			PSL_MBO
403define	PSL_ID			PSL_ID
404define	PSL_VM			PSL_VM
405define	PSL_I			PSL_I
406
407define	MTX_IPL			offsetof(struct kmutex, u.s.mtxs_ipl)
408define	MTX_LOCK		offsetof(struct kmutex, mtx_lock)
409define	MTX_OWNER		offsetof(struct kmutex, u.mtxa_owner)
410
411define	RW_OWNER		offsetof(struct krwlock, rw_owner)
412define	RW_WRITE_LOCKED		RW_WRITE_LOCKED
413define	RW_WRITE_WANTED		RW_WRITE_WANTED
414define	RW_READ_INCR		RW_READ_INCR
415define	RW_HAS_WAITERS		RW_HAS_WAITERS
416define	RW_THREAD		RW_THREAD
417define	RW_READER		RW_READER
418define	RW_WRITER		RW_WRITER
419
420define	MB_POINTER		offsetof(struct pmap_mbox, mb_pointer)
421define	MB_GLOBAL		offsetof(struct pmap_mbox, mb_global)
422define	MB_ADDR1		offsetof(struct pmap_mbox, mb_addr1)
423define	MB_ADDR2		offsetof(struct pmap_mbox, mb_addr2)
424define	MB_HEAD			offsetof(struct pmap_mbox, mb_head)
425define	MB_TAIL			offsetof(struct pmap_mbox, mb_tail)
426
427define	PM_CPUS			offsetof(struct pmap, pm_cpus)
428
429define	EV_COUNT		offsetof(struct evcnt, ev_count)
430
431define	OPTERON_MSR_PASSCODE	OPTERON_MSR_PASSCODE
432
433define	X86_BUS_SPACE_IO	X86_BUS_SPACE_IO
434
435define	L1_SHIFT		L1_SHIFT
436define	L2_SHIFT		L2_SHIFT
437define	L2_FRAME		L2_FRAME
438define	PGOFSET			PGOFSET
439define	PGSHIFT			PGSHIFT
440