Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Jun 2012 13:35:20 +0000
From:      aleek@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r238335 - in soc2012/aleek/beaglexm-armv6: . lib/libc lib/libc/arm sys sys/boot sys/boot/arm/uboot sys/boot/fdt sys/boot/uboot/common sys/boot/uboot/lib sys/modules sys/modules/cpsw
Message-ID:  <20120626133520.34A041065672@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: aleek
Date: Tue Jun 26 13:35:19 2012
New Revision: 238335
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=238335

Log:
  merge with armv6 branch

Added:
  soc2012/aleek/beaglexm-armv6/sys/modules/cpsw/
     - copied from r238334, mirror/FreeBSD/projects/armv6/sys/modules/cpsw/
Modified:
  soc2012/aleek/beaglexm-armv6/   (props changed)
  soc2012/aleek/beaglexm-armv6/lib/libc/   (props changed)
  soc2012/aleek/beaglexm-armv6/lib/libc/arm/Symbol.map
  soc2012/aleek/beaglexm-armv6/sys/   (props changed)
  soc2012/aleek/beaglexm-armv6/sys/boot/   (props changed)
  soc2012/aleek/beaglexm-armv6/sys/boot/arm/uboot/Makefile
  soc2012/aleek/beaglexm-armv6/sys/boot/arm/uboot/ldscript.arm
  soc2012/aleek/beaglexm-armv6/sys/boot/fdt/fdt_loader_cmd.c
  soc2012/aleek/beaglexm-armv6/sys/boot/uboot/common/metadata.c
  soc2012/aleek/beaglexm-armv6/sys/boot/uboot/lib/copy.c
  soc2012/aleek/beaglexm-armv6/sys/boot/uboot/lib/devicename.c
  soc2012/aleek/beaglexm-armv6/sys/boot/uboot/lib/disk.c
  soc2012/aleek/beaglexm-armv6/sys/boot/uboot/lib/elf_freebsd.c
  soc2012/aleek/beaglexm-armv6/sys/boot/uboot/lib/libuboot.h
  soc2012/aleek/beaglexm-armv6/sys/modules/Makefile

Modified: soc2012/aleek/beaglexm-armv6/lib/libc/arm/Symbol.map
==============================================================================
--- soc2012/aleek/beaglexm-armv6/lib/libc/arm/Symbol.map	Tue Jun 26 13:07:43 2012	(r238334)
+++ soc2012/aleek/beaglexm-armv6/lib/libc/arm/Symbol.map	Tue Jun 26 13:35:19 2012	(r238335)
@@ -33,6 +33,10 @@
 	sbrk;
 };
 
+FBSD_1.3 {
+	__flt_rounds;
+};
+
 FBSDprivate_1.0 {
 	/* PSEUDO syscalls */
 	__sys_getlogin;
@@ -70,7 +74,6 @@
 	__divdf3;
 	__floatsisf;
 	__floatsidf;
-	__flt_rounds;
 	__fixsfsi;
 	__fixdfsi;
 	__fixunssfsi;

Modified: soc2012/aleek/beaglexm-armv6/sys/boot/arm/uboot/Makefile
==============================================================================
--- soc2012/aleek/beaglexm-armv6/sys/boot/arm/uboot/Makefile	Tue Jun 26 13:07:43 2012	(r238334)
+++ soc2012/aleek/beaglexm-armv6/sys/boot/arm/uboot/Makefile	Tue Jun 26 13:35:19 2012	(r238335)
@@ -7,6 +7,9 @@
 BINDIR?=	/boot
 INSTALLFLAGS=	-b
 WARNS?=		1
+# Address at which ubldr will be loaded.
+# This varies for different boards and SOCs.
+UBLDR_LOADADDR?=	0x1000000
 
 # Architecture-specific loader code
 SRCS=		start.S conf.c vers.c
@@ -77,7 +80,9 @@
 
 CFLAGS+=	-ffreestanding
 
-LDFLAGS=	-nostdlib -static -T ${.CURDIR}/ldscript.${MACHINE_CPUARCH}
+LDFLAGS=	-nostdlib -static
+LDFLAGS+=	-T ldscript.generated
+LDFLAGS+=	-T ${.CURDIR}/ldscript.${MACHINE_CPUARCH}
 
 # Pull in common loader code
 .PATH:		${.CURDIR}/../../uboot/common
@@ -102,6 +107,18 @@
 	cat ${.ALLSRC} | \
 	    awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET}
 
