Module Name:    src
Committed By:   matt
Date:           Mon Mar 24 18:46:38 UTC 2014

Modified Files:
        src/sys/arch/evbarm/conf [matt-nb5-mips64]: Makefile.evbarm.inc
Added Files:
        src/sys/arch/evbarm/conf [matt-nb5-mips64]: CUBIEBOARD
            CUBIEBOARD_INSTALL files.cubie mk.cubie std.cubie
        src/sys/arch/evbarm/cubie [matt-nb5-mips64]: cubie_machdep.c
            cubie_start.S genassym.cf platform.h

Log Message:
Add cubie from HEAD


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.10.2.2 src/sys/arch/evbarm/conf/CUBIEBOARD
cvs rdiff -u -r0 -r1.1.2.2 src/sys/arch/evbarm/conf/CUBIEBOARD_INSTALL \
    src/sys/arch/evbarm/conf/files.cubie
cvs rdiff -u -r1.19.12.1 -r1.19.12.2 \
    src/sys/arch/evbarm/conf/Makefile.evbarm.inc
cvs rdiff -u -r0 -r1.3.2.2 src/sys/arch/evbarm/conf/mk.cubie \
    src/sys/arch/evbarm/conf/std.cubie
cvs rdiff -u -r0 -r1.14.2.2 src/sys/arch/evbarm/cubie/cubie_machdep.c
cvs rdiff -u -r0 -r1.6.2.2 src/sys/arch/evbarm/cubie/cubie_start.S
cvs rdiff -u -r0 -r1.1.2.2 src/sys/arch/evbarm/cubie/genassym.cf
cvs rdiff -u -r0 -r1.2.2.2 src/sys/arch/evbarm/cubie/platform.h

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

Modified files:

Index: src/sys/arch/evbarm/conf/Makefile.evbarm.inc
diff -u src/sys/arch/evbarm/conf/Makefile.evbarm.inc:1.19.12.1 src/sys/arch/evbarm/conf/Makefile.evbarm.inc:1.19.12.2
--- src/sys/arch/evbarm/conf/Makefile.evbarm.inc:1.19.12.1	Sat Feb 15 16:18:37 2014
+++ src/sys/arch/evbarm/conf/Makefile.evbarm.inc	Mon Mar 24 18:46:38 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.evbarm.inc,v 1.19.12.1 2014/02/15 16:18:37 matt Exp $
+#	$NetBSD: Makefile.evbarm.inc,v 1.19.12.2 2014/03/24 18:46:38 matt Exp $
 
 #
 # If this is a install kernel and the ramdisk image exists in the object
@@ -22,6 +22,11 @@ SYSTEM_LD_TAIL_EXTRA+=; \
 
 EXTRA_CLEAN+= ldscript tmp ${KERNELS:=.map}
 
+.if defined(KERNEL_BASE_PHYS) && defined(KERNEL_BASE_VIRT) \
+    && ${KERNEL_BASE_PHYS} == ${KERNEL_BASE_VIRT}
+CPPFLAGS+=-DKERNEL_BASES_EQUAL
+.endif
+
 .if defined(KERNEL_BASE_PHYS)
 LINKTEXT=
 KERNLDSCRIPT=	ldscript

Added files:

