NetBSD-5.0.2/sys/arch/sparc/sparc/genassym.cf

#	$NetBSD: genassym.cf,v 1.56 2008/09/20 18:29:05 tsutsui Exp $

#
# Copyright (c) 1998 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Christos Zoulas.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Copyright (c) 1992, 1993
#	The Regents of the University of California.  All rights reserved.
#
# This software was developed by the Computer Systems Engineering group
# at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
# contributed to Berkeley.
#
# All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
#	This product includes software developed by the University of
#	California, Lawrence Berkeley Laboratory.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
# 3. Neither the name of the University nor the names of its contributors
#    may be used to endorse or promote products derived from this software
#    without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#	@(#)genassym.c	8.1 (Berkeley) 6/11/93
#

quote	#define	__MUTEX_PRIVATE

include <sys/param.h>
include <sys/buf.h>
include <sys/proc.h>
include <sys/proc.h>
include <sys/mbuf.h>
include <sys/msgbuf.h>
include <sys/user.h>
include <sys/device.h>
include <sys/disklabel.h>
include <sys/disk.h>
include <sys/mutex.h>

include <uvm/uvm.h>

include <machine/cpu.h>
include <machine/oldmon.h>
include <machine/bsd_openprom.h>

include <sparc/sparc/cpuvar.h>

include <sparc/sparc/msiiepreg.h>

ifdef notyet
include <sparc/dev/zsreg.h>
include <sparc/dev/zsvar.h>
endif

include <machine/bus.h>
include <sparc/dev/audioamdvar.h>

include <sparc/dev/fdreg.h>
include <sparc/dev/fdvar.h>

# general constants
define	BSD		BSD
define	USRSTACK	USRSTACK

# proc fields and values
define	L_ADDR		offsetof(struct lwp, l_addr)
define	L_PROC		offsetof(struct lwp, l_proc)
define	L_STAT		offsetof(struct lwp, l_stat)
define	L_WCHAN		offsetof(struct lwp, l_wchan)
define	L_CPU		offsetof(struct lwp, l_cpu)
define	L_PRIORITY	offsetof(struct lwp, l_priority)
define	P_VMSPACE	offsetof(struct proc, p_vmspace)
define	P_MD_SYSCALL	offsetof(struct proc, p_md.md_syscall)
define	LSRUN		LSRUN
define	LSONPROC	LSONPROC

# VM structure fields
define	VM_PMAP		offsetof(struct vmspace, vm_map.pmap)
define	PMAP_CTX	offsetof(struct pmap, pm_ctx)
define	PMAP_CTXNUM	offsetof(struct pmap, pm_ctxnum)
define	PMAP_CPUSET	offsetof(struct pmap, pm_cpuset)

# interrupt/fault metering
define	V_INTR		offsetof(struct uvmexp, intrs)
define	V_SOFT		offsetof(struct uvmexp, softs)
define	V_FAULTS	offsetof(struct uvmexp, faults)
define	EV_COUNT	offsetof(struct evcnt, ev_count)