+${PROG}: ldscript.generated ${.CURDIR}/ldscript.${MACHINE_CPUARCH}
+
+ldscript.generated::
+	rm -f ldscript.generated.tmp
+	echo "UBLDR_LOADADDR = ${UBLDR_LOADADDR};" >ldscript.generated.tmp
+	if diff ldscript.generated ldscript.generated.tmp > /dev/null; then \
+		true; \
+	else \
+		rm -f ldscript.generated; \
+		mv ldscript.generated.tmp ldscript.generated; \
+	fi
+
 .PATH: ${.CURDIR}/../../forth
 FILES=	loader.help
 

Modified: soc2012/aleek/beaglexm-armv6/sys/boot/arm/uboot/ldscript.arm
==============================================================================
--- soc2012/aleek/beaglexm-armv6/sys/boot/arm/uboot/ldscript.arm	Tue Jun 26 13:07:43 2012	(r238334)
+++ soc2012/aleek/beaglexm-armv6/sys/boot/arm/uboot/ldscript.arm	Tue Jun 26 13:35:19 2012	(r238335)
@@ -5,7 +5,7 @@
 SECTIONS
 {
   /* Read-only sections, merged into text segment: */
-  . = 0x1000000 + SIZEOF_HEADERS;
+  . = UBLDR_LOADADDR + SIZEOF_HEADERS;
   .interp     : { *(.interp) 	}
   .hash          : { *(.hash)		}
   .dynsym        : { *(.dynsym)		}

Modified: soc2012/aleek/beaglexm-armv6/sys/boot/fdt/fdt_loader_cmd.c
==============================================================================
--- soc2012/aleek/beaglexm-armv6/sys/boot/fdt/fdt_loader_cmd.c	Tue Jun 26 13:07:43 2012	(r238334)
+++ soc2012/aleek/beaglexm-armv6/sys/boot/fdt/fdt_loader_cmd.c	Tue Jun 26 13:35:19 2012	(r238335)
@@ -57,11 +57,17 @@
 #define STR(number) #number
 #define STRINGIFY(number) STR(number)
 
-#define COPYOUT(s,d,l)	archsw.arch_copyout((vm_offset_t)(s), d, l)
+#define COPYOUT(s,d,l)	archsw.arch_copyout(s, d, l)
+#define COPYIN(s,d,l)	archsw.arch_copyin(s, d, l)
 
 #define FDT_STATIC_DTB_SYMBOL	"fdt_static_dtb"
 
+/* Local copy of FDT */
 static struct fdt_header *fdtp = NULL;
+/* Size of FDT blob */
+static size_t fdtp_size = 0;
+/* Location of FDT in kernel or module */
+static vm_offset_t fdtp_va = 0;
 
 static int fdt_cmd_nyi(int argc, char *argv[]);
 
@@ -98,21 +104,19 @@
 static char cwd[FDT_CWD_LEN] = "/";
 
 static vm_offset_t
-fdt_find_static_dtb(void)
+fdt_find_static_dtb()
 {
+	Elf_Dyn dyn;
 	Elf_Sym sym;
-	vm_offset_t dyntab, esym;
+	vm_offset_t dyntab, esym, strtab, symtab, fdt_start;
 	uint64_t offs;
 	struct preloaded_file *kfp;
 	struct file_metadata *md;
-	Elf_Sym *symtab;
-	Elf_Dyn *dyn;
-	char *strtab, *strp;
-	int i, sym_count;
-
-	symtab = NULL;
-	dyntab = esym = 0;
-	strtab = strp = NULL;
+	char *strp;
+	int sym_count;
+
+	symtab = strtab = dyntab = esym = 0;
+	strp = NULL;
 
 	offs = __elfN(relocation_offset);
 
@@ -123,28 +127,29 @@
 	md = file_findmetadata(kfp, MODINFOMD_ESYM);
 	if (md == NULL)
 		return (0);
-	COPYOUT(md->md_data, &esym, sizeof(esym));
+	bcopy(md->md_data, &esym, sizeof(esym));
+	// esym is already offset
 
 	md = file_findmetadata(kfp, MODINFOMD_DYNAMIC);
 	if (md == NULL)
 		return (0);
-	COPYOUT(md->md_data, &dyntab, sizeof(dyntab));
-
+	bcopy(md->md_data, &dyntab, sizeof(dyntab));
 	dyntab += offs;
 
 	/* Locate STRTAB and DYNTAB */
-	for (dyn = (Elf_Dyn *)dyntab; dyn->d_tag != DT_NULL; dyn++) {
-		if (dyn->d_tag == DT_STRTAB) {
-			strtab = (char *)(uintptr_t)(dyn->d_un.d_ptr + offs);
-			continue;
-		} else if (dyn->d_tag == DT_SYMTAB) {
-			symtab = (Elf_Sym *)(uintptr_t)
-			    (dyn->d_un.d_ptr + offs);
-			continue;
+	for (;;) {
+		COPYOUT(dyntab, &dyn, sizeof(dyn));
+		if (dyn.d_tag == DT_STRTAB) {
+			strtab = (vm_offset_t)(dyn.d_un.d_ptr) + offs;
+		} else if (dyn.d_tag == DT_SYMTAB) {
+			symtab = (vm_offset_t)(dyn.d_un.d_ptr) + offs;
+		} else if (dyn.d_tag == DT_NULL) {
+			break;
 		}
+		dyntab += sizeof(dyn);
 	}
 
-	if (symtab == NULL || strtab == NULL) {
+	if (symtab == 0 || strtab == 0) {
 		/*
 		 * No symtab? No strtab? That should not happen here,
 		 * and should have been verified during __elfN(loadimage).
@@ -153,7 +158,7 @@
 		return (0);
 	}
 
-	sym_count = (int)((Elf_Sym *)esym - symtab) / sizeof(Elf_Sym);
+	sym_count = (int)(esym - symtab) / sizeof(Elf_Sym);
 
 	/*
 	 * The most efficent way to find a symbol would be to calculate a
@@ -165,26 +170,27 @@
 	 * we are eliminating symbols type of which is not STT_NOTYPE, or(and)
 	 * those which binding attribute is not STB_GLOBAL.
 	 */
-	for (i = 0; i < sym_count; i++) {
-		COPYOUT(symtab + i, &sym, sizeof(sym));
+	fdt_start = 0;
+	while (sym_count > 0 && fdt_start == 0) {
+		COPYOUT(symtab, &sym, sizeof(sym));
+		symtab += sizeof(sym);
+		--sym_count;
 		if (ELF_ST_BIND(sym.st_info) != STB_GLOBAL ||
 		    ELF_ST_TYPE(sym.st_info) != STT_NOTYPE)
 			continue;
-
-		strp = strdupout((vm_offset_t)(strtab + sym.st_name));
-		if (strcmp(strp, FDT_STATIC_DTB_SYMBOL) == 0) {
-			/* Found a match ! */
-			free(strp);
-			return ((vm_offset_t)(sym.st_value + offs));
-		}
+		strp = strdupout(strtab + sym.st_name);
+		if (strcmp(strp, FDT_STATIC_DTB_SYMBOL) == 0)
+			fdt_start = (vm_offset_t)sym.st_value + offs;
 		free(strp);
 	}
-	return (0);
+	printf("fdt_start: 0x%08jX\n", (intmax_t)fdt_start);
+	return (fdt_start);
 }
 
 static int
 fdt_setup_fdtp()
 {
+	struct fdt_header header;
 	struct preloaded_file *bfp;
 	int err;
 
@@ -193,15 +199,26 @@
 	 */
 	bfp = file_findfile(NULL, "dtb");
 	if (bfp == NULL) {
-		if ((fdtp = (struct fdt_header *)fdt_find_static_dtb()) == 0) {
+		if ((fdtp_va = fdt_find_static_dtb()) == 0) {
 			command_errmsg = "no device tree blob found!";
+			printf("%s\n", command_errmsg);
 			return (CMD_ERROR);
 		}
 	} else {
 		/* Dynamic blob has precedence over static. */
-		fdtp = (struct fdt_header *)bfp->f_addr;
+		fdtp_va = bfp->f_addr;
 	}
 
+	COPYOUT(fdtp_va, &header, sizeof(header));
+	fdtp_size = fdt_totalsize(&header);
+	fdtp = malloc(fdtp_size);
+	if (fdtp == NULL) {
+		command_errmsg = "can't allocate memory for device tree copy";
+			printf("%s\n", command_errmsg);
+		return (CMD_ERROR);
+	}
+	COPYOUT(fdtp_va, fdtp, fdtp_size);
+
 	/*
 	 * Validate the blob.
 	 */
@@ -317,6 +334,8 @@
 
 	/* We want to modify every subnode of /cpus */
 	o = fdt_path_offset(fdtp, "/cpus");
+	if (o < 0)
+		return;
 
 	/* maxo should contain offset of node next to /cpus */
 	depth = 0;
@@ -545,7 +564,7 @@
 /*
  * Locate the blob, fix it up and return its location.
  */
-void *
+vm_offset_t
 fdt_fixup(void)
 {
 	const char *env;
@@ -561,7 +580,7 @@
 	err = fdt_setup_fdtp();
 	if (err) {
 		sprintf(command_errbuf, "No valid device tree blob found!");
-		return (NULL);
+		return (0);
 	}
 
 	/* Create /chosen node (if not exists) */
@@ -616,7 +635,9 @@
 	fdt_setprop(fdtp, chosen, "fixup-applied", NULL, 0);
 
 success:
-	return (fdtp);
+	/* Overwrite the FDT with the fixed version. */
+	COPYIN(fdtp, fdtp_va, fdtp_size);
+	return (fdtp_va);
 }
 
 int
@@ -634,7 +655,7 @@
 	/*
 	 * Check if uboot env vars were parsed already. If not, do it now.
 	 */
-	if (fdt_fixup() == NULL)
+	if (fdt_fixup() == 0)
 		return (CMD_ERROR);
 
 	/*
@@ -1151,6 +1172,8 @@
 		else
 			sprintf(command_errbuf,
 			    "Could not add/modify property!\n");
+	} else {
+		COPYIN(fdtp, fdtp_va, fdtp_size);
 	}
 	return (rv);
 }
@@ -1371,6 +1394,8 @@
 	if (rv) {
 		sprintf(command_errbuf, "could not delete node");
 		return (CMD_ERROR);
+	} else {
+		COPYIN(fdtp, fdtp_va, fdtp_size);
 	}
 	return (CMD_OK);
 }
@@ -1401,6 +1426,8 @@
 			sprintf(command_errbuf,
 			    "Could not add node!\n");
 		return (CMD_ERROR);
+	} else {
+		COPYIN(fdtp, fdtp_va, fdtp_size);
 	}
 	return (CMD_OK);
 }

Modified: soc2012/aleek/beaglexm-armv6/sys/boot/uboot/common/metadata.c
==============================================================================
--- soc2012/aleek/beaglexm-armv6/sys/boot/uboot/common/metadata.c	Tue Jun 26 13:07:43 2012	(r238334)
+++ soc2012/aleek/beaglexm-armv6/sys/boot/uboot/common/metadata.c	Tue Jun 26 13:35:19 2012	(r238335)
@@ -42,7 +42,7 @@
 #include "glue.h"
 
 #if defined(LOADER_FDT_SUPPORT)
-extern int fdt_fixup(void);
+extern vm_offset_t fdt_fixup(void);
 #endif
 
 /*
@@ -72,6 +72,7 @@
 md_getboothowto(char *kargs)
 {
 	char	*cp;
+	char	*p;
 	int	howto;
 	int	active;
 	int	i;
@@ -132,10 +133,12 @@
 		if (getenv(howto_names[i].ev) != NULL)
 			howto |= howto_names[i].mask;
 	}
-	if (!strcmp(getenv("console"), "comconsole"))
-		howto |= RB_SERIAL;
-	if (!strcmp(getenv("console"), "nullconsole"))
-		howto |= RB_MUTE;
+	if ((p = getenv("console"))) {
+		if (!strcmp(p, "comconsole"))
+			howto |= RB_SERIAL;
+		if (!strcmp(p, "nullconsole"))
+			howto |= RB_MUTE;
+	}
 
 	return(howto);
 }
@@ -334,7 +337,7 @@
 #if defined(LOADER_FDT_SUPPORT)
 	/* Handle device tree blob */
 	dtbp = fdt_fixup();
-	if (dtbp != (vm_offset_t)NULL)
+	if (dtbp != 0)
 		file_addmetadata(kfp, MODINFOMD_DTBP, sizeof dtbp, &dtbp);
 	else
 		pager_output("WARNING! Trying to fire up the kernel, but no "

Modified: soc2012/aleek/beaglexm-armv6/sys/boot/uboot/lib/copy.c
==============================================================================
--- soc2012/aleek/beaglexm-armv6/sys/boot/uboot/lib/copy.c	Tue Jun 26 13:07:43 2012	(r238334)
+++ soc2012/aleek/beaglexm-armv6/sys/boot/uboot/lib/copy.c	Tue Jun 26 13:35:19 2012	(r238335)
@@ -29,32 +29,64 @@
 __FBSDID("$FreeBSD$");
 
 #include <stand.h>
+#include <stdint.h>
+
+#include "api_public.h"
+#include "glue.h"
 
 /*
  * MD primitives supporting placement of module data 
- *
- * XXX should check load address/size against memory top.
  */
 
+void *
+uboot_vm_translate(vm_offset_t o) {
+	struct sys_info *si;
+	static uintptr_t start = 0;
+	static size_t size = 0;
+	int i;
+
+	if (size == 0) {
+		if ((si = ub_get_sys_info()) == NULL)
+			panic("could not retrieve system info");
+
+		/* Find start/size of largest DRAM block. */
+		for (i = 0; i < si->mr_no; i++) {
+			if (si->mr[i].flags == MR_ATTR_DRAM
+			    && si->mr[i].size > size) {
+				start = si->mr[i].start;
+				size = si->mr[i].size;
+			}
+		}
+
+		if (size <= 0)
+			panic("No suitable DRAM?\n");
+		/*
+		printf("Loading into memory region 0x%08X-0x%08X (%d MiB)\n",
+		    start, start + size, size / 1024 / 1024);
+		*/
+	}
+	if (o > size)
+		panic("Address 0x%08jX bigger than size 0x%08X\n",
+		      (intmax_t)o, size);
+	return (void *)(start + o);
+}
+
 ssize_t
 uboot_copyin(const void *src, vm_offset_t dest, const size_t len)
 {
-
-	bcopy(src, (void *)dest, len);
+	bcopy(src, uboot_vm_translate(dest), len);
 	return (len);
 }
 
 ssize_t
 uboot_copyout(const vm_offset_t src, void *dest, const size_t len)
 {
-
-	bcopy((void *)src, dest, len);
+	bcopy(uboot_vm_translate(src), dest, len);
 	return (len);
 }
 
 ssize_t
 uboot_readin(const int fd, vm_offset_t dest, const size_t len)
 {
-
-	return (read(fd, (void *) dest, len));
+	return (read(fd, uboot_vm_translate(dest), len));
 }

Modified: soc2012/aleek/beaglexm-armv6/sys/boot/uboot/lib/devicename.c
==============================================================================
--- soc2012/aleek/beaglexm-armv6/sys/boot/uboot/lib/devicename.c	Tue Jun 26 13:07:43 2012	(r238334)
+++ soc2012/aleek/beaglexm-armv6/sys/boot/uboot/lib/devicename.c	Tue Jun 26 13:35:19 2012	(r238335)
@@ -131,6 +131,10 @@
 				    *(cp + 1) != ':') {
 					pnum = strtol(cp + 1, &cp, 10);
 					ptype = PTYPE_GPT;
+				} else if (*cp == 's' && *(cp + 1) &&
+				    *(cp + 1) != ':') {
+					pnum = strtol(cp + 1, &cp, 10);
+					ptype = PTYPE_MBR;
 				} else {
 					pnum = *cp - 'a';
 					ptype = PTYPE_BSDLABEL;
@@ -218,6 +222,9 @@
 			else if (dev->d_kind.disk.ptype == PTYPE_GPT)
 				cp += sprintf(cp, "p%i",
 				    dev->d_kind.disk.pnum);
+			else if (dev->d_kind.disk.ptype == PTYPE_MBR)
+				cp += sprintf(cp, "s%i",
+				    dev->d_kind.disk.pnum);
 		}
 
 		strcat(cp, ":");

Modified: soc2012/aleek/beaglexm-armv6/sys/boot/uboot/lib/disk.c
==============================================================================
--- soc2012/aleek/beaglexm-armv6/sys/boot/uboot/lib/disk.c	Tue Jun 26 13:07:43 2012	(r238334)
+++ soc2012/aleek/beaglexm-armv6/sys/boot/uboot/lib/disk.c	Tue Jun 26 13:35:19 2012	(r238335)
@@ -398,6 +398,94 @@
 }
 
 static int
+stor_open_mbr(struct open_dev *od, struct uboot_devdesc *dev)
+{
+	char *buf = NULL;
+	struct dos_partition *dp;
+	int err, i, part;
+
+	od->od_nparts = 0;
+	od->od_partitions = NULL;
+
+	/* Block size must be at least 512 bytes. */
+	if (od->od_bsize < 512)
+		return (ENXIO);
+
+	/* Read MBR */
+	buf = malloc(od->od_bsize);
+	if (!buf) {
+		stor_printf("could not allocate memory for MBR\n");
+		return (ENOMEM);
+	}
+	err = stor_readdev(dev, 0, 1, buf);
+	if (err) {
+		stor_printf("MBR read error=%d\n", err);
+		err = EIO;
+		goto out;
+	}
+
+	/* Check the slice table magic. */
+	if (le16toh(*((uint16_t *)(buf + DOSMAGICOFFSET))) != DOSMAGIC) {
+		err = ENXIO;
+		goto out;
+	}
+
+	/* Save information about partitions. */
+	dp = (struct dos_partition *)(buf + DOSPARTOFF);
+	od->od_partitions = calloc(NDOSPART, sizeof(struct gpt_part));
+	if (!od->od_partitions) {
+		stor_printf("could not allocate memory for MBR partitions\n");
+		err = ENOMEM;
+		goto out;
+	}
+
+	part = 0;
+	for (i = 0; i < NDOSPART; i++) {
+		u_int32_t start = le32dec(&dp[i].dp_start);
+		u_int32_t size = le32dec(&dp[i].dp_size);
+		uuid_t *u = NULL;
+
+		/* Map MBR partition types to GPT partition types. */
+		switch (dp[i].dp_typ) {
+		case DOSPTYP_386BSD:
+			u = &freebsd_ufs;
+			break;
+		/* XXX Other types XXX */
+		}
+
+		if (u) {
+			od->od_partitions[part].gp_type = *u;
+			od->od_partitions[part].gp_index = i + 1;
+			od->od_partitions[part].gp_start = start;
+			od->od_partitions[part].gp_end = start + size;
+			part += 1;
+		}
+	}
+	od->od_nparts = part;
+
+	if (od->od_nparts == 0) {
+		err = EINVAL;
+		goto out;
+	}
+
+	dev->d_disk.ptype = PTYPE_MBR;
+
+	/* XXX Be smarter here? XXX */
+	if (dev->d_disk.pnum == 0)
+		dev->d_disk.pnum = od->od_partitions[0].gp_index;
+
+	for (i = 0; i < od->od_nparts; i++)
+		if (od->od_partitions[i].gp_index == dev->d_disk.pnum)
+			od->od_bstart = od->od_partitions[i].gp_start;
+
+out:
+	if (err && od->od_partitions)
+		free(od->od_partitions);
+	free(buf);
+	return (err);
+}
+
+static int
 stor_open_bsdlabel(struct open_dev *od, struct uboot_devdesc *dev)
 {
 	char *buf;
@@ -443,7 +531,7 @@
 	lbasize_t real_size;
 	int err, handle;
 
-	debugf("reading size=%d @ 0x%08x\n", size, (uint32_t)buf);
+	debugf("reading blk=%d size=%d @ 0x%08x\n", (int)blk, size, (uint32_t)buf);
 
 	handle = stor_info[dev->d_unit];
 	err = ub_dev_read(handle, buf, size, blk, &real_size);
@@ -495,7 +583,10 @@
 	od->od_bsize = di->di_stor.block_size;
 	od->od_bstart = 0;
 
-	if ((err = stor_open_gpt(od, dev)) != 0)
+	err = stor_open_gpt(od, dev);
+	if (err != 0)
+		err = stor_open_mbr(od, dev);
+	if (err != 0)
 		err = stor_open_bsdlabel(od, dev);
 
 	if (err != 0)
@@ -517,6 +608,8 @@
 	od = (struct open_dev *)dev->d_disk.data;
 	if (dev->d_disk.ptype == PTYPE_GPT && od->od_nparts != 0)
 		free(od->od_partitions);
+	if (dev->d_disk.ptype == PTYPE_MBR && od->od_nparts != 0)
+		free(od->od_partitions);
 
 	free(od);
 	dev->d_disk.data = NULL;

Modified: soc2012/aleek/beaglexm-armv6/sys/boot/uboot/lib/elf_freebsd.c
==============================================================================
--- soc2012/aleek/beaglexm-armv6/sys/boot/uboot/lib/elf_freebsd.c	Tue Jun 26 13:07:43 2012	(r238334)
+++ soc2012/aleek/beaglexm-armv6/sys/boot/uboot/lib/elf_freebsd.c	Tue Jun 26 13:35:19 2012	(r238335)
@@ -38,6 +38,7 @@
 #include <stand.h>
 
 #include "bootstrap.h"
+#include "libuboot.h"
 
 extern vm_offset_t md_load(char *, vm_offset_t *);
 
@@ -69,6 +70,7 @@
 	vm_offset_t mdp;
 	Elf_Ehdr *e;
 	int error;
+	void (*entry)(void *);
 
 	if ((fmp = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL)
 		return (EFTYPE);
@@ -78,11 +80,12 @@
 	if ((error = md_load(fp->f_args, &mdp)) != 0)
 		return (error);
 
-	printf("Kernel entry at 0x%x ...\n", e->e_entry);
+	entry = uboot_vm_translate(e->e_entry);
+	printf("Kernel entry at 0x%x...\n", (unsigned)entry);
 
 	dev_cleanup();
 
-	(*(void (*)())e->e_entry)((void *)mdp);
+	(*entry)((void *)mdp);
 	panic("exec returned");
 }
 

Modified: soc2012/aleek/beaglexm-armv6/sys/boot/uboot/lib/libuboot.h
==============================================================================
--- soc2012/aleek/beaglexm-armv6/sys/boot/uboot/lib/libuboot.h	Tue Jun 26 13:07:43 2012	(r238334)
+++ soc2012/aleek/beaglexm-armv6/sys/boot/uboot/lib/libuboot.h	Tue Jun 26 13:35:19 2012	(r238335)
@@ -45,6 +45,7 @@
 
 #define PTYPE_BSDLABEL	1
 #define PTYPE_GPT	2
+#define PTYPE_MBR	3
 
 /*
  * Default network packet alignment in memory
@@ -59,6 +60,7 @@
 extern struct netif_driver uboot_net;
 extern struct devsw uboot_storage;
 
+void *uboot_vm_translate(vm_offset_t);
 ssize_t	uboot_copyin(const void *src, vm_offset_t dest, const size_t len);
 ssize_t	uboot_copyout(const vm_offset_t src, void *dest, const size_t len);
 ssize_t	uboot_readin(const int fd, vm_offset_t dest, const size_t len);

Modified: soc2012/aleek/beaglexm-armv6/sys/modules/Makefile
==============================================================================
--- soc2012/aleek/beaglexm-armv6/sys/modules/Makefile	Tue Jun 26 13:07:43 2012	(r238334)
+++ soc2012/aleek/beaglexm-armv6/sys/modules/Makefile	Tue Jun 26 13:35:19 2012	(r238335)
@@ -71,6 +71,7 @@
 	${_coff} \
 	${_coretemp} \
 	${_cp} \
+	${_cpsw} \
 	${_cpuctl} \
 	${_cpufreq} \
 	${_crypto} \
@@ -721,6 +722,7 @@
 
 .if ${MACHINE_CPUARCH} == "arm"
 _cfi=		cfi
+_cpsw=		cpsw
 .endif
 
 .if ${MACHINE_CPUARCH} == "ia64"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120626133520.34A041065672>