Index: src/sys/arch/evbarm/conf/CUBIEBOARD
diff -u /dev/null src/sys/arch/evbarm/conf/CUBIEBOARD:1.10.2.2
--- /dev/null	Mon Mar 24 18:46:38 2014
+++ src/sys/arch/evbarm/conf/CUBIEBOARD	Mon Mar 24 18:46:38 2014
@@ -0,0 +1,297 @@
+#
+#	$NetBSD: CUBIEBOARD,v 1.10.2.2 2014/03/24 18:46:38 matt Exp $
+#
+#	CUBIEBOARD -- Allwinner A10/A20 Eval Board Kernel
+#
+
+include	"arch/evbarm/conf/std.cubie"
+
+# estimated number of users
+
+maxusers	32
+
+# Standard system options
+
+options 	RTC_OFFSET=0	# hardware clock is this many mins. west of GMT
+#options 	NTP		# NTP phase/frequency locked loop
+
+# CPU options
+
+#options 	UVMHIST,UVMHIST_PRINT
+options 	CPU_CORTEXA8
+options 	CPU_CORTEXA7
+options 	ALLWINNER_A10
+options 	ALLWINNER_A20
+options 	PMAPCOUNTERS
+options 	AWIN_CONSOLE_EARLY
+
+# Architecture options
+
+# File systems
+
+file-system	FFS		# UFS
+#file-system	LFS		# log-structured file system
+file-system	MFS		# memory file system
+file-system	NFS		# Network file system
+#file-system 	ADOSFS		# AmigaDOS-compatible file system
+#file-system 	EXT2FS		# second extended file system (linux)
+#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	PROCFS		# /proc
+#file-system	PUFFS		# Userspace file systems (e.g. ntfs-3g & sshfs)
+#file-system	UMAPFS		# NULLFS + uid and gid remapping
+#file-system	UNION		# union file system
+file-system	TMPFS		# memory file system
+file-system	PTYFS		# /dev/pts/N support
+
+# File system options
+#options 	QUOTA		# legacy UFS quotas
+#options 	QUOTA2		# new, in-filesystem UFS quotas
+#options 	FFS_EI		# FFS Endian Independent support
+#options 	NFSSERVER
+options 	WAPBL		# File system journaling support
+#options 	FFS_NO_SNAPSHOT	# No FFS snapshot support
+
+# 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
+#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
+
+options 	NFS_BOOT_BOOTP
+options 	NFS_BOOT_DHCP
+#options		NFS_BOOT_BOOTSTATIC
+#options		NFS_BOOTSTATIC_MYIP="\"192.168.1.4\""
+#options		NFS_BOOTSTATIC_GWIP="\"192.168.1.1\""
+#options		NFS_BOOTSTATIC_MASK="\"255.255.255.0\""
+#options		NFS_BOOTSTATIC_SERVADDR="\"192.168.1.1\""
+#options		NFS_BOOTSTATIC_SERVER="\"192.168.1.1:/nfs/sdp2430\""
+
+options		NFS_BOOT_RWSIZE=1024
+
+# Compatibility options
+
+#options 	COMPAT_43	# 4.3BSD compatibility.
+options 	COMPAT_60	# NetBSD 6.0 compatibility.
+options 	COMPAT_50	# NetBSD 5.0 compatibility.
+options 	COMPAT_40	# NetBSD 4.0 compatibility.
+options 	COMPAT_30	# NetBSD 3.0 compatibility.
+#options 	COMPAT_20	# NetBSD 2.0 compatibility.
+#options 	COMPAT_16	# NetBSD 1.6 compatibility.
+#options 	COMPAT_15	# NetBSD 1.5 compatibility.
+#options 	COMPAT_14	# NetBSD 1.4 compatibility.
+#options 	COMPAT_13	# NetBSD 1.3 compatibility.
+#options 	COMPAT_12	# NetBSD 1.2 compatibility.
+#options 	COMPAT_11	# NetBSD 1.1 compatibility.
+#options 	COMPAT_10	# NetBSD 1.0 compatibility.
+#options 	COMPAT_09	# NetBSD 0.9 compatibility.
+#options 	TCP_COMPAT_42	# 4.2BSD TCP/IP bug compat. Not recommended.
+#options		COMPAT_BSDPTY	# /dev/[pt]ty?? ptys.
+
+# Shared memory options
+
+options 	SYSVMSG		# System V-like message queues
+options 	SYSVSEM		# System V-like semaphores
+options 	SYSVSHM		# System V-like memory sharing
+
+# Device options
+
+#options 	MEMORY_DISK_HOOKS	# boottime setup of ramdisk
+#options 	MEMORY_DISK_ROOT_SIZE=8192	# Size in blocks
+#options 	MEMORY_DISK_DYNAMIC
+#options 	MINIROOTSIZE=1000	# Size in blocks
+#options 	MEMORY_DISK_IS_ROOT	# use memory disk as root
+
+options 	DKWEDGE_AUTODISCOVER
+options 	DKWEDGE_METHOD_GPT
+
+# Miscellaneous kernel options
+options 	KTRACE		# system call tracing, a la ktrace(1)
+#options 	KMEMSTATS	# kernel memory statistics
+#options 	SCSIVERBOSE	# Verbose SCSI errors
+#options 	MIIVERBOSE	# Verbose MII autoconfuration messages
+#options 	DDB_KEYCODE=0x40
+#options 	USERCONF	# userconf(4) support
+#options	PIPE_SOCKETPAIR	# smaller, but slower pipe(2)
+
+# Development and Debugging options
+
+#options 	PERFCTRS	# performance counters
+options 	DIAGNOSTIC	# internally consistency checks
+#options 	DEBUG
+#options 	PMAP_DEBUG	# Enable pmap_debug_level code
+#options 	IPKDB		# remote kernel debugging
+options 	VERBOSE_INIT_ARM # verbose bootstraping messages
+options 	DDB		# in-kernel debugger
+options		DDB_ONPANIC=1
+options 	DDB_HISTORY_SIZE=100	# Enable history editing in DDB
+#options 	KGDB
+makeoptions	DEBUG="-g"	# compile full symbol table
+options 	SYMTAB_SPACE=820000
+
+## USB Debugging options
+options USB_DEBUG
+options EHCI_DEBUG
+options OHCI_DEBUG
+options UHUB_DEBUG
+
+
+# Valid options for BOOT_ARGS:
+#  single		Boot to single user only
+#  kdb			Give control to kernel debugger
+#  ask			Ask for file name to reboot from
+#  memorydisk=<n>	Set memorydisk size to <n> KB
+#  quiet		Show aprint_naive output
+#  verbose		Show aprint_normal and aprint_verbose output
+options		BOOT_ARGS="\"\""
+
+config		netbsd		root on ? type ?
+
+# The main bus device
+mainbus0	at root
+
+# The boot cpu
+cpu0		at mainbus?
+
+# Specify the memory size in megabytes (optional).
+#options 	MEMSIZE=256
+#options 	MEMSIZE=128
+
+# A7 core devices
+armperiph0	at mainbus?
+armgic0		at armperiph?				# Interrupt Controller
+armgtmr0	at armperiph?				# ARM Generic Timer
+
+# SoC I/O
+awinio0		at mainbus?
+
+# SD/MMC controllers
+awinmmc0	at awinio0 port 0
+sdmmc*		at awinmmc?
+ld*		at sdmmc?
+
+# NAND controller
+awinnand0	at awinio0
+
+# NAND layer
+nand0		at nandbus?
+
+# use the bad block table
+options NAND_BBT
+
+# Define flash partitions for board
+flash0		at nand0 offset 0x000000 size 0x080000 readonly 1 # X-Loader
+flash1		at nand0 offset 0x080000 size 0x1e0000 readonly 1 # U-Boot
+flash2		at nand0 offset 0x260000 size 0x020000 readonly 1 # UB Env
+flash3		at nand0 offset 0x280000 size 0x400000		# kernel
+flash4		at nand0 offset 0x680000 size 0			# filesystem
+
+# Interrupt Controller
+awinicu0	at awinio0 
+awingpio0	at awinio0
+
+gpio*		at awingpio?
+
+# System Control Module
+#awinscm0 	at awinio?
+
+# I2C Controller
+awiniic0	at awinio? port 0
+#awiniic*	at awinio? port ?
+iic*		at awiniic?
+
+# On-board 16550 UARTs
+com0		at awinio? port 0			# UART0 (console)
+options 	CONADDR=0x01c28000, CONSPEED=115200
+
+# Operating System Timer (A10)
+awintmr0	at awinio?
+
+# Watchdog timers
+awinwdt*	at awinio?
+
+# onboard DMA
+#awindma0	at obio0 addr 0x48056000 size 0x1000
+
+# onboard video
+#awinfb* 	at obio0 addr 0x48050000 size 0x10000
+#wsdisplay*	at wsemuldisplaydev? console ?
+
+# various options for wscons - we try to look as much like a standard
+# sun console as possible
+#options 	WSEMUL_VT100		# sun terminal emulation
+#options 	WS_DEFAULT_FG=WSCOL_BLACK
+#options 	WS_DEFAULT_BG=WSCOL_LIGHT_WHITE
+#options 	WS_KERNEL_FG=WSCOL_GREEN
+#options 	WS_KERNEL_BG=WSCOL_LIGHT_WHITE
+#options 	WSDISPLAY_COMPAT_PCVT		# emulate some ioctls
+#options 	WSDISPLAY_COMPAT_SYSCONS	# emulate some more ioctls
+#options 	WSDISPLAY_COMPAT_USL		# wsconscfg VT handling
+#options 	WSDISPLAY_COMPAT_RAWKBD		# can get raw scancodes
+#options 	WSDISPLAY_DEFAULTSCREENS=4
+#options 	FONT_QVSS8x15
+#options 	FONT_GALLANT12x22	# the console font
+
+#pseudo-device	wsmux			# mouse & keyboard multiplexor
+#pseudo-device	wsfont
+
+# Power, Reset and Clock Management
+#prcm*		at awinio?
+
+# On-board USB
+awinusb0	at awinio0 port 0
+awinusb1	at awinio0 port 1
+ohci*		at awinusb?
+ehci*		at awinusb?
+usb*		at ohci?
+usb*		at ehci?
+
+# SATA
+ahcisata*	at awinio0
+atabus*		at ata?
+wd*		at atabus? drive ?
+
+# 10/100 Ethernet (A10/A20)
+awe0		at awinio0 port ?
+# 10/100/1000 Ethernet (A10/A20)
+awge0		at awinio0 port ?
+
+#include "dev/usb/usbdevices.config"
+
+rlphy*		at mii? phy ?
+ukphy*		at mii? phy ?
+
+# Pseudo-Devices
+
+# disk/mass storage pseudo-devices
+#pseudo-device	md			# memory disk device (ramdisk)
+#pseudo-device	vnd			# disk-like interface to files
+#pseudo-device	fss			# file system snapshot device
+#pseudo-device	putter			# for puffs and pud
+pseudo-device	drvctl			# driver control
+
+# network pseudo-devices
+pseudo-device	bpfilter		# Berkeley packet filter
+pseudo-device	loop			# network loopback
+#pseudo-device	kttcp			# network loopback
+
+# miscellaneous pseudo-devices
+pseudo-device	pty			# pseudo-terminals
+#options	RND_COM
+#pseudo-device	clockctl		# user control of clock subsystem
+pseudo-device	ksyms			# /dev/ksyms
+pseudo-device	lockstat		# lock profiling
+
+cinclude "arch/evbarm/conf/CUBIEBOARD.local"

