From 4b7a128684ac4ef7af2ef5c78cebd3d3c21332c0 Mon Sep 17 00:00:00 2001 From: simonb Date: Wed, 6 Mar 2002 02:13:37 +0000 Subject: [PATCH] A basic port to the Broadcom/SiByte SB1250 evaluation board (the "swarm"). Other SB-cpu boards will be supported by this port in the future. Includes support for on-chip ethernet and serial. Many features still missing - notably SMP, PCI/LDT and IDE. This code is provided by the Broadband Processor Business Unit at Broadcom Corp with minor updates by me. --- sys/arch/sbmips/Makefile | 5 + sys/arch/sbmips/TODO | 67 +++ sys/arch/sbmips/compile/.keep_me | 3 + sys/arch/sbmips/conf/GENERIC | 158 ++++++ sys/arch/sbmips/conf/Makefile.sbmips.inc | 5 + sys/arch/sbmips/conf/files.sbmips | 138 +++++ sys/arch/sbmips/conf/std.sbmips | 13 + sys/arch/sbmips/include/Makefile | 18 + sys/arch/sbmips/include/ansi.h | 3 + sys/arch/sbmips/include/aout_machdep.h | 3 + sys/arch/sbmips/include/asm.h | 3 + sys/arch/sbmips/include/autoconf.h | 63 +++ sys/arch/sbmips/include/bsd-aout.h | 3 + sys/arch/sbmips/include/bswap.h | 3 + sys/arch/sbmips/include/cdefs.h | 5 + sys/arch/sbmips/include/conf.h | 3 + sys/arch/sbmips/include/cpu.h | 3 + sys/arch/sbmips/include/db_machdep.h | 6 + sys/arch/sbmips/include/disklabel.h | 175 +++++++ sys/arch/sbmips/include/elf_machdep.h | 11 + sys/arch/sbmips/include/endian.h | 3 + sys/arch/sbmips/include/endian_machdep.h | 11 + sys/arch/sbmips/include/float.h | 3 + sys/arch/sbmips/include/ieee.h | 3 + sys/arch/sbmips/include/ieeefp.h | 3 + sys/arch/sbmips/include/int_const.h | 3 + sys/arch/sbmips/include/int_fmtio.h | 3 + sys/arch/sbmips/include/int_limits.h | 3 + sys/arch/sbmips/include/int_mwgwtypes.h | 3 + sys/arch/sbmips/include/int_types.h | 3 + sys/arch/sbmips/include/intr.h | 104 ++++ sys/arch/sbmips/include/kcore.h | 3 + sys/arch/sbmips/include/kdbparam.h | 3 + sys/arch/sbmips/include/leds.h | 39 ++ sys/arch/sbmips/include/limits.h | 3 + sys/arch/sbmips/include/lock.h | 4 + sys/arch/sbmips/include/locore.h | 3 + sys/arch/sbmips/include/math.h | 3 + sys/arch/sbmips/include/mips_opcode.h | 3 + sys/arch/sbmips/include/param.h | 110 ++++ sys/arch/sbmips/include/pcb.h | 3 + sys/arch/sbmips/include/pmap.h | 12 + sys/arch/sbmips/include/proc.h | 3 + sys/arch/sbmips/include/profile.h | 3 + sys/arch/sbmips/include/psl.h | 3 + sys/arch/sbmips/include/pte.h | 3 + sys/arch/sbmips/include/ptrace.h | 3 + sys/arch/sbmips/include/reg.h | 3 + sys/arch/sbmips/include/regdef.h | 3 + sys/arch/sbmips/include/regnum.h | 3 + sys/arch/sbmips/include/reloc.h | 3 + sys/arch/sbmips/include/rnd.h | 3 + sys/arch/sbmips/include/setjmp.h | 3 + sys/arch/sbmips/include/signal.h | 3 + sys/arch/sbmips/include/stdarg.h | 3 + sys/arch/sbmips/include/systemsw.h | 72 +++ sys/arch/sbmips/include/trap.h | 3 + sys/arch/sbmips/include/types.h | 5 + sys/arch/sbmips/include/varargs.h | 3 + sys/arch/sbmips/include/vmparam.h | 9 + sys/arch/sbmips/sbmips/autoconf.c | 85 ++++ sys/arch/sbmips/sbmips/conf.c | 481 +++++++++++++++++ sys/arch/sbmips/sbmips/console.c | 69 +++ sys/arch/sbmips/sbmips/cpu.c | 92 ++++ sys/arch/sbmips/sbmips/disksubr.c | 455 +++++++++++++++++ sys/arch/sbmips/sbmips/locore_machdep.S | 20 + sys/arch/sbmips/sbmips/machdep.c | 623 +++++++++++++++++++++++ sys/arch/sbmips/sbmips/sb1250_icu.c | 205 ++++++++ sys/arch/sbmips/sbmips/softintr.c | 210 ++++++++ sys/arch/sbmips/sbmips/systemsw.c | 189 +++++++ sys/arch/sbmips/sbmips/zbbus.c | 136 +++++ 71 files changed, 3712 insertions(+) create mode 100644 sys/arch/sbmips/Makefile create mode 100644 sys/arch/sbmips/TODO create mode 100644 sys/arch/sbmips/compile/.keep_me create mode 100644 sys/arch/sbmips/conf/GENERIC create mode 100644 sys/arch/sbmips/conf/Makefile.sbmips.inc create mode 100644 sys/arch/sbmips/conf/files.sbmips create mode 100644 sys/arch/sbmips/conf/std.sbmips create mode 100644 sys/arch/sbmips/include/Makefile create mode 100644 sys/arch/sbmips/include/ansi.h create mode 100644 sys/arch/sbmips/include/aout_machdep.h create mode 100644 sys/arch/sbmips/include/asm.h create mode 100644 sys/arch/sbmips/include/autoconf.h create mode 100644 sys/arch/sbmips/include/bsd-aout.h create mode 100644 sys/arch/sbmips/include/bswap.h create mode 100644 sys/arch/sbmips/include/cdefs.h create mode 100644 sys/arch/sbmips/include/conf.h create mode 100644 sys/arch/sbmips/include/cpu.h create mode 100644 sys/arch/sbmips/include/db_machdep.h create mode 100644 sys/arch/sbmips/include/disklabel.h create mode 100644 sys/arch/sbmips/include/elf_machdep.h create mode 100644 sys/arch/sbmips/include/endian.h create mode 100644 sys/arch/sbmips/include/endian_machdep.h create mode 100644 sys/arch/sbmips/include/float.h create mode 100644 sys/arch/sbmips/include/ieee.h create mode 100644 sys/arch/sbmips/include/ieeefp.h create mode 100644 sys/arch/sbmips/include/int_const.h create mode 100644 sys/arch/sbmips/include/int_fmtio.h create mode 100644 sys/arch/sbmips/include/int_limits.h create mode 100644 sys/arch/sbmips/include/int_mwgwtypes.h create mode 100644 sys/arch/sbmips/include/int_types.h create mode 100644 sys/arch/sbmips/include/intr.h create mode 100644 sys/arch/sbmips/include/kcore.h create mode 100644 sys/arch/sbmips/include/kdbparam.h create mode 100644 sys/arch/sbmips/include/leds.h create mode 100644 sys/arch/sbmips/include/limits.h create mode 100644 sys/arch/sbmips/include/lock.h create mode 100644 sys/arch/sbmips/include/locore.h create mode 100644 sys/arch/sbmips/include/math.h create mode 100644 sys/arch/sbmips/include/mips_opcode.h create mode 100644 sys/arch/sbmips/include/param.h create mode 100644 sys/arch/sbmips/include/pcb.h create mode 100644 sys/arch/sbmips/include/pmap.h create mode 100644 sys/arch/sbmips/include/proc.h create mode 100644 sys/arch/sbmips/include/profile.h create mode 100644 sys/arch/sbmips/include/psl.h create mode 100644 sys/arch/sbmips/include/pte.h create mode 100644 sys/arch/sbmips/include/ptrace.h create mode 100644 sys/arch/sbmips/include/reg.h create mode 100644 sys/arch/sbmips/include/regdef.h create mode 100644 sys/arch/sbmips/include/regnum.h create mode 100644 sys/arch/sbmips/include/reloc.h create mode 100644 sys/arch/sbmips/include/rnd.h create mode 100644 sys/arch/sbmips/include/setjmp.h create mode 100644 sys/arch/sbmips/include/signal.h create mode 100644 sys/arch/sbmips/include/stdarg.h create mode 100644 sys/arch/sbmips/include/systemsw.h create mode 100644 sys/arch/sbmips/include/trap.h create mode 100644 sys/arch/sbmips/include/types.h create mode 100644 sys/arch/sbmips/include/varargs.h create mode 100644 sys/arch/sbmips/include/vmparam.h create mode 100644 sys/arch/sbmips/sbmips/autoconf.c create mode 100644 sys/arch/sbmips/sbmips/conf.c create mode 100644 sys/arch/sbmips/sbmips/console.c create mode 100644 sys/arch/sbmips/sbmips/cpu.c create mode 100644 sys/arch/sbmips/sbmips/disksubr.c create mode 100644 sys/arch/sbmips/sbmips/locore_machdep.S create mode 100644 sys/arch/sbmips/sbmips/machdep.c create mode 100644 sys/arch/sbmips/sbmips/sb1250_icu.c create mode 100644 sys/arch/sbmips/sbmips/softintr.c create mode 100644 sys/arch/sbmips/sbmips/systemsw.c create mode 100644 sys/arch/sbmips/sbmips/zbbus.c diff --git a/sys/arch/sbmips/Makefile b/sys/arch/sbmips/Makefile new file mode 100644 index 000000000000..b6717c6f1988 --- /dev/null +++ b/sys/arch/sbmips/Makefile @@ -0,0 +1,5 @@ +# $NetBSD: Makefile,v 1.1 2002/03/06 02:13:37 simonb Exp $ + +SUBDIR= include + +.include diff --git a/sys/arch/sbmips/TODO b/sys/arch/sbmips/TODO new file mode 100644 index 000000000000..fd3de89aa542 --- /dev/null +++ b/sys/arch/sbmips/TODO @@ -0,0 +1,67 @@ +$NetBSD: TODO,v 1.1 2002/03/06 02:13:37 simonb Exp $ + +NetBSD/sbmips to-do list + + +REALLY REALLY SHOULD ("MUST") BE DONE BEFORE INTEGRATION INTO NetBSD: + + * pass1 workarounds code should be removed (i.e. not put into + public libc). + + NOTE- no pass1 workarounds are in libc or the toolchain. + Remove the pass1 workarounds in the kernel at some future stage? + + +SHOULD BE DONE BEFORE INTEGRATION INTO NetBSD: + + * redo the softintr code. it's fairly icky. + + * clean as many changes off of 'stand' as possible. the files + in there were the most part derived from other ports (alpha + and followers of that style of boot block). + + NOTE- 'stand' has not been imported to the NetBSD source tree + yet. + +General features needed: + + * SMP + + * bus.h support. + + * pci/ldt support (requires bus.h support). + + * ide on generic bus (requires bus.h support). + + * generic smbus support, and support for our controller. + + * TOD clock on smbus. + + * board-level configuration details. + + * swarm LEDs. + + * MAC vs. fifo + + * sync serial vs. duart. + + * fifo driver. + + * sync serial driver. + + +Cleanups / Improvements: + + * mips cache code / pmap for coherent system. + + * sb-1 cache error handler. + + * clean up ethernet driver & tune. + + * interrupt handling/routing. + + * systemsw bits should be made more generic. possibly apply to + mips. + + * sbscn should be made split into a driver per channel, w/ + the features for which that's not possible in pass1 disabled. diff --git a/sys/arch/sbmips/compile/.keep_me b/sys/arch/sbmips/compile/.keep_me new file mode 100644 index 000000000000..5589329b92f9 --- /dev/null +++ b/sys/arch/sbmips/compile/.keep_me @@ -0,0 +1,3 @@ +$NetBSD: .keep_me,v 1.1 2002/03/06 02:13:38 simonb Exp $ + +This normally empty directory needs to be kept in the distribution. diff --git a/sys/arch/sbmips/conf/GENERIC b/sys/arch/sbmips/conf/GENERIC new file mode 100644 index 000000000000..bceaa2a9c2fa --- /dev/null +++ b/sys/arch/sbmips/conf/GENERIC @@ -0,0 +1,158 @@ +# $NetBSD: GENERIC,v 1.1 2002/03/06 02:13:38 simonb Exp $ + +include "arch/sbmips/conf/std.sbmips" + +#ident "GENERIC-$Revision: 1.1 $" + +# The following three options are required for BCM1250 pass 1 silicon +options SB1250_PASS1 +options NOFPU +options SOFTFLOAT + +maxusers 32 + +# Standard system options +options KTRACE # system call tracing support +options SYSVMSG # System V message queues +options SYSVSEM # System V semaphores +options SYSVSHM # System V shared memory +#options SHMMAXPGS=1024 # 1024 pages is the default +options LKM # loadable kernel modules +#options NTP # network time protocol +#options UCONSOLE # users can redirect console (unsafe) + +# Debugging options +options DIAGNOSTIC # extra kernel sanity checking +#options DEBUG # extra kernel debugging support +#options KMEMSTATS # kernel memory statistics (vmstat -m) +options DDB # kernel dynamic debugger +options DDB_HISTORY_SIZE=100 # enable history editing in DDB +#makeoptions DEBUG="-g" # compile full symbol table +options SYMTAB_SPACE=200000 # size for embedded symbol table + +# Compatibility options +options COMPAT_43 # compatibility with 4.3BSD binaries +#options COMPAT_10 # NetBSD 0.9 binary compatibility +#options COMPAT_10 # NetBSD 1.0 binary compatibility +#options COMPAT_11 # NetBSD 1.1 binary compatibility +#options COMPAT_12 # NetBSD 1.2 binary compatibility +#options COMPAT_13 # NetBSD 1.3 binary compatibility +#options COMPAT_14 # NetBSD 1.4 binary compatibility +#options EXEC_ECOFF # exec ECOFF binaries +#options COMPAT_ULTRIX # binary compatibility with Ultrix + +# File systems +file-system FFS # Berkeley Fast Filesystem +file-system NFS # Sun NFS-compatible filesystem client +file-system KERNFS # kernel data-structure filesystem +#file-system NULLFS # NULL layered filesystem +file-system OVERLAY # overlay file system +file-system MFS # memory-based filesystem +file-system FDESC # user file descriptor filesystem +#file-system UMAPFS # uid/gid remapping filesystem +file-system LFS # Log-based filesystem (still experimental) +#file-system PORTAL # portal filesystem (still experimental) +#file-system PROCFS # /proc +#file-system CD9660 # ISO 9660 + Rock Ridge file system +#file-system UNION # union file system +#file-system MSDOSFS # MS-DOS FAT filesystem(s). +#file-system CODA # Coda File System; also needs vcoda (below) + +# File system options +options NFSSERVER # Sun NFS-compatible filesystem server +options QUOTA # FFS quotas +#options FFS_EI # FFS Endian Independant support +#options SOFTDEP # FFS soft updates support. +#options EXT2FS_SYSTEM_FLAGS # makes ext2fs file flags (append and + # immutable) behave as system flags. + +# Networking options +#options GATEWAY # IP packet forwarding +options INET # Internet protocols +options INET6 # IPV6 +#options IPSEC # IP security +#options IPSEC_ESP # IP security (encryption part; define w/IPSEC) +#options IPSEC_DEBUG # debug for IP security +#options MROUTING # packet forwarding of multicast packets +#options NS # Xerox NS networking +#options NSIP # Xerox NS tunneling over IP +#options ISO,TPIP # OSI networking +#options EON # OSI tunneling over IP +#options CCITT,LLC,HDLC # X.25 +#options NETATALK # AppleTalk (over Ethernet) protocol +#options PPP_BSDCOMP # BSD-Compress compression support for PPP +#options PPP_DEFLATE # Deflate compression support for PPP +options PPP_FILTER # Active filter support for PPP (requires bpf) +options PFIL_HOOKS # pfil(9) packet filter hooks +options IPFILTER_LOG # ipmon(8) log support + +# Compatibility with 4.2BSD implementation of TCP/IP. Not recommended. +#options TCP_COMPAT_42 + +# These options enable verbose messages for several subsystems. +# Warning, these may compile large string tables into the kernel! +options PCIVERBOSE # verbose PCI device autoconfig messages +#options PCI_CONFIG_DUMP # verbosely dump PCI config space +#options SCSIVERBOSE # human readable SCSI error messages +options MIIVERBOSE # verbose PHY autoconfig messages + +options NFS_BOOT_DHCP + +#config netbsd root on ? type ? +config netbsd root on sbmac0 type nfs + +zbbus* at root + +cpu0 at zbbus? busid 0 +#cpu* at zbbus? busid ? +sbscd* at zbbus? busid ? +sbobio* at zbbus? busid ? + +#sbicu* at sbscd? offset ? +#sbwdog* at sbscd? offset ? intr ? +sbtimer0 at sbscd? offset ? intr ? flags 0x01 # clock +#sbtimer1 at sbscd? offset ? intr ? flags 0x02 # statclock +sbtimer* at sbscd? offset ? intr ? + +sbmac* at sbobio? offset ? +sbscn* at sbobio? offset ? +#sbgbus* at sbobio? offset ? + +# MII/PHY support +brgphy* at mii? phy ? + +# Pseudo-devices + +# Disk/mass storage pseudo-devices +pseudo-device ccd 4 # concatenated disk devices +#pseudo-device raid 4 # RAIDframe disk driver +#options RAID_AUTOCONFIG # auto-configuration of RAID +pseudo-device md 1 # memory disk device (ramdisk) +pseudo-device vnd 4 # disk-like interface to files + +# Network pseudo-devices +pseudo-device bpfilter 8 # Berkeley packet filter +pseudo-device ipfilter # IP filter (firewall) and NAT +pseudo-device loop # network loopback +#pseudo-device ppp 2 # Point-to-Point Protocol +#pseudo-device pppoe # PPP over Ethernet (RFC 2516) +#pseudo-device sl 2 # Serial Line IP +#pseudo-device strip 2 # Starmode Radio IP (Metricom) +#pseudo-device irframetty # IrDA frame line discipline +#pseudo-device tun 2 # network tunneling over tty +#pseudo-device gre 2 # generic L3 over IP tunnel +#pseudo-device ipip 2 # RFC 2003 IP Encapsulation +#pseudo-device gif 4 # RFC1933 tunnel +#pseudo-device faith 1 # IPv[46] tcp relay translation +#pseudo-device stf 1 # 6to4 IPv6 over IPv4 encapsulation +pseudo-device vlan # IEEE 802.1q encapsulation +pseudo-device bridge # simple inter-network bridging + +# Miscellaneous pseudo-devices +pseudo-device pty # pseudo-terminals +#pseudo-device tb 1 # tablet line discipline +#pseudo-device sequencer 1 # MIDI sequencer +pseudo-device rnd # /dev/random & kernel generator + +# A pseudo device needed for Coda # also needs CODA (above) +#pseudo-device vcoda 4 # coda minicache <-> venus comm. diff --git a/sys/arch/sbmips/conf/Makefile.sbmips.inc b/sys/arch/sbmips/conf/Makefile.sbmips.inc new file mode 100644 index 000000000000..8a70d2c65d12 --- /dev/null +++ b/sys/arch/sbmips/conf/Makefile.sbmips.inc @@ -0,0 +1,5 @@ +# $NetBSD: Makefile.sbmips.inc,v 1.1 2002/03/06 02:13:38 simonb Exp $ + +SYSTEM_LD_TAIL_EXTRA=; \ + echo "${DBSYM} $@ || true"; \ + ${DBSYM} $@ || true; diff --git a/sys/arch/sbmips/conf/files.sbmips b/sys/arch/sbmips/conf/files.sbmips new file mode 100644 index 000000000000..188e4f259fcc --- /dev/null +++ b/sys/arch/sbmips/conf/files.sbmips @@ -0,0 +1,138 @@ +# $NetBSD: files.sbmips,v 1.1 2002/03/06 02:13:39 simonb Exp $ + +maxpartitions 8 + +maxusers 1 8 64 + +file arch/sbmips/sbmips/autoconf.c +file arch/sbmips/sbmips/machdep.c +file arch/sbmips/sbmips/softintr.c +file arch/sbmips/sbmips/console.c +file arch/sbmips/sbmips/conf.c +file arch/sbmips/sbmips/disksubr.c +file arch/sbmips/sbmips/systemsw.c +file dev/clock_subr.c +file dev/cons.c + +file arch/sbmips/sbmips/sb1250_icu.c !ikos + +file arch/sbmips/ikos/ikos_clock.c ikos +file arch/sbmips/ikos/ikos_icu.c ikos +file arch/sbmips/ikos/ikoscons.c ikos + +file arch/mips/cfe/cfe_api.c + + +### +### MI device inclusion +### +# Machine-independent MII/PHY drivers. +include "dev/mii/files.mii" + +# Machine-independent I2O drivers. +include "dev/i2o/files.i2o" + +# Machine-independent SCSI drivers +include "dev/scsipi/files.scsipi" +major { sd = 8 } +major { cd = 3 } + +# Machine-independent ATA drivers +include "dev/ata/files.ata" +major { wd = 4 } + +# Memory Disk +file dev/md_root.c memory_disk_hooks +major { md = 6 } + +# RAIDframe +major { raid = 16 } + +# Logical disks +major { ld = 17 } + +# Raster operations +include "dev/rasops/files.rasops" +include "dev/wsfont/files.wsfont" + +# "Workstation Console" glue. +include "dev/wscons/files.wscons" + + +# ISA Bus support +include "dev/pci/files.pci" # XXX some ISA devs are 'at pci' too. +include "dev/isa/files.isa" +# XXXCGD machdep isa files + +# PC Keyboard Controller support +include "dev/pckbc/files.pckbc" + +# XXXCGD lots of junk isa devices, e.g. fd + +# ISA Plug 'n Play devices +file arch/alpha/isa/isapnp_machdep.c isapnp + +# PCI Bus support +# include "dev/pci/files.pci" XXX SEE ABOVE +#file arch/sbmips/dev/pci/pci_machdep.c pci +# XXXCGD macdep pci files + +# XXXX pcic here because it needs to be late. The catch: pcic needs +# to be late, so devices which attach to it are attached late. But it +# needs to be before its isa and pci attachments. This answer is +# non-optimal, but I don't have a better answer right now. + +# PCIC pcmcia contoller +# XXX this needs to be done very late, so it's done here. This feels +# like a kludge, but it might be for the best. + +defparam PCIC_ISA_ALLOC_IOBASE +defparam PCIC_ISA_ALLOC_IOSIZE +defparam PCIC_ISA_INTR_ALLOC_MASK + +device pcic: pcmciabus +file dev/ic/i82365.c pcic + +# PCIC pcmcia controller on ISA bus. +attach pcic at isa with pcic_isa +file dev/isa/i82365_isa.c pcic_isa + +# PCIC pcmcia controller on PCI bus. +attach pcic at pci with pcic_pci +file dev/pci/i82365_pci.c pcic_pci + +# PCIC pcmcia controller on PnP board +attach pcic at isapnp with pcic_isapnp +file dev/isapnp/i82365_isapnp.c pcic_isapnp + +# Code common to ISA and ISAPnP attachments +file dev/isa/i82365_isasubr.c pcic_isa | pcic_isapnp | pcic_pci + + +# this wants to be probed as late as possible. +# +# Machine-independent PCMCIA drivers +# +#XXXCGD can't yet becaue needs fdc include "dev/pcmcia/files.pcmcia" +# +# Machine-independent USB device support +# +include "dev/usb/files.usb" + +### +### SBMIPS DEVICES +### + +# Ze Big Bus: main system bus +device zbbus {[busid = -1]} +attach zbbus at root +file arch/sbmips/sbmips/zbbus.c zbbus + +# CPUs +device cpu +attach cpu at zbbus +file arch/sbmips/sbmips/cpu.c cpu + + + +file nfs/nfs_bio.c compile-with "${NORMAL_C} -O0" diff --git a/sys/arch/sbmips/conf/std.sbmips b/sys/arch/sbmips/conf/std.sbmips new file mode 100644 index 000000000000..b05bf2ad54fe --- /dev/null +++ b/sys/arch/sbmips/conf/std.sbmips @@ -0,0 +1,13 @@ +# $NetBSD: std.sbmips,v 1.1 2002/03/06 02:13:39 simonb Exp $ + +machine sbmips mips + +options MIPS64 + +options EXEC_ELF32 # exec ELF32 binaries +options EXEC_SCRIPT # exec #! scripts + +makeoptions DEFTEXTADDR="0x80001000" +makeoptions MACHINE_ARCH="mipseb" + +include "arch/mips/conf/files.sibyte" diff --git a/sys/arch/sbmips/include/Makefile b/sys/arch/sbmips/include/Makefile new file mode 100644 index 000000000000..14165c254a72 --- /dev/null +++ b/sys/arch/sbmips/include/Makefile @@ -0,0 +1,18 @@ +# $NetBSD: Makefile,v 1.1 2002/03/06 02:13:39 simonb Exp $ + +KDIR= /sys/arch/sbmips/include +INCSDIR= /usr/include/sbmips + +# XXXcgd need local: bus.h pci_machdep.h +# XXXcgd need export: intr.h + +INCS= ansi.h aout_machdep.h asm.h bsd-aout.h bswap.h cdefs.h \ + cpu.h db_machdep.h disklabel.h ecoff_machdep.h elf_machdep.h \ + endian.h endian_machdep.h float.h ieee.h ieeefp.h int_const.h \ + int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h kcore.h \ + kdbparam.h limits.h lock.h locore.h math.h mips_opcode.h \ + param.h pcb.h pmap.h proc.h profile.h psl.h pte.h ptrace.h \ + reg.h regdef.h regnum.h reloc.h setjmp.h signal.h stdarg.h trap.h \ + types.h varargs.h vmparam.h + +.include diff --git a/sys/arch/sbmips/include/ansi.h b/sys/arch/sbmips/include/ansi.h new file mode 100644 index 000000000000..1ed141212be0 --- /dev/null +++ b/sys/arch/sbmips/include/ansi.h @@ -0,0 +1,3 @@ +/* $NetBSD: ansi.h,v 1.1 2002/03/06 02:13:39 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/aout_machdep.h b/sys/arch/sbmips/include/aout_machdep.h new file mode 100644 index 000000000000..086069816892 --- /dev/null +++ b/sys/arch/sbmips/include/aout_machdep.h @@ -0,0 +1,3 @@ +/* $NetBSD: aout_machdep.h,v 1.1 2002/03/06 02:13:40 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/asm.h b/sys/arch/sbmips/include/asm.h new file mode 100644 index 000000000000..001dcebcc8d7 --- /dev/null +++ b/sys/arch/sbmips/include/asm.h @@ -0,0 +1,3 @@ +/* $NetBSD: asm.h,v 1.1 2002/03/06 02:13:40 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/autoconf.h b/sys/arch/sbmips/include/autoconf.h new file mode 100644 index 000000000000..a71bd78810b9 --- /dev/null +++ b/sys/arch/sbmips/include/autoconf.h @@ -0,0 +1,63 @@ +/* $NetBSD: autoconf.h,v 1.1 2002/03/06 02:13:40 simonb Exp $ */ + +/* + * Copyright 2000, 2001 + * Broadcom Corporation. All rights reserved. + * + * This software is furnished under license and may be used and copied only + * in accordance with the following terms and conditions. Subject to these + * conditions, you may download, copy, install, use, modify and distribute + * modified or unmodified copies of this software in source and/or binary + * form. No title or ownership is transferred hereby. + * + * 1) Any source code used, modified or distributed must reproduce and + * retain this copyright notice and list of conditions as they appear in + * the source file. + * + * 2) No right is granted to use any trade name, trademark, or logo of + * Broadcom Corporation. Neither the "Broadcom Corporation" name nor any + * trademark or logo of Broadcom Corporation may be used to endorse or + * promote products derived from this software without the prior written + * permission of Broadcom Corporation. + * + * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE + * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE + * LIABLE FOR 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), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Machine-dependent structures of autoconfiguration + */ + +/* + * The boot program passes a pointer to a bootinfo structure to the + * kernel using the following convention: + * + * a0 - CFE handle + * a1 - bootinfo magic + * a2 - pointer to bootinfo_v1 structrure + * a3 - reserved, 0 + */ + +#define BOOTINFO_MAGIC 0x1234ABCD +#define BOOTINFO_VERSION 1 + +struct bootinfo_v1 { + u_long version; /* 0: version of bootinfo */ + u_long reserved; /* 4: round to 64-bit boundary */ + u_long ssym; /* 8: start of kernel sym table */ + u_long esym; /* 12: end of kernel sym table */ + char boot_flags[64]; /* 16: boot flags */ + char booted_kernel[64]; /* 80: name of booted kernel */ + u_long fwhandle; /* 144: firmware handle */ + u_long fwentry; /* 148: firmware entry point */ + u_char reserved2[100]; /* 256: total size */ +}; diff --git a/sys/arch/sbmips/include/bsd-aout.h b/sys/arch/sbmips/include/bsd-aout.h new file mode 100644 index 000000000000..297dcfb2562c --- /dev/null +++ b/sys/arch/sbmips/include/bsd-aout.h @@ -0,0 +1,3 @@ +/* $NetBSD: bsd-aout.h,v 1.1 2002/03/06 02:13:40 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/bswap.h b/sys/arch/sbmips/include/bswap.h new file mode 100644 index 000000000000..81019fba9aed --- /dev/null +++ b/sys/arch/sbmips/include/bswap.h @@ -0,0 +1,3 @@ +/* $NetBSD: bswap.h,v 1.1 2002/03/06 02:13:40 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/cdefs.h b/sys/arch/sbmips/include/cdefs.h new file mode 100644 index 000000000000..ef1c9bcc72cb --- /dev/null +++ b/sys/arch/sbmips/include/cdefs.h @@ -0,0 +1,5 @@ +/* $NetBSD: cdefs.h,v 1.1 2002/03/06 02:13:40 simonb Exp $ */ + +#include + +#define _MIPS_BSD_API _MIPS_BSD_API_LP32_64CLEAN diff --git a/sys/arch/sbmips/include/conf.h b/sys/arch/sbmips/include/conf.h new file mode 100644 index 000000000000..94432adb6fcf --- /dev/null +++ b/sys/arch/sbmips/include/conf.h @@ -0,0 +1,3 @@ +/* $NetBSD: conf.h,v 1.1 2002/03/06 02:13:41 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/cpu.h b/sys/arch/sbmips/include/cpu.h new file mode 100644 index 000000000000..08cb59abe2bd --- /dev/null +++ b/sys/arch/sbmips/include/cpu.h @@ -0,0 +1,3 @@ +/* $NetBSD: cpu.h,v 1.1 2002/03/06 02:13:41 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/db_machdep.h b/sys/arch/sbmips/include/db_machdep.h new file mode 100644 index 000000000000..484de0e38650 --- /dev/null +++ b/sys/arch/sbmips/include/db_machdep.h @@ -0,0 +1,6 @@ +/* $NetBSD: db_machdep.h,v 1.1 2002/03/06 02:13:41 simonb Exp $ */ + +#include + +#define DB_ELF_SYMBOLS +#define DB_ELFSIZE 32 diff --git a/sys/arch/sbmips/include/disklabel.h b/sys/arch/sbmips/include/disklabel.h new file mode 100644 index 000000000000..0f27d706d46c --- /dev/null +++ b/sys/arch/sbmips/include/disklabel.h @@ -0,0 +1,175 @@ +/* $NetBSD: disklabel.h,v 1.1 2002/03/06 02:13:41 simonb Exp $ */ + +/* + * Copyright 2000, 2001 + * Broadcom Corporation. All rights reserved. + * + * This software is furnished under license and may be used and copied only + * in accordance with the following terms and conditions. Subject to these + * conditions, you may download, copy, install, use, modify and distribute + * modified or unmodified copies of this software in source and/or binary + * form. No title or ownership is transferred hereby. + * + * 1) Any source code used, modified or distributed must reproduce and + * retain this copyright notice and list of conditions as they appear in + * the source file. + * + * 2) No right is granted to use any trade name, trademark, or logo of + * Broadcom Corporation. Neither the "Broadcom Corporation" name nor any + * trademark or logo of Broadcom Corporation may be used to endorse or + * promote products derived from this software without the prior written + * permission of Broadcom Corporation. + * + * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE + * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE + * LIABLE FOR 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), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* from: $NetBSD: disklabel.h,v 1.4 2000/05/05 03:27:22 soren 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 1 /* sector containing label */ +#define LABELOFFSET 0 /* offset of label in sector */ +#define MAXPARTITIONS 16 +#define RAW_PART 3 + +#ifdef __NetBSD__ +/* Pull in MBR partition definitions. */ +#include + +#ifndef __ASSEMBLER__ +#include +struct cpu_disklabel { + struct mbr_partition dosparts[NMBRPART]; + struct dkbad bad; +}; +#endif +#endif + +/* + * CFE boot block, modeled loosely on Alpha. + * + * It consists of: + * + * BSD disk label + * + * Boot block info (5 uint_64s) + * + * The boot block portion looks like: + * + * + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * | BOOT_MAGIC_NUMBER | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * | Flags | Reserved | Vers | Header Checksum | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * | Secondary Loader Location (bytes) | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * | Loader Checksum | Size of loader (bytes) | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * | Reserved | Architecture Information | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * + * Boot block fields should always be read as 64-bit numbers. + * + */ + + +struct boot_block { + uint64_t bb_data[64]; /* data (disklabel, also as below) */ +}; +#define bb_magic bb_data[59] /* magic number */ +#define bb_hdrinfo bb_data[60] /* header checksum, ver, flags */ +#define bb_secstart bb_data[61] /* secondary start (bytes) */ +#define bb_secsize bb_data[62] /* secondary size (bytes) */ +#define bb_archinfo bb_data[63] /* architecture info */ + +#define BOOT_BLOCK_OFFSET 0 /* offset of boot block. */ +#define BOOT_BLOCK_BLOCKSIZE 512 /* block size for sec. size/start, + * and for boot block itself + */ +#define BOOT_BLOCK_SIZE 40 /* 5 64-bit words */ + +#define BOOT_MAGIC_NUMBER 0x43465631424f4f54 +#define BOOT_HDR_CHECKSUM_MASK 0x00000000FFFFFFFF +#define BOOT_HDR_VER_MASK 0x000000FF00000000 +#define BOOT_HDR_VER_SHIFT 32 +#define BOOT_HDR_FLAGS_MASK 0xFF00000000000000 +#define BOOT_SECSIZE_MASK 0x00000000FFFFFFFF +#define BOOT_DATA_CHECKSUM_MASK 0xFFFFFFFF00000000 +#define BOOT_DATA_CHECKSUM_SHIFT 32 +#define BOOT_ARCHINFO_MASK 0x00000000FFFFFFFF + +#define BOOT_HDR_VERSION 1 + +#define CHECKSUM_BOOT_BLOCK(bb,cksum) \ + do { \ + uint32_t *_ptr = (uint32_t *) (bb); \ + uint32_t _cksum; \ + int _i; \ + \ + _cksum = 0; \ + for (_i = 0; \ + _i < (BOOT_BLOCK_SIZE / sizeof (uint32_t)); \ + _i++) \ + _cksum += _ptr[_i]; \ + *(cksum) = _cksum; \ + } while (0) + + +#define CHECKSUM_BOOT_DATA(data,len,cksum) \ + do { \ + uint32_t *_ptr = (uint32_t *) (data); \ + uint32_t _cksum; \ + int _i; \ + \ + _cksum = 0; \ + for (_i = 0; \ + _i < ((len) / sizeof (uint32_t)); \ + _i++) \ + _cksum += _ptr[_i]; \ + *(cksum) = _cksum; \ + } while (0) + + +#endif /* _MACHINE_DISKLABEL_H_ */ diff --git a/sys/arch/sbmips/include/elf_machdep.h b/sys/arch/sbmips/include/elf_machdep.h new file mode 100644 index 000000000000..f7ca83a454bf --- /dev/null +++ b/sys/arch/sbmips/include/elf_machdep.h @@ -0,0 +1,11 @@ +/* $NetBSD: elf_machdep.h,v 1.1 2002/03/06 02:13:42 simonb Exp $ */ + +#include + +#if defined(__MIPSEB__) +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB +#elif defined(__MIPSEL__) +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB +#else +#error neither __MIPSEL__ nor __MIPSEB__ are defined. +#endif diff --git a/sys/arch/sbmips/include/endian.h b/sys/arch/sbmips/include/endian.h new file mode 100644 index 000000000000..0801914641e2 --- /dev/null +++ b/sys/arch/sbmips/include/endian.h @@ -0,0 +1,3 @@ +/* $NetBSD: endian.h,v 1.1 2002/03/06 02:13:42 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/endian_machdep.h b/sys/arch/sbmips/include/endian_machdep.h new file mode 100644 index 000000000000..d3abc3a44c55 --- /dev/null +++ b/sys/arch/sbmips/include/endian_machdep.h @@ -0,0 +1,11 @@ +/* $NetBSD: endian_machdep.h,v 1.1 2002/03/06 02:13:42 simonb Exp $ */ + +#if defined(__MIPSEB__) +#define _BYTE_ORDER _BIG_ENDIAN +#elif defined(__MIPSEL__) +#define _BYTE_ORDER _LITTLE_ENDIAN +#else +#error neither __MIPSEL__ nor __MIPSEB__ are defined. +#endif + +#include diff --git a/sys/arch/sbmips/include/float.h b/sys/arch/sbmips/include/float.h new file mode 100644 index 000000000000..a7f7b900b262 --- /dev/null +++ b/sys/arch/sbmips/include/float.h @@ -0,0 +1,3 @@ +/* $NetBSD: float.h,v 1.1 2002/03/06 02:13:42 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/ieee.h b/sys/arch/sbmips/include/ieee.h new file mode 100644 index 000000000000..b6e4003da78e --- /dev/null +++ b/sys/arch/sbmips/include/ieee.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieee.h,v 1.1 2002/03/06 02:13:43 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/ieeefp.h b/sys/arch/sbmips/include/ieeefp.h new file mode 100644 index 000000000000..8af15ee210ab --- /dev/null +++ b/sys/arch/sbmips/include/ieeefp.h @@ -0,0 +1,3 @@ +/* $NetBSD: ieeefp.h,v 1.1 2002/03/06 02:13:43 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/int_const.h b/sys/arch/sbmips/include/int_const.h new file mode 100644 index 000000000000..65b2a090f117 --- /dev/null +++ b/sys/arch/sbmips/include/int_const.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_const.h,v 1.1 2002/03/06 02:13:43 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/int_fmtio.h b/sys/arch/sbmips/include/int_fmtio.h new file mode 100644 index 000000000000..b3cc262f2c44 --- /dev/null +++ b/sys/arch/sbmips/include/int_fmtio.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_fmtio.h,v 1.1 2002/03/06 02:13:43 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/int_limits.h b/sys/arch/sbmips/include/int_limits.h new file mode 100644 index 000000000000..38771821b4da --- /dev/null +++ b/sys/arch/sbmips/include/int_limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_limits.h,v 1.1 2002/03/06 02:13:43 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/int_mwgwtypes.h b/sys/arch/sbmips/include/int_mwgwtypes.h new file mode 100644 index 000000000000..fc490f317529 --- /dev/null +++ b/sys/arch/sbmips/include/int_mwgwtypes.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_mwgwtypes.h,v 1.1 2002/03/06 02:13:44 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/int_types.h b/sys/arch/sbmips/include/int_types.h new file mode 100644 index 000000000000..966643f75675 --- /dev/null +++ b/sys/arch/sbmips/include/int_types.h @@ -0,0 +1,3 @@ +/* $NetBSD: int_types.h,v 1.1 2002/03/06 02:13:44 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/intr.h b/sys/arch/sbmips/include/intr.h new file mode 100644 index 000000000000..bcc346528209 --- /dev/null +++ b/sys/arch/sbmips/include/intr.h @@ -0,0 +1,104 @@ +/* $NetBSD: intr.h,v 1.1 2002/03/06 02:13:44 simonb Exp $ */ + +/* + * Copyright 2000, 2001 + * Broadcom Corporation. All rights reserved. + * + * This software is furnished under license and may be used and copied only + * in accordance with the following terms and conditions. Subject to these + * conditions, you may download, copy, install, use, modify and distribute + * modified or unmodified copies of this software in source and/or binary + * form. No title or ownership is transferred hereby. + * + * 1) Any source code used, modified or distributed must reproduce and + * retain this copyright notice and list of conditions as they appear in + * the source file. + * + * 2) No right is granted to use any trade name, trademark, or logo of + * Broadcom Corporation. Neither the "Broadcom Corporation" name nor any + * trademark or logo of Broadcom Corporation may be used to endorse or + * promote products derived from this software without the prior written + * permission of Broadcom Corporation. + * + * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE + * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE + * LIABLE FOR 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), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SBMIPS_INTR_H_ +#define _SBMIPS_INTR_H_ + +#include + +/* Interrupt levels */ +#define IPL_SERIAL 0 +#define IPL_STATCLOCK 1 +#define IPL_CLOCK 2 +#define IPL_BIO 3 +#define IPL_NET 4 +#define IPL_TTY 5 +#define _NIPL 6 + +#define IPL_SOFTSERIAL 1000 +#define IPL_SOFTNET 1001 +#define IPL_SOFTCLOCK 1002 + +#define _IMR_SOFT (MIPS_SOFT_INT_MASK_0 | MIPS_SOFT_INT_MASK_1) +#define _IMR_VM (_IMR_SOFT | MIPS_INT_MASK_0) +#define _IMR_SCHED (_IMR_VM | MIPS_INT_MASK_1 | MIPS_INT_MASK_5) +#define _IMR_SERIAL (_IMR_SCHED | MIPS_INT_MASK_2) +#define _IMR_HIGH (MIPS_INT_MASK) + +#define splbio() _splraise(_IMR_VM) +#define splclock() _splraise(_IMR_SCHED) +#define splhigh() _splraise(_IMR_HIGH) +#define spllock() splhigh() +#define splvm() _splraise(_IMR_VM) +#define splnet() _splraise(_IMR_VM) +#define splsched() _splraise(_IMR_SCHED) +#define splserial() _splraise(_IMR_SERIAL) +#define splsoftclock() _splraise(_IMR_SOFT) +#define splsoftnet() _splraise(_IMR_SOFT) +#define splsoftserial() _splraise(_IMR_SOFT) +#define splstatclock() _splraise(_IMR_SCHED) +#define spltty() _splraise(_IMR_VM) + +#define spl0() _spllower(0) +#define spllowersoftclock() _spllower(_IMR_SOFT) +#define splx(s) _splset(s) + +#define __GENERIC_SOFT_INTERRUPTS + +void *softintr_establish(int level, void (*fun)(void *), void *arg); +void softintr_disestablish(void *cookie); +void softintr_schedule(void *cookie); + +/* for interrupt dispatch code */ +void dosoftints(void); + +/* XXX backward-compat */ +void setsoftclock(void); +void setsoftnet(void); + +extern int _splraise(int); +extern int _spllower(int); +extern int _splset(int); +extern int _splget(void); +extern void _splnone(void); +extern void _setsoftintr(int); +extern void _clrsoftintr(int); + +/* XXX */ +extern u_long intrcnt[]; +#define SOFTCLOCK_INTR 0 +#define SOFTNET_INTR 1 + +#endif /* _SBMIPS_INTR_H_ */ diff --git a/sys/arch/sbmips/include/kcore.h b/sys/arch/sbmips/include/kcore.h new file mode 100644 index 000000000000..0b0ee71d93c9 --- /dev/null +++ b/sys/arch/sbmips/include/kcore.h @@ -0,0 +1,3 @@ +/* $NetBSD: kcore.h,v 1.1 2002/03/06 02:13:44 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/kdbparam.h b/sys/arch/sbmips/include/kdbparam.h new file mode 100644 index 000000000000..2d291d461f5b --- /dev/null +++ b/sys/arch/sbmips/include/kdbparam.h @@ -0,0 +1,3 @@ +/* $NetBSD: kdbparam.h,v 1.1 2002/03/06 02:13:44 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/leds.h b/sys/arch/sbmips/include/leds.h new file mode 100644 index 000000000000..e91c959408c2 --- /dev/null +++ b/sys/arch/sbmips/include/leds.h @@ -0,0 +1,39 @@ +/* $NetBSD: leds.h,v 1.1 2002/03/06 02:13:44 simonb Exp $ */ + +/* + * Copyright 2000 + * Broadcom Corporation. All rights reserved. + * + * This software is furnished under license and may be used and copied only + * in accordance with the following terms and conditions. Subject to these + * conditions, you may download, copy, install, use, modify and distribute + * modified or unmodified copies of this software in source and/or binary + * form. No title or ownership is transferred hereby. + * + * 1) Any source code used, modified or distributed must reproduce and + * retain this copyright notice and list of conditions as they appear in + * the source file. + * + * 2) No right is granted to use any trade name, trademark, or logo of + * Broadcom Corporation. Neither the "Broadcom Corporation" name nor any + * trademark or logo of Broadcom Corporation may be used to endorse or + * promote products derived from this software without the prior written + * permission of Broadcom Corporation. + * + * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE + * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE + * LIABLE FOR 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), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* XXX DOES NOT BELONG HERE */ + +void cswarm_setleds(const char *str); + diff --git a/sys/arch/sbmips/include/limits.h b/sys/arch/sbmips/include/limits.h new file mode 100644 index 000000000000..3325148ab034 --- /dev/null +++ b/sys/arch/sbmips/include/limits.h @@ -0,0 +1,3 @@ +/* $NetBSD: limits.h,v 1.1 2002/03/06 02:13:45 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/lock.h b/sys/arch/sbmips/include/lock.h new file mode 100644 index 000000000000..fc03023b33c2 --- /dev/null +++ b/sys/arch/sbmips/include/lock.h @@ -0,0 +1,4 @@ +/* $NetBSD: lock.h,v 1.1 2002/03/06 02:13:45 simonb Exp $ */ + +/* Just use the common mips definition */ +#include diff --git a/sys/arch/sbmips/include/locore.h b/sys/arch/sbmips/include/locore.h new file mode 100644 index 000000000000..b6d993ea8775 --- /dev/null +++ b/sys/arch/sbmips/include/locore.h @@ -0,0 +1,3 @@ +/* $NetBSD: locore.h,v 1.1 2002/03/06 02:13:45 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/math.h b/sys/arch/sbmips/include/math.h new file mode 100644 index 000000000000..82db9cd9c09d --- /dev/null +++ b/sys/arch/sbmips/include/math.h @@ -0,0 +1,3 @@ +/* $NetBSD: math.h,v 1.1 2002/03/06 02:13:45 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/mips_opcode.h b/sys/arch/sbmips/include/mips_opcode.h new file mode 100644 index 000000000000..608f7529f6f4 --- /dev/null +++ b/sys/arch/sbmips/include/mips_opcode.h @@ -0,0 +1,3 @@ +/* $NetBSD: mips_opcode.h,v 1.1 2002/03/06 02:13:45 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/param.h b/sys/arch/sbmips/include/param.h new file mode 100644 index 000000000000..9f98b289f143 --- /dev/null +++ b/sys/arch/sbmips/include/param.h @@ -0,0 +1,110 @@ +/* $NetBSD: param.h,v 1.1 2002/03/06 02:13:45 simonb 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. + */ + +#ifndef _SBMIPS_PARAM_H_ +#define _SBMIPS_PARAM_H_ + +/* + * Machine-dependent constants (VM, etc) common across MIPS cpus + */ + +#include + +/* + * Machine dependent constants for Broadcom/Sibyte boards. + */ + +#if defined(__MIPSEB__) +#define _MACHINE_ARCH mipseb +#define MACHINE_ARCH "mipseb" +#elif defined(__MIPSEL__) +#define _MACHINE_ARCH mipsel +#define MACHINE_ARCH "mipsel" +#else +#error neither __MIPSEL__ nor __MIPSEB__ are defined. +#endif + +#define _MACHINE sbmips +#define MACHINE "sbmips" +#define MID_MACHINE MID_PMAX /* XXX Bogus, but needed for now... */ + +#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 */ + +/* + * Constants related to network buffer management. + * MCLBYTES must be no larger than NBPG (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 256 /* size of an mbuf */ + +#ifndef MCLSHIFT +# define MCLSHIFT 11 /* convert bytes to m_buf clusters */ +#endif /* MCLSHIFT */ + +#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ +#define MCLOFSET (MCLBYTES - 1) + +#ifndef NMBCLUSTERS +#if defined(_KERNEL_OPT) +#include "opt_gateway.h" +#endif + +#ifdef GATEWAY +#define NMBCLUSTERS 2048 /* map size, max cluster allocation */ +#else +#define NMBCLUSTERS 1024 /* map size, max cluster allocation */ +#endif +#endif + +#ifdef _KERNEL +#ifndef _LOCORE + +#include +#include + +#endif /* _LOCORE */ +#endif /* _KERNEL */ + +#endif /* !_SBMIPS_PARAM_H_ */ diff --git a/sys/arch/sbmips/include/pcb.h b/sys/arch/sbmips/include/pcb.h new file mode 100644 index 000000000000..32b3284dd14f --- /dev/null +++ b/sys/arch/sbmips/include/pcb.h @@ -0,0 +1,3 @@ +/* $NetBSD: pcb.h,v 1.1 2002/03/06 02:13:46 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/pmap.h b/sys/arch/sbmips/include/pmap.h new file mode 100644 index 000000000000..b0a50fe59c90 --- /dev/null +++ b/sys/arch/sbmips/include/pmap.h @@ -0,0 +1,12 @@ +/* $NetBSD: pmap.h,v 1.1 2002/03/06 02:13:46 simonb Exp $ */ + +#include + +/* uncached accesses are bad; all accesses should be cached (and coherent) */ +#undef PMAP_PAGEIDLEZERO +#define PMAP_PAGEIDLEZERO(pa) (pmap_zero_page(pa), TRUE) + +int sbmips_cca_for_pa(paddr_t); + +#undef PMAP_CCA_FOR_PA +#define PMAP_CCA_FOR_PA(pa) sbmips_cca_for_pa(pa) diff --git a/sys/arch/sbmips/include/proc.h b/sys/arch/sbmips/include/proc.h new file mode 100644 index 000000000000..a630852cabb8 --- /dev/null +++ b/sys/arch/sbmips/include/proc.h @@ -0,0 +1,3 @@ +/* $NetBSD: proc.h,v 1.1 2002/03/06 02:13:46 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/profile.h b/sys/arch/sbmips/include/profile.h new file mode 100644 index 000000000000..163fbc4419c5 --- /dev/null +++ b/sys/arch/sbmips/include/profile.h @@ -0,0 +1,3 @@ +/* $NetBSD: profile.h,v 1.1 2002/03/06 02:13:46 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/psl.h b/sys/arch/sbmips/include/psl.h new file mode 100644 index 000000000000..3595e4d7cd41 --- /dev/null +++ b/sys/arch/sbmips/include/psl.h @@ -0,0 +1,3 @@ +/* $NetBSD: psl.h,v 1.1 2002/03/06 02:13:46 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/pte.h b/sys/arch/sbmips/include/pte.h new file mode 100644 index 000000000000..162a1e52fcc9 --- /dev/null +++ b/sys/arch/sbmips/include/pte.h @@ -0,0 +1,3 @@ +/* $NetBSD: pte.h,v 1.1 2002/03/06 02:13:47 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/ptrace.h b/sys/arch/sbmips/include/ptrace.h new file mode 100644 index 000000000000..1b47726c7ba2 --- /dev/null +++ b/sys/arch/sbmips/include/ptrace.h @@ -0,0 +1,3 @@ +/* $NetBSD: ptrace.h,v 1.1 2002/03/06 02:13:47 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/reg.h b/sys/arch/sbmips/include/reg.h new file mode 100644 index 000000000000..35656ca69cdb --- /dev/null +++ b/sys/arch/sbmips/include/reg.h @@ -0,0 +1,3 @@ +/* $NetBSD: reg.h,v 1.1 2002/03/06 02:13:47 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/regdef.h b/sys/arch/sbmips/include/regdef.h new file mode 100644 index 000000000000..0e587dc105c6 --- /dev/null +++ b/sys/arch/sbmips/include/regdef.h @@ -0,0 +1,3 @@ +/* $NetBSD: regdef.h,v 1.1 2002/03/06 02:13:47 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/regnum.h b/sys/arch/sbmips/include/regnum.h new file mode 100644 index 000000000000..9f67bbf19757 --- /dev/null +++ b/sys/arch/sbmips/include/regnum.h @@ -0,0 +1,3 @@ +/* $NetBSD: regnum.h,v 1.1 2002/03/06 02:13:47 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/reloc.h b/sys/arch/sbmips/include/reloc.h new file mode 100644 index 000000000000..05dc12172f1f --- /dev/null +++ b/sys/arch/sbmips/include/reloc.h @@ -0,0 +1,3 @@ +/* $NetBSD: reloc.h,v 1.1 2002/03/06 02:13:47 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/rnd.h b/sys/arch/sbmips/include/rnd.h new file mode 100644 index 000000000000..f1e660e4f7f5 --- /dev/null +++ b/sys/arch/sbmips/include/rnd.h @@ -0,0 +1,3 @@ +/* $NetBSD: rnd.h,v 1.1 2002/03/06 02:13:48 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/setjmp.h b/sys/arch/sbmips/include/setjmp.h new file mode 100644 index 000000000000..6c82a28c8556 --- /dev/null +++ b/sys/arch/sbmips/include/setjmp.h @@ -0,0 +1,3 @@ +/* $NetBSD: setjmp.h,v 1.1 2002/03/06 02:13:48 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/signal.h b/sys/arch/sbmips/include/signal.h new file mode 100644 index 000000000000..aa680b62f513 --- /dev/null +++ b/sys/arch/sbmips/include/signal.h @@ -0,0 +1,3 @@ +/* $NetBSD: signal.h,v 1.1 2002/03/06 02:13:48 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/stdarg.h b/sys/arch/sbmips/include/stdarg.h new file mode 100644 index 000000000000..58e2212e0d25 --- /dev/null +++ b/sys/arch/sbmips/include/stdarg.h @@ -0,0 +1,3 @@ +/* $NetBSD: stdarg.h,v 1.1 2002/03/06 02:13:49 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/systemsw.h b/sys/arch/sbmips/include/systemsw.h new file mode 100644 index 000000000000..0f7350531921 --- /dev/null +++ b/sys/arch/sbmips/include/systemsw.h @@ -0,0 +1,72 @@ +/* $NetBSD: systemsw.h,v 1.1 2002/03/06 02:13:49 simonb Exp $ */ + +/* + * Copyright 2000, 2001 + * Broadcom Corporation. All rights reserved. + * + * This software is furnished under license and may be used and copied only + * in accordance with the following terms and conditions. Subject to these + * conditions, you may download, copy, install, use, modify and distribute + * modified or unmodified copies of this software in source and/or binary + * form. No title or ownership is transferred hereby. + * + * 1) Any source code used, modified or distributed must reproduce and + * retain this copyright notice and list of conditions as they appear in + * the source file. + * + * 2) No right is granted to use any trade name, trademark, or logo of + * Broadcom Corporation. Neither the "Broadcom Corporation" name nor any + * trademark or logo of Broadcom Corporation may be used to endorse or + * promote products derived from this software without the prior written + * permission of Broadcom Corporation. + * + * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE + * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE + * LIABLE FOR 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), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SBMIPS_SYSTEMSW_H_ +#define _SBMIPS_SYSTEMSW_H_ + +#include + +struct systemsw { + /* ordered to match likely locality. */ + void (*s_cpu_intr)(uint32_t, uint32_t, uint32_t, uint32_t); + void (*s_cpu_setsoftintr)(void); + void (*s_microtime)(struct timeval *); + void (*s_delay)(u_long); + + void *s_clock_arg; + void (*s_clock_init)(void *); + + void (*s_statclock_init)(void *); + void (*s_statclock_setrate)(void *, int); + + void (*s_inittodr)(void *, time_t); + void (*s_resettodr)(void *); + + void *(*s_intr_establish)(u_int, u_int, + void (*fun)(void *, uint32_t, uint32_t), void *); +}; +extern struct systemsw systemsw; + +int system_set_clockfns(void *, void (*init)(void *)); + +#define delay(n) ((*systemsw.s_delay)(n)) +#define DELAY(n) ((*systemsw.s_delay)(n)) + +#define cpu_setsoftintr() ((*systemsw.s_cpu_setsoftintr)()) +#define cpu_intr_establish(n,s,f,a) ((*systemsw.s_intr_establish)(n,s,f,a)) + +void sb1250_icu_init(void); + +#endif /* _SBMIPS_SYSTEMSW_H_ */ diff --git a/sys/arch/sbmips/include/trap.h b/sys/arch/sbmips/include/trap.h new file mode 100644 index 000000000000..14c6d0fdbe9d --- /dev/null +++ b/sys/arch/sbmips/include/trap.h @@ -0,0 +1,3 @@ +/* $NetBSD: trap.h,v 1.1 2002/03/06 02:13:49 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/types.h b/sys/arch/sbmips/include/types.h new file mode 100644 index 000000000000..029e887909e8 --- /dev/null +++ b/sys/arch/sbmips/include/types.h @@ -0,0 +1,5 @@ +/* $NetBSD: types.h,v 1.1 2002/03/06 02:13:49 simonb Exp $ */ + +#include + +#define __HAVE_DEVICE_REGISTER diff --git a/sys/arch/sbmips/include/varargs.h b/sys/arch/sbmips/include/varargs.h new file mode 100644 index 000000000000..cf4539690cfa --- /dev/null +++ b/sys/arch/sbmips/include/varargs.h @@ -0,0 +1,3 @@ +/* $NetBSD: varargs.h,v 1.1 2002/03/06 02:13:50 simonb Exp $ */ + +#include diff --git a/sys/arch/sbmips/include/vmparam.h b/sys/arch/sbmips/include/vmparam.h new file mode 100644 index 000000000000..893d5ece9528 --- /dev/null +++ b/sys/arch/sbmips/include/vmparam.h @@ -0,0 +1,9 @@ +/* $NetBSD: vmparam.h,v 1.1 2002/03/06 02:13:50 simonb Exp $ */ + +#include + +/* XXXcgd */ +#define VM_PHYSSEG_MAX 8 + +#define VM_NFREELIST 1 +#define VM_FREELIST_DEFAULT 0 diff --git a/sys/arch/sbmips/sbmips/autoconf.c b/sys/arch/sbmips/sbmips/autoconf.c new file mode 100644 index 000000000000..31aed36390d0 --- /dev/null +++ b/sys/arch/sbmips/sbmips/autoconf.c @@ -0,0 +1,85 @@ +/* $NetBSD: autoconf.c,v 1.1 2002/03/06 02:13:50 simonb Exp $ */ + +/* + * Copyright 2000, 2001 + * Broadcom Corporation. All rights reserved. + * + * This software is furnished under license and may be used and copied only + * in accordance with the following terms and conditions. Subject to these + * conditions, you may download, copy, install, use, modify and distribute + * modified or unmodified copies of this software in source and/or binary + * form. No title or ownership is transferred hereby. + * + * 1) Any source code used, modified or distributed must reproduce and + * retain this copyright notice and list of conditions as they appear in + * the source file. + * + * 2) No right is granted to use any trade name, trademark, or logo of + * Broadcom Corporation. Neither the "Broadcom Corporation" name nor any + * trademark or logo of Broadcom Corporation may be used to endorse or + * promote products derived from this software without the prior written + * permission of Broadcom Corporation. + * + * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE + * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE + * LIABLE FOR 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), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include + +#ifdef IKOS +#include +#endif + +struct device *booted_device; +int booted_partition; + +void +cpu_configure(void) +{ + + (void)splhigh(); + +#ifdef IKOS + ikos_icu_init(); + if (system_set_clockfns(NULL, ikos_clock_init)) + panic("couldn't set clock init to ikos_clock_init"); +#else + if (config_rootfound("zbbus", NULL) == NULL) + panic("no zbbus found"); +#endif + + _splnone(); +} + +void +cpu_rootconf(void) +{ + + /* XXXCGD don't know how to find the root device */ + + printf("boot device: %s\n", + booted_device ? booted_device->dv_xname : ""); + + setroot(booted_device, booted_partition); +} + +void +device_register(struct device *dev, void *aux) +{ + + /* XXXCGD */ +} diff --git a/sys/arch/sbmips/sbmips/conf.c b/sys/arch/sbmips/sbmips/conf.c new file mode 100644 index 000000000000..269db58a6dd9 --- /dev/null +++ b/sys/arch/sbmips/sbmips/conf.c @@ -0,0 +1,481 @@ +/* $NetBSD: conf.c,v 1.1 2002/03/06 02:13:50 simonb 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. + */ + +#include /* RCS ID & Copyright macro defns */ + +__KERNEL_RCSID(0, "$NetBSD: conf.c,v 1.1 2002/03/06 02:13:50 simonb Exp $"); + +#include +#include +#include +#include +#include +#include +#include + +bdev_decl(sw); +cdev_decl(sw); + +#include "st.h" +bdev_decl(st); +#include "cd.h" +bdev_decl(cd); +#include "wd.h" +bdev_decl(wd); +#include "sd.h" +bdev_decl(sd); +#include "vnd.h" +bdev_decl(vnd); +#include "raid.h" +bdev_decl(raid); +#include "ccd.h" +bdev_decl(ccd); +#include "md.h" +bdev_decl(md); +#include "ld.h" +bdev_decl(ld); + +struct bdevsw bdevsw[] = +{ + bdev_notdef(), /* 0: XXX PC-ish floppy disk driver */ + bdev_swap_init(1,sw), /* 1: swap pseudo-device */ + bdev_tape_init(NST,st), /* 2: SCSI tape */ + bdev_disk_init(NCD,cd), /* 3: SCSI CD-ROM */ + bdev_disk_init(NWD,wd), /* 4: IDE disk driver */ + bdev_notdef(), /* 5 */ + bdev_disk_init(NMD,md), /* 6: memory disk driver */ + bdev_disk_init(NCCD,ccd), /* 7: concatenated disk driver */ + bdev_disk_init(NSD,sd), /* 8: SCSI disk driver */ + bdev_disk_init(NVND,vnd), /* 9: vnode disk driver */ + bdev_lkm_dummy(), /* 10 */ + bdev_lkm_dummy(), /* 11 */ + bdev_lkm_dummy(), /* 12 */ + bdev_lkm_dummy(), /* 13 */ + bdev_lkm_dummy(), /* 14 */ + bdev_lkm_dummy(), /* 15 */ + bdev_disk_init(NRAID,raid), /* 16: RAIDframe disk driver */ + bdev_disk_init(NLD,ld), /* 17: logical disk driver */ + bdev_lkm_dummy(), /* 18 */ + bdev_lkm_dummy(), /* 19 */ + bdev_lkm_dummy(), /* 20 */ + bdev_lkm_dummy(), /* 21 */ + bdev_lkm_dummy(), /* 22 */ + bdev_lkm_dummy(), /* 23 */ + bdev_lkm_dummy(), /* 24 */ + bdev_lkm_dummy(), /* 25 */ + bdev_lkm_dummy(), /* 26 */ + bdev_lkm_dummy(), /* 27 */ + bdev_lkm_dummy(), /* 28 */ + bdev_lkm_dummy(), /* 29 */ + bdev_lkm_dummy(), /* 30 */ + bdev_lkm_dummy(), /* 31 */ + bdev_lkm_dummy(), /* 32 */ + bdev_lkm_dummy(), /* 33 */ + bdev_lkm_dummy(), /* 34 */ + bdev_lkm_dummy(), /* 35 */ + bdev_lkm_dummy(), /* 36 */ + bdev_lkm_dummy(), /* 37 */ + bdev_lkm_dummy(), /* 38 */ + bdev_lkm_dummy(), /* 39 */ + bdev_lkm_dummy(), /* 40 */ + bdev_lkm_dummy(), /* 41 */ + bdev_lkm_dummy(), /* 42 */ + bdev_lkm_dummy(), /* 43 */ + bdev_lkm_dummy(), /* 44 */ + bdev_lkm_dummy(), /* 45 */ + bdev_lkm_dummy(), /* 46 */ + bdev_lkm_dummy(), /* 47 */ + bdev_lkm_dummy(), /* 48 */ + bdev_lkm_dummy(), /* 49 */ + bdev_lkm_dummy(), /* 50 */ + bdev_lkm_dummy(), /* 51 */ + bdev_lkm_dummy(), /* 52 */ + bdev_lkm_dummy(), /* 53 */ + bdev_lkm_dummy(), /* 54 */ + bdev_lkm_dummy(), /* 55 */ + bdev_lkm_dummy(), /* 56 */ + bdev_lkm_dummy(), /* 57 */ + bdev_lkm_dummy(), /* 58 */ + bdev_lkm_dummy(), /* 59 */ + bdev_lkm_dummy(), /* 60 */ + bdev_lkm_dummy(), /* 61 */ + bdev_lkm_dummy(), /* 62 */ + bdev_lkm_dummy(), /* 63 */ + bdev_lkm_dummy(), /* 64 */ + bdev_lkm_dummy(), /* 65 */ + bdev_lkm_dummy(), /* 66 */ + bdev_lkm_dummy(), /* 67 */ + bdev_lkm_dummy(), /* 68 */ + bdev_lkm_dummy(), /* 69 */ +}; +int nblkdev = sizeof(bdevsw) / sizeof(bdevsw[0]); + + +#ifdef IKOS +cdev_decl(ikoscons); +#else +#ifdef JTAGCONSOLE +cdev_decl(sbjcn); +#else +#include "sbscn.h" +cdev_decl(sbscn); +#endif +#endif + +cdev_decl(cn); +cdev_decl(ctty); +#define mmread mmrw +#define mmwrite 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); +#include "tun.h" +cdev_decl(tun); +cdev_decl(sd); +cdev_decl(vnd); +cdev_decl(ccd); +dev_type_open(filedescopen); +#include "bpfilter.h" +cdev_decl(bpf); +cdev_decl(st); +cdev_decl(cd); +#include "ch.h" +cdev_decl(ch); +#include "audio.h" +cdev_decl(audio); +#include "com.h" +cdev_decl(com); +cdev_decl(kbd); +cdev_decl(ms); +#include "lpt.h" +cdev_decl(lpt); +cdev_decl(md); +cdev_decl(raid); +#include "ses.h" +cdev_decl(ses); +#include "ss.h" +cdev_decl(ss); +#include "uk.h" +cdev_decl(uk); +cdev_decl(fd); +#include "ipfilter.h" +cdev_decl(ipl); +cdev_decl(wd); +#include "satlink.h" +cdev_decl(satlink); +#include "midi.h" +cdev_decl(midi); +#include "sequencer.h" +cdev_decl(music); +#include "mlx.h" +cdev_decl(mlx); + +#include "cy.h" +cdev_decl(cy); +#include "cz.h" +cdev_decl(cztty); + +#include "se.h" +#include "rnd.h" + +#include "wsdisplay.h" +cdev_decl(wsdisplay); +#include "wskbd.h" +cdev_decl(wskbd); +#include "wsmouse.h" +cdev_decl(wsmouse); +#include "wsmux.h" +cdev_decl(wsmux); + +#include "spkr.h" +cdev_decl(spkr); + +#include "scsibus.h" +cdev_decl(scsibus); + +#include "esh.h" +cdev_decl(esh_fp); + +#include "usb.h" +cdev_decl(usb); +#include "uhid.h" +cdev_decl(uhid); +#include "ugen.h" +cdev_decl(ugen); +#include "ulpt.h" +cdev_decl(ulpt); +#include "ucom.h" +cdev_decl(ucom); +#include "urio.h" +cdev_decl(urio); +#include "uscanner.h" +cdev_decl(uscanner); + +#include "i4b.h" +#include "i4bctl.h" +#include "i4btrc.h" +#include "i4brbch.h" +#include "i4btel.h" +cdev_decl(i4b); +cdev_decl(i4bctl); +cdev_decl(i4btrc); +cdev_decl(i4brbch); +cdev_decl(i4btel); + +#include + +#include "clockctl.h" +cdev_decl(clockctl); + +#include "pci.h" +cdev_decl(pci); + +struct cdevsw cdevsw[] = +{ + cdev_cn_init(1,cn), /* 0: virtual console */ + cdev_ctty_init(1,ctty), /* 1: controlling terminal */ + cdev_mm_init(1,mm), /* 2: /dev/{null,mem,kmem,...} */ + cdev_swap_init(1,sw), /* 3: /dev/drum (swap pseudo-device) */ + 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_bpftun_init(NTUN,tun), /* 7: network tunnel */ + cdev_disk_init(NSD,sd), /* 8: SCSI disk */ + cdev_disk_init(NVND,vnd), /* 9: vnode disk driver */ + cdev_fd_init(1,filedesc), /* 10: file descriptor pseudo-dev */ + cdev_bpftun_init(NBPFILTER,bpf),/* 11: Berkeley packet filter */ + cdev_tape_init(NST,st), /* 12: SCSI tape */ + cdev_disk_init(NCD,cd), /* 13: SCSI CD-ROM */ + cdev_ch_init(NCH,ch), /* 14: SCSI autochanger */ + cdev_notdef(), /* 15 */ + cdev_lkm_init(NLKM,lkm), /* 16: loadable module driver */ +#ifdef IKOS + cdev_tty_init(1,ikoscons), /* 17: ikos console memory buffer */ +#else +#ifdef JTAGCONSOLE + cdev_tty_init(1,sbjcn), /* 17: JTAG serial port */ +#else + cdev_tty_init(NSBSCN,sbscn), /* 17: sbscn serial port */ +#endif +#endif + cdev_lkm_dummy(), /* 18 */ + cdev_lkm_dummy(), /* 19 */ + cdev_lkm_dummy(), /* 20 */ + cdev_lkm_dummy(), /* 21 */ + cdev_lkm_dummy(), /* 22 */ + cdev_lkm_dummy(), /* 23 */ + cdev_audio_init(NAUDIO,audio), /* 24: generic audio I/O */ + cdev_wsdisplay_init(NWSDISPLAY, + wsdisplay), /* 25: frame buffers, etc. */ + cdev_tty_init(NCOM,com), /* 26: ns16550 UART */ + cdev_disk_init(NCCD,ccd), /* 27: concatenated disk driver */ + cdev_disk_init(NMD,md), /* 28: memory disk driver */ + cdev_mouse_init(NWSKBD, wskbd), /* 29: keyboards */ + cdev_mouse_init(NWSMOUSE, + wsmouse), /* 30: mice */ + cdev_lpt_init(NLPT,lpt), /* 31: parallel printer */ + cdev_scanner_init(NSS,ss), /* 32: SCSI scanner */ + cdev_uk_init(NUK,uk), /* 33: SCSI unknown */ + cdev_notdef(), /* 34: XXX PC-ish floppy disk driver */ + cdev_ipf_init(NIPFILTER,ipl), /* 35: ip-filter device */ + cdev_disk_init(NWD,wd), /* 36: IDE disk driver */ + cdev_se_init(NSE,se), /* 37: Cabletron SCSI<->Ethernet */ + cdev_satlink_init(NSATLINK,satlink), /* 38: planetconnect satlink */ + cdev_rnd_init(NRND,rnd), /* 39: random source pseudo-device */ + cdev_notdef(), /* 40: */ + cdev_spkr_init(NSPKR,spkr), /* 41: PC speaker */ + cdev_scsibus_init(NSCSIBUS,scsibus), /* 42: SCSI bus */ + cdev_disk_init(NRAID,raid), /* 43: RAIDframe disk driver */ + cdev_esh_init(NESH, esh_fp), /* 44: HIPPI (esh) raw device */ + cdev_usb_init(NUSB,usb), /* 45: USB controller */ + cdev_usbdev_init(NUHID,uhid), /* 46: USB generic HID */ + cdev_lpt_init(NULPT,ulpt), /* 47: USB printer */ + cdev_ugen_init(NUGEN,ugen), /* 48: USB generic driver */ + cdev_midi_init(NMIDI,midi), /* 49: MIDI I/O */ + cdev_midi_init(NSEQUENCER,sequencer), /* 50: sequencer I/O */ + cdev_i4b_init(NI4B, i4b), /* 51: i4b main device */ + cdev_i4bctl_init(NI4BCTL, i4bctl), /* 52: i4b control device */ + cdev_i4brbch_init(NI4BRBCH, i4brbch), /* 53: i4b raw b-chnl access */ + cdev_i4btrc_init(NI4BTRC, i4btrc), /* 54: i4b trace device */ + cdev_i4btel_init(NI4BTEL, i4btel), /* 55: i4b phone device */ + cdev_mouse_init(NWSMUX, wsmux), /* 56: ws multiplexor */ + cdev_tty_init(NUCOM, ucom), /* 57: USB tty */ + cdev_ses_init(NSES,ses), /* 58: SCSI SES/SAF-TE */ + cdev_disk_init(NLD,ld), /* 59: logical disk driver */ + cdev_tty_init(NCY,cy), /* 60: Cyclades Cyclom-Y serial */ + cdev_tty_init(NCZ,cztty), /* 61: Cyclades-Z serial */ + cdev_usbdev_init(NURIO,urio), /* 62: Diamond Rio 500 */ + cdev_ugen_init(NUSCANNER,uscanner),/* 63: USB scanner */ + cdev_altq_init(NALTQ,altq), /* 64: ALTQ control interface */ + cdev__oci_init(NMLX,mlx), /* 65: Mylex DAC960 control interface */ + cdev_pci_init(NPCI,pci), /* 66: PCI bus access device */ + cdev_notdef(), /* 67 */ + cdev_notdef(), /* 68 */ + cdev_clockctl_init(NCLOCKCTL,clockctl), /* 69: clockctl pseudo device */ +}; +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); + +/* + * Returns true if dev is /dev/mem or /dev/kmem. + */ +int +iskmemdev(dev_t dev) +{ + + return (major(dev) == mem_no && minor(dev) < 2); +} + +/* + * Returns true if dev is /dev/zero. + */ +int +iszerodev(dev_t dev) +{ + + return (major(dev) == mem_no && minor(dev) == 12); +} + +static int chrtoblktbl[] = { + /* XXXX This needs to be dynamic for LKMs. */ + /*VCHR*/ /*VBLK*/ + /* 0 */ NODEV, + /* 1 */ NODEV, + /* 2 */ NODEV, + /* 3 */ NODEV, + /* 4 */ NODEV, + /* 5 */ NODEV, + /* 6 */ NODEV, + /* 7 */ NODEV, + /* 8 */ 8, /* sd */ + /* 9 */ 9, /* vnd */ + /* 10 */ NODEV, + /* 11 */ NODEV, + /* 12 */ 2, /* st */ + /* 13 */ 3, /* cd */ + /* 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 */ 7, /* ccd */ + /* 28 */ 6, /* md */ + /* 29 */ NODEV, + /* 30 */ NODEV, + /* 31 */ NODEV, + /* 32 */ NODEV, + /* 33 */ NODEV, + /* 34 */ 0, /* fd */ + /* 35 */ NODEV, + /* 36 */ 4, /* wd */ + /* 37 */ NODEV, + /* 38 */ NODEV, + /* 39 */ NODEV, + /* 40 */ NODEV, + /* 41 */ NODEV, + /* 42 */ NODEV, + /* 43 */ 16, /* raid */ + /* 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, + /* 57 */ NODEV, + /* 58 */ NODEV, + /* 59 */ 17, /* ld */ + /* 60 */ NODEV, + /* 61 */ NODEV, + /* 62 */ NODEV, + /* 63 */ NODEV, + /* 64 */ NODEV, + /* 65 */ NODEV, + /* 66 */ NODEV, + /* 67 */ NODEV, + /* 68 */ NODEV, + /* 69 */ NODEV, +}; + +/* + * Convert a character device number to a block device number. + */ +dev_t +chrtoblk(dev_t dev) +{ + int blkmaj; + + if (major(dev) >= nchrdev) + return (NODEV); + blkmaj = chrtoblktbl[major(dev)]; + if (blkmaj == NODEV) + return (NODEV); + return (makedev(blkmaj, minor(dev))); +} diff --git a/sys/arch/sbmips/sbmips/console.c b/sys/arch/sbmips/sbmips/console.c new file mode 100644 index 000000000000..9b73f4efb234 --- /dev/null +++ b/sys/arch/sbmips/sbmips/console.c @@ -0,0 +1,69 @@ +/* $NetBSD: console.c,v 1.1 2002/03/06 02:13:51 simonb Exp $ */ + +/* + * Copyright 2000, 2001 + * Broadcom Corporation. All rights reserved. + * + * This software is furnished under license and may be used and copied only + * in accordance with the following terms and conditions. Subject to these + * conditions, you may download, copy, install, use, modify and distribute + * modified or unmodified copies of this software in source and/or binary + * form. No title or ownership is transferred hereby. + * + * 1) Any source code used, modified or distributed must reproduce and + * retain this copyright notice and list of conditions as they appear in + * the source file. + * + * 2) No right is granted to use any trade name, trademark, or logo of + * Broadcom Corporation. Neither the "Broadcom Corporation" name nor any + * trademark or logo of Broadcom Corporation may be used to endorse or + * promote products derived from this software without the prior written + * permission of Broadcom Corporation. + * + * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE + * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE + * LIABLE FOR 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), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include + +#ifdef IKOS +#include +#else +#ifdef JTAGCONSOLE +#include +#endif +#include +#endif + +#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */ + +void +consinit(void) +{ + +#ifdef IKOS + ikoscons_cnattach(); +#else +#ifdef JTAGCONSOLE + sbjcn_cnattach(0x1001FF80, 0, 115200, CONMODE); +#else + sbscn_cnattach(0x10060100, 0, 115200, CONMODE); +#ifdef KGDB + sbscn_kgdb_attach(0x10060100, 1, 115200, CONMODE); +#endif +#endif +#endif +} diff --git a/sys/arch/sbmips/sbmips/cpu.c b/sys/arch/sbmips/sbmips/cpu.c new file mode 100644 index 000000000000..03cdad9732e1 --- /dev/null +++ b/sys/arch/sbmips/sbmips/cpu.c @@ -0,0 +1,92 @@ +/* $NetBSD: cpu.c,v 1.1 2002/03/06 02:13:51 simonb Exp $ */ + +/* + * Copyright 2000, 2001 + * Broadcom Corporation. All rights reserved. + * + * This software is furnished under license and may be used and copied only + * in accordance with the following terms and conditions. Subject to these + * conditions, you may download, copy, install, use, modify and distribute + * modified or unmodified copies of this software in source and/or binary + * form. No title or ownership is transferred hereby. + * + * 1) Any source code used, modified or distributed must reproduce and + * retain this copyright notice and list of conditions as they appear in + * the source file. + * + * 2) No right is granted to use any trade name, trademark, or logo of + * Broadcom Corporation. Neither the "Broadcom Corporation" name nor any + * trademark or logo of Broadcom Corporation may be used to endorse or + * promote products derived from this software without the prior written + * permission of Broadcom Corporation. + * + * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE + * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE + * LIABLE FOR 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), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include + +static int cpu_match(struct device *, struct cfdata *, void *); +static void cpu_attach(struct device *, struct device *, void *); + +struct cfattach cpu_ca = { + sizeof(struct device), cpu_match, cpu_attach +}; + +static int +cpu_match(struct device *parent, struct cfdata *match, void *aux) +{ + struct zbbus_attach_args *zap = aux; + + if (zap->za_locs.za_type != ZBBUS_ENTTYPE_CPU) + return (0); + + return 1; +} + +static void +cpu_attach(struct device *parent, struct device *self, void *aux) +{ + uint32_t config; + + /* XXX this code must run on the target cpu */ + config = mips3_cp0_config_read(); + config &= ~MIPS3_CONFIG_K0_MASK; + config |= 0x05; /* XXX. cacheable coherent */ + mips3_cp0_config_write(config); + + /* + * Flush all of the caches, so that any lines marked non-coherent will + * be flushed. Don't need to worry about L2; it's always + * coherent (XXX???). + */ + mips_icache_sync_all(); + mips_dcache_wbinv_all(); + + printf("%s: ", self->dv_xname); + cpu_identify(); + + /* make sure processor is available for use */ + /* XXXCGD */ +} diff --git a/sys/arch/sbmips/sbmips/disksubr.c b/sys/arch/sbmips/sbmips/disksubr.c new file mode 100644 index 000000000000..16c845fabf9e --- /dev/null +++ b/sys/arch/sbmips/sbmips/disksubr.c @@ -0,0 +1,455 @@ +/* $NetBSD: disksubr.c,v 1.1 2002/03/06 02:13:51 simonb Exp $ */ + +/* + * Copyright (c) 1982, 1986, 1988 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. + */ + +#include +#include +#include +#include +#include +#include + +#define NO_MBR_SIGNATURE ((struct mbr_partition *) -1) + +static struct mbr_partition * +mbr_findslice(struct mbr_partition* dp, struct buf *bp); + +/* + * Scan MBR for NetBSD partittion. Return NO_MBR_SIGNATURE if no MBR found + * Otherwise, copy valid MBR partition-table into dp, and if a NetBSD + * partition is found, return a pointer to it; else return NULL. + */ +static +struct mbr_partition * +mbr_findslice(dp, bp) + struct mbr_partition *dp; + struct buf *bp; +{ + struct mbr_partition *ourdp = NULL; + uint16_t *mbrmagicp; + int i; + + /* Note: Magic number is little-endian. */ + mbrmagicp = (uint16_t *)(bp->b_data + MBR_MAGICOFF); + if (*mbrmagicp != MBR_MAGIC) + return (NO_MBR_SIGNATURE); + + /* XXX how do we check veracity/bounds of this? */ + memcpy(dp, bp->b_data + MBR_PARTOFF, NMBRPART * sizeof(*dp)); + + /* look for NetBSD partition */ + for (i = 0; i < NMBRPART; i++) { + if (dp[i].mbrp_typ == MBR_PTYPE_NETBSD) { + ourdp = &dp[i]; + break; + } + } + + return (ourdp); +} + + +/* + * Attempt to read a disk label from a device + * using the indicated stategy routine. + * The label must be partly set up before this: + * secpercyl, secsize and anything required for a block i/o read + * operation in the driver's strategy/start routines + * must be filled in before calling us. + * + * If dos partition table requested, attempt to load it and + * find disklabel inside a DOS partition. Also, if bad block + * table needed, attempt to extract it as well. Return buffer + * for use in signalling errors if requested. + * + * Returns null on success and an error string on failure. + */ +char * +readdisklabel(dev, strat, lp, osdep) + dev_t dev; + void (*strat)(struct buf *); + struct disklabel *lp; + struct cpu_disklabel *osdep; +{ + struct mbr_partition *dp; + struct partition *pp; + struct dkbad *bdp; + struct buf *bp; + struct disklabel *dlp; + char *msg = NULL; + int dospartoff, cyl, i; + + /* minimal requirements for archtypal disk label */ + if (lp->d_secsize == 0) + lp->d_secsize = DEV_BSIZE; + if (lp->d_secperunit == 0) + lp->d_secperunit = 0x1fffffff; +#if 0 + if (lp->d_ncylinders == 16383) { + printf("disklabel: Disk > 8G ... readjusting chs %d/%d/%d to ", + lp->d_ncylinders, lp->d_ntracks, lp->d_nsectors); + lp->d_ncylinders = lp->d_secperunit / lp->d_ntracks / lp->d_nsectors; + printf("%d/%d/%d\n", + lp->d_ncylinders, lp->d_ntracks, lp->d_nsectors); + } +#endif + 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[i].p_size == 0) + lp->d_partitions[i].p_size = 0x1fffffff; + lp->d_partitions[i].p_offset = 0; + + /* get a buffer and initialize it */ + bp = geteblk((int)lp->d_secsize); + bp->b_dev = dev; + + /* do dos partitions in the process of getting disklabel? */ + dospartoff = 0; + cyl = LABELSECTOR / lp->d_secpercyl; + if (!osdep) + goto nombrpart; + dp = osdep->dosparts; + + /* read master boot record */ + bp->b_blkno = MBR_BBSECTOR; + bp->b_bcount = lp->d_secsize; + bp->b_flags = B_BUSY | B_READ; + bp->b_cylinder = MBR_BBSECTOR / lp->d_secpercyl; + (*strat)(bp); + + /* if successful, wander through dos partition table */ + if (biowait(bp)) { + msg = "dos partition I/O error"; + goto done; + } else { + struct mbr_partition *ourdp = NULL; + + ourdp = mbr_findslice(dp, bp); + if (ourdp == NO_MBR_SIGNATURE) + goto nombrpart; + + for (i = 0; i < NMBRPART; i++, dp++) { + /* Install in partition e, f, g, or h. */ + pp = &lp->d_partitions[RAW_PART + 1 + i]; + pp->p_offset = dp->mbrp_start; + pp->p_size = dp->mbrp_size; + if (dp->mbrp_typ == MBR_PTYPE_LNXEXT2) + pp->p_fstype = FS_EX2FS; + + if (dp->mbrp_typ == MBR_PTYPE_LNXSWAP) + pp->p_fstype = FS_SWAP; + + /* is this ours? */ + if (dp == ourdp) { + /* need sector address for SCSI/IDE, + cylinder for ESDI/ST506/RLL */ + dospartoff = dp->mbrp_start; + cyl = MBR_PCYL(dp->mbrp_scyl, dp->mbrp_ssect); + + /* update disklabel with details */ + lp->d_partitions[2].p_size = + dp->mbrp_size; + lp->d_partitions[2].p_offset = + dp->mbrp_start; + } + } + lp->d_npartitions = RAW_PART + 1 + i; + } + +nombrpart: + /* next, dig out disk label */ + bp->b_blkno = dospartoff + LABELSECTOR; + bp->b_cylinder = cyl; + 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 I/O error"; + goto done; + } + for (dlp = (struct disklabel *)bp->b_data; + dlp <= (struct disklabel *)(bp->b_data + lp->d_secsize - sizeof(*dlp)); + dlp = (struct disklabel *)((char *)dlp + sizeof(long))) { + if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) { + if (msg == NULL) + msg = "no disk label"; + } else if (dlp->d_npartitions > MAXPARTITIONS || + dkcksum(dlp) != 0) + msg = "disk label corrupted"; + else { + *lp = *dlp; + msg = NULL; + break; + } + } + + if (msg) + goto done; + + /* obtain bad sector table if requested and present */ + if (osdep && (lp->d_flags & D_BADSECT)) { + struct dkbad *db; + + bdp = &osdep->bad; + i = 0; + do { + /* read a bad sector table */ + bp->b_flags = B_BUSY | B_READ; + bp->b_blkno = lp->d_secperunit - lp->d_nsectors + i; + if (lp->d_secsize > DEV_BSIZE) + bp->b_blkno *= lp->d_secsize / DEV_BSIZE; + else + bp->b_blkno /= DEV_BSIZE / lp->d_secsize; + bp->b_bcount = lp->d_secsize; + bp->b_cylinder = lp->d_ncylinders - 1; + (*strat)(bp); + + /* if successful, validate, otherwise try another */ + if (biowait(bp)) { + msg = "bad sector table I/O error"; + } else { + db = (struct dkbad *)(bp->b_data); +#define DKBAD_MAGIC 0x4321 + if (db->bt_mbz == 0 + && db->bt_flag == DKBAD_MAGIC) { + msg = NULL; + *bdp = *db; + break; + } else + msg = "bad sector table corrupted"; + } + } while ((bp->b_flags & B_ERROR) && (i += 2) < 10 && + i < lp->d_nsectors); + } + +done: + bp->b_flags |= B_INVAL; + brelse(bp); + return (msg); +} + +/* + * Check new disk label for sensibility + * before setting it. + */ +int +setdisklabel(olp, nlp, openmask, osdep) + struct disklabel *olp, *nlp; + u_long openmask; + struct cpu_disklabel *osdep; +{ + int i; + struct partition *opp, *npp; + + /* sanity clause */ + if (nlp->d_secpercyl == 0 || nlp->d_secsize == 0 + || (nlp->d_secsize % DEV_BSIZE) != 0) + return(EINVAL); + + /* special case to allow disklabel to be invalidated */ + if (nlp->d_magic == 0xffffffff) { + *olp = *nlp; + return (0); + } + + if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC || + dkcksum(nlp) != 0) + return (EINVAL); + + /* XXX missing check if other dos partitions will be overwritten */ + + while (openmask != 0) { + i = ffs(openmask) - 1; + 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. + */ +int +writedisklabel(dev, strat, lp, osdep) + dev_t dev; + void (*strat)(struct buf *); + struct disklabel *lp; + struct cpu_disklabel *osdep; +{ + struct mbr_partition *dp; + struct buf *bp; + struct disklabel *dlp; + int error, dospartoff, cyl; + + /* get a buffer and initialize it */ + bp = geteblk((int)lp->d_secsize); + bp->b_dev = dev; + + /* do dos partitions in the process of getting disklabel? */ + dospartoff = 0; + cyl = LABELSECTOR / lp->d_secpercyl; + if (!osdep) + goto nombrpart; + dp = osdep->dosparts; + + /* read master boot record */ + bp->b_blkno = MBR_BBSECTOR; + bp->b_bcount = lp->d_secsize; + bp->b_flags = B_BUSY | B_READ; + bp->b_cylinder = MBR_BBSECTOR / lp->d_secpercyl; + (*strat)(bp); + + if ((error = biowait(bp)) == 0) { + struct mbr_partition *ourdp = NULL; + + ourdp = mbr_findslice(dp, bp); + if (ourdp == NO_MBR_SIGNATURE) + goto nombrpart; + + if (ourdp) { + /* need sector address for SCSI/IDE, + cylinder for ESDI/ST506/RLL */ + dospartoff = ourdp->mbrp_start; + cyl = MBR_PCYL(ourdp->mbrp_scyl, ourdp->mbrp_ssect); + } + } + +nombrpart: + /* next, dig out disk label */ + bp->b_blkno = dospartoff + LABELSECTOR; + bp->b_cylinder = cyl; + 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 ((error = biowait(bp)) != 0) + goto done; + for (dlp = (struct disklabel *)bp->b_data; + dlp <= (struct disklabel *)(bp->b_data + lp->d_secsize - sizeof(*dlp)); + dlp = (struct disklabel *)((char *)dlp + sizeof(long))) { + if (dlp->d_magic == DISKMAGIC && dlp->d_magic2 == DISKMAGIC && + dkcksum(dlp) == 0) { + *dlp = *lp; + bp->b_flags = B_BUSY | B_WRITE; + (*strat)(bp); + error = biowait(bp); + goto done; + } + } + error = ESRCH; + +done: + bp->b_flags |= B_INVAL; + 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; +{ + struct partition *p = lp->d_partitions + DISKPART(bp->b_dev); + int labelsector = lp->d_partitions[2].p_offset + LABELSECTOR; + int sz; + + sz = howmany(bp->b_bcount, lp->d_secsize); + + if (bp->b_blkno + sz > p->p_size) { + sz = p->p_size - bp->b_blkno; + if (sz == 0) { + /* If exactly at end of disk, return EOF. */ + bp->b_resid = bp->b_bcount; + goto done; + } + if (sz < 0) { + /* If past end of disk, return EINVAL. */ + bp->b_error = EINVAL; + goto bad; + } + /* Otherwise, truncate request. */ + bp->b_bcount = sz << DEV_BSHIFT; + } + + /* Overwriting disk label? */ + if (bp->b_blkno + p->p_offset <= labelsector && +#if LABELSECTOR != 0 + bp->b_blkno + p->p_offset + sz > labelsector && +#endif + (bp->b_flags & B_READ) == 0 && !wlabel) { + bp->b_error = EROFS; + goto bad; + } + + /* calculate cylinder for disksort to order transfers with */ + bp->b_cylinder = (bp->b_blkno + p->p_offset) / + (lp->d_secsize / DEV_BSIZE) / lp->d_secpercyl; + return (1); + +bad: + bp->b_flags |= B_ERROR; +done: + return (0); +} diff --git a/sys/arch/sbmips/sbmips/locore_machdep.S b/sys/arch/sbmips/sbmips/locore_machdep.S new file mode 100644 index 000000000000..005c6badb88e --- /dev/null +++ b/sys/arch/sbmips/sbmips/locore_machdep.S @@ -0,0 +1,20 @@ +/* $NetBSD: locore_machdep.S,v 1.1 2002/03/06 02:13:51 simonb Exp $ */ + +#include + + .data + .globl _C_LABEL(intrcnt) + .globl _C_LABEL(eintrcnt) + .globl _C_LABEL(intrnames) + .globl _C_LABEL(eintrnames) + +_C_LABEL(intrnames): + .asciiz "softclock" + .asciiz "softnet" +_C_LABEL(eintrnames): + + .align 2 +_C_LABEL(intrcnt): + .word 0,0 +_C_LABEL(eintrcnt): + .word 0 diff --git a/sys/arch/sbmips/sbmips/machdep.c b/sys/arch/sbmips/sbmips/machdep.c new file mode 100644 index 000000000000..ba89d75499dd --- /dev/null +++ b/sys/arch/sbmips/sbmips/machdep.c @@ -0,0 +1,623 @@ +/* $NetBSD: machdep.c,v 1.1 2002/03/06 02:13:51 simonb Exp $ */ + +/* + * Copyright 2000, 2001 + * Broadcom Corporation. All rights reserved. + * + * This software is furnished under license and may be used and copied only + * in accordance with the following terms and conditions. Subject to these + * conditions, you may download, copy, install, use, modify and distribute + * modified or unmodified copies of this software in source and/or binary + * form. No title or ownership is transferred hereby. + * + * 1) Any source code used, modified or distributed must reproduce and + * retain this copyright notice and list of conditions as they appear in + * the source file. + * + * 2) No right is granted to use any trade name, trademark, or logo of + * Broadcom Corporation. Neither the "Broadcom Corporation" name nor any + * trademark or logo of Broadcom Corporation may be used to endorse or + * promote products derived from this software without the prior written + * permission of Broadcom Corporation. + * + * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE + * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE + * LIABLE FOR 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), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Copyright (c) 2000 Soren S. Jorvang. 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 "opt_ddb.h" +#include "opt_execfmt.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#if 0 /* XXXCGD */ +#include +#endif /* XXXCGD */ +#include + +#ifdef DDB +#include +#include +#include +#include +#ifndef DB_ELFSIZE +#error Must define DB_ELFSIZE! +#endif +#define ELFSIZE DB_ELFSIZE +#include +#endif + +#include + +#ifdef IKOS +#include +#endif + +/* For sysctl. */ +char machine[] = MACHINE; +char machine_arch[] = MACHINE_ARCH; +char cpu_model[] = "sb1250"; + +/* Our exported CPU info. Only one for now */ +struct cpu_info cpu_info_store; + +/* Maps for VM objects. */ +struct vm_map *exec_map = NULL; +struct vm_map *mb_map = NULL; +struct vm_map *phys_map = NULL; + +int physmem; /* Total physical memory */ + +char bootstring[512]; /* Boot command */ +int netboot; /* Are we netbooting? */ +int cfe_present; + +struct bootinfo_v1 bootinfo; + +phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX]; +int mem_cluster_cnt; + +void configure(void); +void mach_init(long,long,long,long); + +/* + * safepri is a safe priority for sleep to set for a spin-wait during + * autoconfiguration or after a panic. Used as an argument to splx(). + */ +int safepri = MIPS_INT_MASK | MIPS_SR_INT_IE; + +extern caddr_t esym; +extern struct user *proc0paddr; + +/* + * Do all the stuff that locore normally does before calling main(). + */ +void +mach_init(fwhandle,magic,bootdata,reserved) + long fwhandle; + long magic; + long bootdata; + long reserved; +{ + caddr_t kernend, v, p0; + u_long first, last; + vsize_t size; + extern char edata[], end[]; + int i; + u_int memsize; + uint32_t config; + + /* XXX this code must run on the target cpu */ + config = mips3_cp0_config_read(); + config &= ~MIPS3_CONFIG_K0_MASK; + config |= 0x05; /* XXX. cacheable coherent */ + mips3_cp0_config_write(config); + + /* XXXCGD */ +#ifdef SBMIPS_MEM_SIZE + memsize = SBMIPS_MEM_SIZE; +#else + memsize = 32 * 1024 * 1024; +#endif + memsize += MIPS_KSEG0_START; + + /* + * Clear the BSS segment. + */ +#ifdef DDB + if (memcmp(((Elf_Ehdr *)end)->e_ident, ELFMAG, SELFMAG) == 0 && + ((Elf_Ehdr *)end)->e_ident[EI_CLASS] == ELFCLASS) { + esym = end; + esym += ((Elf_Ehdr *)end)->e_entry; + kernend = (caddr_t)mips_round_page(esym); + bzero(edata, end - edata); + } else +#endif + { + kernend = (caddr_t)mips_round_page(end); + memset(edata, 0, kernend - edata); + } + + /* + * Copy the bootinfo structure from the boot loader. + * this has to be done before mips_vector_init is + * called because we may need CFE's TLB handler + */ + + cfe_present = 0; + if (magic == BOOTINFO_MAGIC) + bcopy((struct bootinfo_v1 *)bootdata, &bootinfo, + sizeof bootinfo); + else if (reserved == CFE_EPTSEAL) { + magic = BOOTINFO_MAGIC; + bzero(&bootinfo, sizeof bootinfo); + bootinfo.version = BOOTINFO_VERSION; + bootinfo.fwhandle = fwhandle; + bootinfo.fwentry = bootdata; + } + +#ifdef IKOS + ikoscons_output_bufsize = IKOSCONS_OUTPUT_BUFSIZE; + memsize -= ikoscons_output_bufsize; + ikoscons_output_buf = + (void *)MIPS_PHYS_TO_KSEG1(MIPS_KSEG0_TO_PHYS(memsize)); + memset(ikoscons_output_buf, 0, ikoscons_output_bufsize); +#endif + + /* + * physmem is measured in pages + * XXX does this need to be set for 'consinit', 'uvm_setpagesize', + * XXX or 'mips_vector_init'? not that I can tell right now... + * XXX if CFE is present, this will be recalculated. + * XXX + * XXX Does 'physmem' want to be the total amount of RAM in the + * XXX system, or the amount that is available to us? + */ + physmem = btoc(memsize - MIPS_KSEG0_START); + + consinit(); + + uvm_setpagesize(); + + /* + * Copy exception-dispatch code down to exception vector. + * Initialize locore-function vector. + * Clear out the I and D caches. + */ + mips_vector_init(); + +#if 0 +*(unsigned long long *)0xb0020440 = 3; +#endif + + printf("fwhandle=%08X magic=%08X bootdata=%08X reserved=%08X\n", + (u_int) fwhandle,(u_int) magic,(u_int) bootdata,(u_int) reserved); + + if (magic == BOOTINFO_MAGIC) { + int idx; + int added; + cfe_xuint_t start,len,type; + + cfe_init(fwhandle); + cfe_present = 1; + + idx = 0; + physmem = 0; + mem_cluster_cnt = 0; + while (cfe_getmeminfo(idx,&start,&len,&type) == 0) { + added = 0; + printf("Memory Block #%d start %08llX len %08llX: %s: ",idx, + start,len, + (type == CFE_MI_AVAILABLE) ? "Available" : "Reserved"); + if ((type == CFE_MI_AVAILABLE) && (mem_cluster_cnt < VM_PHYSSEG_MAX)) { + /* + * XXX Ignore memory above 256MB for now, it needs special + * XXX handling. + */ + if (start < (256*1024*1024)) { + physmem += btoc(((int) len)); + mem_clusters[mem_cluster_cnt].start = (long) start; + mem_clusters[mem_cluster_cnt].size = (long) len; + mem_cluster_cnt++; + added = 1; + } + } + if (added) + printf("added to map\n"); + else + printf("not added to map\n"); + idx++; + } + + } + else { + /* + * Handle the case of not being called from the firmware. + */ + mem_clusters[0].start = 0; + mem_clusters[0].size = ctob(physmem); + mem_cluster_cnt = 1; + } + + + for (i = 0; i < sizeof(bootinfo.boot_flags); i++) { + switch (bootinfo.boot_flags[i]) { + case '\0': + break; + case ' ': + continue; + case '-': + while (bootinfo.boot_flags[i] != ' ' && bootinfo.boot_flags[i] != '\0') { + switch (bootinfo.boot_flags[i]) { + case 'a': + boothowto |= RB_ASKNAME; + break; + case 'd': + boothowto |= RB_KDB; + break; + case 's': + boothowto |= RB_SINGLE; + break; + } + i++; + } + } + if (memcmp("single", &bootinfo.boot_flags[i], 5) == 0) + boothowto |= RB_SINGLE; + if (memcmp("nfsroot=", &bootinfo.boot_flags[i], 8) == 0) + netboot = 1; + /* + * XXX Select root device from 'root=/dev/hd[abcd][1234]' too. + */ + } + + /* + * Load the rest of the available pages into the VM system. + * The first chunk is tricky because we have to avoid the + * kernel, but the rest are easy. + */ + first = round_page(MIPS_KSEG0_TO_PHYS(kernend)); + last = mem_clusters[0].start + mem_clusters[0].size; + uvm_page_physload(atop(first), atop(last), atop(first), atop(last), + VM_FREELIST_DEFAULT); + + for (i = 1; i < mem_cluster_cnt; i++) { + first = round_page(mem_clusters[i].start); + last = mem_clusters[i].start + mem_clusters[i].size; + uvm_page_physload(atop(first), atop(last), atop(first), atop(last), + VM_FREELIST_DEFAULT); + } + + /* + * Initialize error message buffer (at end of core). + */ + mips_init_msgbuf(); + + /* + * Allocate space for proc0's USPACE + */ + p0 = (caddr_t)pmap_steal_memory(USPACE, NULL, NULL); + proc0.p_addr = proc0paddr = (struct user *)p0; + proc0.p_md.md_regs = (struct frame *)(p0 + USPACE) - 1; + curpcb = &proc0.p_addr->u_pcb; + curpcb->pcb_context[11] = MIPS_INT_MASK | MIPS_SR_INT_IE; /* SR */ + + /* + * Allocate space for system data structures. These data structures + * are allocated here instead of cpu_startup() because physical + * memory is directly addressable. We don't have to map these into + * virtual address space. + */ + size = (vsize_t)allocsys(NULL, NULL); + v = (caddr_t)pmap_steal_memory(size, NULL, NULL); + if ((allocsys(v, NULL) - v) != size) + panic("mach_init: table size inconsistency"); + + pmap_bootstrap(); + + /* + * Initialize debuggers, and break into them, if appropriate. + */ +#if defined(DDB) + ddb_init(0, 0, 0); +#endif + + if (boothowto & RB_KDB) { +#if defined(DDB) + Debugger(); +#endif + } +} + +/* + * Allocate memory for variable-sized tables, + */ +void +cpu_startup() +{ + unsigned i; + int base, residual; + vaddr_t minaddr, maxaddr; + vsize_t size; + char pbuf[9]; + + /* + * Good {morning,afternoon,evening,night}. + */ + printf(version); + format_bytes(pbuf, sizeof(pbuf), ctob(physmem)); + printf("%s memory", pbuf); + + /* + * Allocate virtual address space for file I/O buffers. + * Note they are different than the array of headers, 'buf', + * and usually occupy more virtual memory than physical. + */ + size = MAXBSIZE * nbuf; + if (uvm_map(kernel_map, (vaddr_t *)&buffers, round_page(size), + NULL, UVM_UNKNOWN_OFFSET, 0, + UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE, + UVM_ADV_NORMAL, 0)) != 0) + panic("startup: cannot allocate VM for buffers"); + minaddr = (vaddr_t)buffers; + base = bufpages / nbuf; + residual = bufpages % nbuf; + for (i = 0; i < nbuf; i++) { + vsize_t curbufsize; + vaddr_t curbuf; + struct vm_page *pg; + + /* + * Each buffer has MAXBSIZE bytes of VM space allocated. Of + * that MAXBSIZE space, we allocate and map (base+1) pages + * for the first "residual" buffers, and then we allocate + * "base" pages for the rest. + */ + curbuf = (vaddr_t) buffers + (i * MAXBSIZE); + curbufsize = NBPG * ((i < residual) ? (base + 1) : base); + + while (curbufsize) { + pg = uvm_pagealloc(NULL, 0, NULL, 0); + if (pg == NULL) + panic("cpu_startup: not enough memory for " + "buffer cache"); + pmap_kenter_pa(curbuf, VM_PAGE_TO_PHYS(pg), + VM_PROT_READ|VM_PROT_WRITE); + curbuf += PAGE_SIZE; + curbufsize -= PAGE_SIZE; + } + } + + /* + * Allocate a submap for exec arguments. This map effectively + * limits the number of processes exec'ing at any time. + */ + exec_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, + 16 * NCARGS, VM_MAP_PAGEABLE, FALSE, NULL); + /* + * Allocate a submap for physio. + */ + phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, + VM_PHYS_SIZE, 0, FALSE, NULL); + + + /* + * (No need to allocate an mbuf cluster submap. Mbuf clusters + * are allocated via the pool allocator, and we use KSEG to + * map those pages.) + */ + + format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free)); + printf(", %s free", pbuf); + format_bytes(pbuf, sizeof(pbuf), bufpages * NBPG); + printf(", %s in %d buffers\n", pbuf, nbuf); + + /* + * Set up buffers, so they can be used to read disk labels. + */ + bufinit(); +} + +int +cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) + int *name; + u_int namelen; + void *oldp; + size_t *oldlenp; + void *newp; + size_t newlen; + struct proc *p; +{ + /* All sysctl names at this level are terminal. */ + if (namelen != 1) + return ENOTDIR; + + switch (name[0]) { + default: + return EOPNOTSUPP; + } +} + +int waittime = -1; + +void +cpu_reboot(howto, bootstr) + int howto; + char *bootstr; +{ + /* Take a snapshot before clobbering any registers. */ + if (curproc) + savectx((struct user *)curpcb); + + if (cold) { + howto |= RB_HALT; + goto haltsys; + } + + /* If "always halt" was specified as a boot flag, obey. */ + if (boothowto & RB_HALT) + howto |= RB_HALT; + + boothowto = howto; + if ((howto & RB_NOSYNC) == 0 && (waittime < 0)) { + waittime = 0; + vfs_shutdown(); + + /* + * If we've been adjusting the clock, the todr + * will be out of synch; adjust it now. + */ + resettodr(); + } + + splhigh(); + + if (howto & RB_DUMP) + dumpsys(); + +haltsys: + doshutdownhooks(); + + if (howto & RB_HALT) { + printf("\n"); + printf("The operating system has halted.\n"); + printf("Please press any key to reboot.\n\n"); + cnpollc(1); /* For proper keyboard command handling */ + cngetc(); + cnpollc(0); + } + + printf("rebooting...\n\n"); + + if (cfe_present) { + cfe_exit(1, (howto & RB_DUMP) ? 1 : 0); + printf("cfe_exit didn't!\n"); + } + + delay(500000); + +#if defined(IKOS) && defined(REALLY_IKOS) + *(volatile char *)MIPS_PHYS_TO_KSEG1(0x408000) = 0; +#else + { + static int broken; + + if (!broken) { + broken = 1; + __asm__ ( "move $4, %0 ; break 0x3ff" : : "r"(howto) ); + } + } +#endif + + printf("WARNING: reboot failed!\n"); + + for (;;); +} + +static void +cswarm_setled(u_int index, char c) +{ + volatile u_char *led_ptr = + (void *)MIPS_PHYS_TO_KSEG1(0x100a0000); /* XXX */ + + if (index < 4) + led_ptr[0x20 + ((3 - index) << 3)] = c; +} + +void +cswarm_setleds(const char *str) +{ + int i; + + for (i = 0; i < 4 && str[i]; i++) + cswarm_setled(i, str[i]); + for (; i < 4; i++) + cswarm_setled(' ', str[i]); +} + +int +sbmips_cca_for_pa(paddr_t pa) +{ + int rv; + + /* Check each DRAM region. */ + if ((pa >= 0x0000000000 && pa <= 0x000fffffff) || /* DRAM 0 */ + (pa >= 0x0080000000 && pa <= 0x008fffffff) || /* DRAM 1 */ + (pa >= 0x0090000000 && pa <= 0x009fffffff) || /* DRAM 2 */ + (pa >= 0x00c0000000 && pa <= 0x00cfffffff) || /* DRAM 3 */ +#ifdef _MIPS_PADDR_T_64BIT + (pa >= 0x0100000000 && pa <= 0x07ffffffff) || /* DRAM exp */ +#endif + 0) { + rv = 5; /* Cacheable coherent. */ + goto done; + } + + rv = 2; /* Uncached. */ +done: + return (rv); +} diff --git a/sys/arch/sbmips/sbmips/sb1250_icu.c b/sys/arch/sbmips/sbmips/sb1250_icu.c new file mode 100644 index 000000000000..cb4eabd165a2 --- /dev/null +++ b/sys/arch/sbmips/sbmips/sb1250_icu.c @@ -0,0 +1,205 @@ +/* $NetBSD: sb1250_icu.c,v 1.1 2002/03/06 02:13:52 simonb Exp $ */ + +/* + * Copyright 2000, 2001 + * Broadcom Corporation. All rights reserved. + * + * This software is furnished under license and may be used and copied only + * in accordance with the following terms and conditions. Subject to these + * conditions, you may download, copy, install, use, modify and distribute + * modified or unmodified copies of this software in source and/or binary + * form. No title or ownership is transferred hereby. + * + * 1) Any source code used, modified or distributed must reproduce and + * retain this copyright notice and list of conditions as they appear in + * the source file. + * + * 2) No right is granted to use any trade name, trademark, or logo of + * Broadcom Corporation. Neither the "Broadcom Corporation" name nor any + * trademark or logo of Broadcom Corporation may be used to endorse or + * promote products derived from this software without the prior written + * permission of Broadcom Corporation. + * + * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE + * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE + * LIABLE FOR 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), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +/* XXX for uvmexp */ +#include + +#include +#include + +/* XXX for now, this copes with one cpu only, and assumes it's CPU 0 */ + +/* imr values corresponding to each pin */ +uint64_t ints_for_line[6]; +uint64_t imr_all; + +struct sb1250_ihand { + void (*fun)(void *, uint32_t, uint32_t); + void *arg; + int level; +}; +static struct sb1250_ihand sb1250_ihands[64]; /* XXX */ + +#define SB1250_I_IMR_ADDR (MIPS_PHYS_TO_KSEG1(0x10020000 + 0x0028)) +#define SB1250_I_IMR_SSTATUS (MIPS_PHYS_TO_KSEG1(0x10020000 + 0x0040)) +#define SB1250_I_MAP(x) \ + (MIPS_PHYS_TO_KSEG1(0x10020000 + 0x0200 + (x) * 8)) +#define SB1250_I_MAP_I0 0x00 +#define SB1250_I_MAP_I1 0x01 +#define SB1250_I_MAP_I2 0x02 +/* XXX */ + +#define READ_REG(rp) (mips3_ld((uint64_t *)(rp))) +#define WRITE_REG(rp, val) (mips3_sd((uint64_t *)(rp), (val))) + +#undef __inline +#define __inline + +static void sb1250_cpu_intr(uint32_t, uint32_t, uint32_t, uint32_t); +static void sb1250_cpu_setsoftintr(void); +static void *sb1250_intr_establish(u_int, u_int, + void (*fun)(void *, uint32_t, uint32_t), void *); + +void +sb1250_icu_init(void) +{ + int i; + + /* zero out the list of used interrupts/lines */ + memset(ints_for_line, 0, sizeof ints_for_line); + imr_all = 0xffffffffffffffff; + memset(sb1250_ihands, 0, sizeof sb1250_ihands); + + systemsw.s_cpu_intr = sb1250_cpu_intr; + systemsw.s_cpu_setsoftintr = sb1250_cpu_setsoftintr; + systemsw.s_intr_establish = sb1250_intr_establish; + + WRITE_REG(SB1250_I_IMR_ADDR, imr_all); + + for (i = 0; i < 64; i++) + WRITE_REG(SB1250_I_MAP(i), SB1250_I_MAP_I0); +} + +static void +sb1250_cpu_intr(uint32_t status, uint32_t cause, uint32_t pc, uint32_t ipending) +{ + int i, j; + uint64_t sstatus; + uint32_t cycles; + + uvmexp.intrs++; + +{ int s = splhigh(); + + /* XXX do something if 5? */ + if (ipending & (MIPS_INT_MASK_0 << 5)) { + cycles = mips3_cp0_count_read(); + mips3_cp0_compare_write(cycles - 1); + /* just leave the bugger disabled */ + } + + for (i = 4; i >= 0; i--) { + if (ipending & (MIPS_INT_MASK_0 << i)) { + + sstatus = READ_REG(SB1250_I_IMR_SSTATUS); + sstatus &= ints_for_line[i]; + for (j = 0; sstatus != 0 && j < 64; j++) { + if (sstatus & ((uint64_t)1 << j)) { + struct sb1250_ihand *ihp = &sb1250_ihands[j]; + (*ihp->fun)(ihp->arg, status, pc); + sstatus &= ~((uint64_t)1 << j); + } + } + } + cause &= ~(MIPS_INT_MASK_0 << i); +#if 0 + _splset((status & ~cause & MIPS_HARD_INT_MASK) | MIPS_SR_INT_IE); +#endif + } + + /* software interrupt */ + if (ipending & MIPS_SOFT_INT_MASK_0) { + _clrsoftintr(MIPS_SOFT_INT_MASK_0); + uvmexp.softs++; + dosoftints(); + + cause &= MIPS_SOFT_INT_MASK_0; +#if 0 + _splset((status & ~cause & MIPS_INT_MASK) | MIPS_SR_INT_IE); +#endif + } + +splx(s); } +} + +static void +sb1250_cpu_setsoftintr(void) +{ + + _setsoftintr(MIPS_SOFT_INT_MASK_0); +} + +static void * +sb1250_intr_establish(u_int num, u_int ipl, + void (*fun)(void *, uint32_t, uint32_t), void *arg) +{ + int s, line; + + s = splhigh(); + + if (num >= 64) /* XXX */ + panic("invalid interrupt number (0x%x)", num); + if (ipl >= _NIPL) + panic("invalid ipl (0x%x)", ipl); + + if (sb1250_ihands[num].fun != NULL) + panic("cannot share sb1250 interrupts"); + + /* XXX for now, everything on I0 */ + switch (ipl) { +#if 0 + case IPL_NMI: + sr_mask = XXX; + break; + case IPL_STATCLOCK: + sr_mask = XXX; + break; + case IPL_CLOCK: + sr_mask = XXX; + break; +#endif + default: + line = 0; + break; + } + + ints_for_line[line] |= (1ULL << num); + imr_all &= ~(1ULL << num); + + /* XXX map ! */ + + sb1250_ihands[num].fun = fun; + sb1250_ihands[num].arg = arg; + sb1250_ihands[num].level = ipl; + + WRITE_REG(SB1250_I_IMR_ADDR, imr_all); + + splx(s); + + return (&sb1250_ihands[num]); +} diff --git a/sys/arch/sbmips/sbmips/softintr.c b/sys/arch/sbmips/sbmips/softintr.c new file mode 100644 index 000000000000..b50457da8626 --- /dev/null +++ b/sys/arch/sbmips/sbmips/softintr.c @@ -0,0 +1,210 @@ +/* $NetBSD: softintr.c,v 1.1 2002/03/06 02:13:52 simonb Exp $ */ + +/* + * Copyright 2000, 2001 + * Broadcom Corporation. All rights reserved. + * + * This software is furnished under license and may be used and copied only + * in accordance with the following terms and conditions. Subject to these + * conditions, you may download, copy, install, use, modify and distribute + * modified or unmodified copies of this software in source and/or binary + * form. No title or ownership is transferred hereby. + * + * 1) Any source code used, modified or distributed must reproduce and + * retain this copyright notice and list of conditions as they appear in + * the source file. + * + * 2) No right is granted to use any trade name, trademark, or logo of + * Broadcom Corporation. Neither the "Broadcom Corporation" name nor any + * trademark or logo of Broadcom Corporation may be used to endorse or + * promote products derived from this software without the prior written + * permission of Broadcom Corporation. + * + * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE + * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE + * LIABLE FOR 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), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +__KERNEL_RCSID(0, "$NetBSD: softintr.c,v 1.1 2002/03/06 02:13:52 simonb Exp $"); + +#include +#include +#include + +/* XXX for uvmexp */ +#include + +#include +#include + +#include + +struct sh { + struct sh *next; + void (*fun)(void *); + void *arg; +}; + +static struct sh *sh_list_head = NULL; +static struct sh **sh_list_tail = &sh_list_head; + +static void dosoftnet(void *unused); +static void dosoftclock(void *unused); + +void * +softintr_establish(int level, void (*fun)(void *), void *arg) +{ + struct sh *new, *sh; + + new = malloc(sizeof *sh, M_DEVBUF, M_WAITOK); + new->next = NULL; + new->fun = fun; + new->arg = arg; + + return new; +} + +void +softintr_disestablish(void *cookie) +{ + struct sh *sh, **prevnext; + int s; + + s = splhigh(); + for (prevnext = &sh_list_head, sh = *prevnext; + sh != NULL; + prevnext = &sh->next, sh = *prevnext) { + if (sh == cookie) { + *prevnext = sh->next; + if (*prevnext == NULL) + sh_list_tail = prevnext; + break; + } + } + splx(s); + free(sh, M_DEVBUF); +} + +void +softintr_schedule(void *cookie) +{ + struct sh *sh = cookie; + int s; + + s = splhigh(); + if (sh->next == NULL) { + *sh_list_tail = sh; + sh_list_tail = &sh->next; + cpu_setsoftintr(); + } + splx(s); +} + +void +dosoftints(void) +{ + struct sh *sh; + void (*fun)(void *), *arg; + int s; + + while (1) { + s = splhigh(); + + sh = sh_list_head; + if (sh == NULL) + break; + + uvmexp.softs++; + + if ((sh_list_head = sh->next) == NULL) + sh_list_tail = &sh_list_head; + sh->next = NULL; + fun = sh->fun; + arg = sh->arg; + + splx(s); + + (*fun)(arg); + } + splx(s); +} + +void +setsoftclock() +{ + static struct sh sh_softclock = { NULL, dosoftclock, NULL, }; + + softintr_schedule(&sh_softclock); +} + +static void +dosoftclock(void *unused) +{ + + intrcnt[SOFTCLOCK_INTR]++; + softclock(NULL); +} + +void +setsoftnet() +{ + static struct sh sh_softnet = { NULL, dosoftnet, NULL, }; + + softintr_schedule(&sh_softnet); +} + +/* XXX BEGIN */ +#include "opt_inet.h" +#include +#ifdef INET +#include +#include +#include +#include "arp.h" +#if NARP > 0 +#include +#endif +#endif +#ifdef INET6 +# ifndef INET +# include +# endif +#include +#include +#endif +/* XXX END */ + +static void +dosoftnet(void *unused) +{ + int n, s; + + intrcnt[SOFTNET_INTR]++; + + /* XXX could just use netintr! */ + + s = splhigh(); + n = netisr; + netisr = 0; + splx(s); + +#define DONETISR(bit, fn) \ + do { \ + if (n & (1 << (bit))) \ + fn(); \ + } while (0) + +#include + +#undef DONETISR +} diff --git a/sys/arch/sbmips/sbmips/systemsw.c b/sys/arch/sbmips/sbmips/systemsw.c new file mode 100644 index 000000000000..05e47a2028a0 --- /dev/null +++ b/sys/arch/sbmips/sbmips/systemsw.c @@ -0,0 +1,189 @@ +/* $NetBSD: systemsw.c,v 1.1 2002/03/06 02:13:52 simonb Exp $ */ + +/* + * Copyright 2000, 2001 + * Broadcom Corporation. All rights reserved. + * + * This software is furnished under license and may be used and copied only + * in accordance with the following terms and conditions. Subject to these + * conditions, you may download, copy, install, use, modify and distribute + * modified or unmodified copies of this software in source and/or binary + * form. No title or ownership is transferred hereby. + * + * 1) Any source code used, modified or distributed must reproduce and + * retain this copyright notice and list of conditions as they appear in + * the source file. + * + * 2) No right is granted to use any trade name, trademark, or logo of + * Broadcom Corporation. Neither the "Broadcom Corporation" name nor any + * trademark or logo of Broadcom Corporation may be used to endorse or + * promote products derived from this software without the prior written + * permission of Broadcom Corporation. + * + * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE + * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE + * LIABLE FOR 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), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include + +#include +#include +#include + +/* trivial functions for function switch */ +static void microtime_triv(struct timeval *); +static void delay_triv(u_long); +static void cpu_intr_triv(uint32_t, uint32_t, uint32_t, uint32_t); +static void cpu_setsoftintr_triv(void); +static void clock_init_triv(void *); +static void inittodr_triv(void *, time_t); +static void resettodr_triv(void *); + +#define XXXNULL NULL + +/* system function switch */ +struct systemsw systemsw = { + cpu_intr_triv, + cpu_setsoftintr_triv, + microtime_triv, + delay_triv, + + NULL, /* clock intr arg */ + clock_init_triv, + + NULL, /* s_statclock_init: dflt no-op */ + NULL, /* s_statclock_setrate: dflt no-op */ + + inittodr_triv, + resettodr_triv, + NULL, /* XXX: s_intr_establish */ +}; + +int +system_set_clockfns(void *arg, void (*init)(void *)) +{ + + if (systemsw.s_clock_init != clock_init_triv) + return 1; + systemsw.s_clock_arg = arg; + systemsw.s_clock_init = init; + return 0; +} + +/* trivial microtime() implementation */ +static void +microtime_triv(struct timeval *tvp) +{ + int s = splclock(); + + *tvp = time; + splx(s); +} + +/* trivial delay() implementation */ +static void +delay_triv(u_long n) +{ + volatile register u_long i; + + while (--n > 0) { + /* + * XXX assume 1GHz * dual issue, and that this loop is + * XXX 2 insns + */ + /* XXX FIXME -- cgd */ +// i = 1000; + i = 1; + while (--i > 0) + ; + } +} + +static void +cpu_intr_triv(uint32_t status, uint32_t cause, uint32_t pc, uint32_t ipending) +{ + + panic("cpu_intr_triv"); +} +void +cpu_setsoftintr_triv(void) +{ + panic("cpu_setsoftintr_triv"); +} + +void +cpu_intr(uint32_t status, uint32_t cause, uint32_t pc, uint32_t ipending) +{ + + (*systemsw.s_cpu_intr)(status, cause, pc, ipending); +} + +void +microtime(struct timeval *tvp) +{ + + (*systemsw.s_microtime)(tvp); +} + +static void +clock_init_triv(void *arg) +{ + panic("clock_init_triv"); +} + +static void +inittodr_triv(void *arg, time_t t) +{ + + time.tv_sec = t; +} + +static void +resettodr_triv(void *arg) +{ + + /* do nothing */ +} + +void +cpu_initclocks(void) +{ + + (*systemsw.s_clock_init)(systemsw.s_clock_arg); + + if (systemsw.s_statclock_init != NULL) + (*systemsw.s_statclock_init)(XXXNULL); +} + +void +setstatclockrate(int hzrate) +{ + + if (systemsw.s_statclock_setrate != NULL) + (*systemsw.s_statclock_setrate)(XXXNULL, hzrate); +} + +void +inittodr(time_t t) +{ + + (*systemsw.s_inittodr)(XXXNULL, t); +} + +void +resettodr(void) +{ + + (*systemsw.s_resettodr)(XXXNULL); +} diff --git a/sys/arch/sbmips/sbmips/zbbus.c b/sys/arch/sbmips/sbmips/zbbus.c new file mode 100644 index 000000000000..907231a094a6 --- /dev/null +++ b/sys/arch/sbmips/sbmips/zbbus.c @@ -0,0 +1,136 @@ +/* $NetBSD: zbbus.c,v 1.1 2002/03/06 02:13:52 simonb Exp $ */ + +/* + * Copyright 2000, 2001 + * Broadcom Corporation. All rights reserved. + * + * This software is furnished under license and may be used and copied only + * in accordance with the following terms and conditions. Subject to these + * conditions, you may download, copy, install, use, modify and distribute + * modified or unmodified copies of this software in source and/or binary + * form. No title or ownership is transferred hereby. + * + * 1) Any source code used, modified or distributed must reproduce and + * retain this copyright notice and list of conditions as they appear in + * the source file. + * + * 2) No right is granted to use any trade name, trademark, or logo of + * Broadcom Corporation. Neither the "Broadcom Corporation" name nor any + * trademark or logo of Broadcom Corporation may be used to endorse or + * promote products derived from this software without the prior written + * permission of Broadcom Corporation. + * + * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE + * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE + * LIABLE FOR 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), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include + +#include + +#include "locators.h" + +static int zbbus_match(struct device *, struct cfdata *, void *); +static void zbbus_attach(struct device *, struct device *, void *); + +struct cfattach zbbus_ca = { + sizeof(struct device), zbbus_match, zbbus_attach +}; + +static int zbbus_print(void *, const char *); +static int zbbus_submatch(struct device *, struct cfdata *, void *); +static const char *zbbus_entity_type_name(enum zbbus_entity_type type); + +static int zbbus_attached; + +static const struct zbbus_attach_locs sb1250_zbbus_devs[] = { + { 0, ZBBUS_ENTTYPE_CPU }, + { 1, ZBBUS_ENTTYPE_CPU }, + { 4, ZBBUS_ENTTYPE_SCD }, + { 2, ZBBUS_ENTTYPE_BRZ }, + { 3, ZBBUS_ENTTYPE_OBIO }, +}; +static const int sb1250_zbbus_dev_count = + sizeof sb1250_zbbus_devs / sizeof sb1250_zbbus_devs[0]; + +static int +zbbus_match(struct device *parent, struct cfdata *match, void *aux) +{ + + if (zbbus_attached) + return (0); + return 1; +} + +static void +zbbus_attach(struct device *parent, struct device *self, void *aux) +{ + struct zbbus_attach_args za; + int i; + + printf("\n"); + zbbus_attached = 1; + + sb1250_icu_init(); + + for (i = 0; i < sb1250_zbbus_dev_count; i++) { + memset(&za, 0, sizeof za); + za.za_locs = sb1250_zbbus_devs[i]; + config_found_sm(self, &za, zbbus_print, zbbus_submatch); + } + + return; +} + +int +zbbus_print(void *aux, const char *pnp) +{ + struct zbbus_attach_args *zap = aux; + + if (pnp) + printf("%s at %s", + zbbus_entity_type_name(zap->za_locs.za_type), pnp); + printf(" busid %d", zap->za_locs.za_busid); + return (UNCONF); +} + +static int +zbbus_submatch(struct device *parent, struct cfdata *cf, void *aux) +{ + struct zbbus_attach_args *zap = aux; + + if (cf->cf_loc[ZBBUSCF_BUSID] != ZBBUSCF_BUSID_DEFAULT && + cf->cf_loc[ZBBUSCF_BUSID] != zap->za_locs.za_busid) + return (0); + + return ((*cf->cf_attach->ca_match)(parent, cf, aux)); +} + +static const char * +zbbus_entity_type_name(enum zbbus_entity_type type) +{ + + switch (type) { + case ZBBUS_ENTTYPE_CPU: + return ("cpu"); + case ZBBUS_ENTTYPE_SCD: + return ("sbscd"); + case ZBBUS_ENTTYPE_BRZ: + return ("sbbrz"); + case ZBBUS_ENTTYPE_OBIO: + return ("sbobio"); + } + panic("zbbus_entity_type_name"); + return ("panic"); +}