# CPU info structure
define	CPUINFO_STRUCTSIZE	sizeof(struct cpu_info)
define	CPUINFO_CPUNO		offsetof(struct cpu_info, ci_cpuid)
define	CPUINFO_GETSYNCFLT	offsetof(struct cpu_info, get_syncflt)
define	CPUINFO_GETASYNCFLT	offsetof(struct cpu_info, get_asyncflt)
define	CPUINFO_PURE_VCACHE_FLS	offsetof(struct cpu_info, pure_vcache_flush)
define	CPUINFO_SYNCFLTDUMP	offsetof(struct cpu_info, syncfltdump)
define	CPUINFO_INTREG		offsetof(struct cpu_info, intreg_4m)
define	CPUINFO_EINTSTACK	offsetof(struct cpu_info, eintstack)
define	INT_STACK_SIZE		INT_STACK_SIZE
define	CPUINFO_REDZONE		offsetof(struct cpu_info, redzone)
define	REDSIZE			REDSIZE
define	CPUINFO_CURPCB		offsetof(struct cpu_info, curpcb)
define	CPUINFO_CURLWP		offsetof(struct cpu_info, ci_curlwp)
define	CPUINFO_SELF		offsetof(struct cpu_info, ci_self)
define	CPUINFO_FLAGS		offsetof(struct cpu_info, flags)
define	CPUINFO_WANT_AST	offsetof(struct cpu_info, ci_want_ast)
define	CPUINFO_TT		offsetof(struct cpu_info, ci_tt)
define	CPUINFO_CACHE_LINESZ	offsetof(struct cpu_info, cacheinfo.c_linesize)
define	CPUINFO_CACHE_NLINES	offsetof(struct cpu_info, cacheinfo.c_nlines)
define	CPUINFO_XMSG_FUNC	offsetof(struct cpu_info, msg.u.xpmsg_func.func)
define	CPUINFO_XMSG_TRAP	offsetof(struct cpu_info, msg.u.xpmsg_func.trap)
define	CPUINFO_XMSG_ARG0	offsetof(struct cpu_info, msg.u.xpmsg_func.arg0)
define	CPUINFO_XMSG_ARG1	offsetof(struct cpu_info, msg.u.xpmsg_func.arg1)
define	CPUINFO_XMSG_ARG2	offsetof(struct cpu_info, msg.u.xpmsg_func.arg2)
define	CPUINFO_XMSG_CMPLT	offsetof(struct cpu_info, msg.complete)
define	CPUINFO_IDLESPIN	offsetof(struct cpu_info, idlespin)
define	CPUINFO_MTX_COUNT	offsetof(struct cpu_info, ci_mtx_count)
define	CPUINFO_MTX_OLDSPL	offsetof(struct cpu_info, ci_mtx_oldspl)
define	CPUINFO_IDEPTH		offsetof(struct cpu_info, ci_idepth)

# PTE bits and related information
define	PG_W		PG_W
define	PG_VSHIFT	PG_VSHIFT
define	PG_PROTSHIFT	PG_PROTSHIFT
define	PG_PROTUREAD	PG_PROTUREAD
define	PG_PROTUWRITE	PG_PROTUWRITE

define	SRMMU_TETYPE	SRMMU_TETYPE
define	SRMMU_TEPTE	SRMMU_TEPTE
define	SRMMU_PROT_MASK	SRMMU_PROT_MASK
define	PPROT_R_RW	PPROT_R_RW
define	PPROT_RX_RX	PPROT_RX_RX
define	PPROT_RWX_RWX	PPROT_RWX_RWX
define	PPROT_X_X	PPROT_X_X
define	PPROT_WRITE	PPROT_WRITE

# FPU state
define	FS_REGS		offsetof(struct fpstate, fs_regs)
define	FS_FSR		offsetof(struct fpstate, fs_fsr)
define	FS_QSIZE	offsetof(struct fpstate, fs_qsize)
define	FS_QUEUE	offsetof(struct fpstate, fs_queue)
define	FSR_QNE		FSR_QNE

# microSPARC-IIep PCI controller registers
define PCIC_PROC_IPR_REG	offsetof(struct msiiep_pcic_reg, pcic_proc_ipr)
define PCIC_SOFT_INTR_CLEAR_REG	offsetof(struct msiiep_pcic_reg, pcic_soft_intr_clear)
define PCIC_SOFT_INTR_SET_REG	offsetof(struct msiiep_pcic_reg, pcic_soft_intr_set)
define PCIC_SCCR_REG		offsetof(struct msiiep_pcic_reg, pcic_sccr)
define PCIC_SYS_ITMR_CLR_REG	offsetof(struct msiiep_pcic_reg, pcic_sys_itmr_clr)
define PCIC_SYS_ITMR_SET_REG	offsetof(struct msiiep_pcic_reg, pcic_sys_itmr_set)
define MSIIEP_SYS_ITMR_ALL	MSIIEP_SYS_ITMR_ALL