Index: src/sys/arch/evbarm/conf/CUBIEBOARD_INSTALL
diff -u /dev/null src/sys/arch/evbarm/conf/CUBIEBOARD_INSTALL:1.1.2.2
--- /dev/null	Mon Mar 24 18:46:38 2014
+++ src/sys/arch/evbarm/conf/CUBIEBOARD_INSTALL	Mon Mar 24 18:46:38 2014
@@ -0,0 +1,10 @@
+#	$NetBSD: CUBIEBOARD_INSTALL,v 1.1.2.2 2014/03/24 18:46:38 matt Exp $
+#
+#	CUBIEBOARD_INSTALL -- CUBIEBOARD kernel with installation-sized
+#	ramdisk
+#
+
+include "arch/evbarm/conf/CUBIEBOARD"
+include "arch/evbarm/conf/INSTALL"
+
+options BOOTHOWTO=RB_SINGLE
Index: src/sys/arch/evbarm/conf/files.cubie
diff -u /dev/null src/sys/arch/evbarm/conf/files.cubie:1.1.2.2
--- /dev/null	Mon Mar 24 18:46:38 2014
+++ src/sys/arch/evbarm/conf/files.cubie	Mon Mar 24 18:46:38 2014
@@ -0,0 +1,12 @@
+#	$NetBSD: files.cubie,v 1.1.2.2 2014/03/24 18:46:38 matt Exp $
+#
+# CUBIEBOARD evaluation board configuration info
+#
+
+file	arch/evbarm/cubie/cubie_machdep.c
+
+# Kernel boot arguments
+defparam opt_machdep.h				BOOT_ARGS
+
+# CPU support and integrated peripherals
+include "arch/arm/allwinner/files.awin"

Index: src/sys/arch/evbarm/conf/mk.cubie
diff -u /dev/null src/sys/arch/evbarm/conf/mk.cubie:1.3.2.2
--- /dev/null	Mon Mar 24 18:46:38 2014
+++ src/sys/arch/evbarm/conf/mk.cubie	Mon Mar 24 18:46:38 2014
@@ -0,0 +1,39 @@
+#	$NetBSD: mk.cubie,v 1.3.2.2 2014/03/24 18:46:38 matt Exp $
+CPPFLAGS+= -mcpu=cortex-a8
+#CPFFLAGS+= -mfpu=neon
+
+.if !empty(MACHINE_ARCH:M*eb)
+EXTRA_LINKFLAGS+=	--be8
+.endif
+
+SYSTEM_FIRST_OBJ=	cubie_start.o
+SYSTEM_FIRST_SFILE=	${THISARM}/cubie/cubie_start.S
+
+GENASSYM_EXTRAS+=	${THISARM}/cubie/genassym.cf
+
+_OSRELEASE!=		${HOST_SH} $S/conf/osrelease.sh
+
+KERNEL_BASE_PHYS?=$(LOADADDRESS)
+KERNEL_BASE_VIRT?=$(LOADADDRESS)
+
+MKUBOOTIMAGEARGS=	-A arm -T kernel
+MKUBOOTIMAGEARGS+=	-a $(KERNEL_BASE_PHYS) -e $(KERNEL_BASE_PHYS)
+MKUBOOTIMAGEARGS+=	-n "NetBSD/$(BOARDTYPE) ${_OSRELEASE}"
+MKUBOOTIMAGEARGS_NONE=	${MKUBOOTIMAGEARGS} -C none
+MKUBOOTIMAGEARGS_GZ=	${MKUBOOTIMAGEARGS} -C gz
+
+SYSTEM_LD_TAIL_EXTRA+=; \
+	echo ${OBJCOPY} -S -O binary $@ [email protected]; \
+	${OBJCOPY} -S -O binary $@ [email protected]; \
+	echo gzip -9c [email protected] > [email protected]; \
+	gzip -9c [email protected] > [email protected]; \
+	echo ${TOOL_MKUBOOTIMAGE} ${MKUBOOTIMAGEARGS_GZ} [email protected] [email protected]; \
+	${TOOL_MKUBOOTIMAGE} ${MKUBOOTIMAGEARGS_GZ} [email protected] [email protected]; \
+	echo ${TOOL_MKUBOOTIMAGE} ${MKUBOOTIMAGEARGS_NONE} [email protected] [email protected]; \
+	${TOOL_MKUBOOTIMAGE} ${MKUBOOTIMAGEARGS_NONE} [email protected] [email protected]; \
+	echo
+
+EXTRA_KERNELS+= ${KERNELS:@.KERNEL.@${.KERNEL.}.bin@}
+EXTRA_KERNELS+= ${KERNELS:@.KERNEL.@${.KERNEL.}.ub@}
+EXTRA_KERNELS+= ${KERNELS:@.KERNEL.@${.KERNEL.}.bin.gz@}
+EXTRA_KERNELS+= ${KERNELS:@.KERNEL.@${.KERNEL.}.gz.ub@}
Index: src/sys/arch/evbarm/conf/std.cubie
diff -u /dev/null src/sys/arch/evbarm/conf/std.cubie:1.3.2.2
--- /dev/null	Mon Mar 24 18:46:38 2014
+++ src/sys/arch/evbarm/conf/std.cubie	Mon Mar 24 18:46:38 2014
@@ -0,0 +1,28 @@
+#	$NetBSD: std.cubie,v 1.3.2.2 2014/03/24 18:46:38 matt Exp $
+#
+# standard NetBSD/evbarm for CUBIEBOARD options
+
+machine	evbarm arm
+include 	"arch/evbarm/conf/std.evbarm"
+
+# Pull in CUBIEBOARD config definitions.
+include		"arch/evbarm/conf/files.cubie"
+
+# To support easy transit to ../arch/arm/arm32
+#options 	MODULAR
+options 	__HAVE_CPU_COUNTER
+options 	CORTEX_PMC
+options 	__HAVE_FAST_SOFTINTS		# should be in types.h
+options 	ARM_HAS_VBAR
+#options 	__HAVE_MM_MD_DIRECT_MAPPED_PHYS
+options 	TPIDRPRW_IS_CURCPU
+options 	KERNEL_BASE_EXT=0x80000000
+#options 	FPU_VFP
+
+makeoptions	KERNEL_BASE_PHYS="0x40007800"
+makeoptions	KERNEL_BASE_VIRT="0x80007800"
+makeoptions	BOARDTYPE="cubie"
+makeoptions	BOARDMKFRAG="${THISARM}/conf/mk.cubie"
+
+options 	ARM_INTR_IMPL="<arch/arm/allwinner/awin_intr.h>"
+options		ARM_GENERIC_TODR

