PERFORCE change 184244 for review
John Baldwin
jhb at FreeBSD.org
Mon Sep 27 20:09:02 UTC 2010
http://p4web.freebsd.org/@@184244?ac=10
Change 184244 by jhb at jhb_jhbbsd on 2010/09/27 20:08:16
IFC @184243
Affected files ...
.. //depot/projects/smpng/sys/amd64/conf/GENERIC#94 integrate
.. //depot/projects/smpng/sys/arm/at91/at91_twi.c#15 integrate
.. //depot/projects/smpng/sys/boot/common/crc32.c#1 branch
.. //depot/projects/smpng/sys/boot/common/crc32.h#1 branch
.. //depot/projects/smpng/sys/boot/common/gpt.c#1 branch
.. //depot/projects/smpng/sys/boot/common/gpt.h#1 branch
.. //depot/projects/smpng/sys/boot/common/util.c#1 branch
.. //depot/projects/smpng/sys/boot/common/util.h#1 branch
.. //depot/projects/smpng/sys/boot/i386/boot2/Makefile#22 integrate
.. //depot/projects/smpng/sys/boot/i386/common/cons.c#1 branch
.. //depot/projects/smpng/sys/boot/i386/common/cons.h#1 branch
.. //depot/projects/smpng/sys/boot/i386/common/drv.c#1 branch
.. //depot/projects/smpng/sys/boot/i386/common/drv.h#1 branch
.. //depot/projects/smpng/sys/boot/i386/common/rbx.h#1 branch
.. //depot/projects/smpng/sys/boot/i386/gptboot/Makefile#3 integrate
.. //depot/projects/smpng/sys/boot/i386/gptboot/gptboot.c#7 integrate
.. //depot/projects/smpng/sys/boot/i386/gptzfsboot/Makefile#4 integrate
.. //depot/projects/smpng/sys/boot/i386/zfsboot/Makefile#4 integrate
.. //depot/projects/smpng/sys/boot/i386/zfsboot/zfsboot.c#9 integrate
.. //depot/projects/smpng/sys/boot/pc98/boot2/Makefile#20 integrate
.. //depot/projects/smpng/sys/boot/zfs/Makefile#5 integrate
.. //depot/projects/smpng/sys/boot/zfs/zfsimpl.c#11 integrate
.. //depot/projects/smpng/sys/cam/cam_xpt.c#69 integrate
.. //depot/projects/smpng/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scrub.c#5 integrate
.. //depot/projects/smpng/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c#7 integrate
.. //depot/projects/smpng/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h#5 integrate
.. //depot/projects/smpng/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h#4 integrate
.. //depot/projects/smpng/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h#4 integrate
.. //depot/projects/smpng/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil.h#5 integrate
.. //depot/projects/smpng/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h#7 integrate
.. //depot/projects/smpng/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c#7 integrate
.. //depot/projects/smpng/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c#4 integrate
.. //depot/projects/smpng/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c#4 integrate
.. //depot/projects/smpng/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fm.c#5 integrate
.. //depot/projects/smpng/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c#7 integrate
.. //depot/projects/smpng/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c#10 integrate
.. //depot/projects/smpng/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_inject.c#3 integrate
.. //depot/projects/smpng/sys/conf/files#266 integrate
.. //depot/projects/smpng/sys/conf/ldscript.mips.octeon1.64#2 integrate
.. //depot/projects/smpng/sys/conf/newvers.sh#31 integrate
.. //depot/projects/smpng/sys/crypto/aesni/aesni.c#2 integrate
.. //depot/projects/smpng/sys/crypto/aesni/aesni.h#2 integrate
.. //depot/projects/smpng/sys/crypto/aesni/aesni_wrap.c#2 integrate
.. //depot/projects/smpng/sys/dev/acpica/acpi.c#126 integrate
.. //depot/projects/smpng/sys/dev/acpica/acpi_cpu.c#54 integrate
.. //depot/projects/smpng/sys/dev/ata/chipsets/ata-ahci.c#13 integrate
.. //depot/projects/smpng/sys/dev/ata/chipsets/ata-siliconimage.c#12 integrate
.. //depot/projects/smpng/sys/dev/bge/if_bge.c#118 integrate
.. //depot/projects/smpng/sys/dev/hifn/hifn7751.c#28 integrate
.. //depot/projects/smpng/sys/dev/hifn/hifn7751var.h#10 integrate
.. //depot/projects/smpng/sys/dev/mii/acphy.c#17 integrate
.. //depot/projects/smpng/sys/dev/mii/bmtphy.c#11 integrate
.. //depot/projects/smpng/sys/dev/mii/exphy.c#16 integrate
.. //depot/projects/smpng/sys/dev/mii/gentbi.c#5 integrate
.. //depot/projects/smpng/sys/dev/mii/icsphy.c#2 integrate
.. //depot/projects/smpng/sys/dev/mii/lxtphy.c#18 integrate
.. //depot/projects/smpng/sys/dev/mii/mii.h#4 integrate
.. //depot/projects/smpng/sys/dev/mii/nsphy.c#18 integrate
.. //depot/projects/smpng/sys/dev/mii/nsphyter.c#2 integrate
.. //depot/projects/smpng/sys/dev/mii/qsphy.c#16 integrate
.. //depot/projects/smpng/sys/dev/mii/tlphy.c#18 integrate
.. //depot/projects/smpng/sys/dev/mii/tlphyreg.h#3 integrate
.. //depot/projects/smpng/sys/dev/mii/ukphy.c#14 integrate
.. //depot/projects/smpng/sys/dev/mpt/mpt.c#30 integrate
.. //depot/projects/smpng/sys/dev/mpt/mpt.h#30 integrate
.. //depot/projects/smpng/sys/dev/stge/if_stge.c#15 integrate
.. //depot/projects/smpng/sys/dev/usb/net/if_axe.c#15 integrate
.. //depot/projects/smpng/sys/dev/usb/usbdevs#159 integrate
.. //depot/projects/smpng/sys/fs/devfs/devfs.h#26 integrate
.. //depot/projects/smpng/sys/fs/devfs/devfs_devs.c#38 integrate
.. //depot/projects/smpng/sys/fs/devfs/devfs_dir.c#1 branch
.. //depot/projects/smpng/sys/fs/devfs/devfs_int.h#8 integrate
.. //depot/projects/smpng/sys/fs/devfs/devfs_vnops.c#91 integrate
.. //depot/projects/smpng/sys/geom/eli/g_eli.c#29 integrate
.. //depot/projects/smpng/sys/geom/eli/g_eli.h#11 integrate
.. //depot/projects/smpng/sys/geom/eli/g_eli_crypto.c#6 integrate
.. //depot/projects/smpng/sys/geom/eli/g_eli_ctl.c#11 integrate
.. //depot/projects/smpng/sys/geom/eli/g_eli_integrity.c#3 integrate
.. //depot/projects/smpng/sys/geom/eli/g_eli_key.c#5 integrate
.. //depot/projects/smpng/sys/geom/eli/g_eli_privacy.c#2 integrate
.. //depot/projects/smpng/sys/geom/part/g_part.c#30 integrate
.. //depot/projects/smpng/sys/geom/part/g_part_gpt.c#17 integrate
.. //depot/projects/smpng/sys/geom/part/g_part_mbr.c#10 integrate
.. //depot/projects/smpng/sys/geom/part/g_part_pc98.c#12 integrate
.. //depot/projects/smpng/sys/i386/conf/GENERIC#123 integrate
.. //depot/projects/smpng/sys/i386/i386/machdep.c#160 integrate
.. //depot/projects/smpng/sys/ia64/include/_stdint.h#3 integrate
.. //depot/projects/smpng/sys/ia64/include/bus.h#22 integrate
.. //depot/projects/smpng/sys/kern/kern_clocksource.c#3 integrate
.. //depot/projects/smpng/sys/kern/kern_linker.c#108 integrate
.. //depot/projects/smpng/sys/kern/subr_kdb.c#26 integrate
.. //depot/projects/smpng/sys/kern/subr_stack.c#9 integrate
.. //depot/projects/smpng/sys/libkern/inet_ntop.c#1 branch
.. //depot/projects/smpng/sys/libkern/inet_pton.c#1 branch
.. //depot/projects/smpng/sys/mips/cavium/ciu.c#2 integrate
.. //depot/projects/smpng/sys/mips/cavium/files.octeon1#4 integrate
.. //depot/projects/smpng/sys/mips/cavium/octe/cavium-ethernet.h#2 integrate
.. //depot/projects/smpng/sys/mips/cavium/octe/ethernet-rgmii.c#2 integrate
.. //depot/projects/smpng/sys/mips/cavium/octe/ethernet-rx.c#2 integrate
.. //depot/projects/smpng/sys/mips/cavium/octe/ethernet-sgmii.c#2 integrate
.. //depot/projects/smpng/sys/mips/cavium/octe/ethernet-tx.c#2 integrate
.. //depot/projects/smpng/sys/mips/cavium/octe/ethernet-xaui.c#2 integrate
.. //depot/projects/smpng/sys/mips/cavium/octe/ethernet.c#2 integrate
.. //depot/projects/smpng/sys/mips/cavium/octe/octe.c#2 integrate
.. //depot/projects/smpng/sys/mips/cavium/octopci.c#3 integrate
.. //depot/projects/smpng/sys/mips/cavium/octopcireg.h#2 integrate
.. //depot/projects/smpng/sys/mips/include/pmap.h#17 integrate
.. //depot/projects/smpng/sys/mips/mips/pmap.c#26 integrate
.. //depot/projects/smpng/sys/mips/rmi/board.h#5 integrate
.. //depot/projects/smpng/sys/mips/rmi/pic.h#4 integrate
.. //depot/projects/smpng/sys/mips/rmi/xlr_pci.c#5 integrate
.. //depot/projects/smpng/sys/mips/sibyte/sb_zbpci.c#3 integrate
.. //depot/projects/smpng/sys/modules/krpc/Makefile#3 integrate
.. //depot/projects/smpng/sys/net/if_tap.c#55 integrate
.. //depot/projects/smpng/sys/net/if_tun.c#69 integrate
.. //depot/projects/smpng/sys/netinet/in.h#53 integrate
.. //depot/projects/smpng/sys/netinet/in_rmx.c#32 integrate
.. //depot/projects/smpng/sys/netinet/ip_output.c#121 integrate
.. //depot/projects/smpng/sys/netinet/siftr.c#3 integrate
.. //depot/projects/smpng/sys/netinet/tcp_reass.c#14 integrate
.. //depot/projects/smpng/sys/netinet/tcp_subr.c#126 integrate
.. //depot/projects/smpng/sys/netinet/tcp_var.h#79 integrate
.. //depot/projects/smpng/sys/netinet6/in6_rmx.c#27 integrate
.. //depot/projects/smpng/sys/netinet6/ip6_output.c#73 integrate
.. //depot/projects/smpng/sys/nlm/nlm_prot_impl.c#9 integrate
.. //depot/projects/smpng/sys/opencrypto/cryptodev.c#31 integrate
.. //depot/projects/smpng/sys/opencrypto/cryptodev.h#12 integrate
.. //depot/projects/smpng/sys/opencrypto/cryptosoft.c#19 integrate
.. //depot/projects/smpng/sys/opencrypto/xform.c#9 integrate
.. //depot/projects/smpng/sys/opencrypto/xform.h#5 integrate
.. //depot/projects/smpng/sys/pc98/conf/GENERIC#93 integrate
.. //depot/projects/smpng/sys/powerpc/conf/GENERIC#70 integrate
.. //depot/projects/smpng/sys/powerpc/conf/GENERIC64#4 integrate
.. //depot/projects/smpng/sys/rpc/inet_ntop.c#2 delete
.. //depot/projects/smpng/sys/rpc/inet_pton.c#2 delete
.. //depot/projects/smpng/sys/rpc/rpc_com.h#3 integrate
.. //depot/projects/smpng/sys/rpc/rpc_generic.c#4 integrate
.. //depot/projects/smpng/sys/sparc64/conf/GENERIC#107 integrate
.. //depot/projects/smpng/sys/sparc64/sparc64/elf_machdep.c#28 integrate
.. //depot/projects/smpng/sys/sun4v/conf/GENERIC#24 integrate
.. //depot/projects/smpng/sys/sys/disklabel.h#34 integrate
.. //depot/projects/smpng/sys/sys/gpt.h#11 integrate
.. //depot/projects/smpng/sys/sys/proc.h#211 integrate
Differences ...
==== //depot/projects/smpng/sys/amd64/conf/GENERIC#94 (text+ko) ====
@@ -16,7 +16,7 @@
# If you are in doubt as to the purpose or necessity of a line, check first
# in NOTES.
#
-# $FreeBSD: src/sys/amd64/conf/GENERIC,v 1.548 2010/09/10 15:03:56 ken Exp $
+# $FreeBSD: src/sys/amd64/conf/GENERIC,v 1.549 2010/09/24 09:04:16 davidxu Exp $
cpu HAMMER
ident GENERIC
@@ -55,7 +55,6 @@
options SYSVSHM # SYSV-style shared memory
options SYSVMSG # SYSV-style message queues
options SYSVSEM # SYSV-style semaphores
-options P1003_1B_SEMAPHORES # POSIX-style semaphores
options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
options PRINTF_BUFR_SIZE=128 # Prevent printf output being interspersed.
options KBD_INSTALL_CDEV # install a CDEV entry in /dev
==== //depot/projects/smpng/sys/arm/at91/at91_twi.c#15 (text) ====
@@ -24,7 +24,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/arm/at91/at91_twi.c,v 1.15 2009/06/11 17:05:13 avg Exp $");
+__FBSDID("$FreeBSD: src/sys/arm/at91/at91_twi.c,v 1.17 2010/09/27 15:58:19 ticso Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -338,7 +338,7 @@
err = EINVAL;
goto out;
}
- if (len == 1)
+ if (len == 1 && msgs[i].flags & IIC_M_RD)
WR4(sc, TWI_CR, TWI_CR_START | TWI_CR_STOP);
else
WR4(sc, TWI_CR, TWI_CR_START);
@@ -348,7 +348,7 @@
if ((sr = RD4(sc, TWI_SR)) & TWI_SR_RXRDY) {
len--;
*buf++ = RD4(sc, TWI_RHR) & 0xff;
- if (len == 0 && msgs[i].len != 1)
+ if (len == 1)
WR4(sc, TWI_CR, TWI_CR_STOP);
}
}
@@ -358,8 +358,6 @@
}
} else {
while (len--) {
- if (len == 0 && msgs[i].len != 1)
- WR4(sc, TWI_CR, TWI_CR_STOP);
if ((err = at91_twi_wait(sc, TWI_SR_TXRDY)))
goto out;
WR4(sc, TWI_THR, *buf++);
==== //depot/projects/smpng/sys/boot/i386/boot2/Makefile#22 (text+ko) ====
@@ -1,11 +1,9 @@
-# $FreeBSD: src/sys/boot/i386/boot2/Makefile,v 1.64 2010/08/31 17:33:29 dim Exp $
+# $FreeBSD: src/sys/boot/i386/boot2/Makefile,v 1.65 2010/09/21 21:41:45 dim Exp $
.include <bsd.own.mk>
# XXX: clang can compile the boot code just fine, but boot2 gets too big
-.if ${CC:T:Mclang} == "clang"
-CC=gcc
-.endif
+CC:=${CC:C/^(.*\/)?clang$/gcc/1}
FILES= boot boot1 boot2
==== //depot/projects/smpng/sys/boot/i386/gptboot/Makefile#3 (text+ko) ====
@@ -1,6 +1,6 @@
-# $FreeBSD: src/sys/boot/i386/gptboot/Makefile,v 1.63 2010/08/23 01:42:09 imp Exp $
+# $FreeBSD: src/sys/boot/i386/gptboot/Makefile,v 1.64 2010/09/24 19:49:12 pjd Exp $
-.PATH: ${.CURDIR}/../boot2
+.PATH: ${.CURDIR}/../boot2 ${.CURDIR}/../common ${.CURDIR}/../../common
FILES= gptboot
@@ -19,18 +19,21 @@
#GPTBOOT_UFS?= UFS2_ONLY
#GPTBOOT_UFS?= UFS1_ONLY
-CFLAGS= -Os \
+CFLAGS= -DBOOTPROG=\"gptboot\" \
+ -Os \
-fno-guess-branch-probability \
-fomit-frame-pointer \
-fno-unit-at-a-time \
-mno-align-long-strings \
-mrtd \
-mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 \
+ -DGPT \
-D${GPTBOOT_UFS} \
-DSIOPRT=${BOOT_COMCONSOLE_PORT} \
-DSIOFMT=${B2SIOFMT} \
-DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
-I${.CURDIR}/../../common \
+ -I${.CURDIR}/../common \
-I${.CURDIR}/../btx/lib -I. \
-I${.CURDIR}/../boot2 \
-Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
@@ -57,13 +60,13 @@
gptldr.out: gptldr.o
${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} gptldr.o
-CLEANFILES+= gptboot.bin gptboot.out gptboot.o sio.o
+CLEANFILES+= gptboot.bin gptboot.out gptboot.o sio.o ufsread.o
gptboot.bin: gptboot.out
objcopy -S -O binary gptboot.out ${.TARGET}
-gptboot.out: ${BTXCRT} gptboot.o sio.o
- ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC}
+gptboot.out: ${BTXCRT} gptboot.o sio.o gpt.o crc32.o drv.o cons.o util.o
+ ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSTAND}
gptboot.o: ${.CURDIR}/../../common/ufsread.c
==== //depot/projects/smpng/sys/boot/i386/gptboot/gptboot.c#7 (text+ko) ====
@@ -14,7 +14,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/boot/i386/gptboot/gptboot.c,v 1.91 2010/03/26 01:30:53 delphij Exp $");
+__FBSDID("$FreeBSD: src/sys/boot/i386/gptboot/gptboot.c,v 1.92 2010/09/24 19:49:12 pjd Exp $");
#include <sys/param.h>
#include <sys/gpt.h>
@@ -32,47 +32,12 @@
#include <btxv86.h>
#include "lib.h"
-
-#define IO_KEYBOARD 1
-#define IO_SERIAL 2
-
-#define SECOND 18 /* Circa that many ticks in a second. */
+#include "rbx.h"
+#include "drv.h"
+#include "util.h"
+#include "cons.h"
+#include "gpt.h"
-#define RBX_ASKNAME 0x0 /* -a */
-#define RBX_SINGLE 0x1 /* -s */
-/* 0x2 is reserved for log2(RB_NOSYNC). */
-/* 0x3 is reserved for log2(RB_HALT). */
-/* 0x4 is reserved for log2(RB_INITNAME). */
-#define RBX_DFLTROOT 0x5 /* -r */
-#define RBX_KDB 0x6 /* -d */
-/* 0x7 is reserved for log2(RB_RDONLY). */
-/* 0x8 is reserved for log2(RB_DUMP). */
-/* 0x9 is reserved for log2(RB_MINIROOT). */
-#define RBX_CONFIG 0xa /* -c */
-#define RBX_VERBOSE 0xb /* -v */
-#define RBX_SERIAL 0xc /* -h */
-#define RBX_CDROM 0xd /* -C */
-/* 0xe is reserved for log2(RB_POWEROFF). */
-#define RBX_GDB 0xf /* -g */
-#define RBX_MUTE 0x10 /* -m */
-/* 0x11 is reserved for log2(RB_SELFTEST). */
-/* 0x12 is reserved for boot programs. */
-/* 0x13 is reserved for boot programs. */
-#define RBX_PAUSE 0x14 /* -p */
-#define RBX_QUIET 0x15 /* -q */
-#define RBX_NOINTR 0x1c /* -n */
-/* 0x1d is reserved for log2(RB_MULTIPLE) and is just misnamed here. */
-#define RBX_DUAL 0x1d /* -D */
-/* 0x1f is reserved for log2(RB_BOOTINFO). */
-
-/* pass: -a, -s, -r, -d, -c, -v, -h, -C, -g, -m, -p, -D */
-#define RBX_MASK (OPT_SET(RBX_ASKNAME) | OPT_SET(RBX_SINGLE) | \
- OPT_SET(RBX_DFLTROOT) | OPT_SET(RBX_KDB ) | \
- OPT_SET(RBX_CONFIG) | OPT_SET(RBX_VERBOSE) | \
- OPT_SET(RBX_SERIAL) | OPT_SET(RBX_CDROM) | \
- OPT_SET(RBX_GDB ) | OPT_SET(RBX_MUTE) | \
- OPT_SET(RBX_PAUSE) | OPT_SET(RBX_DUAL))
-
#define PATH_CONFIG "/boot.config"
#define PATH_BOOT3 "/boot/loader"
#define PATH_KERNEL "/boot/kernel/kernel"
@@ -82,8 +47,6 @@
#define NDEV 3
#define MEM_BASE 0x12
#define MEM_EXT 0x15
-#define V86_CY(x) ((x) & PSL_C)
-#define V86_ZR(x) ((x) & PSL_Z)
#define DRV_HARD 0x80
#define DRV_MASK 0x7f
@@ -93,211 +56,178 @@
#define TYPE_MAXHARD TYPE_DA
#define TYPE_FD 2
-#define OPT_SET(opt) (1 << (opt))
-#define OPT_CHECK(opt) ((opts) & OPT_SET(opt))
-
extern uint32_t _end;
static const uuid_t freebsd_ufs_uuid = GPT_ENT_TYPE_FREEBSD_UFS;
static const char optstr[NOPT] = "DhaCcdgmnpqrsv"; /* Also 'P', 'S' */
static const unsigned char flags[NOPT] = {
- RBX_DUAL,
- RBX_SERIAL,
- RBX_ASKNAME,
- RBX_CDROM,
- RBX_CONFIG,
- RBX_KDB,
- RBX_GDB,
- RBX_MUTE,
- RBX_NOINTR,
- RBX_PAUSE,
- RBX_QUIET,
- RBX_DFLTROOT,
- RBX_SINGLE,
- RBX_VERBOSE
+ RBX_DUAL,
+ RBX_SERIAL,
+ RBX_ASKNAME,
+ RBX_CDROM,
+ RBX_CONFIG,
+ RBX_KDB,
+ RBX_GDB,
+ RBX_MUTE,
+ RBX_NOINTR,
+ RBX_PAUSE,
+ RBX_QUIET,
+ RBX_DFLTROOT,
+ RBX_SINGLE,
+ RBX_VERBOSE
};
+uint32_t opts;
static const char *const dev_nm[NDEV] = {"ad", "da", "fd"};
static const unsigned char dev_maj[NDEV] = {30, 4, 2};
-static struct dsk {
- unsigned drive;
- unsigned type;
- unsigned unit;
- int part;
- daddr_t start;
- int init;
-} dsk;
-static char cmd[512], cmddup[512];
+static struct dsk dsk;
static char kname[1024];
-static uint32_t opts;
static int comspeed = SIOSPD;
static struct bootinfo bootinfo;
-static uint8_t ioctrl = IO_KEYBOARD;
void exit(int);
-static int bcmp(const void *, const void *, size_t);
static void load(void);
-static int parse(void);
+static int parse(char *, int *);
static int xfsread(ino_t, void *, size_t);
static int dskread(void *, daddr_t, unsigned);
-static void printf(const char *,...);
-static void putchar(int);
-static void memcpy(void *, const void *, int);
static uint32_t memsize(void);
-static int drvread(void *, daddr_t, unsigned);
-static int keyhit(unsigned);
-static int xputc(int);
-static int xgetc(int);
-static int getc(int);
-static void
-memcpy(void *dst, const void *src, int len)
-{
- const char *s = src;
- char *d = dst;
-
- while (len--)
- *d++ = *s++;
-}
-
-static inline int
-strcmp(const char *s1, const char *s2)
-{
- for (; *s1 == *s2 && *s1; s1++, s2++);
- return (unsigned char)*s1 - (unsigned char)*s2;
-}
-
#include "ufsread.c"
static inline int
xfsread(ino_t inode, void *buf, size_t nbyte)
{
- if ((size_t)fsread(inode, buf, nbyte) != nbyte) {
- printf("Invalid %s\n", "format");
- return -1;
- }
- return 0;
+
+ if ((size_t)fsread(inode, buf, nbyte) != nbyte) {
+ printf("Invalid %s\n", "format");
+ return (-1);
+ }
+ return (0);
}
static inline uint32_t
memsize(void)
{
- v86.addr = MEM_EXT;
- v86.eax = 0x8800;
- v86int();
- return v86.eax;
+
+ v86.addr = MEM_EXT;
+ v86.eax = 0x8800;
+ v86int();
+ return (v86.eax);
}
-static inline void
-getstr(void)
+static int
+gptinit(void)
{
- char *s;
- int c;
- s = cmd;
- for (;;) {
- switch (c = xgetc(0)) {
- case 0:
- break;
- case '\177':
- case '\b':
- if (s > cmd) {
- s--;
- printf("\b \b");
- }
- break;
- case '\n':
- case '\r':
- *s = 0;
- return;
- default:
- if (s - cmd < sizeof(cmd) - 1)
- *s++ = c;
- putchar(c);
+ if (gptread(&freebsd_ufs_uuid, &dsk, dmadat->secbuf) == -1) {
+ printf("%s: unable to load GPT\n", BOOTPROG);
+ return (-1);
+ }
+ if (gptfind(&freebsd_ufs_uuid, &dsk, dsk.part) == -1) {
+ printf("%s: no UFS partition was found\n", BOOTPROG);
+ return (-1);
}
- }
+ dsk_meta = 0;
+ return (0);
}
-static inline void
-putc(int c)
-{
- v86.addr = 0x10;
- v86.eax = 0xe00 | (c & 0xff);
- v86.ebx = 0x7;
- v86int();
-}
-
int
main(void)
{
- int autoboot;
- ino_t ino;
+ char cmd[512], cmdtmp[512];
+ int autoboot, dskupdated;
+ ino_t ino;
+
+ dmadat = (void *)(roundup2(__base + (int32_t)&_end, 0x10000) - __base);
+ v86.ctl = V86_FLAGS;
+ v86.efl = PSL_RESERVED_DEFAULT | PSL_I;
+ dsk.drive = *(uint8_t *)PTOV(ARGS);
+ dsk.type = dsk.drive & DRV_HARD ? TYPE_AD : TYPE_FD;
+ dsk.unit = dsk.drive & DRV_MASK;
+ dsk.part = -1;
+ dsk.start = 0;
+ bootinfo.bi_version = BOOTINFO_VERSION;
+ bootinfo.bi_size = sizeof(bootinfo);
+ bootinfo.bi_basemem = 0; /* XXX will be filled by loader or kernel */
+ bootinfo.bi_extmem = memsize();
+ bootinfo.bi_memsizes_valid++;
- dmadat = (void *)(roundup2(__base + (int32_t)&_end, 0x10000) - __base);
- v86.ctl = V86_FLAGS;
- v86.efl = PSL_RESERVED_DEFAULT | PSL_I;
- dsk.drive = *(uint8_t *)PTOV(ARGS);
- dsk.type = dsk.drive & DRV_HARD ? TYPE_AD : TYPE_FD;
- dsk.unit = dsk.drive & DRV_MASK;
- dsk.part = -1;
- bootinfo.bi_version = BOOTINFO_VERSION;
- bootinfo.bi_size = sizeof(bootinfo);
- bootinfo.bi_basemem = 0; /* XXX will be filled by loader or kernel */
- bootinfo.bi_extmem = memsize();
- bootinfo.bi_memsizes_valid++;
+ /* Process configuration file */
- /* Process configuration file */
+ if (gptinit() != 0)
+ return (-1);
- autoboot = 1;
+ autoboot = 1;
+ *cmd = '\0';
- if ((ino = lookup(PATH_CONFIG)))
- fsread(ino, cmd, sizeof(cmd));
+ for (;;) {
+ *kname = '\0';
+ ino = lookup(PATH_CONFIG);
+ if (ino > 0)
+ fsread(ino, cmd, sizeof(cmd));
- if (*cmd) {
- memcpy(cmddup, cmd, sizeof(cmd));
- if (parse())
- autoboot = 0;
- if (!OPT_CHECK(RBX_QUIET))
- printf("%s: %s", PATH_CONFIG, cmddup);
- /* Do not process this command twice */
- *cmd = 0;
- }
+ if (*cmd != '\0') {
+ memcpy(cmdtmp, cmd, sizeof(cmdtmp));
+ if (parse(cmdtmp, &dskupdated))
+ break;
+ if (dskupdated && gptinit() != 0)
+ break;
+ if (!OPT_CHECK(RBX_QUIET))
+ printf("%s: %s", PATH_CONFIG, cmd);
+ *cmd = '\0';
+ }
- /*
- * Try to exec stage 3 boot loader. If interrupted by a keypress,
- * or in case of failure, try to load a kernel directly instead.
- */
+ if (autoboot && keyhit(3)) {
+ if (*kname == '\0')
+ memcpy(kname, PATH_BOOT3, sizeof(PATH_BOOT3));
+ break;
+ }
+ autoboot = 0;
- if (autoboot && !*kname) {
- memcpy(kname, PATH_BOOT3, sizeof(PATH_BOOT3));
- if (!keyhit(3*SECOND)) {
- load();
- memcpy(kname, PATH_KERNEL, sizeof(PATH_KERNEL));
+ /*
+ * Try to exec stage 3 boot loader. If interrupted by a
+ * keypress, or in case of failure, try to load a kernel
+ * directly instead.
+ */
+ if (*kname != '\0')
+ load();
+ memcpy(kname, PATH_BOOT3, sizeof(PATH_BOOT3));
+ load();
+ memcpy(kname, PATH_KERNEL, sizeof(PATH_KERNEL));
+ load();
+ gptbootfailed(&dsk);
+ if (gptfind(&freebsd_ufs_uuid, &dsk, -1) == -1)
+ break;
+ dsk_meta = 0;
}
- }
- /* Present the user with the boot2 prompt. */
+ /* Present the user with the boot2 prompt. */
- for (;;) {
- if (!autoboot || !OPT_CHECK(RBX_QUIET))
- printf("\nFreeBSD/x86 boot\n"
- "Default: %u:%s(%up%u)%s\n"
- "boot: ",
- dsk.drive & DRV_MASK, dev_nm[dsk.type], dsk.unit,
- dsk.part, kname);
- if (ioctrl & IO_SERIAL)
- sio_flush();
- if (!autoboot || keyhit(5*SECOND))
- getstr();
- else if (!autoboot || !OPT_CHECK(RBX_QUIET))
- putchar('\n');
- autoboot = 0;
- if (parse())
- putchar('\a');
- else
- load();
- }
+ for (;;) {
+ if (!OPT_CHECK(RBX_QUIET)) {
+ printf("\nFreeBSD/x86 boot\n"
+ "Default: %u:%s(%up%u)%s\n"
+ "boot: ",
+ dsk.drive & DRV_MASK, dev_nm[dsk.type], dsk.unit,
+ dsk.part, kname);
+ }
+ if (ioctrl & IO_SERIAL)
+ sio_flush();
+ *cmd = '\0';
+ if (keyhit(0))
+ getstr(cmd, sizeof(cmd));
+ else if (!OPT_CHECK(RBX_QUIET))
+ putchar('\n');
+ if (parse(cmd, &dskupdated)) {
+ putchar('\a');
+ continue;
+ }
+ if (dskupdated && gptinit() != 0)
+ continue;
+ load();
+ }
+ /* NOTREACHED */
}
/* XXX - Needed for btxld to link the boot2 binary; do not remove. */
@@ -321,8 +251,11 @@
int fmt, i, j;
if (!(ino = lookup(kname))) {
- if (!ls)
- printf("No %s\n", kname);
+ if (!ls) {
+ printf("%s: No %s on %u:%s(%up%u)\n", BOOTPROG,
+ kname, dsk.drive & DRV_MASK, dev_nm[dsk.type], dsk.unit,
+ dsk.part);
+ }
return;
}
if (xfsread(ino, &hdr, sizeof(hdr)))
@@ -402,14 +335,15 @@
}
static int
-parse(void)
+parse(char *cmdstr, int *dskupdated)
{
- char *arg = cmd;
+ char *arg = cmdstr;
char *ep, *p, *q;
const char *cp;
unsigned int drv;
int c, i, j;
+ *dskupdated = 0;
while ((c = *arg++)) {
if (c == ' ' || c == '\t' || c == '\n')
continue;
@@ -480,7 +414,7 @@
drv = dsk.unit;
dsk.drive = (dsk.type <= TYPE_MAXHARD
? DRV_HARD : 0) + drv;
- dsk_meta = 0;
+ *dskupdated = 1;
}
if ((i = ep - arg)) {
if ((size_t)i >= sizeof(kname))
@@ -496,232 +430,6 @@
static int
dskread(void *buf, daddr_t lba, unsigned nblk)
{
- struct gpt_hdr hdr;
- struct gpt_ent *ent;
- char *sec;
- daddr_t slba, elba;
- int part, entries_per_sec;
- if (!dsk_meta) {
- /* Read and verify GPT. */
- sec = dmadat->secbuf;
- dsk.start = 0;
- if (drvread(sec, 1, 1))
- return -1;
- memcpy(&hdr, sec, sizeof(hdr));
- if (bcmp(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) {
- printf("Invalid GPT header\n");
- return -1;
- }
-
- /* XXX: CRC check? */
-
- /*
- * If the partition isn't specified, then search for the first UFS
- * partition and hope it is /. Perhaps we should be using an OS
- * flag in the GPT entry to mark / partitions.
- *
- * If the partition is specified, then figure out the LBA for the
- * sector containing that partition index and load it.
- */
- entries_per_sec = DEV_BSIZE / hdr.hdr_entsz;
- if (dsk.part == -1) {
- slba = hdr.hdr_lba_table;
- elba = slba + hdr.hdr_entries / entries_per_sec;
- while (slba < elba && dsk.part == -1) {
- if (drvread(sec, slba, 1))
- return -1;
- for (part = 0; part < entries_per_sec; part++) {
- ent = (struct gpt_ent *)(sec + part * hdr.hdr_entsz);
- if (bcmp(&ent->ent_type, &freebsd_ufs_uuid,
- sizeof(uuid_t)) == 0) {
- dsk.part = (slba - hdr.hdr_lba_table) *
- entries_per_sec + part + 1;
- dsk.start = ent->ent_lba_start;
- break;
- }
- }
- slba++;
- }
- if (dsk.part == -1) {
- printf("No UFS partition was found\n");
- return -1;
- }
- } else {
- if (dsk.part > hdr.hdr_entries) {
- printf("Invalid partition index\n");
- return -1;
- }
- slba = hdr.hdr_lba_table + (dsk.part - 1) / entries_per_sec;
- if (drvread(sec, slba, 1))
- return -1;
- part = (dsk.part - 1) % entries_per_sec;
- ent = (struct gpt_ent *)(sec + part * hdr.hdr_entsz);
- if (bcmp(&ent->ent_type, &freebsd_ufs_uuid, sizeof(uuid_t)) != 0) {
- printf("Specified partition is not UFS\n");
- return -1;
- }
- dsk.start = ent->ent_lba_start;
- }
- /*
- * XXX: No way to detect SCSI vs. ATA currently.
- */
-#if 0
- if (!dsk.init) {
- if (d->d_type == DTYPE_SCSI)
- dsk.type = TYPE_DA;
- dsk.init++;
- }
-#endif
- }
- return drvread(buf, dsk.start + lba, nblk);
-}
-
-static void
-printf(const char *fmt,...)
-{
- va_list ap;
- char buf[10];
- char *s;
- unsigned u;
- int c;
-
- va_start(ap, fmt);
- while ((c = *fmt++)) {
- if (c == '%') {
- c = *fmt++;
- switch (c) {
- case 'c':
- putchar(va_arg(ap, int));
- continue;
- case 's':
- for (s = va_arg(ap, char *); *s; s++)
- putchar(*s);
- continue;
- case 'u':
- u = va_arg(ap, unsigned);
- s = buf;
- do
- *s++ = '0' + u % 10U;
- while (u /= 10U);
- while (--s >= buf)
- putchar(*s);
- continue;
- }
- }
- putchar(c);
- }
- va_end(ap);
- return;
-}
-
-static void
-putchar(int c)
-{
- if (c == '\n')
- xputc('\r');
- xputc(c);
-}
-
-static int
-bcmp(const void *b1, const void *b2, size_t length)
-{
- const char *p1 = b1, *p2 = b2;
-
- if (length == 0)
- return (0);
- do {
- if (*p1++ != *p2++)
- break;
- } while (--length);
- return (length);
-}
-
-static struct {
- uint16_t len;
- uint16_t count;
- uint16_t off;
- uint16_t seg;
- uint64_t lba;
-} packet;
-
-static int
-drvread(void *buf, daddr_t lba, unsigned nblk)
-{
- static unsigned c = 0x2d5c7c2f;
-
- if (!OPT_CHECK(RBX_QUIET))
- printf("%c\b", c = c << 8 | c >> 24);
- packet.len = 0x10;
- packet.count = nblk;
- packet.off = VTOPOFF(buf);
- packet.seg = VTOPSEG(buf);
- packet.lba = lba;
- 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;
-}
-
-static int
-keyhit(unsigned ticks)
-{
- uint32_t t0, t1;
-
- if (OPT_CHECK(RBX_NOINTR))
- return 0;
- t0 = 0;
- for (;;) {
- if (xgetc(1))
- return 1;
- t1 = *(uint32_t *)PTOV(0x46c);
- if (!t0)
- t0 = t1;
- if (t1 < t0 || t1 >= t0 + ticks)
- return 0;
- }
-}
-
-static int
-xputc(int c)
-{
- if (ioctrl & IO_KEYBOARD)
- putc(c);
- if (ioctrl & IO_SERIAL)
- sio_putc(c);
- return c;
-}
-
-static int
-xgetc(int fn)
-{
- if (OPT_CHECK(RBX_NOINTR))
- return 0;
- for (;;) {
- if (ioctrl & IO_KEYBOARD && getc(1))
- return fn ? 1 : getc(0);
- if (ioctrl & IO_SERIAL && sio_ischar())
- return fn ? 1 : sio_getc();
- if (fn)
- return 0;
- }
-}
-
-static int
-getc(int fn)
-{
- v86.addr = 0x16;
- v86.eax = fn << 8;
- v86int();
- return fn == 0 ? v86.eax & 0xff : !V86_ZR(v86.efl);
+ return drvread(&dsk, buf, lba + dsk.start, nblk);
}
==== //depot/projects/smpng/sys/boot/i386/gptzfsboot/Makefile#4 (text+ko) ====
@@ -1,6 +1,8 @@
-# $FreeBSD: src/sys/boot/i386/gptzfsboot/Makefile,v 1.4 2010/08/23 01:42:09 imp Exp $
+# $FreeBSD: src/sys/boot/i386/gptzfsboot/Makefile,v 1.5 2010/09/24 19:49:12 pjd Exp $
-.PATH: ${.CURDIR}/../boot2 ${.CURDIR}/../gptboot ${.CURDIR}/../zfsboot
+.PATH: ${.CURDIR}/../boot2 ${.CURDIR}/../gptboot \
+ ${.CURDIR}/../zfsboot ${.CURDIR}/../common \
+ ${.CURDIR}/../../common
FILES= gptzfsboot
@@ -14,7 +16,8 @@
ORG1= 0x7c00
ORG2= 0x0
-CFLAGS= -Os \
+CFLAGS= -DBOOTPROG=\"gptzfsboot\" \
+ -Os \
-fno-guess-branch-probability \
-fomit-frame-pointer \
-fno-unit-at-a-time \
@@ -26,6 +29,7 @@
-DSIOFMT=${B2SIOFMT} \
-DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
-I${.CURDIR}/../../common \
+ -I${.CURDIR}/../common \
-I${.CURDIR}/../../zfs \
-I${.CURDIR}/../../../cddl/boot/zfs \
-I${.CURDIR}/../btx/lib -I. \
@@ -59,7 +63,7 @@
gptzfsboot.bin: gptzfsboot.out
objcopy -S -O binary gptzfsboot.out ${.TARGET}
-gptzfsboot.out: ${BTXCRT} zfsboot.o sio.o
+gptzfsboot.out: ${BTXCRT} zfsboot.o sio.o gpt.o drv.o cons.o util.o
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list