# errno
define	EFAULT		EFAULT
define	ENAMETOOLONG	ENAMETOOLONG

# PCB fields
define	PCB_NSAVED	offsetof(struct pcb, pcb_nsaved)
define	PCB_ONFAULT	offsetof(struct pcb, pcb_onfault)
define	PCB_PSR		offsetof(struct pcb, pcb_psr)
define	PCB_RW		offsetof(struct pcb, pcb_rw)
define	PCB_SP		offsetof(struct pcb, pcb_sp)
define	PCB_PC		offsetof(struct pcb, pcb_pc)
define	PCB_UW		offsetof(struct pcb, pcb_uw)
define	PCB_WIM		offsetof(struct pcb, pcb_wim)

# interrupt enable register PTE
define	IE_REG_PTE_PG	(PG_V | PG_W | PG_S | PG_NC | PG_OBIO)

ifdef notyet
# ZSCC interrupt fields
define	ZSC_A		offsetof(struct zs_softc, sc_a)
define	ZSC_B		offsetof(struct zs_softc, sc_b)
define	ZL_WREG		offsetof(struct zs_line, zl_wreg)
define	ZL_TBC		offsetof(struct zs_line, zl_tbc)
define	ZL_TBA		offsetof(struct zs_line, zl_tba)
define	ZL_RBPUT	offsetof(struct zs_line, zl_rbput)
define	ZL_RBUF		offsetof(struct zs_line, zl_rbuf)
define	ZSRR1_DO_bit	ffs(ZSRR1_DO) - 1
endif

# audio trap handler fields
define	AU_BH		offsetof(struct auio, au_bh)
define	AU_RDATA	offsetof(struct auio, au_rdata)
define	AU_REND		offsetof(struct auio, au_rend)
define	AU_PDATA	offsetof(struct auio, au_pdata)
define	AU_PEND		offsetof(struct auio, au_pend)
define	AU_EVCNT	offsetof(struct auio, au_intrcnt.ev_count)

define	PROM_BASE	PROM_BASE

define	PV_MAGIC	offsetof(struct promvec, pv_magic)
define	OBP_MAGIC	OBP_MAGIC
define	PV_NODEOPS	offsetof(struct promvec, pv_nodeops)
define	PV_HALT		offsetof(struct promvec, pv_halt)
define	PV_EVAL		offsetof(struct promvec, pv_fortheval.v0_eval)
define	PV_ROMVEC_VERS	offsetof(struct promvec, pv_romvec_vers)

define	NO_NEXTNODE	offsetof(struct nodeops, no_nextnode)
define	NO_GETPROP	offsetof(struct nodeops, no_getprop)

define	OLDMON_PRINTF	offsetof(struct om_vector, printf)
define	OLDMON_HALT	offsetof(struct om_vector, exitToMon)

# floppy trap handler fields
define	FDC_REG_HANDLE	offsetof(struct fdcio, fdcio_handle)
define	FDC_REG_MSR	offsetof(struct fdcio, fdcio_reg_msr)
define	FDC_REG_FIFO	offsetof(struct fdcio, fdcio_reg_fifo)
define	FDC_ITASK	offsetof(struct fdcio, fdcio_itask)
define	FDC_ISTATUS	offsetof(struct fdcio, fdcio_istatus)
define	FDC_STATUS	offsetof(struct fdcio, fdcio_status)
define	FDC_NSTAT	offsetof(struct fdcio, fdcio_nstat)
define	FDC_DATA	offsetof(struct fdcio, fdcio_data)
define	FDC_TC		offsetof(struct fdcio, fdcio_tc)
define	FDC_EVCNT	offsetof(struct fdcio, fdcio_intrcnt.ev_count)

# locking
define	MTX_LOCK	offsetof(struct kmutex, mtx_lock)
define	MTX_IPL		offsetof(struct kmutex, u.s.mtxs_ipl)

define	__SIMPLELOCK_LOCKED	__SIMPLELOCK_LOCKED
define	__SIMPLELOCK_UNLOCKED	__SIMPLELOCK_UNLOCKED