Index: src/sys/arch/evbarm/cubie/cubie_machdep.c
diff -u /dev/null src/sys/arch/evbarm/cubie/cubie_machdep.c:1.14.2.2
--- /dev/null	Mon Mar 24 18:46:38 2014
+++ src/sys/arch/evbarm/cubie/cubie_machdep.c	Mon Mar 24 18:46:38 2014
@@ -0,0 +1,621 @@
+/*	$NetBSD: cubie_machdep.c,v 1.14.2.2 2014/03/24 18:46:38 matt Exp $ */
+
+/*
+ * Machine dependent functions for kernel setup for TI OSK5912 board.
+ * Based on lubbock_machdep.c which in turn was based on iq80310_machhdep.c
+ *
+ * Copyright (c) 2002, 2003, 2005  Genetec Corporation.  All rights reserved.
+ * Written by Hiroyuki Bessho for Genetec Corporation.
+ *
+ * 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. The name of Genetec Corporation may not be used to endorse or
+ *    promote products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``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 GENETEC CORPORATION
+ * 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) 2001 Wasabi Systems, Inc.
+ * All rights reserved.
+ *
+ * Written by Jason R. Thorpe 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) 1997,1998 Mark Brinicombe.
+ * Copyright (c) 1997,1998 Causality Limited.
+ * 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 Mark Brinicombe
+ *	for the NetBSD Project.
+ * 4. The name of the company nor the name of the author may 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 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Copyright (c) 2007 Microsoft
+ * 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 Microsoft
+ *
+ * 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 OR CONTRIBUTERS 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: cubie_machdep.c,v 1.14.2.2 2014/03/24 18:46:38 matt Exp $");
+
+#include "opt_machdep.h"
+#include "opt_ddb.h"
+#include "opt_kgdb.h"
+#include "opt_ipkdb.h"
+#include "opt_md.h"
+#include "opt_com.h"
+#include "opt_allwinner.h"
+
+#include "com.h"
+#include "ukbd.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/cpu.h>
+#include <sys/device.h>
+#include <sys/exec.h>
+#include <sys/kernel.h>
+#include <sys/ksyms.h>
+#include <sys/msgbuf.h>
+#include <sys/proc.h>
+#include <sys/reboot.h>
+#include <sys/termios.h>
+#include <sys/gpio.h>
+
+#include <uvm/uvm_extern.h>
+
+#include <sys/conf.h>
+#include <dev/cons.h>
+#include <dev/md.h>
+
+#include <machine/db_machdep.h>
+#include <ddb/db_sym.h>
+#include <ddb/db_extern.h>
+#ifdef KGDB
+#include <sys/kgdb.h>
+#endif
+
+#include <machine/bootconfig.h>
+#include <arm/armreg.h>
+#include <arm/undefined.h>
+
+#include <arm/arm32/machdep.h>
+#include <arm/mainbus/mainbus.h>
+
+#include <dev/ic/ns16550reg.h>
+#include <dev/ic/comreg.h>
+
+#include <arm/allwinner/awin_reg.h>
+#include <arm/allwinner/awin_var.h>
+
+#include <evbarm/include/autoconf.h>
+#include <evbarm/cubie/platform.h>
+
+#include <dev/i2c/i2cvar.h>
+#include <dev/i2c/ddcreg.h>
+
+#include <dev/usb/ukbdvar.h>
+
+BootConfig bootconfig;		/* Boot config storage */
+static char bootargs[MAX_BOOT_STRING];
+char *boot_args = NULL;
+char *boot_file = NULL;
+
+bool cubietruck_p;
+/*
+ * uboot_args are filled in by cubie_start.S and must be in .data
+ * and not .bbs since .bss is cleared after uboot_args are filled in.
+ */
+uintptr_t uboot_args[4] = { 0 };
+
+/* Same things, but for the free (unused by the kernel) memory. */
+
+extern char KERNEL_BASE_phys[];	/* physical start of kernel */
+extern char _end[];		/* physical end of kernel */
+
+#ifdef MULTIPROCESSOR
+extern uintptr_t cortex_mpfault[4];
+#endif
+
+#if NAWIN_FB > 0
+#if NCOM > 0
+int use_fb_console = false;
+#else
+int use_fb_console = true;
+#endif
+#endif
+
+/*
+ * Macros to translate between physical and virtual for a subset of the
+ * kernel address space.  *Not* for general use.
+ */
+#define KERNEL_BASE_PHYS	((paddr_t)KERNEL_BASE_phys)
+#define KERNEL_PHYS_VOFFSET	(KERNEL_BASE - AWIN_SDRAM_PBASE)
+#define AWIN_CORE_VOFFSET	(AWIN_CORE_VBASE - AWIN_CORE_PBASE)
+
+/* Prototypes */
+
+void consinit(void);
+#ifdef KGDB
+static void kgdb_port_init(void);
+#endif
+
+static void cubie_device_register(device_t, void *);
+
+#if NCOM > 0
+#include <dev/ic/comreg.h>
+#include <dev/ic/comvar.h>
+#endif
+
+/*
+ * Static device mappings. These peripheral registers are mapped at
+ * fixed virtual addresses very early in initarm() so that we can use
+ * them while booting the kernel, and stay at the same address
+ * throughout whole kernel's life time.
+ *
+ * We use this table twice; once with bootstrap page table, and once
+ * with kernel's page table which we build up in initarm().
+ *
+ * Since we map these registers into the bootstrap page table using
+ * pmap_devmap_bootstrap() which calls pmap_map_chunk(), we map
+ * registers segment-aligned and segment-rounded in order to avoid
+ * using the 2nd page tables.
+ */
+
+#define _A(a)	((a) & ~L1_S_OFFSET)
+#define _S(s)	(((s) + L1_S_SIZE - 1) & ~(L1_S_SIZE-1))
+
+static const struct pmap_devmap devmap[] = {
+	{
+		/*
+		 * Map all of core area, this gets us everything and
+		 * it's only 3MB.
+		 */
+		.pd_va = _A(AWIN_CORE_VBASE),
+		.pd_pa = _A(AWIN_CORE_PBASE),
+		.pd_size = _S(AWIN_CORE_SIZE),
+		.pd_prot = VM_PROT_READ|VM_PROT_WRITE,
+		.pd_cache = PTE_NOCACHE
+	},
+	{
+		/*
+		 * Map all 1MB of SRAM area.
+		 */
+		.pd_va = _A(AWIN_SRAM_VBASE),
+		.pd_pa = _A(AWIN_SRAM_PBASE),
+		.pd_size = _S(AWIN_SRAM_SIZE),
+		.pd_prot = VM_PROT_READ|VM_PROT_WRITE,
+		.pd_cache = PTE_CACHE
+	},
+	{0}
+};
+
+#undef	_A
+#undef	_S
+
+/*
+ * u_int initarm(...)
+ *
+ * Initial entry point on startup. This gets called before main() is
+ * entered.
+ * It should be responsible for setting up everything that must be
+ * in place when main is called.
+ * This includes
+ *   Taking a copy of the boot configuration structure.
+ *   Initialising the physical console so characters can be printed.
+ *   Setting up page tables for the kernel
+ *   Relocating the kernel to the bottom of physical memory
+ */
+u_int
+initarm(void *arg)
+{
+	pmap_devmap_register(devmap);
+	awin_bootstrap(AWIN_CORE_VBASE, CONADDR_VA);
+
+	/* Heads up ... Setup the CPU / MMU / TLB functions. */
+	if (set_cpufuncs())
+		panic("cpu not recognized!");
+
+	/* The console is going to try to map things.  Give pmap a devmap. */
+	consinit();
+
+#ifdef VERBOSE_INIT_ARM
+	printf("\nuboot arg = %#"PRIxPTR", %#"PRIxPTR", %#"PRIxPTR", %#"PRIxPTR"\n",
+	    uboot_args[0], uboot_args[1], uboot_args[2], uboot_args[3]);
+#ifdef MULTIPROCESSOR
+	printf("mpfault = %#"PRIxPTR", %#"PRIxPTR", %#"PRIxPTR", %#"PRIxPTR"\n",
+	    cortex_mpfault[0], cortex_mpfault[1], cortex_mpfault[2],
+	    cortex_mpfault[3]);
+#endif
+#endif
+
+#ifdef KGDB
+	kgdb_port_init();
+#endif
+
+	cpu_reset_address = awin_wdog_reset;
+
+#ifdef VERBOSE_INIT_ARM
+	/* Talk to the user */
+	printf("\nNetBSD/evbarm (cubie) booting ...\n");
+#endif
+
+#ifdef BOOT_ARGS
+	char mi_bootargs[] = BOOT_ARGS;
+	parse_mi_bootargs(mi_bootargs);
+#endif
+
+#ifdef VERBOSE_INIT_ARM
+	printf("initarm: Configuring system ...\n");
+
+#if defined(CPU_CORTEXA7) || defined(CPU_CORTEXA9) || defined(CPU_CORTEXA15)
+	printf("initarm: cbar=%#x\n", armreg_cbar_read());
+#endif
+#endif
+
+	/*
+	 * Set up the variables that define the availability of physical
+	 * memory.
+	 */
+	psize_t ram_size = awin_memprobe();
+
+	/* the cubietruck has 2GB whereas the cubieboards only has 1GB */
+	cubietruck_p = (ram_size == 0x80000000);
+
+	/*
+	 * If MEMSIZE specified less than what we really have, limit ourselves
+	 * to that.
+	 */
+#ifdef MEMSIZE
+	if (ram_size == 0 || ram_size > (unsigned)MEMSIZE * 1024 * 1024)
+		ram_size = (unsigned)MEMSIZE * 1024 * 1024;
+#else
+	KASSERTMSG(ram_size > 0, "RAM size unknown and MEMSIZE undefined");
+#endif
+
+	/*
+	 * Configure DMA tags
+	 */
+	awin_dma_bootstrap(ram_size);
+
+	/* Fake bootconfig structure for the benefit of pmap.c. */
+	bootconfig.dramblocks = 1;
+	bootconfig.dram[0].address = AWIN_SDRAM_PBASE;
+	bootconfig.dram[0].pages = ram_size / PAGE_SIZE;
+
+#ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS
+	const bool mapallmem_p = true;
+	if (ram_size > KERNEL_VM_BASE - KERNEL_BASE) {
+		printf("%s: dropping RAM size from %luMB to %uMB\n",
+		   __func__, (unsigned long) (ram_size >> 20),
+		   (KERNEL_VM_BASE - KERNEL_BASE) >> 20);
+		ram_size = KERNEL_VM_BASE - KERNEL_BASE;
+	}
+#else
+	const bool mapallmem_p = false;
+#endif
+	KASSERT((armreg_pfr1_read() & ARM_PFR1_SEC_MASK) != 0);
+
+	arm32_bootmem_init(bootconfig.dram[0].address, ram_size,
+	    KERNEL_BASE_PHYS);
+	arm32_kernel_vm_init(KERNEL_VM_BASE, ARM_VECTORS_LOW, 0, devmap,
+	    mapallmem_p);
+
+	if (mapallmem_p) {
+		/*
+		 * "bootargs" env variable is passed as 4th argument
+		 * to kernel but it's using the physical address and
+		 * we to convert that to a virtual address.
+		 */
+		if (uboot_args[3] - AWIN_SDRAM_PBASE < ram_size) {
+			const char * const args = (const char *)
+			     (uboot_args[3] + KERNEL_PHYS_VOFFSET);
+			strlcpy(bootargs, args, sizeof(bootargs));
+		}
+	}
+
+	boot_args = bootargs;
+	parse_mi_bootargs(boot_args);
+
+	/* we've a specific device_register routine */
+	evbarm_device_register = cubie_device_register;
+
+#if NAWIN_FB > 0
+	char *ptr;
+	if (get_bootconf_option(boot_args, "console",
+		    BOOTOPT_TYPE_STRING, &ptr) && strncmp(ptr, "fb", 2) == 0) {
+		use_fb_console = true;
+	}
+#endif
+	
+	return initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE, NULL, 0);
+
+}
+
+#if NCOM > 0
+#ifndef CONADDR
+#define CONADDR		(AWIN_CORE_PBASE + AWIN_UART0_OFFSET)
+#endif
+#ifndef CONSPEED
+#define CONSPEED 115200
+#endif
+#ifndef CONMODE
+#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB | HUPCL)) | CS8) /* 8N1 */
+#endif
+
+__CTASSERT(AWIN_CORE_PBASE + AWIN_UART0_OFFSET <= CONADDR);
+__CTASSERT(CONADDR <= AWIN_CORE_PBASE + AWIN_UART7_OFFSET);
+__CTASSERT(CONADDR % AWIN_UART_SIZE == 0);
+static const bus_addr_t conaddr = CONADDR;
+static const int conspeed = CONSPEED;
+static const int conmode = CONMODE;
+#endif
+
+void
+consinit(void)
+{
+	bus_space_tag_t bst = &awin_a4x_bs_tag;
+#if NCOM > 0
+	bus_space_handle_t bh;
+#endif
+	static int consinit_called = 0;
+
+	if (consinit_called != 0)
+		return;
+
+	consinit_called = 1;
+
+#if NCOM > 0
+	if (bus_space_map(bst, conaddr, AWIN_UART_SIZE, 0, &bh))
+		panic("Serial console can not be mapped.");
+
+	if (comcnattach(bst, conaddr, conspeed, AWIN_UART_FREQ,
+		    COM_TYPE_NORMAL, conmode))
+		panic("Serial console can not be initialized.");
+
+	bus_space_unmap(bst, bh, AWIN_UART_SIZE);
+#else
+#error only COM console is supported
+
+#if NUKBD > 0
+	ukbd_cnattach();	/* allow USB keyboard to become console */
+#endif
+#endif
+}
+
+#ifdef KGDB
+#ifndef KGDB_DEVADDR
+#error Specify the address of the kgdb UART with the KGDB_DEVADDR option.
+#endif
+#ifndef KGDB_DEVRATE
+#define KGDB_DEVRATE 115200
+#endif
+
+#ifndef KGDB_DEVMODE
+#define KGDB_DEVMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
+#endif
+
+__CTASSERT(KGDB_DEVADDR != CONADDR);
+__CTASSERT(AWIN_CORE_PBASE + AWIN_UART0_OFFSET <= KGDB_DEVADDR);
+__CTASSERT(KGDB_DEVADDR <= AWIN_CORE_PBASE + AWIN_UART7_OFFSET);
+__CTASSERT(KGDB_DEVADDR % AWIN_UART_SIZE == 0);
+
+static const vaddr_t comkgdbaddr = KGDB_DEVADDR;
+static const int comkgdbspeed = KGDB_DEVRATE;
+static const int comkgdbmode = KGDB_DEVMODE;
+
+void
+static kgdb_port_init(void)
+{
+	bus_space_tag_t bst = &awin_a4x_bs_tag;
+	static bool kgdbsinit_called;
+
+	if (kgdbsinit_called)
+		return;
+
+	kgdbsinit_called = true;
+
+	bus_space_handle_t bh;
+	if (bus_space_map(bst, comkgdbaddr, AWIN_UART_SIZE, 0, &bh))
+		panic("kgdb port can not be mapped.");
+
+	if (com_kgdb_attach(bst, comkgdbaddr, comkgdbspeed, AWIN_REF_FREQ,
+		    COM_TYPE_NORMAL, comkgdbmode))
+		panic("KGDB uart can not be initialized.");
+
+	bus_space_unmap(bst, bh, AWIN_UART_SIZE);
+}
+#endif
+
+void
+cubie_device_register(device_t self, void *aux)
+{
+	prop_dictionary_t dict = device_properties(self);
+
+	if (device_is_a(self, "armperiph")
+	    && device_is_a(device_parent(self), "mainbus")) {
+		/*
+		 * XXX KLUDGE ALERT XXX
+		 * The iot mainbus supplies is completely wrong since it scales
+		 * addresses by 2.  The simpliest remedy is to replace with our
+		 * bus space used for the armcore regisers (which armperiph uses). 
+		 */
+		struct mainbus_attach_args * const mb = aux;
+		mb->mb_iot = &awin_bs_tag;
+		return;
+	}
+ 
+#if defined(CPU_CORTEXA7) || defined(CPU_CORTEXA15)
+	if (device_is_a(self, "armgtmr")) {
+		/*
+		 * The frequency of the generic timer is the reference
+		 * frequency.
+		 */
+                prop_dictionary_set_uint32(dict, "frequency", AWIN_REF_FREQ);
+		return;
+	}
+#endif
+
+	if (device_is_a(self, "awinio")) {
+		if (cubietruck_p) {
+			prop_dictionary_set_bool(dict, "no-awe", true);
+		} else {
+			prop_dictionary_set_bool(dict, "no-awge", true);
+		}
+		return;
+	}
+
+	if (device_is_a(self, "awingpio")) {
+		/*
+		 * These are GPIOs being used for various functions.
+		 */
+		prop_dictionary_set_cstring(dict, "satapwren",
+		    (cubietruck_p ? ">PH12" : ">PB8"));
+		prop_dictionary_set_cstring(dict, "usb0drv",
+		    (cubietruck_p ? ">PH17" : ">PB2"));
+		prop_dictionary_set_cstring(dict, "usb2drv", ">PH3");
+		prop_dictionary_set_cstring(dict, "usb0iddet",
+		    (cubietruck_p ? "<PH19" : "<PH4"));
+		prop_dictionary_set_cstring(dict, "usb0vbusdet",
+		    (cubietruck_p ? "<PH22" : "<PH5"));
+		prop_dictionary_set_cstring(dict, "usb1drv", ">PH6");
+		prop_dictionary_set_cstring(dict, "status-led1", ">PH21");
+		prop_dictionary_set_cstring(dict, "status-led2", ">PH20");
+		if (cubietruck_p) {
+			prop_dictionary_set_cstring(dict, "status-led3", ">PH11");
+			prop_dictionary_set_cstring(dict, "status-led4", ">PH7");
+		} else {
+			prop_dictionary_set_cstring(dict, "hdd5ven", ">PH17");
+			prop_dictionary_set_cstring(dict, "emacpwren", ">PH19");
+		}
+		prop_dictionary_set_cstring(dict, "mmc0detect", "<PH1");
+
+		/*
+		 * These pins have no connections.
+		 */
+		prop_dictionary_set_uint32(dict, "nc-b", 0x0003d0e8);
+		prop_dictionary_set_uint32(dict, "nc-c", 0x00ff0000);
+		prop_dictionary_set_uint32(dict, "nc-h", 0x03c53f04);
+		prop_dictionary_set_uint32(dict, "nc-i", 0x003fc03f);
+		return;
+	}
+
+	if (device_is_a(self, "ehci")) {
+		return;
+	}
+
+	if (device_is_a(self, "ahcisata")) {
+		/* PIO PB<8> / PIO PH<12> output */
+		prop_dictionary_set_cstring(dict, "power-gpio", "satapwren");
+		return;
+	}
+
+	if (device_is_a(self, "awinmmc")) {
+		struct awinio_attach_args * const aio = aux;
+		if (aio->aio_loc.loc_port == 0) {
+			prop_dictionary_set_cstring(dict,
+			    "detect-gpio", "mmc0detect");
+			prop_dictionary_set_cstring(dict,
+			    "led-gpio", "status-led2");
+		}
+		return;
+	}
+
+	if (device_is_a(self, "com")) {
+#if NAWIN_FB > 0
+		if (use_fb_console)
+			prop_dictionary_set_bool(dict, "is_console", false);
+#endif
+		return;
+	}
+}

