Module Name:    src
Committed By:   rin
Date:           Fri Apr  2 07:00:33 UTC 2021

Modified Files:
        src/doc: CHANGES
Added Files:
        src/sys/arch/evbppc/conf: DHT Makefile.dht.inc files.dht std.dht
        src/sys/arch/evbppc/dht: autoconf.c locore.S machdep.c
        src/sys/arch/evbppc/include: dht.h

Log Message:
evbppc: Add support for DHT Walnut 405GP evaluation board.
(Digital Home Technologies PCB 01070201 Rev. 1.1)

Official web page seems gone, but analyses by Linux people are at:

- https://elinux.org/DHT-Walnut
- 
http://web.archive.org/web/20070225171826/http://supernova.stanford.edu/dingdong/

The board features:

- 266MHz PowerPC 405GP processor
- one PC133 SDRAM slot
- two 32-bit 5V PCI slot
- on-chip ethernet controller with DP83843 PHY
- on-chip serial port / GPIO controller
- on-board PDC20265 IDE controller

Hardware limitations:

- no MAC address assigned
- no RTC present

Known problem:

- atabus(4) channels cannot be attached to pdcide(4) for cold boot

dmesg:

- https://dmesgd.nycbug.org/index.cgi?do=view&id=5997

Have fun!


To generate a diff of this commit:
cvs rdiff -u -r1.2788 -r1.2789 src/doc/CHANGES
cvs rdiff -u -r0 -r1.1 src/sys/arch/evbppc/conf/DHT \
    src/sys/arch/evbppc/conf/Makefile.dht.inc \
    src/sys/arch/evbppc/conf/files.dht src/sys/arch/evbppc/conf/std.dht
cvs rdiff -u -r0 -r1.1 src/sys/arch/evbppc/dht/autoconf.c \
    src/sys/arch/evbppc/dht/locore.S src/sys/arch/evbppc/dht/machdep.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/evbppc/include/dht.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2788 src/doc/CHANGES:1.2789
--- src/doc/CHANGES:1.2788	Tue Mar 30 23:31:53 2021
+++ src/doc/CHANGES	Fri Apr  2 07:00:33 2021
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2788 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2789 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -343,3 +343,5 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 	nsd: Import 4.3.5. [christos 20210315]
 	unbound(8): Import 1.13.1. [christos 20210315]
 	OpenSSL: Imported 1.1.1k. [christos 20210325]
+	evbppc: Add support for DHT Walnut 405GP evaluation board.
+		[rin 20210402]

Added files:

