First commit of Per Fogelstrom's port to the Acer pica r4400/isa machine.

This commit is contained in:
jonathan 1996-03-13 04:58:04 +00:00
parent f5e6df1ed0
commit dc6fdf6cdc
95 changed files with 32571 additions and 0 deletions

View File

@ -0,0 +1,134 @@
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department and Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: Utah Hdr: pte.h 1.11 89/09/03
*
* from: @(#)pte.h 8.1 (Berkeley) 6/10/93
* $Id: mips3_pte.h,v 1.1.1.1 1996/03/13 04:58:08 jonathan Exp $
*/
/*
* R4000 hardware page table entry
*/
#ifndef LOCORE
struct pte {
#if BYTE_ORDER == BIG_ENDIAN
unsigned int pg_prot:2, /* SW: access control */
pg_pfnum:24, /* HW: core page frame number or 0 */
pg_attr:3, /* HW: cache attribute */
pg_m:1, /* HW: modified (dirty) bit */
pg_v:1, /* HW: valid bit */
pg_g:1; /* HW: ignore pid bit */
#endif
#if BYTE_ORDER == LITTLE_ENDIAN
unsigned int pg_g:1, /* HW: ignore pid bit */
pg_v:1, /* HW: valid bit */
pg_m:1, /* HW: modified (dirty) bit */
pg_attr:3, /* HW: cache attribute */
pg_pfnum:24, /* HW: core page frame number or 0 */
pg_prot:2; /* SW: access control */
#endif
};
/*
* Structure defining an tlb entry data set.
*/
struct tlb {
int tlb_mask;
int tlb_hi;
int tlb_lo0;
int tlb_lo1;
};
typedef union pt_entry {
unsigned int pt_entry; /* for copying, etc. */
struct pte pt_pte; /* for getting to bits by name */
} pt_entry_t; /* Mach page table entry */
#endif /* LOCORE */
#define PT_ENTRY_NULL ((pt_entry_t *) 0)
#define PG_WIRED 0x80000000 /* SW */
#define PG_RO 0x40000000 /* SW */
#define PG_SVPN 0xfffff000 /* Software page no mask */
#define PG_HVPN 0xffffe000 /* Hardware page no mask */
#define PG_ODDPG 0x00001000 /* Odd even pte entry */
#define PG_ASID 0x000000ff /* Address space ID */
#define PG_G 0x00000001 /* HW */
#define PG_V 0x00000002
#define PG_NV 0x00000000
#define PG_M 0x00000004
#define PG_ATTR 0x0000003f
#define PG_UNCACHED 0x00000010
#define PG_CACHED 0x00000018
#define PG_CACHEMODE 0x00000038
#define PG_ROPAGE (PG_V | PG_RO | PG_CACHED) /* Write protected */
#define PG_RWPAGE (PG_V | PG_M | PG_CACHED) /* Not wr-prot not clean */
#define PG_CWPAGE (PG_V | PG_CACHED) /* Not wr-prot but clean */
#define PG_IOPAGE (PG_G | PG_V | PG_M | PG_UNCACHED)
#define PG_FRAME 0x3fffffc0
#define PG_SHIFT 6
#define vad_to_pfn(x) (((unsigned)(x) >> PG_SHIFT) & PG_FRAME)
#define pfn_to_vad(x) (((x) & PG_FRAME) << PG_SHIFT)
#define vad_to_vpn(x) ((unsigned)(x) & PG_SVPN)
#define vpn_to_vad(x) ((x) & PG_SVPN)
/* User viritual to pte page entry */
#define uvtopte(adr) (((adr) >> PGSHIFT) & (NPTEPG -1))
#define PG_SIZE_4K 0x00000000
#define PG_SIZE_16K 0x00006000
#define PG_SIZE_64K 0x0001e000
#define PG_SIZE_256K 0x0007e000
#define PG_SIZE_1M 0x001fe000
#define PG_SIZE_4M 0x007fe000
#define PG_SIZE_16M 0x01ffe000
#if defined(_KERNEL) && !defined(LOCORE)
/*
* Kernel virtual address to page table entry and visa versa.
*/
#define kvtopte(va) \
(Sysmap + (((vm_offset_t)(va) - VM_MIN_KERNEL_ADDRESS) >> PGSHIFT))
#define ptetokv(pte) \
((((pt_entry_t *)(pte) - Sysmap) << PGSHIFT) + VM_MIN_KERNEL_ADDRESS)
extern pt_entry_t *Sysmap; /* kernel pte table */
extern u_int Sysmapsize; /* number of pte's in Sysmap */
#endif

28
sys/arch/pica/Makefile Normal file
View File

@ -0,0 +1,28 @@
# from: @(#)Makefile 8.1 (Berkeley) 6/16/93
# $Id: Makefile,v 1.1.1.1 1996/03/13 04:58:04 jonathan Exp $
# Makefile for pica links, tags file
.include "../kern/Make.tags.inc"
all:
@echo "make links or tags only"
DIRS= conf dev dist include pica
links::
-for i in ${DIRS}; do \
(cd $$i && { rm -f tags; ln -s ${SYSTAGS} tags; }) done
PICA= /sys/pica/dev/*.[ch] /sys/pica/include/*.[ch] \
/sys/pica/pica/*.[ch] /sys/pica/ultrix/*.[ch]
APICA= /sys/pica/pica/*.s
tags::
-ctags -wdt ${COMM} ${PICA}
egrep "^LEAF(.*)|^[AN]LEAF(.*)|^NON_LEAF(.*)" ${APICA} | \
sed "s;\([^:]*\):\([^(]*\)(\([^, )]*\)\(.*\);\3 \1 /^\2(\3\4$$/;" \
>> tags
sort -o tags tags
chown bin.wsrc tags
chmod 444 tags

35
sys/arch/pica/TODO Normal file
View File

@ -0,0 +1,35 @@
To do list (not in any particular order).
o Improve pmap_zero_page and pmap_copy_page. Speed and flushing.
o Move the RO and WIRED attribute from the pte to the pv table.
This saves four instructions in the tlb miss handler.
InWork: Have a test version. The system hangs after a while. Not solved yet.
Also, is it worth the effort to remove 4 instr. in TLB-miss handler?
o Update MAKEDEV to create all devices correctly.
o Boot. Standalone boot program instead of booting the kernel directly?
o Create boot package for distribution.
o sigsetjmp/siglongjmp missing....
o Add more videomodes to pccons driver. 50kHz and 64kHz monitors?
InWork: This seems to be hard. Need more info on the chip.
o Find out why bitmap load to S3-928 flashes screen.
Know why (enable linear mode). Need S3 info.
o Would be nice to have Motif...
o ELF shared libraries......
o GDB. The current one does not work correctly with current toolchain.
o ISA driver. ISA dma, interrupt etc.
o Can we have 32 double registers?
Lots of other things.....

View File

@ -0,0 +1 @@
GENERIC

View File

@ -0,0 +1 @@
This file must remain so that 'cvs checkout' makes the compile directory.

View File

@ -0,0 +1,89 @@
#
# Generic configuration file for MIPS R4400 PICA system
#
machine pica
maxusers 8
# does not really do anything anymore, but this replaces "ident GENERIC"
options GENERIC
# Need to set locally
options TIMEZONE="8*60" # minutes west of GMT (for)
options DST=1 # use daylight savings rules
# Standard system options
options SWAPPAGER # swap pager (anonymous and swap space)
options VNODEPAGER # vnode pager (mapped files)
options DEVPAGER # device pager (mapped devices)
options DIAGNOSTIC # extra kernel debugging checks
options DEBUG # extra kernel debugging support
options "COMPAT_43" # compatibility with 4.3BSD binaries
#options KTRACE # system call tracing support
options "NKMEMCLUSTERS=1024" # 4K pages in kernel malloc pool
#options KGDB # support for kernel gdb
#options "KGDBRATE=19200" # kernel gdb port rate (default 9600)
#options "KGDBDEV=15*256+0" # device for kernel gdb
# System V options
options SYSVMSG # System V-like message queues
options SYSVSEM # System V-like semaphores
options SYSVSHM # System V-like memory sharing
options SHMMAXPGS=1024 # 1024 pages is the default
# Filesystem options
options FIFO # POSIX fifo support (in all filesystems)
options FFS,QUOTA # fast filesystem with user and group quotas
options MFS # memory-based filesystem
options NFSCLIENT # Sun NFS-compatible filesystem (client)
options NFSSERVER # Sun NFS-compatible filesystem (server)
options KERNFS # kernel data-structure filesystem
options MSDOSFS # Ability to read write MS-Dos filsystem
options CD9660 # ISO 9660 + Rock Ridge file system
options FDESC # user file descriptor filesystem
#options UMAPFS # uid/gid remapping filesystem
#options NULLFS # null layer filesystem
#options LFS # Log-based filesystem (still experimental)
#options PORTAL # portal filesystem (still experimental)
# Networking options
options INET # Internet protocols
options "TCP_COMPAT_42" # compatibility with 4.2BSD TCP/IP
options GATEWAY # IP packet forwarding
#options MULTICAST # Multicast support
#options MROUTING # Multicast routing support
#options ISO # OSI networking
#options TPIP
#options EON
config bsd swap generic
mainbus0 at root
cpu* at mainbus0
pica* at mainbus0
clock0 at pica?
pc0 at pica?
pms0 at pica?
com0 at pica?
com1 at pica?
lpt0 at pica?
sn0 at pica?
fdc0 at pica?
fd* at fdc? drive ?
asc0 at pica?
scsibus* at asc?
sd* at scsibus? target ? lun ?
st* at scsibus? target ? lun ?
cd* at scsibus? target ? lun ?
pseudo-device sl 2 # serial-line IP ports
pseudo-device ppp 2 # serial-line PPP ports
pseudo-device pty 64 # pseudo ptys
pseudo-device bpfilter 16 # packet filter ports
pseudo-device loop
pseudo-device vnd 4 # virtual disk

View File

@ -0,0 +1,189 @@
# $NetBSD: Makefile.pica,v 1.1.1.1 1996/03/13 04:58:05 jonathan Exp $
# @(#)Makefile.pica 8.2 (Berkeley) 2/16/94
#
# Makefile for 4.4 BSD
#
# This makefile is constructed from a machine description:
# config machineid
# Most changes should be made in the machine description
# /sys/arch/MACHINE/conf/``machineid''
# after which you should do
# config machineid
# Machine generic makefile changes should be made in
# /sys/arch/MACHINE/conf/Makefile.``machinetype''
# after which config should be rerun for all machines of that type.
#
# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE VISIBLE TO MAKEFILE
# IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING
#
# -DTRACE compile in kernel tracing hooks
# -DQUOTA compile in file system quotas
# DEBUG is set to -g by config if debugging is requested (config -g).
# PROF is set to -pg by config if profiling is requested (config -p).
TOUCH= touch -f -c
# source tree is located via $S relative to the compilation directory
S= ../../../..
PICA= ../..
LD=ld.kern
INCLUDES= -I. -I$S/arch -I$S -I$S/sys
COPTS= ${INCLUDES} ${IDENT} -D_KERNEL -Dpica -D__NetBSD__ ${GP} \
-mips2 -mcpu=r4000
CPPOPTS=${INCLUDES} ${IDENT} -D_KERNEL -Dpica -D__NetBSD__
.ifdef DEBUG
CFLAGS= ${DEBUG} ${COPTS}
.else
CFLAGS= -O2 ${COPTS}
.endif
### find out what to use for libkern
.include "$S/lib/libkern/Makefile.inc"
.ifndef PROF
LIBKERN= ${KERNLIB}
.else
LIBKERN= ${KERNLIB_PROF}
.endif
### find out what to use for libcompat
.include "$S/compat/common/Makefile.inc"
.ifndef PROF
LIBCOMPAT= ${COMPATLIB}
.else
LIBCOMPAT= ${COMPATLIB_PROF}
.endif
# compile rules: rules are named ${TYPE}_${SUFFIX}${CONFIG_DEP}
# where TYPE is NORMAL, DRIVER, or PROFILE}; SUFFIX is the file suffix,
# capitalized (e.g. C for a .c file), and CONFIG_DEP is _C if the file
# is marked as config-dependent.
NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} $<
NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
DRIVER_C= ${CC} -c ${CFLAGS} ${PROF} $<
DRIVER_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $<
PROFILE_C= ${CC} -p -c ${COPTS} $<
NORMAL_S= ${AS} ${COPTS} $< -o $@
NORMAL_S_C= ${AS} ${COPTS} ${PARAM} $< -o $@
%OBJS
%CFILES
# load lines for config "xxx" will be emitted as:
# xxx: ${SYSTEM_DEP} swapxxx.o
# ${SYSTEM_LD_HEAD}
# ${SYSTEM_LD} swapxxx.o
# ${SYSTEM_LD_TAIL}
SYSTEM_OBJ= locore.o fp.o vnode_if.o ${OBJS} param.o ioconf.o ${LIBKERN} \
${LIBCOMPAT}
#SYSTEM_DEP= Makefile symbols.sort ${SYSTEM_OBJ} ${LIBKERN}
SYSTEM_DEP= Makefile ${SYSTEM_OBJ}
SYSTEM_LD_HEAD= rm -f $@
SYSTEM_LD= -@if [ X${DEBUG} = X-g ]; \
then strip=-X; \
else strip=-x; \
fi; \
echo ${LD} $$strip -N -o $@ -e start -Ttext 80080000 \
'$${SYSTEM_OBJ}' vers.o; \
${LD} $$strip -N -o $@ -e start -Ttext 80080000 \
${SYSTEM_OBJ} vers.o
#SYSTEM_LD_TAIL= @echo rearranging symbols;\
# symorder symbols.sort $@;\
#SYSTEM_LD_TAIL= @size $@; chmod 755 $@; \
# [ X${DEBUG} = X-g ] && { \
# echo cp $@ $@.gdb; rm -f $@.gdb; cp $@ $@.gdb; \
# echo strip -d $@; strip -d $@; } || true
SYSTEM_LD_TAIL= mv $@ ${@}.elf; \
elf2aout ${@}.elf $@; \
chmod 755 $@; \
elf2ecoff ${@}.elf ${@}.ecoff
%LOAD
newvers:
sh $S/conf/newvers.sh
${CC} $(CFLAGS) -c vers.c
clean::
rm -f eddep bsd bsd.gdb tags *.o locore.i [a-z]*.s \
vnode_if.[ch] Errs errs linterrs makelinks genassym
lint: /tmp param.c
@lint -hbxn -DGENERIC -Dvolatile= ${COPTS} ${PARAM} -UKGDB \
${PICA}/pica/Locore.c ${CFILES} ${PICA}/pica/swapgeneric.c \
ioconf.c param.c
symbols.sort: ${PICA}/pica/symbols.raw
grep -v '^#' ${PICA}/pica/symbols.raw \
| sed 's/^ //' | sort -u > symbols.sort
locore.o: ${PICA}/pica/locore.S ${PICA}/include/machAsmDefs.h \
${PICA}/include/machConst.h ${PICA}/include/reg.h assym.h
${CC} -c ${COPTS} ${PARAM} -DLOCORE -mips3 ${PICA}/pica/locore.S
fp.o: ${PICA}/pica/fp.S ${PICA}/include/machAsmDefs.h \
${PICA}/include/machConst.h ${PICA}/include/reg.h assym.h
${CC} -c ${COPTS} ${PARAM} -DLOCORE ${PICA}/pica/fp.S
# the following is necessary because autoconf.o depends on #if GENERIC
autoconf.o: Makefile
# the following are necessary because the files depend on the types of
# cpu's included in the system configuration
clock.o machdep.o autoconf.o conf.o: Makefile
# depend on network configuration
uipc_proto.o vfs_conf.o: Makefile
assym.h: genassym
./genassym >assym.h
genassym: ${PICA}/pica/genassym.c
${CC} ${INCLUDES} ${IDENT} ${PARAM} -o genassym ${PICA}/pica/genassym.c
depend: assym.h param.c vnode_if.h
mkdep ${COPTS} ${CFILES} ioconf.c param.c
mkdep -a -p ${INCLUDES} ${IDENT} ${PARAM} ${PICA}/pica/genassym.c
links:
egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
sort -u | comm -23 - dontlink | \
sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
sh makelinks && rm -f dontlink
tags:
@echo "see $S/kern/Makefile for tags"
ioconf.o: ioconf.c
${CC} -c ${CFLAGS} ioconf.c
param.c: $S/conf/param.c
rm -f param.c
cp $S/conf/param.c .
param.o: param.c Makefile
${CC} -c ${CFLAGS} ${PARAM} param.c
vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
sh $S/conf/newvers.sh
${CC} ${CFLAGS} -c vers.c
vnode_if.c: $S/kern/vnode_if.sh $S/kern/vnode_if.src
sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
vnode_if.h: $S/kern/vnode_if.sh $S/kern/vnode_if.src
sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
%RULES

89
sys/arch/pica/conf/PICA Normal file
View File

@ -0,0 +1,89 @@
#
#
#
machine pica
maxusers 8
# Need to set locally
options TIMEZONE="8*60" # minutes west of GMT (for)
options DST=1 # use daylight savings rules
# Standard system options
options SWAPPAGER # swap pager (anonymous and swap space)
options VNODEPAGER # vnode pager (mapped files)
options DEVPAGER # device pager (mapped devices)
options DIAGNOSTIC # extra kernel debugging checks
options DEBUG # extra kernel debugging support
options "COMPAT_43" # compatibility with 4.3BSD binaries
#options KTRACE # system call tracing support
options "NKMEMCLUSTERS=1024" # 4K pages in kernel malloc pool
#options KGDB # support for kernel gdb
#options "KGDBRATE=19200" # kernel gdb port rate (default 9600)
#options "KGDBDEV=15*256+0" # device for kernel gdb
# System V options
options SYSVMSG # System V-like message queues
options SYSVSEM # System V-like semaphores
options SYSVSHM # System V-like memory sharing
options SHMMAXPGS=1024 # 1024 pages is the default
# Filesystem options
options FIFO # POSIX fifo support (in all filesystems)
options FFS,QUOTA # fast filesystem with user and group quotas
options MFS # memory-based filesystem
options NFSCLIENT # Sun NFS-compatible filesystem (client)
options NFSSERVER # Sun NFS-compatible filesystem (server)
options KERNFS # kernel data-structure filesystem
options MSDOSFS # Ability to read write MS-Dos filsystem
options CD9660 # ISO 9660 + Rock Ridge file system
options FDESC # user file descriptor filesystem
#options UMAPFS # uid/gid remapping filesystem
#options NULLFS # null layer filesystem
#options LFS # Log-based filesystem (still experimental)
#options PORTAL # portal filesystem (still experimental)
# Networking options
options INET # Internet protocols
options "TCP_COMPAT_42" # compatibility with 4.2BSD TCP/IP
options GATEWAY # IP packet forwarding
#options MULTICAST # Multicast support
#options MROUTING # Multicast routing support
#options ISO # OSI networking
#options TPIP
#options EON
config bsd root on sd0 swap on sd0 and sd1
#options GENERIC
mainbus0 at root
cpu* at mainbus0
pica* at mainbus0
clock0 at pica?
pc0 at pica?
pms0 at pica?
com0 at pica?
com1 at pica?
lpt0 at pica?
sn0 at pica?
fdc0 at pica?
fd* at fdc? drive ?
asc0 at pica?
scsibus* at asc?
sd* at scsibus? target ? lun ?
st* at scsibus? target ? lun ?
cd* at scsibus? target ? lun ?
pseudo-device loop 1 # network loopback
pseudo-device sl 2 # serial-line IP ports
pseudo-device ppp 2 # serial-line PPP ports
pseudo-device tun 2 # network tunneling over tty
pseudo-device pty 64 # pseudo ptys
pseudo-device bpfilter 16 # packet filter ports
pseudo-device vnd 4 # virtual disk

View File

@ -0,0 +1,87 @@
# $NetBSD: files.pica,v 1.1.1.1 1996/03/13 04:58:05 jonathan Exp $
maxpartitions 8
maxusers 2 8 64
device mainbus at root { } # no locators
# Our CPU configurator
device cpu at mainbus # not optional
file arch/pica/pica/cpu.c cpu
#
# PICA bus autoconfiguration devices
#
device pica at mainbus { } # { slot = -1, offset = -1 }
file arch/pica/pica/pica.c pica needs-flag
# Real time clock, must have one..
device clock at pica
file arch/pica/pica/clock.c clock
file arch/pica/pica/clock_mc.c clock
# Ethernet chip
device sn at pica: ifnet, ether
file arch/pica/dev/if_sn.c sn needs-count
# Use machine independent SCSI driver routines
include "../../../scsi/files.scsi"
major {sd = 0}
major {cd = 3}
# Machine dependent SCSI interface driver
device asc at pica: scsi
file arch/pica/dev/asc.c asc needs-count
# NS16450/16550 Serial line driver
device com at pica
file arch/pica/dev/com.c com needs-count
# Paralell printer port driver
device lpt at pica
file arch/pica/dev/lpt.c lpt needs-count
# Console driver on PC-style graphics
device pc at pica
device pms at pica
file arch/pica/dev/pccons.c pc pms needs-count
# PS2 type mouse driver.
# Floppy disk controller
device fdc at pica {drive = -1}
device fd at fdc
file arch/pica/dev/fd.c fdc needs-flag
major {fd = 7}
# Required files
file arch/pica/isa/isa.c
file arch/pica/pica/autoconf.c
file arch/pica/pica/conf.c
file arch/pica/pica/cpu_exec.c
file arch/pica/pica/disksubr.c
file arch/pica/dev/dma.c
file arch/pica/pica/elf.c
file arch/pica/pica/machdep.c
file arch/pica/pica/mainbus.c
file arch/pica/pica/minidebug.c
file arch/pica/pica/mem.c
file arch/pica/pica/pmap.c
file arch/pica/pica/process_machdep.c
file arch/pica/pica/sys_machdep.c
file arch/pica/pica/trap.c
file arch/pica/pica/vm_machdep.c
#
# This is a dummy - don't try to use it:
file dev/cons.c
file dev/cninit.c
file netinet/in_cksum.c
file netns/ns_cksum.c ns
file compat/ultrix/ultrix_misc.c compat_ultrix
file compat/ultrix/ultrix_syscalls.c compat_ultrix
file compat/ultrix/ultrix_sysent.c compat_ultrix

View File

@ -0,0 +1,6 @@
# $NetBSD: std.pmax,v 1.0 1995/04/28 03:10:41 jonathan Exp
# standard pica info
machine pica
mainbus0 at root
cpu* at mainbus0

2069
sys/arch/pica/dev/asc.c Normal file

File diff suppressed because it is too large Load Diff

321
sys/arch/pica/dev/ascreg.h Normal file
View File

@ -0,0 +1,321 @@
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell and Rick Macklem.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: @(#)ascreg.h 8.1 (Berkeley) 6/10/93
* $Id: ascreg.h,v 1.1.1.1 1996/03/13 04:58:05 jonathan Exp $
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
/*
* HISTORY
* Log: scsi_53C94.h,v
* Revision 2.4 91/02/05 17:44:59 mrt
* Added author notices
* [91/02/04 11:18:32 mrt]
*
* Changed to use new Mach copyright
* [91/02/02 12:17:11 mrt]
*
* Revision 2.3 90/12/05 23:34:46 af
* Documented max DMA xfer size.
* [90/12/03 23:39:36 af]
*
* Revision 2.1.1.1 90/11/01 03:38:54 af
* Created, from the DEC specs:
* "PMAZ-AA TURBOchannel SCSI Module Functional Specification"
* Workstation Systems Engineering, Palo Alto, CA. Aug 27, 1990.
* And from the NCR data sheets
* "NCR 53C94, 53C95, 53C96 Advanced SCSI Controller"
* [90/09/03 af]
*/
/*
* File: scsi_53C94.h
* Author: Alessandro Forin, Carnegie Mellon University
* Date: 9/90
*
* Defines for the NCR 53C94 ASC (SCSI interface)
* Some gotcha came from the "86C01/53C94 DMA lab work" written
* by Ken Stewart (NCR MED Logic Products Applications Engineer)
* courtesy of NCR. Thanks Ken !
*/
#define ASC_OFFSET_53C94 0x0 /* from module base */
#define ASC_NCMD 7 /* Number of simultaneous cmds */
/*
* Synch xfer parameters, and timing conversions
*/
#define SCSI_MIN_PERIOD 50 /* in 4 nsecs units */
#define ASC_MIN_PERIOD40 8 /* in CLKS/BYTE, 1 CLK = 25nsecs */
#define ASC_MIN_PERIOD25 5 /* in CLKS/BYTE, 1 CLK = 40nsecs */
#define ASC_MIN_PERIOD12 3 /* in CLKS/BYTE, 1 CLK = 80nsecs */
#define ASC_MAX_PERIOD40 56 /* in CLKS/BYTE, 1 CLK = 25nsecs */
#define ASC_MAX_PERIOD25 35 /* in CLKS/BYTE, 1 CLK = 40nsecs */
#define ASC_MAX_PERIOD12 18 /* in CLKS/BYTE, 1 CLK = 80nsecs */
#define ASC_MAX_OFFSET 15 /* pure number */
/*
* Register map, padded as needed
*/
typedef volatile struct {
u_char asc_tc_lsb; /* rw: Transfer Counter LSB */
u_char asc_tc_msb; /* rw: Transfer Counter MSB */
u_char asc_fifo; /* rw: FIFO top */
u_char asc_cmd; /* rw: Command */
u_char asc_status; /* r: Status */
#define asc_dbus_id asc_status /* w: Destination Bus ID */
u_char asc_intr; /* r: Interrupt */
#define asc_sel_timo asc_intr /* w: (re)select timeout */
u_char asc_ss; /* r: Sequence Step */
#define asc_syn_p asc_ss /* w: synchronous period */
u_char asc_flags; /* r: FIFO flags + seq step */
#define asc_syn_o asc_flags /* w: synchronous offset */
u_char asc_cnfg1; /* rw: Configuration 1 */
u_char asc_ccf; /* w: Clock Conv. Factor */
u_char asc_test; /* w: Test Mode */
u_char asc_cnfg2; /* rw: Configuration 2 */
u_char asc_cnfg3; /* rw: Configuration 3 */
u_char asc_res_fifo; /* w: Reserve FIFO byte */
} asc_regmap_t;
/*
* Transfer Count: access macros
* That a NOP is required after loading the dma counter
* I learned on the NCR test code. Sic.
*/
#define ASC_TC_MAX 0x10000
#define ASC_TC_GET(ptr, val) \
val = (ptr)->asc_tc_lsb | ((ptr)->asc_tc_msb << 8)
#define ASC_TC_PUT(ptr, val) \
(ptr)->asc_tc_lsb = (val); \
(ptr)->asc_tc_msb = (val) >> 8; \
(ptr)->asc_cmd = ASC_CMD_NOP | ASC_CMD_DMA;
/*
* Command register (command codes)
*/
#define ASC_CMD_DMA 0x80
/* Miscellaneous */
#define ASC_CMD_NOP 0x00
#define ASC_CMD_FLUSH 0x01
#define ASC_CMD_RESET 0x02
#define ASC_CMD_BUS_RESET 0x03
/* Initiator state */
#define ASC_CMD_XFER_INFO 0x10
#define ASC_CMD_I_COMPLETE 0x11
#define ASC_CMD_MSG_ACPT 0x12
#define ASC_CMD_XFER_PAD 0x18
#define ASC_CMD_SET_ATN 0x1a
#define ASC_CMD_CLR_ATN 0x1b
/* Target state */
#define ASC_CMD_SND_MSG 0x20
#define ASC_CMD_SND_STATUS 0x21
#define ASC_CMD_SND_DATA 0x22
#define ASC_CMD_DISC_SEQ 0x23
#define ASC_CMD_TERM 0x24
#define ASC_CMD_T_COMPLETE 0x25
#define ASC_CMD_DISC 0x27
#define ASC_CMD_RCV_MSG 0x28
#define ASC_CMD_RCV_CDB 0x29
#define ASC_CMD_RCV_DATA 0x2a
#define ASC_CMD_RCV_CMD 0x2b
#define ASC_CMD_ABRT_DMA 0x04
/* Disconnected state */
#define ASC_CMD_RESELECT 0x40
#define ASC_CMD_SEL 0x41
#define ASC_CMD_SEL_ATN 0x42
#define ASC_CMD_SEL_ATN_STOP 0x43
#define ASC_CMD_ENABLE_SEL 0x44
#define ASC_CMD_DISABLE_SEL 0x45
#define ASC_CMD_SEL_ATN3 0x46
/*
* Status register, and phase encoding
*/
#define ASC_CSR_INT 0x80
#define ASC_CSR_GE 0x40
#define ASC_CSR_PE 0x20
#define ASC_CSR_TC 0x10
#define ASC_CSR_VGC 0x08
#define ASC_CSR_MSG 0x04
#define ASC_CSR_CD 0x02
#define ASC_CSR_IO 0x01
#define ASC_PHASE(csr) ((csr) & 0x7)
#define ASC_PHASE_DATAO 0x0
#define ASC_PHASE_DATAI 0x1
#define ASC_PHASE_COMMAND 0x2
#define ASC_PHASE_STATUS 0x3
/* 4..5 ANSI reserved */
#define ASC_PHASE_MSG_OUT 0x6
#define ASC_PHASE_MSG_IN 0x7
/*
* Destination Bus ID
*/
#define ASC_DEST_ID_MASK 0x07
/*
* Interrupt register
*/
#define ASC_INT_RESET 0x80
#define ASC_INT_ILL 0x40
#define ASC_INT_DISC 0x20
#define ASC_INT_BS 0x10
#define ASC_INT_FC 0x08
#define ASC_INT_RESEL 0x04
#define ASC_INT_SEL_ATN 0x02
#define ASC_INT_SEL 0x01
/*
* Timeout register:
*
* val = (timeout * CLK_freq) / (8192 * CCF);
*/
#define ASC_TIMEOUT_250(clk, ccf) (((clk) * 31) / (ccf))
/*
* Sequence Step register
*/
#define ASC_SS_RESERVED 0xf0
#define ASC_SS_SOM 0x08
#define ASC_SS_MASK 0x07
#define ASC_SS(ss) ((ss) & ASC_SS_MASK)
/*
* Synchronous Transfer Period
*/
#define ASC_STP_MASK 0x1f
#define ASC_STP_MIN 0x05 /* 5 clk per byte */
#define ASC_STP_MAX 0x04 /* after ovfl, 35 clk/byte */
/*
* FIFO flags
*/
#define ASC_FLAGS_SEQ_STEP 0xe0
#define ASC_FLAGS_FIFO_CNT 0x1f
/*
* Synchronous offset
*/
#define ASC_SYNO_MASK 0x0f /* 0 -> asyn */
/*
* Configuration 1
*/
#define ASC_CNFG1_SLOW 0x80
#define ASC_CNFG1_SRD 0x40
#define ASC_CNFG1_P_TEST 0x20
#define ASC_CNFG1_P_CHECK 0x10
#define ASC_CNFG1_TEST 0x08
#define ASC_CNFG1_MY_BUS_ID 0x07
/*
* CCF register
*/
#define ASC_CCF(clk) ((((clk) - 1) / 5) + 1)
/*
* Test register
*/
#define ASC_TEST_XXXX 0xf8
#define ASC_TEST_HI_Z 0x04
#define ASC_TEST_I 0x02
#define ASC_TEST_T 0x01
/*
* Configuration 2
*/
#define ASC_CNFG2_RFB 0x80
#define ASC_CNFG2_EPL 0x40
#define ASC_CNFG2_EBC 0x20
#define ASC_CNFG2_DREQ_HIZ 0x10
#define ASC_CNFG2_SCSI2 0x08
#define ASC_CNFG2_BPA 0x04
#define ASC_CNFG2_RPE 0x02
#define ASC_CNFG2_DPE 0x01
/*
* Configuration 3
*/
#define ASC_CNFG3_RESERVED 0xf8
#define ASC_CNFG3_SRB 0x04
#define ASC_CNFG3_ALT_DMA 0x02
#define ASC_CNFG3_T8 0x01
#define ST_MASK 0x3e

1000
sys/arch/pica/dev/com.c Normal file

File diff suppressed because it is too large Load Diff

394
sys/arch/pica/dev/dma.c Normal file
View File

@ -0,0 +1,394 @@
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: @(#)rz.c 8.1 (Berkeley) 7/29/93
* $Id: dma.c,v 1.1.1.1 1996/03/13 04:58:05 jonathan Exp $
*/
/*
* PICA system dma driver. Handles resource allocation and
* logical (viritual) address remaping.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/malloc.h>
#include <sys/proc.h>
#include <sys/syslog.h>
#include <sys/device.h>
#include <vm/vm.h>
#include <vm/vm_kern.h>
#include <vm/vm_page.h>
#include <machine/cpu.h>
#include <machine/autoconf.h>
#include <machine/pte.h>
#include <machine/pio.h>
#include <scsi/scsi_all.h>
#include <scsi/scsiconf.h>
#include <pica/pica/pica.h>
#include <pica/dev/dma.h>
extern vm_map_t phys_map;
#define dma_pte_to_pa(x) (((x) - first_dma_pte) * PICA_DMA_PAGE_SIZE)
dma_pte_t *free_dma_pte; /* Pointer to free dma pte list */
dma_pte_t *first_dma_pte; /* Pointer to first dma pte */
/*
* Initialize the dma mapping register area and pool.
*/
void
picaDmaInit()
{
int map = PICA_TL_BASE;
MachFlushCache(); /* Make shure no map entries are cached */
bzero((char *)map, PICA_TL_SIZE);
free_dma_pte = (dma_pte_t *)map;
first_dma_pte = (dma_pte_t *)map;
free_dma_pte->queue.next = NULL;
free_dma_pte->queue.size = PICA_TL_SIZE / sizeof(dma_pte_t);
out32(PICA_SYS_TL_BASE, MACH_UNCACHED_TO_PHYS(map));
out32(PICA_SYS_TL_LIMIT, PICA_TL_SIZE);
out32(PICA_SYS_TL_IVALID, 0);
}
/*
* Allocate an array of 'size' dma pte entrys.
* Return address to first pte.
*/
void
picaDmaTLBAlloc(dma_softc_t *dma)
{
dma_pte_t *list;
dma_pte_t *found;
int size;
int s;
found = NULL;
size = dma->pte_size;
do {
list = (dma_pte_t *)&free_dma_pte;
s = splhigh();
while(list) {
if(list->queue.next->queue.size >= size) {
found = list->queue.next;
break;
}
}
/*XXX Wait for release wakeup */
} while(found == NULL);
if(found->queue.size == size) {
list->queue.next = found->queue.next;
}
else {
list->queue.next = found + size;
list = found + size;
list->queue.next = found->queue.next;
list->queue.size = found->queue.size - size;
}
splx(s);
dma->pte_base = found;
dma->dma_va = dma_pte_to_pa(found);
}
/*
* Free an array of dma pte entrys.
*/
void
picaDmaTLBFree(dma_softc_t *dma)
{
dma_pte_t *list;
dma_pte_t *entry;
int size;
int s;
s = splhigh();
entry = dma->pte_base;
size = dma->pte_size;
entry->queue.next = NULL;
entry->queue.size = size;
if(free_dma_pte == NULL || entry < free_dma_pte) {
list = entry;
list->queue.next = free_dma_pte;
free_dma_pte = entry;
}
else {
list = free_dma_pte;
while(list < entry && list->queue.next != NULL) {
if(list + list->queue.size == entry) {
list->queue.size += size;
break;
}
else if(list->queue.next == NULL) {
list->queue.next = entry;
break;
}
else
list = list->queue.next;
}
}
if(list->queue.next != NULL) {
if(list + list->queue.size == list->queue.next) {
list->queue.size += list->queue.next->queue.size;
list->queue.next = list->queue.next->queue.next;
}
}
splx(s);
/*XXX Wakeup waiting */
}
/*
* Map up a viritual address space in dma space given by
* the dma control structure and invalidate dma TLB cache.
*/
picaDmaTLBMap(dma_softc_t *sc)
{
vm_offset_t pa;
vm_offset_t va;
dma_pte_t *dma_pte;
int nbytes;
va = sc->next_va - sc->dma_va;
dma_pte = sc->pte_base + (va / PICA_DMA_PAGE_SIZE);
nbytes = dma_page_round(sc->next_size + dma_page_offs(va));
va = sc->req_va;
while(nbytes > 0) {
if(va < VM_MIN_KERNEL_ADDRESS) {
pa = MACH_CACHED_TO_PHYS(va);
}
else {
pa = pmap_extract(vm_map_pmap(phys_map), va);
}
pa &= PICA_DMA_PAGE_NUM;
if(pa == 0)
panic("picaDmaTLBMap: null page frame");
dma_pte->entry.lo_addr = pa;
dma_pte->entry.hi_addr = 0;
dma_pte++;
va += PICA_DMA_PAGE_SIZE;
nbytes -= PICA_DMA_PAGE_SIZE;
}
}
/*
* Start local dma channel.
*/
void
picaDmaStart(sc, addr, size, datain)
struct dma_softc *sc;
char *addr;
size_t size;
int datain;
{
int mode;
pDmaReg regs = sc->dma_reg;
/* Halt DMA */
regs->dma_enab = 0;
regs->dma_mode = 0;
/* Remap request space va into dma space va */
sc->req_va = (int)addr;
sc->next_va = sc->dma_va + dma_page_offs(addr);
sc->next_size = size;
/* Map up the request viritual dma space */
picaDmaTLBMap(sc);
out32(PICA_SYS_TL_IVALID, 0); /* Flush dma map cache */
/* Load new transfer parameters */
regs->dma_addr = sc->next_va;
regs->dma_count = sc->next_size;
regs->dma_mode = sc->mode & PICA_DMA_MODE;
sc->sc_active = 1;
if(datain == DMA_FROM_DEV) {
sc->mode &= ~DMA_DIR_WRITE;
regs->dma_enab = PICA_DMA_ENAB_RUN | PICA_DMA_ENAB_READ;
}
else {
sc->mode |= DMA_DIR_WRITE;
regs->dma_enab = PICA_DMA_ENAB_RUN | PICA_DMA_ENAB_WRITE;
}
MachEmptyWriteBuffer();
}
/*
* Set up DMA mapper for external dma.
* Used by ISA dma and SONIC
*/
void
picaDmaMap(sc, addr, size, offset)
struct dma_softc *sc;
char *addr;
size_t size;
int offset;
{
/* Remap request space va into dma space va */
sc->req_va = (int)addr;
sc->next_va = sc->dma_va + dma_page_offs(addr) + offset;
sc->next_size = size;
/* Map up the request viritual dma space */
picaDmaTLBMap(sc);
}
/*
* Prepare for new dma by flushing
*/
void
picaDmaFlush(sc, addr, size, datain)
struct dma_softc *sc;
char *addr;
size_t size;
int datain;
{
out32(PICA_SYS_TL_IVALID, 0); /* Flush dma map cache */
}
/*
* Stop/Reset a DMA channel
*/
void
picaDmaReset(dma_softc_t *sc)
{
pDmaReg regs = sc->dma_reg;
/* Halt DMA */
regs->dma_enab = 0;
regs->dma_mode = 0;
sc->sc_active = 0;
}
/*
* End dma operation, return byte count left.
*/
int
picaDmaEnd(dma_softc_t *sc)
{
pDmaReg regs = sc->dma_reg;
int res;
res = regs->dma_count = sc->next_size;
/* Halt DMA */
regs->dma_enab = 0;
regs->dma_mode = 0;
sc->sc_active = 0;
return res;
}
/*
* Null call rathole!
*/
void
picaDmaNull(dma_softc_t *sc)
{
pDmaReg regs = sc->dma_reg;
printf("picaDmaNull called\n");
}
/*
* dma_init..
* Called from asc to set up dma
*/
void
asc_dma_init(dma_softc_t *sc)
{
sc->reset = picaDmaReset;
sc->enintr = picaDmaNull;
sc->start = picaDmaStart;
sc->map = picaDmaMap;
sc->isintr = picaDmaNull;
sc->intr = picaDmaNull;
sc->end = picaDmaEnd;
sc->dma_reg = (pDmaReg)PICA_SYS_DMA0_REGS;
sc->pte_size = 32;
sc->mode = PICA_DMA_MODE_160NS | PICA_DMA_MODE_16;
picaDmaTLBAlloc(sc);
}
/*
* dma_init..
* Called from fdc to set up dma
*/
void
fdc_dma_init(dma_softc_t *sc)
{
sc->reset = picaDmaReset;
sc->enintr = picaDmaNull;
sc->start = picaDmaStart;
sc->map = picaDmaMap;
sc->isintr = picaDmaNull;
sc->intr = picaDmaNull;
sc->end = picaDmaEnd;
sc->dma_reg = (pDmaReg)PICA_SYS_DMA1_REGS;
sc->pte_size = 32;
sc->mode = PICA_DMA_MODE_160NS | PICA_DMA_MODE_8;
picaDmaTLBAlloc(sc);
}
/*
* dma_init..
* Called from sonic to set up dma
*/
void
sn_dma_init(dma_softc_t *sc, int pages)
{
sc->reset = picaDmaNull;
sc->enintr = picaDmaNull;
sc->start = picaDmaFlush;
sc->map = picaDmaMap;
sc->isintr = picaDmaNull;
sc->intr = picaDmaNull;
sc->end = picaDmaNull;
sc->dma_reg = (pDmaReg)NULL;
sc->pte_size = pages;
sc->mode = 0;
picaDmaTLBAlloc(sc);
}

150
sys/arch/pica/dev/dma.h Normal file
View File

@ -0,0 +1,150 @@
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: @(#)dma.h 8.1 (Berkeley) 6/10/93
* $Id: dma.h,v 1.1.1.1 1996/03/13 04:58:05 jonathan Exp $
*/
/*
* The PICA system has four dma channels capable of scatter/gather
* and full memory addressing. The maximum transfer length is 1Mb.
* Dma snopes the L2 cache so no precaution is required. However
* if L1 cache is cached 'write back' the processor is responible
* for flushing/invalidating it.
*
* The dma mapper has up to 4096 page descriptors.
*/
#define PICA_TL_BASE 0xa0008000 /* Base of tl register area */
#define PICA_TL_SIZE 0x00008000 /* Size of tl register area */
/*
* Hardware dma registers.
*/
typedef volatile struct {
int dma_mode;
int pad1;
int dma_enab;
int pad2;
int dma_count;
int pad3;
vm_offset_t dma_addr;
int pad4;
} DmaReg, *pDmaReg;
#define PICA_DMA_MODE_40NS 0x00 /* Device dma timing */
#define PICA_DMA_MODE_80NS 0x01 /* Device dma timing */
#define PICA_DMA_MODE_120NS 0x02 /* Device dma timing */
#define PICA_DMA_MODE_160NS 0x03 /* Device dma timing */
#define PICA_DMA_MODE_200NS 0x04 /* Device dma timing */
#define PICA_DMA_MODE_240NS 0x05 /* Device dma timing */
#define PICA_DMA_MODE_280NS 0x06 /* Device dma timing */
#define PICA_DMA_MODE_320NS 0x07 /* Device dma timing */
#define PICA_DMA_MODE_8 0x08 /* Device 8 bit */
#define PICA_DMA_MODE_16 0x10 /* Device 16 bit */
#define PICA_DMA_MODE_32 0x18 /* Device 32 bit */
#define PICA_DMA_MODE_INT 0x20 /* Interrupt when done */
#define PICA_DMA_MODE_BURST 0x40 /* Burst mode (Rev 2 only) */
#define PICA_DMA_MODE_FAST 0x80 /* Fast dma cycle (Rev 2 only) */
#define PICA_DMA_MODE 0xff /* Mode register bits */
#define DMA_DIR_WRITE 0x100 /* Software direction status */
#define DMA_DIR_READ 0x000 /* Software direction status */
#define PICA_DMA_ENAB_RUN 0x01 /* Enable dma */
#define PICA_DMA_ENAB_READ 0x00 /* Read from device */
#define PICA_DMA_ENAB_WRITE 0x02 /* Write to device */
#define PICA_DMA_ENAB_TC_IE 0x100 /* Terminal count int enable */
#define PICA_DMA_ENAB_ME_IE 0x200 /* Memory error int enable */
#define PICA_DMA_ENAB_TL_IE 0x400 /* Translation limit int enable */
#define PICA_DMA_COUNT_MASK 0x00fffff /* Byte count mask */
#define PICA_DMA_PAGE_NUM 0xffff000 /* Address page number */
#define PICA_DMA_PAGE_OFFS 0x0000fff /* Address page offset */
#define PICA_DMA_PAGE_SIZE 0x0001000 /* Address page size */
/*
* Dma TLB entry
*/
typedef union dma_pte {
struct {
vm_offset_t lo_addr; /* Low part of translation addr */
vm_offset_t hi_addr; /* High part of translation addr */
} entry;
struct bbb {
union dma_pte *next; /* Next free translation entry */
int size; /* Number of consecutive free entrys */
} queue;
} dma_pte_t;
/*
* Structure used to control dma.
*/
typedef struct dma_softc {
struct device sc_dev; /* use as a device */
struct esp_softc *sc_esp;
vm_offset_t dma_va; /* Viritual address for transfer */
int req_va; /* Original request va */
vm_offset_t next_va; /* Value to program into dma regs */
int next_size; /* Value to program into dma regs */
int mode; /* Mode register value and direction */
dma_pte_t *pte_base; /* Pointer to dma tlb array */
int pte_size; /* Size of pte allocated pte array */
pDmaReg dma_reg; /* Pointer to dma registers */
int sc_active; /* Active flag */
char **sc_dmaaddr; /* Pointer to dma address in dev */
int *sc_dmalen; /* Pointer to len counter in dev */
void (*reset)(struct dma_softc *); /* Reset routine pointer */
void (*enintr)(struct dma_softc *); /* Int enab routine pointer */
void (*map)(struct dma_softc *, caddr_t, size_t, int);
/* Map a dma viritual area */
void (*start)(struct dma_softc *, caddr_t, size_t, int);
/* Start routine pointer */
int (*isintr)(struct dma_softc *); /* Int check routine pointer */
int (*intr)(struct dma_softc *); /* Interrupt routine pointer */
int (*end)(struct dma_softc *); /* Interrupt routine pointer */
} dma_softc_t;
#define DMA_TO_DEV 0
#define DMA_FROM_DEV 1
#define dma_page_offs(x) ((int)(x) & PICA_DMA_PAGE_OFFS)
#define dma_page_round(x) (((int)(x) + PICA_DMA_PAGE_OFFS) & PICA_DMA_PAGE_NUM)
#define DMA_RESET(r) ((r->reset)(r))
#define DMA_START(a, b, c, d) ((a->start)(a, b, c, d))
#define DMA_MAP(a, b, c, d) ((a->map)(a, b, c, d))
#define DMA_INTR(r) ((r->intr)(r))
#define DMA_DRAIN(r)
#define DMA_END(r) ((r->end)(r))

1132
sys/arch/pica/dev/fd.c Normal file

File diff suppressed because it is too large Load Diff

66
sys/arch/pica/dev/fdreg.h Normal file
View File

@ -0,0 +1,66 @@
/* $NetBSD: fdreg.h,v 1.1.1.1 1996/03/13 04:58:06 jonathan Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
* All rights reserved.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* @(#)fdreg.h 7.1 (Berkeley) 5/9/91
*/
/*
* AT floppy controller registers and bitfields
*/
/* uses NEC765 controller */
#include <dev/ic/nec765reg.h>
/* registers */
#define fdout 2 /* Digital Output Register (W) */
#define FDO_FDSEL 0x03 /* floppy device select */
#define FDO_FRST 0x04 /* floppy controller reset */
#define FDO_FDMAEN 0x08 /* enable floppy DMA and Interrupt */
#define FDO_MOEN(n) ((1 << n) * 0x10) /* motor enable */
#define fdsts 4 /* NEC 765 Main Status Register (R) */
#define fddata 5 /* NEC 765 Data Register (R/W) */
#define fdctl 7 /* Control Register (W) */
#define FDC_500KBPS 0x00 /* 500KBPS MFM drive transfer rate */
#define FDC_300KBPS 0x01 /* 300KBPS MFM drive transfer rate */
#define FDC_250KBPS 0x02 /* 250KBPS MFM drive transfer rate */
#define FDC_125KBPS 0x03 /* 125KBPS FM drive transfer rate */
#define fdin 7 /* Digital Input Register (R) */
#define FDI_DCHG 0x80 /* diskette has been changed */
#define FDC_BSIZE 512
#define FDC_NPORT 8
#define FDC_MAXIOSIZE NBPG /* XXX should be MAXBSIZE */

1321
sys/arch/pica/dev/if_sn.c Normal file

File diff suppressed because it is too large Load Diff

346
sys/arch/pica/dev/if_sn.h Normal file
View File

@ -0,0 +1,346 @@
/*
* Copyright (c) 1991 Algorithmics Ltd (http://www.algor.co.uk)
* You may use, copy, and modify this program so long as you retain the
* copyright line.
*/
/*
* if_sonic.h -- National Semiconductor DP83932BVF (SONIC)
*/
/*
* Accessing SONIC data structures and registers as 32 bit values
* makes code endianess independent. The SONIC is however always in
* bigendian mode so it is necessary to ensure that data structures shared
* between the CPU and the SONIC are always in bigendian order.
*/
/*
* Receive Resource Descriptor
* This structure describes the buffers into which packets
* will be received. Note that more than one packet may be
* packed into a single buffer if constraints permit.
*/
#if SONICDW == 32
struct RXrsrc {
u_long buff_ptrlo; /* buffer address LO */
u_long buff_ptrhi; /* buffer address HI */
u_long buff_wclo; /* buffer size (16bit words) LO */
u_long buff_wchi; /* buffer size (16bit words) HI */
};
#endif
/*
* Receive Descriptor
* This structure holds information about packets received.
*/
#if SONICDW == 32
struct RXpkt {
u_long status; /* + receive status */
u_long byte_count; /* + packet byte count (including FCS) */
u_long pkt_ptrlo; /* + packet data LO (in RBA) */
u_long pkt_ptrhi; /* + packet data HI (in RBA) */
u_long seq_no; /* + RBA sequence numbers */
u_long rlink; /* link to next receive descriptor */
u_long in_use; /* + packet available to SONIC */
u_long pad; /* pad to multiple of 16 bytes */
};
#endif
#define RBASEQ(x) (((x)>>8)&0xff)
#define PSNSEQ(x) ((x) & 0xff)
/*
* Transmit Descriptor
* This structure holds information about packets to be transmitted.
*/
#define FRAGMAX 31 /* maximum number of fragments in a packet */
#if SONICDW == 32
struct TXpkt {
u_long status; /* + transmitted packet status */
u_long config; /* transmission configuration */
u_long pkt_size; /* entire packet size in bytes */
u_long frag_count; /* # fragments in packet */
union {
struct {
u_long _frag_ptrlo; /* pointer to packet fragment LO */
u_long _frag_ptrhi; /* pointer to packet fragment HI */
u_long _frag_size; /* fragment size */
} u_frag;
struct {
u_long _tlink; /* link to next transmit descriptor */
} u_link;
} u[FRAGMAX+1]; /* +1 makes tcp->u[FRAGMAX].u_link.link valid! */
};
#endif
#define frag_ptrlo u_frag._frag_ptrlo
#define frag_ptrhi u_frag._frag_ptrhi
#define frag_size u_frag._frag_size
#define tlink u_link._tlink
#define EOL 0x0001 /* end of list marker for link fields */
#define MAXCAM 16 /* number of user entries in CAM */
#if SONICDW == 32
struct CDA {
struct {
u_long cam_ep; /* CAM Entry Pointer */
u_long cam_ap0; /* CAM Address Port 0 xx-xx-xx-xx-YY-YY */
u_long cam_ap1; /* CAM Address Port 1 xx-xx-YY-YY-xxxx */
u_long cam_ap2; /* CAM Address Port 2 YY-YY-xx-xx-xx-xx */
} desc[MAXCAM];
u_long enable; /* mask enabling CAM entries */
};
#endif
/*
* SONIC registers as seen by the processor
*/
struct sonic_reg {
volatile u_long s_cr; /* 00: Command */
volatile u_long s_dcr; /* 01: Data Configuration */
volatile u_long s_rcr; /* 02: Receive Control */
volatile u_long s_tcr; /* 03: Transmit Control */
volatile u_long s_imr; /* 04: Interrupt Mask */
volatile u_long s_isr; /* 05: Interrupt Status */
volatile u_long s_utda; /* 06: Upper Transmit Descriptor Address */
volatile u_long s_ctda; /* 07: Current Transmit Descriptor Address */
volatile u_long _s_tps; /* 08* Transmit Packet Size */
volatile u_long _s_tfc; /* 09* Transmit Fragment Count */
volatile u_long _s_tsa0; /* 0a* Transmit Start Address 0 */
volatile u_long _s_tsa1; /* 0b* Transmit Start Address 1 */
volatile u_long _s_tfs; /* 0c* Transmit Fragment Size */
volatile u_long s_urda; /* 0d: Upper Receive Descriptor Address */
volatile u_long s_crda; /* 0e: Current Receive Descriptor Address */
volatile u_long _s_crba0; /* 0f* Current Receive Buffer Address 0 */
volatile u_long _s_crba1; /* 10* Current Receive Buffer Address 1 */
volatile u_long _s_rbwc0; /* 11* Remaining Buffer Word Count 0 */
volatile u_long _s_rbwc1; /* 12* Remaining Buffer Word Count 1 */
volatile u_long s_eobc; /* 13: End Of Buffer Word Count */
volatile u_long s_urra; /* 14: Upper Receive Resource Address */
volatile u_long s_rsa; /* 15: Resource Start Address */
volatile u_long s_rea; /* 16: Resource End Address */
volatile u_long s_rrp; /* 17: Resource Read Pointer */
volatile u_long s_rwp; /* 18: Resource Write Pointer */
volatile u_long _s_trba0; /* 19* Temporary Receive Buffer Address 0 */
volatile u_long _s_trba1; /* 1a* Temporary Receive Buffer Address 1 */
volatile u_long _s_tbwc0; /* 1b* Temporary Buffer Word Count 0 */
volatile u_long _s_tbwc1; /* 1c* Temporary Buffer Word Count 1 */
volatile u_long _s_addr0; /* 1d* Address Generator 0 */
volatile u_long _s_addr1; /* 1e* Address Generator 1 */
volatile u_long _s_llfa; /* 1f* Last Link Field Address */
volatile u_long _s_ttda; /* 20* Temp Transmit Descriptor Address */
volatile u_long s_cep; /* 21: CAM Entry Pointer */
volatile u_long s_cap2; /* 22: CAM Address Port 2 */
volatile u_long s_cap1; /* 23: CAM Address Port 1 */
volatile u_long s_cap0; /* 24: CAM Address Port 0 */
volatile u_long s_ce; /* 25: CAM Enable */
volatile u_long s_cdp; /* 26: CAM Descriptor Pointer */
volatile u_long s_cdc; /* 27: CAM Descriptor Count */
volatile u_long s_sr; /* 28: Silicon Revision */
volatile u_long s_wt0; /* 29: Watchdog Timer 0 */
volatile u_long s_wt1; /* 2a: Watchdog Timer 1 */
volatile u_long s_rsc; /* 2b: Receive Sequence Counter */
volatile u_long s_crct; /* 2c: CRC Error Tally */
volatile u_long s_faet; /* 2d: FAE Tally */
volatile u_long s_mpt; /* 2e: Missed Packet Tally */
volatile u_long _s_mdt; /* 2f* Maximum Deferral Timer */
volatile u_long _s_rtc; /* 30* Receive Test Control */
volatile u_long _s_ttc; /* 31* Transmit Test Control */
volatile u_long _s_dtc; /* 32* DMA Test Control */
volatile u_long _s_cc0; /* 33* CAM Comparison 0 */
volatile u_long _s_cc1; /* 34* CAM Comparison 1 */
volatile u_long _s_cc2; /* 35* CAM Comparison 2 */
volatile u_long _s_cm; /* 36* CAM Match */
volatile u_long :32; /* 37* reserved */
volatile u_long :32; /* 38* reserved */
volatile u_long _s_rbc; /* 39* Receiver Byte Count */
volatile u_long :32; /* 3a* reserved */
volatile u_long _s_tbo; /* 3b* Transmitter Backoff Counter */
volatile u_long _s_trc; /* 3c* Transmitter Random Counter */
volatile u_long _s_tbm; /* 3d* Transmitter Backoff Mask */
volatile u_long :32; /* 3e* Reserved */
volatile u_long s_dcr2; /* 3f Data Configuration 2 (AVF) */
};
/*
* Register Interpretations
*/
/*
* The command register is used for issuing commands to the SONIC.
* With the exception of CR_RST, the bit is reset when the operation
* completes.
*/
#define CR_LCAM 0x0200 /* load CAM with descriptor at s_cdp */
#define CR_RRRA 0x0100 /* read next RRA descriptor at s_rrp */
#define CR_RST 0x0080 /* software reset */
#define CR_ST 0x0020 /* start timer */
#define CR_STP 0x0010 /* stop timer */
#define CR_RXEN 0x0008 /* receiver enable */
#define CR_RXDIS 0x0004 /* receiver disable */
#define CR_TXP 0x0002 /* transmit packets */
#define CR_HTX 0x0001 /* halt transmission */
/*
* The data configuration register establishes the SONIC's bus cycle
* operation. This register can only be accessed when the SONIC is in
* reset mode (s_cr.CR_RST is set.)
*/
#define DCR_EXBUS 0x8000 /* extended bus mode (AVF) */
#define DCR_LBR 0x2000 /* latched bus retry */
#define DCR_PO1 0x1000 /* programmable output 1 */
#define DCR_PO0 0x0800 /* programmable output 0 */
#define DCR_STERM 0x0400 /* synchronous termination */
#define DCR_USR1 0x0200 /* reflects USR1 input pin */
#define DCR_USR0 0x0100 /* reflects USR0 input pin */
#define DCR_WC1 0x0080 /* wait state control 1 */
#define DCR_WC0 0x0040 /* wait state control 0 */
#define DCR_DW 0x0020 /* data width select */
#define DCR_BMS 0x0010 /* DMA block mode select */
#define DCR_RFT1 0x0008 /* receive FIFO threshold control 1 */
#define DCR_RFT0 0x0004 /* receive FIFO threshold control 0 */
#define DCR_TFT1 0x0002 /* transmit FIFO threshold control 1 */
#define DCR_TFT0 0x0001 /* transmit FIFO threshold control 0 */
/* data configuration register aliases */
#define DCR_SYNC DCR_STERM /* synchronous (memory cycle 2 clocks) */
#define DCR_ASYNC 0 /* asynchronous (memory cycle 3 clocks) */
#define DCR_WAIT0 0 /* 0 wait states added */
#define DCR_WAIT1 DCR_WC0 /* 1 wait state added */
#define DCR_WAIT2 DCR_WC1 /* 2 wait states added */
#define DCR_WAIT3 (DCR_WC1|DCR_WC0) /* 3 wait states added */
#define DCR_DW16 0 /* use 16-bit DMA accesses */
#define DCR_DW32 DCR_DW /* use 32-bit DMA accesses */
#define DCR_DMAEF 0 /* DMA until TX/RX FIFO has emptied/filled */
#define DCR_DMABLOCK DCR_BMS /* DMA until RX/TX threshold crossed */
#define DCR_RFT4 0 /* receive threshold 4 bytes */
#define DCR_RFT8 DCR_RFT0 /* receive threshold 8 bytes */
#define DCR_RFT16 DCR_RFT1 /* receive threshold 16 bytes */
#define DCR_RFT24 (DCR_RFT1|DCR_RFT0) /* receive threshold 24 bytes */
#define DCR_TFT8 0 /* transmit threshold 8 bytes */
#define DCR_TFT16 DCR_TFT0 /* transmit threshold 16 bytes */
#define DCR_TFT24 DCR_TFT1 /* transmit threshold 24 bytes */
#define DCR_TFT28 (DCR_TFT1|DCR_TFT0) /* transmit threshold 28 bytes */
/*
* The receive control register is used to filter incoming packets and
* provides status information on packets received.
* The contents of the register are copied into the RXpkt.status field
* when a packet is received. RCR_MC - RCR_PRX are then reset.
*/
#define RCR_ERR 0x8000 /* accept packets with CRC errors */
#define RCR_RNT 0x4000 /* accept runt (length < 64) packets */
#define RCR_BRD 0x2000 /* accept broadcast packets */
#define RCR_PRO 0x1000 /* accept all physical address packets */
#define RCR_AMC 0x0800 /* accept all multicast packets */
#define RCR_LB1 0x0400 /* loopback control 1 */
#define RCR_LB0 0x0200 /* loopback control 0 */
#define RCR_MC 0x0100 /* multicast packet received */
#define RCR_BC 0x0080 /* broadcast packet received */
#define RCR_LPKT 0x0040 /* last packet in RBA (RBWC < EOBC) */
#define RCR_CRS 0x0020 /* carrier sense activity */
#define RCR_COL 0x0010 /* collision activity */
#define RCR_CRC 0x0008 /* CRC error */
#define RCR_FAE 0x0004 /* frame alignment error */
#define RCR_LBK 0x0002 /* loopback packet received */
#define RCR_PRX 0x0001 /* packet received without errors */
/* receiver control register aliases */
/* the loopback control bits provide the following options */
#define RCR_LBNONE 0 /* no loopback - normal operation */
#define RCR_LBMAC RCR_LB0 /* MAC loopback */
#define RCR_LBENDEC RCR_LB1 /* ENDEC loopback */
#define RCR_LBTRANS (RCR_LB1|RCR_LB0) /* transceiver loopback */
/*
* The transmit control register controls the SONIC's transmit operations.
* TCR_PINT - TCR_EXDIS are loaded from the TXpkt.config field at the
* start of transmission. TCR_EXD-TCR_PTX are cleared at the beginning
* of transmission and updated when the transmission is completed.
*/
#define TCR_PINT 0x8000 /* interrupt when transmission starts */
#define TCR_POWC 0x4000 /* program out of window collision timer */
#define TCR_CRCI 0x2000 /* transmit packet without 4 byte FCS */
#define TCR_EXDIS 0x1000 /* disable excessive deferral timer */
#define TCR_EXD 0x0400 /* excessive deferrals occurred (>3.2ms) */
#define TCR_DEF 0x0200 /* deferred transmissions occurred */
#define TCR_NCRS 0x0100 /* carrier not present during transmission */
#define TCR_CRSL 0x0080 /* carrier lost during transmission */
#define TCR_EXC 0x0040 /* excessive collisions (>16) detected */
#define TCR_OWC 0x0020 /* out of window (bad) collision occurred */
#define TCR_PMB 0x0008 /* packet monitored bad - the tansmitted
* packet had a bad source address or CRC */
#define TCR_FU 0x0004 /* FIFO underrun (memory access failed) */
#define TCR_BCM 0x0002 /* byte count mismatch (TXpkt.pkt_size
* != sum(TXpkt.frag_size) */
#define TCR_PTX 0x0001 /* packet transmitted without errors */
/* transmit control register aliases */
#define TCR_OWCSFD 0 /* start after start of frame delimiter */
#define TCR_OWCPRE TCR_POWC /* start after first bit of preamble */
/*
* The interrupt mask register masks the interrupts that
* are generated from the interrupt status register.
* All reserved bits should be written with 0.
*/
#define IMR_BREN 0x4000 /* bus retry occurred enable */
#define IMR_HBLEN 0x2000 /* heartbeat lost enable */
#define IMR_LCDEN 0x1000 /* load CAM done interrupt enable */
#define IMR_PINTEN 0x0800 /* programmable interrupt enable */
#define IMR_PRXEN 0x0400 /* packet received enable */
#define IMR_PTXEN 0x0200 /* packet transmitted enable */
#define IMR_TXEREN 0x0100 /* transmit error enable */
#define IMR_TCEN 0x0080 /* timer complete enable */
#define IMR_RDEEN 0x0040 /* receive descriptors exhausted enable */
#define IMR_RBEEN 0x0020 /* receive buffers exhausted enable */
#define IMR_RBAEEN 0x0010 /* receive buffer area exceeded enable */
#define IMR_CRCEN 0x0008 /* CRC tally counter rollover enable */
#define IMR_FAEEN 0x0004 /* FAE tally counter rollover enable */
#define IMR_MPEN 0x0002 /* MP tally counter rollover enable */
#define IMR_RFOEN 0x0001 /* receive FIFO overrun enable */
/*
* The interrupt status register indicates the source of an interrupt when
* the INT pin goes active. The interrupt is acknowledged by writing
* the appropriate bit(s) in this register.
*/
#define ISR_ALL 0xffff /* all interrupts */
#define ISR_BR 0x4000 /* bus retry occurred */
#define ISR_HBL 0x2000 /* CD heartbeat lost */
#define ISR_LCD 0x1000 /* load CAM command has completed */
#define ISR_PINT 0x0800 /* programmed interrupt from TXpkt.config */
#define ISR_PKTRX 0x0400 /* packet received */
#define ISR_TXDN 0x0200 /* no remaining packets to be transmitted */
#define ISR_TXER 0x0100 /* packet transmission caused error */
#define ISR_TC 0x0080 /* timer complete */
#define ISR_RDE 0x0040 /* receive descriptors exhausted */
#define ISR_RBE 0x0020 /* receive buffers exhausted */
#define ISR_RBAE 0x0010 /* receive buffer area exceeded */
#define ISR_CRC 0x0008 /* CRC tally counter rollover */
#define ISR_FAE 0x0004 /* FAE tally counter rollover */
#define ISR_MP 0x0002 /* MP tally counter rollover */
#define ISR_RFO 0x0001 /* receive FIFO overrun */
/*
* The second data configuration register allows additional user defined
* pins to be controlled. These bits are only available if s_dcr.DCR_EXBUS
* is set.
*/
#define DCR2_EXPO3 0x8000 /* EXUSR3 output */
#define DCR2_EXPO2 0x4000 /* EXUSR2 output */
#define DCR2_EXPO1 0x2000 /* EXUSR1 output */
#define DCR2_EXPO0 0x1000 /* EXUSR0 output */
#define DCR2_PHL 0x0010 /* extend HOLD signal by 1/2 clock */
#define DCR2_LRDY 0x0008 /* set latched ready mode */
#define DCR2_PCM 0x0004 /* packet compress on match */
#define DCR2_PCNM 0x0002 /* packet compress on mismatch */
#define DCR2_RJM 0x0001 /* reject on match */

482
sys/arch/pica/dev/lpt.c Normal file
View File

@ -0,0 +1,482 @@
/* $NetBSD: lpt.c,v 1.1.1.1 1996/03/13 04:58:06 jonathan Exp $ */
/*
* Copyright (c) 1993, 1994 Charles Hannum.
* Copyright (c) 1990 William F. Jolitz, TeleMuse
* All rights reserved.
*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This software is a component of "386BSD" developed by
* William F. Jolitz, TeleMuse.
* 4. Neither the name of the developer nor the name "386BSD"
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS A COMPONENT OF 386BSD DEVELOPED BY WILLIAM F. JOLITZ
* AND IS INTENDED FOR RESEARCH AND EDUCATIONAL PURPOSES ONLY. THIS
* SOFTWARE SHOULD NOT BE CONSIDERED TO BE A COMMERCIAL PRODUCT.
* THE DEVELOPER URGES THAT USERS WHO REQUIRE A COMMERCIAL PRODUCT
* NOT MAKE USE OF THIS WORK.
*
* FOR USERS WHO WISH TO UNDERSTAND THE 386BSD SYSTEM DEVELOPED
* BY WILLIAM F. JOLITZ, WE RECOMMEND THE USER STUDY WRITTEN
* REFERENCES SUCH AS THE "PORTING UNIX TO THE 386" SERIES
* (BEGINNING JANUARY 1991 "DR. DOBBS JOURNAL", USA AND BEGINNING
* JUNE 1991 "UNIX MAGAZIN", GERMANY) BY WILLIAM F. JOLITZ AND
* LYNNE GREER JOLITZ, AS WELL AS OTHER BOOKS ON UNIX AND THE
* ON-LINE 386BSD USER MANUAL BEFORE USE. A BOOK DISCUSSING THE INTERNALS
* OF 386BSD ENTITLED "386BSD FROM THE INSIDE OUT" WILL BE AVAILABLE LATE 1992.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``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 DEVELOPER 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.
*/
/*
* Device Driver for AT parallel printer port
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/user.h>
#include <sys/buf.h>
#include <sys/kernel.h>
#include <sys/ioctl.h>
#include <sys/uio.h>
#include <sys/device.h>
#include <sys/syslog.h>
#include <machine/cpu.h>
#include <machine/pio.h>
#include <machine/autoconf.h>
#include <dev/isa/lptreg.h>
#define TIMEOUT hz*16 /* wait up to 16 seconds for a ready */
#define STEP hz/4
#define LPTPRI (PZERO+8)
#define LPT_BSIZE 1024
#if !defined(DEBUG) || !defined(notdef)
#define lprintf
#else
#define lprintf if (lptdebug) printf
int lptdebug = 1;
#endif
struct lpt_softc {
struct device sc_dev;
void *sc_ih;
size_t sc_count;
struct buf *sc_inbuf;
u_char *sc_cp;
int sc_spinmax;
int sc_iobase;
u_char sc_state;
#define LPT_OPEN 0x01 /* device is open */
#define LPT_OBUSY 0x02 /* printer is busy doing output */
#define LPT_INIT 0x04 /* waiting to initialize for open */
u_char sc_flags;
#define LPT_AUTOLF 0x20 /* automatic LF on CR */
#define LPT_NOPRIME 0x40 /* don't prime on open */
u_char sc_control;
u_char sc_laststatus;
};
int lptprobe __P((struct device *, void *, void *));
void lptattach __P((struct device *, struct device *, void *));
int lptintr __P((void *));
struct cfdriver lptcd = {
NULL, "lpt", lptprobe, lptattach, DV_TTY, sizeof(struct lpt_softc)
};
#define LPTUNIT(s) (minor(s) & 0x1f)
#define LPTFLAGS(s) (minor(s) & 0xe0)
#define LPS_INVERT (LPS_SELECT|LPS_NERR|LPS_NBSY|LPS_NACK)
#define LPS_MASK (LPS_SELECT|LPS_NERR|LPS_NBSY|LPS_NACK|LPS_NOPAPER)
#define NOT_READY() ((inb(iobase + lpt_status) ^ LPS_INVERT) & LPS_MASK)
#define NOT_READY_ERR() not_ready(inb(iobase + lpt_status), sc)
static int not_ready __P((u_char, struct lpt_softc *));
static void lptwakeup __P((void *arg));
static int pushbytes __P((struct lpt_softc *));
/*
* Internal routine to lptprobe to do port tests of one byte value.
*/
int
lpt_port_test(port, data, mask)
int port;
u_char data, mask;
{
int timeout;
u_char temp;
data &= mask;
outb(port, data);
timeout = 1000;
do {
delay(20);
temp = inb(port) & mask;
} while (temp != data && --timeout);
lprintf("lpt: port=0x%x out=0x%x in=0x%x timeout=%d\n", port, data,
temp, timeout);
return (temp == data);
}
/*
* Logic:
* 1) You should be able to write to and read back the same value
* to the data port. Do an alternating zeros, alternating ones,
* walking zero, and walking one test to check for stuck bits.
*
* 2) You should be able to write to and read back the same value
* to the control port lower 5 bits, the upper 3 bits are reserved
* per the IBM PC technical reference manauls and different boards
* do different things with them. Do an alternating zeros, alternating
* ones, walking zero, and walking one test to check for stuck bits.
*
* Some printers drag the strobe line down when the are powered off
* so this bit has been masked out of the control port test.
*
* XXX Some printers may not like a fast pulse on init or strobe, I
* don't know at this point, if that becomes a problem these bits
* should be turned off in the mask byte for the control port test.
*
* 3) Set the data and control ports to a value of 0
*/
int
lptprobe(parent, match, aux)
struct device *parent;
void *match, *aux;
{
struct confargs *ca = aux;
int iobase = (int)BUS_CVTADDR(ca);
int port;
u_char mask, data;
int i;
if (!BUS_MATCHNAME(ca, "lpt"))
return (0);
#ifdef DEBUG
#define ABORT do {printf("lptprobe: mask %x data %x failed\n", mask, data); \
return 0;} while (0)
#else
#define ABORT return 0
#endif
port = iobase + lpt_data;
mask = 0xff;
data = 0x55; /* Alternating zeros */
if (!lpt_port_test(port, data, mask))
ABORT;
data = 0xaa; /* Alternating ones */
if (!lpt_port_test(port, data, mask))
ABORT;
for (i = 0; i < CHAR_BIT; i++) { /* Walking zero */
data = ~(1 << i);
if (!lpt_port_test(port, data, mask))
ABORT;
}
for (i = 0; i < CHAR_BIT; i++) { /* Walking one */
data = (1 << i);
if (!lpt_port_test(port, data, mask))
ABORT;
}
outb(iobase + lpt_data, 0);
outb(iobase + lpt_control, 0);
return 1;
}
void
lptattach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct lpt_softc *sc = (void *)self;
struct confargs *ca = aux;
int iobase = (int)BUS_CVTADDR(ca);
printf("\n");
sc->sc_iobase = iobase;
sc->sc_state = 0;
outb(iobase + lpt_control, LPC_NINIT);
BUS_INTR_ESTABLISH(ca, lptintr, sc);
}
/*
* Reset the printer, then wait until it's selected and not busy.
*/
int
lptopen(dev, flag)
dev_t dev;
int flag;
{
int unit = LPTUNIT(dev);
u_char flags = LPTFLAGS(dev);
struct lpt_softc *sc;
int iobase;
u_char control;
int error;
int spin;
if (unit >= lptcd.cd_ndevs)
return ENXIO;
sc = lptcd.cd_devs[unit];
if (!sc)
return ENXIO;
#ifdef DIAGNOSTIC
if (sc->sc_state)
printf("%s: stat=0x%x not zero\n", sc->sc_dev.dv_xname,
sc->sc_state);
#endif
if (sc->sc_state)
return EBUSY;
sc->sc_state = LPT_INIT;
sc->sc_flags = flags;
lprintf("%s: open: flags=0x%x\n", sc->sc_dev.dv_xname, flags);
iobase = sc->sc_iobase;
if ((flags & LPT_NOPRIME) == 0) {
/* assert INIT for 100 usec to start up printer */
outb(iobase + lpt_control, LPC_SELECT);
delay(100);
}
control = LPC_SELECT | LPC_NINIT;
outb(iobase + lpt_control, control);
/* wait till ready (printer running diagnostics) */
for (spin = 0; NOT_READY_ERR(); spin += STEP) {
if (spin >= TIMEOUT) {
sc->sc_state = 0;
return EBUSY;
}
/* wait 1/4 second, give up if we get a signal */
if (error = tsleep((caddr_t)sc, LPTPRI | PCATCH, "lptopen",
STEP) != EWOULDBLOCK) {
sc->sc_state = 0;
return error;
}
}
control |= LPC_IENABLE;
if (flags & LPT_AUTOLF)
control |= LPC_AUTOLF;
sc->sc_control = control;
outb(iobase + lpt_control, control);
sc->sc_inbuf = geteblk(LPT_BSIZE);
sc->sc_count = 0;
sc->sc_state = LPT_OPEN;
lptwakeup(sc);
lprintf("%s: opened\n", sc->sc_dev.dv_xname);
return 0;
}
int
not_ready(status, sc)
u_char status;
struct lpt_softc *sc;
{
u_char new;
status = (status ^ LPS_INVERT) & LPS_MASK;
new = status & ~sc->sc_laststatus;
sc->sc_laststatus = status;
if (new & LPS_SELECT)
log(LOG_NOTICE, "%s: offline\n", sc->sc_dev.dv_xname);
else if (new & LPS_NOPAPER)
log(LOG_NOTICE, "%s: out of paper\n", sc->sc_dev.dv_xname);
else if (new & LPS_NERR)
log(LOG_NOTICE, "%s: output error\n", sc->sc_dev.dv_xname);
return status;
}
void
lptwakeup(arg)
void *arg;
{
struct lpt_softc *sc = arg;
int s;
s = spltty();
lptintr(sc);
splx(s);
timeout(lptwakeup, sc, STEP);
}
/*
* Close the device, and free the local line buffer.
*/
lptclose(dev, flag)
dev_t dev;
int flag;
{
int unit = LPTUNIT(dev);
struct lpt_softc *sc = lptcd.cd_devs[unit];
int iobase = sc->sc_iobase;
if (sc->sc_count)
(void) pushbytes(sc);
untimeout(lptwakeup, sc);
outb(iobase + lpt_control, LPC_NINIT);
sc->sc_state = 0;
outb(iobase + lpt_control, LPC_NINIT);
brelse(sc->sc_inbuf);
lprintf("%s: closed\n", sc->sc_dev.dv_xname);
return 0;
}
int
pushbytes(sc)
struct lpt_softc *sc;
{
int iobase = sc->sc_iobase;
int error;
int s;
while (sc->sc_count > 0) {
/* if the printer is ready for a char, give it one */
if ((sc->sc_state & LPT_OBUSY) == 0) {
lprintf("%s: write %d\n", sc->sc_dev.dv_xname,
sc->sc_count);
s = spltty();
(void) lptintr(sc);
splx(s);
}
if (error = tsleep((caddr_t)sc, LPTPRI | PCATCH,
"lptwrite2", 0))
return error;
}
return 0;
}
/*
* Copy a line from user space to a local buffer, then call putc to get the
* chars moved to the output queue.
*/
lptwrite(dev, uio)
dev_t dev;
struct uio *uio;
{
struct lpt_softc *sc = lptcd.cd_devs[LPTUNIT(dev)];
size_t n;
int error = 0;
while (n = min(LPT_BSIZE, uio->uio_resid)) {
uiomove(sc->sc_cp = sc->sc_inbuf->b_data, n, uio);
sc->sc_count = n;
error = pushbytes(sc);
if (error) {
/*
* Return accurate residual if interrupted or timed
* out.
*/
uio->uio_resid += sc->sc_count;
sc->sc_count = 0;
return error;
}
}
return 0;
}
/*
* Handle printer interrupts which occur when the printer is ready to accept
* another char.
*/
int
lptintr(arg)
void *arg;
{
struct lpt_softc *sc = arg;
int iobase = sc->sc_iobase;
#if 0
if ((sc->sc_state & LPT_OPEN) == 0)
return 0;
#endif
/* is printer online and ready for output */
if (NOT_READY() && NOT_READY_ERR())
return 0;
if (sc->sc_count) {
u_char control = sc->sc_control;
/* send char */
outb(iobase + lpt_data, *sc->sc_cp++);
outb(iobase + lpt_control, control | LPC_STROBE);
sc->sc_count--;
outb(iobase + lpt_control, control);
sc->sc_state |= LPT_OBUSY;
} else
sc->sc_state &= ~LPT_OBUSY;
if (sc->sc_count == 0) {
/* none, wake up the top half to get more */
wakeup((caddr_t)sc);
}
return 1;
}
int
lptioctl(dev, cmd, data, flag)
dev_t dev;
u_long cmd;
caddr_t data;
int flag;
{
int error = 0;
switch (cmd) {
default:
error = ENODEV;
}
return error;
}

2219
sys/arch/pica/dev/pccons.c Normal file

File diff suppressed because it is too large Load Diff

558
sys/arch/pica/dev/scsi.h Normal file
View File

@ -0,0 +1,558 @@
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: @(#)scsi.h 8.1 (Berkeley) 6/10/93
* $Id: scsi.h,v 1.1.1.1 1996/03/13 04:58:06 jonathan Exp $
*
* scsi.h --
*
* Common declarations for SCSI command formaters. This file only covers
* definitions pertaining to the SCSI common command set that are
* common to all SCSI device types (ie disk, tapes, WORM, printers, etc).
* Some of the references from the proceedings of the
* 1984 Mini/Micro Northeast conference might help in understanding SCSI.
*
* from: Header: /sprite/src/kernel/dev/RCS/scsi.h,
* v 9.1 90/02/13 23:11:24 jhh Exp SPRITE (Berkeley)
* $Id: scsi.h,v 1.1.1.1 1996/03/13 04:58:06 jonathan Exp $
*/
#ifndef _SCSI_H
#define _SCSI_H
/*
* "Standard" SCSI Commands.
* SCSI commands are divided into 8 groups as follows:
* Group0 (0x00 - 0x1f). Basic commands. 6 bytes long
* Group1 (0x20 - 0x3f). Extended command. 10 bytes.
* Group2 (0x40 - 0x5f). Reserved.
* Group2 (0x60 - 0x7f). Reserved.
* Group2 (0x80 - 0x9f). Reserved.
* Group2 (0xa0 - 0xbf). Reserved.
* Group6 (0xc0 - 0xdf). Vendor Unique
* Group7 (0xe0 - 0xff). Vendor Unique
*/
/*
* Scsi Group0 commands all are 6 bytes and have a format according to
* struct ScsiGroup0Cmd.
*/
#define SCSI_TEST_UNIT_READY 0x00
#define SCSI_REZERO_UNIT 0x01
#define SCSI_REWIND 0x01
#define SCSI_REQUEST_SENSE 0x03
#define SCSI_FORMAT_UNIT 0x04
#define SCSI_READ_BLOCK_LIMITS 0x05
#define SCSI_REASSIGN_BLOCKS 0x07
#define SCSI_READ 0x08
#define SCSI_WRITE 0x0a
#define SCSI_SEEK 0x0b
#define SCSI_TRACK_SELECT 0x0b
#define SCSI_READ_REVERSE 0x0f
#define SCSI_WRITE_EOF 0x10
#define SCSI_SPACE 0x11
#define SCSI_INQUIRY 0x12
#define SCSI_VERIFY 0x13
#define SCSI_READ_BUFFER 0x14
#define SCSI_MODE_SELECT 0x15
#define SCSI_RESERVE_UNIT 0x16
#define SCSI_RELEASE_UNIT 0x17
#define SCSI_COPY 0x18
#define SCSI_ERASE_TAPE 0x19
#define SCSI_MODE_SENSE 0x1a
#define SCSI_START_STOP 0x1b
#define SCSI_LOAD_UNLOAD 0x1b
#define SCSI_RECV_DIAG_RESULTS 0x1c
#define SCSI_SEND_DIAGNOSTIC 0x1d
#define SCSI_PREVENT_ALLOW 0x1e
/*
* Group1 commands are all 10 bytes and have a format according to
* struct ScsiGroup1Cmd.
*/
#define SCSI_READ_CAPACITY 0x25
#define SCSI_READ_EXT 0x28
#define SCSI_WRITE_EXT 0x2a
#define SCSI_SEEK_EXT 0x2b
#define SCSI_WRITE_VERIFY 0x2e
#define SCSI_VERIFY_EXT 0x2f
#define SCSI_SEARCH_HIGH 0x30
#define SCSI_SEARCH_EQUAL 0x31
#define SCSI_SEARCH_LOW 0x32
#define SCSI_SET_LIMITS 0x33
#define SCSI_COMPARE 0x39
#define SCSI_COPY_VERIFY 0x3a
/*
* Control byte flags for Group0 and Group1 commands.
*
* SCSI_CTRL_LINK - This is used to prevent a bus free phase between commands.
* If the command terminates successfully, a SCSI_LINKED_CMD_COMPLETE
* message is returned instead of the normal SCSI_COMMAND_COMPLETE message. * The last command in a chain should not have this bit set
* (and consequently gets a normal SCSI_COMMAND_COMPLETE message).
* SCSI_CTRL_LINK_FLAG - This bit should only set when SCSI_CTRL_LINK is set and
* causes a SCSI_LINKED_FLAGED_CMD_COMPLETE to be returned instead of
* a SCSI_LINKED_CMD_COMPLETE.
*/
#define SCSI_CTRL_LINK 0x01 /* Link commands (no bus free phase) */
#define SCSI_CTRL_LINK_INTR 0x02 /* Interrupt after linked command */
/*
* The standard group0 6-byte SCSI control block. Note that the
* fields between highAddr and blockCount inclusive are command dependent.
* The definitions Addr and BlockCount cover most of the commands we will
* use.
*/
typedef struct ScsiGroup0Cmd {
u_char command; /* command code, defined below. The
* upper three bits of this are zero
* to indicate the control block is
* only 6 bytes long */
#if BYTE_ORDER == BIG_ENDIAN
u_char unitNumber :3; /* Logical Unit (LUN) to which to
* pass the command. The device
* has already been selected using
* the "targetID" bit. */
u_char highAddr :5; /* High bits of address */
#else
u_char highAddr :5; /* High bits of address */
u_char unitNumber :3; /* Logical Unit (LUN) to which to
* pass the command. The device
* has already been selected using
* the "targetID" bit. */
#endif
u_char midAddr; /* Middle bits of address */
u_char lowAddr; /* Low bits of address */
u_char blockCount; /* Blocks to transfer */
u_char control; /* See flags for common bits */
} ScsiGroup0Cmd;
/*
* Format of a SCSI_START_STOP command. This is a group 0 command, but
* the command contents are different.
*/
typedef struct ScsiStartStopCmd {
#if BYTE_ORDER == BIG_ENDIAN
u_char command; /* command code, defined below. The
* upper three bits of this are zero
* to indicate the control block is
* only 6 bytes long */
u_char unitNumber :3; /* Logical Unit (LUN) to which to
* pass the command. The device
* has already been selected using
* the "targetID" bit. */
u_char pad1 :4; /* Reserved */
u_char immed :1; /* Immediate status bit */
u_char pad2; /* Reserved */
u_char pad3; /* Reserved */
u_char pad4 :6; /* Reserved */
u_char loadEject :1; /* Load or eject medium */
u_char start :1; /* Start or stop medium */
u_char control; /* See flags for common bits */
#else
u_char command; /* command code, defined below. The
* upper three bits of this are zero
* to indicate the control block is
* only 6 bytes long */
u_char immed :1; /* Immediate status bit */
u_char pad1 :4; /* Reserved */
u_char unitNumber :3; /* Logical Unit (LUN) to which to
* pass the command. The device
* has already been selected using
* the "targetID" bit. */
u_char pad2; /* Reserved */
u_char pad3; /* Reserved */
u_char start :1; /* Start or stop medium */
u_char loadEject :1; /* Load or eject medium */
u_char pad4 :6; /* Reserved */
u_char control; /* See flags for common bits */
#endif
} ScsiStartStopCmd;
/*
* The standard group1 10-byte SCSI control block. Note that the
* fields between highAddr and blockCount inclusive are command dependent.
* The definitions Addr and BlockCount cover most of the commands we will
* use.
*/
typedef struct ScsiGroup1Cmd {
u_char command; /* command code, defined below. The
* upper three bits of this are zero
* to indicate the control block is
* only 6 bytes long */
#if BYTE_ORDER == BIG_ENDIAN
u_char unitNumber :3; /* Logical Unit (LUN) to which to
* pass the command. The device
* has already been selected using
* the "targetID" bit. */
u_char pad1 :5; /* Reserved */
#else
u_char pad1 :5; /* Reserved */
u_char unitNumber :3; /* Logical Unit (LUN) to which to
* pass the command. The device
* has already been selected using
* the "targetID" bit. */
#endif
u_char highAddr; /* High bits of address */
u_char midHighAddr; /* Middle high bits of address */
u_char midLowAddr; /* Middle low bits of address */
u_char lowAddr; /* Low bits of address */
u_char pad2; /* Reserved */
u_char highBlockCount; /* High bits of blocks to transfer */
u_char lowBlockCount; /* Low bits of blocks to transfer */
u_char control; /* See flags for common bits */
} ScsiGroup1Cmd;
/*
* SCSI status completion information.
* This is returned by the device when a command completes.
*/
#define SCSI_STATUS_CHECKCOND 0x02 /* Check Condition (ie., read sense) */
#define SCSI_STATUS_CONDMET 0x04 /* Condition Met (ie., search worked) */
#define SCSI_STATUS_BUSY 0x08
#define SCSI_STATUS_INTERMED 0x10 /* Intermediate status sent */
#define SCSI_STATUS_EXT 0x80 /* Extended status valid */
/*
* Sense information provided after some errors. This is divided into
* two kinds, classes 0-6, and class 7. This is 30 bytes big to allow
* for the drive specific sense bytes that follow the standard 4 byte header.
*
* For extended sense, this buffer may be cast into another type. Also
* The actual size of the sense data returned is used to detect what
* kind of tape drive is out there. Kludgy, but true.
*/
typedef struct ScsiClass0Sense {
#if BYTE_ORDER == BIG_ENDIAN
u_char valid :1; /* Sense data is valid */
u_char error :7; /* 3 bits class and 4 bits code */
#else
u_char error :7; /* 3 bits class and 4 bits code */
u_char valid :1; /* Sense data is valid */
#endif
u_char highAddr; /* High byte of block address */
u_char midAddr; /* Middle byte of block address */
u_char lowAddr; /* Low byte of block address */
u_char sense[26]; /* Target specific sense data */
} ScsiClass0Sense;
/*
* Definitions for errors in the sense data. The error field is specified
* as a 3 bit class and 4 bit code, but it is easier to treat it as a
* single 7 bit field.
*/
#define SCSI_NO_SENSE_DATA 0x00
#define SCSI_NOT_READY 0x04
#define SCSI_NOT_LOADED 0x09
#define SCSI_INSUF_CAPACITY 0x0a
#define SCSI_HARD_DATA_ERROR 0x11
#define SCSI_WRITE_PROTECT 0x17
#define SCSI_CORRECTABLE_ERROR 0x18
#define SCSI_FILE_MARK 0x1c
#define SCSI_INVALID_COMMAND 0x20
#define SCSI_UNIT_ATTENTION 0x30
#define SCSI_END_OF_MEDIA 0x34
/*
* The standard "extended" sense data returned by SCSI devices. This
* has an error field of 0x70, for a "class 7" error.
*/
typedef struct ScsiClass7Sense {
#if BYTE_ORDER == BIG_ENDIAN
u_char valid :1; /* Sense data is valid */
u_char error7 :7; /* == 0x70 */
u_char pad1; /* Also "segment number" for copy */
u_char fileMark :1; /* File mark on device */
u_char endOfMedia :1; /* End of media reached */
u_char badBlockLen :1; /* Block length mis-match (Exabyte) */
u_char pad2 :1;
u_char key :4; /* Sense keys defined below */
u_char info1; /* Information byte 1 */
u_char info2; /* Information byte 2 */
u_char info3; /* Information byte 3 */
u_char info4; /* Information byte 4 */
u_char length; /* Number of additional info bytes */
#else
u_char error7 :7; /* == 0x70 */
u_char valid :1; /* Sense data is valid */
u_char pad1; /* Also "segment number" for copy */
u_char key :4; /* Sense keys defined below */
u_char pad2 :1;
u_char badBlockLen :1; /* Block length mis-match (Exabyte) */
u_char endOfMedia :1; /* End of media reached */
u_char fileMark :1; /* File mark on device */
u_char info1; /* Information byte 1 */
u_char info2; /* Information byte 2 */
u_char info3; /* Information byte 3 */
u_char info4; /* Information byte 4 */
u_char length; /* Number of additional info bytes */
#endif
} ScsiClass7Sense; /* 8 Bytes */
/*
* Key values for standardized sense class 7.
*/
#define SCSI_CLASS7_NO_SENSE 0
#define SCSI_CLASS7_RECOVERABLE 1
#define SCSI_CLASS7_NOT_READY 2
#define SCSI_CLASS7_MEDIA_ERROR 3
#define SCSI_CLASS7_HARDWARE_ERROR 4
#define SCSI_CLASS7_ILLEGAL_REQUEST 5
/*
* These seem to have different meanings to different vendors....
*/
#define SCSI_CLASS7_MEDIA_CHANGE 6
#define SCSI_CLASS7_UNIT_ATTN 6
#define SCSI_CLASS7_WRITE_PROTECT 7
#define SCSI_CLASS7_BLANK_CHECK 8
#define SCSI_CLASS7_VENDOR 9
#define SCSI_CLASS7_POWER_UP_FAILURE 10
#define SCSI_CLASS7_ABORT 11
#define SCSI_CLASS7_EQUAL 12
#define SCSI_CLASS7_OVERFLOW 13
#define SCSI_CLASS7_RESERVED_14 14
#define SCSI_CLASS7_RESERVED_15 15
/*
* Data return by the SCSI inquiry command.
*/
typedef struct ScsiInquiryData {
#if BYTE_ORDER == BIG_ENDIAN
u_char type; /* Peripheral Device type. See below. */
u_char rmb:1; /* Removable Medium bit. */
u_char qualifier:7; /* Device type qualifier. */
u_char version; /* Version info. */
u_char reserved:4; /* reserved. */
u_char format:4; /* Response format. */
u_char length; /* length of data returned. */
u_char reserved2[2]; /* Reserved */
u_char flags; /* SCSI II flags (see below) */
u_char vendorID[8]; /* Vendor ID (ASCII) */
u_char productID[16]; /* Product ID (ASCII) */
u_char revLevel[4]; /* Revision level (ASCII) */
u_char revData[8]; /* Revision data (ASCII) */
#else
u_char type; /* Peripheral Device type. See below. */
u_char qualifier:7; /* Device type qualifier. */
u_char rmb:1; /* Removable Medium bit. */
u_char version; /* Version info. */
u_char format:4; /* Response format. */
u_char reserved:4; /* reserved. */
u_char length; /* length of data returned. */
u_char reserved2[2]; /* Reserved */
u_char flags; /* SCSI II flags (see below) */
u_char vendorID[8]; /* Vendor ID (ASCII) */
u_char productID[16]; /* Product ID (ASCII) */
u_char revLevel[4]; /* Revision level (ASCII) */
u_char revData[8]; /* Revision data (ASCII) */
#endif
} ScsiInquiryData;
/*
* The SCSI Peripheral type ID codes as return by the SCSI_INQUIRY command.
*
* SCSI_DISK_TYPE - Direct Access Device.
* SCSI_TAPE_TYPE - Sequential Access Device.
* SCSI_PRINTER_TYPE - Printer Device.
* SCSI_HOST_TYPE - Processor Device.
* SCSI_WORM_TYPE - Write-Once Read-Multiple Device.
* SCSI_ROM_TYPE - Read-Only Direct Access Device.
* SCSI_SCANNER_TYPE - Scanner device.
* SCSI_OPTICAL_MEM_TYPE - Optical memory device.
* SCSI_MEDIUM_CHANGER_TYPE - Medium changer device.
* SCSI_COMMUNICATIONS_TYPE - Communications device.
* SCSI_NODEVICE_TYPE - Logical Unit not present or implemented.
*
* Note that codes 0xa-0x7e are reserved and 0x80-0xff are vendor unique.
*/
#define SCSI_DISK_TYPE 0
#define SCSI_TAPE_TYPE 1
#define SCSI_PRINTER_TYPE 2
#define SCSI_HOST_TYPE 3
#define SCSI_WORM_TYPE 4
#define SCSI_ROM_TYPE 5
#define SCSI_SCANNER_TYPE 6
#define SCSI_OPTICAL_MEM_TYPE 7
#define SCSI_MEDIUM_CHANGER_TYPE 8
#define SCSI_COMMUNICATIONS_TYPE 9
#define SCSI_NODEVICE_TYPE 0x7f
/*
* The SCSI I & II inquiry flags.
*
* SCSI_REL_ADR - Relative addressing supported.
* SCSI_WIDE_32 - 32 bit wide SCSI bus transfers supported.
* SCSI_WIDE_16 - 16 bit wide SCSI bus transfers supported.
* SCSI_SYNC - Synchronous data transfers supported.
* SCSI_LINKED - Linked commands supported.
* SCSI_CMD_QUEUE - Tagged command queuing supported.
* SCSI_SOFT_RESET - Soft RESET alternative suported.
*/
#define SCSI_REL_ADR 0x80
#define SCSI_WIDE_32 0x40
#define SCSI_WIDE_16 0x20
#define SCSI_SYNC 0x10
#define SCSI_LINKED 0x08
#define SCSI_CMD_QUEUE 0x02
#define SCSI_SOFT_RESET 0x01
/*
* Standard header for SCSI_MODE_SENSE and SCSI_MODE_SELECT commands for tapes.
*/
typedef struct ScsiTapeModeSelectHdr {
u_char len; /* length */
u_char media; /* media type */
#if BYTE_ORDER == BIG_ENDIAN
u_char writeprot:1; /* Write protected media */
u_char bufferedMode:3; /* Type of buffer to be done. */
u_char speed:4; /* Drive speed. */
#else
u_char speed:4; /* Drive speed. */
u_char bufferedMode:3; /* Type of buffer to be done. */
u_char writeprot:1; /* Write protected media */
#endif
u_char length; /* Block descriptor length. */
u_char density; /* tape density code */
u_char blocks_2; /* number of blocks (MSB) */
u_char blocks_1; /* number of blocks */
u_char blocks_0; /* number of blocks (LSB) */
u_char reserved; /* */
u_char block_size2; /* Tape block size (MSB) */
u_char block_size1; /* Tape block size */
u_char block_size0; /* Tape block size (LSB) */
u_char vendor[6]; /* vendor specific data */
} ScsiTapeModeSelectHdr;
/*
* Definitions of SCSI messages.
*
* SCSI_COMMAND_COMPLETE - After a command has completed, successfully
* or not, this is returned to the host from the target.
*
* SCSI_EXTENDED_MSG - Indicates that a multi-byte message is being sent.
*
* The following messages are used with connect/disconnect:
* SCSI_SAVE_DATA_POINTER - Sent from target to host to request saving
* of current DMA address and count. Indicates a pending dis-connect.
* SCSI_RESTORE_POINTER - Sent from the target to the host to request
* restoring pointers saved before a disconnect
* SCSI_DISCONNECT - Sent from the target to the host to disconnect.
* SCSI_ABORT - Sent from the host to the target to abort current request.
* SCSI_MESSAGE_REJECT - Indicates receipt, by either host or target, of
* an unimplemented message.
* SCSI_NO_OP - Sent from host to target if it has no real message to send.
* SCSI_MESSAGE_PARITY_ERROR - Sent from host to target on message parity error
* SCSI_BUS_RESET - Sent from host to target to reset all current I/O
*
* SCSI_IDENTIFY - The low order two bits of this message type indicate
* the Logical Unit of the Target which is requesting a reconnect.
* SCSI_DIS_REC_IDENTIFY - Sent from the host to a target to indicate
* is supports connect/dis-connect
*
*/
#define SCSI_COMMAND_COMPLETE 0x00
#define SCSI_EXTENDED_MSG 0x01
#define SCSI_SAVE_DATA_POINTER 0x02
#define SCSI_RESTORE_POINTERS 0x03
#define SCSI_DISCONNECT 0x04
#define SCSI_ABORT 0x06
#define SCSI_MESSAGE_REJECT 0x07
#define SCSI_NO_OP 0x08
#define SCSI_MESSAGE_PARITY_ERROR 0x09
#define SCSI_LINKED_CMD_COMPLETE 0x0A
#define SCSI_LINKED_FLAGED_CMD_COMPLETE 0x0B
#define SCSI_BUS_RESET 0x0C
#define SCSI_IDENTIFY 0x80
#define SCSI_DIS_REC_IDENTIFY 0xc0
/*
* Extended message types (2nd byte of SCSI_EXTENDED_MSG).
*/
#define SCSI_MODIFY_DATA_PTR 0x00
#define SCSI_SYNCHRONOUS_XFER 0x01
#define SCSI_EXTENDED_IDENTIFY 0x02 /* only in SCSI I */
#define SCSI_WIDE_XFER 0x03
/*
* Driver ioctl's for various scsi operations.
*/
#ifndef _IOCTL_
#include <sys/ioctl.h>
#endif
/*
* Control for SCSI "format" mode.
*
* "Format" mode allows a privileged process to issue direct SCSI
* commands to a drive (it is intended primarily to allow on-line
* formatting). SDIOCSFORMAT with a non-zero arg will put the drive
* into format mode; a zero arg will take it out. When in format
* mode, only the process that issued the SDIOCFORMAT can read or
* write the drive.
*
* In format mode, process is expected to
* - do SDIOCSCSICOMMAND to supply cdb for next SCSI op
* - do read or write as appropriate for cdb
* - if i/o error, optionally do SDIOCSENSE to get completion
* status and sense data from last scsi operation.
*/
struct scsi_fmt_cdb {
int len; /* cdb length (in bytes) */
u_char cdb[28]; /* cdb to use on next read/write */
};
struct scsi_fmt_sense {
u_int status; /* completion status of last op */
u_char sense[32]; /* sense data (if any) from last op */
};
#define SDIOCSFORMAT _IOW('S', 0x1, int)
#define SDIOCGFORMAT _IOR('S', 0x2, int)
#define SDIOCSCSICOMMAND _IOW('S', 0x3, struct scsi_fmt_cdb)
#define SDIOCSENSE _IOR('S', 0x4, struct scsi_fmt_sense)
#ifdef _KERNEL
/*
* Routines.
*/
extern void scsiGroup0Cmd();
extern void scsiGroup1Cmd();
#endif /* _KERNEL */
#endif /* _SCSI_H */

View File

@ -0,0 +1,74 @@
/* $NetBSD: ansi.h,v 1.1.1.1 1996/03/13 04:58:07 jonathan Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* @(#)ansi.h 8.2 (Berkeley) 1/4/94
*/
#ifndef _ANSI_H_
#define _ANSI_H_
/*
* Types which are fundamental to the implementation and may appear in
* more than one standard header are defined here. Standard headers
* then use:
* #ifdef _BSD_SIZE_T_
* typedef _BSD_SIZE_T_ size_t;
* #undef _BSD_SIZE_T_
* #endif
*/
#define _BSD_CLOCK_T_ unsigned long /* clock() */
#define _BSD_PTRDIFF_T_ int /* ptr1 - ptr2 */
#define _BSD_SIZE_T_ unsigned int /* sizeof() */
#define _BSD_SSIZE_T_ int /* byte count or error */
#define _BSD_TIME_T_ long /* time() */
#define _BSD_VA_LIST_ char * /* va_list */
/*
* Runes (wchar_t) is declared to be an ``int'' instead of the more natural
* ``unsigned long'' or ``long''. Two things are happening here. It is not
* unsigned so that EOF (-1) can be naturally assigned to it and used. Also,
* it looks like 10646 will be a 31 bit standard. This means that if your
* ints cannot hold 32 bits, you will be in trouble. The reason an int was
* chosen over a long is that the is*() and to*() routines take ints (says
* ANSI C), but they use _RUNE_T_ instead of int. By changing it here, you
* lose a bit of ANSI conformance, but your programs will still work.
*
* Note that _WCHAR_T_ and _RUNE_T_ must be of the same type. When wchar_t
* and rune_t are typedef'd, _WCHAR_T_ will be undef'd, but _RUNE_T remains
* defined for ctype.h.
*/
#define _BSD_WCHAR_T_ int /* wchar_t */
#define _BSD_RUNE_T_ int /* rune_t */
#endif /* _ANSI_H_ */

View File

@ -0,0 +1,40 @@
/* $NetBSD: aout_machdep.h,v 1.1.1.1 1996/03/13 04:58:07 jonathan Exp $ */
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* @(#)exec.h 8.1 (Berkeley) 6/10/93
*/
#define __LDPGSZ 4096
#include <machine/reloc.h>

167
sys/arch/pica/include/asm.h Normal file
View File

@ -0,0 +1,167 @@
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: @(#)machAsmDefs.h 8.1 (Berkeley) 6/10/93
* $Id: asm.h,v 1.1.1.1 1996/03/13 04:58:09 jonathan Exp $
*/
/*
* machAsmDefs.h --
*
* Macros used when writing assembler programs.
*
* Copyright (C) 1989 Digital Equipment Corporation.
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
* provided that the above copyright notice appears in all copies.
* Digital Equipment Corporation makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* from: Header: /sprite/src/kernel/mach/ds3100.md/RCS/machAsmDefs.h,
* v 1.2 89/08/15 18:28:24 rab Exp SPRITE (DECWRL)
* $Id: asm.h,v 1.1.1.1 1996/03/13 04:58:09 jonathan Exp $
*/
#ifndef _MACHASMDEFS
#define _MACHASMDEFS
#include <machine/regdef.h>
#define _C_LABEL(x) x
/*
* Define -pg profile entry code.
*/
#if defined(GPROF) || defined(PROF)
#define MCOUNT .set noreorder; \
.set noat; \
move $1,$31; \
jal _mcount; \
subu sp,sp,8; \
.set reorder; \
.set at;
#else
#define MCOUNT
#endif
/*
* LEAF(x)
*
* Declare a leaf routine.
*/
#define LEAF(x) \
.globl x; \
.ent x, 0; \
x: ; \
.frame sp, 0, ra; \
MCOUNT
/*
* NLEAF(x)
*
* Declare a non-profiled leaf routine.
*/
#define NLEAF(x) \
.globl x; \
.ent x, 0; \
x: ; \
.frame sp, 0, ra
/*
* ALEAF -- declare alternate entry to a leaf routine.
*/
#define ALEAF(x) \
.globl x; \
x:
/*
* NON_LEAF(x)
*
* Declare a non-leaf routine (a routine that makes other C calls).
*/
#define NON_LEAF(x, fsize, retpc) \
.globl x; \
.ent x, 0; \
x: ; \
.frame sp, fsize, retpc; \
MCOUNT
/*
* NNON_LEAF(x)
*
* Declare a non-profiled non-leaf routine
* (a routine that makes other C calls).
*/
#define NNON_LEAF(x, fsize, retpc) \
.globl x; \
.ent x, 0; \
x: ; \
.frame sp, fsize, retpc
/*
* END(x)
*
* Mark end of a procedure.
*/
#define END(x) \
.end x
#define STAND_FRAME_SIZE 24
#define STAND_RA_OFFSET 20
/*
* Macros to panic and printf from assembly language.
*/
#define PANIC(msg) \
la a0, 9f; \
jal panic; \
MSG(msg)
#define PRINTF(msg) \
la a0, 9f; \
jal printf; \
MSG(msg)
#define MSG(msg) \
.rdata; \
9: .asciiz msg; \
.text
#define ASMSTR(str) \
.asciiz str; \
.align 3
#endif /* _MACHASMDEFS */

View File

@ -0,0 +1,74 @@
/* $NetBSD: autoconf.h,v 1.1.1.1 1996/03/13 04:58:07 jonathan Exp $ */
/*
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
/*
* Machine-dependent structures of autoconfiguration
*/
struct confargs;
typedef int (*intr_handler_t) __P((void *));
struct abus {
struct device *ab_dv; /* back-pointer to device */
int ab_type; /* bus type (see below) */
void (*ab_intr_establish) /* bus's set-handler function */
__P((struct confargs *, intr_handler_t, void *));
void (*ab_intr_disestablish) /* bus's unset-handler function */
__P((struct confargs *));
caddr_t (*ab_cvtaddr) /* convert slot/offset to address */
__P((struct confargs *));
int (*ab_matchname) /* see if name matches driver */
__P((struct confargs *, char *));
};
#define BUS_MAIN 1 /* mainbus */
#define BUS_PICA 2 /* PICA Bus */
#define BUS_ASIC 3 /* IOCTL ASIC; under TurboChannel */
#define BUS_TCDS 4 /* TCDS ASIC; under TurboChannel */
#define BUS_INTR_ESTABLISH(ca, handler, val) \
(*(ca)->ca_bus->ab_intr_establish)((ca), (handler), (val))
#define BUS_INTR_DISESTABLISH(ca) \
(*(ca)->ca_bus->ab_intr_establish)(ca)
#define BUS_CVTADDR(ca) \
(*(ca)->ca_bus->ab_cvtaddr)(ca)
#define BUS_MATCHNAME(ca, name) \
(*(ca)->ca_bus->ab_matchname)((ca), (name))
struct confargs {
char *ca_name; /* Device name. */
int ca_slot; /* Device slot. */
int ca_offset; /* Offset into slot. */
struct abus *ca_bus; /* bus device resides on. */
};
void set_clockintr __P((void (*)(struct clockframe *)));
void set_iointr __P((void (*)(void *, int)));
int badaddr __P((void *, u_int64_t));

View File

@ -0,0 +1,33 @@
/* bsd-aout.h
4.4bsd a.out format, for backwards compatibility... */
#ifndef __MACHINE_BSD_AOUT_H__
#define __MACHINE_BSD_AOUT_H__
#define BSD_OMAGIC 0407 /* old impure format */
#define BSD_NMAGIC 0410 /* read-only text */
#define BSD_ZMAGIC 0413 /* demand load format */
struct bsd_aouthdr {
#if BYTE_ORDER == BIG_ENDIAN
u_short a_mid; /* machine ID */
u_short a_magic; /* magic number */
#else
u_short a_magic; /* magic number */
u_short a_mid; /* machine ID */
#endif
u_long a_text; /* text segment size */
u_long a_data; /* initialized data size */
u_long a_bss; /* uninitialized data size */
u_long a_syms; /* symbol table size */
u_long a_entry; /* entry point */
u_long a_trsize; /* text relocation size */
u_long a_drsize; /* data relocation size */
};
#ifndef _KERNEL
#define _AOUT_INCLUDE_
#include <nlist.h>
#endif /* _KERNEL */
#endif /* __MACHINE_BSD_AOUT_H__ */

View File

@ -0,0 +1,38 @@
/* $NetBSD: cdefs.h,v 1.1.1.1 1996/03/13 04:58:07 jonathan Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#ifndef _MACHINE_CDEFS_H_
#define _MACHINE_CDEFS_H_
#define _C_LABEL(x) _STRING(x)
#define __indr_references(sym,msg) /* nothing */
#define __warn_references(sym,msg) /* nothing */
#endif /* !_MACHINE_CDEFS_H_ */

184
sys/arch/pica/include/cpu.h Normal file
View File

@ -0,0 +1,184 @@
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell and Rick Macklem.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: @(#)cpu.h 8.4 (Berkeley) 1/4/94
* $Id: cpu.h,v 1.1.1.1 1996/03/13 04:58:07 jonathan Exp $
*/
#ifndef _CPU_H_
#define _CPU_H_
#include <machine/machConst.h>
/*
* Exported definitions unique to pica/mips cpu support.
*/
/*
* definitions of cpu-dependent requirements
* referenced in generic code
*/
#define COPY_SIGCODE /* copy sigcode above user stack in exec */
#define cpu_wait(p) /* nothing */
#define cpu_set_init_frame(p, fp) /* nothing */
#define cpu_swapout(p) panic("cpu_swapout: can't get here");
/*
* Arguments to hardclock and gatherstats encapsulate the previous
* machine state in an opaque clockframe.
*/
struct clockframe {
int pc; /* program counter at time of interrupt */
int sr; /* status register at time of interrupt */
};
#define CLKF_USERMODE(framep) ((framep)->sr & MACH_SR_KSU_USER)
#define CLKF_BASEPRI(framep) \
((~(framep)->sr & (MACH_INT_MASK | MACH_SR_INT_ENAB)) == 0)
#define CLKF_PC(framep) ((framep)->pc)
#define CLKF_INTR(framep) (0)
/*
* Preempt the current process if in interrupt from user mode,
* or after the current trap/syscall if in system mode.
*/
#define need_resched() { want_resched = 1; aston(); }
/*
* Give a profiling tick to the current process when the user profiling
* buffer pages are invalid. On the PICA, request an ast to send us
* through trap, marking the proc as needing a profiling tick.
*/
#define need_proftick(p) { (p)->p_flag |= P_OWEUPC; aston(); }
/*
* Notify the current process (p) that it has a signal pending,
* process as soon as possible.
*/
#define signotify(p) aston()
#define aston() (astpending = 1)
int astpending; /* need to trap before returning to user mode */
int want_resched; /* resched() was called */
/*
* CPU identification, from PRID register.
*/
union cpuprid {
int cpuprid;
struct {
#if BYTE_ORDER == BIG_ENDIAN
u_int pad1:16; /* reserved */
u_int cp_imp:8; /* implementation identifier */
u_int cp_majrev:4; /* major revision identifier */
u_int cp_minrev:4; /* minor revision identifier */
#else
u_int cp_minrev:4; /* minor revision identifier */
u_int cp_majrev:4; /* major revision identifier */
u_int cp_imp:8; /* implementation identifier */
u_int pad1:16; /* reserved */
#endif
} cpu;
};
/*
* CTL_MACHDEP definitions.
*/
#define CPU_CONSDEV 1 /* dev_t: console terminal device */
#define CPU_MAXID 2 /* number of valid machdep ids */
#define CTL_MACHDEP_NAMES { \
{ 0, 0 }, \
{ "console_device", CTLTYPE_STRUCT }, \
}
/*
* MIPS CPU types (cp_imp).
*/
#define MIPS_R2000 0x01 /* MIPS R2000 CPU ISA I */
#define MIPS_R3000 0x02 /* MIPS R3000 CPU ISA I */
#define MIPS_R6000 0x03 /* MIPS R6000 CPU ISA II */
#define MIPS_R4000 0x04 /* MIPS R4000/4400 CPU ISA III */
#define MIPS_R3LSI 0x05 /* LSI Logic R3000 derivate ISA I */
#define MIPS_R6000A 0x06 /* MIPS R6000A CPU ISA II */
#define MIPS_R3IDT 0x07 /* IDT R3000 derivate ISA I */
#define MIPS_R10000 0x09 /* MIPS R10000/T5 CPU ISA IV */
#define MIPS_R4200 0x0a /* MIPS R4200 CPU (ICE) ISA III */
#define MIPS_UNKC1 0x0b /* unnanounced product cpu ISA III */
#define MIPS_UNKC2 0x0c /* unnanounced product cpu ISA III */
#define MIPS_R8000 0x10 /* MIPS R8000 Blackbird/TFP ISA IV */
#define MIPS_R4600 0x20 /* QED R4600 Orion ISA III */
#define MIPS_R3SONY 0x21 /* Sony R3000 based CPU ISA I */
#define MIPS_R3TOSH 0x22 /* Toshiba R3000 based CPU ISA I */
#define MIPS_R3NKK 0x23 /* NKK R3000 based CPU ISA I */
/*
* MIPS FPU types
*/
#define MIPS_SOFT 0x00 /* Software emulation ISA I */
#define MIPS_R2360 0x01 /* MIPS R2360 FPC ISA I */
#define MIPS_R2010 0x02 /* MIPS R2010 FPC ISA I */
#define MIPS_R3010 0x03 /* MIPS R3010 FPC ISA I */
#define MIPS_R6010 0x04 /* MIPS R6010 FPC ISA II */
#define MIPS_R4010 0x05 /* MIPS R4000/R4400 FPC ISA II */
#define MIPS_R31LSI 0x06 /* LSI Logic derivate ISA I */
#define MIPS_R10010 0x09 /* MIPS R10000/T5 FPU ISA IV */
#define MIPS_R4210 0x0a /* MIPS R4200 FPC (ICE) ISA III */
#define MIPS_UNKF1 0x0b /* unnanounced product cpu ISA III */
#define MIPS_R8000 0x10 /* MIPS R8000 Blackbird/TFP ISA IV */
#define MIPS_R4600 0x20 /* QED R4600 Orion ISA III */
#define MIPS_R3SONY 0x21 /* Sony R3000 based FPU ISA I */
#define MIPS_R3TOSH 0x22 /* Toshiba R3000 based FPU ISA I */
#define MIPS_R3NKK 0x23 /* NKK R3000 based FPU ISA I */
#ifdef _KERNEL
union cpuprid cpu_id;
union cpuprid fpu_id;
u_int machPrimaryDataCacheSize;
u_int machPrimaryInstCacheSize;
u_int machPrimaryDataCacheLSize;
u_int machPrimaryInstCacheLSize;
u_int machCacheAliasMask;
extern struct intr_tab intr_tab[];
#endif
/*
* Enable realtime clock (always enabled).
*/
#define enablertclock()
#endif /* _CPU_H_ */

View File

@ -0,0 +1,80 @@
/* $NetBSD: disklabel.h,v 1.1.1.1 1996/03/13 04:58:07 jonathan Exp $ */
/*
* Copyright (c) 1994 Christopher G. Demetriou
* All rights reserved.
*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Christopher G. Demetriou.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
#ifndef _MACHINE_DISKLABEL_H_
#define _MACHINE_DISKLABEL_H_
#define LABELSECTOR 0 /* sector containing label */
#define LABELOFFSET 64 /* offset of label in sector */
#define MAXPARTITIONS 8 /* number of partitions */
#define RAW_PART 2 /* raw partition: xx?c */
/* DOS partition table -- used when the system is booted from a dos
* partition. This is the case on NT systems.
*/
#define DOSBBSECTOR 0 /* DOS boot block relative sector # */
#define DOSPARTOFF 446
#define NDOSPART 4
struct dos_partition {
unsigned char dp_flag; /* bootstrap flags */
unsigned char dp_shd; /* starting head */
unsigned char dp_ssect; /* starting sector */
unsigned char dp_scyl; /* starting cylinder */
unsigned char dp_typ; /* partition type (see below) */
unsigned char dp_ehd; /* end head */
unsigned char dp_esect; /* end sector */
unsigned char dp_ecyl; /* end cylinder */
unsigned long dp_start; /* absolute starting sector number */
unsigned long dp_size; /* partition size in sectors */
} dos_partitions[NDOSPART];
/* Known DOS partition types. */
#define DOSPTYP_386BSD 0xa5 /* 386BSD partition type */
#define DOSPTYP_NETBSD DOSPTYP_386BSD /* NetBSD partition type (XXX) */
#include <sys/dkbad.h>
struct cpu_disklabel {
struct dos_partition dosparts[NDOSPART];
struct dkbad bad;
};
/* Isolate the relevant bits to get sector and cylinder. */
#define DPSECT(s) ((s) & 0x3f)
#define DPCYL(c, s) ((c) + (((s) & 0xc0) << 2))
#ifdef _KERNEL
struct disklabel;
int bounds_check_with_label __P((struct buf *, struct disklabel *, int));
#endif
#endif /* _MACHINE_DISKLABEL_H_ */

View File

@ -0,0 +1,47 @@
/*
* IBM PC display definitions
*
* $Id: display.h,v 1.1.1.1 1996/03/13 04:58:07 jonathan Exp $
*/
/* Color attributes for foreground text */
#define FG_BLACK 0
#define FG_BLUE 1
#define FG_GREEN 2
#define FG_CYAN 3
#define FG_RED 4
#define FG_MAGENTA 5
#define FG_BROWN 6
#define FG_LIGHTGREY 7
#define FG_DARKGREY 8
#define FG_LIGHTBLUE 9
#define FG_LIGHTGREEN 10
#define FG_LIGHTCYAN 11
#define FG_LIGHTRED 12
#define FG_LIGHTMAGENTA 13
#define FG_YELLOW 14
#define FG_WHITE 15
#define FG_BLINK 0x80
#define FG_MASK 0x8f
/* Color attributes for text background */
#define BG_BLACK 0x00
#define BG_BLUE 0x10
#define BG_GREEN 0x20
#define BG_CYAN 0x30
#define BG_RED 0x40
#define BG_MAGENTA 0x50
#define BG_BROWN 0x60
#define BG_LIGHTGREY 0x70
#define BG_MASK 0x70
/* Monochrome attributes for foreground text */
#define FG_UNDERLINE 0x01
#define FG_INTENSE 0x08
/* Monochrome attributes for text background */
#define BG_INTENSE 0x10

View File

@ -0,0 +1,46 @@
/* $NetBSD: ecoff.h,v 1.1.1.1 1996/03/13 04:58:07 jonathan Exp $ */
/*
* Copyright (c) 1994 Adam Glass
* All rights reserved.
*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Adam Glass.
* 4. The name of the Author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Adam Glass ``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 Adam Glass 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.
*/
#define ECOFF_LDPGSZ 4096
#define ECOFF_PAD
#define ECOFF_MACHDEP \
u_long ea_gprmask; \
u_long ea_cprmask[4]; \
u_long ea_gp_value
#define ECOFF_MAGIC_MIPSEL 0x0162
#define ECOFF_BADMAG(ex) ((ex)->ef_magic != ECOFF_MAGIC_MIPSEL)
#define ECOFF_SEGMENT_ALIGNMENT(eap) ((eap)->ea_vstamp < 23 ? 8 : 16)

View File

@ -0,0 +1,46 @@
/* $NetBSD: ecoff_machdep.h,v 1.1.1.1 1996/03/13 04:58:07 jonathan Exp $ */
/*
* Copyright (c) 1994 Adam Glass
* All rights reserved.
*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Adam Glass.
* 4. The name of the Author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Adam Glass ``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 Adam Glass 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.
*/
#define ECOFF_LDPGSZ 4096
#define ECOFF_PAD
#define ECOFF_MACHDEP \
u_long ea_gprmask; \
u_long ea_cprmask[4]; \
u_long ea_gp_value
#define ECOFF_MAGIC_MIPSEL 0x0162
#define ECOFF_BADMAG(ex) ((ex)->ef_magic != ECOFF_MAGIC_MIPSEL)
#define ECOFF_SEGMENT_ALIGNMENT(eap) ((eap)->ea_vstamp < 23 ? 8 : 16)

137
sys/arch/pica/include/elf.h Normal file
View File

@ -0,0 +1,137 @@
/* $NetBSD: elf.h,v 1.1.1.1 1996/03/13 04:58:07 jonathan Exp $ */
/*
* Copyright (c) 1994 Ted Lemon
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
*/
#ifndef __MACHINE_ELF_H__
#define __MACHINE_ELF_H__
/* ELF executable header... */
struct ehdr {
char elf_magic [4]; /* Elf magic number... */
unsigned long magic [3]; /* Magic number... */
unsigned short type; /* Object file type... */
unsigned short machine; /* Machine ID... */
unsigned long version; /* File format version... */
unsigned long entry; /* Entry point... */
unsigned long phoff; /* Program header table offset... */
unsigned long shoff; /* Section header table offset... */
unsigned long flags; /* Processor-specific flags... */
unsigned short ehsize; /* Elf header size in bytes... */
unsigned short phsize; /* Program header size... */
unsigned short phcount; /* Program header count... */
unsigned short shsize; /* Section header size... */
unsigned short shcount; /* Section header count... */
unsigned short shstrndx; /* Section header string table index... */
};
/* Program header... */
struct phdr {
unsigned long type; /* Segment type... */
unsigned long offset; /* File offset... */
unsigned long vaddr; /* Virtual address... */
unsigned long paddr; /* Physical address... */
unsigned long filesz; /* Size of segment in file... */
unsigned long memsz; /* Size of segment in memory... */
unsigned long flags; /* Segment flags... */
unsigned long align; /* Alighment, file and memory... */
};
/* Section header... */
struct shdr {
unsigned long name; /* Offset into string table of section name */
unsigned long type; /* Type of section... */
unsigned long flags; /* Section flags... */
unsigned long addr; /* Section virtual address at execution... */
unsigned long offset; /* Section file offset... */
unsigned long size; /* Section size... */
unsigned long link; /* Link to another section... */
unsigned long info; /* Additional section info... */
unsigned long align; /* Section alignment... */
unsigned long esize; /* Entry size if section holds table... */
};
/* Symbol table entry... */
struct sym {
unsigned long name; /* Index into strtab of symbol name. */
unsigned long value; /* Section offset, virt addr or common align. */
unsigned long size; /* Size of object referenced. */
unsigned type : 4; /* Symbol type (e.g., function, data)... */
unsigned binding : 4; /* Symbol binding (e.g., global, local)... */
unsigned char other; /* Unused. */
unsigned short shndx; /* Section containing symbol. */
};
/* Values for program header type field */
#define PT_NULL 0 /* Program header table entry unused */
#define PT_LOAD 1 /* Loadable program segment */
#define PT_DYNAMIC 2 /* Dynamic linking information */
#define PT_INTERP 3 /* Program interpreter */
#define PT_NOTE 4 /* Auxiliary information */
#define PT_SHLIB 5 /* Reserved, unspecified semantics */
#define PT_PHDR 6 /* Entry for header table itself */
#define PT_LOPROC 0x70000000 /* Processor-specific */
#define PT_HIPROC 0x7FFFFFFF /* Processor-specific */
#define PT_MIPS_REGINFO PT_LOPROC /* Mips reginfo section... */
/* Program segment permissions, in program header flags field */
#define PF_X (1 << 0) /* Segment is executable */
#define PF_W (1 << 1) /* Segment is writable */
#define PF_R (1 << 2) /* Segment is readable */
#define PF_MASKPROC 0xF0000000 /* Processor-specific reserved bits */
/* Reserved section indices... */
#define SHN_UNDEF 0
#define SHN_ABS 0xfff1
#define SHN_COMMON 0xfff2
#define SHN_MIPS_ACOMMON 0xfff0
/* Symbol bindings... */
#define STB_LOCAL 0
#define STB_GLOBAL 1
#define STB_WEAK 2
/* Symbol types... */
#define STT_NOTYPE 0
#define STT_OBJECT 1
#define STT_FUNC 2
#define STT_SECTION 3
#define STT_FILE 4
#define ELF_HDR_SIZE (sizeof (struct ehdr))
#ifdef _KERNEL
int pmax_elf_makecmds __P((struct proc *, struct exec_package *));
#endif /* _KERNEL */
#endif /* __MACHINE_ELF_H__ */

View File

@ -0,0 +1,94 @@
/* $NetBSD: endian.h,v 1.1.1.1 1996/03/13 04:58:07 jonathan Exp $ */
/*
* Copyright (c) 1987, 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* @(#)endian.h 8.1 (Berkeley) 6/11/93
*/
#ifndef _ENDIAN_H_
#define _ENDIAN_H_
/*
* Define _NOQUAD if the compiler does NOT support 64-bit integers.
*/
/* #define _NOQUAD */
/*
* Define the order of 32-bit words in 64-bit words.
*/
#define _QUAD_HIGHWORD 1
#define _QUAD_LOWWORD 0
#ifndef _POSIX_SOURCE
/*
* Definitions for byte order, according to byte significance from low
* address to high.
*/
#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */
#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */
#define BYTE_ORDER LITTLE_ENDIAN
#include <sys/cdefs.h>
__BEGIN_DECLS
unsigned long htonl __P((unsigned long));
unsigned short htons __P((unsigned short));
unsigned long ntohl __P((unsigned long));
unsigned short ntohs __P((unsigned short));
__END_DECLS
/*
* Macros for network/external number representation conversion.
*/
#if BYTE_ORDER == BIG_ENDIAN && !defined(lint)
#define ntohl(x) (x)
#define ntohs(x) (x)
#define htonl(x) (x)
#define htons(x) (x)
#define NTOHL(x) (x)
#define NTOHS(x) (x)
#define HTONL(x) (x)
#define HTONS(x) (x)
#else
#define NTOHL(x) (x) = ntohl((u_long)x)
#define NTOHS(x) (x) = ntohs((u_short)x)
#define HTONL(x) (x) = htonl((u_long)x)
#define HTONS(x) (x) = htons((u_short)x)
#endif
#endif /* ! _POSIX_SOURCE */
#endif /* !_ENDIAN_H_ */

View File

@ -0,0 +1,40 @@
/* $NetBSD: exec.h,v 1.1.1.1 1996/03/13 04:58:07 jonathan Exp $ */
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* @(#)exec.h 8.1 (Berkeley) 6/10/93
*/
#define __LDPGSZ 4096
#include <machine/reloc.h>

View File

@ -0,0 +1,80 @@
/* $NetBSD: float.h,v 1.1.1.1 1996/03/13 04:58:07 jonathan Exp $ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* @(#)float.h 8.1 (Berkeley) 6/10/93
*/
#ifndef _PMAX_FLOAT_H_
#define _PMAX_FLOAT_H_
#include <sys/cdefs.h>
__BEGIN_DECLS
extern int __flt_rounds();
__END_DECLS
#define FLT_RADIX 2 /* b */
#define FLT_ROUNDS __flt_rounds()
#define FLT_MANT_DIG 24 /* p */
#define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */
#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */
#define FLT_MIN_EXP -125 /* emin */
#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */
#define FLT_MIN_10_EXP -37 /* ceil(log10(b**(emin-1))) */
#define FLT_MAX_EXP 128 /* emax */
#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */
#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */
#define DBL_MANT_DIG 53
#define DBL_EPSILON 2.2204460492503131E-16
#define DBL_DIG 15
#define DBL_MIN_EXP -1021
#define DBL_MIN 2.225073858507201E-308
#define DBL_MIN_10_EXP -307
#define DBL_MAX_EXP 1024
#define DBL_MAX 1.797693134862316E+308
#define DBL_MAX_10_EXP 308
#define LDBL_MANT_DIG DBL_MANT_DIG
#define LDBL_EPSILON DBL_EPSILON
#define LDBL_DIG DBL_DIG
#define LDBL_MIN_EXP DBL_MIN_EXP
#define LDBL_MIN DBL_MIN
#define LDBL_MIN_10_EXP DBL_MIN_10_EXP
#define LDBL_MAX_EXP DBL_MAX_EXP
#define LDBL_MAX DBL_MAX
#define LDBL_MAX_10_EXP DBL_MAX_10_EXP
#endif /* _PMAX_FLOAT_H_ */

View File

@ -0,0 +1,23 @@
/*
* Written by J.T. Conklin, Apr 11, 1995
* Public domain.
*/
#ifndef _MIPS_IEEEFP_H_
#define _MIPS_IEEEFP_H_
typedef int fp_except;
#define FP_X_IMP 0x01 /* imprecise (loss of precision) */
#define FP_X_UFL 0x02 /* underflow exception */
#define FP_X_OFL 0x04 /* overflow exception */
#define FP_X_DZ 0x08 /* divide-by-zero exception */
#define FP_X_INV 0x10 /* invalid operation exception */
typedef enum {
FP_RN=0, /* round to nearest representable number */
FP_RZ=1, /* round to zero (truncate) */
FP_RP=2, /* round toward positive infinity */
FP_RM=3 /* round toward negative infinity */
} fp_rnd;
#endif /* _MIPS_IEEEFP_H_ */

View File

@ -0,0 +1,52 @@
/*
* Keyboard definitions
*
* $Id: kbdreg.h,v 1.1.1.1 1996/03/13 04:58:07 jonathan Exp $
*/
#define KBSTATP (PICA_SYS_KBD + 0x61) /* controller status port (I) */
#define KBS_DIB 0x01 /* data in buffer */
#define KBS_IBF 0x02 /* input buffer low */
#define KBS_WARM 0x04 /* input buffer low */
#define KBS_OCMD 0x08 /* output buffer has command */
#define KBS_NOSEC 0x10 /* security lock not engaged */
#define KBS_TERR 0x20 /* transmission error */
#define KBS_RERR 0x40 /* receive error */
#define KBS_PERR 0x80 /* parity error */
#define KBCMDP (PICA_SYS_KBD + 0x61) /* controller port (O) */
#define KBDATAP (PICA_SYS_KBD + 0x60) /* data port (I) */
#define KBOUTP (PICA_SYS_KBD + 0x60) /* data port (O) */
#define K_RDCMDBYTE 0x20
#define K_LDCMDBYTE 0x60
#define KC8_TRANS 0x40 /* convert to old scan codes */
#define KC8_MDISABLE 0x20 /* disable mouse */
#define KC8_KDISABLE 0x10 /* disable keyboard */
#define KC8_IGNSEC 0x08 /* ignore security lock */
#define KC8_CPU 0x04 /* exit from protected mode reset */
#define KC8_MENABLE 0x02 /* enable mouse interrupt */
#define KC8_KENABLE 0x01 /* enable keyboard interrupt */
#define CMDBYTE (KC8_TRANS|KC8_CPU|KC8_MENABLE|KC8_KENABLE)
/* keyboard commands */
#define KBC_RESET 0xFF /* reset the keyboard */
#define KBC_RESEND 0xFE /* request the keyboard resend the last byte */
#define KBC_SETDEFAULT 0xF6 /* resets keyboard to its power-on defaults */
#define KBC_DISABLE 0xF5 /* as per KBC_SETDEFAULT, but also disable key scanning */
#define KBC_ENABLE 0xF4 /* enable key scanning */
#define KBC_TYPEMATIC 0xF3 /* set typematic rate and delay */
#define KBC_SETTABLE 0xF0 /* set scancode translation table */
#define KBC_MODEIND 0xED /* set mode indicators (i.e. LEDs) */
#define KBC_ECHO 0xEE /* request an echo from the keyboard */
/* keyboard responses */
#define KBR_EXTENDED 0xE0 /* extended key sequence */
#define KBR_RESEND 0xFE /* needs resend of command */
#define KBR_ACK 0xFA /* received a valid command */
#define KBR_OVERRUN 0x00 /* flooded */
#define KBR_FAILURE 0xFD /* diagnosic failure */
#define KBR_BREAK 0xF0 /* break code prefix - sent on key release */
#define KBR_RSTDONE 0xAA /* reset complete */
#define KBR_ECHO 0xEE /* echo response */

View File

@ -0,0 +1,74 @@
/* $NetBSD: kdbparam.h,v 1.1.1.1 1996/03/13 04:58:08 jonathan Exp $ */
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* @(#)kdbparam.h 8.1 (Berkeley) 6/10/93
*/
/*
* Machine dependent definitions for kdb.
*/
#if BYTE_ORDER == LITTLE_ENDIAN
#define kdbshorten(w) ((w) & 0xFFFF)
#define kdbbyte(w) ((w) & 0xFF)
#define kdbitol(a,b) ((long)(((b) << 16) | ((a) & 0xFFFF)))
#define kdbbtol(a) ((long)(a))
#endif
#define LPRMODE "%R"
#define OFFMODE "+%R"
#define SETBP(ins) MACH_BREAK_BRKPT
/* return the program counter value modified if we are in a delay slot */
#define kdbgetpc(pcb) (kdbvar[kdbvarchk('t')] < 0 ? \
(pcb).pcb_regs[34] + 4 : (pcb).pcb_regs[34])
#define kdbishiddenreg(p) ((p) >= &kdbreglist[33])
#define kdbisbreak(type) (((type) & MACH_CR_EXC_CODE) == 0x24)
/* check for address wrap around */
#define kdbaddrwrap(addr,newaddr) (((addr)^(newaddr)) >> 31)
/* declare machine dependent routines defined in kadb.c */
void kdbprinttrap __P((unsigned, unsigned));
void kdbsetsstep __P((void));
void kdbclrsstep __P((void));
void kdbreadc __P((char *));
void kdbwrite __P((char *, int));
void kdbprintins __P((int, long));
void kdbstacktrace __P((int));
char *kdbmalloc __P((int));

View File

@ -0,0 +1,100 @@
/* $NetBSD: limits.h,v 1.1.1.1 1996/03/13 04:58:08 jonathan Exp $ */
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* @(#)limits.h 8.3 (Berkeley) 1/4/94
*/
#define CHAR_BIT 8 /* number of bits in a char */
#define MB_LEN_MAX 6 /* Allow 31 bit UTF2 */
#ifdef _KERNEL
#define CLK_TCK 100 /* ticks per second */
#endif
/*
* According to ANSI (section 2.2.4.2), the values below must be usable by
* #if preprocessing directives. Additionally, the expression must have the
* same type as would an expression that is an object of the corresponding
* type converted according to the integral promotions. The subtraction for
* INT_MIN and LONG_MIN is so the value is not unsigned; 2147483648 is an
* unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
* These numbers work for pcc as well. The UINT_MAX and ULONG_MAX values
* are written as hex so that GCC will be quiet about large integer constants.
*/
#define SCHAR_MAX 127 /* min value for a signed char */
#define SCHAR_MIN (-128) /* max value for a signed char */
#define UCHAR_MAX 255 /* max value for an unsigned char */
#define CHAR_MAX 127 /* max value for a char */
#define CHAR_MIN (-128) /* min value for a char */
#define USHRT_MAX 65535 /* max value for an unsigned short */
#define SHRT_MAX 32767 /* max value for a short */
#define SHRT_MIN (-32768) /* min value for a short */
#define UINT_MAX 0xffffffff /* max value for an unsigned int */
#define INT_MAX 2147483647 /* max value for an int */
#define INT_MIN (-2147483647-1) /* min value for an int */
#define ULONG_MAX 0xffffffff /* max value for an unsigned long */
#define LONG_MAX 2147483647 /* max value for a long */
#define LONG_MIN (-2147483647-1) /* min value for a long */
#if !defined(_ANSI_SOURCE)
#define SSIZE_MAX INT_MAX /* max value for a ssize_t */
#if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)
#define SIZE_T_MAX UINT_MAX /* max value for a size_t */
/* GCC requires that quad constants be written as expressions. */
#define UQUAD_MAX ((u_quad_t)0-1) /* max value for a uquad_t */
/* max value for a quad_t */
#define QUAD_MAX ((quad_t)(UQUAD_MAX >> 1))
#define QUAD_MIN (-QUAD_MAX-1) /* min value for a quad_t */
#endif /* !_POSIX_SOURCE && !_XOPEN_SOURCE */
#endif /* !_ANSI_SOURCE */
#if (!defined(_ANSI_SOURCE)&&!defined(_POSIX_SOURCE)) || defined(_XOPEN_SOURCE)
#define LONG_BIT 32
#define WORD_BIT 32
#define DBL_DIG 15
#define DBL_MAX 1.797693134862316E+308
#define DBL_MIN 2.225073858507201E-308
#define FLT_DIG 6
#define FLT_MAX 3.40282347E+38F
#define FLT_MIN 1.17549435E-38F
#endif

View File

@ -0,0 +1,165 @@
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: @(#)machAsmDefs.h 8.1 (Berkeley) 6/10/93
* $Id: machAsmDefs.h,v 1.1.1.1 1996/03/13 04:58:08 jonathan Exp $
*/
/*
* machAsmDefs.h --
*
* Macros used when writing assembler programs.
*
* Copyright (C) 1989 Digital Equipment Corporation.
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
* provided that the above copyright notice appears in all copies.
* Digital Equipment Corporation makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* from: Header: /sprite/src/kernel/mach/ds3100.md/RCS/machAsmDefs.h,
* v 1.2 89/08/15 18:28:24 rab Exp SPRITE (DECWRL)
* $Id: machAsmDefs.h,v 1.1.1.1 1996/03/13 04:58:08 jonathan Exp $
*/
#ifndef _MACHASMDEFS
#define _MACHASMDEFS
#include <machine/regdef.h>
/*
* Define -pg profile entry code.
*/
#if defined(GPROF) || defined(PROF)
#define MCOUNT .set noreorder; \
.set noat; \
move $1,$31; \
jal _mcount; \
subu sp,sp,8; \
.set reorder; \
.set at;
#else
#define MCOUNT
#endif
/*
* LEAF(x)
*
* Declare a leaf routine.
*/
#define LEAF(x) \
.globl x; \
.ent x, 0; \
x: ; \
.frame sp, 0, ra; \
MCOUNT
/*
* NLEAF(x)
*
* Declare a non-profiled leaf routine.
*/
#define NLEAF(x) \
.globl x; \
.ent x, 0; \
x: ; \
.frame sp, 0, ra
/*
* ALEAF -- declare alternate entry to a leaf routine.
*/
#define ALEAF(x) \
.globl x; \
x:
/*
* NON_LEAF(x)
*
* Declare a non-leaf routine (a routine that makes other C calls).
*/
#define NON_LEAF(x, fsize, retpc) \
.globl x; \
.ent x, 0; \
x: ; \
.frame sp, fsize, retpc; \
MCOUNT
/*
* NNON_LEAF(x)
*
* Declare a non-profiled non-leaf routine
* (a routine that makes other C calls).
*/
#define NNON_LEAF(x, fsize, retpc) \
.globl x; \
.ent x, 0; \
x: ; \
.frame sp, fsize, retpc
/*
* END(x)
*
* Mark end of a procedure.
*/
#define END(x) \
.end x
#define STAND_FRAME_SIZE 24
#define STAND_RA_OFFSET 20
/*
* Macros to panic and printf from assembly language.
*/
#define PANIC(msg) \
la a0, 9f; \
jal panic; \
MSG(msg)
#define PRINTF(msg) \
la a0, 9f; \
jal printf; \
MSG(msg)
#define MSG(msg) \
.rdata; \
9: .asciiz msg; \
.text
#define ASMSTR(str) \
.asciiz str; \
.align 3
#endif /* _MACHASMDEFS */

View File

@ -0,0 +1,289 @@
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell and Rick Macklem.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: @(#)machConst.h 8.1 (Berkeley) 6/10/93
* $Id: machConst.h,v 1.1.1.1 1996/03/13 04:58:08 jonathan Exp $
*
* machConst.h --
*
* Machine dependent constants.
*
* Copyright (C) 1989 Digital Equipment Corporation.
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
* provided that the above copyright notice appears in all copies.
* Digital Equipment Corporation makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* from: Header: /sprite/src/kernel/mach/ds3100.md/RCS/machConst.h,
* v 9.2 89/10/21 15:55:22 jhh Exp SPRITE (DECWRL)
* from: Header: /sprite/src/kernel/mach/ds3100.md/RCS/machAddrs.h,
* v 1.2 89/08/15 18:28:21 rab Exp SPRITE (DECWRL)
* from: Header: /sprite/src/kernel/vm/ds3100.md/RCS/vmPmaxConst.h,
* v 9.1 89/09/18 17:33:00 shirriff Exp SPRITE (DECWRL)
* $Id: machConst.h,v 1.1.1.1 1996/03/13 04:58:08 jonathan Exp $
*/
#ifndef _MACHCONST
#define _MACHCONST
#define MACH_KUSEG_ADDR 0x0
#define MACH_CACHED_MEMORY_ADDR 0x80000000
#define MACH_UNCACHED_MEMORY_ADDR 0xa0000000
#define MACH_KSEG2_ADDR 0xc0000000
#define MACH_MAX_MEM_ADDR 0xbe000000
#define MACH_RESERVED_ADDR 0xbfc80000
#define MACH_CACHED_TO_PHYS(x) ((unsigned)(x) & 0x1fffffff)
#define MACH_PHYS_TO_CACHED(x) ((unsigned)(x) | MACH_CACHED_MEMORY_ADDR)
#define MACH_UNCACHED_TO_PHYS(x) ((unsigned)(x) & 0x1fffffff)
#define MACH_PHYS_TO_UNCACHED(x) ((unsigned)(x) | MACH_UNCACHED_MEMORY_ADDR)
#define MACH_VA_TO_CINDEX(x) \
((unsigned)(x) & 0xffffff | MACH_CACHED_MEMORY_ADDR)
#define MACH_CODE_START 0x80080000
/*
* The bits in the cause register.
*
* MACH_CR_BR_DELAY Exception happened in branch delay slot.
* MACH_CR_COP_ERR Coprocessor error.
* MACH_CR_IP Interrupt pending bits defined below.
* MACH_CR_EXC_CODE The exception type (see exception codes below).
*/
#define MACH_CR_BR_DELAY 0x80000000
#define MACH_CR_COP_ERR 0x30000000
#define MACH_CR_EXC_CODE 0x0000007C
#define MACH_CR_IP 0x0000FF00
#define MACH_CR_EXC_CODE_SHIFT 2
/*
* The bits in the status register. All bits are active when set to 1.
*/
#define MACH_SR_COP_USABILITY 0xf0000000
#define MACH_SR_COP_0_BIT 0x10000000
#define MACH_SR_COP_1_BIT 0x20000000
#define MACH_SR_RP 0x08000000
#define MACH_SR_FR_32 0x04000000
#define MACH_SR_RE 0x02000000
#define MACH_SR_BOOT_EXC_VEC 0x00400000
#define MACH_SR_TLB_SHUTDOWN 0x00200000
#define MACH_SR_SOFT_RESET 0x00100000
#define MACH_SR_DIAG_CH 0x00040000
#define MACH_SR_DIAG_CE 0x00020000
#define MACH_SR_DIAG_PE 0x00010000
#define MACH_SR_KX 0x00000080
#define MACH_SR_SX 0x00000040
#define MACH_SR_UX 0x00000020
#define MACH_SR_KSU_MASK 0x00000018
#define MACH_SR_KSU_USER 0x00000010
#define MACH_SR_KSU_SUPER 0x00000008
#define MACH_SR_KSU_KERNEL 0x00000000
#define MACH_SR_ERL 0x00000004
#define MACH_SR_EXL 0x00000002
#define MACH_SR_INT_ENAB 0x00000001
/*#define MACH_SR_INT_MASK 0x0000ff00*/
/*
* The interrupt masks.
* If a bit in the mask is 1 then the interrupt is enabled (or pending).
*/
#define MACH_INT_MASK 0x7f00
#define MACH_INT_MASK_5 0x8000 /* Not used (on chip timer) */
#define MACH_INT_MASK_4 0x4000
#define MACH_INT_MASK_3 0x2000
#define MACH_INT_MASK_2 0x1000
#define MACH_INT_MASK_1 0x0800
#define MACH_INT_MASK_0 0x0400
#define MACH_HARD_INT_MASK 0x7c00
#define MACH_SOFT_INT_MASK_1 0x0200
#define MACH_SOFT_INT_MASK_0 0x0100
/*
* The bits in the context register.
*/
#define MACH_CNTXT_PTE_BASE 0xFF800000
#define MACH_CNTXT_BAD_VPN2 0x007FFFF0
/*
* Location of exception vectors.
*/
#define MACH_RESET_EXC_VEC 0xBFC00000
#define MACH_TLB_MISS_EXC_VEC 0x80000000
#define MACH_XTLB_MISS_EXC_VEC 0x80000080
#define MACH_CACHE_ERR_EXC_VEC 0x80000100
#define MACH_GEN_EXC_VEC 0x80000180
/*
* Coprocessor 0 registers:
*/
#define MACH_COP_0_TLB_INDEX $0
#define MACH_COP_0_TLB_RANDOM $1
#define MACH_COP_0_TLB_LO0 $2
#define MACH_COP_0_TLB_LO1 $3
#define MACH_COP_0_TLB_CONTEXT $4
#define MACH_COP_0_TLB_PG_MASK $5
#define MACH_COP_0_TLB_WIRED $6
#define MACH_COP_0_BAD_VADDR $8
#define MACH_COP_0_TLB_HI $10
#define MACH_COP_0_STATUS_REG $12
#define MACH_COP_0_CAUSE_REG $13
#define MACH_COP_0_EXC_PC $14
#define MACH_COP_0_PRID $15
#define MACH_COP_0_CONFIG $16
#define MACH_COP_0_LLADDR $17
#define MACH_COP_0_WATCH_LO $18
#define MACH_COP_0_WATCH_HI $19
#define MACH_COP_0_TLB_XCONTEXT $20
#define MACH_COP_0_ECC $26
#define MACH_COP_0_CACHE_ERR $27
#define MACH_COP_0_TAG_LO $28
#define MACH_COP_0_TAG_HI $29
#define MACH_COP_0_ERROR_PC $30
/*
* Values for the code field in a break instruction.
*/
#define MACH_BREAK_INSTR 0x0000000d
#define MACH_BREAK_VAL_MASK 0x03ff0000
#define MACH_BREAK_VAL_SHIFT 16
#define MACH_BREAK_KDB_VAL 512
#define MACH_BREAK_SSTEP_VAL 513
#define MACH_BREAK_BRKPT_VAL 514
#define MACH_BREAK_SOVER_VAL 515
#define MACH_BREAK_KDB (MACH_BREAK_INSTR | \
(MACH_BREAK_KDB_VAL << MACH_BREAK_VAL_SHIFT))
#define MACH_BREAK_SSTEP (MACH_BREAK_INSTR | \
(MACH_BREAK_SSTEP_VAL << MACH_BREAK_VAL_SHIFT))
#define MACH_BREAK_BRKPT (MACH_BREAK_INSTR | \
(MACH_BREAK_BRKPT_VAL << MACH_BREAK_VAL_SHIFT))
#define MACH_BREAK_SOVER (MACH_BREAK_INSTR | \
(MACH_BREAK_SOVER_VAL << MACH_BREAK_VAL_SHIFT))
/*
* Mininum and maximum cache sizes.
*/
#define MACH_MIN_CACHE_SIZE (16 * 1024)
#define MACH_MAX_CACHE_SIZE (256 * 1024)
/*
* The floating point version and status registers.
*/
#define MACH_FPC_ID $0
#define MACH_FPC_CSR $31
/*
* The floating point coprocessor status register bits.
*/
#define MACH_FPC_ROUNDING_BITS 0x00000003
#define MACH_FPC_ROUND_RN 0x00000000
#define MACH_FPC_ROUND_RZ 0x00000001
#define MACH_FPC_ROUND_RP 0x00000002
#define MACH_FPC_ROUND_RM 0x00000003
#define MACH_FPC_STICKY_BITS 0x0000007c
#define MACH_FPC_STICKY_INEXACT 0x00000004
#define MACH_FPC_STICKY_UNDERFLOW 0x00000008
#define MACH_FPC_STICKY_OVERFLOW 0x00000010
#define MACH_FPC_STICKY_DIV0 0x00000020
#define MACH_FPC_STICKY_INVALID 0x00000040
#define MACH_FPC_ENABLE_BITS 0x00000f80
#define MACH_FPC_ENABLE_INEXACT 0x00000080
#define MACH_FPC_ENABLE_UNDERFLOW 0x00000100
#define MACH_FPC_ENABLE_OVERFLOW 0x00000200
#define MACH_FPC_ENABLE_DIV0 0x00000400
#define MACH_FPC_ENABLE_INVALID 0x00000800
#define MACH_FPC_EXCEPTION_BITS 0x0003f000
#define MACH_FPC_EXCEPTION_INEXACT 0x00001000
#define MACH_FPC_EXCEPTION_UNDERFLOW 0x00002000
#define MACH_FPC_EXCEPTION_OVERFLOW 0x00004000
#define MACH_FPC_EXCEPTION_DIV0 0x00008000
#define MACH_FPC_EXCEPTION_INVALID 0x00010000
#define MACH_FPC_EXCEPTION_UNIMPL 0x00020000
#define MACH_FPC_COND_BIT 0x00800000
#define MACH_FPC_FLUSH_BIT 0x01000000
#define MACH_FPC_MBZ_BITS 0xfe7c0000
/*
* Constants to determine if have a floating point instruction.
*/
#define MACH_OPCODE_SHIFT 26
#define MACH_OPCODE_C1 0x11
/*
* The low part of the TLB entry.
*/
#define VMMACH_TLB_PF_NUM 0x3fffffc0
#define VMMACH_TLB_ATTR_MASK 0x00000038
#define VMMACH_TLB_MOD_BIT 0x00000004
#define VMMACH_TLB_VALID_BIT 0x00000002
#define VMMACH_TLB_GLOBAL_BIT 0x00000001
#define VMMACH_TLB_PHYS_PAGE_SHIFT 6
/*
* The high part of the TLB entry.
*/
#define VMMACH_TLB_VIRT_PAGE_NUM 0xffffe000
#define VMMACH_TLB_PID 0x000000ff
#define VMMACH_TLB_PID_SHIFT 0
#define VMMACH_TLB_VIRT_PAGE_SHIFT 12
/*
* The number of TLB entries and the first one that write random hits.
*/
#define VMMACH_NUM_TLB_ENTRIES 48
#define VMMACH_WIRED_ENTRIES 8
/*
* The number of process id entries.
*/
#define VMMACH_NUM_PIDS 256
/*
* TLB probe return codes.
*/
#define VMMACH_TLB_NOT_FOUND 0
#define VMMACH_TLB_FOUND 1
#define VMMACH_TLB_FOUND_WITH_PATCH 2
#define VMMACH_TLB_PROBE_ERROR 3
/*
* Kernel virtual address for user page table entries
* (i.e., the address for the context register).
*/
#define VMMACH_PTE_BASE 0xFF800000
#endif /* _MACHCONST */

View File

@ -0,0 +1,259 @@
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: @(#)mips_opcode.h 8.1 (Berkeley) 6/10/93
* $Id: mips_opcode.h,v 1.1.1.1 1996/03/13 04:58:08 jonathan Exp $
*/
/*
* Define the instruction formats and opcode values for the
* MIPS instruction set.
*/
/*
* Define the instruction formats.
*/
typedef union {
unsigned word;
#if BYTE_ORDER == LITTLE_ENDIAN
struct {
unsigned imm: 16;
unsigned rt: 5;
unsigned rs: 5;
unsigned op: 6;
} IType;
struct {
unsigned target: 26;
unsigned op: 6;
} JType;
struct {
unsigned func: 6;
unsigned shamt: 5;
unsigned rd: 5;
unsigned rt: 5;
unsigned rs: 5;
unsigned op: 6;
} RType;
struct {
unsigned func: 6;
unsigned fd: 5;
unsigned fs: 5;
unsigned ft: 5;
unsigned fmt: 4;
unsigned : 1; /* always '1' */
unsigned op: 6; /* always '0x11' */
} FRType;
#endif
} InstFmt;
/*
* Values for the 'op' field.
*/
#define OP_SPECIAL 000
#define OP_BCOND 001
#define OP_J 002
#define OP_JAL 003
#define OP_BEQ 004
#define OP_BNE 005
#define OP_BLEZ 006
#define OP_BGTZ 007
#define OP_ADDI 010
#define OP_ADDIU 011
#define OP_SLTI 012
#define OP_SLTIU 013
#define OP_ANDI 014
#define OP_ORI 015
#define OP_XORI 016
#define OP_LUI 017
#define OP_COP0 020
#define OP_COP1 021
#define OP_COP2 022
#define OP_COP3 023
#define OP_BEQL 024
#define OP_BNEL 025
#define OP_BLEZL 026
#define OP_BGTZL 027
#define OP_DADDI 030
#define OP_DADDIU 031
#define OP_LDL 032
#define OP_LDR 033
#define OP_LB 040
#define OP_LH 041
#define OP_LWL 042
#define OP_LW 043
#define OP_LBU 044
#define OP_LHU 045
#define OP_LWR 046
#define OP_LHU 045
#define OP_LWR 046
#define OP_LWU 047
#define OP_SB 050
#define OP_SH 051
#define OP_SWL 052
#define OP_SW 053
#define OP_SDL 054
#define OP_SDR 055
#define OP_SWR 056
#define OP_CACHE 057
#define OP_LL 060
#define OP_LWC1 061
#define OP_LWC2 062
#define OP_LWC3 063
#define OP_LLD 064
#define OP_LD 067
#define OP_SC 070
#define OP_SWC1 071
#define OP_SWC2 072
#define OP_SWC3 073
#define OP_SCD 074
#define OP_SD 077
/*
* Values for the 'func' field when 'op' == OP_SPECIAL.
*/
#define OP_SLL 000
#define OP_SRL 002
#define OP_SRA 003
#define OP_SLLV 004
#define OP_SRLV 006
#define OP_SRAV 007
#define OP_JR 010
#define OP_JALR 011
#define OP_SYSCALL 014
#define OP_BREAK 015
#define OP_SYNC 017
#define OP_MFHI 020
#define OP_MTHI 021
#define OP_MFLO 022
#define OP_MTLO 023
#define OP_DSLLV 024
#define OP_DSRLV 026
#define OP_DSRAV 027
#define OP_MULT 030
#define OP_MULTU 031
#define OP_DIV 032
#define OP_DIVU 033
#define OP_DMULT 034
#define OP_DMULTU 035
#define OP_DDIV 036
#define OP_DDIVU 037
#define OP_ADD 040
#define OP_ADDU 041
#define OP_SUB 042
#define OP_SUBU 043
#define OP_AND 044
#define OP_OR 045
#define OP_XOR 046
#define OP_NOR 047
#define OP_SLT 052
#define OP_SLTU 053
#define OP_DADD 054
#define OP_DADDU 055
#define OP_DSUB 056
#define OP_DSUBU 057
#define OP_TGE 060
#define OP_TGEU 061
#define OP_TLT 062
#define OP_TLTU 063
#define OP_TEQ 064
#define OP_TNE 066
#define OP_DSLL 070
#define OP_DSRL 072
#define OP_DSRA 073
#define OP_DSLL32 074
#define OP_DSRL32 076
#define OP_DSRA32 077
/*
* Values for the 'func' field when 'op' == OP_BCOND.
*/
#define OP_BLTZ 000
#define OP_BGEZ 001
#define OP_BLTZL 002
#define OP_BGEZL 003
#define OP_TGEI 010
#define OP_TGEIU 011
#define OP_TLTI 012
#define OP_TLTIU 013
#define OP_TEQI 014
#define OP_TNEI 016
#define OP_BLTZAL 020
#define OP_BLTZAL 020
#define OP_BGEZAL 021
#define OP_BLTZALL 022
#define OP_BGEZALL 023
/*
* Values for the 'rs' field when 'op' == OP_COPz.
*/
#define OP_MF 000
#define OP_DMF 001
#define OP_MT 004
#define OP_DMT 005
#define OP_BCx 010
#define OP_BCy 014
#define OP_CF 002
#define OP_CT 006
/*
* Values for the 'rt' field when 'op' == OP_COPz.
*/
#define COPz_BC_TF_MASK 0x01
#define COPz_BC_TRUE 0x01
#define COPz_BC_FALSE 0x00
#define COPz_BCL_TF_MASK 0x02
#define COPz_BCL_TRUE 0x02
#define COPz_BCL_FALSE 0x00

View File

@ -0,0 +1,49 @@
/* $NetBSD: mouse.h,v 1.1.1.1 1996/03/13 04:58:08 jonathan Exp $ */
/*-
* Copyright (c) 1992, 1993 Erik Forsberg.
* All rights reserved.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY ``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 I 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.
*/
#ifndef _MOUSE_H_
#define _MOUSE_H_
struct mouseinfo {
unsigned char status;
char xmotion, ymotion;
};
#define BUTSTATMASK 0x07 /* Any mouse button down if any bit set */
#define BUTCHNGMASK 0x38 /* Any mouse button changed if any bit set */
#define BUT3STAT 0x01 /* Button 3 down if set */
#define BUT2STAT 0x02 /* Button 2 down if set */
#define BUT1STAT 0x04 /* Button 1 down if set */
#define BUT3CHNG 0x08 /* Button 3 changed if set */
#define BUT2CHNG 0x10 /* Button 2 changed if set */
#define BUT1CHNG 0x20 /* Button 1 changed if set */
#define MOVEMENT 0x40 /* Mouse movement detected */
/* Ioctl definitions */
#define MOUSEIOC ('M'<<8)
#define MOUSEIOCREAD (MOUSEIOC|60)
#endif /* !_MOUSE_H_ */

View File

@ -0,0 +1,167 @@
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department and Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: Utah Hdr: machparam.h 1.11 89/08/14
*
*
* from: @(#)param.h 8.1 (Berkeley) 6/10/93
* $Id: param.h,v 1.1.1.1 1996/03/13 04:58:08 jonathan Exp $
*/
/*
* Machine dependent constants for Acer Labs PICA_61.
*/
#define MACHINE "pica"
#define MACHINE_ARCH "mips"
#define MID_PICA MID_PMAX /* For the moment */
#define MID_MACHINE MID_PICA
/*
* Round p (pointer or byte index) up to a correctly-aligned value for all
* data types (int, long, ...). The result is u_int and must be cast to
* any desired pointer type.
*/
#define ALIGNBYTES 7
#define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
#define NBPG 4096 /* bytes/page */
#define PGOFSET (NBPG-1) /* byte offset into page */
#define PGSHIFT 12 /* LOG2(NBPG) */
#define NPTEPG (NBPG/4)
#define NBSEG 0x400000 /* bytes/segment */
#define SEGOFSET (NBSEG-1) /* byte offset into segment */
#define SEGSHIFT 22 /* LOG2(NBSEG) */
#define KERNBASE 0x80000000 /* start of kernel virtual */
#define KERNTEXTOFF 0x80080000 /* start of kernel text for kvm_mkdb */
#define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT)
#define DEV_BSIZE 512
#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
#define BLKDEV_IOSIZE 2048
#define MAXPHYS (64 * 1024) /* max raw I/O transfer size */
#define CLSIZE 1
#define CLSIZELOG2 0
/* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */
#define SSIZE 1 /* initial stack size/NBPG */
#define SINCR 1 /* increment of stack/NBPG */
#define UPAGES 2 /* pages of u-area */
#define UADDR 0xffffc000 /* address of u */
#define USPACE (UPAGES*NBPG) /* size of u-area in bytes */
#define UVPN (UADDR>>PGSHIFT)/* virtual page number of u */
#define KERNELSTACK (UADDR+UPAGES*NBPG) /* top of kernel stack */
/*
* Constants related to network buffer management.
* MCLBYTES must be no larger than CLBYTES (the software page size), and,
* on machines that exchange pages of input or output buffers with mbuf
* clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
* of the hardware page size.
*/
#define MSIZE 128 /* size of an mbuf */
#define MCLBYTES 2048 /* enough for whole Ethernet packet */
#define MCLSHIFT 10
#define MCLOFSET (MCLBYTES - 1)
#ifndef NMBCLUSTERS
#ifdef GATEWAY
#define NMBCLUSTERS 2048 /* map size, max cluster allocation */
#else
#define NMBCLUSTERS 1024 /* map size, max cluster allocation */
#endif
#endif
/*
* Size of kernel malloc arena in CLBYTES-sized logical pages
*/
#ifndef NKMEMCLUSTERS
#define NKMEMCLUSTERS (512*1024/CLBYTES)
#endif
/* pages ("clicks") (4096 bytes) to disk blocks */
#define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT))
#define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT))
/* pages to bytes */
#define ctob(x) ((x) << PGSHIFT)
#define btoc(x) (((x) + PGOFSET) >> PGSHIFT)
/* bytes to disk blocks */
#define btodb(x) ((x) >> DEV_BSHIFT)
#define dbtob(x) ((x) << DEV_BSHIFT)
/*
* Map a ``block device block'' to a file system block.
* This should be device dependent, and should use the bsize
* field from the disk label.
* For now though just use DEV_BSIZE.
*/
#define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
/*
* Mach derived conversion macros
*/
#define pica_round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1))
#define pica_trunc_page(x) ((unsigned)(x) & ~(NBPG-1))
#define pica_btop(x) ((unsigned)(x) >> PGSHIFT)
#define pica_ptob(x) ((unsigned)(x) << PGSHIFT)
#ifdef _KERNEL
#ifndef LOCORE
extern int (*Mach_splnet)(), (*Mach_splbio)(), (*Mach_splimp)(),
(*Mach_spltty)(), (*Mach_splclock)(), (*Mach_splstatclock)();
#define splnet() ((*Mach_splnet)())
#define splbio() ((*Mach_splbio)())
#define splimp() ((*Mach_splimp)())
#define spltty() ((*Mach_spltty)())
#define splclock() ((*Mach_splclock)())
#define splstatclock() ((*Mach_splstatclock)())
/*
* Delay is based on an assumtion that each time in the loop
* takes 3 clocks. Three is for branch and subtract in the delay slot.
*/
extern int cpuspeed;
#define DELAY(n) { register int N = cpuspeed * (n); while ((N -= 3) > 0); }
#endif
#else /* !_KERNEL */
#define DELAY(n) { register int N = (n); while (--N > 0); }
#endif /* !_KERNEL */

View File

@ -0,0 +1,61 @@
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department and Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: Utah Hdr: pcb.h 1.13 89/04/23
*
* from: @(#)pcb.h 8.1 (Berkeley) 6/10/93
* $Id: pcb.h,v 1.1.1.1 1996/03/13 04:58:08 jonathan Exp $
*/
/*
* PICA process control block
*/
struct pcb
{
int pcb_regs[71]; /* saved CPU and floating point registers */
label_t pcb_context; /* kernel context for resume */
int pcb_onfault; /* for copyin/copyout faults */
void *pcb_segtab; /* copy of pmap pm_segtab */
};
/*
* The pcb is augmented with machine-dependent additional data for
* core dumps. For the PICA, there is nothing to add.
*/
struct md_coredump {
long md_pad[8];
};

View File

@ -0,0 +1,21 @@
/*
* pccons.h -- pccons ioctl definitions
*
* $Id: pccons.h,v 1.1.1.1 1996/03/13 04:58:08 jonathan Exp $
*/
#ifndef _PCCONS_H_
#define _PCCONS_H_
#ifndef _KERNEL
#include <sys/ioctl.h>
#else
#include "ioctl.h"
#endif
#define CONSOLE_X_MODE_ON _IO('t',121)
#define CONSOLE_X_MODE_OFF _IO('t',122)
#define CONSOLE_X_BELL _IOW('t',123,int[2])
#define CONSOLE_SET_TYPEMATIC_RATE _IOW('t',124,u_char)
#endif /* _PCCONS_H_ */

View File

@ -0,0 +1,46 @@
/* $NetBSD: pio.h,v 1.1.1.1 1996/03/13 04:58:08 jonathan Exp $ */
/*
* Copyright (c) 1995 Per Fogelstrom. All rights reserved.
*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Charles M. Hannum.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/*
* I/O macros.
*/
#define outb(a,v) (*(volatile unsigned char*)(a) = (v))
#define outw(a,v) (*(volatile unsigned short*)(a) = (v))
#define out16(a,v) outw(a,v)
#define outl(a,v) (*(volatile unsigned int*)(a) = (v))
#define out32(a,v) outl(a,v)
#define inb(a) (*(volatile unsigned char*)(a))
#define inw(a) (*(volatile unsigned short*)(a))
#define in16(a) inw(a)
#define inl(a) (*(volatile unsigned int*)(a))
#define in32(a) inl(a)

View File

@ -0,0 +1,104 @@
/*
* Copyright (c) 1987 Carnegie-Mellon University
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: @(#)pmap.h 8.1 (Berkeley) 6/10/93
* $Id: pmap.h,v 1.1.1.1 1996/03/13 04:58:08 jonathan Exp $
*/
#ifndef _PMAP_MACHINE_
#define _PMAP_MACHINE_
/*
* The user address space is 2Gb (0x0 - 0x80000000).
* User programs are laid out in memory as follows:
* address
* USRTEXT 0x00001000
* USRDATA USRTEXT + text_size
* USRSTACK 0x7FFFFFFF
*
* The user address space is mapped using a two level structure where
* virtual address bits 30..22 are used to index into a segment table which
* points to a page worth of PTEs (4096 page can hold 1024 PTEs).
* Bits 21..12 are then used to index a PTE which describes a page within
* a segment.
*
* The wired entries in the TLB will contain the following:
* 0-1 (UPAGES) for curproc user struct and kernel stack.
*
* Note: The kernel doesn't use the same data structures as user programs.
* All the PTE entries are stored in a single array in Sysmap which is
* dynamically allocated at boot time.
*/
#define pica_trunc_seg(x) ((vm_offset_t)(x) & ~SEGOFSET)
#define pica_round_seg(x) (((vm_offset_t)(x) + SEGOFSET) & ~SEGOFSET)
#define pmap_segmap(m, v) ((m)->pm_segtab->seg_tab[((v) >> SEGSHIFT)])
#define PMAP_SEGTABSIZE 512
union pt_entry;
struct segtab {
union pt_entry *seg_tab[PMAP_SEGTABSIZE];
};
/*
* Machine dependent pmap structure.
*/
typedef struct pmap {
int pm_count; /* pmap reference count */
simple_lock_data_t pm_lock; /* lock on pmap */
struct pmap_statistics pm_stats; /* pmap statistics */
int pm_tlbpid; /* address space tag */
u_int pm_tlbgen; /* TLB PID generation number */
struct segtab *pm_segtab; /* pointers to pages of PTEs */
} *pmap_t;
/*
* Defines for pmap_attributes[phys_mach_page];
*/
#define PMAP_ATTR_MOD 0x01 /* page has been modified */
#define PMAP_ATTR_REF 0x02 /* page has been referenced */
#ifdef _KERNEL
extern char *pmap_attributes; /* reference and modify bits */
extern struct pmap kernel_pmap_store;
#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count)
#define pmap_kernel() (&kernel_pmap_store)
#endif /* _KERNEL */
#endif /* _PMAP_MACHINE_ */

View File

@ -0,0 +1,53 @@
/* $NetBSD: proc.h,v 1.1.1.1 1996/03/13 04:58:08 jonathan Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* @(#)proc.h 8.1 (Berkeley) 6/10/93
*/
/*
* Machine-dependent part of the proc structure for DEC Station.
*/
struct mdproc {
int *md_regs; /* registers on current frame */
int md_flags; /* machine-dependent flags */
int md_upte[UPAGES]; /* ptes for mapping u page */
int md_ss_addr; /* single step address for ptrace */
int md_ss_instr; /* single step instruction for ptrace */
};
/* md_flags */
#define MDP_FPUSED 0x0001 /* floating point coprocessor used */

View File

@ -0,0 +1,78 @@
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: @(#)profile.h 8.1 (Berkeley) 6/10/93
* $Id: profile.h,v 1.1.1.1 1996/03/13 04:58:08 jonathan Exp $
*/
#define _MCOUNT_DECL static void __mcount
#define MCOUNT \
asm(".globl _mcount;" \
"_mcount:;" \
".set noreorder;" \
".set noat;" \
"sw $4,8($29);" \
"sw $5,12($29);" \
"sw $6,16($29);" \
"sw $7,20($29);" \
"sw $1,0($29);" \
"sw $31,4($29);" \
"move $5,$31;" \
"jal ___mcount;" \
"move $4,$1;" \
"lw $4,8($29);" \
"lw $5,12($29);" \
"lw $6,16($29);" \
"lw $7,20($29);" \
"lw $31,4($29);" \
"lw $1,0($29);" \
"addu $29,$29,8;" \
"j $31;" \
"move $31,$1;" \
".set reorder;" \
".set at");
#ifdef _KERNEL
/*
* The following two macros do splhigh and splx respectively.
* They have to be defined this way because these are real
* functions on the PICA, and we do not want to invoke mcount
* recursively.
*/
#define MCOUNT_ENTER s = _splhigh()
#define MCOUNT_EXIT _splx(s)
#endif /* _KERNEL */

View File

@ -0,0 +1,68 @@
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: @(#)psl.h 8.1 (Berkeley) 6/10/93
* $Id: psl.h,v 1.1.1.1 1996/03/13 04:58:08 jonathan Exp $
*/
#include <machine/machConst.h>
#define PSL_LOWIPL (MACH_INT_MASK | MACH_SR_INT_ENAB)
#define PSL_USERSET ( \
MACH_SR_KSU_USER | \
MACH_SR_INT_ENAB | \
MACH_SR_EXL | \
MACH_INT_MASK)
#define PSL_USERCLR ( \
MACH_SR_COP_USABILITY | \
MACH_SR_BOOT_EXC_VEC | \
MACH_SR_TLB_SHUTDOWN | \
MACH_SR_PARITY_ERR | \
MACH_SR_CACHE_MISS | \
MACH_SR_PARITY_ZERO | \
MACH_SR_SWAP_CACHES | \
MACH_SR_ISOL_CACHES | \
MACH_SR_KU_CUR | \
MACH_SR_INT_ENA_CUR | \
MACH_SR_MBZ)
/*
* Macros to decode processor status word.
*/
#define USERMODE(ps) (((ps) & MACH_SR_KSU_MASK) == MACH_SR_KSU_USER)
#define BASEPRI(ps) (((ps) & (MACH_INT_MASK | MACH_SR_INT_ENA_PREV)) \
== (MACH_INT_MASK | MACH_SR_INT_ENA_PREV))

134
sys/arch/pica/include/pte.h Normal file
View File

@ -0,0 +1,134 @@
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department and Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: Utah Hdr: pte.h 1.11 89/09/03
*
* from: @(#)pte.h 8.1 (Berkeley) 6/10/93
* $Id: pte.h,v 1.1.1.1 1996/03/13 04:58:08 jonathan Exp $
*/
/*
* R4000 hardware page table entry
*/
#ifndef LOCORE
struct pte {
#if BYTE_ORDER == BIG_ENDIAN
unsigned int pg_prot:2, /* SW: access control */
pg_pfnum:24, /* HW: core page frame number or 0 */
pg_attr:3, /* HW: cache attribute */
pg_m:1, /* HW: modified (dirty) bit */
pg_v:1, /* HW: valid bit */
pg_g:1; /* HW: ignore pid bit */
#endif
#if BYTE_ORDER == LITTLE_ENDIAN
unsigned int pg_g:1, /* HW: ignore pid bit */
pg_v:1, /* HW: valid bit */
pg_m:1, /* HW: modified (dirty) bit */
pg_attr:3, /* HW: cache attribute */
pg_pfnum:24, /* HW: core page frame number or 0 */
pg_prot:2; /* SW: access control */
#endif
};
/*
* Structure defining an tlb entry data set.
*/
struct tlb {
int tlb_mask;
int tlb_hi;
int tlb_lo0;
int tlb_lo1;
};
typedef union pt_entry {
unsigned int pt_entry; /* for copying, etc. */
struct pte pt_pte; /* for getting to bits by name */
} pt_entry_t; /* Mach page table entry */
#endif /* LOCORE */
#define PT_ENTRY_NULL ((pt_entry_t *) 0)
#define PG_WIRED 0x80000000 /* SW */
#define PG_RO 0x40000000 /* SW */
#define PG_SVPN 0xfffff000 /* Software page no mask */
#define PG_HVPN 0xffffe000 /* Hardware page no mask */
#define PG_ODDPG 0x00001000 /* Odd even pte entry */
#define PG_ASID 0x000000ff /* Address space ID */
#define PG_G 0x00000001 /* HW */
#define PG_V 0x00000002
#define PG_NV 0x00000000
#define PG_M 0x00000004
#define PG_ATTR 0x0000003f
#define PG_UNCACHED 0x00000010
#define PG_CACHED 0x00000018
#define PG_CACHEMODE 0x00000038
#define PG_ROPAGE (PG_V | PG_RO | PG_CACHED) /* Write protected */
#define PG_RWPAGE (PG_V | PG_M | PG_CACHED) /* Not wr-prot not clean */
#define PG_CWPAGE (PG_V | PG_CACHED) /* Not wr-prot but clean */
#define PG_IOPAGE (PG_G | PG_V | PG_M | PG_UNCACHED)
#define PG_FRAME 0x3fffffc0
#define PG_SHIFT 6
#define vad_to_pfn(x) (((unsigned)(x) >> PG_SHIFT) & PG_FRAME)
#define pfn_to_vad(x) (((x) & PG_FRAME) << PG_SHIFT)
#define vad_to_vpn(x) ((unsigned)(x) & PG_SVPN)
#define vpn_to_vad(x) ((x) & PG_SVPN)
/* User viritual to pte page entry */
#define uvtopte(adr) (((adr) >> PGSHIFT) & (NPTEPG -1))
#define PG_SIZE_4K 0x00000000
#define PG_SIZE_16K 0x00006000
#define PG_SIZE_64K 0x0001e000
#define PG_SIZE_256K 0x0007e000
#define PG_SIZE_1M 0x001fe000
#define PG_SIZE_4M 0x007fe000
#define PG_SIZE_16M 0x01ffe000
#if defined(_KERNEL) && !defined(LOCORE)
/*
* Kernel virtual address to page table entry and visa versa.
*/
#define kvtopte(va) \
(Sysmap + (((vm_offset_t)(va) - VM_MIN_KERNEL_ADDRESS) >> PGSHIFT))
#define ptetokv(pte) \
((((pt_entry_t *)(pte) - Sysmap) << PGSHIFT) + VM_MIN_KERNEL_ADDRESS)
extern pt_entry_t *Sysmap; /* kernel pte table */
extern u_int Sysmapsize; /* number of pte's in Sysmap */
#endif

View File

@ -0,0 +1,41 @@
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: @(#)ptrace.h 8.1 (Berkeley) 6/10/93
* $Id: ptrace.h,v 1.1.1.1 1996/03/13 04:58:08 jonathan Exp $
*/
/*
* Machine dependent trace commands.
*
* None for the pica at this time.
*/

View File

@ -0,0 +1,62 @@
/* $NetBSD: reg.h,v 1.1.1.1 1996/03/13 04:58:08 jonathan Exp $ */
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department and Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: Utah Hdr: reg.h 1.1 90/07/09
*
* @(#)reg.h 8.2 (Berkeley) 1/11/94
*/
#ifndef _MACHINE_REG_H_
#define _MACHINE_REG_H_
/*
* Location of the users' stored
* registers relative to ZERO.
* Usage is p->p_regs[XX].
*
* must be visible to assembly code.
*/
#include <machine/regnum.h>
/*
* Register set accessible via /proc/$pid/reg
*/
struct reg {
int r_regs[71]; /* numbered as above */
};
#endif /*_MACHINE_REG_H_*/

View File

@ -0,0 +1,73 @@
/* $NetBSD: regdef.h,v 1.1.1.1 1996/03/13 04:58:08 jonathan Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell. This file is derived from the MIPS RISC
* Architecture book by Gerry Kane.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* @(#)regdef.h 8.1 (Berkeley) 6/10/93
*/
#define zero $0 /* always zero */
#define AT $at /* assembler temp */
#define v0 $2 /* return value */
#define v1 $3
#define a0 $4 /* argument registers */
#define a1 $5
#define a2 $6
#define a3 $7
#define t0 $8 /* temp registers (not saved across subroutine calls) */
#define t1 $9
#define t2 $10
#define t3 $11
#define t4 $12
#define t5 $13
#define t6 $14
#define t7 $15
#define s0 $16 /* saved across subroutine calls (callee saved) */
#define s1 $17
#define s2 $18
#define s3 $19
#define s4 $20
#define s5 $21
#define s6 $22
#define s7 $23
#define t8 $24 /* two more temp registers */
#define t9 $25
#define k0 $26 /* kernel temporary */
#define k1 $27
#define gp $28 /* global pointer */
#define sp $29 /* stack pointer */
#define s8 $30 /* one more callee saved */
#define ra $31 /* return address */

View File

@ -0,0 +1,136 @@
/* $NetBSD: regnum.h,v 1.1.1.1 1996/03/13 04:58:09 jonathan Exp $ */
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department and Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: Utah Hdr: reg.h 1.1 90/07/09
*
* @(#)reg.h 8.2 (Berkeley) 1/11/94
*/
/*
* Location of the users' stored
* registers relative to ZERO.
* Usage is p->p_regs[XX].
*/
#define ZERO 0
#define AST 1
#define V0 2
#define V1 3
#define A0 4
#define A1 5
#define A2 6
#define A3 7
#define T0 8
#define T1 9
#define T2 10
#define T3 11
#define T4 12
#define T5 13
#define T6 14
#define T7 15
#define S0 16
#define S1 17
#define S2 18
#define S3 19
#define S4 20
#define S5 21
#define S6 22
#define S7 23
#define T8 24
#define T9 25
#define K0 26
#define K1 27
#define GP 28
#define SP 29
#define S8 30
#define RA 31
#define SR 32
#define PS SR /* alias for SR */
#define MULLO 33
#define MULHI 34
#define BADVADDR 35
#define CAUSE 36
#define PC 37
#define FPBASE 38
#define F0 (FPBASE+0)
#define F1 (FPBASE+1)
#define F2 (FPBASE+2)
#define F3 (FPBASE+3)
#define F4 (FPBASE+4)
#define F5 (FPBASE+5)
#define F6 (FPBASE+6)
#define F7 (FPBASE+7)
#define F8 (FPBASE+8)
#define F9 (FPBASE+9)
#define F10 (FPBASE+10)
#define F11 (FPBASE+11)
#define F12 (FPBASE+12)
#define F13 (FPBASE+13)
#define F14 (FPBASE+14)
#define F15 (FPBASE+15)
#define F16 (FPBASE+16)
#define F17 (FPBASE+17)
#define F18 (FPBASE+18)
#define F19 (FPBASE+19)
#define F20 (FPBASE+20)
#define F21 (FPBASE+21)
#define F22 (FPBASE+22)
#define F23 (FPBASE+23)
#define F24 (FPBASE+24)
#define F25 (FPBASE+25)
#define F26 (FPBASE+26)
#define F27 (FPBASE+27)
#define F28 (FPBASE+28)
#define F29 (FPBASE+29)
#define F30 (FPBASE+30)
#define F31 (FPBASE+31)
#define FSR (FPBASE+32)
#ifdef IPCREG
#define NIPCREG (FSR + 1)
int ipcreg[NIPCREG] = {
ZERO, AST, V0, V1, A0, A1, A2, A3, T0, T1, T2, T3, T4, T5, T6, T7,
S0, S1, S2, S3, S4, S5, S6, S7, T8, T9, K0, K1, GP, SP, S8, RA,
SR, MULLO, MULHI, BADVADDR, CAUSE, PC,
F0, F1, F2, F3, F4, F5, F6, F7,
F8, F9, F10, F11, F12, F13, F14, F15,
F16, F17, F18, F19, F20, F21, F22, F23,
F24, F25, F26, F27, F28, F29, F30, F31, FSR,
};
#endif

View File

@ -0,0 +1,73 @@
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: @(#)reloc.h 8.1 (Berkeley) 6/10/93
* $Id: reloc.h,v 1.1.1.1 1996/03/13 04:58:08 jonathan Exp $
*
* from: Header: reloc.h,v 1.6 92/06/20 09:59:37 torek Exp
*/
/*
* MIPS relocation types.
*/
enum reloc_type {
MIPS_RELOC_32, /* 32-bit absolute */
MIPS_RELOC_JMP, /* 26-bit absolute << 2 | high 4 bits of pc */
MIPS_RELOC_WDISP16, /* 16-bit signed pc-relative << 2 */
MIPS_RELOC_HI16, /* 16-bit absolute << 16 */
MIPS_RELOC_HI16_S, /* 16-bit absolute << 16 (+1 if needed) */
MIPS_RELOC_LO16, /* 16-bit absolute */
};
/*
* MIPS relocation info.
*
* Symbol-relative relocation is done by:
* 1. start with the value r_addend,
* 2. locate the appropriate symbol and if defined, add symbol value,
* 3. if pc relative, subtract pc,
* 4. if the reloc_type is MIPS_RELOC_HI16_S and the result bit 15 is set,
* add 0x00010000,
* 5. shift down 2 or 16 if necessary.
* The resulting value is then to be stuffed into the appropriate bits
* in the object (the low 16, or the low 26 bits).
*/
struct reloc_info_pica {
u_long r_address; /* relocation addr (offset in segment) */
u_int r_index:24, /* segment (r_extern==0) or symbol index */
r_extern:1, /* if set, r_index is symbol index */
:2; /* unused */
enum reloc_type r_type:5; /* relocation type, from above */
long r_addend; /* value to add to symbol value */
};
#define relocation_info reloc_info_pica

View File

@ -0,0 +1,7 @@
/* $NetBSD: setjmp.h,v 1.1.1.1 1996/03/13 04:58:08 jonathan Exp $ */
/*
* machine/setjmp.h: machine dependent setjmp-related information.
*/
#define _JBLEN 83 /* size, in longs, of a jmp_buf */

View File

@ -0,0 +1,67 @@
/* $NetBSD: signal.h,v 1.1.1.1 1996/03/13 04:58:09 jonathan Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* @(#)signal.h 8.1 (Berkeley) 6/10/93
*/
/*
* Machine-dependent signal definitions
*/
typedef int sig_atomic_t;
#ifndef _ANSI_SOURCE
/*
* Information pushed on stack when a signal is delivered.
* This is used by the kernel to restore state following
* execution of the signal handler. It is also made available
* to the handler to allow it to restore state properly if
* a non-standard exit is performed.
*/
struct sigcontext {
int sc_onstack; /* sigstack state to restore */
int sc_mask; /* signal mask to restore */
int sc_pc; /* pc at time of signal */
int sc_regs[32]; /* processor regs 0 to 31 */
int mullo, mulhi; /* mullo and mulhi registers... */
int sc_fpused; /* fp has been used */
int sc_fpregs[33]; /* fp regs 0 to 31 and csr */
int sc_fpc_eir; /* floating point exception instruction reg */
int xxx[8]; /* XXX reserved */
};
#endif /* !_ANSI_SOURCE */

View File

@ -0,0 +1,64 @@
/* $NetBSD: stdarg.h,v 1.1.1.1 1996/03/13 04:58:09 jonathan Exp $ */
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* @(#)stdarg.h 8.1 (Berkeley) 6/10/93
*/
#ifndef _PMAX_STDARG_H_
#define _PMAX_STDARG_H_
#include <machine/ansi.h>
typedef _BSD_VA_LIST_ va_list;
#define __va_promote(type) \
(((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
#define va_start(ap, last) \
(ap = ((char *)&(last) + __va_promote(last)))
#ifdef _KERNEL
#define va_arg(ap, type) \
((type *)(ap += sizeof(type)))[-1]
#else
#define va_arg(ap, type) \
((type *)(ap += sizeof(type) == sizeof(int) ? sizeof(type) : \
sizeof(type) > sizeof(int) ? \
(-(int)(ap) & (sizeof(type) - 1)) + sizeof(type) : \
(abort(), 0)))[-1]
#endif
#define va_end(ap) ((void) 0)
#endif /* !_PMAX_STDARG_H_ */

View File

@ -0,0 +1,68 @@
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department and Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: Utah Hdr: trap.h 1.1 90/07/09
*
* from: @(#)trap.h 8.1 (Berkeley) 6/10/93
* $Id: trap.h,v 1.1.1.1 1996/03/13 04:58:09 jonathan Exp $
*/
/*
* Trap codes
* also known in trap.c for name strings
*/
#define T_INT 0 /* Interrupt pending */
#define T_TLB_MOD 1 /* TLB modified fault */
#define T_TLB_LD_MISS 2 /* TLB miss on load or ifetch */
#define T_TLB_ST_MISS 3 /* TLB miss on a store */
#define T_ADDR_ERR_LD 4 /* Address error on a load or ifetch */
#define T_ADDR_ERR_ST 5 /* Address error on a store */
#define T_BUS_ERR_IFETCH 6 /* Bus error on an ifetch */
#define T_BUS_ERR_LD_ST 7 /* Bus error on a load or store */
#define T_SYSCALL 8 /* System call */
#define T_BREAK 9 /* Breakpoint */
#define T_RES_INST 10 /* Reserved instruction exception */
#define T_COP_UNUSABLE 11 /* Coprocessor unusable */
#define T_OVFLOW 12 /* Arithmetic overflow */
#define T_TRAP 13 /* Trap instruction */
#define T_VCEI 14 /* Viritual coherency instruction */
#define T_FPE 15 /* Floating point exception */
#define T_WATCH 23 /* Watch address reference */
#define T_VCED 31 /* Viritual coherency data */
#define T_USER 0x20 /* user-mode flag or'ed with type */

View File

@ -0,0 +1,79 @@
/* $NetBSD: types.h,v 1.1.1.1 1996/03/13 04:58:09 jonathan Exp $ */
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* @(#)types.h 8.3 (Berkeley) 1/5/94
*/
#ifndef _MACHTYPES_H_
#define _MACHTYPES_H_
#include <sys/cdefs.h>
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
typedef struct _physadr {
int r[1];
} *physadr;
typedef struct label_t {
int val[12];
} label_t;
#endif
typedef unsigned long vm_offset_t;
typedef unsigned long vm_size_t;
/*
* Basic integral types. Omit the typedef if
* not possible for a machine/compiler combination.
*/
#define __BIT_TYPES_DEFINED__
typedef __signed char int8_t;
typedef unsigned char u_int8_t;
typedef short int16_t;
typedef unsigned short u_int16_t;
typedef int int32_t;
typedef unsigned int u_int32_t;
typedef long long int64_t;
typedef unsigned long long u_int64_t;
typedef int32_t register_t;
#define __BDEVSW_DUMP_OLD_TYPE
#define __SWAP_BROKEN
#define __FORK_BRAINDAMAGE
#endif /* _MACHTYPES_H_ */

View File

@ -0,0 +1,68 @@
/* $NetBSD: varargs.h,v 1.1.1.1 1996/03/13 04:58:09 jonathan Exp $ */
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
* All or some portions of this file are derived from material licensed
* to the University of California by American Telephone and Telegraph
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
* the permission of UNIX System Laboratories, Inc.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* @(#)varargs.h 8.2 (Berkeley) 3/22/94
*/
#ifndef _PMAX_VARARGS_H_
#define _PMAX_VARARGS_H_
#include <machine/ansi.h>
typedef _BSD_VA_LIST_ va_list;
#define va_dcl int va_alist; ...
#define va_start(ap) \
ap = (char *)&va_alist
#ifdef _KERNEL
#define va_arg(ap, type) \
((type *)(ap += sizeof(type)))[-1]
#else
#define va_arg(ap, type) \
((type *)(ap += sizeof(type) == sizeof(int) ? sizeof(type) : \
sizeof(type) > sizeof(int) ? \
(-(int)(ap) & (sizeof(type) - 1)) + sizeof(type) : \
(abort(), 0)))[-1]
#endif
#define va_end(ap) ((void) 0)
#endif /* !_PMAX_VARARGS_H_ */

View File

@ -0,0 +1,238 @@
/* $NetBSD: vmparam.h,v 1.1.1.1 1996/03/13 04:58:09 jonathan Exp $ */
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department and Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: Utah Hdr: vmparam.h 1.16 91/01/18
*
* @(#)vmparam.h 8.2 (Berkeley) 4/22/94
*/
/*
* Machine dependent constants for DEC Station 3100.
*/
/*
* USRTEXT is the start of the user text/data space, while USRSTACK
* is the top (end) of the user stack. LOWPAGES and HIGHPAGES are
* the number of pages from the beginning of the P0 region to the
* beginning of the text and from the beginning of the P1 region to the
* beginning of the stack respectively.
*/
#define USRTEXT 0x00001000
#define USRSTACK 0x80000000 /* Start of user stack */
#define BTOPUSRSTACK 0x80000 /* btop(USRSTACK) */
#define LOWPAGES 0x00001
#define HIGHPAGES 0
/*
* Virtual memory related constants, all in bytes
*/
#ifndef MAXTSIZ
#define MAXTSIZ (24*1024*1024) /* max text size */
#endif
#ifndef DFLDSIZ
#define DFLDSIZ (32*1024*1024) /* initial data size limit */
#endif
#ifndef MAXDSIZ
#define MAXDSIZ (32*1024*1024) /* max data size */
#endif
#ifndef DFLSSIZ
#define DFLSSIZ (1024*1024) /* initial stack size limit */
#endif
#ifndef MAXSSIZ
#define MAXSSIZ MAXDSIZ /* max stack size */
#endif
/*
* Default sizes of swap allocation chunks (see dmap.h).
* The actual values may be changed in vminit() based on MAXDSIZ.
* With MAXDSIZ of 16Mb and NDMAP of 38, dmmax will be 1024.
* DMMIN should be at least ctod(1) so that vtod() works.
* vminit() insures this.
*/
#define DMMIN 32 /* smallest swap allocation */
#define DMMAX 4096 /* largest potential swap allocation */
/*
* Sizes of the system and user portions of the system page table.
*/
/* SYSPTSIZE IS SILLY; (really number of buffers for I/O) */
#define SYSPTSIZE 1228
#define USRPTSIZE 1024
/*
* PTEs for mapping user space into the kernel for phyio operations.
* 16 pte's are enough to cover 8 disks * MAXBSIZE.
*/
#ifndef USRIOSIZE
#define USRIOSIZE 32
#endif
/*
* PTEs for system V style shared memory.
* This is basically slop for kmempt which we actually allocate (malloc) from.
*/
#ifndef SHMMAXPGS
#define SHMMAXPGS 1024 /* 4mb */
#endif
/*
* Boundary at which to place first MAPMEM segment if not explicitly
* specified. Should be a power of two. This allows some slop for
* the data segment to grow underneath the first mapped segment.
*/
#define MMSEG 0x200000
/*
* The size of the clock loop.
*/
#define LOOPPAGES (maxfree - firstfree)
/*
* The time for a process to be blocked before being very swappable.
* This is a number of seconds which the system takes as being a non-trivial
* amount of real time. You probably shouldn't change this;
* it is used in subtle ways (fractions and multiples of it are, that is, like
* half of a ``long time'', almost a long time, etc.)
* It is related to human patience and other factors which don't really
* change over time.
*/
#define MAXSLP 20
/*
* A swapped in process is given a small amount of core without being bothered
* by the page replacement algorithm. Basically this says that if you are
* swapped in you deserve some resources. We protect the last SAFERSS
* pages against paging and will just swap you out rather than paging you.
* Note that each process has at least UPAGES+CLSIZE pages which are not
* paged anyways (this is currently 8+2=10 pages or 5k bytes), so this
* number just means a swapped in process is given around 25k bytes.
* Just for fun: current memory prices are 4600$ a megabyte on VAX (4/22/81),
* so we loan each swapped in process memory worth 100$, or just admit
* that we don't consider it worthwhile and swap it out to disk which costs
* $30/mb or about $0.75.
*/
#define SAFERSS 4 /* nominal ``small'' resident set size
protected against replacement */
/*
* DISKRPM is used to estimate the number of paging i/o operations
* which one can expect from a single disk controller.
*/
#define DISKRPM 60
/*
* Klustering constants. Klustering is the gathering
* of pages together for pagein/pageout, while clustering
* is the treatment of hardware page size as though it were
* larger than it really is.
*
* KLMAX gives maximum cluster size in CLSIZE page (cluster-page)
* units. Note that ctod(KLMAX*CLSIZE) must be <= DMMIN in dmap.h.
* ctob(KLMAX) should also be less than MAXPHYS (in vm_swp.c)
* unless you like "big push" panics.
*/
#ifdef notdef /* XXX */
#define KLMAX (4/CLSIZE)
#define KLSEQL (2/CLSIZE) /* in klust if vadvise(VA_SEQL) */
#define KLIN (4/CLSIZE) /* default data/stack in klust */
#define KLTXT (4/CLSIZE) /* default text in klust */
#define KLOUT (4/CLSIZE)
#else
#define KLMAX (1/CLSIZE)
#define KLSEQL (1/CLSIZE)
#define KLIN (1/CLSIZE)
#define KLTXT (1/CLSIZE)
#define KLOUT (1/CLSIZE)
#endif
/*
* KLSDIST is the advance or retard of the fifo reclaim for sequential
* processes data space.
*/
#define KLSDIST 3 /* klusters advance/retard for seq. fifo */
/*
* Paging thresholds (see vm_sched.c).
* Strategy of 1/19/85:
* lotsfree is 512k bytes, but at most 1/4 of memory
* desfree is 200k bytes, but at most 1/8 of memory
*/
#define LOTSFREE (512 * 1024)
#define LOTSFREEFRACT 4
#define DESFREE (200 * 1024)
#define DESFREEFRACT 8
/*
* There are two clock hands, initially separated by HANDSPREAD bytes
* (but at most all of user memory). The amount of time to reclaim
* a page once the pageout process examines it increases with this
* distance and decreases as the scan rate rises.
*/
#define HANDSPREAD (2 * 1024 * 1024)
/*
* The number of times per second to recompute the desired paging rate
* and poke the pagedaemon.
*/
#define RATETOSCHEDPAGING 4
/*
* Believed threshold (in megabytes) for which interleaved
* swapping area is desirable.
*/
#define LOTSOFMEM 2
#define mapin(pte, v, pfnum, prot) \
(*(int *)(pte) = ((pfnum) << PG_SHIFT) | (prot), MachTLBFlushAddr(v))
/*
* Mach derived constants
*/
/* user/kernel map constants */
#define VM_MIN_ADDRESS ((vm_offset_t)0x00000000)
#define VM_MAXUSER_ADDRESS ((vm_offset_t)0x80000000)
#define VM_MAX_ADDRESS ((vm_offset_t)0x80000000)
#define VM_MIN_KERNEL_ADDRESS ((vm_offset_t)0xC0000000)
#define VM_MAX_KERNEL_ADDRESS ((vm_offset_t)0xFFFFC000)
/* virtual sizes (bytes) for various kernel submaps */
#define VM_MBUF_SIZE (NMBCLUSTERS*MCLBYTES)
#define VM_KMEM_SIZE (NKMEMCLUSTERS*CLBYTES)
#define VM_PHYS_SIZE (USRIOSIZE*CLBYTES)

147
sys/arch/pica/isa/isa.c Normal file
View File

@ -0,0 +1,147 @@
/* $NetBSD: isa.c,v 1.1.1.1 1996/03/13 04:58:09 jonathan Exp $ */
/*-
* Copyright (c) 1995 Per Fogelstrom
* Copyright (c) 1993, 1994 Charles Hannum.
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* William Jolitz and Don Ahn.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* @(#)isa.c 7.2 (Berkeley) 5/12/91
*/
/*
* Mach Operating System
* Copyright (c) 1991,1990,1989 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
Copyright 1988, 1989 by Intel Corporation, Santa Clara, California.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appears in all
copies and that both the copyright notice and this permission notice
appear in supporting documentation, and that the name of Intel
not be used in advertising or publicity pertaining to distribution
of the software without specific, written prior permission.
INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/time.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <machine/cpu.h>
#include <machine/pio.h>
#include <machine/autoconf.h>
#include <pica/pica/pica.h>
#include <dev/isa/isareg.h>
#include <dev/isa/isavar.h>
#include <pica/isa/timerreg.h>
#include <pica/isa/spkrreg.h>
extern int isa_io_base;
extern int isa_mem_base;
static int beeping;
#define isa_outb(x,y) outb(isa_io_base + (x), y)
#define isa_inb(x) inb(isa_io_base + (x))
void
sysbeepstop(arg)
void *arg;
{
int s;
/* disable counter 2 */
s = splhigh();
isa_outb(PITAUX_PORT, isa_inb(PITAUX_PORT) & ~PIT_SPKR);
splx(s);
beeping = 0;
}
void
sysbeep(pitch, period)
int pitch, period;
{
static int last_pitch, last_period;
int s;
if (beeping)
untimeout(sysbeepstop, 0);
if (!beeping || last_pitch != pitch) {
s = splhigh();
isa_outb(TIMER_MODE, TIMER_SEL2 | TIMER_16BIT | TIMER_SQWAVE);
isa_outb(TIMER_CNTR2, TIMER_DIV(pitch) % 256);
isa_outb(TIMER_CNTR2, TIMER_DIV(pitch) / 256);
isa_outb(PITAUX_PORT, isa_inb(PITAUX_PORT) | PIT_SPKR);
splx(s);
}
last_pitch = pitch;
beeping = last_period = period;
timeout(sysbeepstop, 0, period);
}

View File

@ -0,0 +1,11 @@
/* $NetBSD: spkrreg.h,v 1.1.1.1 1996/03/13 04:58:09 jonathan Exp $ */
/*
* PIT port addresses and speaker control values
*/
#define PITAUX_PORT 0x61 /* port of Programmable Peripheral Interface */
#define PIT_ENABLETMR2 0x01 /* Enable timer/counter 2 */
#define PIT_SPKRDATA 0x02 /* Direct to speaker */
#define PIT_SPKR (PIT_ENABLETMR2|PIT_SPKRDATA)

View File

@ -0,0 +1,100 @@
/* $NetBSD: timerreg.h,v 1.1.1.1 1996/03/13 04:58:09 jonathan Exp $ */
/*-
* Copyright (c) 1993 The Regents of the University of California.
* All rights reserved.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*/
/*
* Register definitions for the Intel 8253 Programmable Interval Timer.
*
* This chip has three independent 16-bit down counters that can be
* read on the fly. There are three mode registers and three countdown
* registers. The countdown registers are addressed directly, via the
* first three I/O ports. The three mode registers are accessed via
* the fourth I/O port, with two bits in the mode byte indicating the
* register. (Why are hardware interfaces always so braindead?).
*
* To write a value into the countdown register, the mode register
* is first programmed with a command indicating the which byte of
* the two byte register is to be modified. The three possibilities
* are load msb (TMR_MR_MSB), load lsb (TMR_MR_LSB), or load lsb then
* msb (TMR_MR_BOTH).
*
* To read the current value ("on the fly") from the countdown register,
* you write a "latch" command into the mode register, then read the stable
* value from the corresponding I/O port. For example, you write
* TMR_MR_LATCH into the corresponding mode register. Presumably,
* after doing this, a write operation to the I/O port would result
* in undefined behavior (but hopefully not fry the chip).
* Reading in this manner has no side effects.
*
* The outputs of the three timers are connected as follows:
*
* timer 0 -> irq 0
* timer 1 -> dma chan 0 (for dram refresh)
* timer 2 -> speaker (via keyboard controller)
*
* Timer 0 is used to call hardclock.
* Timer 2 is used to generate console beeps.
*/
/*
* Frequency of all three count-down timers; (TIMER_FREQ/freq) is the
* appropriate count to generate a frequency of freq hz.
*/
#ifndef TIMER_FREQ
#define TIMER_FREQ 1193182
#endif
#define TIMER_DIV(x) ((TIMER_FREQ+(x)/2)/(x))
/*
* Macros for specifying values to be written into a mode register.
*/
#define TIMER_CNTR0 (IO_TIMER1 + 0) /* timer 0 counter port */
#define TIMER_CNTR1 (IO_TIMER1 + 1) /* timer 1 counter port */
#define TIMER_CNTR2 (IO_TIMER1 + 2) /* timer 2 counter port */
#define TIMER_MODE (IO_TIMER1 + 3) /* timer mode port */
#define TIMER_SEL0 0x00 /* select counter 0 */
#define TIMER_SEL1 0x40 /* select counter 1 */
#define TIMER_SEL2 0x80 /* select counter 2 */
#define TIMER_INTTC 0x00 /* mode 0, intr on terminal cnt */
#define TIMER_ONESHOT 0x02 /* mode 1, one shot */
#define TIMER_RATEGEN 0x04 /* mode 2, rate generator */
#define TIMER_SQWAVE 0x06 /* mode 3, square wave */
#define TIMER_SWSTROBE 0x08 /* mode 4, s/w triggered strobe */
#define TIMER_HWSTROBE 0x0a /* mode 5, h/w triggered strobe */
#define TIMER_LATCH 0x00 /* latch counter for reading */
#define TIMER_LSB 0x10 /* r/w counter LSB */
#define TIMER_MSB 0x20 /* r/w counter MSB */
#define TIMER_16BIT 0x30 /* r/w counter 16 bits, LSB first */
#define TIMER_BCD 0x01 /* count in BCD */

View File

@ -0,0 +1,230 @@
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department and Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: Utah Hdr: autoconf.c 1.31 91/01/21
*
* from: @(#)autoconf.c 8.1 (Berkeley) 6/10/93
* $Id: autoconf.c,v 1.1.1.1 1996/03/13 04:58:10 jonathan Exp $
*/
/*
* Setup the system to run on the current machine.
*
* Configure() is called at boot time. Available
* devices are determined (from possibilities mentioned in ioconf.c),
* and the drivers are initialized.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/buf.h>
#include <sys/disklabel.h>
#include <sys/conf.h>
#include <sys/reboot.h>
#include <sys/device.h>
#include <machine/autoconf.h>
/*
* The following several variables are related to
* the configuration process, and are used in initializing
* the machine.
*/
int cold = 1; /* if 1, still working on cold-start */
int cpuspeed = 150; /* approx # instr per usec. */
extern int pica_boardtype;
/*
* Configure all devices found that we know about.
* This is done at boot time.
*/
configure()
{
(void)splhigh(); /* To be really shure.. */
if(config_rootfound("mainbus", "mainbus") == 0)
panic("no mainbus found");
(void)spl0();
#ifdef GENERIC
if ((boothowto & RB_ASKNAME) == 0)
setroot();
setconf();
#else
setroot();
#endif
swapconf();
cold = 0;
}
/*
* Configure swap space and related parameters.
*/
swapconf()
{
register struct swdevt *swp;
register int nblks;
for (swp = swdevt; swp->sw_dev != NODEV; swp++) {
if (bdevsw[major(swp->sw_dev)].d_psize) {
nblks =
(*bdevsw[major(swp->sw_dev)].d_psize)(swp->sw_dev);
if (nblks != -1 &&
(swp->sw_nblks == 0 || swp->sw_nblks > nblks))
swp->sw_nblks = nblks;
swp->sw_nblks = ctod(dtoc(swp->sw_nblks));
}
}
dumpconf();
}
#define DOSWAP /* Change swdevt and dumpdev too */
u_long bootdev; /* should be dev_t, but not until 32 bits */
static char devname[][2] = {
's','d', /* 0 = sd */
'x','x', /* 1 = unused */
'x','x', /* 2 = unused */
'x','x', /* 3 = unused */
'x','x', /* 4 = unused */
'x','x', /* 5 = unused */
'x','x', /* 6 = unused */
'f','d', /* 7 = floppy */
};
#define PARTITIONMASK 0x7
#define PARTITIONSHIFT 3
/*
* Attempt to find the device from which we were booted.
* If we can do so, and not instructed not to do so,
* change rootdev to correspond to the load device.
*/
setroot()
{
int majdev, mindev, unit, part, controller;
dev_t temp, orootdev;
struct swdevt *swp;
if (boothowto & RB_DFLTROOT ||
(bootdev & B_MAGICMASK) != B_DEVMAGIC)
return;
majdev = B_TYPE(bootdev);
if (majdev >= sizeof(devname) / sizeof(devname[0]))
return;
controller = B_CONTROLLER(bootdev);
part = B_PARTITION(bootdev);
unit = B_UNIT(bootdev);
mindev = (unit << PARTITIONSHIFT) + part;
orootdev = rootdev;
rootdev = makedev(majdev, mindev);
/*
* If the original rootdev is the same as the one
* just calculated, don't need to adjust the swap configuration.
*/
if (rootdev == orootdev)
return;
printf("changing root device to %c%c%d%c\n",
devname[majdev][0], devname[majdev][1],
unit, part + 'a');
#ifdef DOSWAP
for (swp = swdevt; swp->sw_dev != NODEV; swp++) {
if (majdev == major(swp->sw_dev) &&
(mindev / MAXPARTITIONS) == (minor(swp->sw_dev) / MAXPARTITIONS)) {
temp = swdevt[0].sw_dev;
swdevt[0].sw_dev = swp->sw_dev;
swp->sw_dev = temp;
break;
}
}
if (swp->sw_dev == NODEV)
return;
/*
* If dumpdev was the same as the old primary swap
* device, move it to the new primary swap device.
*/
if (temp == dumpdev)
dumpdev = swdevt[0].sw_dev;
#endif
}
/*
* Look at the string 'cp' and decode the boot device.
* Boot names look like: scsi()disk(n)rdisk()partition(1)\bsd
*/
void
makebootdev(cp)
char *cp;
{
int majdev, unit, part, ctrl;
char dv[8];
bootdev = B_DEVMAGIC;
dv[0] = *cp;
ctrl = getpno(&cp);
if(*cp++ == ')') {
dv[1] = *cp;
unit = getpno(&cp);
for (majdev = 0; majdev < sizeof(devname)/sizeof(devname[0]); majdev++)
if (dv[0] == devname[majdev][0] &&
dv[1] == devname[majdev][1] && cp[0] == ')')
bootdev = MAKEBOOTDEV(majdev, 0, ctrl, unit,0);
}
}
getpno(cp)
char **cp;
{
int val = 0;
char *cx = *cp;
while(*cx && *cx != '(')
cx++;
if(*cx == '(') {
cx++;
while(*cx && *cx != ')') {
val = val * 10 + *cx - '0';
cx++;
}
}
*cp = cx;
return val;
}

308
sys/arch/pica/pica/clock.c Normal file
View File

@ -0,0 +1,308 @@
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department and Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: Utah Hdr: clock.c 1.18 91/01/21
*
* from: @(#)clock.c 8.1 (Berkeley) 6/10/93
* $Id: clock.c,v 1.1.1.1 1996/03/13 04:58:10 jonathan Exp $
*/
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <machine/autoconf.h>
#include <machine/machConst.h>
#include <pica/pica/clockvar.h>
#include <pica/pica/picatype.h>
extern int cputype; /* What kind of cpu we are running on */
/* Definition of the driver for autoconfig. */
static int clockmatch __P((struct device *, void *, void *));
static void clockattach __P((struct device *, struct device *, void *));
struct cfdriver clockcd =
{ NULL, "clock", clockmatch, clockattach, DV_DULL,
sizeof(struct clock_softc) };
void mcclock_attach __P((struct device *, struct device *, void *));
#define SECMIN ((unsigned)60) /* seconds per minute */
#define SECHOUR ((unsigned)(60*SECMIN)) /* seconds per hour */
#define SECDAY ((unsigned)(24*SECHOUR)) /* seconds per day */
#define SECYR ((unsigned)(365*SECDAY)) /* seconds per common year */
#define LEAPYEAR(year) (((year) % 4) == 0)
static int
clockmatch(parent, cfdata, aux)
struct device *parent;
void *cfdata;
void *aux;
{
struct cfdata *cf = cfdata;
struct confargs *ca = aux;
/* See how many clocks this system has */
switch (cputype) {
case MIPS_PICA_61:
/* make sure that we're looking for this type of device. */
if (!BUS_MATCHNAME(ca, "dallas_rtc"))
return (0);
if (cf->cf_unit >= 1)
return (0);
break;
default:
panic("unknown CPU");
}
return (1);
}
static void
clockattach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
{
switch (cputype) {
case MIPS_PICA_61:
mcclock_attach(parent, self, aux);
break;
default:
panic("clockattach: it didn't get here. really.");
}
/*
* establish the clock interrupt; it's a special case
*/
BUS_INTR_ESTABLISH((struct confargs *)aux, hardclock, self);
printf("\n");
}
/*
* Wait "n" microseconds. This doesn't belong here. XXX.
*/
void
delay(n)
int n;
{
DELAY(n);
}
/*
* Machine-dependent clock routines.
*
* Startrtclock restarts the real-time clock, which provides
* hardclock interrupts to kern_clock.c.
*
* Inittodr initializes the time of day hardware which provides
* date functions. Its primary function is to use some file
* system information in case the hardare clock lost state.
*
* Resettodr restores the time of day hardware after a time change.
*/
/*
* Start the real-time and statistics clocks. Leave stathz 0 since there
* are no other timers available.
*/
cpu_initclocks()
{
extern int tickadj;
struct clock_softc *csc = (struct clock_softc *)clockcd.cd_devs[0];
hz = 100; /* 100 Hz */
tick = 1000000 / hz; /* number of micro-seconds between interrupts */
/*
* Start the clock.
*/
(*csc->sc_init)(csc);
}
/*
* We assume newhz is either stathz or profhz, and that neither will
* change after being set up above. Could recalculate intervals here
* but that would be a drag.
*/
void
setstatclockrate(newhz)
int newhz;
{
}
/*
* This code is defunct after 2099.
* Will Unix still be here then??
*/
static short dayyr[12] = {
0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
};
/*
* Initialze the time of day register, based on the time base which is, e.g.
* from a filesystem. Base provides the time to within six months,
* and the time of year clock (if any) provides the rest.
*/
void
inittodr(base)
time_t base;
{
struct tod_time c;
struct clock_softc *csc = (struct clock_softc *)clockcd.cd_devs[0];
register int days, yr;
long deltat;
int badbase, s;
if (base < 5*SECYR) {
printf("WARNING: preposterous time in file system");
/* read the system clock anyway */
base = 6*SECYR + 186*SECDAY + SECDAY/2;
badbase = 1;
} else
badbase = 0;
/* Read RTC chip registers */
(*csc->sc_get)(csc, base, &c);
csc->sc_initted = 1;
/* simple sanity checks */
c.year = c.year+80; /* must be multiple of 4 because chip knows leap */
if (c.year < 70 || c.mon < 1 || c.mon > 12 || c.day < 1 ||
c.day > 31 || c.hour > 23 || c.min > 59 || c.sec > 59) {
/*
* Believe the time in the file system for lack of
* anything better, resetting the TODR.
*/
time.tv_sec = base;
if (!badbase) {
printf("WARNING: preposterous clock chip time\n");
resettodr();
}
goto bad;
}
days = 0;
for (yr = 70; yr < c.year; yr++)
days += LEAPYEAR(yr) ? 366 : 365;
days += dayyr[c.mon - 1] + c.day - 1;
if (LEAPYEAR(yr) && c.mon > 2)
days++;
/* now have days since Jan 1, 1970; the rest is easy... */
time.tv_sec = days * SECDAY + c.hour * 3600 + c.min * 60 + c.sec;
if (!badbase) {
/*
* See if we gained/lost two or more days;
* if so, assume something is amiss.
*/
deltat = time.tv_sec - base;
if (deltat < 0)
deltat = -deltat;
if (deltat < 2 * SECDAY)
return;
printf("WARNING: clock %s %d days",
time.tv_sec < base ? "lost" : "gained", deltat / SECDAY);
}
bad:
printf(" -- CHECK AND RESET THE DATE!\n");
}
/*
* Reset the TODR based on the time value; used when the TODR
* has a preposterous value and also when the time is reset
* by the stime system call. Also called when the TODR goes past
* TODRZERO + 100*(SECYEAR+2*SECDAY) (e.g. on Jan 2 just after midnight)
* to wrap the TODR around.
*/
void
resettodr()
{
struct tod_time c;
struct clock_softc *csc = (struct clock_softc *)clockcd.cd_devs[0];
register int t, t2;
int s;
if(!csc->sc_initted)
return;
/* compute the day of week. 1 is Sunday*/
t2 = time.tv_sec / SECDAY;
c.dow = (t2 + 5) % 7; /* 1/1/1970 was thursday */
/* compute the year */
t2 = time.tv_sec / SECDAY;
c.year = 69;
while (t2 >= 0) { /* whittle off years */
t = t2;
c.year++;
t2 -= LEAPYEAR(c.year) ? 366 : 365;
}
/* t = month + day; separate */
t2 = LEAPYEAR(c.year);
for (c.mon = 1; c.mon < 12; c.mon++)
if (t < dayyr[c.mon] + (t2 && c.mon > 1))
break;
c.day = t - dayyr[c.mon - 1] + 1;
if (t2 && c.mon > 2)
c.day--;
/* the rest is easy */
t = time.tv_sec % SECDAY;
c.hour = t / 3600;
t %= 3600;
c.min = t / 60;
c.sec = t % 60;
c.year = c.year-80; /* must be multiple of 4 because chip knows leap */
(*csc->sc_set)(csc, &c);
}

View File

@ -0,0 +1,215 @@
/* $NetBSD: clock_mc.c,v 1.1.1.1 1996/03/13 04:58:10 jonathan Exp $ */
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department and Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: Utah Hdr: clock.c 1.18 91/01/21
*
* @(#)clock.c 8.1 (Berkeley) 6/10/93
*/
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <machine/autoconf.h>
#include <machine/pio.h>
#include <pica/pica/clockvar.h>
#include <pica/pica/picatype.h>
#include <pica/pica/pica.h>
#include <dev/ic/mc146818reg.h>
extern u_int cputype;
extern int cpu_int_mask;
void mcclock_attach __P((struct device *parent,
struct device *self, void *aux));
static void mcclock_init __P((struct clock_softc *csc));
static void mcclock_get __P((struct clock_softc *csc, time_t base,
struct tod_time *ct));
static void mcclock_set __P((struct clock_softc *csc,
struct tod_time *ct));
struct mcclockdata {
void (*mc_write) __P((struct clock_softc *csc, u_int reg,
u_int datum));
u_int (*mc_read) __P((struct clock_softc *csc, u_int reg));
void *mc_addr;
};
#define mc146818_write(sc, reg, datum) \
(*((struct mcclockdata *)sc->sc_data)->mc_write)(sc, reg, datum)
#define mc146818_read(sc, reg) \
(*((struct mcclockdata *)sc->sc_data)->mc_read)(sc, reg)
#if defined(MIPS_PICA_61)
static void mc_write_pica __P((struct clock_softc *csc, u_int reg,
u_int datum));
static u_int mc_read_pica __P((struct clock_softc *csc, u_int reg));
static struct mcclockdata mcclockdata_pica = { mc_write_pica, mc_read_pica };
#endif
void
mcclock_attach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
{
struct clock_softc *csc = (struct clock_softc *)self;
register volatile struct chiptime *c;
struct confargs *ca = aux;
printf(": mc146818 or compatible");
csc->sc_init = mcclock_init;
csc->sc_get = mcclock_get;
csc->sc_set = mcclock_set;
switch (cputype) {
case MIPS_PICA_61:
/*
* XXX should really allocate a new one and copy, or
* something. unlikely we'll have more than one...
*/
csc->sc_data = &mcclockdata_pica;
mcclockdata_pica.mc_addr = BUS_CVTADDR(ca);
break;
default:
printf("\n");
panic("don't know how to set up for other system types.");
}
/* Turn interrupts off, just in case. */
mc146818_write(csc, MC_REGB, MC_REGB_BINARY | MC_REGB_24HR);
}
static void
mcclock_init(csc)
struct clock_softc *csc;
{
/* XXX Does not really belong here but for the moment we don't care */
out32(PICA_SYS_IT_VALUE, 9); /* 10ms - 1 */
/* Enable periodic clock interrupt */
out32(PICA_SYS_EXT_IMASK, cpu_int_mask);
}
/*
* Get the time of day, based on the clock's value and/or the base value.
*/
static void
mcclock_get(csc, base, ct)
struct clock_softc *csc;
time_t base;
struct tod_time *ct;
{
mc_todregs regs;
int s;
s = splclock();
MC146818_GETTOD(csc, &regs)
splx(s);
ct->sec = regs[MC_SEC];
ct->min = regs[MC_MIN];
ct->hour = regs[MC_HOUR];
ct->dow = regs[MC_DOW];
ct->day = regs[MC_DOM];
ct->mon = regs[MC_MONTH];
ct->year = regs[MC_YEAR];
}
/*
* Reset the TODR based on the time value.
*/
static void
mcclock_set(csc, ct)
struct clock_softc *csc;
struct tod_time *ct;
{
mc_todregs regs;
int s;
s = splclock();
MC146818_GETTOD(csc, &regs);
splx(s);
regs[MC_SEC] = ct->sec;
regs[MC_MIN] = ct->min;
regs[MC_HOUR] = ct->hour;
regs[MC_DOW] = ct->dow;
regs[MC_DOM] = ct->day;
regs[MC_MONTH] = ct->mon;
regs[MC_YEAR] = ct->year;
s = splclock();
MC146818_PUTTOD(csc, &regs);
splx(s);
}
#if defined(ACER_PICA_61)
static void
mc_write_pica(csc, reg, datum)
struct clock_softc *csc;
u_int reg, datum;
{
int i,as;
as = in32(PICA_SYS_ISA_AS) & 0x80;
out32(PICA_SYS_ISA_AS, as | reg);
outb(PICA_SYS_CLOCK, datum);
}
static u_int
mc_read_pica(csc, reg)
struct clock_softc *csc;
u_int reg;
{
int i,as;
as = in32(PICA_SYS_ISA_AS) & 0x80;
out32(PICA_SYS_ISA_AS, as | reg);
i = inb(PICA_SYS_CLOCK);
return(i);
}
#endif /*ACER_PICA_61*/

View File

@ -0,0 +1,78 @@
/* $NetBSD: clockvar.h,v 1.1.1.1 1996/03/13 04:58:10 jonathan Exp $ */
/*
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
* Adopted for r4400: Per Fogelstrom
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
/*
* Definitions for "cpu-independent" clock handling for the r4400.
*/
/*
* clocktime structure:
*
* structure passed to TOY clocks when setting them. broken out this
* way, so that the time_t -> field conversion can be shared.
*/
struct tod_time {
int year; /* year - 1900 */
int mon; /* month (1 - 12) */
int day; /* day (1 - 31) */
int hour; /* hour (0 - 23) */
int min; /* minute (0 - 59) */
int sec; /* second (0 - 59) */
int dow; /* day of week (0 - 6; 0 = Sunday) */
};
/*
* clockdesc structure:
*
* provides clock-specific functions to do necessary operations.
*/
struct clock_softc {
struct device sc_dev;
/*
* The functions that all types of clock provide.
*/
void (*sc_attach) __P((struct device *parent, struct device *self,
void *aux));
void (*sc_init) __P((struct clock_softc *csc));
void (*sc_get) __P((struct clock_softc *csc, time_t base,
struct tod_time *ct));
void (*sc_set) __P((struct clock_softc *csc, struct tod_time *ct));
/*
* Private storage for particular clock types.
*/
void *sc_data;
/*
* Has the time been initialized?
*/
int sc_initted;
};

341
sys/arch/pica/pica/conf.c Normal file
View File

@ -0,0 +1,341 @@
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: @(#)conf.c 8.2 (Berkeley) 11/14/93
* $Id: conf.c,v 1.1.1.1 1996/03/13 04:58:10 jonathan Exp $
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/buf.h>
#include <sys/ioctl.h>
#include <sys/proc.h>
#include <sys/vnode.h>
#include <sys/tty.h>
#include <sys/conf.h>
int ttselect __P((dev_t, int, struct proc *));
/*
* Block devices.
*/
#include "vnd.h"
bdev_decl(vnd);
bdev_decl(sw);
#include "sd.h"
bdev_decl(sd);
#include "cd.h"
bdev_decl(cd);
#include "fdc.h"
#define fdopen Fdopen
bdev_decl(fd);
#undef fdopen
struct bdevsw bdevsw[] =
{
bdev_disk_init(NSD,sd), /* 0: SCSI disk */
bdev_swap_init(1,sw), /* 1: should be here swap pseudo-dev */
bdev_disk_init(NVND,vnd), /* 2: vnode disk driver */
bdev_disk_init(NCD,cd), /* 3: SCSI CD-ROM */
bdev_notdef(), /* 4: */
bdev_notdef(), /* 5: */
bdev_notdef(), /* 6: */
#define fdopen Fdopen
bdev_disk_init(NFDC,fd), /* 7: Floppy disk driver */
#undef fdopen
bdev_notdef(), /* 8: */
bdev_notdef(), /* 9: */
bdev_notdef(), /* 10: */
bdev_notdef(), /* 11: */
bdev_notdef(), /* 12: */
bdev_notdef(), /* 13: */
bdev_notdef(), /* 14: */
bdev_notdef(), /* 15: */
};
int nblkdev = sizeof (bdevsw) / sizeof (bdevsw[0]);
/*
* Character devices.
*/
/* open, close, read, write, ioctl, tty, mmap */
#define cdev_pc_init(c,n) { \
dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
dev_init(c,n,write), dev_init(c,n,ioctl), dev_init(c,n,stop), \
dev_init(c,n,tty), ttselect, dev_init(c,n,mmap), D_TTY }
/* open, close, write, ioctl */
#define cdev_lpt_init(c,n) { \
dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
0, seltrue, (dev_type_mmap((*))) enodev }
/* open, close, write, ioctl */
#define cdev_spkr_init(c,n) { \
dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
0, seltrue, (dev_type_mmap((*))) enodev }
cdev_decl(cn);
cdev_decl(sw);
cdev_decl(ctty);
#define mmread mmrw
#define mmwrite mmrw
dev_type_read(mmrw);
cdev_decl(mm);
#include "pty.h"
#define ptstty ptytty
#define ptsioctl ptyioctl
cdev_decl(pts);
#define ptctty ptytty
#define ptcioctl ptyioctl
cdev_decl(ptc);
cdev_decl(log);
cdev_decl(fd);
#include "st.h"
cdev_decl(st);
#include "fdc.h"
#define fdopen Fdopen
bdev_decl(fd);
#undef fdopen
cdev_decl(vnd);
#include "bpfilter.h"
cdev_decl(bpf);
#include "com.h"
cdev_decl(com);
#include "lpt.h"
cdev_decl(lpt);
cdev_decl(sd);
#include "pc.h"
cdev_decl(pc);
cdev_decl(pms);
cdev_decl(cd);
/* open, close, read, ioctl */
cdev_decl(ipl);
#define cdev_gen_ipf(c,n) { \
dev_init(c,n,open), dev_init(c,n,close), dev_init(c,n,read), \
(dev_type_write((*))) enodev, dev_init(c,n,ioctl), \
(dev_type_stop((*))) nullop, 0, (dev_type_select((*))) enodev, \
(dev_type_mmap((*))) enodev, 0 }
#ifdef IPFILTER
#define NIPF 1
#else
#define NIPF 0
#endif
struct cdevsw cdevsw[] =
{
cdev_cn_init(1,cn), /* 0: virtual console */
cdev_swap_init(1,sw), /* 1: /dev/drum (swap pseudo-device) */
cdev_ctty_init(1,ctty), /* 2: controlling terminal */
cdev_mm_init(1,mm), /* 3: /dev/{null,mem,kmem,...} */
cdev_tty_init(NPTY,pts), /* 4: pseudo-tty slave */
cdev_ptc_init(NPTY,ptc), /* 5: pseudo-tty master */
cdev_log_init(1,log), /* 6: /dev/klog */
cdev_fd_init(1,fd), /* 7: file descriptor pseudo-dev */
cdev_disk_init(NCD,cd), /* 8: SCSI CD */
cdev_disk_init(NSD,sd), /* 9: SCSI disk */
cdev_tape_init(NST,st), /* 10: SCSI tape */
cdev_disk_init(NVND,vnd), /* 11: vnode disk */
cdev_bpftun_init(NBPFILTER,bpf),/* 12: berkeley packet filter */
#define fdopen Fdopen
cdev_disk_init(NFDC,fd), /* 13: Floppy disk */
#undef fdopen
cdev_pc_init(1,pc), /* 14: builtin pc style console dev */
cdev_mouse_init(1,pms), /* 15: builtin PS2 style mouse */
cdev_lpt_init(NLPT,lpt), /* 16: lpt paralell printer interface */
cdev_tty_init(NCOM,com), /* 17: com 16C450 serial interface */
cdev_notdef(), /* 18: */
cdev_notdef(), /* 19: */
cdev_tty_init(NPTY,pts), /* 20: pseudo-tty slave */
cdev_ptc_init(NPTY,ptc), /* 21: pseudo-tty master */
cdev_notdef(), /* 22: */
cdev_notdef(), /* 23: */
cdev_notdef(), /* 24: */
cdev_notdef(), /* 25: */
cdev_notdef(), /* 26: */
cdev_notdef(), /* 27: */
cdev_notdef(), /* 28: */
cdev_notdef(), /* 29: */
cdev_notdef(), /* 30: */
cdev_gen_ipf(NIPF,ipl), /* 31: IP filter log */
};
int nchrdev = sizeof (cdevsw) / sizeof (cdevsw[0]);
int mem_no = 2; /* major device number of memory special file */
/*
* Swapdev is a fake device implemented
* in sw.c used only internally to get to swstrategy.
* It cannot be provided to the users, because the
* swstrategy routine munches the b_dev and b_blkno entries
* before calling the appropriate driver. This would horribly
* confuse, e.g. the hashing routines. Instead, /dev/drum is
* provided as a character (raw) device.
*/
dev_t swapdev = makedev(1, 0);
/*
* Routine that identifies /dev/mem and /dev/kmem.
*
* A minimal stub routine can always return 0.
*/
iskmemdev(dev)
dev_t dev;
{
#ifdef COMPAT_BSD44
if (major(dev) == 2 && (minor(dev) == 0 || minor(dev) == 1))
#else
if (major(dev) == 3 && (minor(dev) == 0 || minor(dev) == 1))
#endif
return (1);
return (0);
}
/*
* Returns true if def is /dev/zero
*/
iszerodev(dev)
dev_t dev;
{
#ifdef COMPAT_BSD44
return (major(dev) == 2 && minor(dev) == 12);
#else
return (major(dev) == 3 && minor(dev) == 12);
#endif
}
#define MAXDEV 57
static int chrtoblktbl[MAXDEV] = {
/* VCHR */ /* VBLK */
/* 0 */ NODEV,
/* 1 */ NODEV,
/* 2 */ NODEV,
/* 3 */ NODEV,
/* 4 */ NODEV,
/* 5 */ NODEV,
/* 6 */ NODEV,
/* 7 */ NODEV,
/* 8 */ NODEV,
/* 9 */ 0,
/* 10 */ NODEV,
/* 11 */ 2,
/* 12 */ NODEV,
/* 13 */ 7,
/* 14 */ NODEV,
/* 15 */ NODEV,
/* 16 */ NODEV,
/* 17 */ NODEV,
/* 18 */ NODEV,
/* 19 */ NODEV,
/* 20 */ NODEV,
/* 21 */ NODEV,
/* 22 */ NODEV,
/* 23 */ NODEV,
/* 24 */ NODEV,
/* 25 */ NODEV,
/* 26 */ NODEV,
/* 27 */ NODEV,
/* 28 */ NODEV,
/* 29 */ NODEV,
/* 30 */ NODEV,
/* 31 */ NODEV,
/* 32 */ NODEV,
/* 33 */ NODEV,
/* 34 */ NODEV,
/* 35 */ NODEV,
/* 36 */ NODEV,
/* 37 */ NODEV,
/* 38 */ NODEV,
/* 39 */ NODEV,
/* 40 */ NODEV,
/* 41 */ NODEV,
/* 42 */ NODEV,
/* 43 */ NODEV,
/* 44 */ NODEV,
/* 45 */ NODEV,
/* 46 */ NODEV,
/* 47 */ NODEV,
/* 48 */ NODEV,
/* 49 */ NODEV,
/* 50 */ NODEV,
/* 51 */ NODEV,
/* 52 */ NODEV,
/* 53 */ NODEV,
/* 54 */ NODEV,
/* 55 */ NODEV,
/* 56 */ NODEV,
};
/*
* Routine to convert from character to block device number.
*
* A minimal stub routine can always return NODEV.
*/
chrtoblk(dev)
dev_t dev;
{
int blkmaj;
if (major(dev) >= MAXDEV || (blkmaj = chrtoblktbl[major(dev)]) == NODEV)
return (NODEV);
return (makedev(blkmaj, minor(dev)));
}
/*
* This entire table could be autoconfig()ed but that would mean that
* the kernel's idea of the console would be out of sync with that of
* the standalone boot. I think it best that they both use the same
* known algorithm unless we see a pressing need otherwise.
*/
#include <dev/cons.h>
cons_decl(pc);
cons_decl(com);
struct consdev constab[] = {
#if NPC + NVT > 0
cons_init(pc),
#endif
#if NCOM > 0
cons_init(com),
#endif
{ 0 },
};

183
sys/arch/pica/pica/cpu.c Normal file
View File

@ -0,0 +1,183 @@
/* $NetBSD: cpu.c,v 1.1.1.1 1996/03/13 04:58:10 jonathan Exp $ */
/*
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Per Fogelstrom
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#include <sys/param.h>
#include <sys/device.h>
#include <machine/cpu.h>
#include <machine/autoconf.h>
/* Definition of the driver for autoconfig. */
static int cpumatch(struct device *, void *, void *);
static void cpuattach(struct device *, struct device *, void *);
struct cfdriver cpucd =
{ NULL, "cpu", cpumatch, cpuattach, DV_DULL, sizeof (struct device) };
static int cpuprint __P((void *, char *pnp));
static int
cpumatch(parent, cfdata, aux)
struct device *parent;
void *cfdata;
void *aux;
{
struct cfdata *cf = cfdata;
struct confargs *ca = aux;
/* make sure that we're looking for a CPU. */
if (strcmp(ca->ca_name, cpucd.cd_name) != 0)
return (0);
return (1);
}
static void
cpuattach(parent, dev, aux)
struct device *parent;
struct device *dev;
void *aux;
{
struct pcs *p;
int needcomma, needrev, i;
printf(": ");
switch(cpu_id.cpu.cp_imp) {
case MIPS_R2000:
printf("MIPS R2000 CPU");
break;
case MIPS_R3000:
printf("MIPS R3000 CPU");
break;
case MIPS_R6000:
printf("MIPS R6000 CPU");
break;
case MIPS_R4000:
if(machPrimaryInstCacheSize == 16384)
printf("MIPS R4400 CPU");
else
printf("MIPS R4000 CPU");
break;
case MIPS_R3LSI:
printf("LSI Logic R3000 derivate");
break;
case MIPS_R6000A:
printf("MIPS R6000A CPU");
break;
case MIPS_R3IDT:
printf("IDT R3000 derivate");
break;
case MIPS_R10000:
printf("MIPS R10000/T5 CPU");
break;
case MIPS_R4200:
printf("MIPS R4200 CPU (ICE)");
break;
case MIPS_R8000:
printf("MIPS R8000 Blackbird/TFP CPU");
break;
case MIPS_R4600:
printf("QED R4600 Orion CPU");
break;
case MIPS_R3SONY:
printf("Sony R3000 based CPU");
break;
case MIPS_R3TOSH:
printf("Toshiba R3000 based CPU");
break;
case MIPS_R3NKK:
printf("NKK R3000 based CPU");
break;
case MIPS_UNKC1:
case MIPS_UNKC2:
default:
printf("Unknown CPU type (0x%x)",cpu_id.cpu.cp_imp);
break;
}
printf(" Rev. %d.%d with ", cpu_id.cpu.cp_majrev, cpu_id.cpu.cp_minrev);
switch(fpu_id.cpu.cp_imp) {
case MIPS_SOFT:
printf("Software emulation float");
break;
case MIPS_R2360:
printf("MIPS R2360 FPC");
break;
case MIPS_R2010:
printf("MIPS R2010 FPC");
break;
case MIPS_R3010:
printf("MIPS R3010 FPC");
break;
case MIPS_R6010:
printf("MIPS R6010 FPC");
break;
case MIPS_R4010:
printf("MIPS R4010 FPC");
break;
case MIPS_R31LSI:
printf("FPC");
break;
case MIPS_R10010:
printf("MIPS R10000/T5 FPU");
break;
case MIPS_R4210:
printf("MIPS R4200 FPC (ICE)");
case MIPS_R8000:
printf("MIPS R8000 Blackbird/TFP");
break;
case MIPS_R4600:
printf("QED R4600 Orion FPC");
break;
case MIPS_R3SONY:
printf("Sony R3000 based FPC");
break;
case MIPS_R3TOSH:
printf("Toshiba R3000 based FPC");
break;
case MIPS_R3NKK:
printf("NKK R3000 based FPC");
break;
case MIPS_UNKF1:
default:
printf("Unknown FPU type (0x%x)", fpu_id.cpu.cp_imp);
break;
}
printf(" Rev. %d.%d", fpu_id.cpu.cp_majrev, fpu_id.cpu.cp_minrev);
printf("\n");
printf(" Primary cache size: %dkb Instruction, %dkb Data.\n",
machPrimaryInstCacheSize / 1024,
machPrimaryDataCacheSize / 1024);
}

View File

@ -0,0 +1,157 @@
/* $NetBSD: cpu_exec.c,v 1.1.1.1 1996/03/13 04:58:10 jonathan Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by Ralph
* Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* @(#)machdep.c 8.3 (Berkeley) 1/12/94
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/malloc.h>
#include <sys/vnode.h>
#include <sys/exec.h>
#include <sys/resourcevar.h>
#include <vm/vm.h>
#include <sys/exec_ecoff.h>
#ifdef COMPAT_09
#include <machine/bsd-aout.h>
#endif
#include <machine/reg.h>
/*
* cpu_exec_aout_makecmds():
* cpu-dependent a.out format hook for execve().
*
* Determine of the given exec package refers to something which we
* understand and, if so, set up the vmcmds for it.
*
*/
int
cpu_exec_aout_makecmds(p, epp)
struct proc *p;
struct exec_package *epp;
{
/* If COMPAT_09 is defined, allow loading of old-style 4.4bsd a.out
executables. */
#ifdef COMPAT_09
struct bsd_aouthdr *hdr = (struct bsd_aouthdr *)epp -> ep_hdr;
/* Only handle paged files (laziness). */
if (hdr -> a_magic != BSD_ZMAGIC)
#endif
/* If it's not a.out, maybe it's ELF. (This wants to
be moved up to the machine independent code as soon
as possible.) XXX */
return pmax_elf_makecmds (p, epp);
#ifdef COMPAT_09
epp -> ep_taddr = 0x1000;
epp -> ep_entry = hdr -> a_entry;
epp -> ep_tsize = hdr -> a_text;
epp -> ep_daddr = epp -> ep_taddr + hdr -> a_text;
epp -> ep_dsize = hdr -> a_data + hdr -> a_bss;
/*
* check if vnode is in open for writing, because we want to
* demand-page out of it. if it is, don't do it, for various
* reasons
*/
if ((hdr -> a_text != 0 || hdr -> a_data != 0)
&& epp->ep_vp->v_writecount != 0) {
#ifdef DIAGNOSTIC
if (epp->ep_vp->v_flag & VTEXT)
panic("exec: a VTEXT vnode has writecount != 0\n");
#endif
return ETXTBSY;
}
epp->ep_vp->v_flag |= VTEXT;
/* set up command for text segment */
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, hdr -> a_text,
epp->ep_taddr, epp->ep_vp, 0, VM_PROT_READ|VM_PROT_EXECUTE);
/* set up command for data segment */
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, hdr -> a_data,
epp->ep_daddr, epp->ep_vp, hdr -> a_text,
VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
/* set up command for bss segment */
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, hdr -> a_bss,
epp->ep_daddr + hdr -> a_data, NULLVP, 0,
VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
return exec_aout_setup_stack(p, epp);
#endif
}
#ifdef COMPAT_ULTRIX
extern struct emul emul_ultrix;
void
cpu_exec_ecoff_setregs(p, pack, stack, retval)
struct proc *p;
struct exec_package *pack;
u_long stack;
register_t *retval;
{
struct ecoff_aouthdr *eap;
setregs(p, pack, stack, retval);
eap = (struct ecoff_aouthdr *)
((caddr_t)pack->ep_hdr + sizeof(struct ecoff_filehdr));
p->p_md.md_regs[GP] = eap->ea_gp_value;
}
/*
* cpu_exec_ecoff_hook():
* cpu-dependent ECOFF format hook for execve().
*
* Do any machine-dependent diddling of the exec package when doing ECOFF.
*
*/
int
cpu_exec_ecoff_hook(p, epp, eap)
struct proc *p;
struct exec_package *epp;
struct ecoff_aouthdr *eap;
{
epp->ep_emul = &emul_ultrix;
return 0;
}
#endif

View File

@ -0,0 +1,339 @@
/* $NetBSD: disksubr.c,v 1.1.1.1 1996/03/13 04:58:10 jonathan Exp $ */
/*
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
* All rights reserved.
*
* Authors: Keith Bostic, Chris G. Demetriou, Per Fogelstrom (R4000)
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#include <sys/param.h>
#include <sys/buf.h>
#include <sys/ioccom.h>
#include <sys/device.h>
#include <sys/disklabel.h>
#include <sys/disk.h>
#include <scsi/scsi_all.h>
#include <scsi/scsiconf.h>
#include <machine/cpu.h>
#include <machine/autoconf.h>
extern struct device *bootdv;
/* was this the boot device ? */
int
dk_establish(dk, dev)
struct disk *dk;
struct device *dev;
{
#ifdef NOTDEF
/* XXX: sd -> scsibus -> esp */
struct bootpath *bp = ((struct esp_softc *)dev->dv_parent->dv_parent)->sc_bp;
char name[10];
#define CRAZYMAP(v) ((v) == 3 ? 0 : (v) == 0 ? 3 : (v))
if (bp == NULL) {
printf("no boot path\n");
return -1;
}
sprintf(name, "%s%d", bp->name, CRAZYMAP(bp->val[0]));
if (strcmp(name, dev->dv_xname) == 0) {
bootdv = dev;
}
#endif
return 1;
}
/*
* Attempt to read a disk label from a device
* using the indicated stategy routine.
* The label must be partly set up before this:
* secpercyl and anything required in the strategy routine
* (e.g., sector size) must be filled in before calling us.
* Returns null on success and an error string on failure.
*/
char *
readdisklabel(dev, strat, lp, clp)
dev_t dev;
void (*strat)();
struct disklabel *lp;
struct cpu_disklabel *clp;
{
struct buf *bp;
struct disklabel *dlp;
struct dos_partition *dp = clp->dosparts;
char *msg = NULL;
int dospartoff = 0;
int i;
/* minimal requirements for archtypal disk label */
if (lp->d_secperunit == 0)
lp->d_secperunit = 0x1fffffff;
lp->d_npartitions = RAW_PART + 1;
for(i = 0; i < RAW_PART; i++) {
lp->d_partitions[i].p_size = 0;
lp->d_partitions[i].p_offset = 0;
}
if (lp->d_partitions[RAW_PART].p_size == 0)
lp->d_partitions[RAW_PART].p_size = 0x1fffffff;
lp->d_partitions[RAW_PART].p_offset = 0;
/* obtain buffer to probe drive with */
bp = geteblk((int)lp->d_secsize);
bp->b_dev = dev;
/* do dos partitions in the process of getting disklabel? */
if (dp) {
/* read master boot record */
bp->b_blkno = DOSBBSECTOR;
bp->b_bcount = lp->d_secsize;
bp->b_flags = B_BUSY | B_READ;
bp->b_resid = 0;
(*strat)(bp);
/* if successful, wander through dos partition table */
if (biowait(bp)) {
msg = "dos partition I/O error";
goto done;
} else if (*(unsigned int *)(bp->b_data) == 0x8ec033fa) {
/* XXX how do we check veracity/bounds of this? */
bcopy(bp->b_data + DOSPARTOFF, dp, NDOSPART * sizeof(*dp));
for (i = 0; i < NDOSPART; i++, dp++) {
/* is this ours? */
if (dp->dp_size && dp->dp_typ == DOSPTYP_386BSD
&& dospartoff == 0) {
dospartoff = dp->dp_start;
/* set part a to show NetBSD part */
lp->d_partitions[0].p_size = dp->dp_size;
lp->d_partitions[0].p_offset = dp->dp_start;
lp->d_ntracks = dp->dp_ehd + 1;
lp->d_nsectors = DPSECT(dp->dp_esect);
lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
}
}
}
}
/* next, dig out disk label */
bp->b_blkno = dospartoff + LABELSECTOR;
bp->b_resid = 0;
bp->b_bcount = lp->d_secsize;
bp->b_flags = B_BUSY | B_READ;
(*strat)(bp);
/* if successful, locate disk label within block and validate */
if (biowait(bp)) {
msg = "disk label read error";
goto done;
}
dlp = (struct disklabel *)(bp->b_un.b_addr + LABELOFFSET);
if (dlp->d_magic == DISKMAGIC) {
if (dkcksum(dlp)) {
msg = "NetBSD disk label corrupted";
goto done;
}
*lp = *dlp;
goto done;
}
msg = "no disk label";
done:
bp->b_flags = B_INVAL | B_AGE | B_READ;
brelse(bp);
return (msg);
}
/*
* Check new disk label for sensibility before setting it.
*/
int
setdisklabel(olp, nlp, openmask, clp)
register struct disklabel *olp, *nlp;
u_long openmask;
struct cpu_disklabel *clp;
{
register i;
register struct partition *opp, *npp;
/* sanity clause */
if (nlp->d_secpercyl == 0 || nlp->d_secsize == 0 ||
(nlp->d_secsize % DEV_BSIZE) != 0)
return(EINVAL);
#ifdef notdef
/* XXX WHY WAS THIS HERE?! */
/* special case to allow disklabel to be invalidated */
if (nlp->d_magic == 0xffffffff) {
*olp = *nlp;
return (0);
}
#endif
if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
dkcksum(nlp) != 0)
return (EINVAL);
while ((i = ffs((long)openmask)) != 0) {
i--;
openmask &= ~(1 << i);
if (nlp->d_npartitions <= i)
return (EBUSY);
opp = &olp->d_partitions[i];
npp = &nlp->d_partitions[i];
if (npp->p_offset != opp->p_offset || npp->p_size < opp->p_size)
return (EBUSY);
/*
* Copy internally-set partition information
* if new label doesn't include it. XXX
*/
if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) {
npp->p_fstype = opp->p_fstype;
npp->p_fsize = opp->p_fsize;
npp->p_frag = opp->p_frag;
npp->p_cpg = opp->p_cpg;
}
}
nlp->d_checksum = 0;
nlp->d_checksum = dkcksum(nlp);
*olp = *nlp;
return (0);
}
/*
* Write disk label back to device after modification.
* this means write out the Rigid disk blocks to represent the
* label. Hope the user was carefull.
*/
int
writedisklabel(dev, strat, lp, clp)
dev_t dev;
void (*strat)();
register struct disklabel *lp;
struct cpu_disklabel *clp;
{
struct buf *bp;
struct disklabel *dlp;
struct dos_partition *dp = clp->dosparts;
int error = 0, i;
int dospartoff = 0;
bp = geteblk((int)lp->d_secsize);
bp->b_dev = dev;
/* do dos partitions in the process of getting disklabel? */
if (dp) {
/* read master boot record */
bp->b_blkno = DOSBBSECTOR;
bp->b_bcount = lp->d_secsize;
bp->b_flags = B_BUSY | B_READ;
bp->b_resid = 0;
(*strat)(bp);
if (((error = biowait(bp)) == 0)
&& *(unsigned int *)(bp->b_data) == 0x8ec033fa) {
/* XXX how do we check veracity/bounds of this? */
bcopy(bp->b_data + DOSPARTOFF, dp, NDOSPART * sizeof(*dp));
for (i = 0; i < NDOSPART; i++, dp++) {
/* is this ours? */
if (dp->dp_size && dp->dp_typ == DOSPTYP_386BSD
&& dospartoff == 0) {
dospartoff = dp->dp_start;
}
}
}
}
bp->b_blkno = dospartoff + LABELSECTOR;
bp->b_resid = 0;
bp->b_bcount = lp->d_secsize;
bp->b_flags = B_READ; /* get current label */
(*strat)(bp);
if (error = biowait(bp))
goto done;
dlp = (struct disklabel *)(bp->b_un.b_addr + LABELOFFSET);
*dlp = *lp; /* struct assignment */
bp->b_flags = B_WRITE;
(*strat)(bp);
error = biowait(bp);
done:
brelse(bp);
return (error);
}
/*
* Determine the size of the transfer, and make sure it is
* within the boundaries of the partition. Adjust transfer
* if needed, and signal errors or early completion.
*/
int
bounds_check_with_label(bp, lp, wlabel)
struct buf *bp;
struct disklabel *lp;
int wlabel;
{
#define dkpart(dev) (minor(dev) & 7)
struct partition *p = lp->d_partitions + dkpart(bp->b_dev);
int labelsect = lp->d_partitions[RAW_PART].p_offset;
int maxsz = p->p_size;
int sz = (bp->b_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT;
/* overwriting disk label ? */
/* XXX should also protect bootstrap in first 8K */
if (bp->b_blkno + p->p_offset == LABELSECTOR + labelsect &&
(bp->b_flags & B_READ) == 0 && wlabel == 0) {
bp->b_error = EROFS;
goto bad;
}
/* beyond partition? */
if (bp->b_blkno < 0 || bp->b_blkno + sz > maxsz) {
/* if exactly at end of disk, return an EOF */
if (bp->b_blkno == maxsz) {
bp->b_resid = bp->b_bcount;
return(0);
}
/* or truncate if part of it fits */
sz = maxsz - bp->b_blkno;
if (sz <= 0) {
bp->b_error = EINVAL;
goto bad;
}
bp->b_bcount = sz << DEV_BSHIFT;
}
/* calculate cylinder for disksort to order transfers with */
bp->b_resid = (bp->b_blkno + p->p_offset) / lp->d_secpercyl;
return(1);
bad:
bp->b_flags |= B_ERROR;
return(-1);
}

194
sys/arch/pica/pica/elf.c Normal file
View File

@ -0,0 +1,194 @@
/* $NetBSD: elf.c,v 1.1.1.1 1996/03/13 04:58:10 jonathan Exp $ */
/*
* Copyright (c) 1994 Ted Lemon
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/filedesc.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/mount.h>
#include <sys/malloc.h>
#include <sys/namei.h>
#include <sys/vnode.h>
#include <sys/file.h>
#include <sys/acct.h>
#include <sys/resourcevar.h>
#include <vm/vm.h>
#include <sys/exec.h>
#include <machine/elf.h>
/* pmax_elf_makecmds (p, epp)
Test if an executable is a MIPS ELF executable. If it is,
try to load it. */
pmax_elf_makecmds (p, epp)
struct proc *p;
struct exec_package *epp;
{
struct ehdr *ex = (struct ehdr *)epp -> ep_hdr;
struct phdr ph;
int i, error, resid;
/* Make sure we got enough data to check magic numbers... */
if (epp -> ep_hdrvalid < sizeof (struct ehdr)) {
#ifdef DIAGNOSTIC
if (epp -> ep_hdrlen < sizeof (struct ehdr))
printf ("pmax_elf_makecmds: execsw hdrsize too short!\n");
#endif
return ENOEXEC;
}
/* See if it's got the basic elf magic number leadin... */
if (ex -> elf_magic [0] != 127
|| bcmp ("ELF", &ex -> elf_magic [1], 3)) {
return ENOEXEC;
}
/* XXX: Check other magic numbers here. */
/* See if we got any program header information... */
if (!ex -> phoff || !ex -> phcount) {
return ENOEXEC;
}
/* Set the entry point... */
epp -> ep_entry = ex -> entry;
/*
* Check if vnode is open for writing, because we want to
* demand-page out of it. If it is, don't do it.
*/
if (epp->ep_vp->v_writecount != 0) {
#ifdef DIAGNOSTIC
if (epp->ep_vp->v_flag & VTEXT)
panic("exec: a VTEXT vnode has writecount != 0\n");
#endif
return ETXTBSY;
}
epp->ep_vp->v_flag |= VTEXT;
epp->ep_taddr = 0;
epp->ep_tsize = 0;
epp->ep_daddr = 0;
epp->ep_dsize = 0;
for (i = 0; i < ex -> phcount; i++) {
if (error = vn_rdwr(UIO_READ, epp -> ep_vp, (caddr_t)&ph,
sizeof ph, ex -> phoff + i * sizeof ph,
UIO_SYSSPACE, IO_NODELOCKED,
p->p_ucred, &resid, p))
return error;
if (resid != 0) {
return ENOEXEC;
}
/* We only care about loadable sections... */
if (ph.type == PT_LOAD) {
int prot = VM_PROT_READ | VM_PROT_EXECUTE;
int residue;
unsigned vaddr, offset, length;
vaddr = ph.vaddr;
offset = ph.offset;
length = ph.filesz;
residue = ph.memsz - ph.filesz;
if (ph.flags & PF_W) {
prot |= VM_PROT_WRITE;
if (!epp->ep_daddr || vaddr < epp -> ep_daddr)
epp->ep_daddr = vaddr;
epp->ep_dsize += ph.memsz;
/* Read the data from the file... */
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn,
length, vaddr,
epp->ep_vp, offset, prot);
if (residue) {
vaddr &= ~(NBPG - 1);
offset &= ~(NBPG - 1);
length = roundup (length + ph.vaddr
- vaddr, NBPG);
residue = (ph.vaddr + ph.memsz)
- (vaddr + length);
}
} else {
vaddr &= ~(NBPG - 1);
offset &= ~(NBPG - 1);
length = roundup (length + ph.vaddr - vaddr,
NBPG);
residue = (ph.vaddr + ph.memsz)
- (vaddr + length);
if (!epp->ep_taddr || vaddr < epp -> ep_taddr)
epp->ep_taddr = vaddr;
epp->ep_tsize += ph.memsz;
/* Map the data from the file... */
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn,
length, vaddr,
epp->ep_vp, offset, prot);
}
/* If part of the segment is just zeros (e.g., bss),
map that. */
if (residue > 0) {
NEW_VMCMD (&epp->ep_vmcmds, vmcmd_map_zero,
residue, vaddr + length,
NULLVP, 0, prot);
}
}
}
epp->ep_maxsaddr = USRSTACK - MAXSSIZ;
epp->ep_minsaddr = USRSTACK;
epp->ep_ssize = p->p_rlimit[RLIMIT_STACK].rlim_cur;
/*
* set up commands for stack. note that this takes *two*, one to
* map the part of the stack which we can access, and one to map
* the part which we can't.
*
* arguably, it could be made into one, but that would require the
* addition of another mapping proc, which is unnecessary
*
* note that in memory, things assumed to be: 0 ....... ep_maxsaddr
* <stack> ep_minsaddr
*/
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero,
((epp->ep_minsaddr - epp->ep_ssize) - epp->ep_maxsaddr),
epp->ep_maxsaddr, NULLVP, 0, VM_PROT_NONE);
NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, epp->ep_ssize,
(epp->ep_minsaddr - epp->ep_ssize), NULLVP, 0,
VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
return 0;
}

3610
sys/arch/pica/pica/fp.S Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,74 @@
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: @(#)genassym.c 8.2 (Berkeley) 9/23/93
* $Id: genassym.c,v 1.1.1.1 1996/03/13 04:58:11 jonathan Exp $
*/
#define _KERNEL
#include <sys/param.h>
#include <sys/buf.h>
#include <sys/map.h>
#include <sys/proc.h>
#include <sys/mbuf.h>
#include <sys/user.h>
#include <machine/reg.h>
main()
{
register struct proc *p = (struct proc *)0;
register struct user *up = (struct user *)0;
register struct vmmeter *vm = (struct vmmeter *)0;
register int size, s, n;
printf("#define\tP_FORW %d\n", &p->p_forw);
printf("#define\tP_BACK %d\n", &p->p_back);
printf("#define\tP_PRIORITY %d\n", &p->p_priority);
printf("#define\tP_ADDR %d\n", &p->p_addr);
printf("#define\tP_UPTE %d\n", p->p_md.md_upte);
printf("#define\tU_PCB_REGS %d\n", up->u_pcb.pcb_regs);
printf("#define\tU_PCB_FPREGS %d\n", &up->u_pcb.pcb_regs[F0]);
printf("#define\tU_PCB_CONTEXT %d\n", &up->u_pcb.pcb_context);
printf("#define\tU_PCB_ONFAULT %d\n", &up->u_pcb.pcb_onfault);
printf("#define\tU_PCB_SEGTAB %d\n", &up->u_pcb.pcb_segtab);
printf("#define\tVM_MIN_ADDRESS 0x%x\n", VM_MIN_ADDRESS);
printf("#define\tVM_MIN_KERNEL_ADDRESS 0x%x\n", VM_MIN_KERNEL_ADDRESS);
printf("#define\tV_SWTCH %d\n", &vm->v_swtch);
printf("#define\tSIGILL %d\n", SIGILL);
printf("#define\tSIGFPE %d\n", SIGFPE);
exit(0);
}

3176
sys/arch/pica/pica/locore.S Normal file

File diff suppressed because it is too large Load Diff

1155
sys/arch/pica/pica/machdep.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,168 @@
/* $NetBSD: mainbus.c,v 1.1.1.1 1996/03/13 04:58:12 jonathan Exp $ */
/*
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/reboot.h>
#include <pica/pica/picatype.h>
#include <machine/autoconf.h>
struct mainbus_softc {
struct device sc_dv;
struct abus sc_bus;
};
/* Definition of the mainbus driver. */
static int mbmatch __P((struct device *, void *, void *));
static void mbattach __P((struct device *, struct device *, void *));
static int mbprint __P((void *, char *));
struct cfdriver mainbuscd =
{ NULL, "mainbus", mbmatch, mbattach, DV_DULL,
sizeof (struct mainbus_softc) };
void mb_intr_establish __P((struct confargs *, int (*)(void *), void *));
void mb_intr_disestablish __P((struct confargs *));
caddr_t mb_cvtaddr __P((struct confargs *));
int mb_matchname __P((struct confargs *, char *));
static int
mbmatch(parent, cfdata, aux)
struct device *parent;
void *cfdata;
void *aux;
{
struct cfdata *cf = cfdata;
/*
* Only one mainbus, but some people are stupid...
*/
if (cf->cf_unit > 0)
return(0);
/*
* That one mainbus is always here.
*/
return(1);
}
static void
mbattach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
{
struct mainbus_softc *sc = (struct mainbus_softc *)self;
struct confargs nca;
extern int cputype, ncpus;
printf("\n");
sc->sc_bus.ab_dv = (struct device *)sc;
sc->sc_bus.ab_type = BUS_MAIN;
sc->sc_bus.ab_intr_establish = mb_intr_establish;
sc->sc_bus.ab_intr_disestablish = mb_intr_disestablish;
sc->sc_bus.ab_cvtaddr = mb_cvtaddr;
sc->sc_bus.ab_matchname = mb_matchname;
/*
* Try to find and attach all of the CPUs in the machine.
* ( Right now only one CPU so code is simple )
*/
nca.ca_name = "cpu";
nca.ca_slot = 0;
nca.ca_offset = 0;
nca.ca_bus = &sc->sc_bus;
config_found(self, &nca, mbprint);
if (cputype == ACER_PICA_61) {
/* we have a PICA bus! */
nca.ca_name = "pica";
nca.ca_slot = 0;
nca.ca_offset = 0;
nca.ca_bus = &sc->sc_bus;
config_found(self, &nca, mbprint);
}
if (cputype == ACER_PICA_61) {
/* we have an ISA bus! */
nca.ca_name = "isa";
nca.ca_slot = 0;
nca.ca_offset = 0;
nca.ca_bus = &sc->sc_bus;
config_found(self, &nca, mbprint);
}
}
static int
mbprint(aux, pnp)
void *aux;
char *pnp;
{
if (pnp)
return (QUIET);
return (UNCONF);
}
void
mb_intr_establish(ca, handler, val)
struct confargs *ca;
int (*handler) __P((void *));
void *val;
{
panic("can never mb_intr_establish");
}
void
mb_intr_disestablish(ca)
struct confargs *ca;
{
panic("can never mb_intr_disestablish");
}
caddr_t
mb_cvtaddr(ca)
struct confargs *ca;
{
return (NULL);
}
int
mb_matchname(ca, name)
struct confargs *ca;
char *name;
{
return (strcmp(name, ca->ca_name) == 0);
}

169
sys/arch/pica/pica/mem.c Normal file
View File

@ -0,0 +1,169 @@
/* $NetBSD: mem.c,v 1.1.1.1 1996/03/13 04:58:12 jonathan Exp $ */
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1982, 1986, 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department and Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* @(#)mem.c 8.3 (Berkeley) 1/12/94
*/
/*
* Memory special file
*/
#include <sys/param.h>
#include <sys/conf.h>
#include <sys/buf.h>
#include <sys/systm.h>
#include <sys/uio.h>
#include <sys/malloc.h>
#include <machine/cpu.h>
#include <vm/vm.h>
extern vm_offset_t avail_end;
caddr_t zeropage;
/*ARGSUSED*/
int
mmopen(dev, flag, mode)
dev_t dev;
int flag, mode;
{
return (0);
}
/*ARGSUSED*/
int
mmclose(dev, flag, mode)
dev_t dev;
int flag, mode;
{
return (0);
}
/*ARGSUSED*/
int
mmrw(dev, uio, flags)
dev_t dev;
struct uio *uio;
int flags;
{
register vm_offset_t o, v;
register int c;
register struct iovec *iov;
int error = 0;
while (uio->uio_resid > 0 && error == 0) {
iov = uio->uio_iov;
if (iov->iov_len == 0) {
uio->uio_iov++;
uio->uio_iovcnt--;
if (uio->uio_iovcnt < 0)
panic("mmrw");
continue;
}
switch (minor(dev)) {
/* minor device 0 is physical memory */
case 0:
v = uio->uio_offset;
c = iov->iov_len;
if (v + c > ctob(physmem))
return (EFAULT);
v += MACH_CACHED_MEMORY_ADDR;
error = uiomove((caddr_t)v, c, uio);
continue;
/* minor device 1 is kernel memory */
case 1:
v = uio->uio_offset;
c = min(iov->iov_len, MAXPHYS);
if (v < MACH_CACHED_MEMORY_ADDR)
return (EFAULT);
if (v + c > MACH_PHYS_TO_CACHED(avail_end) &&
(v < MACH_KSEG2_ADDR ||
!kernacc((caddr_t)v, c,
uio->uio_rw == UIO_READ ? B_READ : B_WRITE)))
return (EFAULT);
error = uiomove((caddr_t)v, c, uio);
continue;
/* minor device 2 is EOF/RATHOLE */
case 2:
if (uio->uio_rw == UIO_WRITE)
uio->uio_resid = 0;
return (0);
/* minor device 12 (/dev/zero) is source of nulls on read, rathole on write */
case 12:
if (uio->uio_rw == UIO_WRITE) {
c = iov->iov_len;
break;
}
if (zeropage == NULL) {
zeropage = (caddr_t)
malloc(CLBYTES, M_TEMP, M_WAITOK);
bzero(zeropage, CLBYTES);
}
c = min(iov->iov_len, CLBYTES);
error = uiomove(zeropage, c, uio);
continue;
default:
return (ENXIO);
}
if (error)
break;
iov->iov_base += c;
iov->iov_len -= c;
uio->uio_offset += c;
uio->uio_resid -= c;
}
return (error);
}
int
mmmmap(dev, off, prot)
dev_t dev;
int off, prot;
{
return (EOPNOTSUPP);
}

File diff suppressed because it is too large Load Diff

317
sys/arch/pica/pica/pica.c Normal file
View File

@ -0,0 +1,317 @@
/* $NetBSD: pica.c,v 1.1.1.1 1996/03/13 04:58:12 jonathan Exp $ */
/*
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Chris G. Demetriou
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#include <sys/param.h>
#include <sys/device.h>
#include <machine/cpu.h>
#include <machine/pio.h>
#include <machine/autoconf.h>
#include <pica/pica/pica.h>
#include <pica/pica/picatype.h>
struct pica_softc {
struct device sc_dv;
struct abus sc_bus;
struct pica_dev *sc_devs;
};
/* Definition of the driver for autoconfig. */
int picamatch(struct device *, void *, void *);
void picaattach(struct device *, struct device *, void *);
int picaprint(void *, char *);
struct cfdriver picacd =
{ NULL, "pica", picamatch, picaattach, DV_DULL, sizeof (struct pica_softc) };
void pica_intr_establish __P((struct confargs *, int (*)(void *), void *));
void pica_intr_disestablish __P((struct confargs *));
caddr_t pica_cvtaddr __P((struct confargs *));
int pica_matchname __P((struct confargs *, char *));
int pica_iointr __P((void *));
int pica_clkintr __P((unsigned, unsigned, unsigned, unsigned));
extern int cputype;
/*
* Interrupt dispatch table.
*/
struct pica_int_desc int_table[] = {
{0, pica_intrnull, (void *)NULL, 0 }, /* 0 */
{0, pica_intrnull, (void *)NULL, 0 }, /* 1 */
{0, pica_intrnull, (void *)NULL, 0 }, /* 2 */
{0, pica_intrnull, (void *)NULL, 0 }, /* 3 */
{0, pica_intrnull, (void *)NULL, 0 }, /* 4 */
{0, pica_intrnull, (void *)NULL, 0 }, /* 5 */
{0, pica_intrnull, (void *)NULL, 0 }, /* 6 */
{0, pica_intrnull, (void *)NULL, 0 }, /* 7 */
{0, pica_intrnull, (void *)NULL, 0 }, /* 8 */
{0, pica_intrnull, (void *)NULL, 0 }, /* 9 */
{0, pica_intrnull, (void *)NULL, 0 }, /* 10 */
{0, pica_intrnull, (void *)NULL, 0 }, /* 11 */
{0, pica_intrnull, (void *)NULL, 0 }, /* 12 */
{0, pica_intrnull, (void *)NULL, 0 }, /* 13 */
{0, pica_intrnull, (void *)NULL, 0 }, /* 14 */
{0, pica_intrnull, (void *)NULL, 0 }, /* 15 */
};
struct pica_dev {
struct confargs ps_ca;
u_int ps_mask;
intr_handler_t ps_handler;
void *ps_base;
};
#ifdef ACER_PICA_61
struct pica_dev acer_pica_61_cpu[] = {
{{ "dallas_rtc",0, 0, },
0, pica_intrnull, (void *)PICA_SYS_CLOCK, },
{{ "lpt", 1, 0, },
PICA_SYS_LB_IE_PAR1, pica_intrnull, (void *)PICA_SYS_PAR1, },
{{ "fdc", 2, 0, },
PICA_SYS_LB_IE_FLOPPY,pica_intrnull, (void *)PICA_SYS_FLOPPY, },
{{ NULL, 3, NULL, },
0, pica_intrnull, (void *)NULL, },
{{ NULL, 4, NULL, },
0, pica_intrnull, (void *)NULL, },
{{ "sonic", 5, 0, },
PICA_SYS_LB_IE_SONIC, pica_intrnull, (void *)PICA_SYS_SONIC, },
{{ "asc", 6, 0, },
PICA_SYS_LB_IE_SCSI, pica_intrnull, (void *)PICA_SYS_SCSI, },
{{ "pc", 7, 0, },
PICA_SYS_LB_IE_KBD, pica_intrnull, (void *)PICA_SYS_KBD, },
{{ "pms", 8, NULL, },
PICA_SYS_LB_IE_MOUSE, pica_intrnull, (void *)PICA_SYS_KBD, },
{{ "com", 9, 0, },
PICA_SYS_LB_IE_COM1, pica_intrnull, (void *)PICA_SYS_COM1, },
{{ "com", 10, 0, },
PICA_SYS_LB_IE_COM2, pica_intrnull, (void *)PICA_SYS_COM2, },
{{ NULL, -1, NULL, },
0, NULL, (void *)NULL, },
};
#endif
struct pica_dev *pica_cpu_devs[] = {
NULL, /* Unused */
#ifdef ACER_PICA_61
acer_pica_61_cpu, /* Acer PICA */
#else
NULL,
#endif
};
int npica_cpu_devs = sizeof pica_cpu_devs / sizeof pica_cpu_devs[0];
int local_int_mask = 0; /* Local interrupt enable mask */
int
picamatch(parent, cfdata, aux)
struct device *parent;
void *cfdata;
void *aux;
{
struct cfdata *cf = cfdata;
struct confargs *ca = aux;
/* Make sure that we're looking for a PICA. */
if (strcmp(ca->ca_name, picacd.cd_name) != 0)
return (0);
/* Make sure that unit exists. */
if (cf->cf_unit != 0 ||
cputype > npica_cpu_devs || pica_cpu_devs[cputype] == NULL)
return (0);
return (1);
}
void
picaattach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
{
struct pica_softc *sc = (struct pica_softc *)self;
struct confargs *nca;
int i;
printf("\n");
/* keep our CPU device description handy */
sc->sc_devs = pica_cpu_devs[cputype];
/* set up interrupt handlers */
set_intr(MACH_INT_MASK_1, pica_iointr, 2);
sc->sc_bus.ab_dv = (struct device *)sc;
sc->sc_bus.ab_type = BUS_PICA;
sc->sc_bus.ab_intr_establish = pica_intr_establish;
sc->sc_bus.ab_intr_disestablish = pica_intr_disestablish;
sc->sc_bus.ab_cvtaddr = pica_cvtaddr;
sc->sc_bus.ab_matchname = pica_matchname;
/* Initialize PICA Dma */
picaDmaInit();
/* Try to configure each PICA attached device */
for (i = 0; sc->sc_devs[i].ps_ca.ca_slot >= 0; i++) {
if(sc->sc_devs[i].ps_ca.ca_name == NULL)
continue; /* Empty slot */
nca = &sc->sc_devs[i].ps_ca;
nca->ca_bus = &sc->sc_bus;
/* Tell the autoconfig machinery we've found the hardware. */
config_found(self, nca, picaprint);
}
}
int
picaprint(aux, pnp)
void *aux;
char *pnp;
{
struct confargs *ca = aux;
if (pnp)
printf("%s at %s", ca->ca_name, pnp);
printf(" slot %ld offset 0x%lx", ca->ca_slot, ca->ca_offset);
return (UNCONF);
}
caddr_t
pica_cvtaddr(ca)
struct confargs *ca;
{
struct pica_softc *sc = picacd.cd_devs[0];
return(sc->sc_devs[ca->ca_slot].ps_base + ca->ca_offset);
}
void
pica_intr_establish(ca, handler, val)
struct confargs *ca;
intr_handler_t handler;
void *val;
{
struct pica_softc *sc = picacd.cd_devs[0];
int slot;
slot = ca->ca_slot;
if(slot == 0) { /* Slot 0 is special, clock */
set_intr(MACH_INT_MASK_4, pica_clkintr, 1);
}
if(int_table[slot].int_mask != 0) {
panic("pica intr already set");
}
else {
int_table[slot].int_mask = sc->sc_devs[slot].ps_mask;;
local_int_mask |= int_table[slot].int_mask;
int_table[slot].int_hand = handler;
int_table[slot].param = val;
}
out16(PICA_SYS_LB_IE, local_int_mask);
}
void
pica_intr_disestablish(ca)
struct confargs *ca;
{
struct pica_softc *sc = picacd.cd_devs[0];
int slot;
slot = ca->ca_slot;
if(slot = 0) { /* Slot 0 is special, clock */
}
else {
local_int_mask &= ~int_table[slot].int_mask;
int_table[slot].int_mask = 0;
int_table[slot].int_hand = pica_intrnull;
int_table[slot].param = (void *)NULL;
}
}
int
pica_matchname(ca, name)
struct confargs *ca;
char *name;
{
return (strcmp(name, ca->ca_name) == 0);
}
int
pica_intrnull(val)
void *val;
{
panic("uncaught PICA intr for slot %d\n", val);
}
/*
* Handle pica i/o interrupt.
*/
int
pica_iointr(val)
void *val;
{
int vector;
while((vector = inb(PVIS) >> 2) != 0) {
(*int_table[vector].int_hand)(int_table[vector].param);
}
return(~0); /* Dont reenable */
}
/*
* Handle pica interval clock interrupt.
*/
int
pica_clkintr(mask, pc, statusReg, causeReg)
unsigned mask;
unsigned pc;
unsigned statusReg;
unsigned causeReg;
{
struct clockframe cf;
int temp;
temp = inw(PICA_SYS_IT_STAT);
cf.pc = pc;
cf.sr = statusReg;
hardclock(&cf);
/* Re-enable clock interrupts */
splx(MACH_INT_MASK_4 | MACH_SR_INT_ENAB);
return(~MACH_INT_MASK_4); /* Keep clock interrupts enabled */
}

166
sys/arch/pica/pica/pica.h Normal file
View File

@ -0,0 +1,166 @@
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* The Mach Operating System project at Carnegie-Mellon University,
* Ralph Campbell and Rick Macklem.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: @(#)pica.h 8.1 (Berkeley) 6/10/93
* $Id: pica.h,v 1.1.1.1 1996/03/13 04:58:12 jonathan Exp $
*/
/*
* HISTORY
* Log: pica.h,v
* Created, from the ALI specs:
*/
/*
* File: pica.h
* Author: Per Fogelstrom
* Date: 1/95
*
*/
#ifndef MIPS_PICA_H
#define MIPS_PICA_H 1
/*
* PICA's Physical address space
*/
#define PICA_PHYS_MIN 0x00000000 /* 256 Meg */
#define PICA_PHYS_MAX 0x0fffffff
/*
* Memory map
*/
#define PICA_PHYS_MEMORY_START 0x00000000
#define PICA_PHYS_MEMORY_END 0x0fffffff /* 256 Meg in 8 slots */
#define PICA_MEMORY_SIZE_REG 0xe00fffe0 /* Memory size register */
#define PICA_CONFIG_REG 0xe00ffff0 /* Hardware config reg */
/*
* I/O map
*/
#define PICA_P_LOCAL_IO_BASE 0x80000000 /* I/O Base address */
#define PICA_V_LOCAL_IO_BASE 0xe0000000
#define PICA_S_LOCAL_IO_BASE 0x00040000 /* Size */
#define PVLB PICA_V_LOCAL_IO_BASE
#define PICA_SYS_TL_BASE (PVLB+0x0018) /* DMA transl. table base */
#define PICA_SYS_TL_LIMIT (PVLB+0x0020) /* DMA transl. table limit */
#define PICA_SYS_TL_IVALID (PVLB+0x0028) /* DMA transl. cache inval */
#define PICA_SYS_DMA0_REGS (PVLB+0x0100) /* DMA ch0 base address */
#define PICA_SYS_DMA1_REGS (PVLB+0x0120) /* DMA ch0 base address */
#define PICA_SYS_DMA2_REGS (PVLB+0x0140) /* DMA ch0 base address */
#define PICA_SYS_DMA3_REGS (PVLB+0x0160) /* DMA ch0 base address */
#define PICA_SYS_IT_VALUE (PVLB+0x0228) /* Interval timer reload */
#define PICA_SYS_IT_STAT (PVLB+0x0230) /* Interval timer count */
#define PICA_SYS_EXT_IMASK (PVLB+0x00e8) /* External int enable mask */
#define PICA_SYS_SONIC (PVLB+0x1000) /* SONIC base address */
#define PICA_SYS_SCSI (PVLB+0x2000) /* SCSI base address */
#define PICA_SYS_FLOPPY (PVLB+0x3000) /* Floppy base address */
#define PICA_SYS_CLOCK (PVLB+0x4000) /* Clock base address */
#define PICA_SYS_KBD (PVLB+0x5000) /* Keybrd/mouse base address */
#define PICA_SYS_COM1 (PVLB+0x6000) /* Com port 1 */
#define PICA_SYS_COM2 (PVLB+0x7000) /* Com port 2 */
#define PICA_SYS_PAR1 (PVLB+0x8000) /* Parallel port 1 */
#define PICA_SYS_NVRAM (PVLB+0x9000) /* Unprotected NV-ram */
#define PICA_SYS_PNVRAM (PVLB+0xa000) /* Protected NV-ram */
#define PICA_SYS_NVPROM (PVLB+0xb000) /* Read only NV-ram */
#define PICA_SYS_SOUND (PVLB+0xc000) /* Sound port */
#define PICA_SYS_ISA_AS (PICA_V_ISA_IO+0x70)
#define PICA_P_DRAM_CONF 0x800e0000 /* Dram config registers */
#define PICA_V_DRAM_CONF 0xe00e0000
#define PICA_S_DRAM_CONF 0x00020000
#define PICA_P_INT_SOURCE 0xf0000000 /* Interrupt src registers */
#define PICA_V_INT_SOURCE PICA_V_LOCAL_IO_BASE+PICA_S_LOCAL_IO_BASE
#define PICA_S_INT_SOURCE 0x00001000
#define PVIS PICA_V_INT_SOURCE
#define PICA_SYS_LB_IS (PVIS+0x0000) /* Local bus int source */
#define PICA_SYS_LB_IE (PVIS+0x0002) /* Local bus int enables */
#define PICA_SYS_LB_IE_PAR1 0x0001 /* Parallel port enable */
#define PICA_SYS_LB_IE_FLOPPY 0x0002 /* Floppy ctrl enable */
#define PICA_SYS_LB_IE_SOUND 0x0004 /* Sound port enable */
#define PICA_SYS_LB_IE_VIDEO 0x0008 /* Video int enable */
#define PICA_SYS_LB_IE_SONIC 0x0010 /* Ethernet ctrl enable */
#define PICA_SYS_LB_IE_SCSI 0x0020 /* Scsi crtl enable */
#define PICA_SYS_LB_IE_KBD 0x0040 /* Keyboard ctrl enable */
#define PICA_SYS_LB_IE_MOUSE 0x0080 /* Mouse ctrl enable */
#define PICA_SYS_LB_IE_COM1 0x0100 /* Serial port 1 enable */
#define PICA_SYS_LB_IE_COM2 0x0200 /* Serial port 2 enable */
#define PICA_P_LOCAL_VIDEO_CTRL 0x60000000 /* Local video control */
#define PICA_V_LOCAL_VIDEO_CTRL 0xe0200000
#define PICA_S_LOCAL_VIDEO_CTRL 0x00200000
#define PICA_P_EXTND_VIDEO_CTRL 0x60200000 /* Extended video control */
#define PICA_V_EXTND_VIDEO_CTRL 0xe0400000
#define PICA_S_EXTND_VIDEO_CTRL 0x00200000
#define PICA_P_LOCAL_VIDEO 0x40000000 /* Local video memory */
#define PICA_V_LOCAL_VIDEO 0xe0800000
#define PICA_S_LOCAL_VIDEO 0x00800000
#define PICA_P_ISA_IO 0x90000000 /* ISA I/O control */
#define PICA_V_ISA_IO 0xe2000000
#define PICA_S_ISA_IO 0x01000000
#define PICA_P_ISA_MEM 0x91000000 /* ISA Memory control */
#define PICA_V_ISA_MEM 0xe3000000
#define PICA_S_ISA_MEM 0x01000000
/*
* Addresses used by various display drivers.
*/
#define MONO_BASE (PICA_V_LOCAL_VIDEO_CTRL + 0x3B4)
#define MONO_BUF (PICA_V_LOCAL_VIDEO + 0xB0000)
#define CGA_BASE (PICA_V_LOCAL_VIDEO_CTRL + 0x3D4)
#define CGA_BUF (PICA_V_LOCAL_VIDEO + 0xB8000)
/*
* Interrupt vector descriptor for device on pica bus.
*/
struct pica_int_desc {
int int_mask; /* Mask used in PICA_SYS_LB_IE */
intr_handler_t int_hand; /* Interrupt handler */
void *param; /* Parameter to send to handler */
int spl_mask; /* Spl mask for interrupt */
};
int pica_intrnull __P((void *));
#endif /* MIPS_PICA_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,45 @@
/*-
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* The Mach Operating System project at Carnegie-Mellon University,
* Ralph Campbell and Rick Macklem.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: @(#)picatype.h 8.1 (Berkeley) 6/10/93
* $Id: picatype.h,v 1.1.1.1 1996/03/13 04:58:12 jonathan Exp $
*/
/*
* Mother board type byte of "systype" environment variable.
*/
#define MIPS_PICA_61 0x1 /* Acer Labs Pica 61 */
#define ACER_PICA_61 0x1 /* Acer Labs Pica 61 */

1626
sys/arch/pica/pica/pmap.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,113 @@
/*
* Copyright (c) 1994 Adam Glass
* Copyright (c) 1993 The Regents of the University of California.
* Copyright (c) 1993 Jan-Simon Pendry
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Jan-Simon Pendry.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* From:
* Id: procfs_i386.c,v 4.1 1993/12/17 10:47:45 jsp Rel
*
* $Id: process_machdep.c,v 1.1.1.1 1996/03/13 04:58:13 jonathan Exp $
*/
/*
* This file may seem a bit stylized, but that so that it's easier to port.
* Functions to be implemented here are:
*
* process_read_regs(proc, regs)
* Get the current user-visible register set from the process
* and copy it into the regs structure (<machine/reg.h>).
* The process is stopped at the time read_regs is called.
*
* process_write_regs(proc, regs)
* Update the current register set from the passed in regs
* structure. Take care to avoid clobbering special CPU
* registers or privileged bits in the PSL.
* The process is stopped at the time write_regs is called.
*
* process_sstep(proc)
* Arrange for the process to trap after executing a single instruction.
*
* process_set_pc(proc)
* Set the process's program counter.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/time.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/user.h>
#include <sys/vnode.h>
#include <sys/ptrace.h>
#include <machine/psl.h>
#include <machine/reg.h>
int
process_read_regs(p, regs)
struct proc *p;
struct reg *regs;
{
bcopy((caddr_t)p->p_md.md_regs, (caddr_t)regs, sizeof(struct reg));
return (0);
}
int
process_write_regs(p, regs)
struct proc *p;
struct reg *regs;
{
bcopy((caddr_t)regs, (caddr_t)p->p_md.md_regs, sizeof(struct reg));
/*XXX Clear to user set bits!! */
return (0);
}
int
process_sstep(p, sstep)
struct proc *p;
{
if(sstep)
cpu_singlestep(p);
return (0);
}
int
process_set_pc(p, addr)
struct proc *p;
caddr_t addr;
{
p->p_md.md_regs[PC] = (int)addr;
return (0);
}

View File

@ -0,0 +1,194 @@
/* $NetBSD: swapgeneric.c,v 1.1.1.1 1996/03/13 04:58:13 jonathan Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* William Jolitz.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* @(#)swapgeneric.c 5.5 (Berkeley) 5/9/91
*/
#include <sys/param.h>
#include <sys/conf.h>
#include <sys/buf.h>
#include <sys/systm.h>
#include <sys/reboot.h>
#include <sys/device.h>
#include <sys/disklabel.h>
#include <machine/pte.h>
/*
* Generic configuration; all in one
*/
dev_t rootdev = NODEV;
dev_t argdev = NODEV;
dev_t dumpdev = NODEV;
int nswap;
struct swdevt swdevt[] = {
{ NODEV, 1, 0 },
{ NODEV, 0, 0 },
};
long dumplo;
int dmmin, dmmax, dmtext;
#include "sd.h"
#if NSD > 0
extern struct cfdriver sdcd;
#endif
#include "fdc.h"
#if NFDC > 0
extern struct cfdriver fdcd;
#endif
struct genericconf {
struct cfdriver *gc_driver;
char *gc_name;
dev_t gc_major;
} genericconf[] = {
#if NSD > 0
{ &sdcd, "sd", 0 },
#endif
#if NFDC > 0
{ &fdcd, "fd", 7 },
#endif
{ 0 }
};
extern int ffs_mountroot();
int (*mountroot)() = ffs_mountroot;
setconf()
{
register struct genericconf *gc;
int unit, swaponroot = 0;
if (rootdev != NODEV)
goto doswap;
if (genericconf[0].gc_driver == 0)
goto verybad;
if (boothowto & RB_ASKNAME) {
char name[128];
retry:
printf("root device? ");
gets(name);
if (strcmp(name, "halt") == 0)
boot(RB_HALT);
for (gc = genericconf; gc->gc_driver; gc++)
if (gc->gc_name[0] == name[0] &&
gc->gc_name[1] == name[1])
goto gotit;
goto bad;
gotit:
if (name[3] == '*') {
name[3] = name[4];
swaponroot++;
}
if (name[2] >= '0' && name[2] <= '7' && name[3] == 0) {
unit = name[2] - '0';
goto found;
}
printf("bad/missing unit number\n");
bad:
printf("use:\n");
for (gc = genericconf; gc->gc_driver; gc++)
printf("\t%s%%d\n", gc->gc_name);
printf("\thalt\n");
goto retry;
}
unit = 0;
for (gc = genericconf; gc->gc_driver; gc++) {
if (gc->gc_driver->cd_ndevs > unit &&
gc->gc_driver->cd_devs[unit]) {
printf("root on %s0\n", gc->gc_name);
goto found;
}
}
verybad:
printf("no suitable root\n");
boot(RB_HALT);
found:
rootdev = makedev(gc->gc_major, unit * MAXPARTITIONS);
doswap:
swdevt[0].sw_dev = argdev = dumpdev =
makedev(major(rootdev), minor(rootdev) + 1);
/* swap size and dumplo set during autoconfigure */
if (swaponroot)
rootdev = dumpdev;
}
gets(cp)
char *cp;
{
register char *lp;
register c;
lp = cp;
for (;;) {
c = cngetc() & 0177;
switch (c) {
case '\n':
case '\r':
cnputc(c);
*lp++ = '\0';
return;
case '\b':
case '\177':
if (lp > cp) {
printf("\b \b");
lp--;
}
continue;
case '#':
cnputc(c);
lp--;
if (lp < cp)
lp = cp;
continue;
case '@':
case 'u'&037:
cnputc(c);
cnputc('\n');
lp = cp;
continue;
default:
cnputc(c);
*lp++ = c;
}
}
}

View File

@ -0,0 +1,129 @@
/* $NetBSD: sys_machdep.c,v 1.1.1.1 1996/03/13 04:58:13 jonathan Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* @(#)sys_machdep.c 8.1 (Berkeley) 6/10/93
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/ioctl.h>
#include <sys/file.h>
#include <sys/time.h>
#include <sys/proc.h>
#include <sys/uio.h>
#include <sys/kernel.h>
#include <sys/mtio.h>
#include <sys/buf.h>
#include <sys/trace.h>
#include <sys/mount.h>
#include <sys/syscallargs.h>
#ifdef TRACE
int nvualarm;
vtrace(p, uap, retval)
struct proc *p;
register struct vtrace_args /* {
syscallarg(int) request;
syscallarg(int) value;
} */ *uap;
register_t *retval;
{
int vdoualarm();
switch (SCARG(uap, request)) {
case VTR_DISABLE: /* disable a trace point */
case VTR_ENABLE: /* enable a trace point */
if (SCARG(uap, value) < 0 || SCARG(uap, value) >= TR_NFLAGS)
return (EINVAL);
*retval = traceflags[SCARG(uap, value)];
traceflags[SCARG(uap, value)] = SCARG(uap, request);
break;
case VTR_VALUE: /* return a trace point setting */
if (SCARG(uap, value) < 0 || SCARG(uap, value) >= TR_NFLAGS)
return (EINVAL);
*retval = traceflags[SCARG(uap, value)];
break;
case VTR_UALARM: /* set a real-time ualarm, less than 1 min */
if (SCARG(uap, value) <= 0 || SCARG(uap, value) > 60 * hz ||
nvualarm > 5)
return (EINVAL);
nvualarm++;
timeout(vdoualarm, (caddr_t)p->p_pid, SCARG(uap, value));
break;
case VTR_STAMP:
trace(TR_STAMP, SCARG(uap, value), p->p_pid);
break;
}
return (0);
}
vdoualarm(arg)
int arg;
{
register struct proc *p;
p = pfind(arg);
if (p)
psignal(p, 16);
nvualarm--;
}
#endif
sys_sysarch(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct sys_sysarch_args /* {
syscallarg(int) op;
syscallarg(char *) parms;
} */ *uap = v;
int error = 0;
switch(SCARG(uap, op)) {
default:
error = EINVAL;
break;
}
return(error);
}

1560
sys/arch/pica/pica/trap.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,480 @@
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department and Ralph Campbell.
*
* 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. 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, Berkeley and its contributors.
* 4. 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.
*
* from: Utah Hdr: vm_machdep.c 1.21 91/04/06
*
* from: @(#)vm_machdep.c 8.3 (Berkeley) 1/4/94
* $Id: vm_machdep.c,v 1.1.1.1 1996/03/13 04:58:13 jonathan Exp $
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/malloc.h>
#include <sys/buf.h>
#include <sys/vnode.h>
#include <sys/user.h>
#include <vm/vm.h>
#include <vm/vm_kern.h>
#include <vm/vm_page.h>
#if 0
#include <vm/vm_object.h>
#endif
#include <machine/pte.h>
#include <machine/cpu.h>
vm_offset_t kmem_alloc_wait_align();
/*
* Finish a fork operation, with process p2 nearly set up.
* Copy and update the kernel stack and pcb, making the child
* ready to run, and marking it so that it can return differently
* than the parent. Returns 1 in the child process, 0 in the parent.
* We currently double-map the user area so that the stack is at the same
* address in each process; in the future we will probably relocate
* the frame pointers on the stack after copying.
*/
cpu_fork(p1, p2)
register struct proc *p1, *p2;
{
register struct user *up = p2->p_addr;
register pt_entry_t *pte;
register int i;
extern struct proc *machFPCurProcPtr;
p2->p_md.md_regs = up->u_pcb.pcb_regs;
p2->p_md.md_flags = p1->p_md.md_flags & MDP_FPUSED;
/*
* Cache the PTEs for the user area in the machine dependent
* part of the proc struct so cpu_switch() can quickly map in
* the user struct and kernel stack. Note: if the virtual address
* translation changes (e.g. swapout) we have to update this.
*/
pte = kvtopte(up);
for (i = 0; i < UPAGES; i++) {
p2->p_md.md_upte[i] = pte->pt_entry & ~(PG_G | PG_RO | PG_WIRED);
pte++;
}
/*
* Copy floating point state from the FP chip if this process
* has state stored there.
*/
if (p1 == machFPCurProcPtr)
MachSaveCurFPState(p1);
/*
* Copy pcb and stack from proc p1 to p2.
* We do this as cheaply as possible, copying only the active
* part of the stack. The stack and pcb need to agree;
*/
p2->p_addr->u_pcb = p1->p_addr->u_pcb;
/* cache segtab for ULTBMiss() */
p2->p_addr->u_pcb.pcb_segtab = (void *)p2->p_vmspace->vm_pmap.pm_segtab;
/*
* Arrange for a non-local goto when the new process
* is started, to resume here, returning nonzero from setjmp.
*/
#ifdef DIAGNOSTIC
if (p1 != curproc)
panic("cpu_fork: curproc");
#endif
if (copykstack(up)) {
/*
* Return 1 in child.
*/
return (1);
}
return (0);
}
/*
* Finish a swapin operation.
* We neded to update the cached PTEs for the user area in the
* machine dependent part of the proc structure.
*/
void
cpu_swapin(p)
register struct proc *p;
{
register struct user *up = p->p_addr;
register pt_entry_t *pte;
register int i;
/*
* Cache the PTEs for the user area in the machine dependent
* part of the proc struct so cpu_switch() can quickly map in
* the user struct and kernel stack.
*/
pte = kvtopte(up);
for (i = 0; i < UPAGES; i++) {
p->p_md.md_upte[i] = pte->pt_entry & ~(PG_G | PG_RO | PG_WIRED);
pte++;
}
}
/*
* cpu_exit is called as the last action during exit.
* We release the address space and machine-dependent resources,
* including the memory for the user structure and kernel stack.
* Once finished, we call switch_exit, which switches to a temporary
* pcb and stack and never returns. We block memory allocation
* until switch_exit has made things safe again.
*/
void cpu_exit(p)
struct proc *p;
{
extern struct proc *machFPCurProcPtr;
if (machFPCurProcPtr == p)
machFPCurProcPtr = (struct proc *)0;
vmspace_free(p->p_vmspace);
(void) splhigh();
kmem_free(kernel_map, (vm_offset_t)p->p_addr, ctob(UPAGES));
switch_exit();
/* NOTREACHED */
}
/*
* Dump the machine specific header information at the start of a core dump.
*/
cpu_coredump(p, vp, cred)
struct proc *p;
struct vnode *vp;
struct ucred *cred;
{
extern struct proc *machFPCurProcPtr;
/*
* Copy floating point state from the FP chip if this process
* has state stored there.
*/
if (p == machFPCurProcPtr)
MachSaveCurFPState(p);
return (vn_rdwr(UIO_WRITE, vp, (caddr_t)p->p_addr, ctob(UPAGES),
(off_t)0, UIO_SYSSPACE, IO_NODELOCKED|IO_UNIT, cred, (int *)NULL,
p));
}
/*
* Move pages from one kernel virtual address to another.
* Both addresses are assumed to reside in the Sysmap,
* and size must be a multiple of CLSIZE.
*/
pagemove(from, to, size)
register caddr_t from, to;
int size;
{
register pt_entry_t *fpte, *tpte;
if (size % CLBYTES)
panic("pagemove");
fpte = kvtopte(from);
tpte = kvtopte(to);
if(((int)from & machCacheAliasMask) != ((int)to & machCacheAliasMask)) {
MachHitFlushDCache(from, size);
}
while (size > 0) {
MachTLBFlushAddr(from);
MachTLBUpdate(to, *fpte);
*tpte++ = *fpte;
fpte->pt_entry = PG_NV | PG_G;
fpte++;
size -= NBPG;
from += NBPG;
to += NBPG;
}
}
extern vm_map_t phys_map;
/*
* Map an IO request into kernel virtual address space. Requests fall into
* one of five catagories:
*
* B_PHYS|B_UAREA: User u-area swap.
* Address is relative to start of u-area (p_addr).
* B_PHYS|B_PAGET: User page table swap.
* Address is a kernel VA in usrpt (Usrptmap).
* B_PHYS|B_DIRTY: Dirty page push.
* Address is a VA in proc2's address space.
* B_PHYS|B_PGIN: Kernel pagein of user pages.
* Address is VA in user's address space.
* B_PHYS: User "raw" IO request.
* Address is VA in user's address space.
*
* All requests are (re)mapped into kernel VA space via the phys_map
*/
vmapbuf(bp)
register struct buf *bp;
{
register caddr_t addr;
register vm_size_t sz;
struct proc *p;
int off;
vm_offset_t kva;
register vm_offset_t pa;
if ((bp->b_flags & B_PHYS) == 0)
panic("vmapbuf");
addr = bp->b_saveaddr = bp->b_un.b_addr;
off = (int)addr & PGOFSET;
p = bp->b_proc;
sz = round_page(bp->b_bcount + off);
kva = kmem_alloc_wait_align(phys_map, sz, (vm_size_t)addr & machCacheAliasMask);
bp->b_un.b_addr = (caddr_t) (kva + off);
sz = atop(sz);
while (sz--) {
pa = pmap_extract(vm_map_pmap(&p->p_vmspace->vm_map),
(vm_offset_t)addr);
if (pa == 0)
panic("vmapbuf: null page frame");
pmap_enter(vm_map_pmap(phys_map), kva, trunc_page(pa),
VM_PROT_READ|VM_PROT_WRITE, TRUE);
addr += PAGE_SIZE;
kva += PAGE_SIZE;
}
}
/*
* Free the io map PTEs associated with this IO operation.
* We also invalidate the TLB entries and restore the original b_addr.
*/
vunmapbuf(bp)
register struct buf *bp;
{
register caddr_t addr = bp->b_un.b_addr;
register vm_size_t sz;
vm_offset_t kva;
if ((bp->b_flags & B_PHYS) == 0)
panic("vunmapbuf");
sz = round_page(bp->b_bcount + ((int)addr & PGOFSET));
kva = (vm_offset_t)((int)addr & ~PGOFSET);
kmem_free_wakeup(phys_map, kva, sz);
bp->b_un.b_addr = bp->b_saveaddr;
bp->b_saveaddr = NULL;
}
/*
* SAVE_HINT:
*
* Saves the specified entry as the hint for
* future lookups. Performs necessary interlocks.
*/
#define SAVE_HINT(map,value) \
simple_lock(&(map)->hint_lock); \
(map)->hint = (value); \
simple_unlock(&(map)->hint_lock);
/*
* kmem_alloc_upage:
*
* Allocate pageable memory to the kernel's address map.
* map must be "kernel_map" below.
* (Currently only used when allocating U pages).
*/
vm_offset_t
kmem_alloc_upage(map, size)
vm_map_t map;
register vm_size_t size;
{
vm_offset_t addr;
register int result;
size = round_page(size);
addr = vm_map_min(map);
result = vm_map_find_U(map, NULL, (vm_offset_t) 0,
&addr, size, TRUE);
if (result != KERN_SUCCESS) {
return(0);
}
return(addr);
}
/*
* vm_map_find finds an unallocated region in the target address
* map with the given length aligned on U viritual address.
* The search is defined to be first-fit from the specified address;
* the region found is returned in the same parameter.
*
*/
int
vm_map_find_U(map, object, offset, addr, length, find_space)
vm_map_t map;
vm_object_t object;
vm_offset_t offset;
vm_offset_t *addr; /* IN/OUT */
vm_size_t length;
boolean_t find_space;
{
register vm_offset_t start;
int result;
start = *addr;
vm_map_lock(map);
if (find_space) {
if (vm_map_findspace_align(map, start, length, addr, 0)) {
vm_map_unlock(map);
return (KERN_NO_SPACE);
}
start = *addr;
}
result = vm_map_insert(map, object, offset, start, start + length);
vm_map_unlock(map);
return (result);
}
/*
* Find sufficient space for `length' bytes in the given map, starting at
* `start'. The map must be locked. Returns 0 on success, 1 on no space.
*/
int
vm_map_findspace_align(map, start, length, addr, align)
register vm_map_t map;
register vm_offset_t start;
vm_size_t length;
vm_offset_t *addr;
vm_size_t align;
{
register vm_map_entry_t entry, next;
register vm_offset_t end;
if (start < map->min_offset)
start = map->min_offset;
if (start > map->max_offset)
return (1);
/*
* Look for the first possible address; if there's already
* something at this address, we have to start after it.
*/
if (start == map->min_offset) {
if ((entry = map->first_free) != &map->header)
start = entry->end;
} else {
vm_map_entry_t tmp;
if (vm_map_lookup_entry(map, start, &tmp))
start = tmp->end;
entry = tmp;
}
/*
* Look through the rest of the map, trying to fit a new region in
* the gap between existing regions, or after the very last region.
*/
for (;; start = (entry = next)->end) {
/*
* Find the end of the proposed new region. Be sure we didn't
* go beyond the end of the map, or wrap around the address;
* if so, we lose. Otherwise, if this is the last entry, or
* if the proposed new region fits before the next entry, we
* win.
*/
start = ((start + NBPG -1) & ~(NBPG - 1)); /* Paranoia */
if((start & machCacheAliasMask) <= align) {
start += align - (start & machCacheAliasMask);
}
else {
start = ((start + machCacheAliasMask) & ~machCacheAliasMask);
start += align;
}
end = start + length;
if (end > map->max_offset || end < start)
return (1);
next = entry->next;
if (next == &map->header || next->start >= end)
break;
}
SAVE_HINT(map, entry);
*addr = start;
return (0);
}
/*
* kmem_alloc_wait_align
*
* Allocates pageable memory from a sub-map of the kernel. If the submap
* has no room, the caller sleeps waiting for more memory in the submap.
*
*/
vm_offset_t
kmem_alloc_wait_align(map, size, align)
vm_map_t map;
vm_size_t size;
vm_size_t align;
{
vm_offset_t addr;
size = round_page(size);
for (;;) {
/*
* To make this work for more than one map,
* use the map's lock to lock out sleepers/wakers.
*/
vm_map_lock(map);
if (vm_map_findspace_align(map, 0, size, &addr, align) == 0)
break;
/* no space now; see if we can ever get space */
if (vm_map_max(map) - vm_map_min(map) < size) {
vm_map_unlock(map);
return (0);
}
assert_wait(map, TRUE);
vm_map_unlock(map);
thread_block();
}
vm_map_insert(map, NULL, (vm_offset_t)0, addr, addr + size);
vm_map_unlock(map);
return (addr);
}