Index: src/sys/arch/evbarm/cubie/cubie_start.S
diff -u /dev/null src/sys/arch/evbarm/cubie/cubie_start.S:1.6.2.2
--- /dev/null	Mon Mar 24 18:46:38 2014
+++ src/sys/arch/evbarm/cubie/cubie_start.S	Mon Mar 24 18:46:38 2014
@@ -0,0 +1,166 @@
+/*-
+ * Copyright (c) 2014 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * 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.
+ */
+
+#include "opt_allwinner.h"
+#include "opt_com.h"
+#include "opt_cpuoptions.h"
+#include "opt_cputypes.h"
+#include "opt_multiprocessor.h"
+
+#include <arm/asm.h>
+#include <arm/armreg.h>
+#include "assym.h"
+
+#include <arm/allwinner/awin_reg.h>
+#include <evbarm/cubie/platform.h>  
+
+RCSID("$NetBSD: cubie_start.S,v 1.6.2.2 2014/03/24 18:46:38 matt Exp $")
+
+#if defined(VERBOSE_INIT_ARM)
+#define	XPUTC(n)	mov r0, n; bl xputc
+#ifdef __ARMEB__
+#define COM_BSWAP
+#endif
+#define COM_MULT	4
+#define XPUTC_COM	1
+#else
+#define	XPUTC(n)
+#endif
+
+#define INIT_MEMSIZE	128
+#define	TEMP_L1_TABLE	(AWIN_SDRAM_PBASE + INIT_MEMSIZE * 0x100000 - L1_TABLE_SIZE)
+
+#define	MD_CPU_HATCH	_C_LABEL(awin_cpu_hatch)
+
+/*
+ * Kernel start routine for BEAGLEBOARD boards.
+ * At this point, this code has been loaded into SDRAM
+ * and the MMU is off
+ */
+	.section .start,"ax",%progbits
+
+	.global	_C_LABEL(cubie_start)
+_C_LABEL(cubie_start):
+#ifdef __ARMEB__
+	setend	be			/* force big endian */
+#endif
+
+	/* Move into supervisor mode and disable IRQs/FIQs. */
+	cpsid	if, #PSR_SVC32_MODE
+
+	/*
+	 * Save any arguments passed to us.  But since .start is at 0x40000000
+	 * and .text is at 0x8000000, we can't directly use the address that
+	 * the linker gave us directly.  We have to replace the upper 4 bits
+	 * of the address the linker gave us and replace it with the upper 4
+	 * bits of our pc.  Or replace the lower 28 bits of our PC with the
+	 * lower 28 bits of what the linker gave us.
+	 */
+	adr	r4, _C_LABEL(cubie_start)
+	ldr	r5, =uboot_args
+	bfi	r4, r5, #0, #28
+
+	stmia	r4, {r0-r3}		// Save the arguments
+	/*
+	 * Turn on the SMP bit
+	 */
+	bl	cortex_init
+	XPUTC(#67)
+
+#if defined(MULTIPROCESSOR) && 0
+	movw	r0, #((AWIN_CORE_PBASE+AWIN_CPUCFG_OFFSET)&0xffff)
+	movt	r0, #((AWIN_CORE_PBASE+AWIN_CPUCFG_OFFSET)>>16)
+
+	/* Set where the other CPU(s) are going to execute */
+	adr	r1, cortex_mpstart
+	str	r1, [r0, #AWIN_CPUCFG_PRIVATE_REG]
+
+	/* Bring CPU1 out of reset */
+	ldr	r1, [r0, #AWIN_CPUCFG_CPU1_RST_CTRL_REG]
+	orr	r1, r1, #(AWIN_CPUCFG_CPU_RST_CTRL_CORE_RESET|AWIN_CPUCFG_CPU_RST_CTRL_RESET)
+	str	r1, [r0, #AWIN_CPUCFG_CPU1_RST_CTRL_REG]
+#endif /* MULTIPROCESSOR */
+
+	/*
+	 * Set up a preliminary mapping in the MMU to allow us to run
+	 * at KERNEL_BASE with caches on.
+	 */
+	movw	r0, #(TEMP_L1_TABLE & 0xffff)
+	movt	r0, #(TEMP_L1_TABLE >> 16)
+	adr	r1, .Lmmu_init_table
+	bl	arm_boot_l1pt_init
+
+	XPUTC(#68)
+
+	/*
+	 * Turn on the MMU, Caches, etc.
+	 */
+	movw	r0, #(TEMP_L1_TABLE & 0xffff)
+	movt	r0, #(TEMP_L1_TABLE >> 16)
+	bl	arm_cpuinit
+
+	XPUTC(#90)
+	XPUTC(#13)
+	XPUTC(#10)
+
+	/*
+	 * Jump to start in locore.S, which in turn will call initarm and main.
+	 */
+	ldr	ip, =start
+	bx	ip		/* Jump to start (flushes pipeline). */
+
+	/* NOTREACHED */
+
+#include <arm/cortex/a9_mpsubr.S>
+
+.Lmmu_init_table:
+	/* Map KERNEL_BASE VA to SDRAM PA, write-back cacheable, shareable */
+	MMU_INIT(KERNEL_BASE, AWIN_SDRAM_PBASE,
+		(INIT_MEMSIZE * L1_S_SIZE + L1_S_SIZE - 1) / L1_S_SIZE,
+		L1_S_PROTO | L1_S_APv7_KRW | L1_S_B | L1_S_C | L1_S_V6_S)
+
+	/* Map memory 1:1 VA to PA, write-back cacheable, shareable */
+	MMU_INIT(AWIN_SDRAM_PBASE, AWIN_SDRAM_PBASE,
+		(INIT_MEMSIZE * L1_S_SIZE + L1_S_SIZE - 1) / L1_S_SIZE,
+		L1_S_PROTO | L1_S_APv7_KRW | L1_S_B | L1_S_C | L1_S_V6_S)
+
+	/* Map AWIN CORE (so console will work) */
+	MMU_INIT(AWIN_CORE_VBASE, AWIN_CORE_PBASE,
+		(AWIN_CORE_SIZE + L1_S_SIZE - 1) / L1_S_SIZE,
+		L1_S_PROTO | L1_S_APv7_KRW)
+
+	/* Map AWIN CORE (so console will work) */
+	MMU_INIT(AWIN_CORE_PBASE, AWIN_CORE_PBASE,
+		(AWIN_CORE_SIZE + L1_S_SIZE - 1) / L1_S_SIZE,
+		L1_S_PROTO | L1_S_APv7_KRW)
+
+	/* end of table */
+	MMU_INIT(0, 0, 0, 0)
+
+END(_C_LABEL(cubie_start))

Index: src/sys/arch/evbarm/cubie/genassym.cf
diff -u /dev/null src/sys/arch/evbarm/cubie/genassym.cf:1.1.2.2
--- /dev/null	Mon Mar 24 18:46:38 2014
+++ src/sys/arch/evbarm/cubie/genassym.cf	Mon Mar 24 18:46:38 2014
@@ -0,0 +1,38 @@
+# $NetBSD: genassym.cf,v 1.1.2.2 2014/03/24 18:46:38 matt Exp $
+
+#-
+# Copyright (c) 2013 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Matt Thomas of 3am Software Foundry.
+#
+# 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.
+#
+
+include <dev/ic/ns16550reg.h>
+include <dev/ic/comreg.h>
+
+define	LSR_TXRDY		LSR_TXRDY
+define	LSR_TSRE		LSR_TSRE
+define	COM_DATA		com_data
+define	COM_LSR			com_lsr

Index: src/sys/arch/evbarm/cubie/platform.h
diff -u /dev/null src/sys/arch/evbarm/cubie/platform.h:1.2.2.2
--- /dev/null	Mon Mar 24 18:46:38 2014
+++ src/sys/arch/evbarm/cubie/platform.h	Mon Mar 24 18:46:38 2014
@@ -0,0 +1,54 @@
+/*	$NetBSD: platform.h,v 1.2.2.2 2014/03/24 18:46:38 matt Exp $	*/
+/*
+ * Copyright (c) 2007 Microsoft
+ * 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 Microsoft
+ *
+ * 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 OR CONTRIBUTERS 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 _EVBARM_CUBIE_PLATFORM_H
+#define _EVBARM_CUBIE_PLATFORM_H
+
+#include <arm/allwinner/awin_reg.h>
+
+/*
+ * Memory may be mapped VA:PA starting at 0x80000000:0x40000000
+ * Kernel VM space: 576MB at KERNEL_VM_BASE
+ */
+#define KERNEL_VM_BASE		0xc0000000
+#define KERNEL_VM_SIZE		0x24000000
+
+/*
+ * We devmap IO starting at KERNEL_VM_BASE + KERNEL_VM_SIZE
+ */
+#define AWIN_KERNEL_IO_VBASE	(KERNEL_VM_BASE + KERNEL_VM_SIZE)
+#define AWIN_CORE_VBASE		AWIN_KERNEL_IO_VBASE
+#define AWIN_SRAM_VBASE		(AWIN_CORE_VBASE + AWIN_CORE_SIZE)
+#define AWIN_KERNEL_IO_VEND	(AWIN_SRAM_VBASE + AWIN_SRAM_SIZE)
+#define CONADDR_VA		((CONADDR - AWIN_CORE_PBASE) + AWIN_CORE_VBASE)
+#ifndef _LOCORE
+CTASSERT(AWIN_KERNEL_IO_VEND <= VM_MAX_KERNEL_ADDRESS);
+#endif
+#endif /* _EVBARM_CUBIE_PLATFORM_H */

Reply via email to