Index: src/sys/arch/evbppc/conf/DHT
diff -u /dev/null src/sys/arch/evbppc/conf/DHT:1.1
--- /dev/null	Fri Apr  2 07:00:33 2021
+++ src/sys/arch/evbppc/conf/DHT	Fri Apr  2 07:00:33 2021
@@ -0,0 +1,237 @@
+#	$NetBSD: DHT,v 1.1 2021/04/02 07:00:33 rin Exp $
+#
+#	DHT --- DHT Walnut 405GP Evaluation Board
+#		(Digital Home Technologies PCB 01070201 Rev. 1.1)
+#
+
+include 	"arch/evbppc/conf/std.dht"
+
+options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
+
+#ident 		"DHT-$Revision: 1.1 $"
+
+maxusers	32
+
+
+#
+# Standard system options
+#
+
+options 	INSECURE		# disable kernel security levels
+options 	NTP			# NTP phase/frequency locked loop
+options 	KTRACE			# system call tracing via ktrace(1)
+
+options 	SYSVMSG			# System V message queues
+options 	SYSVSEM			# System V semaphores
+options 	SYSVSHM			# System V shared memory
+
+options 	MODULAR			# new style module(7) framework
+#options 	MODULAR_DEFAULT_AUTOLOAD
+#options 	USERCONF		# userconf(4) support
+#options	PIPE_SOCKETPAIR		# smaller, but slower pipe(2)
+#options 	SYSCTL_INCLUDE_DESCR	# Include sysctl descriptions in kernel
+
+#options 	UVMHIST
+#options 	UVMHIST_PRINT
+
+
+# Alternate buffer queue strategies for better responsiveness under high
+# disk I/O load.
+#options 	BUFQ_READPRIO
+options 	BUFQ_PRIOCSCAN
+
+#
+# Diagnostic/debugging support options
+#
+
+options 	DIAGNOSTIC		# cheap kernel consistency checks
+#options 	DEBUG			# expensive debugging checks/support
+options 	DDB			# in-kernel debugger
+options 	DDB_HISTORY_SIZE=512	# enable history editing in DDB
+#options 	TRAP_PANICWAIT
+makeoptions	COPY_SYMTAB=1	# size for embedded symbol table
+
+makeoptions	DEBUG="-g"		# compile full symbol table
+
+
+#
+# Compatibility options
+#
+
+include 	"conf/compat_netbsd13.config"
+#options 	COMPAT_386BSD_MBRPART	# recognize old partition ID
+
+#
+# File systems
+#
+
+file-system 	FFS		# UFS
+file-system 	EXT2FS		# second extended file system (linux)
+file-system 	LFS		# log-structured file system
+file-system 	MFS		# memory file system
+file-system 	NFS		# Network File System client
+file-system 	CD9660		# ISO 9660 + Rock Ridge file system
+file-system 	MSDOSFS		# MS-DOS file system
+file-system 	FDESC		# /dev/fd
+file-system 	KERNFS		# /kern
+file-system 	NULLFS		# loopback file system
+file-system 	OVERLAY		# overlay file system
+file-system	PUFFS		# Userspace file systems (e.g. ntfs-3g & sshfs)
+file-system 	PROCFS		# /proc
+file-system 	UMAPFS		# NULLFS + uid and gid remapping
+file-system 	UNION		# union file system
+file-system	PTYFS		# /dev/pts/N support
+file-system	TMPFS		# Efficient memory file-system
+#file-system	NTFS		# Windows NT file system (experimental)
+
+
+#
+# File system options
+#
+
+options 	QUOTA		# legacy UFS quotas
+options 	QUOTA2		# new, in-filesystem UFS quotas
+options 	FFS_EI			# FFS Endian Independent support
+options 	WAPBL		# File system journaling support
+options 	NFSSERVER		# Network File System server
+#options 	FFS_NO_SNAPSHOT		# No FFS snapshot support
+options 	EXT2FS_SYSTEM_FLAGS	# makes ext2fs file flags (append and
+					# immutable) behave as system flags.
+options 	NFS_BOOT_DHCP		# Support DHCP NFS root
+
+
+#
+# Networking options
+#
+
+options 	GATEWAY		# packet forwarding
+options 	INET		# IP + ICMP + TCP + UDP
+options 	INET6		# IPv6
+#options 	IPSEC		# IP security
+#options 	IPSEC_DEBUG	# debug for IP security
+#options 	MROUTING	# IP multicast routing
+#options 	PIM		# Protocol Independent Multicast
+#options 	NETATALK	# AppleTalk networking protocols
+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 	TCP_DEBUG	# Record last TCP_NDEBUG packets with SO_DEBUG
+
+
+#
+# Kernel root file system and dump configuration.
+#
+
+#config		netbsd	root on ? type ?
+config		netbsd	root on wd0a type ffs
+#config		netbsd	root on emac0 type nfs
+
+
+#
+# Device configuration
+#
+
+plb0 at root				# Processor Local Bus
+cpu0	at plb?				# CPU
+ecc0	at plb? irq 17			# On-chip ECC controller
+pchb0	at plb?				# PCI-Host bridges
+
+# On-chip Peripheral Bus support
+opb*	at plb?				# On-chip Peripheral Bus
+wdog*	at opb?				# Watchdog timer
+com*	at opb? addr ? irq ?		# UARTs
+emac0	at opb? addr ? irq ?		# Ethernet Media Access Controller
+#options 	EMAC_EVENT_COUNTERS
+opbgpio0 at opb? addr ? irq ?		# On-chip GPIO controller
+gpio*	at opbgpio?			# GPIO framework
+	# GPIO pins 0-8 go to J5 header. Pins 0 and 1 are also connected to
+	# Power and Media LEDs, respectively (negative logic).
+
+# PCI bus support
+pci*	at pchb?
+options 	PCIVERBOSE		# verbose PCI device autoconfig messages
+#options 	PCI_CONFIG_DUMP		# verbosely dump PCI config space
+options 	PCI_NETBSD_CONFIGURE	# Do not rely on BIOS/whatever
+					# to configure PCI devices
+#options 	PCI_CONFIGURE_VERBOSE	# Show PCI config information
+
+pdcide* at pci? dev ? function ?	# Promise IDE controllers
+
+# ATA (IDE) bus support
+atabus* at ata?
+wd*	at atabus? drive ?
+
+# MII/PHY support
+nsphyter* at mii? phy ?			# NS83843 PHYs
+options 	MIIVERBOSE		# verbose PHY autoconfig messages
+
+#
+# Random useful PCI devices known to work.
+#
+
+ppb*	at pci? dev ? function ?	# PCI-PCI{,e} bridges
+pci*	at ppb?
+
+ahcisata* at pci? dev ? function ?	# AHCI SATA controllers
+siisata* at pci? dev ? function ?	# SiI SteelVine controllers
+
+wm*	at pci? dev ? function ?	# Intel 82543/82544 gigabit
+igphy*	at mii? phy ?			# Intel IGP01E1000
+ukphy*	at mii? phy ?			# generic unknown PHYs
+
+xhci*	at pci?	dev ? function ?	# eXtensible Host Controller
+usb*	at xhci?
+
+# USB Hubs
+uhub*	at usb?
+uhub*	at uhub? port ?
+
+# USB Mass Storage
+umass*	at uhub? port ? configuration ? interface ?
+scsibus* at umass?
+sd*	at scsibus? target ? lun ?	# SCSI disk drives
+
+
+#
+# Pseudo devices
+#
+
+pseudo-device	crypto			# /dev/crypto device
+pseudo-device	swcrypto		# software crypto implementation
+
+# disk/mass storage pseudo-devices
+#pseudo-device	ccd			# concatenated/striped disk devices
+#pseudo-device	cgd			# cryptographic disk devices
+#pseudo-device	raid			# RAIDframe disk driver
+#options 	RAID_AUTOCONFIG		# auto-configuration of RAID components
+#pseudo-device	fss			# file system snapshot device
+#pseudo-device	md			# memory disk device
+pseudo-device	vnd			# disk-like interface to files
+
+# network pseudo-devices
+pseudo-device	loop			# network loopback
+pseudo-device	bpfilter		# packet filter
+pseudo-device 	carp			# Common Address Redundancy Protocol
+pseudo-device	npf			# NPF packet filter
+pseudo-device	ppp			# Point-to-Point Protocol
+pseudo-device	pppoe			# PPP over Ethernet (RFC 2516)
+pseudo-device	sl			# Serial Line IP
+pseudo-device	irframetty		# IrDA frame line discipline
+pseudo-device	tap			# virtual ethernet
+pseudo-device	tun			# network tunneling over tty
+pseudo-device	gre			# generic L3 over IP tunnel
+pseudo-device	gif			# IPv[46] over IPv[46] tunnel (RFC 1933)
+#pseudo-device	faith			# IPv[46] TCP relay translation i/f
+pseudo-device	stf			# 6to4 IPv6 over IPv4 encapsulation
+pseudo-device	vlan			# IEEE 802.1q encapsulation
+pseudo-device	bridge			# simple inter-network bridging
+pseudo-device	vether			# Virtual Ethernet for bridge
+pseudo-device	agr			# IEEE 802.3ad link aggregation
+
+# miscellaneous pseudo-devices
+pseudo-device	pty			# pseudo-terminals
+pseudo-device	clockctl		# user control of clock subsystem
+pseudo-device	ksyms			# /dev/ksyms
+pseudo-device	putter			# for puffs and pud
+
+include "dev/veriexec.config"
Index: src/sys/arch/evbppc/conf/Makefile.dht.inc
diff -u /dev/null src/sys/arch/evbppc/conf/Makefile.dht.inc:1.1
--- /dev/null	Fri Apr  2 07:00:33 2021
+++ src/sys/arch/evbppc/conf/Makefile.dht.inc	Fri Apr  2 07:00:33 2021
@@ -0,0 +1,8 @@
+#	$NetBSD: Makefile.dht.inc,v 1.1 2021/04/02 07:00:33 rin Exp $
+
+CFLAGS+=-mcpu=405
+AFLAGS+=-mcpu=405
+TEXTADDR?=	100000
+
+SYSTEM_FIRST_OBJ=	locore.o
+SYSTEM_FIRST_SFILE=	${THISPPC}/dht/locore.S
Index: src/sys/arch/evbppc/conf/files.dht
diff -u /dev/null src/sys/arch/evbppc/conf/files.dht:1.1
--- /dev/null	Fri Apr  2 07:00:33 2021
+++ src/sys/arch/evbppc/conf/files.dht	Fri Apr  2 07:00:33 2021
@@ -0,0 +1,21 @@
+#	$NetBSD: files.dht,v 1.1 2021/04/02 07:00:33 rin Exp $
+#
+# DHT Walnut-specific configuration info
+
+file	arch/evbppc/dht/autoconf.c
+file	arch/evbppc/dht/machdep.c
+file	arch/powerpc/ibm4xx/ibm4xx_autoconf.c
+file	arch/powerpc/ibm4xx/ibm40x_machdep.c
+file	arch/powerpc/ibm4xx/ibm4xx_machdep.c
+
+# Memory Disk for install kernel
+file	dev/md_root.c				memory_disk_hooks
+
+# Machine-independent ATA drivers
+include	"dev/ata/files.ata"
+
+# Machine-independent SCSI drivers
+include	"dev/scsipi/files.scsipi"
+
+# Machine-independent USB drivers
+include	"dev/usb/files.usb"
Index: src/sys/arch/evbppc/conf/std.dht
diff -u /dev/null src/sys/arch/evbppc/conf/std.dht:1.1
--- /dev/null	Fri Apr  2 07:00:33 2021
+++ src/sys/arch/evbppc/conf/std.dht	Fri Apr  2 07:00:33 2021
@@ -0,0 +1,32 @@
+#	$NetBSD: std.dht,v 1.1 2021/04/02 07:00:33 rin Exp $
+#
+# Standard/required options for DHT Walnut 405GP Evaluation Board.
+
+machine	evbppc powerpc
+include		"conf/std"	# MI standard options
+
+# standard ("mandatory") kernel options.
+options 	PPC_IBM4XX	# IBM 40x family
+
+options 	IBM405_ERRATA77
+
+# Executable support:
+options 	EXEC_ELF32	# (native) ELF32 binary support
+options 	EXEC_AOUT	# (native) a.out binary support (deprecated)
+options 	EXEC_SCRIPT	# shell script support
+
+makeoptions	TEXTADDR=0x100000
+makeoptions	BOARDTYPE="dht"
+makeoptions	PPCDIR="ibm4xx"
+makeoptions	NEED_BINARY="yes"
+
+options 	PPC_INTR_IMPL="<powerpc/intr.h>"
+options 	PPC_PCI_MACHDEP_IMPL="<powerpc/pci_machdep.h>"
+options 	KERNBASE=0x100000
+
+options 	INTSTK=16384
+
+options 	EVBPPC_HAS_MBR
+
+include		"arch/powerpc/conf/files.ibm4xx"
+include		"arch/evbppc/conf/files.dht"

