PERFORCE change 222156 for review

Robert Watson rwatson at FreeBSD.org
Mon Feb 18 00:51:33 UTC 2013


http://p4web.freebsd.org/@@222156?ac=10

Change 222156 by rwatson at rwatson_zenith_cl_cam_ac_uk on 2013/02/18 00:50:36

	Checkpoint an adaptation of the ARM at91 version of boot2 for use on
	the FreeBSD/BERI MIPS platform, including support for Intel
	StrataFlash-originated boot2 parts (which must self-relocate to DRAM
	before getting too far), and an Altera JTAG UART.  Some elements of
	this work (e.g., the "boot:" prompt) and others don't (UFS-embedded
	kernel loading from the on-board flash, SD card kernel loading).
	Among other things, this required making the ARM-derived code 64-bit
	safe.  Some further refinement, especially SD support, is still
	required.

Affected files ...

.. //depot/projects/ctsrd/beribsd/src/sys/boot/common/util.c#3 edit
.. //depot/projects/ctsrd/beribsd/src/sys/boot/mips/beri/boot2/Makefile#2 edit
.. //depot/projects/ctsrd/beribsd/src/sys/boot/mips/beri/boot2/altera_jtag_uart.c#1 add
.. //depot/projects/ctsrd/beribsd/src/sys/boot/mips/beri/boot2/boot2.c#2 edit
.. //depot/projects/ctsrd/beribsd/src/sys/boot/mips/beri/boot2/cons.h#1 add
.. //depot/projects/ctsrd/beribsd/src/sys/boot/mips/beri/boot2/drv.h#1 add
.. //depot/projects/ctsrd/beribsd/src/sys/boot/mips/beri/boot2/flash.c#1 add
.. //depot/projects/ctsrd/beribsd/src/sys/boot/mips/beri/boot2/linker.cfg#1 add
.. //depot/projects/ctsrd/beribsd/src/sys/boot/mips/beri/boot2/mips.h#1 add
.. //depot/projects/ctsrd/beribsd/src/sys/boot/mips/beri/boot2/start.s#1 add

Differences ...

==== //depot/projects/ctsrd/beribsd/src/sys/boot/common/util.c#3 (text+ko) ====

@@ -125,7 +125,15 @@
 
 	va_start(ap, fmt);
 	while ((c = *fmt++) != '\0') {
-		if (c != '%') {
+		switch (c) {
+		case '%':
+			break;
+
+		case '\n':
+			putchar('\r');
+			/* FALLTHROUGH */
+
+		default:
 			putchar(c);
 			continue;
 		}

==== //depot/projects/ctsrd/beribsd/src/sys/boot/mips/beri/boot2/Makefile#2 (text+ko) ====

@@ -1,15 +1,37 @@
 #  $FreeBSD$
 
-P=boot2
-FILES=${P}
-SRCS=mips_init.S boot2.c beri_board.c
+PROG=		boot2
+BINDIR?=	/boot
+INSTALLFLAGS=	-b
+
+FILES=		${PROG}
+SRCS=		start.s			\
+		boot2.c			\
+		altera_jtag_uart.c	\
+		flash.c
+
 NO_MAN=
-LDFLAGS=-e 0 -T ${.CURDIR}/../linker.cfg
-OBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
+
+AFLAGS=		-G0
+
+CFLAGS=		-ffreestanding			\
+		-I${.CURDIR}			\
+		-I${.CURDIR}/../../../common	\
+		-I${.CURDIR}/../../../..	\
+		-D_KERNEL			\
+		-Wall				\
+		-G0 -Xassembler -G0		\
+		-fno-pic -mno-abicalls
+
+LDFLAGS=	-nostdlib		\
+		-static			\
+		-N			\
+		-T linker.cfg		\
+		-G0
+
+boot2: linker.cfg
+
+boot2.img: boot2
+	objcopy -S -O binary boot2 boot2.img
 
 .include <bsd.prog.mk>
-
-CFLAGS+= \
-	-I${.CURDIR}/../../../common \
-	-I${.CURDIR}/../../../.. \
-	-D_KERNEL

==== //depot/projects/ctsrd/beribsd/src/sys/boot/mips/beri/boot2/boot2.c#2 (text+ko) ====

@@ -1,4 +1,32 @@
 /*-
+ * Copyright (c) 2013 Robert N. M. Watson
+ * All rights reserved.
+ *
+ * This software was developed by SRI International and the University of
+ * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
+ * ("CTSRD"), as part of the DARPA CRASH research programme.
+ *
+ * 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.
+ *
  * Copyright (c) 2008 John Hay
  * Copyright (c) 2006 Warner Losh
  * Copyright (c) 1998 Robert Nordier
@@ -28,8 +56,11 @@
 
 #include <stdarg.h>
 
-#include "lib.h"
-#include "board.h"
+#include "cons.h"
+#include "drv.h"
+
+//#include "lib.h"
+//#include "board.h"
 
 #define RBX_ASKNAME	0x0	/* -a */
 #define RBX_SINGLE	0x1	/* -s */
@@ -66,8 +97,7 @@
 
 #define PATH_DOTCONFIG	"/boot.config"
 #define PATH_CONFIG	"/boot/config"
-//#define PATH_KERNEL	"/boot/kernel/kernel"
-#define PATH_KERNEL	"/boot/kernel/kernel.gz.tramp"
+#define PATH_KERNEL	"/boot/kernel/kernel"
 
 extern uint32_t _end;
 
@@ -100,9 +130,12 @@
 static void fixup_boot_drv(caddr_t, int, int, int);
 #endif
 
+#include "util.c"
 #define	UFS_SMALL_CGBASE
 #include "ufsread.c"
 
+static struct dmadat __dmadat;
+
 #ifdef DEBUG
 #define	DPRINTF(fmt, ...) printf(fmt, __VA_ARGS__)
 #else
@@ -143,7 +176,7 @@
 		default:
 			if (s - cmd < sizeof(cmd) - 1)
 				*s++ = c;
-			xputchar(c);
+			putchar(c);
 		}
 		c = getc(10000);
 	}
@@ -155,8 +188,8 @@
 	int autoboot, c = 0;
 	ufs_ino_t ino;
 
-	dmadat = (void *)(0x20000000 + (16 << 20));
-	board_init();
+	dmadat = &__dmadat;
+	//board_init();
 
 	autoboot = 1;
 
@@ -182,11 +215,11 @@
 		if (!autoboot ||
 		    (OPT_CHECK(RBX_NOINTR) == 0 && (c = getc(2)) != 0))
 			getstr(c);
-		xputchar('\n');
+		putchar('\n');
 		autoboot = 0;
 		c = 0;
 		if (parse())
-			xputchar('\a');
+			putchar('\a');
 		else
 			load();
 	}
@@ -195,11 +228,11 @@
 static void
 load(void)
 {
-	Elf32_Ehdr eh;
-	static Elf32_Phdr ep[2];
+	Elf64_Ehdr eh;
+	static Elf64_Phdr ep[2];
 	caddr_t p;
 	ufs_ino_t ino;
-	uint32_t addr;
+	uint64_t addr;
 	int i, j;
 #ifdef FIXUP_BOOT_DRV
 	caddr_t staddr;


More information about the p4-projects mailing list