diff --git a/distrib/sets/lists/base/md.evbmips b/distrib/sets/lists/base/md.evbmips new file mode 100644 index 000000000000..b7b044bd0d29 --- /dev/null +++ b/distrib/sets/lists/base/md.evbmips @@ -0,0 +1,7 @@ +# $NetBSD: md.evbmips,v 1.3.2.2 2017/08/30 15:45:04 martin Exp $ +./usr/mdec/sbmips base-sysutil-bin +./usr/mdec/sbmips/boot base-sysutil-bin +./usr/mdec/sbmips/bootxx_cd9660 base-sysutil-bin +./usr/mdec/sbmips/bootxx_ffs base-sysutil-bin +./usr/mdec/sbmips/bootxx_lfs base-sysutil-bin +./usr/mdec/sbmips/netboot base-sysutil-bin diff --git a/doc/CHANGES b/doc/CHANGES index 2a41da48d582..952f2343b728 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2286.2.1 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2286.2.2 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -521,3 +521,4 @@ Changes from NetBSD 7.0 to NetBSD 8.0: file(1): Upgraded to 5.31. [christos 20170524] can(4): Added a socketcan implementation, a socket layer for CAN busses. [bouyer 20170527] + evbmips: Merge sbmips port into evbmips. [mrg 20170815] diff --git a/etc/etc.evbmips/MAKEDEV.conf b/etc/etc.evbmips/MAKEDEV.conf index 76d56bf7c809..2ecc37d2a4ba 100644 --- a/etc/etc.evbmips/MAKEDEV.conf +++ b/etc/etc.evbmips/MAKEDEV.conf @@ -1,4 +1,21 @@ -# $NetBSD: MAKEDEV.conf,v 1.7 2016/12/24 07:07:06 mrg Exp $ +# $NetBSD: MAKEDEV.conf,v 1.7.6.1 2017/08/30 15:45:03 martin Exp $ + +# When creating a /dev file system on MFS, init makes a FS that leaves +# only 890 (or so) inodes free. Therefore the "init" case (used by +# init for that purpose) must be a trimmed down list. +init) + makedev std wd0 wd1 wd2 wd3 sd0 sd1 sd2 sd3 sd4 + makedev tty00 tty01 + makedev st0 st1 ch0 cd0 cd1 vnd0 vnd1 + makedev bpf + makedev ccd0 md0 ch0 random + makedev cgd0 cgd1 + makedev raid0 + makedev ld0 ld1 ld2 ld3 + makedev usbs + makedev ipty + makedev local + ;; all_md) makedev wscons sd0 sd1 sd2 sd3 sd4 @@ -7,7 +24,7 @@ all_md) makedev ss0 ss1 uk0 uk1 makedev ld0 ld1 ld2 ld3 makedev tty00 tty01 - makedev lpa0 lpt0 audio wd0 wd1 fd0 fd1 + makedev lpa0 lpt0 audio wd0 wd1 wd2 wd3 fd0 fd1 makedev satlink0 speaker mlx0 makedev scsibus0 scsibus1 scsibus2 scsibus3 makedev ses0 ses1 ses2 ses3 @@ -17,12 +34,13 @@ all_md) makedev pci0 pci1 pci2 pci3 pci4 pci5 pci6 pci7 makedev altq sysmon makedev iic0 iic1 iic2 iic3 iic4 + makedev kttcp ;; minimal) makedev std makedev sd0 sd1 sd2 sd3 opty st0 st1 ch0 cd0 cd1 ccd0 ccd1 md0 - makedev wd0 wd1 fd0 fd1 + makedev wd0 wd1 wd2 wd3 fd0 fd1 makedev flash0 flash1 flash2 flash3 flash4 flash5 flash6 flash7 makedev tty00 tty01 ttyE0 ttyE1 wsmouse0 wskbd0 ttyEcfg ;; diff --git a/etc/etc.evbmips/Makefile.inc b/etc/etc.evbmips/Makefile.inc index 3f234a1d9824..8eed596617b2 100644 --- a/etc/etc.evbmips/Makefile.inc +++ b/etc/etc.evbmips/Makefile.inc @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.21 2016/09/05 07:23:43 skrll Exp $ +# $NetBSD: Makefile.inc,v 1.21.6.1 2017/08/30 15:45:03 martin Exp $ # # etc.evbmips/Makefile.inc -- evbmips-specific etc Makefile targets # @@ -15,23 +15,25 @@ BUILD_KERNELS= INSTALL_CI20 INSTALL_OMSAL400 INSTALL_MALTA KERNEL_SETS+= P4032 P5064 P6032 -.elif ${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el" +. elif ${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el" KERNEL_SETS= MALTA32 MALTA64 XLSATX32 XLSATX64 BUILD_KERNELS= INSTALL_MALTA32 INSTALL_MALTA64 BUILD_KERNELS+= INSTALL_XLSATX32 INSTALL_XLSATX64 -.if ${MACHINE_ARCH} == "mips64el" +. if ${MACHINE_ARCH} == "mips64el" KERNEL_SETS+= P5064-64 KERNEL_SETS+= LOONGSON BUILD_KERNELS+= INSTALL_LOONGSON KERNEL_SETS+= GDIUM64 -.else +. else KERNEL_SETS+= ERLITE BUILD_KERNELS+= INSTALL_ERLITE -.endif +. endif .else KERNEL_SETS= ALCHEMY DB120 DBAU1500 DBAU1550 MALTA RB433UAH BUILD_KERNELS= INSTALL_MALTA .endif +# SBMIPS has a kernel for all targets +KERNEL_SETS+= SBMIPS${MACHINE_ARCH:S/mips//:C/e[lb]//} diff --git a/etc/mtree/Makefile b/etc/mtree/Makefile index 3ba2a5949b07..fbec88cd5720 100644 --- a/etc/mtree/Makefile +++ b/etc/mtree/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.36 2016/11/15 22:31:07 matt Exp $ +# $NetBSD: Makefile,v 1.36.6.1 2017/08/30 15:45:04 martin Exp $ .include @@ -21,6 +21,10 @@ EXTRA_DIST_FILES+= NetBSD.dist.xcompat # autogenerated .endif .endif +.if exists(NetBSD.dist.${MACHINE}) +EXTRA_DIST_FILES+= NetBSD.dist.${MACHINE} +.endif + .if ${MKATF} != "no" EXTRA_DIST_FILES+= NetBSD.dist.tests .if defined(MKCOMPATTESTS) && ${MKCOMPATTESTS} != "no" diff --git a/etc/mtree/NetBSD.dist.evbmips b/etc/mtree/NetBSD.dist.evbmips new file mode 100644 index 000000000000..35ddb8b8704a --- /dev/null +++ b/etc/mtree/NetBSD.dist.evbmips @@ -0,0 +1,2 @@ +# $NetBSD: NetBSD.dist.evbmips,v 1.1.2.2 2017/08/30 15:45:04 martin Exp $ +./usr/mdec/sbmips diff --git a/sys/arch/evbmips/Makefile b/sys/arch/evbmips/Makefile index 15c78925d730..681bd1abee3c 100644 --- a/sys/arch/evbmips/Makefile +++ b/sys/arch/evbmips/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.8 2011/04/04 19:46:40 dyoung Exp $ +# $NetBSD: Makefile,v 1.8.48.1 2017/08/30 15:45:05 martin Exp $ # Makefile for evbmips tags file and boot blocks @@ -16,7 +16,9 @@ SEVBMIPS+= ${SYSDIR}/arch/evbmips/include/*.h SEVBMIPS+= ${SYSDIR}/arch/evbmips/isa/*.[ch] SEVBMIPS+= ${SYSDIR}/arch/evbmips/malta/*.[ch] SEVBMIPS+= ${SYSDIR}/arch/evbmips/rmixl/*.[ch] +SEVBMIPS+= ${SYSDIR}/arch/evbmips/sbmips/*.[ch] AEVBMIPS= ${SYSDIR}/arch/evbmips/evbmips/*.S +AEVBMIPS+= ${SYSDIR}/arch/evbmips/sbmips/*.S # Directories in which to place tags links DEVBMIPS= evbmips include isa pci @@ -38,6 +40,6 @@ links: cd $$i && rm -f tags; ln -s ../tags tags; done -SUBDIR= compile include +SUBDIR= compile include stand .include diff --git a/sys/arch/evbmips/conf/SBMIPS b/sys/arch/evbmips/conf/SBMIPS new file mode 100644 index 000000000000..ad3e6e036798 --- /dev/null +++ b/sys/arch/evbmips/conf/SBMIPS @@ -0,0 +1,242 @@ +# $NetBSD: SBMIPS,v 1.3.4.2 2017/08/30 15:45:03 martin Exp $ + +include "arch/sbmips/conf/std.sbmips" + +options INCLUDE_CONFIG_FILE # embed config file in kernel binary + +#ident "GENERIC-$Revision: 1.3.4.2 $" + +#options LOCKDEBUG # XXX XXX XXX XXX +#options DEBUG # extra kernel debugging support + +# The following three options are required for BCM1250 pass 1 silicon +#options SB1250_PASS1 +#options NOFPU +#options FPEMUL + +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 NTP # network time protocol + +# Debugging options +#options DIAGNOSTIC # extra kernel sanity checking +#options DEBUG # extra kernel debugging support +options USERCONF # userconf(4) support +options SYSCTL_INCLUDE_DESCR # Include sysctl descriptions in kernel +options DDB # kernel dynamic debugger +options DDB_HISTORY_SIZE=100 # enable history editing in DDB +#makeoptions DEBUG="-g" # compile full symbol table +makeoptions COPY_SYMTAB=1 # size for embedded symbol table + +# Compatibility options +options COMPAT_43 # compatibility with 4.3BSD binaries +#options COMPAT_09 # NetBSD 0.9, +#options COMPAT_10 # NetBSD 1.0, +#options COMPAT_11 # NetBSD 1.1, +#options COMPAT_12 # NetBSD 1.2, +#options COMPAT_13 # NetBSD 1.3, +#options COMPAT_14 # NetBSD 1.4, +#options COMPAT_15 # NetBSD 1.5, +options COMPAT_16 # NetBSD 1.6, +options COMPAT_20 # NetBSD 2.0, +options COMPAT_30 # NetBSD 3.0, +options COMPAT_40 # NetBSD 4.0, +options COMPAT_50 # NetBSD 5.0, +options COMPAT_60 # NetBSD 6.0, and +options COMPAT_70 # NetBSD 7.0 binary compatibility +#options EXEC_ECOFF # exec ECOFF binaries +#options COMPAT_ULTRIX # binary compatibility with Ultrix +options COMPAT_BSDPTY # /dev/[pt]ty?? ptys. + +# 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 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 PTYFS # /dev/pts/N support +file-system TMPFS # Efficient memory file-system +#file-system UDF # experimental - OSTA UDF CD/DVD file-system + +# File system options +options NFSSERVER # Sun NFS-compatible filesystem server +options QUOTA # legacy UFS quotas +options QUOTA2 # new, in-filesystem UFS quotas +#options FFS_NO_SNAPSHOT # No FFS snapshot support +options UFS_EXTATTR # Extended attribute support for UFS1 +#options FFS_EI # FFS Endian Independent support +options WAPBL # File system journaling support +#options UFS_DIRHASH # UFS Large Directory Hashing - Experimental +#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_DEBUG # debug for IP security +#options MROUTING # packet forwarding of multicast packets +#options PIM # Protocol Independent Multicast +#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 IPFILTER_LOG # ipmon(8) log support +options IPFILTER_LOOKUP # ippool(8) support +options IPFILTER_COMPAT # Compat for IP-Filter +#options IPFILTER_DEFAULT_BLOCK # block all packets by default + +#options ALTQ # Manipulate network interfaces' output queues +#options ALTQ_BLUE # Stochastic Fair Blue +#options ALTQ_CBQ # Class-Based Queueing +#options ALTQ_CDNR # Diffserv Traffic Conditioner +#options ALTQ_FIFOQ # First-In First-Out Queue +#options ALTQ_FLOWVALVE # RED/flow-valve (red-penalty-box) +#options ALTQ_HFSC # Hierarchical Fair Service Curve +#options ALTQ_LOCALQ # Local queueing discipline +#options ALTQ_PRIQ # Priority Queueing +#options ALTQ_RED # Random Early Detection +#options ALTQ_RIO # RED with IN/OUT +#options ALTQ_WFQ # Weighted Fair Queueing + +# Compatibility with 4.2BSD implementation of TCP/IP. Not recommended. +#options TCP_COMPAT_42 + +# JIT compiler for bpfilter +#options SLJIT +#options BPFJIT + +# 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 + +cpu* at zbbus? busid ? +sbscd* at zbbus? busid ? +sbbrz* at zbbus? busid ? +sbobio* at zbbus? busid ? + +pci* at sbbrz? bus ? +ppb* at pci? dev ? +pci* at ppb? + +ohci* at pci? dev ? function ? # Open Host Controller + +bge* at pci? dev ? + +#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 ? +smbus* at sbobio? offset ? + +xirtc* at smbus? chan ? dev ? # Xicor X1241 RTC +m41t81rtc* at smbus? chan ? dev ? # ST M41T81 RTC + +# MII/PHY support +brgphy* at mii? phy ? + +# USB +usb* at ohci? +uhub* at usb? +uhub* at uhub? port ? +umass* at uhub? port ? configuration ? interface ? +wd* at umass? +scsibus* at umass? channel ? +sd* at scsibus? target ? lun ? +uplcom* at uhub? port ? # I/O DATA USB-RSAQ2 serial adapter +ucom* at uplcom? portno ? + +# Pseudo-devices + +# Disk/mass storage pseudo-devices +pseudo-device ccd # concatenated disk devices +#pseudo-device cgd # cryptographic disk devices +#pseudo-device raid # RAIDframe disk driver +#options RAID_AUTOCONFIG # auto-configuration of RAID +pseudo-device md # memory disk device (ramdisk) +pseudo-device vnd # disk-like interface to files +#options VND_COMPRESSION # compressed vnd(4) + +# Network pseudo-devices +pseudo-device bpfilter # Berkeley packet filter +#pseudo-device carp # Common Address Redundancy Protocol +pseudo-device ipfilter # IP filter (firewall) and NAT +pseudo-device loop # network loopback +#pseudo-device ppp # Point-to-Point Protocol +#pseudo-device pppoe # PPP over Ethernet (RFC 2516) +#pseudo-device sl # Serial Line IP +#pseudo-device strip # Starmode Radio IP (Metricom) +#pseudo-device irframetty # IrDA frame line discipline +#pseudo-device tun # network tunneling over tty +#pseudo-device tap # virtual Ethernet +#pseudo-device gre # generic L3 over IP tunnel +#pseudo-device ipip # RFC 2003 IP Encapsulation +#pseudo-device gif # RFC1933 tunnel +#pseudo-device faith # IPv[46] tcp relay translation +#pseudo-device stf # 6to4 IPv6 over IPv4 encapsulation +pseudo-device vlan # IEEE 802.1q encapsulation +pseudo-device bridge # simple inter-network bridging +#options BRIDGE_IPF # bridge uses IP/IPv6 pfil hooks too +pseudo-device agr # IEEE 802.3ad link aggregation + +# +# accept filters +pseudo-device accf_data # "dataready" accept filter +pseudo-device accf_http # "httpready" accept filter + +# Miscellaneous pseudo-devices +pseudo-device pty # pseudo-terminals +#pseudo-device sequencer # MIDI sequencer +pseudo-device clockctl # user control of clock subsystem +pseudo-device ksyms # /dev/ksyms +#pseudo-device pf # PF packet filter +#pseudo-device pflog # PF log if + +# A pseudo device needed for Coda # also needs CODA (above) +#pseudo-device vcoda # coda minicache <-> venus comm. + +# Veriexec +# +# a pseudo device needed for veriexec +#pseudo-device veriexec +# +# Uncomment the fingerprint methods below that are desired. Note that +# removing fingerprint methods will have almost no impact on the kernel +# code size. +# +#options VERIFIED_EXEC_FP_RMD160 +#options VERIFIED_EXEC_FP_SHA256 +#options VERIFIED_EXEC_FP_SHA384 +#options VERIFIED_EXEC_FP_SHA512 +#options VERIFIED_EXEC_FP_SHA1 +#options VERIFIED_EXEC_FP_MD5 diff --git a/sys/arch/evbmips/conf/SBMIPS.MP b/sys/arch/evbmips/conf/SBMIPS.MP new file mode 100644 index 000000000000..0767e6a85f81 --- /dev/null +++ b/sys/arch/evbmips/conf/SBMIPS.MP @@ -0,0 +1,11 @@ + +include "arch/sbmips/conf/GENERIC" + +options MULTIPROCESSOR +options LOCKDEBUG + +pseudo-device lockstat + +no makeoptions COPY_SYMTAB +makeoptions COPY_SYMTAB=1 + diff --git a/sys/arch/evbmips/conf/SBMIPS64 b/sys/arch/evbmips/conf/SBMIPS64 new file mode 100644 index 000000000000..248d3e3892e2 --- /dev/null +++ b/sys/arch/evbmips/conf/SBMIPS64 @@ -0,0 +1,10 @@ + +include "arch/sbmips/conf/GENERIC" + +makeoptions LP64="yes" +options EXEC_ELF64 +options COMPAT_NETBSD32 + +no makeoptions COPY_SYMTAB +makeoptions COPY_SYMTAB=1 + diff --git a/sys/arch/evbmips/conf/SBMIPS64.MP b/sys/arch/evbmips/conf/SBMIPS64.MP new file mode 100644 index 000000000000..d6389b6e5cf1 --- /dev/null +++ b/sys/arch/evbmips/conf/SBMIPS64.MP @@ -0,0 +1,11 @@ + +include "arch/sbmips/conf/GENERIC64" + +options MULTIPROCESSOR +options LOCKDEBUG + +pseudo-device lockstat + +no makeoptions COPY_SYMTAB +makeoptions COPY_SYMTAB=1 + diff --git a/sys/arch/evbmips/conf/files.sbmips b/sys/arch/evbmips/conf/files.sbmips new file mode 100644 index 000000000000..177f467e6957 --- /dev/null +++ b/sys/arch/evbmips/conf/files.sbmips @@ -0,0 +1,113 @@ +# $NetBSD: files.sbmips,v 1.2.4.2 2017/08/30 15:45:03 martin Exp $ + +maxpartitions 8 + +maxusers 1 8 64 + +file arch/sbmips/sbmips/autoconf.c +file arch/sbmips/sbmips/machdep.c +file arch/sbmips/sbmips/console.c +file arch/sbmips/sbmips/disksubr.c +file arch/sbmips/sbmips/systemsw.c +file dev/cons.c + +file arch/sbmips/sbmips/sb1250_icu.c + +file arch/mips/cfe/cfe_api.c +file arch/mips/mips/mips3_clock.c +file arch/mips/mips/bus_dma.c + +### +### MI device inclusion +### + +# Stack-less Just-In-Time compiler +include "external/bsd/sljit/conf/files.sljit" + +# Machine-independent I2O drivers. +include "dev/i2o/files.i2o" + +# Machine-independent SCSI drivers +include "dev/scsipi/files.scsipi" + +# Machine-independent ATA drivers +include "dev/ata/files.ata" + +# Memory Disk +file dev/md_root.c memory_disk_hooks + +# 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/pckbport/files.pckbport" + +# 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 + +include "arch/evbmips/conf/majors.evbmips" diff --git a/sys/arch/evbmips/conf/std.sbmips b/sys/arch/evbmips/conf/std.sbmips new file mode 100644 index 000000000000..f6bc481719f0 --- /dev/null +++ b/sys/arch/evbmips/conf/std.sbmips @@ -0,0 +1,16 @@ +# $NetBSD: std.sbmips,v 1.2.4.2 2017/08/30 15:45:03 martin Exp $ + +machine sbmips mips +include "conf/std" # MI standard options + +options MIPS64 +options MIPS64_SB1 # we use an SB1 core + +options EXEC_ELF32 # exec ELF32 binaries +options EXEC_SCRIPT # exec #! scripts + +makeoptions CFLAGS+="-mips64 -mtune=sb1" +makeoptions AFLAGS+="-mips64 -mtune=sb1" +makeoptions DEFTEXTADDR="0x80001000" + +include "arch/mips/conf/files.sibyte" diff --git a/sys/arch/evbmips/include/disklabel.h b/sys/arch/evbmips/include/disklabel.h index 31cd053dec36..34ffaf2f9597 100644 --- a/sys/arch/evbmips/include/disklabel.h +++ b/sys/arch/evbmips/include/disklabel.h @@ -1,4 +1,4 @@ -/* $NetBSD: disklabel.h,v 1.5 2011/08/30 12:39:54 bouyer Exp $ */ +/* $NetBSD: disklabel.h,v 1.5.46.1 2017/08/30 15:45:03 martin Exp $ */ /* * Copyright (c) 1994 Christopher G. Demetriou @@ -30,11 +30,163 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* + * 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. The "Broadcom Corporation" name may not 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 _EVBMIPS_DISKLABEL_H_ #define _EVBMIPS_DISKLABEL_H_ + #ifdef _KERNEL_OPT #include "opt_pmon.h" +#include "opt_cputype.h" #endif + +#ifdef MIPS64_SB1 + +#define LABELUSESMBR 0 /* no MBR partitionning */ +#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. */ +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ + +#ifndef __ASSEMBLER__ +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif /* HAVE_NBTOOL_CONFIG_H */ +struct cpu_disklabel { + struct mbr_partition mbrparts[MBR_PART_COUNT]; +#define __HAVE_DISKLABEL_DKBAD + 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 cfe_bb_data[64]; /* data (disklabel, also as below) */ +}; +#define cfe_bb_magic cfe_bb_data[59] /* magic number */ +#define cfe_bb_hdrinfo cfe_bb_data[60] /* header checksum, ver, flags */ +#define cfe_bb_secstart cfe_bb_data[61] /* secondary start (bytes) */ +#define cfe_bb_secsize cfe_bb_data[62] /* secondary size (bytes) */ +#define cfe_bb_archinfo cfe_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) + +#else /* MIPS64_SB1 */ + #ifdef PMON #define LABELUSESMBR 1 /* use MBR partitionning */ #else @@ -57,4 +209,6 @@ struct cpu_disklabel { struct dkbad bad; /* must have one element. */ }; +#endif /* MIPS64_SB1 */ + #endif /* !_EVBMIPS_DISKLABEL_H_ */ diff --git a/sys/arch/evbmips/include/loadfile_machdep.h b/sys/arch/evbmips/include/loadfile_machdep.h new file mode 100644 index 000000000000..10ecd89e04e1 --- /dev/null +++ b/sys/arch/evbmips/include/loadfile_machdep.h @@ -0,0 +1,53 @@ +/* $NetBSD: loadfile_machdep.h,v 1.1.1.1.4.2 2017/08/30 15:45:03 martin Exp $ */ + +/*- + * Copyright (c) 1999 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#define BOOT_ELF32 +#define BOOT_ELF64 + +#define LOAD_KERNEL (LOAD_ALL & ~LOAD_TEXTA) +#define COUNT_KERNEL (COUNT_ALL & ~COUNT_TEXTA) + +#define LOADADDR(a) (((u_long)(a)) + offset) +#define ALIGNENTRY(a) ((u_long)(a)) +#define READ(f, b, c) read((f), (void *)LOADADDR(b), (c)) +#define BCOPY(s, d, c) memcpy((void *)LOADADDR(d), (void *)(s), (c)) +#define BZERO(d, c) memset((void *)LOADADDR(d), 0, (c)) +#define WARN(a) do { \ + (void)printf a; \ + if (errno) \ + (void)printf(": %s\n", \ + strerror(errno)); \ + else \ + (void)printf("\n"); \ + } while(/* CONSTCOND */0) +#define PROGRESS(a) (void) printf a +#define ALLOC(a) alloc(a) +#define DEALLOC(a, b) dealloc(a, b) diff --git a/sys/arch/evbmips/include/param.h b/sys/arch/evbmips/include/param.h index e042fbe02618..a5e64da31532 100644 --- a/sys/arch/evbmips/include/param.h +++ b/sys/arch/evbmips/include/param.h @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.9 2011/03/18 16:30:01 tsutsui Exp $ */ +/* $NetBSD: param.h,v 1.9.48.1 2017/08/30 15:45:03 martin Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -55,7 +55,7 @@ #ifndef _LOCORE void delay(int n); -#define DELAY delay +#define DELAY(x) delay(x) #include diff --git a/sys/arch/evbmips/include/pci_machdep.h b/sys/arch/evbmips/include/pci_machdep.h index bbdbb3fc6df6..44adc8455c26 100644 --- a/sys/arch/evbmips/include/pci_machdep.h +++ b/sys/arch/evbmips/include/pci_machdep.h @@ -1,6 +1,13 @@ -/* $NetBSD: pci_machdep.h,v 1.2 2002/03/18 10:10:15 simonb Exp $ */ +/* $NetBSD: pci_machdep.h,v 1.2.202.1 2017/08/30 15:45:03 martin Exp $ */ +#ifdef _KERNEL_OPT +#include "opt_cputype.h" +#endif + +/* SB1 PCI isn't finished */ +#ifndef MIPS64_SB1 /* Before including */ #define __HAVE_PCIIDE_MACHDEP_COMPAT_INTR_ESTABLISH +#endif #include diff --git a/sys/arch/evbmips/sbmips/TODO b/sys/arch/evbmips/sbmips/TODO new file mode 100644 index 000000000000..e5e85bd505de --- /dev/null +++ b/sys/arch/evbmips/sbmips/TODO @@ -0,0 +1,59 @@ +$NetBSD: TODO,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin 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: + + * 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). + +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. currently the 'generic' sibyte + code in arch/mips/sibyte knows board-specific information, + and is not very clean. + + * board-level configuration details. + + * swarm LEDs. + + * MAC vs. fifo + + * sync serial vs. duart. + + * fifo driver. + + * sync serial driver. + +Cleanups / Improvements: + + * 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/evbmips/sbmips/autoconf.c b/sys/arch/evbmips/sbmips/autoconf.c new file mode 100644 index 000000000000..e17937942417 --- /dev/null +++ b/sys/arch/evbmips/sbmips/autoconf.c @@ -0,0 +1,74 @@ +/* $NetBSD: autoconf.c,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin 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. The "Broadcom Corporation" name may not 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: autoconf.c,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin Exp $"); + +#include +#include +#include +#include +#include +#include + +void +cpu_configure(void) +{ + + (void)splhigh(); + + if (config_rootfound("zbbus", NULL) == NULL) + panic("no zbbus found"); + + spl0(); +} + +void +cpu_rootconf(void) +{ + + /* XXXCGD don't know how to find the root device */ + + printf("boot device: %s\n", + booted_device ? device_xname(booted_device) : ""); + + rootconf(); +} + +void +device_register(device_t dev, void *aux) +{ + + /* XXXCGD */ +} diff --git a/sys/arch/evbmips/sbmips/autoconf.h b/sys/arch/evbmips/sbmips/autoconf.h new file mode 100644 index 000000000000..1efc47163ed4 --- /dev/null +++ b/sys/arch/evbmips/sbmips/autoconf.h @@ -0,0 +1,87 @@ +/* $NetBSD: autoconf.h,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin 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. The "Broadcom Corporation" name may not 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 for 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 + +#if _LP64 +#define BI_FIXUP(x) ((vaddr_t)x | 0xffffffff00000000) +#else +#define BI_FIXUP(x) x +#endif + + +struct bootinfo_v1 { + uint32_t version; /* 0: version of bootinfo */ + uint32_t reserved; /* 4: round to 64-bit boundary */ + uint32_t ssym; /* 8: start of kernel sym table */ + uint32_t esym; /* 12: end of kernel sym table */ + char boot_flags[64]; /* 16: boot flags */ + char booted_kernel[64]; /* 80: name of booted kernel */ + uint32_t fwhandle; /* 144: firmware handle */ + uint32_t fwentry; /* 148: firmware entry point */ + u_char reserved2[100]; /* 256: total size */ +}; + + +struct bootinfo_v1_int { + uint32_t version; /* 0/0: version of bootinfo */ + uint32_t reserved; /* 4/4: round to 64-bit boundary */ + vaddr_t ssym; /* 8/8: start of kernel sym table */ + vaddr_t esym; /* 12/16: end of kernel sym table */ + char boot_flags[64]; /* 16/24: boot flags */ + char booted_kernel[64]; /* 80/88: name of booted kernel */ + vaddr_t fwhandle; /* 144/152: firmware handle */ + vaddr_t fwentry; /* 148/160: firmware entry point */ +#ifdef _LP64 + u_char reserved2[88]; /* 168: total size -> 256 */ +#else + u_char reserved2[104]; /* 152: total size -> 256 */ +#endif +}; + diff --git a/sys/arch/evbmips/sbmips/console.c b/sys/arch/evbmips/sbmips/console.c new file mode 100644 index 000000000000..af5d9e07d444 --- /dev/null +++ b/sys/arch/evbmips/sbmips/console.c @@ -0,0 +1,66 @@ +/* $NetBSD: console.c,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin 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. The "Broadcom Corporation" name may not 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: console.c,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin Exp $"); + +#include +#include +#include +#include +#include + +#ifdef JTAGCONSOLE +#include +#endif +#include + +#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */ +#ifndef CONSPEED +#define CONSPEED 115200 +#endif + +void +consinit(void) +{ + +#ifdef JTAGCONSOLE + sbjcn_cnattach(0x1001FF80, 0, CONSPEED, CONMODE); +#else + sbscn_cnattach(0x10060100, 0, CONSPEED, CONMODE); +#ifdef KGDB + sbscn_kgdb_attach(0x10060100, 1, CONSPEED, CONMODE); +#endif +#endif +} diff --git a/sys/arch/evbmips/sbmips/cpu.c b/sys/arch/evbmips/sbmips/cpu.c new file mode 100644 index 000000000000..54857f0c85b7 --- /dev/null +++ b/sys/arch/evbmips/sbmips/cpu.c @@ -0,0 +1,178 @@ +/* $NetBSD: cpu.c,v 1.3.4.2 2017/08/30 15:45:04 martin 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. The "Broadcom Corporation" name may not 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: cpu.c,v 1.3.4.2 2017/08/30 15:45:04 martin Exp $"); + +#include "opt_multiprocessor.h" + +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include + +#define READ_REG(rp) mips3_ld((register_t)(rp)) + +static int cpu_match(device_t, cfdata_t, void *); +static void cpu_attach(device_t, device_t, void *); + +CFATTACH_DECL_NEW(cpu, sizeof(struct cpu_softc), + cpu_match, cpu_attach, NULL, NULL); + +static u_int found = 0; + +static int +cpu_match(device_t parent, cfdata_t match, void *aux) +{ + struct zbbus_attach_args *zap = aux; + int part; + + if (zap->za_locs.za_type != ZBBUS_ENTTYPE_CPU) + return (0); + + /* + * The 3rd hex digit of the part number is the number of CPUs; + * ref Table 26, p38 1250-UM101-R. + */ + part = G_SYS_PART(READ_REG(MIPS_PHYS_TO_KSEG1(A_SCD_SYSTEM_REVISION))); + return (found < ((part >> 8) & 0xf)); +} + +static void +cpu_attach(device_t parent, device_t self, void *aux) +{ + struct cpu_info *ci; + struct cpu_softc * const cpu = device_private(self); + const char * const xname = device_xname(self); + uint32_t config; + int plldiv; + + found++; + + /* XXX this code must run on the target CPU */ + config = mips3_cp0_config_read(); + __USE(config); + KASSERT((config & MIPS3_CONFIG_K0_MASK) == 5); + + /* Determine CPU frequency */ + + /* XXX: We should determine the CPU frequency from a time source + * not coupled with the CPU crystal, like the RTC. Unfortunately + * we don't attach that yet... + */ + plldiv = G_SYS_PLL_DIV(READ_REG(MIPS_PHYS_TO_KSEG1(A_SCD_SYSTEM_CFG))); + if (plldiv == 0) { + aprint_normal(": PLL_DIV of zero found, assuming 6 (300MHz)\n"); + plldiv = 6; + + aprint_normal("%s", xname); + } + + if (found == 1) { + ci = curcpu(); + ci->ci_cpu_freq = 50000000 * plldiv; + /* Compute the delay divisor. */ + ci->ci_divisor_delay = (ci->ci_cpu_freq + 500000) / 1000000; + /* Compute clock cycles per hz */ + ci->ci_cycles_per_hz = (ci->ci_cpu_freq + hz / 2 ) / hz; + + aprint_normal(": %lu.%02luMHz (hz cycles = %lu, delay divisor = %lu)\n", + ci->ci_cpu_freq / 1000000, + (ci->ci_cpu_freq % 1000000) / 10000, + ci->ci_cycles_per_hz, ci->ci_divisor_delay); + + KASSERT(ci->ci_cpuid == 0); + + cpu->sb1cpu_dev = self; + cpu->sb1cpu_ci = ci; + ci->ci_softc = cpu; + + sb1250_cpu_init(cpu); + } else { +#if defined(MULTIPROCESSOR) + int status; + ci = cpu_info_alloc(NULL, found - 1, 0, found - 1, 0); + KASSERT(ci); + + cpu->sb1cpu_dev = self; + cpu->sb1cpu_ci = ci; + ci->ci_softc = cpu; + + sb1250_cpu_init(cpu); + + status = cfe_cpu_start(ci->ci_cpuid, cpu_trampoline, + (long) ci->ci_data.cpu_idlelwp->l_md.md_utf, 0, + (long) ci); + if (status != 0) { + aprint_error(": CFE call to start failed: %d\n", + status); + } + const u_long cpu_mask = 1L << cpu_index(ci); + for (size_t i = 0; i < 10000; i++) { + if (cpus_hatched & cpu_mask) + break; + DELAY(100); + } + if ((cpus_hatched & cpu_mask) == 0) { + aprint_error(": failed to hatch!\n"); + return; + } +#else + aprint_normal_dev(self, + "processor off-line; " + "multiprocessor support not present in kernel\n"); + return; +#endif + } + + /* + * Announce ourselves. + */ + aprint_normal("%s: ", xname); + cpu_identify(self); + + cpu_attach_common(self, ci); +} diff --git a/sys/arch/evbmips/sbmips/cpuvar.h b/sys/arch/evbmips/sbmips/cpuvar.h new file mode 100644 index 000000000000..97c8cb518202 --- /dev/null +++ b/sys/arch/evbmips/sbmips/cpuvar.h @@ -0,0 +1,21 @@ +/* $NetBSD: cpuvar.h,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin Exp $ */ + +#ifndef _SBMIPS_CPUVAR_H_ +#define _SBMIPS_CPUVAR_H_ + +#include + +#ifndef _LOCORE +struct cpu_softc { + device_t sb1cpu_dev; + struct cpu_info *sb1cpu_ci; + vaddr_t sb1cpu_imr_base; + uint64_t sb1cpu_imr_all; + struct evcnt sb1cpu_intr_evcnts[64]; + struct evcnt sb1cpu_spurious_intrs[_IPL_N]; + struct evcnt sb1cpu_intrs[_IPL_N]; + struct evcnt sb1cpu_int5; +}; +#endif /* _LOCORE */ + +#endif /* !_SBMIPS_CPUVAR_H_ */ diff --git a/sys/arch/evbmips/sbmips/disksubr.c b/sys/arch/evbmips/sbmips/disksubr.c new file mode 100644 index 000000000000..c58143dc3e4c --- /dev/null +++ b/sys/arch/evbmips/sbmips/disksubr.c @@ -0,0 +1,393 @@ +/* $NetBSD: disksubr.c,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin 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. 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 +__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin Exp $"); + +#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(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 *)((char *)bp->b_data + MBR_MAGIC_OFFSET); + if (*mbrmagicp != MBR_MAGIC) + return (NO_MBR_SIGNATURE); + + /* XXX how do we check veracity/bounds of this? */ + memcpy(dp, (char *)bp->b_data + MBR_PART_OFFSET, MBR_PART_COUNT * sizeof(*dp)); + + /* look for NetBSD partition */ + for (i = 0; i < MBR_PART_COUNT; i++) { + if (dp[i].mbrp_type == MBR_PTYPE_NETBSD) { + ourdp = &dp[i]; + break; + } + } + + return (ourdp); +} + + +/* + * Attempt to read a disk label from a device + * using the indicated strategy 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. + */ +const char * +readdisklabel(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; + const 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->mbrparts; + + /* read master boot record */ + bp->b_blkno = MBR_BBSECTOR; + bp->b_bcount = lp->d_secsize; + bp->b_cflags = BC_BUSY; + bp->b_flags |= 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 < MBR_PART_COUNT; 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_type == MBR_PTYPE_LNXEXT2) + pp->p_fstype = FS_EX2FS; + + if (dp->mbrp_type == 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_cflags = BC_BUSY; + bp->b_flags = 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 *) + ((char *)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_cflags = BC_BUSY; + bp->b_flags = 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_error && (i += 2) < 10 && + i < lp->d_nsectors); + } + +done: + brelse(bp, BC_INVAL); + return (msg); +} + +/* + * Check new disk label for sensibility + * before setting it. + */ +int +setdisklabel(struct disklabel *olp, struct disklabel *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_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->mbrparts; + + /* read master boot record */ + bp->b_blkno = MBR_BBSECTOR; + bp->b_bcount = lp->d_secsize; + bp->b_cflags = BC_BUSY; + bp->b_flags = 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_cflags = BC_BUSY; + bp->b_flags = 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 *) + ((char *)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_cflags = BC_BUSY; + bp->b_flags = B_WRITE; + (*strat)(bp); + error = biowait(bp); + goto done; + } + } + error = ESRCH; + +done: + brelse(bp, BC_INVAL); + return (error); +} diff --git a/sys/arch/evbmips/sbmips/leds.h b/sys/arch/evbmips/sbmips/leds.h new file mode 100644 index 000000000000..ebe0274dfbbd --- /dev/null +++ b/sys/arch/evbmips/sbmips/leds.h @@ -0,0 +1,37 @@ +/* $NetBSD: leds.h,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin 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. The "Broadcom Corporation" name may not 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/evbmips/sbmips/locore_machdep.S b/sys/arch/evbmips/sbmips/locore_machdep.S new file mode 100644 index 000000000000..ce6cc2ac186e --- /dev/null +++ b/sys/arch/evbmips/sbmips/locore_machdep.S @@ -0,0 +1,3 @@ +/* $NetBSD: locore_machdep.S,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin Exp $ */ + +/* This file intentionally left blank. */ diff --git a/sys/arch/evbmips/sbmips/machdep.c b/sys/arch/evbmips/sbmips/machdep.c new file mode 100644 index 000000000000..2756519b9574 --- /dev/null +++ b/sys/arch/evbmips/sbmips/machdep.c @@ -0,0 +1,449 @@ +/* $NetBSD: machdep.c,v 1.2.4.2 2017/08/30 15:45:04 martin 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. The "Broadcom Corporation" name may not 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 +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.2.4.2 2017/08/30 15:45:04 martin Exp $"); + +#include "opt_ddb.h" +#include "opt_execfmt.h" +#include "opt_modular.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 + +#if 0 /* XXXCGD */ +#include +#endif /* XXXCGD */ +#include + +#include + +#include "ksyms.h" + +#if NKSYMS || defined(DDB) || defined(MODULAR) +#include +#include +#include +#include +#ifndef DB_ELFSIZE +#error Must define DB_ELFSIZE! +#endif +#define ELFSIZE DB_ELFSIZE +#include +#endif + +#include + +#if NKSYMS || defined(DDB) || defined(MODULAR) +/* start and end of kernel symbol table */ +void *ksym_start, *ksym_end; +#endif + +/* Maps for VM objects. */ +struct vm_map *phys_map = NULL; + +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); + +extern void *esym; + +/* + * Do all the stuff that locore normally does before calling main(). + */ +void +mach_init(long fwhandle, long magic, long bootdata, long reserved) +{ + void *kernend; + extern char edata[], end[]; + 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); + + /* Zero BSS. XXXCGD: uh, is this really necessary still? */ + memset(edata, 0, end - 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 + */ + + if (magic == BOOTINFO_MAGIC) + memcpy(&bootinfo, (struct bootinfo_v1 *)bootdata, + sizeof bootinfo); + else if (reserved == CFE_EPTSEAL) { + magic = BOOTINFO_MAGIC; + memset(&bootinfo, 0, sizeof bootinfo); + bootinfo.version = BOOTINFO_VERSION; + bootinfo.fwhandle = fwhandle; + bootinfo.fwentry = bootdata; + bootinfo.ssym = (vaddr_t)end; + bootinfo.esym = (vaddr_t)end; + } + + kernend = (void *)mips_round_page(end); +#if NKSYMS || defined(DDB) || defined(MODULAR) + if (magic == BOOTINFO_MAGIC) { + ksym_start = (void *)(intptr_t)bootinfo.ssym; + ksym_end = (void *)(intptr_t)bootinfo.esym; + kernend = (void *)mips_round_page((vaddr_t)ksym_end); + } +#endif + + consinit(); + + uvm_md_init(); + + /* + * Copy exception-dispatch code down to exception vector. + * Initialize locore-function vector. + * Clear out the I and D caches. + */ +#ifdef MULTIPROCESSOR + mips_vector_init(NULL, true); +#else + mips_vector_init(NULL, false); +#endif + + mips_locoresw.lsw_bus_error = sibyte_bus_watch_check; + + sb1250_ipl_map_init(); + +#ifdef DEBUG + printf("fwhandle=%08X magic=%08X bootdata=%08X reserved=%08X\n", + (u_int)fwhandle, (u_int)magic, (u_int)bootdata, (u_int)reserved); +#endif + + cpu_setmodel("sb1250"); + + if (magic == BOOTINFO_MAGIC) { + int idx; + int added; + uint64_t start, len, type; + + cfe_init(bootinfo.fwhandle, bootinfo.fwentry); + cfe_present = 1; + + idx = 0; + physmem = 0; + mem_cluster_cnt = 0; + while (cfe_enummem(idx, 0, &start, &len, &type) == 0) { + added = 0; + printf("Memory Block #%d start %08"PRIx64"X len %08"PRIx64"X: %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 + * XXX needs special 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. + */ + /* XXX hardwire to 32MB; should be kernel config option */ + physmem = 32 * 1024 * 1024 / 4096; + mem_clusters[0].start = 0; + mem_clusters[0].size = ctob(physmem); + mem_cluster_cnt = 1; + } + + + for (u_int 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++; + } + } + } + + /* + * Load the rest of the available pages into the VM system. + */ + mips_page_physload(MIPS_KSEG0_START, (vaddr_t) kernend, + mem_clusters, mem_cluster_cnt, NULL, 0); + + /* + * Initialize error message buffer (at end of core). + */ + mips_init_msgbuf(); + + pmap_bootstrap(); + + /* + * Allocate uarea for lwp0 and set it. + */ + mips_init_lwp0_uarea(); + + /* + * Initialize debuggers, and break into them, if appropriate. + */ +#if NKSYMS || defined(DDB) || defined(MODULAR) + ksyms_addsyms_elf(((uintptr_t)ksym_end - (uintptr_t)ksym_start), + ksym_start, ksym_end); +#endif + + if (boothowto & RB_KDB) { +#if defined(DDB) + Debugger(); +#endif + } + +#ifdef MULTIPROCESSOR + mips_fixup_exceptions(mips_fixup_zero_relative); +#endif +} + +/* + * Allocate memory for variable-sized tables, + */ +void +cpu_startup(void) +{ + /* + * Just do the common stuff. + */ + cpu_startup_common(); +} + +int waittime = -1; + +void +cpu_reboot(int howto, char *bootstr) +{ + + /* Take a snapshot before clobbering any registers. */ + savectx(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(); + + pmf_system_shutdown(boothowto); + + 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) { + /* + * XXX + * For some reason we can't return to CFE with + * and do a warm start. Need to look into this... + */ + cfe_exit(0, (howto & RB_DUMP) ? 1 : 0); + printf("cfe_exit didn't!\n"); + } + + 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(SWARM_LEDS_PHYS); + + 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; + + rv = 2; /* Uncached. */ + + /* 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 >= 0x0100000000LL && pa <= 0x07ffffffffLL) || /* DRAM exp */ +#endif + 0) { + rv = 5; /* Cacheable coherent. */ + } + + return (rv); +} diff --git a/sys/arch/evbmips/sbmips/rtc.c b/sys/arch/evbmips/sbmips/rtc.c new file mode 100644 index 000000000000..ebd053a7666b --- /dev/null +++ b/sys/arch/evbmips/sbmips/rtc.c @@ -0,0 +1,602 @@ +/* $NetBSD: rtc.c,v 1.2.4.2 2017/08/30 15:45:04 martin Exp $ */ + +/* + * Copyright 2002 Wasabi Systems, Inc. + * All rights reserved. + * + * Written by Simon Burge for Wasabi Systems, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed for the NetBSD Project by + * Wasabi Systems, Inc. + * 4. The name of Wasabi Systems, Inc. may not be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC + * 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 +__KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.2.4.2 2017/08/30 15:45:04 martin Exp $"); + +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include + +#include +#include + +struct rtc_softc { + device_t sc_dev; + int sc_smbus_chan; + int sc_smbus_addr; + int sc_type; + struct todr_chip_handle sc_ct; +}; + +/* "types" for RTCs we support */ +#define SMB_1BYTE_ADDR 1 +#define SMB_2BYTE_ADDR 2 + +static int xirtc_match(device_t, cfdata_t , void *); +static void xirtc_attach(device_t, device_t, void *); +static int xirtc_gettime(todr_chip_handle_t, struct clock_ymdhms *); +static int xirtc_settime(todr_chip_handle_t, struct clock_ymdhms *); + +static int strtc_match(device_t, cfdata_t , void *); +static void strtc_attach(device_t, device_t, void *); +static int strtc_gettime(todr_chip_handle_t, struct clock_ymdhms *); +static int strtc_settime(todr_chip_handle_t, struct clock_ymdhms *); + +static void rtc_cal_timer(void); + +static void time_smbus_init(int); +static int time_waitready(int); +static int time_readrtc(int, int, int, int); +static int time_writertc(int, int, int, int, int); + +#define WRITERTC(sc, dev, val) \ + time_writertc((sc)->sc_smbus_chan, (sc)->sc_smbus_addr, (dev), (sc)->sc_type, (val)) +#define READRTC(sc, dev) \ + time_readrtc((sc)->sc_smbus_chan, (sc)->sc_smbus_addr, (dev), (sc)->sc_type) + + +CFATTACH_DECL_NEW(xirtc, sizeof(struct rtc_softc), + xirtc_match, xirtc_attach, NULL, NULL); + +CFATTACH_DECL_NEW(m41t81rtc, sizeof(struct rtc_softc), + strtc_match, strtc_attach, NULL, NULL); + +static int rtcfound = 0; +struct rtc_softc *the_rtc; + +/* + * Xicor X1241 RTC support. + */ +static int +xirtc_match(device_t parent, cfdata_t cf, void *aux) +{ + struct smbus_attach_args *sa = aux; + int ret; + + time_smbus_init(sa->sa_interface); + + if ((sa->sa_interface != X1241_SMBUS_CHAN) || + (sa->sa_device != X1241_RTC_SLAVEADDR)) + return (0); + + ret = time_readrtc(sa->sa_interface, sa->sa_device, SMB_2BYTE_ADDR, X1241REG_SC); + if (ret < 0) + return (0); + + return (!rtcfound); +} + +static void +xirtc_attach(device_t parent, device_t self, void *aux) +{ + struct smbus_attach_args *sa = aux; + struct rtc_softc *sc = device_private(self); + + rtcfound = 1; + the_rtc = sc; + + sc->sc_dev = self; + sc->sc_smbus_chan = sa->sa_interface; + sc->sc_smbus_addr = sa->sa_device; + sc->sc_type = SMB_2BYTE_ADDR; /* Two-byte register addresses on the Xicor */ + + + /* Set up MI todr(9) stuff */ + sc->sc_ct.cookie = sc; + sc->sc_ct.todr_settime_ymdhms = xirtc_settime; + sc->sc_ct.todr_gettime_ymdhms = xirtc_gettime; + + todr_attach(&sc->sc_ct); + + aprint_normal("\n"); + rtc_cal_timer(); /* XXX */ +} + +static int +xirtc_settime(todr_chip_handle_t handle, struct clock_ymdhms *ymdhms) +{ + struct rtc_softc *sc = handle->cookie; + uint8_t year, y2k; + + time_smbus_init(sc->sc_smbus_chan); + + /* unlock writes to the CCR */ + WRITERTC(sc, X1241REG_SR, X1241REG_SR_WEL); + WRITERTC(sc, X1241REG_SR, X1241REG_SR_WEL | X1241REG_SR_RWEL); + + /* set the time */ + WRITERTC(sc, X1241REG_HR, bintobcd(ymdhms->dt_hour) | X1241REG_HR_MIL); + WRITERTC(sc, X1241REG_MN, bintobcd(ymdhms->dt_min)); + WRITERTC(sc, X1241REG_SC, bintobcd(ymdhms->dt_sec)); + + /* set the date */ + y2k = (ymdhms->dt_year >= 2000) ? 0x20 : 0x19; + year = ymdhms->dt_year % 100; + + WRITERTC(sc, X1241REG_MO, bintobcd(ymdhms->dt_mon)); + WRITERTC(sc, X1241REG_DT, bintobcd(ymdhms->dt_day)); + WRITERTC(sc, X1241REG_YR, bintobcd(year)); + WRITERTC(sc, X1241REG_Y2K, bintobcd(y2k)); + + /* lock writes again */ + WRITERTC(sc, X1241REG_SR, 0); + + return (0); +} + +static int +xirtc_gettime(todr_chip_handle_t handle, struct clock_ymdhms *ymdhms) +{ + struct rtc_softc *sc = handle->cookie; + uint8_t hour, year, y2k; + uint8_t status; + + time_smbus_init(sc->sc_smbus_chan); + ymdhms->dt_day = bcdtobin(READRTC(sc, X1241REG_DT)); + ymdhms->dt_mon = bcdtobin(READRTC(sc, X1241REG_MO)); + year = READRTC(sc, X1241REG_YR); + y2k = READRTC(sc, X1241REG_Y2K); + ymdhms->dt_year = bcdtobin(y2k) * 100 + bcdtobin(year); + + + ymdhms->dt_sec = bcdtobin(READRTC(sc, X1241REG_SC)); + ymdhms->dt_min = bcdtobin(READRTC(sc, X1241REG_MN)); + hour = READRTC(sc, X1241REG_HR); + ymdhms->dt_hour = bcdtobin(hour & ~X1241REG_HR_MIL); + + status = READRTC(sc, X1241REG_SR); + + if (status & X1241REG_SR_RTCF) { + printf("%s: battery has failed, clock setting is not accurate\n", + device_xname(sc->sc_dev)); + return (EIO); + } + + return (0); +} + +/* + * ST M41T81 RTC support. + */ +static int +strtc_match(device_t parent, cfdata_t cf, void *aux) +{ + struct smbus_attach_args *sa = aux; + int ret; + + if ((sa->sa_interface != M41T81_SMBUS_CHAN) || + (sa->sa_device != M41T81_SLAVEADDR)) + return (0); + + time_smbus_init(sa->sa_interface); + + ret = time_readrtc(sa->sa_interface, sa->sa_device, SMB_1BYTE_ADDR, M41T81_SEC); + if (ret < 0) + return (0); + + return (!rtcfound); +} + +static void +strtc_attach(device_t parent, device_t self, void *aux) +{ + struct smbus_attach_args *sa = aux; + struct rtc_softc *sc = device_private(self); + + rtcfound = 1; + the_rtc = sc; + + sc->sc_dev = self; + sc->sc_smbus_chan = sa->sa_interface; + sc->sc_smbus_addr = sa->sa_device; + sc->sc_type = SMB_1BYTE_ADDR; /* One-byte register addresses on the ST */ + + /* Set up MI todr(9) stuff */ + sc->sc_ct.cookie = sc; + sc->sc_ct.todr_settime_ymdhms = strtc_settime; + sc->sc_ct.todr_gettime_ymdhms = strtc_gettime; + + todr_attach(&sc->sc_ct); + + aprint_normal("\n"); + rtc_cal_timer(); /* XXX */ +} + +static int +strtc_settime(todr_chip_handle_t handle, struct clock_ymdhms *ymdhms) +{ + struct rtc_softc *sc = handle->cookie; + uint8_t hour; + + time_smbus_init(sc->sc_smbus_chan); + + hour = bintobcd(ymdhms->dt_hour); + if (ymdhms->dt_year >= 2000) /* Should be always true! */ + hour |= M41T81_HOUR_CB | M41T81_HOUR_CEB; + + /* set the time */ + WRITERTC(sc, M41T81_SEC, bintobcd(ymdhms->dt_sec)); + WRITERTC(sc, M41T81_MIN, bintobcd(ymdhms->dt_min)); + WRITERTC(sc, M41T81_HOUR, hour); + + /* set the date */ + WRITERTC(sc, M41T81_DATE, bintobcd(ymdhms->dt_day)); + WRITERTC(sc, M41T81_MON, bintobcd(ymdhms->dt_mon)); + WRITERTC(sc, M41T81_YEAR, bintobcd(ymdhms->dt_year % 100)); + + return (0); +} + +static int +strtc_gettime(todr_chip_handle_t handle, struct clock_ymdhms *ymdhms) +{ + struct rtc_softc *sc = handle->cookie; + uint8_t hour; + + time_smbus_init(sc->sc_smbus_chan); + + ymdhms->dt_sec = bcdtobin(READRTC(sc, M41T81_SEC)); + ymdhms->dt_min = bcdtobin(READRTC(sc, M41T81_MIN)); + hour = READRTC(sc, M41T81_HOUR & M41T81_HOUR_MASK); + ymdhms->dt_hour = bcdtobin(hour & M41T81_HOUR_MASK); + + ymdhms->dt_day = bcdtobin(READRTC(sc, M41T81_DATE)); + ymdhms->dt_mon = bcdtobin(READRTC(sc, M41T81_MON)); + ymdhms->dt_year = 1900 + bcdtobin(READRTC(sc, M41T81_YEAR)); + if (hour & M41T81_HOUR_CB) + ymdhms->dt_year += 100; + + return (0); +} + +#define NITERS 3 +#define RTC_SECONDS(rtc) bcdtobin(READRTC((rtc), X1241REG_SC)) + +/* + * Since it takes so long to read the complete time/date values from + * the RTC over the SMBus, we only read the seconds value. + * Later versions of the SWARM will hopefully have the RTC interrupt + * attached so we can do the clock calibration much more quickly and + * with a higher resolution. + */ +static void +rtc_cal_timer(void) +{ + uint32_t ctrdiff[NITERS], startctr, endctr; + int sec, lastsec, i; + + if (rtcfound == 0) { + printf("rtc_cal_timer before rtc attached\n"); + return; + } +return; /* XXX XXX */ + + printf("%s: calibrating CPU clock", device_xname(the_rtc->sc_dev)); + + /* + * Run the loop an extra time to wait for the second to tick over + * and to prime the cache. + */ + time_smbus_init(the_rtc->sc_smbus_chan); + sec = RTC_SECONDS(the_rtc); + endctr = mips3_cp0_count_read(); + + for (i = 0; i < NITERS; i++) { + int diff; + + again: + lastsec = sec; + startctr = endctr; + + /* Wait for the timer to tick over. */ + do { + // time_smbus_init(the_rtc->sc_smbus_chan); + sec = RTC_SECONDS(the_rtc); + } while (lastsec == sec); + endctr = mips3_cp0_count_read(); + + diff = sec - lastsec; + if (diff < 0) + diff += 60; + + /* Sometimes we appear to skip a second. Clock jitter? */ + if (diff > 1) + goto again; + + if (endctr < startctr) + ctrdiff[i] = 0xffffffff - startctr + endctr; + else + ctrdiff[i] = endctr - startctr; + } + printf("\n"); + + /* Compute the number of cycles per second. */ + curcpu()->ci_cpu_freq = ((ctrdiff[1] + ctrdiff[2]) / 2); + + /* Compute the delay divisor. */ + curcpu()->ci_divisor_delay = curcpu()->ci_cpu_freq / 1000000; + + /* Compute clock cycles per hz */ + curcpu()->ci_cycles_per_hz = curcpu()->ci_cpu_freq / hz; + + printf("%s: timer calibration: %lu cycles/sec [(%u, %u)]\n", + device_xname(the_rtc->sc_dev), curcpu()->ci_cpu_freq, + ctrdiff[1], ctrdiff[2]); +} +#undef RTC_SECONDS + +/* XXX eville direct-access-to-the-device code follows... */ + +/* + * 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. The "Broadcom Corporation" name may not 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 + +#define READ_REG(rp) mips3_ld((register_t)(MIPS_PHYS_TO_KSEG1(rp))) +#define WRITE_REG(rp, val) mips3_sd((register_t)(MIPS_PHYS_TO_KSEG1(rp)), (val)) + +static void +time_smbus_init(int chan) +{ + uint32_t reg; + + reg = A_SMB_REGISTER(chan, R_SMB_FREQ); + WRITE_REG(reg, K_SMB_FREQ_100KHZ); + reg = A_SMB_REGISTER(chan, R_SMB_CONTROL); + WRITE_REG(reg, 0); /* not in direct mode, no interrupts, will poll */ +} + +static int +time_waitready(int chan) +{ + uint32_t reg; + uint64_t status; + + reg = A_SMB_REGISTER(chan, R_SMB_STATUS); + + for (;;) { + status = READ_REG(reg); + if (status & M_SMB_BUSY) + continue; + break; + } + + if (status & M_SMB_ERROR) { + WRITE_REG(reg, (status & M_SMB_ERROR)); + return (-1); + } + return (0); +} + +static int +time_readrtc(int chan, int slaveaddr, int devaddr, int type) +{ + uint32_t reg; + int err; + + /* + * Make sure the bus is idle (probably should + * ignore error here) + */ + + if (time_waitready(chan) < 0) + return (-1); + + if (type == SMB_2BYTE_ADDR) { + /* + * Write the device address to the controller. There are two + * parts, the high part goes in the "CMD" field, and the + * low part is the data field. + */ + + reg = A_SMB_REGISTER(chan, R_SMB_CMD); + WRITE_REG(reg, (devaddr >> 8) & 0x7); + + /* + * Write the data to the controller + */ + + reg = A_SMB_REGISTER(chan, R_SMB_DATA); + WRITE_REG(reg, (devaddr & 0xff) & 0xff); + } else { /* SMB_1BYTE_ADDR */ + /* + * Write the device address to the controller. + */ + + reg = A_SMB_REGISTER(chan, R_SMB_CMD); + WRITE_REG(reg, devaddr & 0xff); + } + + /* + * Start the command + */ + + reg = A_SMB_REGISTER(chan, R_SMB_START); + if (type == SMB_2BYTE_ADDR) + WRITE_REG(reg, V_SMB_TT(K_SMB_TT_WR2BYTE) | V_SMB_ADDR(slaveaddr)); + else /* SMB_1BYTE_ADDR */ + WRITE_REG(reg, V_SMB_TT(K_SMB_TT_WR1BYTE) | V_SMB_ADDR(slaveaddr)); + + /* + * Wait till done + */ + + err = time_waitready(chan); + if (err < 0) + return (err); + + /* + * Read the data byte + */ + + WRITE_REG(reg, V_SMB_TT(K_SMB_TT_RD1BYTE) | V_SMB_ADDR(slaveaddr)); + + err = time_waitready(chan); + if (err < 0) + return (err); + + reg = A_SMB_REGISTER(chan, R_SMB_DATA); + err = READ_REG(reg); + + return (err & 0xff); +} + +static int +time_writertc(int chan, int slaveaddr, int devaddr, int type, int b) +{ + uint32_t reg; + int err, timer; + + /* + * Make sure the bus is idle (probably should + * ignore error here) + */ + + if (time_waitready(chan) < 0) + return (-1); + + /* + * Write the device address to the controller. There are two + * parts, the high part goes in the "CMD" field, and the + * low part is the data field. + */ + + reg = A_SMB_REGISTER(chan, R_SMB_CMD); + if (type == SMB_2BYTE_ADDR) + WRITE_REG(reg, (devaddr >> 8) & 0x7); + else /* SMB_1BYTE_ADDR */ + WRITE_REG(reg, devaddr & 0xff); + + /* + * Write the data to the controller + */ + + reg = A_SMB_REGISTER(chan, R_SMB_DATA); + if (type == SMB_2BYTE_ADDR) + WRITE_REG(reg, (devaddr & 0xff) | ((b & 0xff) << 8)); + else /* SMB_1BYTE_ADDR */ + WRITE_REG(reg, b & 0xff); + + /* + * Start the command. Keep pounding on the device until it + * submits or the timer expires, whichever comes first. The + * datasheet says writes can take up to 10ms, so we'll give it 500. + */ + + reg = A_SMB_REGISTER(chan, R_SMB_START); + if (type == SMB_2BYTE_ADDR) + WRITE_REG(reg, V_SMB_TT(K_SMB_TT_WR3BYTE) | V_SMB_ADDR(slaveaddr)); + else /* SMB_1BYTE_ADDR */ + WRITE_REG(reg, V_SMB_TT(K_SMB_TT_WR2BYTE) | V_SMB_ADDR(slaveaddr)); + + /* + * Wait till the SMBus interface is done + */ + + err = time_waitready(chan); + if (err < 0) + return (err); + + /* + * Pound on the device with a current address read + * to poll for the write complete + */ + + err = -1; + timer = 100000000; /* XXX */ + + while (timer-- > 0) { + WRITE_REG(reg, V_SMB_TT(K_SMB_TT_RD1BYTE) | V_SMB_ADDR(slaveaddr)); + + err = time_waitready(chan); + if (err == 0) + break; + } + + return (err); +} diff --git a/sys/arch/evbmips/sbmips/sb1250_icu.c b/sys/arch/evbmips/sbmips/sb1250_icu.c new file mode 100644 index 000000000000..a357be77b1a0 --- /dev/null +++ b/sys/arch/evbmips/sbmips/sb1250_icu.c @@ -0,0 +1,366 @@ +/* $NetBSD: sb1250_icu.c,v 1.2.4.2 2017/08/30 15:45:04 martin 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. The "Broadcom Corporation" name may not 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: sb1250_icu.c,v 1.2.4.2 2017/08/30 15:45:04 martin Exp $"); + +#define __INTR_PRIVATE + +#include +#include +#include +#include +#include +#include + +/* XXX for uvmexp */ +#include + +#include + +#include +#include + +#include +#include +#include + +static const struct ipl_sr_map sb1250_ipl_sr_map = { + .sr_bits = { + [IPL_NONE] = MIPS_INT_MASK_5, + [IPL_SOFTCLOCK] = MIPS_SOFT_INT_MASK_0 | MIPS_INT_MASK_5, + [IPL_SOFTBIO] = MIPS_SOFT_INT_MASK_0 | MIPS_INT_MASK_5, + [IPL_SOFTNET] = MIPS_SOFT_INT_MASK | MIPS_INT_MASK_5, + [IPL_SOFTSERIAL] = MIPS_SOFT_INT_MASK | MIPS_INT_MASK_5, + [IPL_VM] = MIPS_SOFT_INT_MASK | MIPS_INT_MASK_0 + | MIPS_INT_MASK_5, + [IPL_SCHED] = MIPS_SOFT_INT_MASK | MIPS_INT_MASK_0 + | MIPS_INT_MASK_1 | MIPS_INT_MASK_5, + [IPL_DDB] = MIPS_SOFT_INT_MASK | MIPS_INT_MASK_0 + | MIPS_INT_MASK_1 | MIPS_INT_MASK_4 + | MIPS_INT_MASK_5, + [IPL_HIGH] = MIPS_INT_MASK, + }, +}; + +/* imr values corresponding to each pin */ +static uint64_t ints_for_ipl[_IPL_N]; + +struct sb1250_ihand { + void (*ih_fun)(void *, uint32_t, vaddr_t); + void *ih_arg; + int ih_ipl; +}; + +static struct sb1250_ihand sb1250_ihands[K_INT_SOURCES]; + +#ifdef MULTIPROCESSOR +static void sb1250_ipi_intr(void *, uint32_t, vaddr_t); +#endif +#define SB1250_I_MAP(x) (R_IMR_INTERRUPT_MAP_BASE + (x) * 8) + +#define READ_REG(rp) mips3_ld((register_t)(rp)) +#define WRITE_REG(rp, val) mips3_sd((register_t)(rp), (val)) + +static void sb1250_cpu_intr(int, vaddr_t, uint32_t); +static void *sb1250_intr_establish(u_int, u_int, + void (*fun)(void *, uint32_t, vaddr_t), void *); + +static const char sb1250_intr_names[K_INT_SOURCES][16] = { + [K_INT_WATCHDOG_TIMER_0] = "wdog0", + [K_INT_WATCHDOG_TIMER_1] = "wdog1", + [K_INT_TIMER_0] = "timer0", + [K_INT_TIMER_1] = "timer1", + [K_INT_TIMER_2] = "timer2", + [K_INT_TIMER_3] = "timer3", + [K_INT_SMB_0] = "smb0", + [K_INT_SMB_1] = "smb1", + [K_INT_UART_0] = "uart0", + [K_INT_UART_1] = "uart1", + [K_INT_SER_0] = "syncser0", + [K_INT_SER_1] = "syncser1", + [K_INT_PCMCIA] = "pcmcia", + [K_INT_ADDR_TRAP] = "addrtrap", + [K_INT_PERF_CNT] = "perfcnt", + [K_INT_TRACE_FREEZE] = "tracefreeze", + [K_INT_BAD_ECC] = "bad ECC", + [K_INT_COR_ECC] = "corrected ECC", + [K_INT_IO_BUS] = "iobus", + [K_INT_MAC_0] = "mac0", + [K_INT_MAC_1] = "mac1", + [K_INT_MAC_2] = "mac2", + [K_INT_DM_CH_0] = "dmover0", + [K_INT_DM_CH_1] = "dmover1", + [K_INT_DM_CH_2] = "dmover2", + [K_INT_DM_CH_3] = "dmover3", + [K_INT_MBOX_0] = "mbox0", + [K_INT_MBOX_1] = "mbox1", + [K_INT_MBOX_2] = "mbox2", + [K_INT_MBOX_3] = "mbox3", + [K_INT_CYCLE_CP0_INT] = "zbccp0", + [K_INT_CYCLE_CP1_INT] = "zbccp1", + [K_INT_GPIO_0] = "gpio0", + [K_INT_GPIO_1] = "gpio1", + [K_INT_GPIO_2] = "gpio2", + [K_INT_GPIO_3] = "gpio3", + [K_INT_GPIO_4] = "gpio4", + [K_INT_GPIO_5] = "gpio5", + [K_INT_GPIO_6] = "gpio6", + [K_INT_GPIO_7] = "gpio7", + [K_INT_GPIO_8] = "gpio8", + [K_INT_GPIO_9] = "gpio9", + [K_INT_GPIO_10] = "gpio10", + [K_INT_GPIO_11] = "gpio11", + [K_INT_GPIO_12] = "gpio12", + [K_INT_GPIO_13] = "gpio13", + [K_INT_GPIO_14] = "gpio14", + [K_INT_GPIO_15] = "gpio15", + [K_INT_LDT_FATAL] = "ldt fatal", + [K_INT_LDT_NONFATAL] = "ldt nonfatal", + [K_INT_LDT_SMI] = "ldt smi", + [K_INT_LDT_NMI] = "ldt nmi", + [K_INT_LDT_INIT] = "ldt init", + [K_INT_LDT_STARTUP] = "ldt startup", + [K_INT_LDT_EXT] = "ldt ext", + [K_INT_PCI_ERROR] = "pci error", + [K_INT_PCI_INTA] = "pci inta", + [K_INT_PCI_INTB] = "pci intb", + [K_INT_PCI_INTC] = "pci intc", + [K_INT_PCI_INTD] = "pci intd", + [K_INT_SPARE_2] = "spare2", + [K_INT_MAC_0_CH1] = "mac0 ch1", + [K_INT_MAC_1_CH1] = "mac1 ch1", + [K_INT_MAC_2_CH1] = "mac2 ch1", +}; + +#ifdef MULTIPROCESSOR +static void +sb1250_lsw_cpu_init(struct cpu_info *ci) +{ + struct cpu_softc * const cpu = ci->ci_softc; + + WRITE_REG(cpu->sb1cpu_imr_base + R_IMR_INTERRUPT_MASK, cpu->sb1cpu_imr_all); +} + +static int +sb1250_lsw_send_ipi(struct cpu_info *ci, int tag) +{ + struct cpu_softc * const cpu = ci->ci_softc; + const uint64_t mbox_mask = 1LLU << tag; + + if (cpus_running & (1 << cpu_index(ci))) + WRITE_REG(cpu->sb1cpu_imr_base + R_IMR_MAILBOX_SET_CPU, mbox_mask); + + return 0; +} + +static void +sb1250_ipi_intr(void *arg, uint32_t status, vaddr_t pc) +{ + struct cpu_info * const ci = curcpu(); + struct cpu_softc * const cpu = ci->ci_softc; + uint64_t mbox_mask; + + ci->ci_data.cpu_nintr++; + + mbox_mask = READ_REG(cpu->sb1cpu_imr_base + R_IMR_MAILBOX_CPU); + WRITE_REG(cpu->sb1cpu_imr_base + R_IMR_MAILBOX_CLR_CPU, mbox_mask); + + ipi_process(ci, mbox_mask); +} +#endif /* MULTIPROCESSOR */ + +void +sb1250_cpu_init(struct cpu_softc *cpu) +{ + const char * const xname = device_xname(cpu->sb1cpu_dev); + struct evcnt * evcnts = cpu->sb1cpu_intr_evcnts; + + cpu->sb1cpu_imr_base = + MIPS_PHYS_TO_KSEG1(A_IMR_MAPPER(cpu->sb1cpu_ci->ci_cpuid)); +#ifdef MULTIPROCESSOR + cpu->sb1cpu_imr_all = + ~(M_INT_MBOX_0|M_INT_MBOX_1|M_INT_MBOX_2|M_INT_MBOX_3 + |M_INT_WATCHDOG_TIMER_0|M_INT_WATCHDOG_TIMER_1); +#else + cpu->sb1cpu_imr_all = ~(M_INT_WATCHDOG_TIMER_0|M_INT_WATCHDOG_TIMER_1); +#endif + + for (u_int i = 0; i < K_INT_SOURCES; i++, evcnts++) { + WRITE_REG(cpu->sb1cpu_imr_base + SB1250_I_MAP(i), K_INT_MAP_I0); + evcnt_attach_dynamic(evcnts, EVCNT_TYPE_INTR, NULL, + xname, sb1250_intr_names[i]); + } +#if 0 + WRITE_REG(cpu->sb1cpu_imr_base + SB1250_I_MAP(K_INT_WATCHDOG_TIMER_0), K_INT_MAP_NMI); + WRITE_REG(cpu->sb1cpu_imr_base + SB1250_I_MAP(K_INT_WATCHDOG_TIMER_1), K_INT_MAP_NMI); +#endif + + WRITE_REG(cpu->sb1cpu_imr_base + R_IMR_INTERRUPT_MASK, cpu->sb1cpu_imr_all); +#ifdef MULTIPROCESSOR + if (sb1250_ihands[K_INT_MBOX_0].ih_fun == NULL) { + /* + * For now, deliver all IPIs at IPL_SCHED. Eventually + * some will be at IPL_VM. + */ + for (int irq = K_INT_MBOX_0; irq <= K_INT_MBOX_3; irq++) + sb1250_intr_establish(irq, IPL_SCHED, + sb1250_ipi_intr, NULL); + } +#endif /* MULTIPROCESSOR */ +} + +void +sb1250_ipl_map_init(void) +{ + ipl_sr_map = sb1250_ipl_sr_map; +} + +void +sb1250_icu_init(void) +{ + const uint64_t imr_all = 0xffffffffffffffffULL; + + KASSERT(memcmp((const void *)&ipl_sr_map, (const void *)&sb1250_ipl_sr_map, sizeof(ipl_sr_map)) == 0); + + /* zero out the list of used interrupts/lines */ + memset(ints_for_ipl, 0, sizeof ints_for_ipl); + memset(sb1250_ihands, 0, sizeof sb1250_ihands); + + systemsw.s_cpu_intr = sb1250_cpu_intr; + systemsw.s_intr_establish = sb1250_intr_establish; + +#ifdef MULTIPROCESSOR + /* + * Bits 27:24 (11:8 of G_SYS_PART) encode the number of CPUs present. + */ + u_int sys_part = G_SYS_PART(READ_REG(MIPS_PHYS_TO_KSEG1(A_SCD_SYSTEM_REVISION))); + const u_int cpus = (sys_part >> 8) & 0xf; + + /* + * Allocate an evcnt structure for every possible interrupt on + * every possible CPU. + */ + vaddr_t imr = MIPS_PHYS_TO_KSEG1(A_IMR_CPU0_BASE + R_IMR_INTERRUPT_MASK); + for (u_int i = 1; imr += IMR_REGISTER_SPACING, i < cpus; i++) { + WRITE_REG(imr, imr_all); + } +#endif /* MULTIPROCESSOR */ + WRITE_REG(MIPS_PHYS_TO_KSEG1(A_IMR_CPU0_BASE + R_IMR_INTERRUPT_MASK), + imr_all); + +#ifdef MULTIPROCESSOR + mips_locoresw.lsw_send_ipi = sb1250_lsw_send_ipi; + mips_locoresw.lsw_cpu_init = sb1250_lsw_cpu_init; +#endif /* MULTIPROCESSOR */ +} + +static void +sb1250_cpu_intr(int ppl, vaddr_t pc, uint32_t status) +{ + struct cpu_info * const ci = curcpu(); + struct cpu_softc * const cpu = ci->ci_softc; + const vaddr_t imr_base = cpu->sb1cpu_imr_base; + struct evcnt * const evcnts = cpu->sb1cpu_intr_evcnts; + uint32_t pending; + int ipl; + + ci->ci_data.cpu_nintr++; + + while (ppl < (ipl = splintr(&pending))) { + splx(ipl); + + /* XXX do something if 5? */ + if (pending & MIPS_INT_MASK_5) { + uint32_t cycles = mips3_cp0_count_read(); + mips3_cp0_compare_write(cycles - 1); + /* just leave the bugger disabled */ + } + + uint64_t sstatus = ints_for_ipl[ipl]; + sstatus &= READ_REG(imr_base + R_IMR_INTERRUPT_SOURCE_STATUS); + while (sstatus != 0) { +#ifndef __mips_o32 + u_int n; + __asm("dclz %0,%1" : "=r"(n) : "r"(sstatus)); +#else + u_int n = (sstatus >> 32) + ? 0 + __builtin_clz(sstatus >> 32) + : 32 + __builtin_clz((uint32_t)sstatus); +#endif + u_int j = 63 - n; + KASSERT(sstatus & (1ULL << j)); + sstatus ^= (1ULL << j); + struct sb1250_ihand *ihp = &sb1250_ihands[j]; + KASSERT(ihp->ih_fun); + (*ihp->ih_fun)(ihp->ih_arg, status, pc); + evcnts[j].ev_count++; + } + (void) splhigh(); + } +} + +static void * +sb1250_intr_establish(u_int num, u_int ipl, + void (*fun)(void *, uint32_t, vaddr_t), void *arg) +{ + struct cpu_softc * const cpu = curcpu()->ci_softc; + struct sb1250_ihand * const ih = &sb1250_ihands[num]; + const int s = splhigh(); + + if (num >= K_INT_SOURCES) + panic("%s: invalid interrupt number (0x%x)", __func__, num); + if (ipl >= _IPL_N || ipl < IPL_VM) + panic("%s: invalid ipl %d", __func__, ipl); + if (ih->ih_fun != NULL) + panic("%s: cannot share sb1250 interrupts", __func__); + + ints_for_ipl[ipl] |= (1ULL << num); + cpu->sb1cpu_imr_all &= ~(1ULL << num); + + ih->ih_fun = fun; + ih->ih_arg = arg; + ih->ih_ipl = ipl; + + if (num <= K_INT_WATCHDOG_TIMER_1) + WRITE_REG(cpu->sb1cpu_imr_base + SB1250_I_MAP(num), K_INT_MAP_I4); + else if (ipl > IPL_VM) + WRITE_REG(cpu->sb1cpu_imr_base + SB1250_I_MAP(num), K_INT_MAP_I1); + + WRITE_REG(cpu->sb1cpu_imr_base + R_IMR_INTERRUPT_MASK, cpu->sb1cpu_imr_all); + + splx(s); + + return ih; +} diff --git a/sys/arch/evbmips/sbmips/swarm.h b/sys/arch/evbmips/sbmips/swarm.h new file mode 100644 index 000000000000..e19e741ba1ef --- /dev/null +++ b/sys/arch/evbmips/sbmips/swarm.h @@ -0,0 +1,79 @@ +/* $NetBSD: swarm.h,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin Exp $ */ + +/* + * I/O Address assignments for the CSWARM board + * + * Summary of address map: + * + * Address Size CSel Description + * --------------- ---- ------ -------------------------------- + * 0x1FC00000 2MB CS0 Boot ROM + * 0x1F800000 2MB CS1 Alternate boot ROM + * CS2 Unused + * 0x100A0000 64KB CS3 LED display + * 0x100B0000 64KB CS4 IDE Disk + * CS5 Unused + * 0x11000000 64MB CS6 PCMCIA + * CS7 Unused + * + * GPIO assignments + * + * GPIO# Direction Description + * ------- --------- ------------------------------------------ + * GPIO0 Output Debug LED + * GPIO1 Output Sturgeon NMI + * GPIO2 Input PHY Interrupt (interrupt) + * GPIO3 Input Nonmaskable Interrupt (interrupt) + * GPIO4 Input IDE Disk Interrupt (interrupt) + * GPIO5 Input Temperature Sensor Alert (interrupt) + * GPIO6 N/A PCMCIA interface + * GPIO7 N/A PCMCIA interface + * GPIO8 N/A PCMCIA interface + * GPIO9 N/A PCMCIA interface + * GPIO10 N/A PCMCIA interface + * GPIO11 N/A PCMCIA interface + * GPIO12 N/A PCMCIA interface + * GPIO13 N/A PCMCIA interface + * GPIO14 N/A PCMCIA interface + * GPIO15 N/A PCMCIA interface +*/ + + +/* GPIO pins */ +#define GPIO_DEBUG_LED 0 +#define GPIO_STURGEON_NMI 1 +#define GPIO_PHY_INTERRUPT 2 +#define GPIO_NONMASKABLE_INT 3 +#define GPIO_IDE_INTERRUPT 4 +#define GPIO_TEMP_SENSOR_INT 5 + +/* device addresses */ +#define SWARM_LEDS_PHYS 0x100a0000 +#define SWARM_IDE_PHYS 0x100b0000 +#define SWARM_PCMCIA_PHYS 0x11000000 + +/* SMBus devices */ +#define TEMPSENSOR_SMBUS_CHAN 0 +#define TEMPSENSOR_SMBUS_DEV 0x2A + +#define DRAM_SMBUS_CHAN 0 +#define DRAM_SMBUS_DEV 0x54 + +#define BIGEEPROM_SMBUS_CHAN 0 +#define BIGEEPROM_SMBUS_DEV 0x50 + +#define BIGEEPROM_SMBUS_CHAN_1 1 /* rev 2.0 swarm only */ +#define BIGEEPROM_SMBUS_DEV_1 0x51 + +#define CFG_DRAM_SMBUS_CHAN 0 +#define CFG_DRAM_SMBUS_BASE 0x54 /* starting SMBus device base */ + +#define X1241_SMBUS_CHAN 1 /* rev 1.0 swarm only, fixed slave address */ + +#define M41T81_SMBUS_CHAN 1 /* rev 2.0 swarm only (or PCF8563), fixed slave address */ + +#define PCF8563_SMBUS_CHAN 1 /* rev 2.0 swarm only (or M41T81) */ +#define PCF8563_SMBUS_DEV 0x50 + +#define MAX1617A_SMBUS_CHAN 0 /* or MAX6654 on newer board, reg compatible */ +#define MAX1617A_SMBUS_DEV 0x2a diff --git a/sys/arch/evbmips/sbmips/systemsw.c b/sys/arch/evbmips/sbmips/systemsw.c new file mode 100644 index 000000000000..4047525cad27 --- /dev/null +++ b/sys/arch/evbmips/sbmips/systemsw.c @@ -0,0 +1,132 @@ +/* $NetBSD: systemsw.c,v 1.2.4.2 2017/08/30 15:45:04 martin 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. The "Broadcom Corporation" name may not 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: systemsw.c,v 1.2.4.2 2017/08/30 15:45:04 martin Exp $"); + +#include +#include +#include +#include +#include + +#include +#include + +#include + + +/* trivial functions for function switch */ +static void clock_init_triv(void *); +static void cpu_intr_triv(int, vaddr_t, uint32_t); + +/* system function switch */ +struct systemsw systemsw = { + cpu_intr_triv, + + NULL, /* clock intr arg */ + clock_init_triv, + + NULL, /* statclock arg */ + NULL, /* s_statclock_init: dflt no-op */ + NULL, /* s_statclock_setrate: dflt no-op */ + + NULL, /* intr_establish */ +}; + +bool +system_set_clockfns(void *arg, void (*init)(void *)) +{ + + if (systemsw.s_clock_init != clock_init_triv) + return true; + systemsw.s_clock_arg = arg; + systemsw.s_clock_init = init; + return false; +} + +static void +cpu_intr_triv(int ppl, vaddr_t pc, uint32_t status) +{ + + panic("cpu_intr_triv"); +} + +void +cpu_intr(int ppl, vaddr_t pc, uint32_t status) +{ + + (*systemsw.s_cpu_intr)(ppl, pc, status); +} + +static void +clock_init_triv(void *arg) +{ + + panic("clock_init_triv"); +} + +void +cpu_initclocks(void) +{ + + (*systemsw.s_clock_init)(systemsw.s_clock_arg); + + if (systemsw.s_statclock_init != NULL) + (*systemsw.s_statclock_init)(systemsw.s_statclock_arg); + + /* + * ``Disable'' the compare interrupt by setting it to its largest + * value. Each hard clock interrupt we'll reset the CP0 compare + * register to just bind the CP0 clock register. + */ + mips3_cp0_compare_write(~0u); + mips3_cp0_count_write(0); + + mips3_init_tc(); + + /* + * Now we can enable all interrupts including hardclock(9). + */ + spl0(); +} + +void +setstatclockrate(int hzrate) +{ + + if (systemsw.s_statclock_setrate != NULL) + (*systemsw.s_statclock_setrate)(systemsw.s_statclock_arg, + hzrate); +} diff --git a/sys/arch/evbmips/sbmips/systemsw.h b/sys/arch/evbmips/sbmips/systemsw.h new file mode 100644 index 000000000000..4de1eb4b751b --- /dev/null +++ b/sys/arch/evbmips/sbmips/systemsw.h @@ -0,0 +1,65 @@ +/* $NetBSD: systemsw.h,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin 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. The "Broadcom Corporation" name may not 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)(int, vaddr_t, uint32_t); + + void *s_clock_arg; + void (*s_clock_init)(void *); + + void *s_statclock_arg; + void (*s_statclock_init)(void *); + void (*s_statclock_setrate)(void *, int); + + void *(*s_intr_establish)(u_int, u_int, + void (*fun)(void *, uint32_t, vaddr_t), void *); +}; +extern struct systemsw systemsw; + +bool system_set_clockfns(void *, void (*)(void *)); + +void sb1250_icu_init(void); +struct cpu_softc; +void sb1250_cpu_init(struct cpu_softc *); +void sb1250_ipl_map_init(void); + +#define cpu_intr_establish(n,s,f,a) ((*systemsw.s_intr_establish)(n,s,f,a)) + +#endif /* _SBMIPS_SYSTEMSW_H_ */ diff --git a/sys/arch/evbmips/sbmips/zbbus.c b/sys/arch/evbmips/sbmips/zbbus.c new file mode 100644 index 000000000000..92b461e34737 --- /dev/null +++ b/sys/arch/evbmips/sbmips/zbbus.c @@ -0,0 +1,138 @@ +/* $NetBSD: zbbus.c,v 1.2.4.2 2017/08/30 15:45:04 martin 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. The "Broadcom Corporation" name may not 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: zbbus.c,v 1.2.4.2 2017/08/30 15:45:04 martin Exp $"); + +#include +#include +#include + +#include + +#include "locators.h" + +static int zbbus_match(device_t, cfdata_t, void *); +static void zbbus_attach(device_t, device_t, void *); + +CFATTACH_DECL_NEW(zbbus, 0, + zbbus_match, zbbus_attach, NULL, NULL); + +static int zbbus_print(void *, const char *); +static int zbbus_submatch(device_t, cfdata_t, const int *, 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(device_t parent, cfdata_t match, void *aux) +{ + + if (zbbus_attached) + return (0); + return 1; +} + +static void +zbbus_attach(device_t parent, device_t 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_loc(self, "zbbus", NULL, &za, zbbus_print, + zbbus_submatch); + } + + return; +} + +int +zbbus_print(void *aux, const char *pnp) +{ + struct zbbus_attach_args *zap = aux; + + if (pnp) + aprint_normal("%s at %s", + zbbus_entity_type_name(zap->za_locs.za_type), pnp); + aprint_normal(" busid %d", zap->za_locs.za_busid); + return (UNCONF); +} + +static int +zbbus_submatch(device_t parent, cfdata_t cf, const int *ldesc, 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 (config_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"); +} diff --git a/sys/arch/evbmips/stand/Makefile b/sys/arch/evbmips/stand/Makefile new file mode 100644 index 000000000000..5bf945e9f0d0 --- /dev/null +++ b/sys/arch/evbmips/stand/Makefile @@ -0,0 +1,5 @@ +# $NetBSD: Makefile,v 1.1.4.2 2017/08/30 15:45:04 martin Exp $ + +SUBDIR= sbmips + +.include diff --git a/sys/arch/evbmips/stand/sbmips/Makefile b/sys/arch/evbmips/stand/sbmips/Makefile new file mode 100644 index 000000000000..203499018506 --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/Makefile @@ -0,0 +1,7 @@ +# $NetBSD: Makefile,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin Exp $ + +SUBDIR= bootxx_cd9660 bootxx_ffs bootxx_lfs netboot +SUBDIR+= boot netboot +#SUBDIR+= installboot + +.include diff --git a/sys/arch/evbmips/stand/sbmips/Makefile.bootprogs b/sys/arch/evbmips/stand/sbmips/Makefile.bootprogs new file mode 100644 index 000000000000..2af76d2fd72e --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/Makefile.bootprogs @@ -0,0 +1,138 @@ +# $NetBSD: Makefile.bootprogs,v 1.3.4.2 2017/08/30 15:45:04 martin Exp $ + +.include +.include + +S= ${.CURDIR}/../../../.. + +.PATH: ${.CURDIR}/../common + +STRIPFLAG= +BINMODE= 444 + +# XXX SHOULD NOT NEED TO DEFINE THESE! +LIBCRT0= +LIBCRTI= +LIBC= +LIBCRTBEGIN= +LIBCRTEND= + +STRIP?= strip + +CHECKSIZE_CMD= SIZE=${SIZE} ${HOST_SH} ${.CURDIR}/../common/checksize.sh + +AFLAGS+= -DASSEMBLER -D_LOCORE -mno-abicalls -mips64 +# -I${.CURDIR}/../.. done by Makefile.inc +CPPFLAGS+= -nostdinc -I${.OBJDIR} -D_STANDALONE -I${S} +CFLAGS= -Os -g -ffreestanding -mno-abicalls -msoft-float -G 0 +CFLAGS+= -mips64 +CFLAGS+= -Werror ${CWARNFLAGS} + +NETBSD_VERS!=${HOST_SH} ${.CURDIR}/../../../../conf/osrelease.sh +CPPFLAGS+= -DNETBSD_VERS='"${NETBSD_VERS}"' + +CWARNFLAGS+= -Wno-main +CWARNFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith +CWARNFLAGS+= -Wno-pointer-sign + +VERSIONFLAGS+=-n +.include "${S}/conf/newvers_stand.mk" + +# +# Refer to CFE documentation for a description of these regions. +# + +REGION1_START= 0x20000000 # "Region 1 start" +REGION1_SIZE!= expr 256 \* 1024 # 256k + +LDSCRIPT= ${.CURDIR}/../common/boot.ldscript + +# our memory lauout: + +# 'unified' boot loaders (e.g. netboot) can consume all of region +# 1 for their text+data, or text+data+bss. + +UNIFIED_LOAD_ADDRESS= ${REGION1_START} +UNIFIED_MAX_LOAD!= expr ${REGION1_SIZE} +UNIFIED_MAX_TOTAL!= expr ${REGION1_SIZE} + +#UNIFIED_HEAP_START= right after secondary bss +UNIFIED_HEAP_LIMIT= (${REGION1_START} + ${REGION1_SIZE}) + +# two-stage boot loaders must share region 1. The first stage +# loads into the lowest portion, and uses the higest portion +# for its heap. The second stage loads in between the primary image +# and the heap, and can reuse the memory after it (i.e. the primary's +# heap) for its own heap. + +PRIMARY_LOAD_ADDRESS= ${REGION1_START} +#PRIMARY_MAX_LOAD= booter dependent, no more than ${PRIMARY_MAX_TOTAL} +PRIMARY_MAX_TOTAL!= expr 16 \* 1024 + +# XXX SECONDARY_LOAD_ADDRESS should be +# XXX (${PRIMARY_LOAD_ADDRESS} + ${PRIMARY_MAX_TOTAL}) bt there's no easy +# XXX way to do that calculation and 'ld' wants a single number. +SECONDARY_LOAD_ADDRESS= 0x20004000 # XXX +SECONDARY_MAX_LOAD!= expr 112 \* 1024 +SECONDARY_MAX_TOTAL!= expr ${REGION1_SIZE} - ${PRIMARY_MAX_TOTAL} + +PRIMARY_HEAP_START= (${SECONDARY_LOAD_ADDRESS} + ${SECONDARY_MAX_LOAD}) +PRIMARY_HEAP_LIMIT= (${REGION1_START} + ${REGION1_SIZE}) + +#SECONDARY_HEAP_START= right after secondary bss +SECONDARY_HEAP_LIMIT= (${REGION1_START} + ${REGION1_SIZE}) + +# standalone programs are like kernels. They load at +# 0xfffffc0000300000 and can use the rest of memory. + +STANDPROG_LOAD_ADDRESS= 0xfffffc0000300000 + + +FILE_FORMAT_CPPFLAGS= -DBOOT_ELF + +UNIFIED_CPPFLAGS= -DUNIFIED_BOOTBLOCK \ + -DHEAP_LIMIT="${UNIFIED_HEAP_LIMIT}" \ + ${FILE_FORMAT_CPPFLAGS} + +PRIMARY_CPPFLAGS= -DPRIMARY_BOOTBLOCK \ + -DSECONDARY_LOAD_ADDRESS="${SECONDARY_LOAD_ADDRESS}" \ + -DSECONDARY_MAX_LOAD="${SECONDARY_MAX_LOAD}" \ + -DHEAP_LIMIT="${PRIMARY_HEAP_LIMIT}" \ + -DHEAP_START="${PRIMARY_HEAP_START}" + +SECONDARY_CPPFLAGS= -DSECONDARY_BOOTBLOCK \ + -DHEAP_LIMIT="${SECONDARY_HEAP_LIMIT}" \ + ${FILE_FORMAT_CPPFLAGS} + +STANDPROG_CPPFLAGS= -DSTANDALONE_PROGRAM + +.include + +### find out what to use for libkern +KERN_AS= library +.include "${S}/lib/libkern/Makefile.inc" +LIBKERN= ${KERNLIB} + +### find out what to use for libz +Z_AS= library +.include "${S}/lib/libz/Makefile.inc" +LIBZ= ${ZLIB} + +### find out what to use for libsa +SA_AS= library +SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes" +.include "${S}/lib/libsa/Makefile.inc" +LIBSA= ${SALIB} + +/usr/lib/crt0.o: + true + +/usr/lib/crtbegin.o: + true + +/usr/lib/crtend.o: + true + +cleandir: .WAIT cleandirlocal +cleandirlocal: + -rm -rf lib diff --git a/sys/arch/evbmips/stand/sbmips/Makefile.bootxx b/sys/arch/evbmips/stand/sbmips/Makefile.bootxx new file mode 100644 index 000000000000..a6195a9d6e2b --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/Makefile.bootxx @@ -0,0 +1,37 @@ +# $NetBSD: Makefile.bootxx,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin Exp $ + +SRCS = start.S bootxx.c booted_dev.c blkdev.c cfe.c cfe_api.c \ + putstr.c panic_putstr.c + +BOOT_RELOC = ${PRIMARY_LOAD_ADDRESS} + +CPPFLAGS += ${PRIMARY_CPPFLAGS} \ + -DLIBSA_FS_SINGLECOMPONENT -DLIBSA_NO_FS_WRITE \ + -DLIBSA_NO_FS_CLOSE -DLIBSA_NO_FS_SEEK \ + -DLIBSA_SINGLE_DEVICE=blkdev \ + -D"blkdevioctl(x,y,z)=EINVAL" -D"blkdevclose(f)=0" \ + -DLIBSA_NO_TWIDDLE \ + -DLIBSA_NO_FD_CHECKING \ + -DLIBSA_NO_RAW_ACCESS \ + -DLIBSA_NO_DISKLABEL_MSGS + +CLEANFILES+= ${PROG}.sym + +${PROG}: ${PROG}.sym + @echo creating ${PROG} from ${PROG}.sym... + @${OBJCOPY} --output-target=binary -R .reginfo -R .MIPS.abiflags \ + ${PROG}.sym ${PROG} + @chmod 644 ${PROG} + @ls -l ${PROG} + @${CHECKSIZE_CMD} ${PROG}.sym ${PROG} ${PRIMARY_MAX_LOAD} \ + ${PRIMARY_MAX_TOTAL} || (rm -f ${PROG} ; false) + +SAMISCMAKEFLAGS= SA_INCLUDE_NET=no SA_USE_CREAD=no +.include "../Makefile.bootprogs" + +${PROG}.sym: ${OBJS} ${LIBSA} ${LIBKERN} + ${_MKTARGET_LINK} + ${LD} -Ttext ${BOOT_RELOC} -N -e start -o ${PROG}.sym \ + ${OBJS} ${LIBSA} ${LIBKERN} + @chmod 644 ${PROG}.sym + @${SIZE} ${PROG}.sym diff --git a/sys/arch/evbmips/stand/sbmips/Makefile.inc b/sys/arch/evbmips/stand/sbmips/Makefile.inc new file mode 100644 index 000000000000..b2fe00ee31a5 --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/Makefile.inc @@ -0,0 +1,11 @@ +# $NetBSD: Makefile.inc,v 1.3.4.2 2017/08/30 15:45:04 martin Exp $ + +.include + +BINDIR?= /usr/mdec +WARNS?= 1 + +MKMAN= no + +CPPFLAGS+= -I${.CURDIR}/../.. +LDSTATIC?= -static diff --git a/sys/arch/evbmips/stand/sbmips/boot/Makefile b/sys/arch/evbmips/stand/sbmips/boot/Makefile new file mode 100644 index 000000000000..a2bc6916edbf --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/boot/Makefile @@ -0,0 +1,32 @@ +# $NetBSD: Makefile,v 1.1.1.1.4.2 2017/08/30 15:45:05 martin Exp $ + +PROG = boot + +SRCS = start.S boot.c blkdev.c cfe.c cfe_api.c +SRCS+= filesystem.c booted_dev.c + +BOOT_RELOC = ${SECONDARY_LOAD_ADDRESS} + +CPPFLAGS += ${SECONDARY_CPPFLAGS} \ + -DBOOT_TYPE_NAME='"Secondary"' \ + -DLIBSA_SINGLE_DEVICE=blkdev \ + -D"blkdevioctl(x,y,z)=EINVAL" + +CLEANFILES+= ${PROG}.sym + +${PROG}: ${PROG}.sym + @echo creating ${PROG} from ${PROG}.sym... + @${OBJCOPY} --output-target=binary -R .reginfo ${PROG}.sym ${PROG} + @chmod 644 ${PROG} + @ls -l ${PROG} + @${CHECKSIZE_CMD} ${PROG}.sym ${PROG} ${SECONDARY_MAX_LOAD} \ + ${SECONDARY_MAX_TOTAL} || (rm -f ${PROG} ; false) + +SAMISCMAKEFLAGS= SA_INCLUDE_NET=no SA_USE_CREAD=yes +.include "../Makefile.bootprogs" + +${PROG}.sym: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${LDSCRIPT} + ${_MKTARGET_LINK} + ${LD} -T ${LDSCRIPT} -N -e start -o ${PROG}.sym \ + ${OBJS} ${LIBSA} ${LIBZ} ${LIBSA} ${LIBKERN} + ${SIZE} ${PROG}.sym diff --git a/sys/arch/evbmips/stand/sbmips/boot/filesystem.c b/sys/arch/evbmips/stand/sbmips/boot/filesystem.c new file mode 100644 index 000000000000..3b5d844becd0 --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/boot/filesystem.c @@ -0,0 +1,51 @@ +/* $NetBSD: filesystem.c,v 1.1.1.1.4.2 2017/08/30 15:45:05 martin Exp $ */ + +/* + * Copyright (c) 1993 Philip A. Nelson. + * 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 Philip A. Nelson. + * 4. The name of Philip A. Nelson may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY PHILIP NELSON ``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 PHILIP NELSON 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. + * + * filesystem.c + */ + +#include +#include +#include +#include +#include + +struct fs_ops file_system[] = { + FS_OPS(ustarfs), /* this can work from tape, so put it first */ + FS_OPS(ufs), + FS_OPS(cd9660), + FS_OPS(lfsv1), + FS_OPS(lfsv2), +}; + +int nfsys = sizeof(file_system)/sizeof(struct fs_ops); + diff --git a/sys/arch/evbmips/stand/sbmips/boot/version b/sys/arch/evbmips/stand/sbmips/boot/version new file mode 100644 index 000000000000..02e1a370f40b --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/boot/version @@ -0,0 +1,7 @@ +$NetBSD: version,v 1.1.1.1.4.2 2017/08/30 15:45:05 martin Exp $ + +NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this +file is important - make sure the entries are appended on end, last item +is taken as the current. + +1.1: Initial version diff --git a/sys/arch/evbmips/stand/sbmips/bootxx_cd9660/Makefile b/sys/arch/evbmips/stand/sbmips/bootxx_cd9660/Makefile new file mode 100644 index 000000000000..7a6613d3d09c --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/bootxx_cd9660/Makefile @@ -0,0 +1,13 @@ +# $NetBSD: Makefile,v 1.1.1.1.4.2 2017/08/30 15:45:05 martin Exp $ + +PROG = bootxx_cd9660 +CPPFLAGS += -DLIBSA_SINGLE_FILESYSTEM=cd9660 \ + -DBOOTXX_FS_NAME='"ISO 9660"' \ + -DNO_GETCHAR + +# not yet desired: -DBOOTXX_FS_TYPE=FS_ISO9660 + +# XXX the following could probably be increased +PRIMARY_MAX_LOAD!= expr 8192 - 512 + +.include "../Makefile.bootxx" diff --git a/sys/arch/evbmips/stand/sbmips/bootxx_ffs/Makefile b/sys/arch/evbmips/stand/sbmips/bootxx_ffs/Makefile new file mode 100644 index 000000000000..ea437a5083b1 --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/bootxx_ffs/Makefile @@ -0,0 +1,14 @@ +# $NetBSD: Makefile,v 1.1.1.1.4.2 2017/08/30 15:45:05 martin Exp $ + +PROG = bootxx_ffs +CPPFLAGS += -DLIBSA_SINGLE_FILESYSTEM=ufs \ + -DBOOTXX_FS_NAME='"FFS"' \ + -DNO_GETCHAR +# Use small daddr_t to avoid code bloat +CPPFLAGS+= -D__daddr_t=int32_t + +# not yet desired: -DBOOTXX_FS_TYPE=FS_BSDFFS + +PRIMARY_MAX_LOAD!= expr 8192 - 512 + +.include "../Makefile.bootxx" diff --git a/sys/arch/evbmips/stand/sbmips/bootxx_lfs/Makefile b/sys/arch/evbmips/stand/sbmips/bootxx_lfs/Makefile new file mode 100644 index 000000000000..b368ee9c4540 --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/bootxx_lfs/Makefile @@ -0,0 +1,14 @@ +# $NetBSD: Makefile,v 1.1.1.1.4.2 2017/08/30 15:45:05 martin Exp $ + +PROG = bootxx_lfs +CPPFLAGS += -DLIBSA_SINGLE_FILESYSTEM=lfsv2 \ + -DBOOTXX_FS_NAME='"LFS"' \ + -DNO_GETCHAR +# Use small daddr_t to avoid code bloat +CPPFLAGS+= -D__daddr_t=int32_t + +# not yet desired: -DBOOTXX_FS_TYPE=FS_BSDLFS + +PRIMARY_MAX_LOAD!= expr 8192 - 512 + +.include "../Makefile.bootxx" diff --git a/sys/arch/evbmips/stand/sbmips/common/bbinfo.h b/sys/arch/evbmips/stand/sbmips/common/bbinfo.h new file mode 100644 index 000000000000..1fe64816b32d --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/common/bbinfo.h @@ -0,0 +1,54 @@ +/* $NetBSD: bbinfo.h,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin Exp $ */ + +/* + * Copyright (c) 1995, 1996 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +struct bbinfoloc { + u_int64_t magic1; + u_int64_t start; + u_int64_t end; + u_int64_t pad1[4]; + u_int64_t magic2; +}; + +struct bbinfo { + int32_t cksum; + int32_t nblocks; + int32_t bsize; + u_int32_t pad1[8]; + int32_t blocks[1]; +}; + +struct netbbinfo { + u_int64_t magic1; + u_int8_t set; + u_int8_t ether_addr[6]; + u_int8_t force; + u_int64_t pad1[4]; + u_int64_t cksum; + u_int64_t magic2; +}; diff --git a/sys/arch/evbmips/stand/sbmips/common/blkdev.c b/sys/arch/evbmips/stand/sbmips/common/blkdev.c new file mode 100644 index 000000000000..d026dcac062d --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/common/blkdev.c @@ -0,0 +1,183 @@ +/* $NetBSD: blkdev.c,v 1.2.4.2 2017/08/30 15:45:04 martin Exp $ */ + +/* + * Copyright (c) 1999 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 + * for the NetBSD Project. + * 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. + */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Van Jacobson of Lawrence Berkeley Laboratory 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. 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. + * + * @(#)rz.c 8.1 (Berkeley) 6/10/93 + */ + +#include +#include + +#include +#include + +#include "stand/common/cfe_api.h" + +#include "stand/common/common.h" +#include "blkdev.h" + +/* + * If BOOTXX_FS_TYPE is defined, we'll try to find and use the first + * partition with that type mentioned in the disklabel, else default to + * using block 0. + * + * The old boot blocks used to look for a file system starting at block + * 0. It's not immediately obvious that change here is necessary or good, + * so for now we don't bother looking for the specific type. + */ +#undef BOOTXX_FS_TYPE + +int blkdev_is_open; +u_int32_t blkdev_part_offset; + +/* + * Since we have only one device, and want to squeeze space, we just + * short-circuit devopen() to do the disk open as well. + * + * Devopen is supposed to decode the string 'fname', open the device, + * and make 'file' point to the remaining file name. Since we don't + * do any device munging, we can just set *file to fname. + */ +int +devopen(struct open_file *f, const char *fname, char **file) + /* file: out */ +{ +#if defined(BOOTXX_FS_TYPE) + int i; + size_t cnt; + char *msg, buf[DEV_BSIZE]; + struct disklabel l; +#endif /* defined(BOOTXX_FS_TYPE) */ + + if (blkdev_is_open) { + return (EBUSY); + } + + *file = (char *)fname; + +#if 0 + f->f_devdata = NULL; /* no point */ +#endif + + /* Try to read disk label and partition table information. */ + blkdev_part_offset = 0; +#if defined(BOOTXX_FS_TYPE) + + i = diskstrategy(NULL, F_READ, + (daddr_t)LABELSECTOR, DEV_BSIZE, buf, &cnt); + if (i || cnt != DEV_BSIZE) { + return (ENXIO); + } + msg = getdisklabel(buf, &l); + if (msg == NULL) { + /* + * there's a label. find the first partition of the + * type we want and use its offset. if none are + * found, we just use offset 0. + */ + for (i = 0; i < l.d_npartitions; i++) { + if (l.d_partitions[i].p_fstype == BOOTXX_FS_TYPE) { + blkdev_part_offset = l.d_partitions[i].p_offset; + break; + } + } + } else { + /* just use offset 0; it's already set that way */ + } +#endif /* defined(BOOTXX_FS_TYPE) */ + + blkdev_is_open = 1; + return (0); +} + +int +blkdevstrategy(void *devdata, int rw, daddr_t bn, size_t reqcnt, void *addrvoid, size_t *cnt) + /* cnt: out: number of bytes transfered */ +{ + unsigned char *addr = addrvoid; + int res; + +#if !defined(LIBSA_NO_TWIDDLE) + twiddle(); +#endif + + /* Partial-block transfers not handled. */ + if (reqcnt & (DEV_BSIZE - 1)) { + *cnt = 0; + return (EINVAL); + } + res = cfe_readblk(booted_dev_fd,(bn+blkdev_part_offset)*DEV_BSIZE,addr,reqcnt); + if (res < 0) return EIO; + + *cnt = res; + return (0); +} + +#if !defined(LIBSA_NO_FS_CLOSE) +int +blkdevclose(struct open_file *f) +{ + + blkdev_is_open = 0; + return (0); +} +#endif /* !defined(LIBSA_NO_FS_CLOSE) */ diff --git a/sys/arch/evbmips/stand/sbmips/common/blkdev.h b/sys/arch/evbmips/stand/sbmips/common/blkdev.h new file mode 100644 index 000000000000..25e8e1991902 --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/common/blkdev.h @@ -0,0 +1,10 @@ +/* $NetBSD: blkdev.h,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin Exp $ */ + +#if 0 /* folded into devopen */ +int blkdevopen(struct open_file *, ...); +#endif + +int blkdevstrategy(void *, int, daddr_t, size_t, void *, size_t *); +#if !defined(LIBSA_NO_FS_CLOSE) +int blkdevclose(struct open_file *); +#endif /* defined(LIBSA_NO_FS_CLOSE) */ diff --git a/sys/arch/evbmips/stand/sbmips/common/boot.c b/sys/arch/evbmips/stand/sbmips/common/boot.c new file mode 100644 index 000000000000..9273d47ad8ae --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/common/boot.c @@ -0,0 +1,170 @@ +/* $NetBSD: boot.c,v 1.2.4.2 2017/08/30 15:45:04 martin 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. 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. + * + * @(#)boot.c 8.1 (Berkeley) 6/10/93 + */ + +#include +#include +#include + +#include +#include +#include + +#include "stand/common/common.h" +#include "stand/common/cfe_api.h" + +#include + +#if !defined(UNIFIED_BOOTBLOCK) && !defined(SECONDARY_BOOTBLOCK) +#error not UNIFIED_BOOTBLOCK and not SECONDARY_BOOTBLOCK +#endif + +char boot_file[128]; +char boot_flags[128]; +extern int debug; + +struct bootinfo_v1 bootinfo; + +paddr_t ffp_save, ptbr_save; + +int debug; + +char *kernelnames[] = { + "netbsd", "netbsd.gz", + "netbsd.bak", "netbsd.bak.gz", + "netbsd.old", "netbsd.old.gz", + "onetbsd", "onetbsd.gz", + "netbsd.mips", "netbsd.mips.gz", + NULL +}; + +int +#if defined(UNIFIED_BOOTBLOCK) +main(long fwhandle,long evector,long fwentry,long fwseal) +#else /* defined(SECONDARY_BOOTBLOCK) */ +main(long fwhandle,long fd,long fwentry) +#endif +{ + char *name, **namep; + u_long marks[MARK_MAX]; + u_int32_t entry; + int win; + + /* Init prom callback vector. */ + cfe_init(fwhandle,fwentry); + + /* Init the console device */ + init_console(); + + /* print a banner */ + printf("\n"); + printf("NetBSD/sbmips " NETBSD_VERS " " BOOT_TYPE_NAME " Bootstrap, Revision %s\n", + bootprog_rev); + printf("\n"); + + /* set up the booted device descriptor */ +#if defined(UNIFIED_BOOTBLOCK) + if (!booted_dev_open()) { + printf("Boot device (%s) open failed.\n", + booted_dev_name[0] ? booted_dev_name : "unknown"); + goto fail; + } +#else /* defined(SECONDARY_BOOTBLOCK) */ + booted_dev_setfd(fd); +#endif + + printf("\n"); + + boot_file[0] = 0; + cfe_getenv("KERNEL_FILE",boot_file,sizeof(boot_file)); + + boot_flags[0] = 0; + cfe_getenv("BOOT_FLAGS",boot_flags,sizeof(boot_flags)); + + if (boot_file[0] != 0) + (void)printf("Boot file: %s\n", boot_file); + (void)printf("Boot flags: %s\n", boot_flags); + + if (strchr(boot_flags, 'i') || strchr(boot_flags, 'I')) { + printf("Boot file: "); + kgets(boot_file, sizeof(boot_file)); + } + + memset(marks, 0, sizeof marks); + if (boot_file[0] != '\0') { + name = boot_file; + win = loadfile(name, marks, LOAD_KERNEL) == 0; + } else { + name = NULL; /* XXX gcc -Wuninitialized */ + for (namep = kernelnames, win = 0; *namep != NULL && !win; + namep++) + win = loadfile(name = *namep, marks, LOAD_KERNEL) == 0; + } + + entry = marks[MARK_ENTRY]; + booted_dev_close(); + printf("\n"); + if (!win) + goto fail; + + (void)printf("Entering %s at 0x%lx...\n", name, (long)entry); + + cfe_flushcache(0); + + memset(&bootinfo, 0,sizeof(bootinfo)); + bootinfo.version = BOOTINFO_VERSION; + bootinfo.reserved = 0; + bootinfo.ssym = marks[MARK_SYM]; + bootinfo.esym = marks[MARK_END]; + strncpy(bootinfo.boot_flags,boot_flags,sizeof(bootinfo.boot_flags)); + strncpy(bootinfo.booted_kernel,name,sizeof(bootinfo.booted_kernel)); + bootinfo.fwhandle = fwhandle; + bootinfo.fwentry = fwentry; + + (*(void (*)(long,long,long,long))entry)(fwhandle, + BOOTINFO_MAGIC, + (long)&bootinfo, + fwentry); + + (void)printf("KERNEL RETURNED!\n"); + +fail: + (void)printf("Boot failed! Halting...\n"); + halt(); + return 1; +} + + + diff --git a/sys/arch/evbmips/stand/sbmips/common/boot.ldscript b/sys/arch/evbmips/stand/sbmips/common/boot.ldscript new file mode 100644 index 000000000000..aab5f1b48716 --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/common/boot.ldscript @@ -0,0 +1,260 @@ +/* Script for -N: mix text and data on same page; don't align data */ +OUTPUT_ARCH(mips) +ENTRY(__start) +SEARCH_DIR("=/usr/lib"); +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x20000000)); . = SEGMENT_START("text-segment", 0x20000000) + SIZEOF_HEADERS; + .interp : { *(.interp) } + .reginfo : { *(.reginfo) } + .note.gnu.build-id : { *(.note.gnu.build-id) } + .dynamic : { *(.dynamic) } + .hash : { *(.hash) } + .gnu.hash : { *(.gnu.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + .rel.init : { *(.rel.init) } + .rela.init : { *(.rela.init) } + .rel.text : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) } + .rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) } + .rel.fini : { *(.rel.fini) } + .rela.fini : { *(.rela.fini) } + .rel.rodata : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) } + .rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) } + .rel.data.rel.ro : { *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*) } + .rela.data.rel.ro : { *(.rela.data.rel.ro* .rela.gnu.linkonce.d.rel.ro.*) } + .rel.data : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) } + .rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) } + .rel.tdata : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) } + .rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) } + .rel.tbss : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) } + .rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) } + .rel.ctors : { *(.rel.ctors) } + .rela.ctors : { *(.rela.ctors) } + .rel.dtors : { *(.rel.dtors) } + .rela.dtors : { *(.rela.dtors) } + .rel.got : { *(.rel.got) } + .rela.got : { *(.rela.got) } + .rel.dyn : { *(.rel.dyn) } + .rel.sdata : { *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) } + .rela.sdata : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) } + .rel.sbss : { *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) } + .rela.sbss : { *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) } + .rel.sdata2 : { *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) } + .rela.sdata2 : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) } + .rel.sbss2 : { *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) } + .rela.sbss2 : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) } + .rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) } + .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) } + .rel.iplt : + { + PROVIDE_HIDDEN (__rel_iplt_start = .); + *(.rel.iplt) + PROVIDE_HIDDEN (__rel_iplt_end = .); + } + .rela.iplt : + { + PROVIDE_HIDDEN (__rela_iplt_start = .); + *(.rela.iplt) + PROVIDE_HIDDEN (__rela_iplt_end = .); + } + .rel.plt : + { + *(.rel.plt) + } + .rela.plt : + { + *(.rela.plt) + } + .init : + { + KEEP (*(.init)) + } =0 + .plt : { *(.plt) } + .iplt : { *(.iplt) } + .text : + { + _ftext = . ; + *(.text.unlikely .text.*_unlikely) + *(.text.exit .text.exit.*) + *(.text.startup .text.startup.*) + *(.text.hot .text.hot.*) + *(.text .stub .text.* .gnu.linkonce.t.*) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.mips16.fn.*) *(.mips16.call.*) + } =0 + .fini : + { + KEEP (*(.fini)) + } =0 + PROVIDE (__etext = .); + PROVIDE (_etext = .); + PROVIDE (etext = .); + .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } + .rodata1 : { *(.rodata1) } + .sdata2 : + { + *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) + } + .sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) } + .eh_frame_hdr : { *(.eh_frame_hdr) } + .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } + .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } + /* Adjust the address for the data segment. We want to adjust up to + the same address within the page on the next page up. */ + . = .; + /* Exception handling */ + .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } + .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } + /* Thread Local Storage sections */ + .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } + .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + } + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array)) + PROVIDE_HIDDEN (__fini_array_end = .); + } + .ctors : + { + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + KEEP (*crtbegin.o(.ctors)) + KEEP (*crtbegin?.o(.ctors)) + /* We don't want to include the .ctor section from + the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + } + .dtors : + { + KEEP (*crtbegin.o(.dtors)) + KEEP (*crtbegin?.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + } + .jcr : { KEEP (*(.jcr)) } + .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) } + .data : + { + _fdata = . ; + *(.data .data.* .gnu.linkonce.d.*) + SORT(CONSTRUCTORS) + } + .data1 : { *(.data1) } + .got.plt : { *(.got.plt) } + . = .; + _gp = ALIGN(16) + 0x7ff0; + .got : { *(.got) } + /* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata : + { + *(.sdata .sdata.* .gnu.linkonce.s.*) + } + .lit8 : { *(.lit8) } + .lit4 : { *(.lit4) } + _edata = .; PROVIDE (edata = .); + __bss_start = .; + _fbss = .; + .sbss : + { + *(.dynsbss) + *(.sbss .sbss.* .gnu.linkonce.sb.*) + *(.scommon) + } + .bss : + { + *(.dynbss) + *(.bss .bss.* .gnu.linkonce.b.*) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. + FIXME: Why do we need it? When there is no .bss section, we don't + pad the .data section. */ + . = ALIGN(. != 0 ? 32 / 8 : 1); + } + . = ALIGN(32 / 8); + . = ALIGN(32 / 8); + _end = .; PROVIDE (end = .); + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /* DWARF 3 */ + .debug_pubtypes 0 : { *(.debug_pubtypes) } + .debug_ranges 0 : { *(.debug_ranges) } + .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) } + .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) } + .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) } + .mdebug.abi32 : { KEEP(*(.mdebug.abi32)) } + .mdebug.abiN32 : { KEEP(*(.mdebug.abiN32)) } + .mdebug.abi64 : { KEEP(*(.mdebug.abi64)) } + .mdebug.abiO64 : { KEEP(*(.mdebug.abiO64)) } + .mdebug.eabi32 : { KEEP(*(.mdebug.eabi32)) } + .mdebug.eabi64 : { KEEP(*(.mdebug.eabi64)) } + .gcc_compiled_long32 : { KEEP(*(.gcc_compiled_long32)) } + .gcc_compiled_long64 : { KEEP(*(.gcc_compiled_long64)) } + /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) } +} diff --git a/sys/arch/evbmips/stand/sbmips/common/booted_dev.c b/sys/arch/evbmips/stand/sbmips/common/booted_dev.c new file mode 100644 index 000000000000..9b9f0ac54bc3 --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/common/booted_dev.c @@ -0,0 +1,62 @@ +/* $NetBSD: booted_dev.c,v 1.2.4.2 2017/08/30 15:45:04 martin 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. The "Broadcom Corporation" name may not 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 "stand/common/common.h" +#include "stand/common/cfe_api.h" + +int booted_dev_fd; +#if defined(PRIMARY_BOOTBLOCK) || defined(UNIFIED_BOOTBLOCK) +char booted_dev_name[BOOTED_DEV_MAXNAMELEN]; +#endif /* defined(PRIMARY_BOOTBLOCK) || defined(UNIFIED_BOOTBLOCK) */ + +#if defined(PRIMARY_BOOTBLOCK) || defined(UNIFIED_BOOTBLOCK) +int booted_dev_open(void) +{ + if (cfe_getenv("BOOT_DEVICE",booted_dev_name,sizeof(booted_dev_name)) != 0) { + return 0; + } + + booted_dev_fd = cfe_open(booted_dev_name); + + return 1; +} +#endif + +void booted_dev_close(void) +{ + cfe_close(booted_dev_fd); +} diff --git a/sys/arch/evbmips/stand/sbmips/common/bootxx.c b/sys/arch/evbmips/stand/sbmips/common/bootxx.c new file mode 100644 index 000000000000..f7f4007a8ca0 --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/common/bootxx.c @@ -0,0 +1,127 @@ +/* $NetBSD: bootxx.c,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin Exp $ */ + +/* + * Copyright (c) 1999 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 + * for the NetBSD Project. + * 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. + */ + +/* + * 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. 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. + * + * @(#)boot.c 8.1 (Berkeley) 6/10/93 + */ + +#include +#include + +#include +#include +#include + +#include "../common/cfe_api.h" + +#include "../common/common.h" + +int main(long fwhandle,long evector,long fwentry,long fwseal); + +int +main(long fwhandle,long evector,long fwentry,long fwseal) +{ + struct stat sb; + const char *reason; + int fd; + + /* Init prom callback vector. */ + cfe_init(fwhandle,fwentry); + init_console(); + + putstr("\nNetBSD/sbmips " NETBSD_VERS " " BOOTXX_FS_NAME " Primary Bootstrap\n"); + + if (!booted_dev_open()) { + reason = "Can't open boot device."; + goto fail; + } + + fd = open("boot", 0); + if (fd == -1 || (fstat(fd, &sb) == -1)) { + reason = "Can't open /boot."; + goto failclose; + } + + if (sb.st_size > SECONDARY_MAX_LOAD) { + reason = "/boot too large."; + goto failclose; + } + + if (read(fd, (void*)SECONDARY_LOAD_ADDRESS, sb.st_size) != sb.st_size) { + reason = "/boot load failed."; + goto failclose; + } + + cfe_flushcache(0); + + putstr("Jumping to entry point...\n"); + (*((void(*)(long,long,long))SECONDARY_LOAD_ADDRESS))(fwhandle,booted_dev_fd,fwentry); + + reason = "Secondary boot returned!"; +failclose: + booted_dev_close(); +fail: + putstr(reason); + putstr("\n\nPRIMARY BOOTSTRAP FAILED!\n"); + + return 1; +} diff --git a/sys/arch/evbmips/stand/sbmips/common/cfe.c b/sys/arch/evbmips/stand/sbmips/common/cfe.c new file mode 100644 index 000000000000..7810c438ac99 --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/common/cfe.c @@ -0,0 +1,67 @@ +/* $NetBSD: cfe.c,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin 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. The "Broadcom Corporation" name may not 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 "common.h" + +#include "cfe_api.h" + +static int conhandle = -1; + +int getchar(void) +{ + char ch; + int res; + + while ((res = cfe_read(conhandle,&ch,1)) == 0) ; /* null loop */ + return (res < 0) ? -1 : ch; +} + +void putchar(int c) +{ + char ch; + + ch = (char) c; + if (ch == '\n') + putchar('\r'); + while (cfe_write(conhandle,&ch,1) == 0) ; /* null loop */ +} + +void init_console(void) +{ + conhandle = cfe_getstdhandle(CFE_STDHANDLE_CONSOLE); +} + + diff --git a/sys/arch/evbmips/stand/sbmips/common/cfe_api.c b/sys/arch/evbmips/stand/sbmips/common/cfe_api.c new file mode 100644 index 000000000000..184d82266c84 --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/common/cfe_api.c @@ -0,0 +1,535 @@ +/* $NetBSD: cfe_api.c,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin Exp $ */ +/* from: SiByte Id: cfe_api.c,v 1.16 2002/07/09 23:29:11 cgd Exp $ */ + +/* + * Copyright 2000, 2001, 2002 + * 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. The "Broadcom Corporation" name may not 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. + */ + +/* ********************************************************************* + * + * Broadcom Common Firmware Environment (CFE) + * + * Device Function stubs File: cfe_api.c + * + * This module contains device function stubs (small routines to + * call the standard "iocb" interface entry point to CFE). + * There should be one routine here per iocb function call. + * + * Authors: Mitch Lichtenberg, Chris Demetriou + * + ********************************************************************* */ + +#include "cfe_api.h" +#include "cfe_api_int.h" + +/* Cast from a native pointer to a cfe_xptr_t and back. */ +#define XPTR_FROM_NATIVE(n) ((cfe_xptr_t) (intptr_t) (n)) +#define NATIVE_FROM_XPTR(x) ((void *) (intptr_t) (x)) + +#ifdef CFE_API_IMPL_NAMESPACE +#define cfe_iocb_dispatch(a) __cfe_iocb_dispatch(a) +#endif +int cfe_iocb_dispatch(cfe_xiocb_t *xiocb); + +#if defined(CFE_API_common) || defined(CFE_API_ALL) +/* + * Declare the dispatch function with args of "intptr_t". + * This makes sure whatever model we're compiling in + * puts the pointers in a single register. For example, + * combining -mlong64 and -mips1 or -mips2 would lead to + * trouble, since the handle and IOCB pointer will be + * passed in two registers each, and CFE expects one. + */ + +static int (*cfe_dispfunc)(intptr_t handle, intptr_t xiocb) = 0; +static cfe_xuint_t cfe_handle = 0; + +int +cfe_init(cfe_xuint_t handle, cfe_xuint_t ept) +{ + cfe_dispfunc = NATIVE_FROM_XPTR(ept); + cfe_handle = handle; + return 0; +} + +int +cfe_iocb_dispatch(cfe_xiocb_t *xiocb) +{ + if (!cfe_dispfunc) return -1; + return (*cfe_dispfunc)((intptr_t)cfe_handle, (intptr_t)xiocb); +} +#endif /* CFE_API_common || CFE_API_ALL */ + +#if defined(CFE_API_close) || defined(CFE_API_ALL) +int +cfe_close(int handle) +{ + cfe_xiocb_t xiocb; + + xiocb.xiocb_fcode = CFE_CMD_DEV_CLOSE; + xiocb.xiocb_status = 0; + xiocb.xiocb_handle = handle; + xiocb.xiocb_flags = 0; + xiocb.xiocb_psize = 0; + + cfe_iocb_dispatch(&xiocb); + + return xiocb.xiocb_status; + +} +#endif /* CFE_API_close || CFE_API_ALL */ + +#if defined(CFE_API_cpu_start) || defined(CFE_API_ALL) +int +cfe_cpu_start(int cpu, void (*fn)(void), long sp, long gp, long a1) +{ + cfe_xiocb_t xiocb; + + xiocb.xiocb_fcode = CFE_CMD_FW_CPUCTL; + xiocb.xiocb_status = 0; + xiocb.xiocb_handle = 0; + xiocb.xiocb_flags = 0; + xiocb.xiocb_psize = sizeof(xiocb_cpuctl_t); + xiocb.plist.xiocb_cpuctl.cpu_number = cpu; + xiocb.plist.xiocb_cpuctl.cpu_command = CFE_CPU_CMD_START; + xiocb.plist.xiocb_cpuctl.gp_val = gp; + xiocb.plist.xiocb_cpuctl.sp_val = sp; + xiocb.plist.xiocb_cpuctl.a1_val = a1; + xiocb.plist.xiocb_cpuctl.start_addr = (long)fn; + + cfe_iocb_dispatch(&xiocb); + + return xiocb.xiocb_status; +} +#endif /* CFE_API_cpu_start || CFE_API_ALL */ + +#if defined(CFE_API_cpu_stop) || defined(CFE_API_ALL) +int +cfe_cpu_stop(int cpu) +{ + cfe_xiocb_t xiocb; + + xiocb.xiocb_fcode = CFE_CMD_FW_CPUCTL; + xiocb.xiocb_status = 0; + xiocb.xiocb_handle = 0; + xiocb.xiocb_flags = 0; + xiocb.xiocb_psize = sizeof(xiocb_cpuctl_t); + xiocb.plist.xiocb_cpuctl.cpu_number = cpu; + xiocb.plist.xiocb_cpuctl.cpu_command = CFE_CPU_CMD_STOP; + + cfe_iocb_dispatch(&xiocb); + + return xiocb.xiocb_status; +} +#endif /* CFE_API_cpu_stop || CFE_API_ALL */ + +#if defined(CFE_API_enumenv) || defined(CFE_API_ALL) +int +cfe_enumenv(int idx, char *name, int namelen, char *val, int vallen) +{ + cfe_xiocb_t xiocb; + + xiocb.xiocb_fcode = CFE_CMD_ENV_SET; + xiocb.xiocb_status = 0; + xiocb.xiocb_handle = 0; + xiocb.xiocb_flags = 0; + xiocb.xiocb_psize = sizeof(xiocb_envbuf_t); + xiocb.plist.xiocb_envbuf.enum_idx = idx; + xiocb.plist.xiocb_envbuf.name_ptr = XPTR_FROM_NATIVE(name); + xiocb.plist.xiocb_envbuf.name_length = namelen; + xiocb.plist.xiocb_envbuf.val_ptr = XPTR_FROM_NATIVE(val); + xiocb.plist.xiocb_envbuf.val_length = vallen; + + cfe_iocb_dispatch(&xiocb); + + return xiocb.xiocb_status; +} +#endif /* CFE_API_enumenv || CFE_API_ALL */ + +#if defined(CFE_API_enummem) || defined(CFE_API_ALL) +int +cfe_enummem(int idx, int flags, cfe_xuint_t *start, cfe_xuint_t *length, + cfe_xuint_t *type) +{ + cfe_xiocb_t xiocb; + + xiocb.xiocb_fcode = CFE_CMD_FW_MEMENUM; + xiocb.xiocb_status = 0; + xiocb.xiocb_handle = 0; + xiocb.xiocb_flags = flags; + xiocb.xiocb_psize = sizeof(xiocb_meminfo_t); + xiocb.plist.xiocb_meminfo.mi_idx = idx; + + cfe_iocb_dispatch(&xiocb); + + if (xiocb.xiocb_status < 0) + return xiocb.xiocb_status; + + *start = xiocb.plist.xiocb_meminfo.mi_addr; + *length = xiocb.plist.xiocb_meminfo.mi_size; + *type = xiocb.plist.xiocb_meminfo.mi_type; + + return 0; +} +#endif /* CFE_API_enummem || CFE_API_ALL */ + +#if defined(CFE_API_exit) || defined(CFE_API_ALL) +int +cfe_exit(int warm, int status) +{ + cfe_xiocb_t xiocb; + + xiocb.xiocb_fcode = CFE_CMD_FW_RESTART; + xiocb.xiocb_status = 0; + xiocb.xiocb_handle = 0; + xiocb.xiocb_flags = warm ? CFE_FLG_WARMSTART : 0; + xiocb.xiocb_psize = sizeof(xiocb_exitstat_t); + xiocb.plist.xiocb_exitstat.status = status; + + cfe_iocb_dispatch(&xiocb); + + return xiocb.xiocb_status; +} +#endif /* CFE_API_exit || CFE_API_ALL */ + +#if defined(CFE_API_flushcache) || defined(CFE_API_ALL) +int +cfe_flushcache(int flg) +{ + cfe_xiocb_t xiocb; + + xiocb.xiocb_fcode = CFE_CMD_FW_FLUSHCACHE; + xiocb.xiocb_status = 0; + xiocb.xiocb_handle = 0; + xiocb.xiocb_flags = flg; + xiocb.xiocb_psize = 0; + + cfe_iocb_dispatch(&xiocb); + + return xiocb.xiocb_status; +} +#endif /* CFE_API_flushcache || CFE_API_ALL */ + +#if defined(CFE_API_getdevinfo) || defined(CFE_API_ALL) +int +cfe_getdevinfo(char *name) +{ + cfe_xiocb_t xiocb; + + xiocb.xiocb_fcode = CFE_CMD_DEV_GETINFO; + xiocb.xiocb_status = 0; + xiocb.xiocb_handle = 0; + xiocb.xiocb_flags = 0; + xiocb.xiocb_psize = sizeof(xiocb_buffer_t); + xiocb.plist.xiocb_buffer.buf_offset = 0; + xiocb.plist.xiocb_buffer.buf_ptr = XPTR_FROM_NATIVE(name); + xiocb.plist.xiocb_buffer.buf_length = cfe_strlen(name); + + cfe_iocb_dispatch(&xiocb); + + if (xiocb.xiocb_status < 0) + return xiocb.xiocb_status; + return xiocb.plist.xiocb_buffer.buf_devflags; +} +#endif /* CFE_API_getdevinfo || CFE_API_ALL */ + +#if defined(CFE_API_getenv) || defined(CFE_API_ALL) +int +cfe_getenv(char *name, char *dest, int destlen) +{ + cfe_xiocb_t xiocb; + + *dest = 0; + + xiocb.xiocb_fcode = CFE_CMD_ENV_GET; + xiocb.xiocb_status = 0; + xiocb.xiocb_handle = 0; + xiocb.xiocb_flags = 0; + xiocb.xiocb_psize = sizeof(xiocb_envbuf_t); + xiocb.plist.xiocb_envbuf.enum_idx = 0; + xiocb.plist.xiocb_envbuf.name_ptr = XPTR_FROM_NATIVE(name); + xiocb.plist.xiocb_envbuf.name_length = cfe_strlen(name); + xiocb.plist.xiocb_envbuf.val_ptr = XPTR_FROM_NATIVE(dest); + xiocb.plist.xiocb_envbuf.val_length = destlen; + + cfe_iocb_dispatch(&xiocb); + + return xiocb.xiocb_status; +} +#endif /* CFE_API_getenv || CFE_API_ALL */ + +#if defined(CFE_API_getfwinfo) || defined(CFE_API_ALL) +int +cfe_getfwinfo(cfe_fwinfo_t *info) +{ + cfe_xiocb_t xiocb; + + xiocb.xiocb_fcode = CFE_CMD_FW_GETINFO; + xiocb.xiocb_status = 0; + xiocb.xiocb_handle = 0; + xiocb.xiocb_flags = 0; + xiocb.xiocb_psize = sizeof(xiocb_fwinfo_t); + + cfe_iocb_dispatch(&xiocb); + + if (xiocb.xiocb_status < 0) + return xiocb.xiocb_status; + + info->fwi_version = xiocb.plist.xiocb_fwinfo.fwi_version; + info->fwi_totalmem = xiocb.plist.xiocb_fwinfo.fwi_totalmem; + info->fwi_flags = xiocb.plist.xiocb_fwinfo.fwi_flags; + info->fwi_boardid = xiocb.plist.xiocb_fwinfo.fwi_boardid; + info->fwi_bootarea_va = xiocb.plist.xiocb_fwinfo.fwi_bootarea_va; + info->fwi_bootarea_pa = xiocb.plist.xiocb_fwinfo.fwi_bootarea_pa; + info->fwi_bootarea_size = xiocb.plist.xiocb_fwinfo.fwi_bootarea_size; +#if 0 + info->fwi_reserved1 = xiocb.plist.xiocb_fwinfo.fwi_reserved1; + info->fwi_reserved2 = xiocb.plist.xiocb_fwinfo.fwi_reserved2; + info->fwi_reserved3 = xiocb.plist.xiocb_fwinfo.fwi_reserved3; +#endif + + return 0; +} +#endif /* CFE_API_getfwinfo || CFE_API_ALL */ + +#if defined(CFE_API_getstdhandle) || defined(CFE_API_ALL) +int +cfe_getstdhandle(int flg) +{ + cfe_xiocb_t xiocb; + + xiocb.xiocb_fcode = CFE_CMD_DEV_GETHANDLE; + xiocb.xiocb_status = 0; + xiocb.xiocb_handle = 0; + xiocb.xiocb_flags = flg; + xiocb.xiocb_psize = 0; + + cfe_iocb_dispatch(&xiocb); + + if (xiocb.xiocb_status < 0) + return xiocb.xiocb_status; + return xiocb.xiocb_handle; + +} +#endif /* CFE_API_getstdhandle || CFE_API_ALL */ + +#if defined(CFE_API_getticks) || defined(CFE_API_ALL) +int64_t +#ifdef CFE_API_IMPL_NAMESPACE +__cfe_getticks(void) +#else +cfe_getticks(void) +#endif +{ + cfe_xiocb_t xiocb; + + xiocb.xiocb_fcode = CFE_CMD_FW_GETTIME; + xiocb.xiocb_status = 0; + xiocb.xiocb_handle = 0; + xiocb.xiocb_flags = 0; + xiocb.xiocb_psize = sizeof(xiocb_time_t); + xiocb.plist.xiocb_time.ticks = 0; + + cfe_iocb_dispatch(&xiocb); + + return xiocb.plist.xiocb_time.ticks; + +} +#endif /* CFE_API_getticks || CFE_API_ALL */ + +#if defined(CFE_API_inpstat) || defined(CFE_API_ALL) +int +cfe_inpstat(int handle) +{ + cfe_xiocb_t xiocb; + + xiocb.xiocb_fcode = CFE_CMD_DEV_INPSTAT; + xiocb.xiocb_status = 0; + xiocb.xiocb_handle = handle; + xiocb.xiocb_flags = 0; + xiocb.xiocb_psize = sizeof(xiocb_inpstat_t); + xiocb.plist.xiocb_inpstat.inp_status = 0; + + cfe_iocb_dispatch(&xiocb); + + if (xiocb.xiocb_status < 0) + return xiocb.xiocb_status; + return xiocb.plist.xiocb_inpstat.inp_status; + +} +#endif /* CFE_API_inpstat || CFE_API_ALL */ + +#if defined(CFE_API_ioctl) || defined(CFE_API_ALL) +int +cfe_ioctl(int handle, unsigned int ioctlnum, unsigned char *buffer, int length, + int *retlen, cfe_xuint_t offset) +{ + cfe_xiocb_t xiocb; + + xiocb.xiocb_fcode = CFE_CMD_DEV_IOCTL; + xiocb.xiocb_status = 0; + xiocb.xiocb_handle = handle; + xiocb.xiocb_flags = 0; + xiocb.xiocb_psize = sizeof(xiocb_buffer_t); + xiocb.plist.xiocb_buffer.buf_offset = offset; + xiocb.plist.xiocb_buffer.buf_ioctlcmd = ioctlnum; + xiocb.plist.xiocb_buffer.buf_ptr = XPTR_FROM_NATIVE(buffer); + xiocb.plist.xiocb_buffer.buf_length = length; + + cfe_iocb_dispatch(&xiocb); + + if (retlen) + *retlen = xiocb.plist.xiocb_buffer.buf_retlen; + return xiocb.xiocb_status; +} +#endif /* CFE_API_ioctl || CFE_API_ALL */ + +#if defined(CFE_API_open) || defined(CFE_API_ALL) +int +cfe_open(char *name) +{ + cfe_xiocb_t xiocb; + + xiocb.xiocb_fcode = CFE_CMD_DEV_OPEN; + xiocb.xiocb_status = 0; + xiocb.xiocb_handle = 0; + xiocb.xiocb_flags = 0; + xiocb.xiocb_psize = sizeof(xiocb_buffer_t); + xiocb.plist.xiocb_buffer.buf_offset = 0; + xiocb.plist.xiocb_buffer.buf_ptr = XPTR_FROM_NATIVE(name); + xiocb.plist.xiocb_buffer.buf_length = cfe_strlen(name); + + cfe_iocb_dispatch(&xiocb); + + if (xiocb.xiocb_status < 0) + return xiocb.xiocb_status; + return xiocb.xiocb_handle; +} +#endif /* CFE_API_open || CFE_API_ALL */ + +#if defined(CFE_API_read) || defined(CFE_API_ALL) +int +cfe_read(int handle, unsigned char *buffer, int length) +{ + return cfe_readblk(handle, 0, buffer, length); +} +#endif /* CFE_API_read || CFE_API_ALL */ + +#if defined(CFE_API_readblk) || defined(CFE_API_ALL) +int +cfe_readblk(int handle, cfe_xint_t offset, unsigned char *buffer, int length) +{ + cfe_xiocb_t xiocb; + + xiocb.xiocb_fcode = CFE_CMD_DEV_READ; + xiocb.xiocb_status = 0; + xiocb.xiocb_handle = handle; + xiocb.xiocb_flags = 0; + xiocb.xiocb_psize = sizeof(xiocb_buffer_t); + xiocb.plist.xiocb_buffer.buf_offset = offset; + xiocb.plist.xiocb_buffer.buf_ptr = XPTR_FROM_NATIVE(buffer); + xiocb.plist.xiocb_buffer.buf_length = length; + + cfe_iocb_dispatch(&xiocb); + + if (xiocb.xiocb_status < 0) + return xiocb.xiocb_status; + return xiocb.plist.xiocb_buffer.buf_retlen; +} +#endif /* CFE_API_readblk || CFE_API_ALL */ + +#if defined(CFE_API_setenv) || defined(CFE_API_ALL) +int +cfe_setenv(char *name, char *val) +{ + cfe_xiocb_t xiocb; + + xiocb.xiocb_fcode = CFE_CMD_ENV_SET; + xiocb.xiocb_status = 0; + xiocb.xiocb_handle = 0; + xiocb.xiocb_flags = 0; + xiocb.xiocb_psize = sizeof(xiocb_envbuf_t); + xiocb.plist.xiocb_envbuf.enum_idx = 0; + xiocb.plist.xiocb_envbuf.name_ptr = XPTR_FROM_NATIVE(name); + xiocb.plist.xiocb_envbuf.name_length = cfe_strlen(name); + xiocb.plist.xiocb_envbuf.val_ptr = XPTR_FROM_NATIVE(val); + xiocb.plist.xiocb_envbuf.val_length = cfe_strlen(val); + + cfe_iocb_dispatch(&xiocb); + + return xiocb.xiocb_status; +} +#endif /* CFE_API_setenv || CFE_API_ALL */ + +#if (defined(CFE_API_strlen) || defined(CFE_API_ALL)) \ + && !defined(CFE_API_STRLEN_CUSTOM) +int +cfe_strlen(char *name) +{ + int count = 0; + + while (*name++) + count++; + + return count; +} +#endif /* CFE_API_strlen || CFE_API_ALL */ + +#if defined(CFE_API_write) || defined(CFE_API_ALL) +int +cfe_write(int handle, unsigned char *buffer, int length) +{ + return cfe_writeblk(handle, 0, buffer, length); +} +#endif /* CFE_API_write || CFE_API_ALL */ + +#if defined(CFE_API_writeblk) || defined(CFE_API_ALL) +int +cfe_writeblk(int handle, cfe_xint_t offset, unsigned char *buffer, int length) +{ + cfe_xiocb_t xiocb; + + xiocb.xiocb_fcode = CFE_CMD_DEV_WRITE; + xiocb.xiocb_status = 0; + xiocb.xiocb_handle = handle; + xiocb.xiocb_flags = 0; + xiocb.xiocb_psize = sizeof(xiocb_buffer_t); + xiocb.plist.xiocb_buffer.buf_offset = offset; + xiocb.plist.xiocb_buffer.buf_ptr = XPTR_FROM_NATIVE(buffer); + xiocb.plist.xiocb_buffer.buf_length = length; + + cfe_iocb_dispatch(&xiocb); + + if (xiocb.xiocb_status < 0) + return xiocb.xiocb_status; + return xiocb.plist.xiocb_buffer.buf_retlen; +} +#endif /* CFE_API_writeblk || CFE_API_ALL */ diff --git a/sys/arch/evbmips/stand/sbmips/common/cfe_api.h b/sys/arch/evbmips/stand/sbmips/common/cfe_api.h new file mode 100644 index 000000000000..15a3304f6e7d --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/common/cfe_api.h @@ -0,0 +1,209 @@ +/* $NetBSD: cfe_api.h,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin Exp $ */ +/* from: SiByte Id: cfe_api.h,v 1.29 2002/07/09 23:29:11 cgd Exp $ */ + +/* + * Copyright 2000, 2001, 2002 + * 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. The "Broadcom Corporation" name may not 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. + */ + +/* ********************************************************************* + * + * Broadcom Common Firmware Environment (CFE) + * + * Device function prototypes File: cfe_api.h + * + * This file contains declarations for doing callbacks to + * cfe from an application. It should be the only header + * needed by the application to use this library + * + * Authors: Mitch Lichtenberg, Chris Demetriou + * + ********************************************************************* */ + +#ifndef CFE_API_H +#define CFE_API_H + +/* + * Apply customizations here for different OSes. These need to: + * * typedef uint64_t, int64_t, intptr_t, uintptr_t. + * * define cfe_strlen() if use of an existing function is desired. + * * define CFE_API_IMPL_NAMESPACE if API functions are to use + * names in the implementation namespace. + * Also, optionally, if the build environment does not do so automatically, + * CFE_API_* can be defined here as desired. + */ +/* Begin customization. */ +#include /* All of the typedefs. */ +#include /* strlen() prototype. */ + +#define CFE_API_close +#define CFE_API_common +#define CFE_API_flushcache +#define CFE_API_getenv +#define CFE_API_getstdhandle +#define CFE_API_getticks +#define CFE_API_ioctl +#define CFE_API_open +#define CFE_API_read +#define CFE_API_readblk +#define CFE_API_write +#define CFE_API_writeblk + +#define cfe_strlen(x) strlen(x) +/* End customization. */ + + +/* ********************************************************************* + * Constants + ********************************************************************* */ + +/* Seal indicating CFE's presence, passed to user program. */ +#define CFE_EPTSEAL 0x43464531 + +#define CFE_MI_RESERVED 0 /* memory is reserved, do not use */ +#define CFE_MI_AVAILABLE 1 /* memory is available */ + +#define CFE_FLG_WARMSTART 0x00000001 +#define CFE_FLG_FULL_ARENA 0x00000001 +#define CFE_FLG_ENV_PERMANENT 0x00000001 + +#define CFE_CPU_CMD_START 1 +#define CFE_CPU_CMD_STOP 0 + +#define CFE_STDHANDLE_CONSOLE 0 + +#define CFE_DEV_NETWORK 1 +#define CFE_DEV_DISK 2 +#define CFE_DEV_FLASH 3 +#define CFE_DEV_SERIAL 4 +#define CFE_DEV_CPU 5 +#define CFE_DEV_NVRAM 6 +#define CFE_DEV_CLOCK 7 +#define CFE_DEV_OTHER 8 +#define CFE_DEV_MASK 0x0F + +#define CFE_CACHE_FLUSH_D 1 +#define CFE_CACHE_INVAL_I 2 +#define CFE_CACHE_INVAL_D 4 +#define CFE_CACHE_INVAL_L2 8 + +#define CFE_FWI_64BIT 0x00000001 +#define CFE_FWI_32BIT 0x00000002 +#define CFE_FWI_RELOC 0x00000004 +#define CFE_FWI_UNCACHED 0x00000008 +#define CFE_FWI_MULTICPU 0x00000010 +#define CFE_FWI_FUNCSIM 0x00000020 +#define CFE_FWI_RTLSIM 0x00000040 + +typedef struct { + int64_t fwi_version; /* major, minor, eco version */ + int64_t fwi_totalmem; /* total installed mem */ + int64_t fwi_flags; /* various flags */ + int64_t fwi_boardid; /* board ID */ + int64_t fwi_bootarea_va; /* VA of boot area */ + int64_t fwi_bootarea_pa; /* PA of boot area */ + int64_t fwi_bootarea_size; /* size of boot area */ +} cfe_fwinfo_t; + + +/* + * cfe_strlen is handled specially: If already defined, it has been + * overridden in this environment with a standard strlen-like function. + */ +#ifdef cfe_strlen +# define CFE_API_STRLEN_CUSTOM +#else +# ifdef CFE_API_IMPL_NAMESPACE +# define cfe_strlen(a) __cfe_strlen(a) +# endif +int cfe_strlen(char *name); +#endif + +/* + * Defines and prototypes for functions which take no arguments. + */ +#ifdef CFE_API_IMPL_NAMESPACE +int64_t __cfe_getticks(void); +#define cfe_getticks() __cfe_getticks() +#else +int64_t cfe_getticks(void); +#endif + +/* + * Defines and prototypes for the rest of the functions. + */ +#ifdef CFE_API_IMPL_NAMESPACE +#define cfe_close(a) __cfe_close(a) +#define cfe_cpu_start(a,b,c,d,e) __cfe_cpu_start(a,b,c,d,e) +#define cfe_cpu_stop(a) __cfe_cpu_stop(a) +#define cfe_enumenv(a,b,d,e,f) __cfe_enumenv(a,b,d,e,f) +#define cfe_enummem(a,b,c,d,e) __cfe_enummem(a,b,c,d,e) +#define cfe_exit(a,b) __cfe_exit(a,b) +#define cfe_flushcache(a) __cfe_cacheflush(a) +#define cfe_getdevinfo(a) __cfe_getdevinfo(a) +#define cfe_getenv(a,b,c) __cfe_getenv(a,b,c) +#define cfe_getfwinfo(a) __cfe_getfwinfo(a) +#define cfe_getstdhandle(a) __cfe_getstdhandle(a) +#define cfe_init(a,b) __cfe_init(a,b) +#define cfe_inpstat(a) __cfe_inpstat(a) +#define cfe_ioctl(a,b,c,d,e,f) __cfe_ioctl(a,b,c,d,e,f) +#define cfe_open(a) __cfe_open(a) +#define cfe_read(a,b,c) __cfe_read(a,b,c) +#define cfe_readblk(a,b,c,d) __cfe_readblk(a,b,c,d) +#define cfe_setenv(a,b) __cfe_setenv(a,b) +#define cfe_write(a,b,c) __cfe_write(a,b,c) +#define cfe_writeblk(a,b,c,d) __cfe_writeblk(a,b,c,d) +#endif /* CFE_API_IMPL_NAMESPACE */ + +int cfe_close(int handle); +int cfe_cpu_start(int cpu, void (*fn)(void), long sp, long gp, long a1); +int cfe_cpu_stop(int cpu); +int cfe_enumenv(int idx, char *name, int namelen, char *val, int vallen); +int cfe_enummem(int idx, int flags, uint64_t *start, uint64_t *length, + uint64_t *type); +int cfe_exit(int warm,int status); +int cfe_flushcache(int flg); +int cfe_getdevinfo(char *name); +int cfe_getenv(char *name, char *dest, int destlen); +int cfe_getfwinfo(cfe_fwinfo_t *info); +int cfe_getstdhandle(int flg); +int cfe_init(uint64_t handle,uint64_t ept); +int cfe_inpstat(int handle); +int cfe_ioctl(int handle, unsigned int ioctlnum, unsigned char *buffer, + int length, int *retlen, uint64_t offset); +int cfe_open(char *name); +int cfe_read(int handle, unsigned char *buffer, int length); +int cfe_readblk(int handle, int64_t offset, unsigned char *buffer, int length); +int cfe_setenv(char *name, char *val); +int cfe_write(int handle, unsigned char *buffer, int length); +int cfe_writeblk(int handle, int64_t offset, unsigned char *buffer, + int length); + +#endif /* CFE_API_H */ diff --git a/sys/arch/evbmips/stand/sbmips/common/cfe_api_int.h b/sys/arch/evbmips/stand/sbmips/common/cfe_api_int.h new file mode 100644 index 000000000000..451f79d2afd2 --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/common/cfe_api_int.h @@ -0,0 +1,169 @@ +/* $NetBSD: cfe_api_int.h,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin Exp $ */ +/* from: SiByte Id: cfe_api_int.h,v 1.21 2002/07/09 23:29:11 cgd Exp $ */ + +/* + * Copyright 2000, 2001, 2002 + * 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. The "Broadcom Corporation" name may not 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. + */ + +/* ********************************************************************* + * + * Broadcom Common Firmware Environment (CFE) + * + * Device function prototypes File: cfe_api_int.h + * + * This header defines all internal types and macros for the + * library. This is stuff that's not exported to an app + * using the library. + * + * Authors: Mitch Lichtenberg, Chris Demetriou + * + ********************************************************************* */ + +#ifndef CFE_API_INT_H +#define CFE_API_INT_H + +/* ********************************************************************* + * Constants + ********************************************************************* */ + +#define CFE_CMD_FW_GETINFO 0 +#define CFE_CMD_FW_RESTART 1 +#define CFE_CMD_FW_BOOT 2 +#define CFE_CMD_FW_CPUCTL 3 +#define CFE_CMD_FW_GETTIME 4 +#define CFE_CMD_FW_MEMENUM 5 +#define CFE_CMD_FW_FLUSHCACHE 6 + +#define CFE_CMD_DEV_GETHANDLE 9 +#define CFE_CMD_DEV_ENUM 10 +#define CFE_CMD_DEV_OPEN 11 +#define CFE_CMD_DEV_INPSTAT 12 +#define CFE_CMD_DEV_READ 13 +#define CFE_CMD_DEV_WRITE 14 +#define CFE_CMD_DEV_IOCTL 15 +#define CFE_CMD_DEV_CLOSE 16 +#define CFE_CMD_DEV_GETINFO 17 + +#define CFE_CMD_ENV_ENUM 20 +#define CFE_CMD_ENV_GET 22 +#define CFE_CMD_ENV_SET 23 +#define CFE_CMD_ENV_DEL 24 + +#define CFE_CMD_MAX 32 + +#define CFE_CMD_VENDOR_USE 0x8000 /* codes above this are for customer use */ + +/* ********************************************************************* + * Structures + ********************************************************************* */ + +typedef uint64_t cfe_xuint_t; +typedef int64_t cfe_xint_t; +typedef int64_t cfe_xptr_t; + +typedef struct xiocb_buffer_s { + cfe_xuint_t buf_offset; /* offset on device (bytes) */ + cfe_xptr_t buf_ptr; /* pointer to a buffer */ + cfe_xuint_t buf_length; /* length of this buffer */ + cfe_xuint_t buf_retlen; /* returned length (for read ops) */ + cfe_xuint_t buf_ioctlcmd; /* IOCTL command (used only for IOCTLs) */ +} xiocb_buffer_t; + +#define buf_devflags buf_ioctlcmd /* returned device info flags */ + +typedef struct xiocb_inpstat_s { + cfe_xuint_t inp_status; /* 1 means input available */ +} xiocb_inpstat_t; + +typedef struct xiocb_envbuf_s { + cfe_xint_t enum_idx; /* 0-based enumeration index */ + cfe_xptr_t name_ptr; /* name string buffer */ + cfe_xint_t name_length; /* size of name buffer */ + cfe_xptr_t val_ptr; /* value string buffer */ + cfe_xint_t val_length; /* size of value string buffer */ +} xiocb_envbuf_t; + +typedef struct xiocb_cpuctl_s { + cfe_xuint_t cpu_number; /* cpu number to control */ + cfe_xuint_t cpu_command; /* command to issue to CPU */ + cfe_xuint_t start_addr; /* CPU start address */ + cfe_xuint_t gp_val; /* starting GP value */ + cfe_xuint_t sp_val; /* starting SP value */ + cfe_xuint_t a1_val; /* starting A1 value */ +} xiocb_cpuctl_t; + +typedef struct xiocb_time_s { + cfe_xint_t ticks; /* current time in ticks */ +} xiocb_time_t; + +typedef struct xiocb_exitstat_s { + cfe_xint_t status; +} xiocb_exitstat_t; + +typedef struct xiocb_meminfo_s { + cfe_xint_t mi_idx; /* 0-based enumeration index */ + cfe_xint_t mi_type; /* type of memory block */ + cfe_xuint_t mi_addr; /* physical start address */ + cfe_xuint_t mi_size; /* block size */ +} xiocb_meminfo_t; + +typedef struct xiocb_fwinfo_s { + cfe_xint_t fwi_version; /* major, minor, eco version */ + cfe_xint_t fwi_totalmem; /* total installed mem */ + cfe_xint_t fwi_flags; /* various flags */ + cfe_xint_t fwi_boardid; /* board ID */ + cfe_xint_t fwi_bootarea_va; /* VA of boot area */ + cfe_xint_t fwi_bootarea_pa; /* PA of boot area */ + cfe_xint_t fwi_bootarea_size; /* size of boot area */ + cfe_xint_t fwi_reserved1; + cfe_xint_t fwi_reserved2; + cfe_xint_t fwi_reserved3; +} xiocb_fwinfo_t; + +typedef struct cfe_xiocb_s { + cfe_xuint_t xiocb_fcode; /* IOCB function code */ + cfe_xint_t xiocb_status; /* return status */ + cfe_xint_t xiocb_handle; /* file/device handle */ + cfe_xuint_t xiocb_flags; /* flags for this IOCB */ + cfe_xuint_t xiocb_psize; /* size of parameter list */ + union { + xiocb_buffer_t xiocb_buffer; /* buffer parameters */ + xiocb_inpstat_t xiocb_inpstat; /* input status parameters */ + xiocb_envbuf_t xiocb_envbuf; /* environment function parameters */ + xiocb_cpuctl_t xiocb_cpuctl; /* CPU control parameters */ + xiocb_time_t xiocb_time; /* timer parameters */ + xiocb_meminfo_t xiocb_meminfo; /* memory arena info parameters */ + xiocb_fwinfo_t xiocb_fwinfo; /* firmware information */ + xiocb_exitstat_t xiocb_exitstat; /* Exit Status */ + } plist; +} cfe_xiocb_t; + +#endif /* CFE_API_INT_H */ diff --git a/sys/arch/evbmips/stand/sbmips/common/cfe_error.h b/sys/arch/evbmips/stand/sbmips/common/cfe_error.h new file mode 100644 index 000000000000..60357d567a39 --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/common/cfe_error.h @@ -0,0 +1,102 @@ +/* $NetBSD: cfe_error.h,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin Exp $ */ +/* from: SiByte Id: cfe_error.h,v 1.2 2002/07/09 19:37:52 cgd Exp $ */ + +/* + * Copyright 2000, 2001, 2002 + * 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. The "Broadcom Corporation" name may not 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. + */ + +/* ********************************************************************* + * + * Broadcom Common Firmware Environment (CFE) + * + * Error codes File: cfe_error.h + * + * CFE's global error code list is here. + * + * Author: Mitch Lichtenberg + * + ********************************************************************* */ + + +#define CFE_OK 0 +#define CFE_ERR -1 /* generic error */ +#define CFE_ERR_INV_COMMAND -2 +#define CFE_ERR_EOF -3 +#define CFE_ERR_IOERR -4 +#define CFE_ERR_NOMEM -5 +#define CFE_ERR_DEVNOTFOUND -6 +#define CFE_ERR_DEVOPEN -7 +#define CFE_ERR_INV_PARAM -8 +#define CFE_ERR_ENVNOTFOUND -9 +#define CFE_ERR_ENVREADONLY -10 + +#define CFE_ERR_NOTELF -11 +#define CFE_ERR_NOT32BIT -12 +#define CFE_ERR_WRONGENDIAN -13 +#define CFE_ERR_BADELFVERS -14 +#define CFE_ERR_NOTMIPS -15 +#define CFE_ERR_BADELFFMT -16 +#define CFE_ERR_BADADDR -17 + +#define CFE_ERR_FILENOTFOUND -18 +#define CFE_ERR_UNSUPPORTED -19 + +#define CFE_ERR_HOSTUNKNOWN -20 + +#define CFE_ERR_TIMEOUT -21 + +#define CFE_ERR_PROTOCOLERR -22 + +#define CFE_ERR_NETDOWN -23 +#define CFE_ERR_NONAMESERVER -24 + +#define CFE_ERR_NOHANDLES -25 +#define CFE_ERR_ALREADYBOUND -26 + +#define CFE_ERR_CANNOTSET -27 +#define CFE_ERR_NOMORE -28 +#define CFE_ERR_BADFILESYS -29 +#define CFE_ERR_FSNOTAVAIL -30 + +#define CFE_ERR_INVBOOTBLOCK -31 +#define CFE_ERR_WRONGDEVTYPE -32 +#define CFE_ERR_BBCHECKSUM -33 +#define CFE_ERR_BOOTPROGCHKSUM -34 + +#define CFE_ERR_LDRNOTAVAIL -35 + +#define CFE_ERR_NOTREADY -36 + +#define CFE_ERR_GETMEM -37 +#define CFE_ERR_SETMEM -38 + +#define CFE_ERR_NOTCONN -39 +#define CFE_ERR_ADDRINUSE -40 diff --git a/sys/arch/evbmips/stand/sbmips/common/cfe_ioctl.h b/sys/arch/evbmips/stand/sbmips/common/cfe_ioctl.h new file mode 100644 index 000000000000..5e53dc27d650 --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/common/cfe_ioctl.h @@ -0,0 +1,73 @@ +/* $NetBSD: cfe_ioctl.h,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin 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. The "Broadcom Corporation" name may not 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. + */ + +/* ********************************************************************* + * Broadcom Common Firmware Environment (CFE) + * + * IOCTL definitions File: cfe_ioctl.h + * + * IOCTL function numbers and I/O data structures. + * + * Author: Mitch Lichtenberg (mpl@broadcom.com) + * + ********************************************************************* */ + + +/* ********************************************************************* + * NVFAM and FLASH stuff + ********************************************************************* */ + +#define IOCTL_NVRAM_GETINFO 1 /* return nvram_info_t */ +#define IOCTL_NVRAM_ERASE 2 /* erase sector containing nvram_info_t area */ +#define IOCTL_FLASH_ERASE_SECTOR 3 /* erase an arbitrary sector */ +#define IOCTL_FLASH_ERASE_ALL 4 /* Erase the entire flash */ + +typedef struct nvram_info_s { + int nvram_offset; /* offset of environment area */ + int nvram_size; /* size of environment area */ + int nvram_eraseflg; /* true if we need to erase first */ +} nvram_info_t; + +/* ********************************************************************* + * Ethernet stuff + ********************************************************************* */ + +#define IOCTL_ETHER_GETHWADDR 1 + +/* ********************************************************************* + * Block device stuff + ********************************************************************* */ + +#define IOCTL_BLOCK_GETBLOCKSIZE 1 +#define IOCTL_BLOCK_GETTOTALBLOCKS 2 diff --git a/sys/arch/evbmips/stand/sbmips/common/checksize.sh b/sys/arch/evbmips/stand/sbmips/common/checksize.sh new file mode 100644 index 000000000000..6335ac43bcb8 --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/common/checksize.sh @@ -0,0 +1,75 @@ +#!/bin/sh +# $NetBSD: checksize.sh,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin Exp $ +# +# Copyright (c) 1999 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 +# for the NetBSD Project. +# 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. + +# four arguments: +# boot object with headers, to check bss size +# boot file (just text+data), to check load and total sizes +# maximum load size +# maximum total (load + bss) size + +progname=$0 +if [ $# != 4 ] || [ ! -f $1 ] || [ ! -f $2 ]; then + echo "$progname bootobj bootfile maxload maxtotal" 1>&2 + exit 1 +fi + +bootobj=$1 +bootfile=$2 +maxloadsize=$3 +maxtotalsize=$4 + +if [ "$SIZE" = "" ]; then + SIZE=size +fi + +size_data=`$SIZE $bootobj` +if [ $? != 0 ]; then + echo "$progname: couldn't get size of $bootobj" 2>&1 + exit 1 +fi +bss_size=`echo "$size_data" | awk ' NR == 2 { print $3 } '` + +load_size=`ls -l $bootfile | awk ' { print $5 }'` + +echo -n "checking sizes for $bootfile/$bootobj... " + +if expr $load_size \> $maxloadsize >/dev/null 2>&1; then + echo "MAXIMUM LOAD SIZE EXCEEDED ($load_size > $maxloadsize)" + exit 1 +fi + +if expr $load_size + $bss_size \> $maxtotalsize >/dev/null 2>&1; then + echo "MAXIMUM TOTAL SIZE EXCEEDED ($load_size + $bss_size > $maxtotalsize)" + exit 1 +fi + +echo "OK" +exit 0 diff --git a/sys/arch/evbmips/stand/sbmips/common/common.h b/sys/arch/evbmips/stand/sbmips/common/common.h new file mode 100644 index 000000000000..a4393a891ea0 --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/common/common.h @@ -0,0 +1,69 @@ +/* $NetBSD: common.h,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin Exp $ */ + +/* + * Copyright (c) 1999 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 + * for the NetBSD Project. + * 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. + */ + +void halt(void); +void putstr(const char *); +void init_console(void); +void putchar(int); +int getchar(void); + + +/* + * vers.c (generated by newvers.sh) + */ +extern const char bootprog_rev[]; + +/* + * booted_dev.c + */ + +#define BOOTED_DEV_MAXNAMELEN 64 + +#if defined(PRIMARY_BOOTBLOCK) || defined(UNIFIED_BOOTBLOCK) +int booted_dev_open(void); +#endif +void booted_dev_close(void); +#if defined(SECONDARY_BOOTBLOCK) +#define booted_dev_setfd(fd) ((void)(booted_dev_fd = fd)) +#endif + +extern int booted_dev_fd; +#if defined(PRIMARY_BOOTBLOCK) || defined(UNIFIED_BOOTBLOCK) +extern char booted_dev_name[BOOTED_DEV_MAXNAMELEN]; +#endif + + +/* + * putstr.c + */ + +void putstr(const char *s); diff --git a/sys/arch/evbmips/stand/sbmips/common/panic_putstr.c b/sys/arch/evbmips/stand/sbmips/common/panic_putstr.c new file mode 100644 index 000000000000..f874791ba062 --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/common/panic_putstr.c @@ -0,0 +1,42 @@ +/* $NetBSD: panic_putstr.c,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin Exp $ */ + +/* + * Copyright (c) 1999 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 + * for the NetBSD Project. + * 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. + */ + +#include +#include "common.h" + +void +panic(const char *fmt, ...) +{ + putstr("panic: "); + putstr(fmt); /* not a great attempt, but something */ + _rtt(); +} diff --git a/sys/arch/evbmips/stand/sbmips/common/putstr.c b/sys/arch/evbmips/stand/sbmips/common/putstr.c new file mode 100644 index 000000000000..587ce73ed9be --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/common/putstr.c @@ -0,0 +1,41 @@ +/* $NetBSD: putstr.c,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin Exp $ */ + +/* + * Copyright (c) 1999 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 + * for the NetBSD Project. + * 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. + */ + +#include +#include "common.h" + +void +putstr(const char *s) +{ + while (*s) + putchar(*s++); +} diff --git a/sys/arch/evbmips/stand/sbmips/common/start.S b/sys/arch/evbmips/stand/sbmips/common/start.S new file mode 100644 index 000000000000..19ecf4954858 --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/common/start.S @@ -0,0 +1,111 @@ +/* $NetBSD: start.S,v 1.1.1.1.4.2 2017/08/30 15:45:04 martin 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. The "Broadcom Corporation" name may not 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. + */ + +#define STACK_SIZE 8192 + +#include "include/asm.h" + + + .bss + + .comm stack_bottom,STACK_SIZE + + .text + +LEAF(start) + + la gp,_gp + + la sp,stack_bottom+STACK_SIZE-32 + +/* + * On entry: a0 = the firmware handle, a2 = firmware's + * for secondary bootstraps, a1 is the booted device handle + * Don't trash a0..a3 until main is called! + */ + + +#if defined(STANDALONE_PROGRAM) + /* + * This should not be used anywhere. + */ + +#error "don't do this." + +#else /* defined(STANDALONE_PROGRAM) */ + +#if !defined(PRIMARY_BOOTBLOCK) && !defined(UNIFIED_BOOTBLOCK) + + la sp,start + +#endif /* !defined(PRIMARY_BOOTBLOCK) && !defined(UNIFIED_BOOTBLOCK) */ + +#endif /* defined(STANDALONE_PROGRAM) */ + +/* + * Zero BSS + */ + + la t0,_edata /* t0 = address */ + la t1,_end + +1: sw zero,0(t0) + sw zero,4(t0) + sw zero,8(t0) + sw zero,16(t0) + add t0,16 + ble t0,t1,1b + + +/* + * Run the main program. + */ + + jal main /* transfer to C */ + +XLEAF(halt) + li t0,0xBFC00000 /* transfer back to firmware */ + j t0 +END(start) + + + +LEAF(__main) + j ra +END(__main) + +LEAF(_rtt) + li t0,0xBFC00000 + j t0 +END(_rtt) diff --git a/sys/arch/evbmips/stand/sbmips/netboot/Makefile b/sys/arch/evbmips/stand/sbmips/netboot/Makefile new file mode 100644 index 000000000000..ed78015b73f0 --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/netboot/Makefile @@ -0,0 +1,32 @@ +# $NetBSD: Makefile,v 1.1.1.1.4.2 2017/08/30 15:45:03 martin Exp $ + +PROG = netboot + +SRCS = start.S boot.c cfe_api.c cfe.c +SRCS+= dev_net.c conf.c devopen.c +SRCS+= if_cfe.c getsecs.c booted_dev.c + +BOOT_RELOC = ${UNIFIED_LOAD_ADDRESS} + +CLEANFILES+= ${PROG}.sym + +CPPFLAGS += ${UNIFIED_CPPFLAGS} -DSUPPORT_DHCP \ + -DBOOT_TYPE_NAME='"Network"' + +${PROG}: ${PROG}.sym + @echo creating ${PROG} from ${PROG}.sym... + @${OBJCOPY} --output-target=binary -R .reginfo -R .rel.dyn \ + ${PROG}.sym ${PROG} + @chmod 644 ${PROG} + @ls -l ${PROG} + @${CHECKSIZE_CMD} ${PROG}.sym ${PROG} ${UNIFIED_MAX_LOAD} \ + ${UNIFIED_MAX_TOTAL} || (rm -f ${PROG} ; false) + +SAMISCMAKEFLAGS= SA_INCLUDE_NET=yes SA_USE_CREAD=yes +.include "../Makefile.bootprogs" + +${PROG}.sym: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${LDSCRIPT} + ${_MKTARGET_LINK} + ${LD} -T ${LDSCRIPT} -N -e start -o ${PROG}.sym \ + ${OBJS} ${LIBSA} ${LIBZ} ${LIBSA} ${LIBKERN} + ${SIZE} ${PROG}.sym diff --git a/sys/arch/evbmips/stand/sbmips/netboot/conf.c b/sys/arch/evbmips/stand/sbmips/netboot/conf.c new file mode 100644 index 000000000000..5121f7b640d5 --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/netboot/conf.c @@ -0,0 +1,25 @@ +/* $NetBSD: conf.c,v 1.1.1.1.4.2 2017/08/30 15:45:03 martin Exp $ */ + +#include +#include + +#include +#include +#include + +struct fs_ops file_system[] = { + FS_OPS(nfs), +}; +int nfsys = 1; + +struct devsw devsw[] = { + { "net", net_strategy, net_open, net_close, net_ioctl }, +}; +int ndevs = 1; + +extern struct netif_driver prom_netif_driver; + +struct netif_driver *netif_drivers[] = { + &prom_netif_driver, +}; +int n_netif_drivers = (sizeof(netif_drivers) / sizeof(netif_drivers[0])); diff --git a/sys/arch/evbmips/stand/sbmips/netboot/dev_net.c b/sys/arch/evbmips/stand/sbmips/netboot/dev_net.c new file mode 100644 index 000000000000..68218c193123 --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/netboot/dev_net.c @@ -0,0 +1,251 @@ +/* $NetBSD: dev_net.c,v 1.1.1.1.4.2 2017/08/30 15:45:03 martin Exp $ */ + +/* + * Copyright (c) 1995 Gordon W. Ross + * 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 ``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. + */ + +/* + * This module implements a "raw device" interface suitable for + * use by the stand-alone I/O library NFS code. This interface + * does not support any "block" access, and exists only for the + * purpose of initializing the network interface, getting boot + * parameters, and performing the NFS mount. + * + * At open time, this does: + * + * find interface - netif_open() + * RARP for IP address - rarp_getipaddress() + * RPC/bootparams - callrpc(d, RPC_BOOTPARAMS, ...) + * RPC/mountd - nfs_mount(sock, ip, path) + * + * the root file handle from mountd is saved in a global + * for use by the NFS open code (NFS/lookup). + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include + +#ifndef SUN_BOOTPARAMS +void bootp(int); +#endif + +extern int debug; +extern int nfs_root_node[]; /* XXX - get from nfs_mount() */ + +/* + * Various globals needed by the network code: + */ + +#if 0 +/* for arp.c, rarp.c */ +u_char bcea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; +#endif + +struct in_addr myip; /* my ip address */ +struct in_addr rootip; /* root ip address */ +struct in_addr gateip; /* swap ip address */ +n_long netmask; /* subnet or net mask */ + +char rootpath[FNAME_SIZE]; +char hostname[FNAME_SIZE]; + +/* + * Local things... + */ +static int netdev_sock = -1; +static int netdev_opens; + +int net_getparams(int); + +/* + * Called by devopen after it sets f->f_dev to our devsw entry. + * This opens the low-level device and sets f->f_devdata. + * This is declared with variable arguments... + */ +int +net_open(struct open_file *f, ...) +{ + va_list ap; + char *devname; /* Device part of file name (or NULL). */ + int error = 0; + + va_start(ap, f); + devname = va_arg(ap, char*); + va_end(ap); + +#ifdef NETIF_DEBUG + if (debug) + printf("net_open: %s\n", devname); +#endif + + /* On first open, do netif open, mount, etc. */ + if (netdev_opens == 0) { + /* Find network interface. */ + if (netdev_sock < 0) { + netdev_sock = netif_open(devname); + if (netdev_sock < 0) { + printf("net_open: netif_open() failed\n"); + return (ENXIO); + } + if (debug) + printf("net_open: netif_open() succeeded\n"); + } + if (rootip.s_addr == 0) { + /* Get root IP address, and path, etc. */ + error = net_getparams(netdev_sock); + if (error) { + /* getparams makes its own noise */ + goto fail; + } + /* Get the NFS file handle (mountd). */ + error = nfs_mount(netdev_sock, rootip, rootpath); + if (error) { + error = errno; + printf("net_open: NFS mount error=%d\n", error); + rootip.s_addr = 0; + fail: + netif_close(netdev_sock); + netdev_sock = -1; + return (error); + } + if (debug) + printf("net_open: NFS mount succeeded\n"); + } + } + netdev_opens++; + f->f_devdata = nfs_root_node; + return (error); +} + +int +net_close(struct open_file *f) +{ + +#ifdef NETIF_DEBUG + if (debug) + printf("net_close: opens=%d\n", netdev_opens); +#endif + + /* On last close, do netif close, etc. */ + f->f_devdata = NULL; + /* Extra close call? */ + if (netdev_opens <= 0) + return (0); + netdev_opens--; + /* Not last close? */ + if (netdev_opens > 0) + return(0); + rootip.s_addr = 0; + if (netdev_sock >= 0) { + if (debug) + printf("net_close: calling netif_close()\n"); + netif_close(netdev_sock); + netdev_sock = -1; + } + return (0); +} + +int +net_ioctl(struct open_file *a, u_long b, void *c) +{ + return EIO; +} + +int +net_strategy(void *a, int b, daddr_t c, size_t d, void *e, size_t *f) +{ + return EIO; +} + +int +net_getparams(int sock) +{ + /* + * Get info for NFS boot: our IP address, our hostname, + * server IP address, and our root path on the server. + * There are two ways to do this: The old, Sun way, + * and the more modern, BOOTP way. (RFC951, RFC1048) + */ + +#ifdef SUN_BOOTPARAMS + /* Get our IP address. (rarp.c) */ + if (rarp_getipaddress(sock)) { + printf("net_open: RARP failed\n"); + return (EIO); + } +#else /* BOOTPARAMS */ + /* + * Get boot info using BOOTP. (RFC951, RFC1048) + * This also gets the server IP address, gateway, + * root path, etc. + */ + bootp(sock); + if (myip.s_addr == 0) { + printf("net_open: BOOTP failed\n"); + return (EIO); + } +#endif /* BOOTPARAMS */ + + printf("boot: client addr: %s\n", inet_ntoa(myip)); + +#ifdef SUN_BOOTPARAMS + /* Get our hostname, server IP address, gateway. */ + if (bp_whoami(sock)) { + printf("net_open: bootparam/whoami RPC failed\n"); + return (EIO); + } +#endif /* BOOTPARAMS */ + + printf("boot: client name: %s\n", hostname); + if (gateip.s_addr) { + printf("boot: subnet mask: %s\n", intoa(netmask)); + printf("boot: net gateway: %s\n", inet_ntoa(gateip)); + } + +#ifdef SUN_BOOTPARAMS + /* Get the root pathname. */ + if (bp_getfile(sock, "root", &rootip, rootpath)) { + printf("net_open: bootparam/getfile RPC failed\n"); + return (EIO); + } +#endif /* BOOTPARAMS */ + + printf("boot: server addr: %s\n", inet_ntoa(rootip)); + printf("boot: server path: %s\n", rootpath); + + return (0); +} diff --git a/sys/arch/evbmips/stand/sbmips/netboot/devopen.c b/sys/arch/evbmips/stand/sbmips/netboot/devopen.c new file mode 100644 index 000000000000..549cbf1c08de --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/netboot/devopen.c @@ -0,0 +1,158 @@ +/* $NetBSD: devopen.c,v 1.1.1.1.4.2 2017/08/30 15:45:03 martin 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. 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. + * + * @(#)devopen.c 8.1 (Berkeley) 6/10/93 + */ + +#include + +/* + * Decode the string 'fname', open the device and return the remaining + * file name if any. + */ +int +devopen(struct open_file *f, const char *fname, char **file) + /* file: out */ +{ + register char *cp; + register struct devsw *dp; +#if 0 + register char *ncp; + register int c, i; + char namebuf[20]; +#endif + int ctlr = 0, unit = 0, part = 0; + int rc; + + cp = (char *)fname; +#if 0 + ncp = namebuf; + + /* look for a string like '5/rz0/vmunix' or '5/rz3f/vmunix */ + if ((c = *cp) >= '0' && c <= '9') { + ctlr = c - '0'; + /* skip the '/' */ + if (*++cp != '/') + return (ENXIO); + cp++; + while ((c = *cp) != '\0') { + if (c == '/') + break; + if (c >= '0' && c <= '9') { + /* read unit number */ + unit = c - '0'; + + /* look for a partition */ + if ((c = *++cp) >= 'a' && c <= 'h') { + part = c - 'a'; + c = *++cp; + } + if (c != '/') + return (ENXIO); + break; + } + if (ncp < namebuf + sizeof(namebuf) - 1) + *ncp++ = c; + cp++; + } + *ncp = '\0'; + /* + * XXX + * pulling strchr from the C library, should pull from libkern. + */ + } else if (strchr(cp, '(')) { + /* expect a string like 'rz(0,0,0)vmunix' */ + while ((c = *cp) != '\0') { + if (c == '(') { + cp++; + break; + } + if (ncp < namebuf + sizeof(namebuf) - 1) + *ncp++ = c; + cp++; + } + + /* get controller number */ + if ((c = *cp) >= '0' && c <= '9') { + ctlr = c - '0'; + c = *++cp; + } + + if (c == ',') { + /* get SCSI device number */ + if ((c = *++cp) >= '0' && c <= '9') { + unit = c - '0'; + c = *++cp; + } + + if (c == ',') { + /* get partition number */ + if ((c = *++cp) >= '0' && c <= '9') { + part = c - '0'; + c = *++cp; + } + } + } + if (c != ')') + return (ENXIO); + cp++; + *ncp = '\0'; + } else { +#endif + dp = devsw; + ctlr = unit = part = 0; + goto fnd; +#if 0 + } + + for (dp = devsw, i = 0; i < ndevs; dp++, i++) + if (dp->dv_name && strcmp(namebuf, dp->dv_name) == 0) + goto fnd; + printf("Unknown device '%s'\nKnown devices are:", namebuf); + for (dp = devsw, i = 0; i < ndevs; dp++, i++) + if (dp->dv_name) + printf(" %s", dp->dv_name); + printf("\n"); + return (ENXIO); +#endif + +fnd: + rc = (dp->dv_open)(f, ctlr, unit, part); + if (rc) + return (rc); + + f->f_dev = dp; + if (file && *cp != '\0') + *file = cp; + return (0); +} diff --git a/sys/arch/evbmips/stand/sbmips/netboot/getsecs.c b/sys/arch/evbmips/stand/sbmips/netboot/getsecs.c new file mode 100644 index 000000000000..2c8f41a3eb5c --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/netboot/getsecs.c @@ -0,0 +1,55 @@ +/* $NetBSD: getsecs.c,v 1.2.4.2 2017/08/30 15:45:03 martin Exp $ */ + +/* + * Copyright 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. The "Broadcom Corporation" name may not 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 "stand/common/cfe_api.h" + +satime_t +getsecs(void) +{ + long long time; + + time = cfe_getticks(); + + return (time / 10); +} diff --git a/sys/arch/evbmips/stand/sbmips/netboot/if_cfe.c b/sys/arch/evbmips/stand/sbmips/netboot/if_cfe.c new file mode 100644 index 000000000000..c73c9a31029f --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/netboot/if_cfe.c @@ -0,0 +1,149 @@ +/* $NetBSD: if_cfe.c,v 1.2.4.2 2017/08/30 15:45:03 martin Exp $ */ + +/* + * Copyright (c) 1997 Christopher G. Demetriou. All rights reserved. + * Copyright (c) 1993 Adam Glass + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Adam Glass. + * 4. The name of the Author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY Adam Glass ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL 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 +#include +#include + +#include "stand/common/common.h" +#include "stand/common/bbinfo.h" +#include "stand/common/cfe_api.h" +#include "stand/common/cfe_ioctl.h" + +int cfenet_probe(struct netif *, void *); +int cfenet_match(struct netif *, void *); +void cfenet_init(struct iodesc *, void *); +int cfenet_get(struct iodesc *, void *, size_t, saseconds_t); +int cfenet_put(struct iodesc *, void *, size_t); +void cfenet_end(struct netif *); + +extern struct netif_stats cfenet_stats[]; + +struct netif_dif cfenet_ifs[] = { +/* dif_unit dif_nsel dif_stats dif_private */ +{ 0, 1, &cfenet_stats[0], 0, }, +}; +#define NCFENET_IFS (sizeof(cfenet_ifs) / sizeof(cfenet_ifs[0])) + +struct netif_stats cfenet_stats[NCFENET_IFS]; + +struct netif_driver prom_netif_driver = { + "cfe", /* netif_bname */ + cfenet_match, /* netif_match */ + cfenet_probe, /* netif_probe */ + cfenet_init, /* netif_init */ + cfenet_get, /* netif_get */ + cfenet_put, /* netif_put */ + cfenet_end, /* netif_end */ + cfenet_ifs, /* netif_ifs */ + NCFENET_IFS /* netif_nifs */ +}; + +int +cfenet_match(struct netif *nif, void *machdep_hint) +{ + + return (1); +} + +int +cfenet_probe(struct netif *nif, void *machdep_hint) +{ + + return 0; +} + +int +cfenet_put(struct iodesc *desc, void *pkt, size_t len) +{ + + cfe_write(booted_dev_fd,pkt,len); + + return len; +} + + +int +cfenet_get(struct iodesc *desc, void *pkt, size_t len, saseconds_t timeout) +{ + satime_t t; + int cc; + + t = getsecs(); + cc = 0; + while (((getsecs() - t) < timeout) && !cc) { + cc = cfe_read(booted_dev_fd,pkt,len); + if (cc < 0) break; + break; + } + + return cc; +} + +void +cfenet_init(struct iodesc *desc, void *machdep_hint) +{ + u_int8_t eaddr[6]; + int res; + + res = cfe_ioctl(booted_dev_fd,IOCTL_ETHER_GETHWADDR,eaddr,sizeof(eaddr),NULL,0); + + if (res < 0) { + printf("boot: boot device name does not contain ethernet address.\n"); + goto punt; + } + + memcpy(desc->myea, eaddr,6); + + printf("boot: ethernet address: %s\n", ether_sprintf(desc->myea)); + return; + +punt: + halt(); + +} + +void +cfenet_end(struct netif *nif) +{ + + /* nothing to do */ +} diff --git a/sys/arch/evbmips/stand/sbmips/netboot/version b/sys/arch/evbmips/stand/sbmips/netboot/version new file mode 100644 index 000000000000..521f1fa57fc2 --- /dev/null +++ b/sys/arch/evbmips/stand/sbmips/netboot/version @@ -0,0 +1,7 @@ +$NetBSD: version,v 1.1.1.1.4.2 2017/08/30 15:45:03 martin Exp $ + +NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this +file is important - make sure the entries are appended on end, last item +is taken as the current. + +1.1: Initial version diff --git a/sys/arch/mips/conf/files.sibyte b/sys/arch/mips/conf/files.sibyte index cbae9b90543b..4b4cda43dd6a 100644 --- a/sys/arch/mips/conf/files.sibyte +++ b/sys/arch/mips/conf/files.sibyte @@ -66,6 +66,7 @@ attach xirtc at smbus device m41t81rtc attach m41t81rtc at smbus -file arch/sbmips/sbmips/rtc.c xirtc | m41t81rtc +# XXX move to arch/mips/sibyte? +file arch/evbmips/sbmips/rtc.c xirtc | m41t81rtc file arch/mips/sibyte/dev/sbbuswatch.c diff --git a/sys/arch/mips/include/pmap.h b/sys/arch/mips/include/pmap.h index b9106b3d0e74..b5a0e60e98c1 100644 --- a/sys/arch/mips/include/pmap.h +++ b/sys/arch/mips/include/pmap.h @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.69 2016/12/23 07:15:27 cherry Exp $ */ +/* $NetBSD: pmap.h,v 1.69.8.1 2017/08/30 15:45:04 martin Exp $ */ /* * Copyright (c) 1992, 1993 @@ -77,6 +77,7 @@ #ifdef _KERNEL_OPT #include "opt_multiprocessor.h" #include "opt_uvmhist.h" +#include "opt_cputype.h" #endif #include @@ -242,5 +243,16 @@ vaddr_t pmap_md_pool_phystov(paddr_t); #define POOL_VTOPHYS(va) pmap_md_pool_vtophys((vaddr_t)va) #define POOL_PHYSTOV(pa) pmap_md_pool_phystov((paddr_t)pa) +#ifdef MIPS64_SB1 +/* 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) +#endif + #endif /* _KERNEL */ #endif /* _MIPS_PMAP_H_ */ diff --git a/sys/arch/mips/sibyte/dev/sbbuswatch.c b/sys/arch/mips/sibyte/dev/sbbuswatch.c index 381e94334246..5fd38dcf2946 100644 --- a/sys/arch/mips/sibyte/dev/sbbuswatch.c +++ b/sys/arch/mips/sibyte/dev/sbbuswatch.c @@ -1,4 +1,4 @@ -/* $NetBSD: sbbuswatch.c,v 1.3 2016/07/21 17:02:47 christos Exp $ */ +/* $NetBSD: sbbuswatch.c,v 1.3.8.1 2017/08/30 15:45:03 martin Exp $ */ /* * Copyright (c) 2010, The NetBSD Foundation, Inc. All rights reserved. * @@ -38,6 +38,8 @@ #include #include +#include + #define READ_REG(rp) mips3_ld((register_t)(rp)) #define WRITE_REG(rp, val) mips3_sd((register_t)(rp), (val)) diff --git a/sys/arch/mips/sibyte/dev/sbmac.c b/sys/arch/mips/sibyte/dev/sbmac.c index b74a89840083..52791a92c097 100644 --- a/sys/arch/mips/sibyte/dev/sbmac.c +++ b/sys/arch/mips/sibyte/dev/sbmac.c @@ -1,4 +1,4 @@ -/* $NetBSD: sbmac.c,v 1.48 2017/02/20 08:25:57 ozaki-r Exp $ */ +/* $NetBSD: sbmac.c,v 1.48.6.1 2017/08/30 15:45:03 martin Exp $ */ /* * Copyright 2000, 2001, 2004 @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sbmac.c,v 1.48 2017/02/20 08:25:57 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sbmac.c,v 1.48.6.1 2017/08/30 15:45:03 martin Exp $"); #include "opt_inet.h" #include "opt_ns.h" @@ -75,6 +75,8 @@ __KERNEL_RCSID(0, "$NetBSD: sbmac.c,v 1.48 2017/02/20 08:25:57 ozaki-r Exp $"); #include #include +#include + /* Simple types */ typedef u_long sbmac_port_t; diff --git a/sys/arch/mips/sibyte/dev/sbscn.c b/sys/arch/mips/sibyte/dev/sbscn.c index 88cc4148e4e5..8afd1f168e96 100644 --- a/sys/arch/mips/sibyte/dev/sbscn.c +++ b/sys/arch/mips/sibyte/dev/sbscn.c @@ -1,4 +1,4 @@ -/* $NetBSD: sbscn.c,v 1.42 2016/07/21 17:02:47 christos Exp $ */ +/* $NetBSD: sbscn.c,v 1.42.8.1 2017/08/30 15:45:03 martin Exp $ */ /* * Copyright 2000, 2001 @@ -109,7 +109,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sbscn.c,v 1.42 2016/07/21 17:02:47 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sbscn.c,v 1.42.8.1 2017/08/30 15:45:03 martin Exp $"); #define SBSCN_DEBUG @@ -146,6 +146,8 @@ __KERNEL_RCSID(0, "$NetBSD: sbscn.c,v 1.42 2016/07/21 17:02:47 christos Exp $"); #include #include +#include + void sbscn_attach_channel(struct sbscn_softc *sc, int chan, int intr); #if defined(DDB) || defined(KGDB) static void sbscn_enable_debugport(struct sbscn_channel *ch); diff --git a/sys/arch/mips/sibyte/dev/sbsmbus.c b/sys/arch/mips/sibyte/dev/sbsmbus.c index 4aa502bdc543..6de0c3cdad78 100644 --- a/sys/arch/mips/sibyte/dev/sbsmbus.c +++ b/sys/arch/mips/sibyte/dev/sbsmbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: sbsmbus.c,v 1.16 2011/07/10 23:32:03 matt Exp $ */ +/* $NetBSD: sbsmbus.c,v 1.16.46.1 2017/08/30 15:45:03 martin Exp $ */ /* * Copyright 2002 Wasabi Systems, Inc. @@ -36,13 +36,13 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sbsmbus.c,v 1.16 2011/07/10 23:32:03 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sbsmbus.c,v 1.16.46.1 2017/08/30 15:45:03 martin Exp $"); #include #include #include -#include +#include #include #include diff --git a/sys/arch/mips/sibyte/dev/sbtimer.c b/sys/arch/mips/sibyte/dev/sbtimer.c index 1e855b4c9f67..f3e0a62ad864 100644 --- a/sys/arch/mips/sibyte/dev/sbtimer.c +++ b/sys/arch/mips/sibyte/dev/sbtimer.c @@ -1,4 +1,4 @@ -/* $NetBSD: sbtimer.c,v 1.20 2016/07/21 17:02:47 christos Exp $ */ +/* $NetBSD: sbtimer.c,v 1.20.8.1 2017/08/30 15:45:03 martin Exp $ */ /* * Copyright 2000, 2001 @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sbtimer.c,v 1.20 2016/07/21 17:02:47 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sbtimer.c,v 1.20.8.1 2017/08/30 15:45:03 martin Exp $"); #include #include @@ -47,6 +47,8 @@ __KERNEL_RCSID(0, "$NetBSD: sbtimer.c,v 1.20 2016/07/21 17:02:47 christos Exp $" #include #include +#include + struct sbtimer_softc { device_t sc_dev; void *sc_intrhand; diff --git a/sys/arch/mips/sibyte/dev/sbwdog.c b/sys/arch/mips/sibyte/dev/sbwdog.c index 6a7ed44314ba..948968b63af7 100644 --- a/sys/arch/mips/sibyte/dev/sbwdog.c +++ b/sys/arch/mips/sibyte/dev/sbwdog.c @@ -1,4 +1,4 @@ -/* $NetBSD: sbwdog.c,v 1.14 2016/07/21 17:02:47 christos Exp $ */ +/* $NetBSD: sbwdog.c,v 1.14.8.1 2017/08/30 15:45:03 martin Exp $ */ /* * Copyright (c) 2002 Wasabi Systems, Inc. @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sbwdog.c,v 1.14 2016/07/21 17:02:47 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sbwdog.c,v 1.14.8.1 2017/08/30 15:45:03 martin Exp $"); #include "locators.h" @@ -57,6 +57,8 @@ __KERNEL_RCSID(0, "$NetBSD: sbwdog.c,v 1.14 2016/07/21 17:02:47 christos Exp $") #include #include +#include + #define SBWDOG_DEFAULT_PERIOD 5 /* Default to 5 seconds. */ struct sbwdog_softc { diff --git a/sys/arch/mips/sibyte/pci/sbbrz_pci.c b/sys/arch/mips/sibyte/pci/sbbrz_pci.c index 498556de1530..a766bbb8330a 100644 --- a/sys/arch/mips/sibyte/pci/sbbrz_pci.c +++ b/sys/arch/mips/sibyte/pci/sbbrz_pci.c @@ -1,4 +1,4 @@ -/* $NetBSD: sbbrz_pci.c,v 1.7 2016/07/21 17:02:47 christos Exp $ */ +/* $NetBSD: sbbrz_pci.c,v 1.7.8.1 2017/08/30 15:45:04 martin Exp $ */ /* * Copyright 2000, 2001 @@ -64,7 +64,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: sbbrz_pci.c,v 1.7 2016/07/21 17:02:47 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sbbrz_pci.c,v 1.7.8.1 2017/08/30 15:45:04 martin Exp $"); #include #include @@ -81,6 +81,8 @@ __KERNEL_RCSID(0, "$NetBSD: sbbrz_pci.c,v 1.7 2016/07/21 17:02:47 christos Exp $ #include #include +#include + void sbbrz_pci_attach_hook(device_t, device_t, struct pcibus_attach_args *); static int sbbrz_pci_bus_maxdevs(void *, int); diff --git a/usr.sbin/installboot/installboot.8 b/usr.sbin/installboot/installboot.8 index 93593ce72c8e..feae93324cf2 100644 --- a/usr.sbin/installboot/installboot.8 +++ b/usr.sbin/installboot/installboot.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: installboot.8,v 1.92 2017/03/15 11:22:47 wiz Exp $ +.\" $NetBSD: installboot.8,v 1.92.4.1 2017/08/30 15:45:04 martin Exp $ .\" -.\" Copyright (c) 2002-2015 The NetBSD Foundation, Inc. +.\" Copyright (c) 2002-2017 The NetBSD Foundation, Inc. .\" All rights reserved. .\" .\" This code is derived from software contributed to The NetBSD Foundation @@ -527,6 +527,37 @@ is not found. . .El . +.Ss Nx Ns Tn /evbmips files +. +The +.Nx Ns Tn /evbmips +bootstrap files currently only apply to the SBMIPS kernels for the +SiByte/Broadcom BCM1250 and BCM1480 CPUs. +.Bl -tag -width /usr/mdec/sbmips/bootxx_cd9660 +. +.It Pa /usr/mdec/sbmips/boot +.Nx Ns Tn /evbmips +secondary bootstrap for +.Sy FFSv1 , +.Sy FFSv2 , +.Sy LFSv1 , +and +.Sy LFSv2 . +.It Pa /usr/mdec/sbmips/bootxx_cd9660 +SBMIPS primary bootstrap for ISO 9660 file system. +.It Pa /usr/mdec/sbmips/bootxx_ffs +SBMIPS primary bootstrap for FFSv1 and FFSv2 file system. +.It Pa /usr/mdec/sbmips/bootxx_lfs +SBMIPS primary bootstrap for LFSv1 and LFSv2 file system. +.It Pa /usr/mdec/sbmips/netboot +SBMIPS primary bootstrap for network root. +.Pp +Note that +.Nm +does not currently support evbmips directly. +. +.El +. .Ss Nx Ns Tn /hppa files . .Bl -tag -width /usr/mdec/bootxx_ustarfs