Index: src/sys/arch/evbppc/dht/autoconf.c
diff -u /dev/null src/sys/arch/evbppc/dht/autoconf.c:1.1
--- /dev/null	Fri Apr  2 07:00:33 2021
+++ src/sys/arch/evbppc/dht/autoconf.c	Fri Apr  2 07:00:33 2021
@@ -0,0 +1,79 @@
+/*	$NetBSD: autoconf.c,v 1.1 2021/04/02 07:00:33 rin Exp $	*/
+
+/*
+ * Taken from src/sys/arch/evbppc/walnut/autoconf.c:
+ *	NetBSD: autoconf.c,v 1.26 2021/03/30 05:14:00 rin Exp
+ */
+
+/*
+ * Copyright (C) 1995, 1996 Wolfgang Solfrank.
+ * Copyright (C) 1995, 1996 TooLs GmbH.
+ * 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 TooLs GmbH.
+ * 4. The name of TooLs GmbH may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.1 2021/04/02 07:00:33 rin Exp $");
+
+#include <sys/param.h>
+#include <sys/device.h>
+#include <sys/systm.h>
+
+#include <machine/dht.h>
+
+#include <powerpc/spr.h>
+#include <powerpc/ibm4xx/spr.h>
+
+#include <powerpc/ibm4xx/cpu.h>
+#include <powerpc/ibm4xx/dcr4xx.h>
+#include <powerpc/ibm4xx/dev/plbvar.h>
+
+/*
+ * Determine device configuration for a machine.
+ */
+void
+cpu_configure(void)
+{
+
+	intr_init();
+	calc_delayconst();
+
+	/* Make sure that timers run at CPU frequency */
+	mtdcr(DCR_CPC0_CR1, mfdcr(DCR_CPC0_CR1) & ~CPC0_CR1_CETE);
+
+	if (config_rootfound("plb", NULL) == NULL)
+		panic("%s: plb not configured", __func__);
+
+	genppc_cpu_configure();
+}
+
+void
+device_register(device_t dev, void *aux)
+{
+
+	ibm4xx_device_register(dev, aux, DHT_COM_FREQ);
+}
Index: src/sys/arch/evbppc/dht/locore.S
diff -u /dev/null src/sys/arch/evbppc/dht/locore.S:1.1
--- /dev/null	Fri Apr  2 07:00:33 2021
+++ src/sys/arch/evbppc/dht/locore.S	Fri Apr  2 07:00:33 2021
@@ -0,0 +1,193 @@
+/*	$NetBSD: locore.S,v 1.1 2021/04/02 07:00:33 rin Exp $	*/
+
+/*
+ * Taken from src/sys/arch/powerpc/ibm4xx/openbios/locore.s:
+ *	NetBSD: locore.S,v 1.17 2021/03/30 01:57:20 rin Exp
+ */
+
+/*
+ * Copyright 2001 Wasabi Systems, Inc.
+ * All rights reserved.
+ *
+ * Written by Eduardo Horvath and 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.
+ */
+
+/*
+ * Copyright (C) 1995, 1996 Wolfgang Solfrank.
+ * Copyright (C) 1995, 1996 TooLs GmbH.
+ * 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 TooLs GmbH.
+ * 4. The name of TooLs GmbH may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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.
+ */
+
+#ifdef PPC_4XX_NOCACHE
+#error Not tested.
+#endif
+
+#include "assym.h"
+#include "ksyms.h"
+
+#ifdef _KERNEL_OPT
+#include "opt_ddb.h"
+#include "opt_modular.h"
+#include "opt_ppcparam.h"
+#endif
+
+#include <machine/param.h>
+#include <machine/asm.h>
+#include <machine/psl.h>
+#include <machine/trap.h>
+
+#include <powerpc/spr.h>
+#include <powerpc/ibm4xx/spr.h>
+
+#include <powerpc/ibm4xx/dcr4xx.h>
+
+/*
+ * This symbol is here for the benefit of kvm_mkdb, and is supposed to
+ * mark the start of kernel text.
+ */
+	.text
+	.globl	_C_LABEL(kernel_text)
+_C_LABEL(kernel_text):
+
+/*
+ * Startup entry.  Note, this must be the first thing in the text
+ * segment!
+ */
+	.text
+	.globl	__start
+__start:
+	li	%r0,0
+	mtmsr	%r0			/* Disable FPU/MMU/exceptions */
+	isync
+
+	/*
+	 * Errata 213:  Incorrect data may be flushed from the data cache.
+	 * Cores:       PPC405D5X1, PPC405D5X2
+	 * Workaround:  #1, CCR0 modification sequence #2
+	 * Note:        Meaning of bits we need to set is undocumented.
+	 */
+	sync
+	mfccr0  %r0
+	oris    %r0,%r0,0x50000000@h
+	mtccr0  %r0
+	isync
+
+	/* PPC405GP errata, item #58.
+	 * Load string instructions may write incorrect data into the last GPR
+	 * targeted in the operation.
+	 * Workaround: set OCM0_DSCNTL[DSEN]=0 and OCM0_DSCNTL[DOF]=0 */
+	li %r0,0
+	mtdcr	DCR_OCM0_DSCNTL, %r0  	/* Disable Data access to OCM */
+	mtdcr	DCR_OCM0_ISCNTL, %r0  	/* Disable Instruction access to OCM.
+					   Just in case */
+#ifdef PPC_4XX_NOCACHE
+	/* Disable all caches for physical addresses */
+	li	%r0,0
+#else
+	/* Allow cacheing for only the first 2GB of RAM */
+	lis	%r0,0xffff
+#endif
+	mtdccr	%r0
+	mticcr	%r0
+
+	/* Invalidate all TLB entries */
+	tlbia
+	sync
+	isync
+
+	/* Get start of BSS */
+	lis	%r3,_C_LABEL(_edata)-4@ha
+	addi	%r3,%r3,_C_LABEL(_edata)-4@l
+	/* Get end of kernel memory */
+	lis	%r8,_C_LABEL(end)@ha
+	addi	%r8,%r8,_C_LABEL(end)@l
+	/* Zero BSS */
+	li	%r4,0
+2:	stwu	%r4,4(%r3)
+	cmpw	%r3,%r8
+	bne+	2b
+
+#if NKSYMS > 0 || defined(DDB) || defined(MODULAR)
+	/*
+	 * If we had symbol table location we'd store it here and would've
+	 * adjusted r8 here.
+	 */
+	lis	%r7,_C_LABEL(startsym)@ha
+	addi	%r7,%r7,_C_LABEL(startsym)@l
+	stw	%r8,0(%r7)
+	lis	%r7,_C_LABEL(endsym)@ha
+	addi	%r7,%r7,_C_LABEL(endsym)@l
+	stw	%r8,0(%r7)
+#endif
+
+	/* Set kernel MMU context. */
+	li	%r0,KERNEL_PID
+	mtpid	%r0
+	sync
+
+	INIT_CPUINFO(%r8,%r1,%r9,%r0)
+	mr	%r4,%r8
+
+	lis	%r3,__start@ha
+	addi	%r3,%r3,__start@l
+
+	mr	%r6,%r31		/* info_block address */
+	bl	_C_LABEL(initppc)
+	bl	_C_LABEL(main)
+
+loop:	b	loop			/* XXX not reached */
+
+#include <powerpc/ibm4xx/4xx_locore.S>
Index: src/sys/arch/evbppc/dht/machdep.c
diff -u /dev/null src/sys/arch/evbppc/dht/machdep.c:1.1
--- /dev/null	Fri Apr  2 07:00:33 2021
+++ src/sys/arch/evbppc/dht/machdep.c	Fri Apr  2 07:00:33 2021
@@ -0,0 +1,327 @@
+/*	$NetBSD: machdep.c,v 1.1 2021/04/02 07:00:33 rin Exp $	*/
+
+/*
+ * Taken from src/sys/arch/evbppc/walnut/machdep.c:
+ *	NetBSD: machdep.c,v 1.67 2021/03/30 05:08:16 rin Exp
+ */
+
+/*
+ * Copyright 2001, 2002 Wasabi Systems, Inc.
+ * All rights reserved.
+ *
+ * Written by Eduardo Horvath and 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.
+ */
+
+/*
+ * Copyright (C) 1995, 1996 Wolfgang Solfrank.
+ * Copyright (C) 1995, 1996 TooLs GmbH.
+ * 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 TooLs GmbH.
+ * 4. The name of TooLs GmbH may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.1 2021/04/02 07:00:33 rin Exp $");
+
+#include "opt_ddb.h"
+#include "opt_pci.h"
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/device.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/reboot.h>
+#include <sys/systm.h>
+
+#include <machine/dht.h>
+
+#include <powerpc/spr.h>
+#include <powerpc/ibm4xx/spr.h>
+
+#include <powerpc/ibm4xx/cpu.h>
+#include <powerpc/ibm4xx/dcr4xx.h>
+#include <powerpc/ibm4xx/ibm405gp.h>
+#include <powerpc/ibm4xx/openbios.h>
+#include <powerpc/ibm4xx/tlb.h>
+
+#include "com.h"
+#if NCOM > 0
+#include <sys/termios.h>
+#include <dev/ic/comreg.h>
+#include <dev/ic/comvar.h>
+#include <powerpc/ibm4xx/dev/comopbvar.h>
+#ifndef CONADDR
+#define	CONADDR		IBM405GP_UART0_BASE
+#endif
+#ifndef CONSPEED
+#define	CONSPEED	B115200
+#endif
+#ifndef CONMODE
+#define	CONMODE		TTYDEF_CFLAG
+#endif
+#endif /* NCOM > 0 */
+
+#include "emac.h"
+#if NEMAC > 0
+#include <net/if_ether.h>
+#endif
+
+#include "pci.h"
+#if NPCI > 0
+#ifndef PCI_NETBSD_CONFIGURE
+#error options PCI_NETBSD_CONFIGURE is mandatory.
+#endif
+#include <powerpc/ibm4xx/pci_machdep.h>
+#include <dev/pci/pciconf.h>
+#include <dev/pci/pcivar.h>
+#endif
+
+#define TLB_PG_SIZE 	(16 * 1024 * 1024)
+
+static u_int memsize;
+
+void initppc(vaddr_t, vaddr_t, char *, void *);
+
+/*
+ * Get memory size from SDRAM bank register.
+ */
+static u_int
+dht_memsize(void)
+{
+	u_int total = 0;
+	uint32_t val, addr;
+
+	for (addr = DCR_SDRAM0_B0CR; addr <= DCR_SDRAM0_B3CR; addr += 4) {
+		mtdcr(DCR_SDRAM0_CFGADDR, addr);
+		val = mfdcr(DCR_SDRAM0_CFGDATA);
+		if (val & SDRAM0_BnCR_EN)
+			total += SDRAM0_BnCR_SZ(val);
+	}
+	return total;
+}
+
+void
+consinit(void)
+{
+
+#if NCOM > 0
+	com_opb_cnattach(DHT_COM_FREQ, CONADDR, CONSPEED, CONMODE);
+#endif
+}
+
+void
+initppc(vaddr_t startkernel, vaddr_t endkernel, char *args, void *info_block)
+{
+
+	/* Disable all external interrupts */
+	mtdcr(DCR_UIC0_BASE + DCR_UIC_ER, 0);
+
+	memsize = dht_memsize();
+
+	/* Linear map kernel memory */
+	for (vaddr_t va = 0; va < endkernel; va += TLB_PG_SIZE)
+		ppc4xx_tlb_reserve(va, va, TLB_PG_SIZE, TLB_EX);
+
+	/* Map console after physmem (see pmap_tlbmiss()) */
+	ppc4xx_tlb_reserve(IBM405GP_UART0_BASE, roundup(memsize, TLB_PG_SIZE),
+	    TLB_PG_SIZE, TLB_I | TLB_G);
+
+	/* Disable all timers */
+	mtspr(SPR_TCR, 0);
+
+	ibm40x_memsize_init(memsize, startkernel);
+	ibm4xx_init(startkernel, endkernel, pic_ext_intr);
+
+#ifdef DDB
+	if (boothowto & RB_KDB)
+		Debugger();
+#endif
+
+	/* Look for the ibm4xx modules in the right place */
+	module_machine = module_machine_ibm4xx;
+}
+
+void
+cpu_startup(void)
+{
+	prop_number_t pn;
+
+	ibm4xx_cpu_startup("DHT Walnut 405GP Evaluation Board");
+
+	/*
+	 * Set up the board properties database.
+	 */
+	board_info_init();
+
+	pn = prop_number_create_integer(DHT_CPU_FREQ);
+	KASSERT(pn != NULL);
+	if (prop_dictionary_set(board_properties, "processor-frequency", pn) ==
+	    false)
+		panic("setting processor-frequency");
+	prop_object_release(pn);
+
+	pn = prop_number_create_integer(memsize);
+	KASSERT(pn != NULL);
+	if (prop_dictionary_set(board_properties, "mem-size", pn) == false)
+		panic("setting mem-size");
+	prop_object_release(pn);
+
+#if NEMAC > 0
+	/*
+	 * XXX
+	 * Unfortunately, no MAC address is assigned to this board.
+	 * Set fake address de:ad:be:ef:00:00.
+	 *
+	 * XXX
+	 * This should be same with what U-Boot/PPC-Boot set.
+	 */
+	static uint8_t enaddr[ETHER_ADDR_LEN];
+	enaddr[0] = 0xde; enaddr[1] = 0xad; enaddr[2] = 0xbe;
+	enaddr[3] = 0xef; enaddr[4] = 0x00; enaddr[5] = 0x00;
+	prop_data_t pd = prop_data_create_data_nocopy(enaddr, ETHER_ADDR_LEN);
+	KASSERT(pd != NULL);
+	if (prop_dictionary_set(board_properties, "emac0-mac-addr", pd) ==
+	    false)
+		panic("setting emac0-mac-addr");
+	prop_object_release(pd);
+#endif
+
+	/*
+	 * Now that we have VM, malloc()s are OK in bus_space.
+	 */
+	bus_space_mallocok();
+
+	/*
+	 * No fake mapiodev.
+	 */
+	fake_mapiodev = 0;
+}
+
+#if NPCI > 0
+int
+ibm4xx_pci_bus_maxdevs(void *v, int busno)
+{
+
+	return 32;
+}
+
+/*
+ * This is only possible mapping known to work b/w PCI devices and IRQ pins.
+ */
+#define	DEV_TO_IRQ(dev)		(27 + (dev))
+#define	PARENT_DEV(swiz, dev)	((swiz) - (dev))
+
+int
+ibm4xx_pci_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ihp)
+{
+	int pin = pa->pa_intrpin, bus = pa->pa_bus, dev = pa->pa_device;
+
+	if (pin <= 0 || pin > 4)
+		goto bad;
+
+	if (bus != 0) {
+		/*
+		 * XXX
+		 * We only support ppb(4) directly attached to pci0.
+		 */
+		dev = PARENT_DEV(pa->pa_intrswiz, dev);
+		goto out;
+	}
+
+	switch (dev) {
+	case 2:
+	case 3:
+	case 4:
+out:
+		*ihp = DEV_TO_IRQ(dev);
+		return 0;
+	default:
+bad:
+		printf("%s: invalid request: bus %d dev %d pin %d\n",
+		    __func__, bus, dev, pin);
+		*ihp = -1;
+		return 1;
+	}
+}
+
+void
+ibm4xx_pci_conf_interrupt(void *v, int bus, int dev, int pin, int swiz,
+    int *iline)
+{
+
+	if (bus != 0) {
+		/*
+		 * XXX
+		 * See coment above.
+		 */
+		dev = PARENT_DEV(swiz, dev);
+		goto out;
+	}
+
+	switch (dev) {
+	case 2:
+	case 3:
+	case 4:
+out:
+		*iline = DEV_TO_IRQ(dev);
+		break;
+	default:
+		printf("%s: invalid request: bus %d dev %d pin %d swiz %d\n",
+		    __func__, bus, dev, pin, swiz);
+		*iline = 0;
+		break;
+	}
+}
+#endif /* NPCI > 0 */

Index: src/sys/arch/evbppc/include/dht.h
diff -u /dev/null src/sys/arch/evbppc/include/dht.h:1.1
--- /dev/null	Fri Apr  2 07:00:33 2021
+++ src/sys/arch/evbppc/include/dht.h	Fri Apr  2 07:00:33 2021
@@ -0,0 +1,40 @@
+/*	$NetBSD: dht.h,v 1.1 2021/04/02 07:00:33 rin Exp $	*/
+
+/*
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Rin Okuyama.
+ *
+ * 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.
+ */
+
+#ifndef	_EVBPPC_DHT_H_
+#define	_EVBPPC_DHT_H_
+
+#include <dev/ic/comreg.h>
+
+#define	DHT_CPU_FREQ	266666666
+#define	DHT_COM_FREQ	(6 * COM_FREQ)
+
+#endif	/* _EVBPPC_DHT_H_ */

Reply via email to