Date: Sun, 23 Nov 2008 11:07:34 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 153385 for review Message-ID: <200811231107.mANB7YQB008817@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=153385 Change 153385 by hselasky@hselasky_laptop001 on 2008/11/23 11:07:16 IFC @ 1553381 Affected files ... .. //depot/projects/usb/src/sys/amd64/amd64/elf_machdep.c#4 integrate .. //depot/projects/usb/src/sys/amd64/include/atomic.h#4 integrate .. //depot/projects/usb/src/sys/amd64/linux32/linux32_sysvec.c#11 integrate .. //depot/projects/usb/src/sys/arm/arm/elf_machdep.c#5 integrate .. //depot/projects/usb/src/sys/arm/include/atomic.h#5 integrate .. //depot/projects/usb/src/sys/arm/mv/mv_pci.c#2 integrate .. //depot/projects/usb/src/sys/boot/arm/uboot/Makefile#2 integrate .. //depot/projects/usb/src/sys/boot/arm/uboot/conf.c#2 integrate .. //depot/projects/usb/src/sys/boot/arm/uboot/version#2 integrate .. //depot/projects/usb/src/sys/boot/common/interp.c#2 integrate .. //depot/projects/usb/src/sys/boot/i386/Makefile#5 integrate .. //depot/projects/usb/src/sys/boot/i386/gptzfsboot/Makefile#1 branch .. //depot/projects/usb/src/sys/boot/i386/libi386/biosdisk.c#6 integrate .. //depot/projects/usb/src/sys/boot/i386/zfsboot/zfsboot.c#2 integrate .. //depot/projects/usb/src/sys/boot/uboot/lib/devicename.c#2 integrate .. //depot/projects/usb/src/sys/boot/uboot/lib/disk.c#2 integrate .. //depot/projects/usb/src/sys/boot/uboot/lib/glue.c#4 integrate .. //depot/projects/usb/src/sys/boot/uboot/lib/glue.h#4 integrate .. //depot/projects/usb/src/sys/boot/uboot/lib/libuboot.h#2 integrate .. //depot/projects/usb/src/sys/boot/uboot/lib/net.c#4 integrate .. //depot/projects/usb/src/sys/boot/zfs/Makefile#2 integrate .. //depot/projects/usb/src/sys/boot/zfs/zfs.c#2 integrate .. //depot/projects/usb/src/sys/boot/zfs/zfsimpl.c#2 integrate .. //depot/projects/usb/src/sys/cddl/boot/zfs/zfsimpl.h#2 integrate .. //depot/projects/usb/src/sys/cddl/boot/zfs/zfssubr.c#2 integrate .. //depot/projects/usb/src/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_config.c#3 integrate .. //depot/projects/usb/src/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c#3 integrate .. //depot/projects/usb/src/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c#5 integrate .. //depot/projects/usb/src/sys/compat/ia32/ia32_sysvec.c#8 integrate .. //depot/projects/usb/src/sys/compat/svr4/svr4_sysvec.c#5 integrate .. //depot/projects/usb/src/sys/conf/files#42 integrate .. //depot/projects/usb/src/sys/dev/acpica/acpi_hpet.c#8 integrate .. //depot/projects/usb/src/sys/dev/bce/if_bcereg.h#9 integrate .. //depot/projects/usb/src/sys/dev/cardbus/cardbus_device.c#4 integrate .. //depot/projects/usb/src/sys/dev/cardbus/cardbusvar.h#3 integrate .. //depot/projects/usb/src/sys/dev/cxgb/common/cxgb_ael1002.c#7 integrate .. //depot/projects/usb/src/sys/dev/cxgb/common/cxgb_common.h#8 integrate .. //depot/projects/usb/src/sys/dev/cxgb/common/cxgb_t3_hw.c#9 integrate .. //depot/projects/usb/src/sys/dev/cxgb/cxgb_adapter.h#8 integrate .. //depot/projects/usb/src/sys/dev/cxgb/cxgb_config.h#6 integrate .. //depot/projects/usb/src/sys/dev/cxgb/cxgb_main.c#11 integrate .. //depot/projects/usb/src/sys/dev/cxgb/cxgb_multiq.c#3 integrate .. //depot/projects/usb/src/sys/dev/cxgb/cxgb_osdep.h#9 integrate .. //depot/projects/usb/src/sys/dev/cxgb/cxgb_sge.c#9 integrate .. //depot/projects/usb/src/sys/dev/cxgb/sys/cxgb_support.c#3 integrate .. //depot/projects/usb/src/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_resource.c#3 integrate .. //depot/projects/usb/src/sys/dev/dcons/dcons_crom.c#3 integrate .. //depot/projects/usb/src/sys/dev/dcons/dcons_os.c#8 integrate .. //depot/projects/usb/src/sys/dev/hwpmc/hwpmc_arm.c#3 integrate .. //depot/projects/usb/src/sys/dev/hwpmc/hwpmc_ia64.c#3 integrate .. //depot/projects/usb/src/sys/dev/hwpmc/hwpmc_powerpc.c#3 integrate .. //depot/projects/usb/src/sys/dev/hwpmc/hwpmc_sparc64.c#3 integrate .. //depot/projects/usb/src/sys/dev/mxge/if_mxge_var.h#8 integrate .. //depot/projects/usb/src/sys/dev/nmdm/nmdm.c#6 integrate .. //depot/projects/usb/src/sys/dev/nxge/xge-osdep.h#3 integrate .. //depot/projects/usb/src/sys/dev/sound/pci/hda/hdac.c#13 integrate .. //depot/projects/usb/src/sys/dev/uart/uart_dev_quicc.c#2 integrate .. //depot/projects/usb/src/sys/i386/i386/elf_machdep.c#4 integrate .. //depot/projects/usb/src/sys/i386/ibcs2/ibcs2_sysvec.c#4 integrate .. //depot/projects/usb/src/sys/i386/include/atomic.h#4 integrate .. //depot/projects/usb/src/sys/i386/include/xen/xen-os.h#3 integrate .. //depot/projects/usb/src/sys/i386/linux/linux_sysvec.c#8 integrate .. //depot/projects/usb/src/sys/ia64/ia64/elf_machdep.c#5 integrate .. //depot/projects/usb/src/sys/ia64/include/atomic.h#5 integrate .. //depot/projects/usb/src/sys/kern/imgact_aout.c#5 integrate .. //depot/projects/usb/src/sys/kern/kern_thr.c#10 integrate .. //depot/projects/usb/src/sys/kern/subr_bufring.c#1 branch .. //depot/projects/usb/src/sys/kern/uipc_socket.c#14 integrate .. //depot/projects/usb/src/sys/mips/mips/elf_machdep.c#3 integrate .. //depot/projects/usb/src/sys/modules/uart/Makefile#3 integrate .. //depot/projects/usb/src/sys/net/if.c#14 integrate .. //depot/projects/usb/src/sys/net/if_ethersubr.c#12 integrate .. //depot/projects/usb/src/sys/net/if_fddisubr.c#7 integrate .. //depot/projects/usb/src/sys/net/if_fwsubr.c#10 integrate .. //depot/projects/usb/src/sys/net/if_lagg.c#10 integrate .. //depot/projects/usb/src/sys/net/if_tun.c#9 integrate .. //depot/projects/usb/src/sys/net/if_var.h#10 integrate .. //depot/projects/usb/src/sys/net/if_vlan.c#9 integrate .. //depot/projects/usb/src/sys/net80211/ieee80211_hostap.c#5 integrate .. //depot/projects/usb/src/sys/net80211/ieee80211_output.c#12 integrate .. //depot/projects/usb/src/sys/net80211/ieee80211_var.h#11 integrate .. //depot/projects/usb/src/sys/net80211/ieee80211_wds.c#4 integrate .. //depot/projects/usb/src/sys/netgraph/ng_base.c#13 integrate .. //depot/projects/usb/src/sys/netgraph/ng_iface.c#7 integrate .. //depot/projects/usb/src/sys/netgraph/ng_l2tp.c#7 integrate .. //depot/projects/usb/src/sys/netgraph/ng_socket.c#7 integrate .. //depot/projects/usb/src/sys/netinet/ip_divert.c#11 integrate .. //depot/projects/usb/src/sys/netinet/raw_ip.c#14 integrate .. //depot/projects/usb/src/sys/powerpc/include/atomic.h#5 integrate .. //depot/projects/usb/src/sys/powerpc/powerpc/elf_machdep.c#4 integrate .. //depot/projects/usb/src/sys/sparc64/include/atomic.h#3 integrate .. //depot/projects/usb/src/sys/sparc64/include/intr_machdep.h#7 integrate .. //depot/projects/usb/src/sys/sparc64/pci/schizo.c#2 integrate .. //depot/projects/usb/src/sys/sparc64/pci/schizoreg.h#2 integrate .. //depot/projects/usb/src/sys/sparc64/pci/schizovar.h#2 integrate .. //depot/projects/usb/src/sys/sparc64/sparc64/elf_machdep.c#6 integrate .. //depot/projects/usb/src/sys/sparc64/sparc64/intr_machdep.c#8 integrate .. //depot/projects/usb/src/sys/sparc64/sparc64/nexus.c#4 integrate .. //depot/projects/usb/src/sys/sun4v/include/atomic.h#3 integrate .. //depot/projects/usb/src/sys/sys/buf_ring.h#1 branch .. //depot/projects/usb/src/sys/sys/bus_dma.h#4 edit .. //depot/projects/usb/src/sys/sys/disklabel.h#3 integrate .. //depot/projects/usb/src/sys/sys/mbuf.h#9 integrate .. //depot/projects/usb/src/sys/sys/param.h#16 integrate .. //depot/projects/usb/src/sys/sys/sysent.h#10 integrate .. //depot/projects/usb/src/sys/ufs/ufs/ufs_dirhash.c#6 integrate .. //depot/projects/usb/src/sys/ufs/ufs/ufs_lookup.c#9 integrate Differences ... ==== //depot/projects/usb/src/sys/amd64/amd64/elf_machdep.c#4 (text+ko) ==== @@ -24,7 +24,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/amd64/amd64/elf_machdep.c,v 1.27 2008/09/24 10:14:37 kib Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/amd64/elf_machdep.c,v 1.28 2008/11/22 12:36:15 kib Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -72,7 +72,8 @@ .sv_copyout_strings = exec_copyout_strings, .sv_setregs = exec_setregs, .sv_fixlimit = NULL, - .sv_maxssiz = NULL + .sv_maxssiz = NULL, + .sv_flags = SV_ABI_FREEBSD | SV_LP64 }; static Elf64_Brandinfo freebsd_brand_info = { ==== //depot/projects/usb/src/sys/amd64/include/atomic.h#4 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/amd64/include/atomic.h,v 1.45 2008/03/16 21:20:48 pjd Exp $ + * $FreeBSD: src/sys/amd64/include/atomic.h,v 1.46 2008/11/22 05:55:56 kmacy Exp $ */ #ifndef _MACHINE_ATOMIC_H_ #define _MACHINE_ATOMIC_H_ @@ -32,6 +32,10 @@ #error this file needs sys/cdefs.h as a prerequisite #endif +#define mb() __asm__ __volatile__ ("mfence;": : :"memory") +#define wmb() __asm__ __volatile__ ("sfence;": : :"memory") +#define rmb() __asm__ __volatile__ ("lfence;": : :"memory") + /* * Various simple operations on memory, each of which is atomic in the * presence of interrupts and multiple processors. ==== //depot/projects/usb/src/sys/amd64/linux32/linux32_sysvec.c#11 (text+ko) ==== @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/amd64/linux32/linux32_sysvec.c,v 1.37 2008/10/19 10:02:26 kib Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/linux32/linux32_sysvec.c,v 1.38 2008/11/22 12:36:15 kib Exp $"); #include "opt_compat.h" #ifndef COMPAT_IA32 @@ -1026,6 +1026,7 @@ .sv_setregs = exec_linux_setregs, .sv_fixlimit = linux32_fixlimit, .sv_maxssiz = &linux32_maxssiz, + .sv_flags = SV_ABI_LINUX | SV_ILP32 | SV_IA32 }; static Elf32_Brandinfo linux_brand = { ==== //depot/projects/usb/src/sys/arm/arm/elf_machdep.c#5 (text+ko) ==== @@ -24,7 +24,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/arm/arm/elf_machdep.c,v 1.9 2008/10/13 18:59:59 raj Exp $"); +__FBSDID("$FreeBSD: src/sys/arm/arm/elf_machdep.c,v 1.10 2008/11/22 12:36:15 kib Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -72,7 +72,8 @@ .sv_copyout_strings = exec_copyout_strings, .sv_setregs = exec_setregs, .sv_fixlimit = NULL, - .sv_maxssiz = NULL + .sv_maxssiz = NULL, + .sv_flags = SV_ABI_FREEBSD | SV_ILP32 }; static Elf32_Brandinfo freebsd_brand_info = { ==== //depot/projects/usb/src/sys/arm/include/atomic.h#5 (text+ko) ==== @@ -33,7 +33,7 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/arm/include/atomic.h,v 1.24 2008/02/05 10:22:33 raj Exp $ + * $FreeBSD: src/sys/arm/include/atomic.h,v 1.25 2008/11/22 05:55:56 kmacy Exp $ */ #ifndef _MACHINE_ATOMIC_H_ @@ -47,6 +47,10 @@ #include <machine/sysarch.h> #endif +#define mb() +#define wmb() +#define rmb() + #ifndef I32_bit #define I32_bit (1 << 7) /* IRQ disable */ #endif ==== //depot/projects/usb/src/sys/arm/mv/mv_pci.c#2 (text+ko) ==== @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/arm/mv/mv_pci.c,v 1.1 2008/11/19 11:30:44 raj Exp $"); +__FBSDID("$FreeBSD: src/sys/arm/mv/mv_pci.c,v 1.2 2008/11/19 17:07:01 raj Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -369,8 +369,10 @@ &sc->sc_rid, sc->sc_info->op_base, sc->sc_info->op_base + sc->sc_info->op_size - 1, sc->sc_info->op_size, RF_ACTIVE); - if (sc->sc_res == NULL) + if (sc->sc_res == NULL) { device_printf(parent, "Could not map pcib memory\n"); + break; + } sc->sc_bst = rman_get_bustag(sc->sc_res); sc->sc_bsh = rman_get_bushandle(sc->sc_res); ==== //depot/projects/usb/src/sys/boot/arm/uboot/Makefile#2 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/boot/arm/uboot/Makefile,v 1.1 2008/10/14 10:11:14 raj Exp $ +# $FreeBSD: src/sys/boot/arm/uboot/Makefile,v 1.2 2008/11/19 17:34:28 raj Exp $ PROG= ubldr NEWVERSWHAT= "U-Boot loader" ${MACHINE_ARCH} @@ -10,8 +10,8 @@ # Architecture-specific loader code SRCS= start.S conf.c vers.c -LOADER_DISK_SUPPORT?= no -LOADER_UFS_SUPPORT?= no +LOADER_DISK_SUPPORT?= yes +LOADER_UFS_SUPPORT?= yes LOADER_CD9660_SUPPORT?= no LOADER_EXT2FS_SUPPORT?= no LOADER_NET_SUPPORT?= yes ==== //depot/projects/usb/src/sys/boot/arm/uboot/conf.c#2 (text+ko) ==== @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/boot/arm/uboot/conf.c,v 1.1 2008/10/14 10:11:14 raj Exp $"); +__FBSDID("$FreeBSD: src/sys/boot/arm/uboot/conf.c,v 1.2 2008/11/19 17:34:28 raj Exp $"); #include <stand.h> #include "bootstrap.h" @@ -38,7 +38,7 @@ struct devsw *devsw[] = { #if defined(LOADER_DISK_SUPPORT) || defined(LOADER_CD9660_SUPPORT) - &uboot_disk, + &uboot_storage, #endif #if defined(LOADER_NET_SUPPORT) &netdev, ==== //depot/projects/usb/src/sys/boot/arm/uboot/version#2 (text+ko) ==== @@ -1,6 +1,7 @@ -$FreeBSD: src/sys/boot/arm/uboot/version,v 1.1 2008/10/14 10:11:14 raj Exp $ +$FreeBSD: src/sys/boot/arm/uboot/version,v 1.2 2008/11/19 17:34:28 raj Exp $ NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this file is important. Make sure the current version number is on line 6. +1.0: Added storage support. Booting from HDD, USB, etc. is now possible. 0.5: Initial U-Boot/arm version (netbooting only). ==== //depot/projects/usb/src/sys/boot/common/interp.c#2 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/boot/common/interp.c,v 1.29 2003/08/25 23:30:41 obrien Exp $"); +__FBSDID("$FreeBSD: src/sys/boot/common/interp.c,v 1.30 2008/11/20 14:57:09 luigi Exp $"); /* * Simple commandline interpreter, toplevel and misc. @@ -92,7 +92,7 @@ void interact(void) { - char input[256]; /* big enough? */ + static char input[256]; /* big enough? */ #ifndef BOOT_FORTH int argc; char **argv; @@ -178,14 +178,21 @@ return(res); } +/* + * Header prepended to each line. The text immediately follows the header. + * We try to make this short in order to save memory -- the loader has + * limited memory available, and some of the forth files are very long. + */ struct includeline { - char *text; + struct includeline *next; +#ifndef BOOT_FORTH int flags; int line; #define SL_QUIET (1<<0) #define SL_IGNOREERR (1<<1) - struct includeline *next; +#endif + char text[0]; }; int @@ -236,13 +243,14 @@ } #endif /* Allocate script line structure and copy line, flags */ + if (*cp == '\0') + continue; /* ignore empty line, save memory */ sp = malloc(sizeof(struct includeline) + strlen(cp) + 1); - sp->text = (char *)sp + sizeof(struct includeline); strcpy(sp->text, cp); #ifndef BOOT_FORTH sp->flags = flags; + sp->line = line; #endif - sp->line = line; sp->next = NULL; if (script == NULL) { ==== //depot/projects/usb/src/sys/boot/i386/Makefile#5 (text+ko) ==== @@ -1,7 +1,7 @@ -# $FreeBSD: src/sys/boot/i386/Makefile,v 1.23 2008/11/17 20:49:29 pjd Exp $ +# $FreeBSD: src/sys/boot/i386/Makefile,v 1.26 2008/11/22 14:24:55 dfr Exp $ SUBDIR= mbr pmbr boot0 boot0sio btx boot2 cdboot gptboot zfsboot \ - kgzldr libi386 libfirewire loader + gptzfsboot kgzldr libi386 libfirewire loader # special boot programs, 'self-extracting boot2+loader' SUBDIR+= pxeldr ==== //depot/projects/usb/src/sys/boot/i386/libi386/biosdisk.c#6 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/boot/i386/libi386/biosdisk.c,v 1.55 2008/02/28 17:49:23 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/boot/i386/libi386/biosdisk.c,v 1.56 2008/11/19 16:04:07 dfr Exp $"); /* * BIOS disk device handling. @@ -969,8 +969,10 @@ od->od_boff = gp->gp_start; out: - if (error) + if (error) { free(od->od_partitions); + od->od_flags &= ~BD_GPTOK; + } return (error); } @@ -1058,7 +1060,7 @@ switch(rw){ case F_READ: - DEBUG("read %d from %d to %p", blks, dblk, buf); + DEBUG("read %d from %lld to %p", blks, dblk, buf); if (blks && bd_read(od, dblk, blks, buf)) { DEBUG("read error"); ==== //depot/projects/usb/src/sys/boot/i386/zfsboot/zfsboot.c#2 (text+ko) ==== @@ -14,11 +14,14 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/boot/i386/zfsboot/zfsboot.c,v 1.1 2008/11/17 20:49:29 pjd Exp $"); +__FBSDID("$FreeBSD: src/sys/boot/i386/zfsboot/zfsboot.c,v 1.2 2008/11/19 16:39:01 dfr Exp $"); #include <sys/param.h> #include <sys/errno.h> #include <sys/diskmbr.h> +#ifdef GPT +#include <sys/gpt.h> +#endif #include <sys/reboot.h> #include <sys/queue.h> @@ -32,7 +35,9 @@ #include <btxv86.h> +#ifndef GPT #include "zfsboot.h" +#endif #include "lib.h" #define IO_KEYBOARD 1 @@ -103,6 +108,9 @@ extern uint32_t _end; +#ifdef GPT +static const uuid_t freebsd_zfs_uuid = GPT_ENT_TYPE_FREEBSD_ZFS; +#endif static const char optstr[NOPT] = "DhaCcdgmnpqrsv"; /* Also 'P', 'S' */ static const unsigned char flags[NOPT] = { RBX_DUAL, @@ -408,6 +416,12 @@ static void probe_drive(struct dsk *dsk, spa_t **spap) { +#ifdef GPT + struct gpt_hdr hdr; + struct gpt_ent *ent; + daddr_t slba, elba; + unsigned part, entries_per_sec; +#endif struct dos_partition *dp; char *sec; unsigned i; @@ -424,6 +438,63 @@ sec = dmadat->secbuf; dsk->start = 0; + +#ifdef GPT + /* + * First check for GPT. + */ + if (drvread(dsk, sec, 1, 1)) { + return; + } + memcpy(&hdr, sec, sizeof(hdr)); + if (memcmp(hdr.hdr_sig, GPT_HDR_SIG, sizeof(hdr.hdr_sig)) != 0 || + hdr.hdr_lba_self != 1 || hdr.hdr_revision < 0x00010000 || + hdr.hdr_entsz < sizeof(*ent) || DEV_BSIZE % hdr.hdr_entsz != 0) { + goto trymbr; + } + + /* + * Probe all GPT partitions for the presense of ZFS pools. We + * return the spa_t for the first we find (if requested). This + * will have the effect of booting from the first pool on the + * disk. + */ + entries_per_sec = DEV_BSIZE / hdr.hdr_entsz; + slba = hdr.hdr_lba_table; + elba = slba + hdr.hdr_entries / entries_per_sec; + while (slba < elba) { + if (drvread(dsk, sec, slba, 1)) + return; + for (part = 0; part < entries_per_sec; part++) { + ent = (struct gpt_ent *)(sec + part * hdr.hdr_entsz); + if (memcmp(&ent->ent_type, &freebsd_zfs_uuid, + sizeof(uuid_t)) == 0) { + dsk->start = ent->ent_lba_start; + if (vdev_probe(vdev_read, dsk, spap) == 0) { + /* + * We record the first pool we find (we will try + * to boot from that one. + */ + spap = 0; + + /* + * This slice had a vdev. We need a new dsk + * structure now since the vdev now owns this one. + */ + struct dsk *newdsk; + newdsk = malloc(sizeof(struct dsk)); + *newdsk = *dsk; + dsk = newdsk; + } + break; + } + } + slba++; + } + return; +trymbr: +#endif + if (drvread(dsk, sec, DOSBBSECTOR, 1)) return; dp = (void *)(sec + DOSPARTOFF); @@ -441,7 +512,7 @@ /* * This slice had a vdev. We need a new dsk structure now - * sice the vdev now owns this one. + * since the vdev now owns this one. */ struct dsk *newdsk; newdsk = malloc(sizeof(struct dsk)); @@ -859,9 +930,42 @@ xputc(c); } +#ifdef GPT +static struct { + uint16_t len; + uint16_t count; + uint16_t seg; + uint16_t off; + uint64_t lba; +} packet; +#endif + static int drvread(struct dsk *dsk, void *buf, unsigned lba, unsigned nblk) { +#ifdef GPT + static unsigned c = 0x2d5c7c2f; + + if (!OPT_CHECK(RBX_QUIET)) + printf("%c\b", c = c << 8 | c >> 24); + packet.len = 0x10; + packet.count = nblk; + packet.seg = VTOPOFF(buf); + packet.off = VTOPSEG(buf); + packet.lba = lba + dsk->start; + v86.ctl = V86_FLAGS; + v86.addr = 0x13; + v86.eax = 0x4200; + v86.edx = dsk->drive; + v86.ds = VTOPSEG(&packet); + v86.esi = VTOPOFF(&packet); + v86int(); + if (V86_CY(v86.efl)) { + printf("error %u lba %u\n", v86.eax >> 8 & 0xff, lba); + return -1; + } + return 0; +#else static unsigned c = 0x2d5c7c2f; lba += dsk->start; @@ -881,6 +985,7 @@ return -1; } return 0; +#endif } static int ==== //depot/projects/usb/src/sys/boot/uboot/lib/devicename.c#2 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/boot/uboot/lib/devicename.c,v 1.2 2008/03/13 17:54:21 obrien Exp $"); +__FBSDID("$FreeBSD: src/sys/boot/uboot/lib/devicename.c,v 1.3 2008/11/19 17:34:28 raj Exp $"); #include <sys/disklabel.h> @@ -64,7 +64,7 @@ /* * Try to parse the device name off the beginning of the devspec. */ - return(uboot_parsedev(dev, devspec, path)); + return (uboot_parsedev(dev, devspec, path)); } /* @@ -78,7 +78,7 @@ * * For disk-type devices, the syntax is: * - * disk<unit>[s<slice>][<partition>]: + * disk<unit>[<partition>]: * */ static int @@ -86,10 +86,10 @@ const char **path) { struct uboot_devdesc *idev; - struct devsw *dv; - char *cp; - const char *np; - int i, unit, slice, partition, err; + struct devsw *dv; + char *cp; + const char *np; + int i, unit, partition, err; /* minimum length check */ if (strlen(devspec) < 2) @@ -110,12 +110,11 @@ np = (devspec + strlen(dv->dv_name)); switch(dv->dv_type) { - case DEVT_NONE: /* XXX what to do here? Do we care? */ + case DEVT_NONE: break; case DEVT_DISK: unit = -1; - slice = -1; partition = -1; if (*np && (*np != ':')) { /* next comes the unit number */ @@ -124,16 +123,8 @@ err = EUNIT; goto fail; } - if (*cp == 's') { /* got a slice number */ - np = cp + 1; - slice = strtol(np, &cp, 10); - if (cp == np) { - err = ESLICE; - goto fail; - } - } if (*cp && (*cp != ':')) { - /* get a partition number */ + /* get partition */ partition = *cp - 'a'; if ((partition < 0) || (partition >= MAXPARTITIONS)) { @@ -145,12 +136,12 @@ } if (*cp && (*cp != ':')) { err = EINVAL; - goto fail; + goto fail; } idev->d_unit = unit; - idev->d_kind.disk.slice = slice; - idev->d_kind.disk.partition = partition; + idev->d_disk.partition = partition; + idev->d_disk.data = NULL; if (path != NULL) *path = (*cp == 0) ? cp : cp + 1; break; @@ -170,10 +161,8 @@ err = EINVAL; goto fail; } + idev->d_unit = unit; - if (dv->dv_type == DEVT_NET) - idev->d_unit = unit; - if (path != NULL) *path = (*cp == 0) ? cp : cp + 1; break; @@ -212,8 +201,6 @@ case DEVT_DISK: cp = buf; cp += sprintf(cp, "%s%d", dev->d_dev->dv_name, dev->d_unit); - if (dev->d_kind.disk.slice > 0) - cp += sprintf(cp, "s%d", dev->d_kind.disk.slice); if (dev->d_kind.disk.partition >= 0) cp += sprintf(cp, "%c", dev->d_kind.disk.partition + 'a'); ==== //depot/projects/usb/src/sys/boot/uboot/lib/disk.c#2 (text+ko) ==== @@ -1,5 +1,5 @@ /*- - * Copyright (C) 2000 Benno Rice. + * Copyright (c) 2008 Semihalf, Rafal Jaworowski * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -11,99 +11,453 @@ * 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 Benno Rice ``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. + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/boot/uboot/lib/disk.c,v 1.2 2008/03/13 17:54:21 obrien Exp $"); - /* - * Disk I/O routines using U-Boot - TODO + * Block storage I/O routines for U-Boot */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD: src/sys/boot/uboot/lib/disk.c,v 1.3 2008/11/19 17:34:28 raj Exp $"); + #include <sys/param.h> #include <sys/queue.h> - #include <netinet/in.h> #include <machine/stdarg.h> #include <stand.h> +#include <uuid.h> + +#define FSTYPENAMES +#include <sys/disklabel.h> +#include "api_public.h" #include "bootstrap.h" +#include "glue.h" +#include "libuboot.h" + +#define DEBUG +#undef DEBUG -static int d_init(void); -static int d_strategy(void *devdata, int flag, daddr_t dblk, - size_t size, char *buf, size_t *rsize); -static int d_open(struct open_file *f, ...); -static int d_close(struct open_file *f); -static int d_ioctl(struct open_file *f, u_long cmd, void *data); -static void d_print(int verbose); +#define stor_printf(fmt, args...) do { \ + printf("%s%d: ", dev->d_dev->dv_name, dev->d_unit); \ + printf(fmt, ##args); \ +} while (0) + +#ifdef DEBUG +#define debugf(fmt, args...) do { printf("%s(): ", __func__); \ + printf(fmt,##args); } while (0) +#else +#define debugf(fmt, args...) +#endif -struct devsw uboot_disk = { - "block", - DEVT_DISK, - d_init, - d_strategy, - d_open, - d_close, - d_ioctl, - d_print +struct gpt_part { + int gp_index; + uuid_t gp_type; + uint64_t gp_start; + uint64_t gp_end; }; -struct opened_dev { - u_int count; - SLIST_ENTRY(opened_dev) link; +struct open_dev { + int od_bsize; /* block size */ + int od_bstart; /* start block offset from beginning of disk */ + int od_type; +#define OD_BSDLABEL 0x0001 +#define OD_GPT 0x0002 + union { + struct { + struct disklabel bsdlabel; + } _bsd; + struct { + struct gpt_part *gpt_partitions; + int gpt_nparts; + } _gpt; + } _data; }; -SLIST_HEAD(, opened_dev) opened_devs = SLIST_HEAD_INITIALIZER(opened_dev); +#define od_bsdlabel _data._bsd.bsdlabel +#define od_nparts _data._gpt.gpt_nparts +#define od_partitions _data._gpt.gpt_partitions + +static int stor_info[UB_MAX_DEV]; +static int stor_info_no = 0; +static int stor_opendev(struct open_dev **, struct uboot_devdesc *); +static int stor_closedev(struct uboot_devdesc *); +static int stor_readdev(struct uboot_devdesc *, daddr_t, size_t, char *); +static int stor_open_count = 0; + +/* devsw I/F */ +static int stor_init(void); +static int stor_strategy(void *, int, daddr_t, size_t, char *, size_t *); +static int stor_open(struct open_file *, ...); +static int stor_close(struct open_file *); +static void stor_print(int); + +struct devsw uboot_storage = { + "disk", + DEVT_DISK, + stor_init, + stor_strategy, + stor_open, + stor_close, + noioctl, + stor_print +}; static int -d_init(void) +stor_init(void) { + struct device_info *di; + int i, found = 0; + + if (devs_no == 0) { + printf("No U-Boot devices! Really enumerated?\n"); + return (-1); + } + + for (i = 0; i < devs_no; i++) { + di = ub_dev_get(i); + if ((di != NULL) && (di->type & DEV_TYP_STOR)) { + if (stor_info_no >= UB_MAX_DEV) { + printf("Too many storage devices: %d\n", + stor_info_no); + return (-1); + } + stor_info[stor_info_no++] = i; + found = 1; + } + } + + if (!found) { + printf("No storage devices\n"); + return (-1); + } - return 0; + debugf("storage devices found: %d\n", stor_info_no); + return (0); } static int -d_strategy(void *devdata, int flag, daddr_t dblk, size_t size, char *buf, +stor_strategy(void *devdata, int rw, daddr_t blk, size_t size, char *buf, size_t *rsize) { + struct uboot_devdesc *dev = (struct uboot_devdesc *)devdata; + struct open_dev *od = (struct open_dev *)dev->d_disk.data; + int bcount, err; + + debugf("od=%p, size=%d, bsize=%d\n", od, size, od->od_bsize); + + if (rw != F_READ) { + stor_printf("write attempt, operation not supported!\n"); + return (EROFS); + } + + if (size % od->od_bsize) { + stor_printf("size=%d not multiple of device block size=%d\n", + size, od->od_bsize); + return (EIO); + } + bcount = size / od->od_bsize; + + if (rsize) + *rsize = 0; + + err = stor_readdev(dev, blk + od->od_bstart, bcount, buf); + if (!err && rsize) + *rsize = size; + + return (err); +} + +static int +stor_open(struct open_file *f, ...) +{ + va_list ap; + struct open_dev *od; + struct uboot_devdesc *dev; + int err; + + va_start(ap, f); + dev = va_arg(ap, struct uboot_devdesc *); + va_end(ap); + + if ((err = stor_opendev(&od, dev)) != 0) + return (err); + + ((struct uboot_devdesc *)(f->f_devdata))->d_disk.data = od; + + return (0); +} + +static int +stor_close(struct open_file *f) +{ + struct uboot_devdesc *dev; + + dev = (struct uboot_devdesc *)(f->f_devdata); + + return (stor_closedev(dev)); +} + +static int +stor_open_gpt(struct open_dev *od, struct uboot_devdesc *dev) +{ + + /* TODO */ + return (ENXIO); +} + +static int +stor_open_bsdlabel(struct open_dev *od, struct uboot_devdesc *dev) +{ + char *buf; + struct disklabel *dl; + int err = 0; + + /* Allocate 1 block */ + buf = malloc(od->od_bsize); + if (!buf) { + stor_printf("could not allocate memory for disklabel\n"); + return (ENOMEM); + } - return (EINVAL); + /* Read disklabel */ + err = stor_readdev(dev, LABELSECTOR, 1, buf); + if (err) { + stor_printf("disklabel read error=%d\n", err); + err = ERDLAB; + goto out; + } + bcopy(buf + LABELOFFSET, &od->od_bsdlabel, sizeof(struct disklabel)); + dl = &od->od_bsdlabel; + + if (dl->d_magic != DISKMAGIC) { + stor_printf("no disklabel magic!\n"); + err = EUNLAB; + goto out; + } + od->od_type = OD_BSDLABEL; + od->od_bstart = dl->d_partitions[dev->d_disk.partition].p_offset; + + debugf("bstart=%d\n", od->od_bstart); + +out: + free(buf); + return (err); } >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811231107.mANB7YQB008817>