From owner-svn-src-projects@FreeBSD.ORG Sun Mar 15 09:26:56 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9A98A106564A; Sun, 15 Mar 2009 09:26:56 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7F39B8FC14; Sun, 15 Mar 2009 09:26:56 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2F9QuYn022521; Sun, 15 Mar 2009 09:26:56 GMT (envelope-from pho@svn.freebsd.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2F9Qu3H022520; Sun, 15 Mar 2009 09:26:56 GMT (envelope-from pho@svn.freebsd.org) Message-Id: <200903150926.n2F9Qu3H022520@svn.freebsd.org> From: Peter Holm Date: Sun, 15 Mar 2009 09:26:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189847 - projects/stress2/misc X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Mar 2009 09:26:56 -0000 Author: pho Date: Sun Mar 15 09:26:56 2009 New Revision: 189847 URL: http://svn.freebsd.org/changeset/base/189847 Log: Added test programs used in the implementation of i386_get/set_ldt() for 32 bit processes on amd64. Submitted by: kib Added: projects/stress2/misc/ldt.sh (contents, props changed) Added: projects/stress2/misc/ldt.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/stress2/misc/ldt.sh Sun Mar 15 09:26:56 2009 (r189847) @@ -0,0 +1,369 @@ +#!/bin/sh + +# +# Copyright (c) 2009 Peter Holm +# 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. +# +# 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. +# +# $FreeBSD$ +# + +# Test the amd64 implementation of: +# 1. Per-process private ldt and corresponding i386 arch syscalls. +# 2. Per-process private io permission bitmap and corresponding +# i386 arch syscalls. +# 3. Sigcontext + +# The tests must be compiled on i386 and run on amd64 + +# All tests by kib@ + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +cd /tmp +if [ "`uname -p`" = "i386" ]; then + cat > ldt.c < +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +char stack[64 * 1024]; + +char a[1]; + +int +s2ds(int sel) +{ + + return (LSEL(sel, SEL_UPL)); +} + +unsigned char +readbyte(int sel, int offset) +{ + unsigned char res; + + __asm__ volatile( + "\tpushl %%es\n" + "\tmovl %1,%%es\n" + "\tmovb %%es:(%2),%0\n" + "\tpopl %%es\n" + : "=r"(res) : "r"(s2ds(sel)), "r"(offset)); + + return (res); +} + +void +writebyte(int sel, int offset, unsigned char val) +{ + + __asm__ volatile( + "\tpushl %%es\n" + "\tmovl %0,%%es\n" + "\tmovb %2,%%es:(%1)\n" + "\tpopl %%es\n" + : : "r"(s2ds(sel)), "r"(offset), "r"(val) : "memory"); +} + +int +alloc_sel(char *base, size_t len, int type, int p) +{ + int sel; + union descriptor descs[1], descsk[1]; + uintptr_t pb; + + memset(descs, 0, sizeof(descs)); + if (len > PAGE_SIZE) { + len = roundup(len, PAGE_SIZE); + len /= PAGE_SIZE; + descs[0].sd.sd_lolimit = len & 0xffff; + descs[0].sd.sd_hilimit = (len >> 16) & 0xf; + descs[0].sd.sd_gran = 1; + } else { + descs[0].sd.sd_lolimit = len; + descs[0].sd.sd_hilimit = 0; + descs[0].sd.sd_gran = 0; + } + pb = (uintptr_t)base; + descs[0].sd.sd_lobase = pb & 0xffffff; + descs[0].sd.sd_hibase = (pb >> 24) & 0xff; + descs[0].sd.sd_type = type; + descs[0].sd.sd_dpl = SEL_UPL; + descs[0].sd.sd_p = p; + descs[0].sd.sd_def32 = 1; + + if ((sel = i386_set_ldt(LDT_AUTO_ALLOC, descs, 1)) == -1) + fprintf(stderr, "i386_set_ldt: %s\n", strerror(errno)); + else if (i386_get_ldt(sel, descsk, 1) == -1) { + fprintf(stderr, "i386_get_ldt: %s\n", strerror(errno)); + sel = -1; + } else if (memcmp(descs, descsk, sizeof(descs)) != 0) { + fprintf(stderr, "descs != descsk\n"); + sel = -1; + } else + fprintf(stderr, "selector %d\n", sel); + + return (sel); +} + +int +test1(int tnum, int sel) +{ + unsigned char ar; + + writebyte(sel, 0, '1'); + ar = readbyte(sel, 0); + if (ar == '1') + fprintf(stderr, "test %d.1 ok\n", tnum); + else + fprintf(stderr, "test%d.1 failed, ar %x\n", tnum, ar); + writebyte(sel, 0, '2'); + ar = readbyte(sel, 0); + if (ar == '2') + fprintf(stderr, "test %d.2 ok\n", tnum); + else + fprintf(stderr, "test%d.2 failed, ar %x\n", tnum, ar); + return (sel); +} + +int +test2_func(void *arg) +{ + int *sel; + + sel = arg; + test1(2, *sel); + rfork(0); + test1(3, *sel); + return (0); +} + +void +test2(int sel) +{ + pid_t r; + int status; + + r = rfork_thread(RFPROC | RFMEM, stack + sizeof(stack), + test2_func, &sel); + if (r == -1) { + fprintf(stderr, "rfork(RFPROC): %s\n", strerror(errno)); + return; + } else { + waitpid(r, &status, 0); + if (WIFSIGNALED(status)) { + fprintf(stderr, "test2: child terminated by %s\n", + strsignal(WTERMSIG(status))); + } + } +} + +int +main(int argc, char *argv[]) +{ + int sel; + + sel = alloc_sel(a, 1, SDT_MEMRWA, 1); + if (sel == -1) + return (1); + + test1(1, sel); + test2(sel); + return (0); +} +EOF + cc -o ldt_static_i386 -Wall -static ldt.c + rm ldt.c + + cat > ioperm.c < +#include +#include +#include +#include +#include + +static const unsigned int port_num = 0x130; + +unsigned char +inb(unsigned int port) +{ + unsigned char data; + + __asm __volatile("inb %%dx,%0" : "=a" (data) : "d" (port)); + return (data); +} + +void +sigbus_handler(int signo) +{ + + fprintf(stderr, "Got SIGBUS\n"); + exit(0); +} + +int +main(int argc, char *argv[]) +{ + struct sigaction sa; + unsigned int length1; + int enable1; + + if (i386_get_ioperm(port_num, &length1, &enable1) == -1) { + fprintf(stderr, "get 1: %s\n", strerror(errno)); + return (1); + } + if (length1 != 0 && enable1 != 0) { + fprintf(stderr, "enable1: enabled\n"); + return (1); + } + if (i386_set_ioperm(port_num, 1, 1) == -1) { + fprintf(stderr, "set 1: %s\n", strerror(errno)); + return (1); + } + inb(port_num); + if (i386_set_ioperm(port_num, 1, 0) == -1) { + fprintf(stderr, "set 2: %s\n", strerror(errno)); + return (1); + } + if (i386_get_ioperm(port_num, &length1, &enable1) == -1) { + fprintf(stderr, "get 1: %s\n", strerror(errno)); + return (1); + } + if (enable1 != 0) { + fprintf(stderr, "enable2: enabled\n"); + return (1); + } + fprintf(stderr, "And now we should get SIGBUS\n"); + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = sigbus_handler; + if (sigaction(SIGBUS, &sa, NULL) == -1) { + fprintf(stderr, "sigaction(SIGBUS): %s\n", strerror(errno)); + return (1); + } + inb(port_num); + + return (0); +} +EOF + cc -o ioperm_static_i386 -Wall -static ioperm.c + rm ioperm.c + + cat > fault.c < +#include +#include +#include +#include +#include +#include +#include + +extern char *fault_instr; +int run; + +void +sigsegv_sigaction(int signo, siginfo_t *si, void *c) +{ + ucontext_t *uc; + mcontext_t *mc; + + uc = c; + mc = &uc->uc_mcontext; + printf("SIGSEGV run %d err %x ds %x ss %x es %x fs %x gs %x\n", + run, mc->mc_err, mc->mc_ds, mc->mc_ss, mc->mc_es, mc->mc_fs, + mc->mc_gs); + switch (run) { + case 0: + mc->mc_ds = 0x1111; + break; + case 1: + mc->mc_es = 0x1111; + break; + case 2: + mc->mc_fs = 0x1111; + break; + case 3: + mc->mc_gs = 0x1111; + break; + case 4: + mc->mc_ss = 0x1111; + break; + case 5: + _exit(11); + } + run++; +} + +void +fault(void) +{ + + __asm__ volatile(".globl\tfault_instr;fault_instr:\ttestl\t\$0,0\n"); +} + +int +main(int argc, char *argv[]) +{ + struct sigaction sa; + + memset(&sa, 0, sizeof(sa)); + sa.sa_sigaction = sigsegv_sigaction; + sa.sa_flags = SA_SIGINFO; + if (sigaction(SIGSEGV, &sa, NULL) == -1) { + fprintf(stderr, "sigaction: %s\n", strerror(errno)); + return (1); + } + if (sigaction(SIGBUS, &sa, NULL) == -1) { + fprintf(stderr, "sigaction: %s\n", strerror(errno)); + return (1); + } + + fault(); + + return (0); +} +EOF + cc -o fault_static_i386 -Wall -static fault.c + rm fault.c +fi + +if [ "`uname -p`" = "amd64" ]; then + [ -x ldt_static_i386 ] && ./ldt_static_i386 + [ -x ioperm_static_i386 ] && ./ioperm_static_i386 + [ -x fault_static_i386 ] && ./fault_static_i386 +fi From owner-svn-src-projects@FreeBSD.ORG Sun Mar 15 14:25:03 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 91533106566B; Sun, 15 Mar 2009 14:25:03 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7F9C98FC0A; Sun, 15 Mar 2009 14:25:03 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2FEP370031508; Sun, 15 Mar 2009 14:25:03 GMT (envelope-from pho@svn.freebsd.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2FEP3sa031507; Sun, 15 Mar 2009 14:25:03 GMT (envelope-from pho@svn.freebsd.org) Message-Id: <200903151425.n2FEP3sa031507@svn.freebsd.org> From: Peter Holm Date: Sun, 15 Mar 2009 14:25:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189852 - projects/stress2/misc X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Mar 2009 14:25:03 -0000 Author: pho Date: Sun Mar 15 14:25:03 2009 New Revision: 189852 URL: http://svn.freebsd.org/changeset/base/189852 Log: Test the implementation of i386_get_ldt() and i386_set_ldt() for 32 bit processes on amd64 by running wine and mplayer with a 32 bit codec. Added: projects/stress2/misc/ldt2.sh (contents, props changed) Added: projects/stress2/misc/ldt2.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/stress2/misc/ldt2.sh Sun Mar 15 14:25:03 2009 (r189852) @@ -0,0 +1,102 @@ +#!/bin/sh + +# +# Copyright (c) 2009 Peter Holm +# 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. +# +# 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. +# + +# Test the implementation of i386_get_ldt() and i386_set_ldt() for 32 bit +# processes on amd64 by running wine and mplayer with a 32 bit codec. + +# This is not a test script, but more of a howto document. + +[ `uname -p` != "amd64" ] && echo "Must run on amd64" && exit + +exit 0 + +This are notes of how to perform the test. + + +First of all you will need a i386 jail on amd64. This could be build like +this: + +cat > jailbuild.sh < mplayer.sh <:0 +while true;do + pos=100 + for i in `jot 5`; do + mplayer -vc rv40win -geometry $pos:$pos /root/samples/Real_Media.rm < \ + /dev/null > /dev/null 2>&1 & + pos=$((pos + 50)) + done + for i in `jot 5`; do + wait + done +done +EOF From owner-svn-src-projects@FreeBSD.ORG Mon Mar 16 16:52:09 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 695AB106566C; Mon, 16 Mar 2009 16:52:09 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 577898FC12; Mon, 16 Mar 2009 16:52:09 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2GGq9jd066220; Mon, 16 Mar 2009 16:52:09 GMT (envelope-from lulf@svn.freebsd.org) Received: (from lulf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2GGq9ia066219; Mon, 16 Mar 2009 16:52:09 GMT (envelope-from lulf@svn.freebsd.org) Message-Id: <200903161652.n2GGq9ia066219@svn.freebsd.org> From: Ulf Lilleengen Date: Mon, 16 Mar 2009 16:52:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189884 - projects/gvinum/sys/geom/vinum X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Mar 2009 16:52:09 -0000 Author: lulf Date: Mon Mar 16 16:52:09 2009 New Revision: 189884 URL: http://svn.freebsd.org/changeset/base/189884 Log: - Fixup plex synchronization. The start command on an unsynchronized plex in mirror with another plex will now start the synchronization from the good plex. - Cleanup the code and try to generalize the procedure of starting a plex synchronization. Modified: projects/gvinum/sys/geom/vinum/geom_vinum_init.c Modified: projects/gvinum/sys/geom/vinum/geom_vinum_init.c ============================================================================== --- projects/gvinum/sys/geom/vinum/geom_vinum_init.c Mon Mar 16 16:33:08 2009 (r189883) +++ projects/gvinum/sys/geom/vinum/geom_vinum_init.c Mon Mar 16 16:52:09 2009 (r189884) @@ -36,10 +36,12 @@ __FBSDID("$FreeBSD$"); #include #include -static int gv_sync(struct gv_volume *); -static int gv_rebuild_plex(struct gv_plex *); -static int gv_init_plex(struct gv_plex *); -static int gv_grow_plex(struct gv_plex *); +static int gv_sync(struct gv_volume *); +static int gv_rebuild_plex(struct gv_plex *); +static int gv_init_plex(struct gv_plex *); +static int gv_grow_plex(struct gv_plex *); +static int gv_sync_plex(struct gv_plex *, struct gv_plex *); +static struct gv_plex *gv_find_good_plex(struct gv_volume *); void gv_start_obj(struct g_geom *gp, struct gctl_req *req) @@ -99,6 +101,7 @@ int gv_start_plex(struct gv_plex *p) { struct gv_volume *v; + struct gv_plex *up; struct gv_sd *s; int error, grow; @@ -106,17 +109,9 @@ gv_start_plex(struct gv_plex *p) error = 0; v = p->vol_sc; - if (p->org == GV_PLEX_STRIPED) { - grow = 0; - LIST_FOREACH(s, &p->subdisks, in_plex) { - if (s->flags & GV_SD_GROW) { - grow = 1; - break; - } - } - if (grow) - error = gv_grow_plex(p); - } else if (p->org == GV_PLEX_RAID5) { + + /* RAID5 plexes can either be init, rebuilt or grown. */ + if (p->org == GV_PLEX_RAID5) { if (p->state > GV_PLEX_DEGRADED) { LIST_FOREACH(s, &p->subdisks, in_plex) { if (s->flags & GV_SD_GROW) { @@ -128,8 +123,43 @@ gv_start_plex(struct gv_plex *p) error = gv_rebuild_plex(p); } else error = gv_init_plex(p); + } else { + /* We want to sync from the other plex if we're down. */ + if (p->state == GV_PLEX_DOWN && v->plexcount > 1) { + up = gv_find_good_plex(v); + if (up == NULL) { + G_VINUM_DEBUG(1, "unable to find a good plex"); + return (ENXIO); + } + g_topology_lock(); + error = gv_access(v->provider, 1, 1, 0); + if (error) { + g_topology_unlock(); + G_VINUM_DEBUG(0, "sync from '%s' failed to " + "access volume: %d", up->name, error); + return (error); + } + g_topology_unlock(); + error = gv_sync_plex(p, up); + if (error) + return (error); + /* + * In case we have a stripe that is up, check whether it can be + * grown. + */ + } else if (p->org == GV_PLEX_STRIPED && + p->state != GV_PLEX_DOWN) { + grow = 0; + LIST_FOREACH(s, &p->subdisks, in_plex) { + if (s->flags & GV_SD_GROW) { + grow = 1; + break; + } + } + if (grow) + error = gv_grow_plex(p); + } } - return (error); } @@ -156,16 +186,38 @@ gv_start_vol(struct gv_volume *v) return (error); } +/* Sync a plex p from the plex up. */ static int -gv_sync(struct gv_volume *v) +gv_sync_plex(struct gv_plex *p, struct gv_plex *up) { - struct gv_softc *sc; - struct gv_plex *p, *up; int error; - KASSERT(v != NULL, ("gv_sync: NULL v")); - sc = v->vinumconf; - KASSERT(sc != NULL, ("gv_sync: NULL sc on %s", v->name)); + KASSERT(p != NULL, ("%s: NULL p", __func__)); + KASSERT(up != NULL, ("%s: NULL up", __func__)); + if ((p == up) || (p->state == GV_PLEX_UP)) + return (0); + /* XXX: Should we check if rebuilding too? */ + if (p->flags & GV_PLEX_SYNCING) { + return (EINPROGRESS); + } + p->synced = 0; + p->flags |= GV_PLEX_SYNCING; + G_VINUM_DEBUG(1, "starting sync of plex %s", p->name); + error = gv_sync_request(up, p, p->synced, + MIN(GV_DFLT_SYNCSIZE, up->size - p->synced), + BIO_READ, NULL); + if (error) { + G_VINUM_DEBUG(0, "error syncing plex %s", p->name); + return (error); + } + return (0); +} + +/* Return a good plex from volume v. */ +static struct gv_plex * +gv_find_good_plex(struct gv_volume *v) +{ + struct gv_plex *up; /* Find the plex that's up. */ up = NULL; @@ -173,11 +225,25 @@ gv_sync(struct gv_volume *v) if (up->state == GV_PLEX_UP) break; } - /* Didn't find a good plex. */ + return (up); +} + +static int +gv_sync(struct gv_volume *v) +{ + struct gv_softc *sc; + struct gv_plex *p, *up; + int error; + + KASSERT(v != NULL, ("gv_sync: NULL v")); + sc = v->vinumconf; + KASSERT(sc != NULL, ("gv_sync: NULL sc on %s", v->name)); + + + up = gv_find_good_plex(v); if (up == NULL) return (ENXIO); - g_topology_lock(); error = gv_access(v->provider, 1, 1, 0); if (error) { @@ -190,24 +256,10 @@ gv_sync(struct gv_volume *v) /* Go through the good plex, and issue BIO's to all other plexes. */ LIST_FOREACH(p, &v->plexes, in_volume) { - if ((p == up) || (p->state == GV_PLEX_UP)) - continue; - /* XXX: Should we check if rebuilding too? */ - if (p->flags & GV_PLEX_SYNCING) { - return (EINPROGRESS); - } - p->synced = 0; - p->flags |= GV_PLEX_SYNCING; - G_VINUM_DEBUG(1, "starting sync of plex %s", p->name); - error = gv_sync_request(up, p, p->synced, - MIN(GV_DFLT_SYNCSIZE, up->size - p->synced), - BIO_READ, NULL); - if (error) { - G_VINUM_DEBUG(0, "error syncing plex %s", p->name); + error = gv_sync_plex(p, up); + if (error) break; - } } - return (0); } From owner-svn-src-projects@FreeBSD.ORG Mon Mar 16 16:55:05 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7DC1F1065672; Mon, 16 Mar 2009 16:55:05 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6BC1C8FC1D; Mon, 16 Mar 2009 16:55:05 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2GGt5w5066320; Mon, 16 Mar 2009 16:55:05 GMT (envelope-from lulf@svn.freebsd.org) Received: (from lulf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2GGt576066318; Mon, 16 Mar 2009 16:55:05 GMT (envelope-from lulf@svn.freebsd.org) Message-Id: <200903161655.n2GGt576066318@svn.freebsd.org> From: Ulf Lilleengen Date: Mon, 16 Mar 2009 16:55:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189885 - projects/gvinum/sys/geom/vinum X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Mar 2009 16:55:05 -0000 Author: lulf Date: Mon Mar 16 16:55:05 2009 New Revision: 189885 URL: http://svn.freebsd.org/changeset/base/189885 Log: - Avoid prioritizing rebuilds to normal user bios, as it makes the volume unusable, which makes it pointless to support rebuild/resync etc. while the volume is mounted. Instead, put the internal requests into the main request queue to increase fairness. Modified: projects/gvinum/sys/geom/vinum/geom_vinum.c projects/gvinum/sys/geom/vinum/geom_vinum_plex.c Modified: projects/gvinum/sys/geom/vinum/geom_vinum.c ============================================================================== --- projects/gvinum/sys/geom/vinum/geom_vinum.c Mon Mar 16 16:52:09 2009 (r189884) +++ projects/gvinum/sys/geom/vinum/geom_vinum.c Mon Mar 16 16:55:05 2009 (r189885) @@ -1009,6 +1009,10 @@ gv_worker(void *arg) bp->bio_cflags &= ~GV_BIO_ONHOLD; g_io_request(bp, s->drive_sc->consumer); } + /* A special request requireing special handling. */ + } else if (bp->bio_cflags & GV_BIO_INTERNAL) { + p = bp->bio_caller1; + gv_plex_start(p, bp); /* A fresh bio, scheduled it down. */ } else { gv_volume_start(sc, bp); Modified: projects/gvinum/sys/geom/vinum/geom_vinum_plex.c ============================================================================== --- projects/gvinum/sys/geom/vinum/geom_vinum_plex.c Mon Mar 16 16:52:09 2009 (r189884) +++ projects/gvinum/sys/geom/vinum/geom_vinum_plex.c Mon Mar 16 16:55:05 2009 (r189885) @@ -566,10 +566,13 @@ int gv_sync_request(struct gv_plex *from, struct gv_plex *to, off_t offset, off_t length, int type, caddr_t data) { + struct gv_softc *sc; struct bio *bp; KASSERT(from != NULL, ("NULL from")); KASSERT(to != NULL, ("NULL to")); + sc = from->vinumconf; + KASSERT(sc != NULL, ("NULL sc")); bp = g_new_bio(); if (bp == NULL) { @@ -581,6 +584,7 @@ gv_sync_request(struct gv_plex *from, st bp->bio_done = gv_done; bp->bio_cflags |= GV_BIO_SYNCREQ; bp->bio_offset = offset; + bp->bio_caller1 = from; bp->bio_caller2 = to; bp->bio_cmd = type; if (data == NULL) @@ -589,7 +593,10 @@ gv_sync_request(struct gv_plex *from, st bp->bio_data = data; /* Send down next. */ - gv_plex_start(from, bp); + mtx_lock(&sc->queue_mtx); + bioq_disksort(sc->bqueue, bp); + mtx_unlock(&sc->queue_mtx); + //gv_plex_start(from, bp); return (0); } @@ -681,9 +688,13 @@ int gv_grow_request(struct gv_plex *p, off_t offset, off_t length, int type, caddr_t data) { + struct gv_softc *sc; struct bio *bp; KASSERT(p != NULL, ("gv_grow_request: NULL p")); + sc = p->vinumconf; + KASSERT(sc != NULL, ("gv_grow_request: NULL sc")); + bp = g_new_bio(); if (bp == NULL) { G_VINUM_DEBUG(0, "grow of %s failed creating bio: " @@ -694,6 +705,7 @@ gv_grow_request(struct gv_plex *p, off_t bp->bio_cmd = type; bp->bio_done = gv_done; bp->bio_error = 0; + bp->bio_caller1 = p; bp->bio_offset = offset; bp->bio_length = length; bp->bio_pflags |= GV_BIO_SYNCREQ; /* XXX: misuse of pflags AND syncreq.*/ @@ -702,8 +714,10 @@ gv_grow_request(struct gv_plex *p, off_t bp->bio_cflags |= GV_BIO_MALLOC; bp->bio_data = data; - /* Send down. */ - gv_plex_start(p, bp); + mtx_lock(&sc->queue_mtx); + bioq_disksort(sc->bqueue, bp); + mtx_unlock(&sc->queue_mtx); + //gv_plex_start(p, bp); return (0); } @@ -887,9 +901,12 @@ gv_init_complete(struct gv_plex *p, stru void gv_parity_request(struct gv_plex *p, int flags, off_t offset) { + struct gv_softc *sc; struct bio *bp; KASSERT(p != NULL, ("gv_parity_request: NULL p")); + sc = p->vinumconf; + KASSERT(sc != NULL, ("gv_parity_request: NULL sc")); bp = g_new_bio(); if (bp == NULL) { @@ -902,6 +919,7 @@ gv_parity_request(struct gv_plex *p, int bp->bio_done = gv_done; bp->bio_error = 0; bp->bio_length = p->stripesize; + bp->bio_caller1 = p; /* * Check if it's a rebuild of a degraded plex or a user request of @@ -921,8 +939,10 @@ gv_parity_request(struct gv_plex *p, int /* We still have more parity to build. */ bp->bio_offset = offset; - - gv_plex_start(p, bp); /* Send it down to the plex. */ + mtx_lock(&sc->queue_mtx); + bioq_disksort(sc->bqueue, bp); + mtx_unlock(&sc->queue_mtx); + //gv_plex_start(p, bp); /* Send it down to the plex. */ } /* From owner-svn-src-projects@FreeBSD.ORG Mon Mar 16 23:08:38 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 61A92106566C; Mon, 16 Mar 2009 23:08:38 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 501F18FC1B; Mon, 16 Mar 2009 23:08:38 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2GN8cmI074730; Mon, 16 Mar 2009 23:08:38 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2GN8ck3074729; Mon, 16 Mar 2009 23:08:38 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200903162308.n2GN8ck3074729@svn.freebsd.org> From: Robert Watson Date: Mon, 16 Mar 2009 23:08:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189901 - projects/pnet/sys/net X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Mar 2009 23:08:38 -0000 Author: rwatson Date: Mon Mar 16 23:08:38 2009 New Revision: 189901 URL: http://svn.freebsd.org/changeset/base/189901 Log: Force 64-byte alignment of workstreams so that sequential arrays, indexed by CPU ID, are less likely to cause cache line thrashing. Modified: projects/pnet/sys/net/netisr2.c Modified: projects/pnet/sys/net/netisr2.c ============================================================================== --- projects/pnet/sys/net/netisr2.c Mon Mar 16 19:31:08 2009 (r189900) +++ projects/pnet/sys/net/netisr2.c Mon Mar 16 23:08:38 2009 (r189901) @@ -225,7 +225,7 @@ struct netisr_workstream { * Each protocol has per-workstream data. */ struct netisr_work nws_work[NETISR_MAXPROT]; -}; +} __aligned(64); /* * Kernel process associated with worker threads. From owner-svn-src-projects@FreeBSD.ORG Tue Mar 17 11:28:56 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7B9331065673; Tue, 17 Mar 2009 11:28:56 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 500BC8FC0C; Tue, 17 Mar 2009 11:28:56 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2HBSu0g093641; Tue, 17 Mar 2009 11:28:56 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2HBSub5093640; Tue, 17 Mar 2009 11:28:56 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <200903171128.n2HBSub5093640@svn.freebsd.org> From: Rui Paulo Date: Tue, 17 Mar 2009 11:28:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189924 - projects/efi X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Mar 2009 11:28:56 -0000 Author: rpaulo Date: Tue Mar 17 11:28:56 2009 New Revision: 189924 URL: http://svn.freebsd.org/changeset/base/189924 Log: Branch for EFI development. I will incorporate the Perforce changes shortly. Discussed with: marcel Added: projects/efi/ (props changed) - copied from r189923, head/ From owner-svn-src-projects@FreeBSD.ORG Tue Mar 17 19:57:12 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7859C1065694; Tue, 17 Mar 2009 19:57:12 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 655188FC08; Tue, 17 Mar 2009 19:57:12 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2HJvCBD004972; Tue, 17 Mar 2009 19:57:12 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2HJvBQI004963; Tue, 17 Mar 2009 19:57:11 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <200903171957.n2HJvBQI004963@svn.freebsd.org> From: Rui Paulo Date: Tue, 17 Mar 2009 19:57:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189937 - projects/efi/sys/boot/i386/efi X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Mar 2009 19:57:13 -0000 Author: rpaulo Date: Tue Mar 17 19:57:11 2009 New Revision: 189937 URL: http://svn.freebsd.org/changeset/base/189937 Log: loader.efi support for i386. Obtained from: //depot/projects/efi/ Added: projects/efi/sys/boot/i386/efi/ projects/efi/sys/boot/i386/efi/Makefile projects/efi/sys/boot/i386/efi/conf.c projects/efi/sys/boot/i386/efi/exec.c projects/efi/sys/boot/i386/efi/ldscript.amd64 projects/efi/sys/boot/i386/efi/ldscript.i386 projects/efi/sys/boot/i386/efi/main.c projects/efi/sys/boot/i386/efi/reloc.c projects/efi/sys/boot/i386/efi/start.S projects/efi/sys/boot/i386/efi/version Added: projects/efi/sys/boot/i386/efi/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/efi/sys/boot/i386/efi/Makefile Tue Mar 17 19:57:11 2009 (r189937) @@ -0,0 +1,67 @@ +# $FreeBSD$ + +NO_MAN= +WITHOUT_SSP= +BUILDING_EFI= + +.include + +PROG= loader.sym +INTERNALPROG= + +# architecture-specific loader code +SRCS= main.c exec.c conf.c vers.c reloc.c start.S + +CFLAGS+= -I${.CURDIR}/../../efi/include +CFLAGS+= -I${.CURDIR}/../../efi/include/i386 + +.if ${MK_FORTH} != "no" +BOOT_FORTH= yes +CFLAGS+= -DBOOT_FORTH +CFLAGS+= -I${.CURDIR}/../../ficl +CFLAGS+= -I${.CURDIR}/../../ficl/i386 +LIBFICL= ${.OBJDIR}/../../ficl/libficl.a +.endif + +# Include bcache code. +HAVE_BCACHE= yes + +# Always add MI sources +.PATH: ${.CURDIR}/../../common +.include "${.CURDIR}/../../common/Makefile.inc" +CFLAGS+= -I${.CURDIR}/../../common + +FILES= loader.efi +FILESMODE_loader.efi= ${BINMODE} + +LDSCRIPT= ${.CURDIR}/ldscript.${MACHINE_ARCH} +LDFLAGS= -Wl,-T${LDSCRIPT} -shared -symbolic + +${PROG}: ${LDSCRIPT} + +CLEANFILES= vers.c loader.efi + +NEWVERSWHAT= "EFI loader" ${MACHINE_ARCH} + +vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version + sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} + +OBJCOPY?= objcopy +OBJDUMP?= objdump + +loader.efi: loader.sym + if [ `${OBJDUMP} -t ${.ALLSRC} | fgrep '*UND*' | wc -l` != 0 ]; then \ + ${OBJDUMP} -t ${.ALLSRC} | fgrep '*UND*'; \ + exit 1; \ + fi + ${OBJCOPY} -j .data -j .dynamic -j .dynstr -j .dynsym -j .hash \ + -j .rel.dyn -j .reloc -j .sdata -j .text -j set_Xcommand_set \ + --target=efi-app-ia32 ${.ALLSRC} ${.TARGET} + +LIBEFI= ${.OBJDIR}/../../efi/libefi/libefi.a +LIBI386= ${.OBJDIR}/../libi386/libi386.a + +DPADD= ${LIBFICL} ${LIBEFI} ${LIBI386} ${LIBSTAND} +LDADD= ${LIBFICL} ${LIBEFI} ${LIBI386} -lstand + +.include Added: projects/efi/sys/boot/i386/efi/conf.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/efi/sys/boot/i386/efi/conf.c Tue Mar 17 19:57:11 2009 (r189937) @@ -0,0 +1,72 @@ +/*- + * Copyright (c) 2006 Marcel Moolenaar + * 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. + * + * 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 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +struct devsw *devsw[] = { + &efifs_dev, + &efinet_dev, + NULL +}; + +struct fs_ops *file_system[] = { + &efifs_fsops, + &ufs_fsops, + &dosfs_fsops, + &nfs_fsops, + NULL +}; + +struct netif_driver *netif_drivers[] = { + &efinetif, + NULL +}; + +extern struct file_format amd64_elf; +extern struct file_format amd64_elf_obj; +extern struct file_format i386_elf; +extern struct file_format i386_elf_obj; + +struct file_format *file_formats[] = { + &amd64_elf, + &amd64_elf_obj, + &i386_elf, + &i386_elf_obj, + NULL +}; + +extern struct console efi_console; + +struct console *consoles[] = { + &efi_console, + NULL +}; Added: projects/efi/sys/boot/i386/efi/exec.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/efi/sys/boot/i386/efi/exec.c Tue Mar 17 19:57:11 2009 (r189937) @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 2006 Marcel Moolenaar + * 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. + * + * 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 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 +__FBSDID("$FreeBSD$"); + +#include +#include "../btx/lib/btxv86.h" + +uint32_t __base; +struct __v86 __v86; + +void +__v86int() +{ + printf("%s\n", __func__); + exit(1); +} + +void +__exec(caddr_t addr, ...) +{ + printf("%s(%p, ...)\n", __func__, addr); + exit (0); +} Added: projects/efi/sys/boot/i386/efi/ldscript.amd64 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/efi/sys/boot/i386/efi/ldscript.amd64 Tue Mar 17 19:57:11 2009 (r189937) @@ -0,0 +1,72 @@ +/* $FreeBSD$ */ +OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64") +OUTPUT_ARCH(i386:x86-64) +ENTRY(_start) +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = 0; + ImageBase = .; + . = SIZEOF_HEADERS; + . = ALIGN(4096); + .text : { + *(.text .stub .text.* .gnu.linkonce.t.*) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.plt) + } =0x00300000010070000002000001000400 + . = ALIGN(4096); + .data : { + *(.rodata .rodata.* .gnu.linkonce.r.*) + *(.rodata1) + *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) + *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) + *(.opd) + *(.data .data.* .gnu.linkonce.d.*) + *(.data1) + *(.plabel) + *(.dynbss) + *(.bss .bss.* .gnu.linkonce.b.*) + *(COMMON) + } + . = ALIGN(4096); + set_Xcommand_set : { + __start_set_Xcommand_set = .; + *(set_Xcommand_set) + __stop_set_Xcommand_set = .; + } + . = ALIGN(4096); + __gp = .; + .sdata : { + *(.got.plt .got) + *(.sdata .sdata.* .gnu.linkonce.s.*) + *(dynsbss) + *(.sbss .sbss.* .gnu.linkonce.sb.*) + *(.scommon) + } + . = ALIGN(4096); + .dynamic : { *(.dynamic) } + . = ALIGN(4096); + .rel.dyn : { + *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) + *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) + *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) + *(.rel.got) + *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) + *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) + *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) + *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) + *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) + *(.rel.plt) + *(.relset_*) + *(.rel.dyn .rel.dyn.*) + } + . = ALIGN(4096); + .reloc : { *(.reloc) } + . = ALIGN(4096); + .hash : { *(.hash) } + . = ALIGN(4096); + .dynsym : { *(.dynsym) } + . = ALIGN(4096); + .dynstr : { *(.dynstr) } +} Added: projects/efi/sys/boot/i386/efi/ldscript.i386 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/efi/sys/boot/i386/efi/ldscript.i386 Tue Mar 17 19:57:11 2009 (r189937) @@ -0,0 +1,72 @@ +/* $FreeBSD$ */ +OUTPUT_FORMAT("elf32-i386-freebsd", "elf32-i386-freebsd", "elf32-i386-freebsd") +OUTPUT_ARCH(i386) +ENTRY(_start) +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = 0; + ImageBase = .; + . = SIZEOF_HEADERS; + . = ALIGN(4096); + .text : { + *(.text .stub .text.* .gnu.linkonce.t.*) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.plt) + } =0x00300000010070000002000001000400 + . = ALIGN(4096); + .data : { + *(.rodata .rodata.* .gnu.linkonce.r.*) + *(.rodata1) + *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) + *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) + *(.opd) + *(.data .data.* .gnu.linkonce.d.*) + *(.data1) + *(.plabel) + *(.dynbss) + *(.bss .bss.* .gnu.linkonce.b.*) + *(COMMON) + } + . = ALIGN(4096); + set_Xcommand_set : { + __start_set_Xcommand_set = .; + *(set_Xcommand_set) + __stop_set_Xcommand_set = .; + } + . = ALIGN(4096); + __gp = .; + .sdata : { + *(.got.plt .got) + *(.sdata .sdata.* .gnu.linkonce.s.*) + *(dynsbss) + *(.sbss .sbss.* .gnu.linkonce.sb.*) + *(.scommon) + } + . = ALIGN(4096); + .dynamic : { *(.dynamic) } + . = ALIGN(4096); + .rel.dyn : { + *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) + *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) + *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) + *(.rel.got) + *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) + *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) + *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) + *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) + *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) + *(.rel.plt) + *(.relset_*) + *(.rel.dyn .rel.dyn.*) + } + . = ALIGN(4096); + .reloc : { *(.reloc) } + . = ALIGN(4096); + .hash : { *(.hash) } + . = ALIGN(4096); + .dynsym : { *(.dynsym) } + . = ALIGN(4096); + .dynstr : { *(.dynstr) } +} Added: projects/efi/sys/boot/i386/efi/main.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/efi/sys/boot/i386/efi/main.c Tue Mar 17 19:57:11 2009 (r189937) @@ -0,0 +1,371 @@ +/*- + * Copyright (c) 2008 Rui Paulo + * Copyright (c) 2006 Marcel Moolenaar + * 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. + * + * 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 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +#include +#include + +#include +#include "../libi386/libi386.h" + +extern char bootprog_name[]; +extern char bootprog_rev[]; +extern char bootprog_date[]; +extern char bootprog_maker[]; + +struct devdesc currdev; /* our current device */ +struct arch_switch archsw; /* MI/MD interface boundary */ + +EFI_GUID acpi = ACPI_TABLE_GUID; +EFI_GUID acpi20 = ACPI_20_TABLE_GUID; +EFI_GUID devid = DEVICE_PATH_PROTOCOL; +EFI_GUID imgid = LOADED_IMAGE_PROTOCOL; +EFI_GUID mps = MPS_TABLE_GUID; +EFI_GUID netid = EFI_SIMPLE_NETWORK_PROTOCOL; +EFI_GUID smbios = SMBIOS_TABLE_GUID; + +EFI_STATUS +main(int argc, CHAR16 *argv[]) +{ + char vendor[128]; + EFI_LOADED_IMAGE *img; + int i; + + /* + * XXX Chicken-and-egg problem; we want to have console output + * early, but some console attributes may depend on reading from + * eg. the boot device, which we can't do yet. We can use + * printf() etc. once this is done. + */ + cons_probe(); + + /* + * March through the device switch probing for things. + */ + for (i = 0; devsw[i] != NULL; i++) + if (devsw[i]->dv_init != NULL) + (devsw[i]->dv_init)(); + + /* Get our loaded image protocol interface structure. */ + BS->HandleProtocol(IH, &imgid, (VOID**)&img); + + printf("Image base: 0x%lx\n", (u_long)img->ImageBase); + printf("EFI version: %d.%02d\n", ST->Hdr.Revision >> 16, + ST->Hdr.Revision & 0xffff); + printf("EFI Firmware: "); + /* printf doesn't understand EFI Unicode */ + ST->ConOut->OutputString(ST->ConOut, ST->FirmwareVendor); + printf(" (rev %d.%02d)\n", ST->FirmwareRevision >> 16, + ST->FirmwareRevision & 0xffff); + + printf("\n"); + printf("%s, Revision %s\n", bootprog_name, bootprog_rev); + printf("(%s, %s)\n", bootprog_maker, bootprog_date); + + efi_handle_lookup(img->DeviceHandle, &currdev.d_dev, &currdev.d_unit); + currdev.d_type = currdev.d_dev->dv_type; + + /* + * Disable the watchdog timer. By default the boot manager sets + * the timer to 5 minutes before invoking a boot option. If we + * want to return to the boot manager, we have to disable the + * watchdog timer and since we're an interactive program, we don't + * want to wait until the user types "quit". The timer may have + * fired by then. We don't care if this fails. It does not prevent + * normal functioning in any way... + */ + BS->SetWatchdogTimer(0, 0, 0, NULL); + + env_setenv("currdev", EV_VOLATILE, i386_fmtdev(&currdev), + i386_setcurrdev, env_nounset); + env_setenv("loaddev", EV_VOLATILE, i386_fmtdev(&currdev), env_noset, + env_nounset); + + setenv("LINES", "24", 1); /* optional */ + + archsw.arch_autoload = i386_autoload; + archsw.arch_getdev = i386_getdev; + archsw.arch_copyin = i386_copyin; + archsw.arch_copyout = i386_copyout; + archsw.arch_readin = i386_readin; + + interact(); /* doesn't return */ + + return (EFI_SUCCESS); /* keep compiler happy */ +} + +COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot); + +static int +command_reboot(int argc, char *argv[]) +{ + int i; + + for (i = 0; devsw[i] != NULL; ++i) + if (devsw[i]->dv_cleanup != NULL) + (devsw[i]->dv_cleanup)(); + + RS->ResetSystem(EfiResetCold, EFI_SUCCESS, 23, + (CHAR16 *)"Reboot from the loader"); + + /* NOTREACHED */ + return (CMD_ERROR); +} + +COMMAND_SET(quit, "quit", "exit the loader", command_quit); + +static int +command_quit(int argc, char *argv[]) +{ + exit(0); + return (CMD_OK); +} + +COMMAND_SET(memmap, "memmap", "print memory map", command_memmap); + +static int +command_memmap(int argc, char *argv[]) +{ + UINTN sz; + EFI_MEMORY_DESCRIPTOR *map, *p; + UINTN key, dsz; + UINT32 dver; + EFI_STATUS status; + int i, ndesc; + static char *types[] = { + "Reserved", + "LoaderCode", + "LoaderData", + "BootServicesCode", + "BootServicesData", + "RuntimeServicesCode", + "RuntimeServicesData", + "ConventionalMemory", + "UnusableMemory", + "ACPIReclaimMemory", + "ACPIMemoryNVS", + "MemoryMappedIO", + "MemoryMappedIOPortSpace", + "PalCode" + }; + + sz = 0; + status = BS->GetMemoryMap(&sz, 0, &key, &dsz, &dver); + if (status != EFI_BUFFER_TOO_SMALL) { + printf("Can't determine memory map size\n"); + return CMD_ERROR; + } + map = malloc(sz); + status = BS->GetMemoryMap(&sz, map, &key, &dsz, &dver); + if (EFI_ERROR(status)) { + printf("Can't read memory map\n"); + return CMD_ERROR; + } + + ndesc = sz / dsz; + printf("%23s %12s %12s %8s %4s\n", + "Type", "Physical", "Virtual", "#Pages", "Attr"); + + for (i = 0, p = map; i < ndesc; + i++, p = NextMemoryDescriptor(p, dsz)) { + printf("%23s %012lx %012lx %08lx ", + types[p->Type], + p->PhysicalStart, + p->VirtualStart, + p->NumberOfPages); + if (p->Attribute & EFI_MEMORY_UC) + printf("UC "); + if (p->Attribute & EFI_MEMORY_WC) + printf("WC "); + if (p->Attribute & EFI_MEMORY_WT) + printf("WT "); + if (p->Attribute & EFI_MEMORY_WB) + printf("WB "); + if (p->Attribute & EFI_MEMORY_UCE) + printf("UCE "); + if (p->Attribute & EFI_MEMORY_WP) + printf("WP "); + if (p->Attribute & EFI_MEMORY_RP) + printf("RP "); + if (p->Attribute & EFI_MEMORY_XP) + printf("XP "); + printf("\n"); + } + + return CMD_OK; +} + +COMMAND_SET(configuration, "configuration", + "print configuration tables", command_configuration); + +static const char * +guid_to_string(EFI_GUID *guid) +{ + static char buf[40]; + + sprintf(buf, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + guid->Data1, guid->Data2, guid->Data3, guid->Data4[0], + guid->Data4[1], guid->Data4[2], guid->Data4[3], guid->Data4[4], + guid->Data4[5], guid->Data4[6], guid->Data4[7]); + return (buf); +} + +static int +command_configuration(int argc, char *argv[]) +{ + int i; + + printf("NumberOfTableEntries=%ld\n", ST->NumberOfTableEntries); + for (i = 0; i < ST->NumberOfTableEntries; i++) { + EFI_GUID *guid; + + printf(" "); + guid = &ST->ConfigurationTable[i].VendorGuid; + if (!memcmp(guid, &mps, sizeof(EFI_GUID))) + printf("MPS Table"); + else if (!memcmp(guid, &acpi, sizeof(EFI_GUID))) + printf("ACPI Table"); + else if (!memcmp(guid, &acpi20, sizeof(EFI_GUID))) + printf("ACPI 2.0 Table"); + else if (!memcmp(guid, &smbios, sizeof(EFI_GUID))) + printf("SMBIOS Table"); + else + printf("Unknown Table (%s)", guid_to_string(guid)); + printf(" at %p\n", ST->ConfigurationTable[i].VendorTable); + } + + return CMD_OK; +} + + +COMMAND_SET(mode, "mode", "change or display text modes", command_mode); + +static int +command_mode(int argc, char *argv[]) +{ + unsigned int cols, rows, mode; + int i; + char *cp; + char rowenv[8]; + EFI_STATUS status; + SIMPLE_TEXT_OUTPUT_INTERFACE *conout; + + conout = ST->ConOut; + + if (argc > 1) { + mode = strtol(argv[1], &cp, 0); + if (cp[0] != '\0') { + printf("Invalid mode\n"); + return (CMD_ERROR); + } + status = conout->QueryMode(conout, mode, &cols, &rows); + if (EFI_ERROR(status)) { + printf("invalid mode %d\n", mode); + return (CMD_ERROR); + } + status = conout->SetMode(conout, mode); + if (EFI_ERROR(status)) { + printf("couldn't set mode %d\n", mode); + return (CMD_ERROR); + } + sprintf(rowenv, "%d", rows); + setenv("LINES", rowenv, 1); + + return (CMD_OK); + } + + for (i = 0; ; i++) { + status = conout->QueryMode(conout, i, &cols, &rows); + if (EFI_ERROR(status)) + break; + printf("Mode %d: %d columns, %d rows\n", i, cols, rows); + } + + if (i != 0) + printf("Choose the mode with \"col \"\n"); + + return (CMD_OK); +} + + +COMMAND_SET(nvram, "nvram", "get or set NVRAM variables", command_nvram); + +static int +command_nvram(int argc, char *argv[]) +{ + CHAR16 var[128]; + CHAR16 *data; + EFI_STATUS status; + EFI_GUID varguid = { 0,0,0,{0,0,0,0,0,0,0,0} }; + unsigned int varsz; + unsigned int datasz; + SIMPLE_TEXT_OUTPUT_INTERFACE *conout; + int i; + + conout = ST->ConOut; + + /* Initiate the search */ + status = RS->GetNextVariableName(&varsz, NULL, NULL); + + for (; status != EFI_NOT_FOUND; ) { + status = RS->GetNextVariableName(&varsz, var, + &varguid); + //if (EFI_ERROR(status)) + //break; + + conout->OutputString(conout, var); + printf("="); + datasz = 0; + status = RS->GetVariable(var, &varguid, NULL, &datasz, + NULL); + /* XXX: check status */ + data = malloc(datasz); + status = RS->GetVariable(var, &varguid, NULL, &datasz, + data); + if (EFI_ERROR(status)) + printf(""); + else { + for (i = 0; i < datasz; i++) { + if (isalnum(data[i]) || isspace(data[i])) + printf("%c", data[i]); + else + printf("\\x%02x", data[i]); + } + } + /* XXX */ + pager_output("\n"); + free(data); + } + + return (CMD_OK); +} Added: projects/efi/sys/boot/i386/efi/reloc.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/efi/sys/boot/i386/efi/reloc.c Tue Mar 17 19:57:11 2009 (r189937) @@ -0,0 +1,103 @@ +/*- + * Copyright (c) 2008 Rui Paulo + * 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. + * + * 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +/* + * XXX: we can't include sys/systm.h. + */ +#ifndef CTASSERT /* Allow lint to override */ +#define CTASSERT(x) _CTASSERT(x, __LINE__) +#define _CTASSERT(x, y) __CTASSERT(x, y) +#define __CTASSERT(x, y) typedef char __assert ## y[(x) ? 1 : -1] +#endif + + +/* + * A simple relocator for IA32 EFI binaries. + */ +EFI_STATUS +_reloc(unsigned long ImageBase, Elf32_Dyn *dynamic, EFI_HANDLE image_handle, + EFI_SYSTEM_TABLE *system_table) +{ + unsigned long relsz, relent; + unsigned long *newaddr; + Elf32_Rel *rel; + Elf32_Dyn *dynp; + + /* + * Find the relocation address, its size and the relocation entry. + */ + relsz = 0; + relent = 0; + for (dynp = dynamic; dynp->d_tag != DT_NULL; dynp++) { + switch (dynp->d_tag) { + case DT_REL: + rel = (Elf32_Rel *) ((unsigned long) dynp->d_un.d_ptr + + ImageBase); + break; + case DT_RELSZ: + relsz = dynp->d_un.d_val; + break; + case DT_RELENT: + relent = dynp->d_un.d_val; + break; + default: + break; + } + } + + /* + * Perform the actual relocation. + * XXX: We are reusing code for the amd64 version of this, but + * we must make sure the relocation types are the same. + */ + CTASSERT(R_386_NONE == R_X86_64_NONE); + CTASSERT(R_386_RELATIVE == R_X86_64_RELATIVE); + for (; relsz > 0; relsz -= relent) { + switch (ELF32_R_TYPE(rel->r_info)) { + case R_386_NONE: + /* No relocation needs be performed. */ + break; + case R_386_RELATIVE: + /* Address relative to the base address. */ + newaddr = (unsigned long *)(ImageBase + rel->r_offset); + *newaddr += ImageBase; + break; + default: + /* XXX: do we need other relocations ? */ + return (EFI_LOAD_ERROR); + } + rel = (Elf32_Rel *) ((caddr_t) rel + relent); + } + + return (EFI_SUCCESS); +} Added: projects/efi/sys/boot/i386/efi/start.S ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/efi/sys/boot/i386/efi/start.S Tue Mar 17 19:57:11 2009 (r189937) @@ -0,0 +1,70 @@ +/*- + * Copyright (c) 2008 Rui Paulo + * 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. + * + * 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. + * + * $FreeBSD$ + */ + + .text + +#include + +#define EFI_SUCCESS 0 + +/* + * EFI entry point. + * _start(EFI_IMAGE image_handle, EFI_SYSTEM_TABLE *system_table); + * + * We calculate the base address along with _DYNAMIC, relocate us and finally + * pass control to efi_main. + */ + +ENTRY(_start) + pushl %ebp + movl %esp, %ebp + + pushl 12(%ebp) /* image_handle */ + pushl 8(%ebp) /* system_table */ + call 0f +0: popl %eax + movl %eax, %ebx + addl $ImageBase-0b, %eax + addl $_DYNAMIC-0b, %ebx + pushl %ebx /* dynamic */ + pushl %eax /* ImageBase */ + call _reloc + cmpl $EFI_SUCCESS, %eax + jne 1f + popl %ebx /* remove ImageBase from the stack */ + popl %ebx /* remove dynamic from the stack */ + call efi_main +1: leave + ret +END(_start) + + .data + .section .reloc, "a" + .long 0 + .long 10 + .word 0 Added: projects/efi/sys/boot/i386/efi/version ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/efi/sys/boot/i386/efi/version Tue Mar 17 19:57:11 2009 (r189937) @@ -0,0 +1,7 @@ +$FreeBSD$ + +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.1: Keep in sync with i386 version. +0.1: Initial i386 version. Derived from ia64. From owner-svn-src-projects@FreeBSD.ORG Tue Mar 17 21:56:05 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CE77A10656F9 for ; Tue, 17 Mar 2009 21:56:05 +0000 (UTC) (envelope-from rpaulo@gmail.com) Received: from mail-ew0-f176.google.com (mail-ew0-f176.google.com [209.85.219.176]) by mx1.freebsd.org (Postfix) with ESMTP id 976928FC0A for ; Tue, 17 Mar 2009 21:56:02 +0000 (UTC) (envelope-from rpaulo@gmail.com) Received: by ewy24 with SMTP id 24so204091ewy.43 for ; Tue, 17 Mar 2009 14:56:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:cc:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-pgp-agent:x-mailer; bh=AbMKvVN5ZW4ndqq1Ui/B19edIsaW5cEFChi55tuO/TE=; b=W0X07wbgumRT0CDRfQ4EP28JaAvuO28kEAveWiZVkdqQ6ewsVpWPAIhJd8/dLBIBAj EJFndCd6c3iLbtCmuzPsYQhOs7mtSbyIOVfwvX9Jymvl5AZM747kWbjDW9AUlN+C2sXE tkAMjmjw15m/xL+n8V3XV69ZlGKgzpPlzBaEw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:cc:message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-pgp-agent:x-mailer; b=ZXoXc+UyoraMKUzy8SPO3VO/yAveHfWQo3/Lp46twHJSdbRwuaXsyM2ZMlh+gqqDA+ GavLBHesh8XN5xM1xl9imN7vFzBmNuf9f53bKNDzvBSzOcDxrkAfmTvxzd2si/mVB+lj pNAh9vFloZ0rc0zyfqJuLWPqJxrD5mbaZ46dA= Received: by 10.210.113.16 with SMTP id l16mr327501ebc.63.1237325390517; Tue, 17 Mar 2009 14:29:50 -0700 (PDT) Received: from epsilon.lan (bl5-225-147.dsl.telepac.pt [82.154.225.147]) by mx.google.com with ESMTPS id 10sm145014eyd.13.2009.03.17.14.29.49 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 17 Mar 2009 14:29:49 -0700 (PDT) Sender: Rui Paulo Message-Id: From: Rui Paulo To: Marcel Moolenaar In-Reply-To: <59600660-A5D5-470F-AD4C-4D58220B3219@mac.com> Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="Apple-Mail-11--827333331" Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Date: Tue, 17 Mar 2009 21:29:47 +0000 References: <200903171957.n2HJvBQI004963@svn.freebsd.org> <59600660-A5D5-470F-AD4C-4D58220B3219@mac.com> X-Pgp-Agent: GPGMail 1.2.0 (v56) X-Mailer: Apple Mail (2.930.3) Cc: svn-src-projects@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r189937 - projects/efi/sys/boot/i386/efi X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Mar 2009 21:56:07 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --Apple-Mail-11--827333331 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit On 17 Mar 2009, at 21:04, Marcel Moolenaar wrote: > > On Mar 17, 2009, at 12:57 PM, Rui Paulo wrote: > >> Author: rpaulo >> Date: Tue Mar 17 19:57:11 2009 >> New Revision: 189937 >> URL: http://svn.freebsd.org/changeset/base/189937 >> >> Log: >> loader.efi support for i386. >> >> >> Obtained from: //depot/projects/efi/ > > Thanks Rui. I'll "close" the P4 branch. Ok, great. Thanks, -- Rui Paulo --Apple-Mail-11--827333331 content-type: application/pgp-signature; x-mac-type=70674453; name=PGP.sig content-description: This is a digitally signed message part content-disposition: inline; filename=PGP.sig content-transfer-encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Darwin) iEYEARECAAYFAknAFksACgkQfD8M/ASTygIYYACfYZdMgVvTr3TUX6OitQS11V4E k+sAnjAMo84Bex7emPbp+PL5x+UYVGuq =/ez6 -----END PGP SIGNATURE----- --Apple-Mail-11--827333331-- From owner-svn-src-projects@FreeBSD.ORG Tue Mar 17 22:04:29 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 24280106564A; Tue, 17 Mar 2009 22:04:29 +0000 (UTC) (envelope-from xcllnt@mac.com) Received: from asmtpout022.mac.com (asmtpout022.mac.com [17.148.16.97]) by mx1.freebsd.org (Postfix) with ESMTP id 103AD8FC0A; Tue, 17 Mar 2009 22:04:29 +0000 (UTC) (envelope-from xcllnt@mac.com) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; charset=US-ASCII; format=flowed Received: from chebrolu-t43.jnpr.net (natint3.juniper.net [66.129.224.36]) by asmtp022.mac.com (Sun Java(tm) System Messaging Server 6.3-8.01 (built Dec 16 2008; 32bit)) with ESMTPSA id <0KGO007MZ57CY460@asmtp022.mac.com>; Tue, 17 Mar 2009 14:04:29 -0700 (PDT) Message-id: <59600660-A5D5-470F-AD4C-4D58220B3219@mac.com> From: Marcel Moolenaar To: Rui Paulo In-reply-to: <200903171957.n2HJvBQI004963@svn.freebsd.org> Date: Tue, 17 Mar 2009 14:04:24 -0700 References: <200903171957.n2HJvBQI004963@svn.freebsd.org> X-Mailer: Apple Mail (2.930.3) Cc: svn-src-projects@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r189937 - projects/efi/sys/boot/i386/efi X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Mar 2009 22:04:29 -0000 On Mar 17, 2009, at 12:57 PM, Rui Paulo wrote: > Author: rpaulo > Date: Tue Mar 17 19:57:11 2009 > New Revision: 189937 > URL: http://svn.freebsd.org/changeset/base/189937 > > Log: > loader.efi support for i386. > > > Obtained from: //depot/projects/efi/ Thanks Rui. I'll "close" the P4 branch. -- Marcel Moolenaar xcllnt@mac.com From owner-svn-src-projects@FreeBSD.ORG Fri Mar 20 09:01:34 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D6A6B106564A; Fri, 20 Mar 2009 09:01:34 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C5F028FC12; Fri, 20 Mar 2009 09:01:34 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2K91YkZ091556; Fri, 20 Mar 2009 09:01:34 GMT (envelope-from lulf@svn.freebsd.org) Received: (from lulf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2K91YtA091555; Fri, 20 Mar 2009 09:01:34 GMT (envelope-from lulf@svn.freebsd.org) Message-Id: <200903200901.n2K91YtA091555@svn.freebsd.org> From: Ulf Lilleengen Date: Fri, 20 Mar 2009 09:01:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r190136 - projects/gvinum/sys/geom/vinum X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Mar 2009 09:01:35 -0000 Author: lulf Date: Fri Mar 20 09:01:34 2009 New Revision: 190136 URL: http://svn.freebsd.org/changeset/base/190136 Log: - Fix a bug where gvinum would assume that a plex had subdisks during size calculation. Modified: projects/gvinum/sys/geom/vinum/geom_vinum_subr.c Modified: projects/gvinum/sys/geom/vinum/geom_vinum_subr.c ============================================================================== --- projects/gvinum/sys/geom/vinum/geom_vinum_subr.c Fri Mar 20 05:51:54 2009 (r190135) +++ projects/gvinum/sys/geom/vinum/geom_vinum_subr.c Fri Mar 20 09:01:34 2009 (r190136) @@ -441,11 +441,11 @@ gv_plex_size(struct gv_plex *p) break; case GV_PLEX_STRIPED: s = LIST_FIRST(&p->subdisks); - size = sdcount * s->size; + size = ((s != NULL) ? (sdcount * s->size) : 0); break; case GV_PLEX_RAID5: s = LIST_FIRST(&p->subdisks); - size = (sdcount - 1) * s->size; + size = ((s != NULL) ? ((sdcount - 1) * s->size) : 0); break; } From owner-svn-src-projects@FreeBSD.ORG Fri Mar 20 09:02:40 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B84E6106566C; Fri, 20 Mar 2009 09:02:40 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A76058FC1F; Fri, 20 Mar 2009 09:02:40 +0000 (UTC) (envelope-from lulf@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2K92egG091619; Fri, 20 Mar 2009 09:02:40 GMT (envelope-from lulf@svn.freebsd.org) Received: (from lulf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2K92eNk091618; Fri, 20 Mar 2009 09:02:40 GMT (envelope-from lulf@svn.freebsd.org) Message-Id: <200903200902.n2K92eNk091618@svn.freebsd.org> From: Ulf Lilleengen Date: Fri, 20 Mar 2009 09:02:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r190137 - projects/gvinum/sys/geom/vinum X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Mar 2009 09:02:41 -0000 Author: lulf Date: Fri Mar 20 09:02:40 2009 New Revision: 190137 URL: http://svn.freebsd.org/changeset/base/190137 Log: - Fix errors from previous mis-merges. The parity rebuild would end prematurely. Modified: projects/gvinum/sys/geom/vinum/geom_vinum_plex.c Modified: projects/gvinum/sys/geom/vinum/geom_vinum_plex.c ============================================================================== --- projects/gvinum/sys/geom/vinum/geom_vinum_plex.c Fri Mar 20 09:01:34 2009 (r190136) +++ projects/gvinum/sys/geom/vinum/geom_vinum_plex.c Fri Mar 20 09:02:40 2009 (r190137) @@ -966,21 +966,21 @@ gv_parity_complete(struct gv_plex *p, st g_free(bp->bio_data); g_destroy_bio(bp); - if (error) { + if (error == EAGAIN) { + G_VINUM_DEBUG(0, "parity incorrect at offset 0x%jx", + (intmax_t)p->synced); + } + + /* Any error is fatal, except EAGAIN when we're rebuilding. */ + if (error && !(error == EAGAIN && (flags & GV_BIO_PARITY))) { /* Make sure we don't have the lock. */ g_topology_assert_not(); g_topology_lock(); gv_access(p->vol_sc->provider, -1, -1, 0); g_topology_unlock(); - - if (error == EAGAIN) { - G_VINUM_DEBUG(0, "parity incorrect at offset 0x%jx", - (intmax_t)p->synced); - if (!(flags & GV_BIO_PARITY)) - return; - } - G_VINUM_DEBUG(0, "parity check on %s failed at 0x%jx errno %d", - p->name, (intmax_t)p->synced, error); + G_VINUM_DEBUG(0, "parity check on %s failed at 0x%jx " + "errno %d", p->name, (intmax_t)p->synced, error); + return; } else { p->synced += p->stripesize; } @@ -991,7 +991,6 @@ gv_parity_complete(struct gv_plex *p, st g_topology_lock(); gv_access(p->vol_sc->provider, -1, -1, 0); g_topology_unlock(); - /* We're finished. */ G_VINUM_DEBUG(1, "parity operation on %s finished", p->name); p->synced = 0;