Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Jul 2011 05:07:26 +0000 (UTC)
From:      Andreas Tobler <andreast@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r223833 - in projects/pseries: amd64/acpica amd64/amd64 amd64/include arm/arm arm/at91 arm/conf arm/mv arm/sa11x0 boot boot/common boot/ficl/amd64 boot/i386/libi386 boot/i386/zfsboot bo...
Message-ID:  <201107070507.p6757QDd046463@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andreast
Date: Thu Jul  7 05:07:25 2011
New Revision: 223833
URL: http://svn.freebsd.org/changeset/base/223833

Log:
  MFC.

Added:
  projects/pseries/boot/common/disk.c
     - copied unchanged from r223832, head/sys/boot/common/disk.c
  projects/pseries/boot/common/disk.h
     - copied unchanged from r223832, head/sys/boot/common/disk.h
  projects/pseries/boot/ficl/amd64/
     - copied from r223832, head/sys/boot/ficl/amd64/
  projects/pseries/boot/userboot/
     - copied from r223832, head/sys/boot/userboot/
  projects/pseries/contrib/pf/net/if_pflow.h
     - copied unchanged from r223832, head/sys/contrib/pf/net/if_pflow.h
  projects/pseries/contrib/pf/net/pf_lb.c
     - copied unchanged from r223832, head/sys/contrib/pf/net/pf_lb.c
  projects/pseries/dev/pci/pci_subr.c
     - copied unchanged from r223832, head/sys/dev/pci/pci_subr.c
  projects/pseries/modules/pfsync/
     - copied from r223832, head/sys/modules/pfsync/
Deleted:
  projects/pseries/contrib/pf/net/pf_subr.c
Modified:
  projects/pseries/amd64/acpica/acpi_wakeup.c
  projects/pseries/amd64/amd64/mp_machdep.c
  projects/pseries/amd64/amd64/pmap.c
  projects/pseries/amd64/amd64/sys_machdep.c
  projects/pseries/amd64/amd64/vm_machdep.c
  projects/pseries/amd64/include/cpufunc.h
  projects/pseries/arm/arm/pmap.c
  projects/pseries/arm/arm/sys_machdep.c
  projects/pseries/arm/at91/at91_machdep.c
  projects/pseries/arm/conf/CAMBRIA
  projects/pseries/arm/mv/common.c
  projects/pseries/arm/sa11x0/assabet_machdep.c
  projects/pseries/arm/sa11x0/sa11x0.c
  projects/pseries/boot/Makefile
  projects/pseries/boot/Makefile.amd64
  projects/pseries/boot/Makefile.arm
  projects/pseries/boot/Makefile.powerpc
  projects/pseries/boot/common/Makefile.inc
  projects/pseries/boot/common/load_elf.c
  projects/pseries/boot/common/reloc_elf.c
  projects/pseries/boot/i386/libi386/bioscd.c
  projects/pseries/boot/i386/zfsboot/zfsldr.S
  projects/pseries/boot/sparc64/loader/main.c
  projects/pseries/cam/cam_xpt.c
  projects/pseries/cam/scsi/scsi_cd.c
  projects/pseries/cddl/contrib/opensolaris/common/zfs/zfs_prop.c
  projects/pseries/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c
  projects/pseries/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_cache.c
  projects/pseries/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h
  projects/pseries/cddl/dev/dtrace/amd64/dtrace_subr.c
  projects/pseries/cddl/dev/dtrace/i386/dtrace_subr.c
  projects/pseries/conf/NOTES
  projects/pseries/conf/files
  projects/pseries/conf/files.ia64
  projects/pseries/conf/options
  projects/pseries/contrib/altq/altq/altq_red.c
  projects/pseries/contrib/pf/net/if_pflog.c
  projects/pseries/contrib/pf/net/if_pflog.h
  projects/pseries/contrib/pf/net/if_pfsync.c
  projects/pseries/contrib/pf/net/if_pfsync.h
  projects/pseries/contrib/pf/net/pf.c
  projects/pseries/contrib/pf/net/pf_if.c
  projects/pseries/contrib/pf/net/pf_ioctl.c
  projects/pseries/contrib/pf/net/pf_mtag.h
  projects/pseries/contrib/pf/net/pf_norm.c
  projects/pseries/contrib/pf/net/pf_osfp.c
  projects/pseries/contrib/pf/net/pf_ruleset.c
  projects/pseries/contrib/pf/net/pf_table.c
  projects/pseries/contrib/pf/net/pfvar.h
  projects/pseries/dev/acpica/acpi.c
  projects/pseries/dev/acpica/acpi_cpu.c
  projects/pseries/dev/acpica/acpi_thermal.c
  projects/pseries/dev/ahci/ahci.c
  projects/pseries/dev/an/if_an.c
  projects/pseries/dev/ath/ah_osdep.c
  projects/pseries/dev/ath/ath_hal/ah_eeprom_9287.h
  projects/pseries/dev/ath/ath_hal/ah_internal.h
  projects/pseries/dev/ath/ath_hal/ar9002/ar9287_attach.c
  projects/pseries/dev/ath/if_ath.c
  projects/pseries/dev/dc/dcphy.c
  projects/pseries/dev/dc/pnphy.c
  projects/pseries/dev/e1000/if_em.c
  projects/pseries/dev/e1000/if_igb.c
  projects/pseries/dev/e1000/if_igb.h
  projects/pseries/dev/en/if_en_pci.c
  projects/pseries/dev/et/if_et.c
  projects/pseries/dev/fdc/fdc_pccard.c
  projects/pseries/dev/fxp/if_fxp.c
  projects/pseries/dev/gem/if_gem.c
  projects/pseries/dev/gem/if_gemvar.h
  projects/pseries/dev/iicbus/if_ic.c
  projects/pseries/dev/lmc/if_lmc.c
  projects/pseries/dev/mfi/mfi_cam.c
  projects/pseries/dev/mii/e1000phy.c
  projects/pseries/dev/mii/miidevs
  projects/pseries/dev/my/if_my.c
  projects/pseries/dev/pci/pci_pci.c
  projects/pseries/dev/ppbus/if_plip.c
  projects/pseries/dev/pty/pty.c
  projects/pseries/dev/sis/if_sis.c
  projects/pseries/dev/snp/snp.c
  projects/pseries/dev/sound/macio/i2s.c
  projects/pseries/dev/sound/usb/uaudio.c
  projects/pseries/dev/syscons/scterm-teken.c
  projects/pseries/dev/tdfx/tdfx_pci.c
  projects/pseries/dev/uart/uart_bus_pci.c
  projects/pseries/dev/usb/input/uep.c
  projects/pseries/dev/usb/input/uhid.c
  projects/pseries/dev/usb/input/ukbd.c
  projects/pseries/dev/usb/input/ums.c
  projects/pseries/dev/usb/misc/udbp.c
  projects/pseries/dev/usb/misc/ufm.c
  projects/pseries/dev/usb/net/uhso.c
  projects/pseries/dev/usb/quirk/usb_quirk.c
  projects/pseries/dev/usb/quirk/usb_quirk.h
  projects/pseries/dev/usb/serial/ufoma.c
  projects/pseries/dev/usb/serial/umodem.c
  projects/pseries/dev/usb/storage/urio.c
  projects/pseries/dev/usb/usb_device.c
  projects/pseries/dev/usb/usb_hid.c
  projects/pseries/dev/usb/usb_lookup.c
  projects/pseries/dev/usb/usb_msctest.c
  projects/pseries/dev/usb/usbdevs
  projects/pseries/dev/usb/usbdi.h
  projects/pseries/dev/usb/usbhid.h
  projects/pseries/dev/usb/wlan/if_uath.c
  projects/pseries/dev/xen/control/control.c
  projects/pseries/fs/nfs/nfs_var.h
  projects/pseries/fs/nfs/nfsproto.h
  projects/pseries/fs/nfsclient/nfs_clport.c
  projects/pseries/fs/nfsclient/nfs_clrpcops.c
  projects/pseries/fs/nfsclient/nfs_clstate.c
  projects/pseries/fs/tmpfs/tmpfs_subr.c
  projects/pseries/geom/part/g_part_ebr.c
  projects/pseries/geom/part/g_part_gpt.c
  projects/pseries/geom/part/g_part_mbr.c
  projects/pseries/i386/i386/mp_machdep.c
  projects/pseries/i386/i386/pmap.c
  projects/pseries/i386/i386/sys_machdep.c
  projects/pseries/i386/i386/vm_machdep.c
  projects/pseries/i386/include/cpufunc.h
  projects/pseries/i386/xen/mp_machdep.c
  projects/pseries/i386/xen/pmap.c
  projects/pseries/ia64/conf/GENERIC
  projects/pseries/ia64/ia64/clock.c
  projects/pseries/ia64/ia64/db_machdep.c
  projects/pseries/ia64/ia64/exception.S
  projects/pseries/ia64/ia64/interrupt.c
  projects/pseries/ia64/ia64/machdep.c
  projects/pseries/ia64/ia64/mp_machdep.c
  projects/pseries/ia64/ia64/pmap.c
  projects/pseries/ia64/include/pcpu.h
  projects/pseries/ia64/include/smp.h
  projects/pseries/kern/imgact_elf.c
  projects/pseries/kern/kern_descrip.c
  projects/pseries/kern/kern_exec.c
  projects/pseries/kern/kern_exit.c
  projects/pseries/kern/kern_fork.c
  projects/pseries/kern/kern_jail.c
  projects/pseries/kern/kern_rmlock.c
  projects/pseries/kern/kern_thr.c
  projects/pseries/kern/sched_4bsd.c
  projects/pseries/kern/subr_kdb.c
  projects/pseries/kern/subr_pcpu.c
  projects/pseries/kern/subr_smp.c
  projects/pseries/kern/subr_trap.c
  projects/pseries/kern/sys_capability.c
  projects/pseries/kern/sysv_msg.c
  projects/pseries/kern/sysv_sem.c
  projects/pseries/kern/sysv_shm.c
  projects/pseries/kern/tty.c
  projects/pseries/kern/tty_inq.c
  projects/pseries/kern/tty_outq.c
  projects/pseries/kern/tty_pts.c
  projects/pseries/kern/tty_ttydisc.c
  projects/pseries/kern/uipc_shm.c
  projects/pseries/kern/uipc_syscalls.c
  projects/pseries/kern/vfs_bio.c
  projects/pseries/kern/vfs_subr.c
  projects/pseries/mips/atheros/ar71xx_chip.c
  projects/pseries/mips/atheros/ar71xx_machdep.c
  projects/pseries/mips/atheros/ar71xx_ohci.c
  projects/pseries/mips/atheros/ar71xx_setup.c
  projects/pseries/mips/atheros/ar724x_chip.c
  projects/pseries/mips/atheros/ar91xx_chip.c
  projects/pseries/mips/mips/genassym.c
  projects/pseries/mips/mips/mp_machdep.c
  projects/pseries/mips/mips/pmap.c
  projects/pseries/mips/mips/trap.c
  projects/pseries/mips/rmi/dev/xlr/rge.c
  projects/pseries/mips/rmi/fmn.c
  projects/pseries/mips/rmi/iodi.c
  projects/pseries/mips/sentry5/s5_machdep.c
  projects/pseries/mips/sibyte/sb_machdep.c
  projects/pseries/modules/Makefile
  projects/pseries/modules/ipdivert/Makefile
  projects/pseries/modules/pf/Makefile
  projects/pseries/modules/pflog/Makefile
  projects/pseries/net/if.c
  projects/pseries/net/if.h
  projects/pseries/net/if_arcsubr.c
  projects/pseries/net/if_atmsubr.c
  projects/pseries/net/if_debug.c
  projects/pseries/net/if_ethersubr.c
  projects/pseries/net/if_fddisubr.c
  projects/pseries/net/if_fwsubr.c
  projects/pseries/net/if_gif.c
  projects/pseries/net/if_iso88025subr.c
  projects/pseries/net/if_spppfr.c
  projects/pseries/net/if_spppsubr.c
  projects/pseries/net/if_stf.c
  projects/pseries/net/if_tun.c
  projects/pseries/net/if_var.h
  projects/pseries/net80211/ieee80211_dfs.c
  projects/pseries/netgraph/netflow/netflow.c
  projects/pseries/netgraph/netflow/netflow_v9.c
  projects/pseries/netgraph/netflow/ng_netflow.c
  projects/pseries/netgraph/netflow/ng_netflow.h
  projects/pseries/netgraph/netgraph.h
  projects/pseries/netgraph/ng_base.c
  projects/pseries/netgraph/ng_iface.c
  projects/pseries/netinet/if_ether.c
  projects/pseries/netinet/in_gif.c
  projects/pseries/netinet/ip_divert.c
  projects/pseries/netinet/ip_fw.h
  projects/pseries/netinet/ip_icmp.c
  projects/pseries/netinet/ip_var.h
  projects/pseries/netinet/ipfw/ip_fw2.c
  projects/pseries/netinet/ipfw/ip_fw_log.c
  projects/pseries/netinet/ipfw/ip_fw_pfil.c
  projects/pseries/netinet/ipfw/ip_fw_sockopt.c
  projects/pseries/netinet/libalias/libalias.3
  projects/pseries/netinet/raw_ip.c
  projects/pseries/netinet/sctp_uio.h
  projects/pseries/netinet/sctp_usrreq.c
  projects/pseries/netinet/tcp_lro.c
  projects/pseries/netinet/tcp_output.c
  projects/pseries/netinet/tcp_subr.c
  projects/pseries/netinet6/icmp6.c
  projects/pseries/netinet6/in6_gif.c
  projects/pseries/netipsec/ipsec_input.c
  projects/pseries/netipsec/ipsec_output.c
  projects/pseries/netipsec/xform_ipip.c
  projects/pseries/nfs/bootp_subr.c
  projects/pseries/powerpc/aim/mmu_oea.c
  projects/pseries/powerpc/aim/mmu_oea64.c
  projects/pseries/powerpc/aim/trap_subr32.S
  projects/pseries/powerpc/aim/trap_subr64.S
  projects/pseries/powerpc/booke/pmap.c
  projects/pseries/powerpc/ofw/rtas.c
  projects/pseries/powerpc/powermac/fcu.c
  projects/pseries/powerpc/powerpc/mp_machdep.c
  projects/pseries/powerpc/ps3/if_glc.c
  projects/pseries/sparc64/include/cache.h
  projects/pseries/sparc64/include/cpu.h
  projects/pseries/sparc64/include/pmap.h
  projects/pseries/sparc64/include/tlb.h
  projects/pseries/sparc64/sparc64/cache.c
  projects/pseries/sparc64/sparc64/cheetah.c
  projects/pseries/sparc64/sparc64/exception.S
  projects/pseries/sparc64/sparc64/interrupt.S
  projects/pseries/sparc64/sparc64/machdep.c
  projects/pseries/sparc64/sparc64/mp_exception.S
  projects/pseries/sparc64/sparc64/mp_machdep.c
  projects/pseries/sparc64/sparc64/pmap.c
  projects/pseries/sparc64/sparc64/spitfire.c
  projects/pseries/sparc64/sparc64/sys_machdep.c
  projects/pseries/sparc64/sparc64/vm_machdep.c
  projects/pseries/sparc64/sparc64/zeus.c
  projects/pseries/sys/_types.h
  projects/pseries/sys/capability.h
  projects/pseries/sys/cpuset.h
  projects/pseries/sys/diskmbr.h
  projects/pseries/sys/file.h
  projects/pseries/sys/filedesc.h
  projects/pseries/sys/mbuf.h
  projects/pseries/sys/param.h
  projects/pseries/sys/pcpu.h
  projects/pseries/sys/priv.h
  projects/pseries/sys/sockio.h
  projects/pseries/sys/soundcard.h
  projects/pseries/sys/tty.h
  projects/pseries/sys/ttydevsw.h
  projects/pseries/sys/types.h
  projects/pseries/teken/demo/teken_demo.c
  projects/pseries/teken/gensequences
  projects/pseries/teken/libteken/teken.3
  projects/pseries/teken/teken.c
  projects/pseries/teken/teken_subr.h
  projects/pseries/ufs/ffs/ffs_inode.c
  projects/pseries/ufs/ffs/ffs_softdep.c
  projects/pseries/ufs/ffs/softdep.h
  projects/pseries/ufs/ufs/ufs_inode.c
  projects/pseries/vm/device_pager.c
  projects/pseries/vm/swap_pager.c
  projects/pseries/vm/vm_glue.c
  projects/pseries/vm/vm_map.c
  projects/pseries/vm/vm_mmap.c
  projects/pseries/vm/vm_object.c
  projects/pseries/vm/vm_object.h
  projects/pseries/vm/vm_pageout.c
  projects/pseries/vm/vm_unix.c
  projects/pseries/vm/vnode_pager.c
Directory Properties:
  projects/pseries/   (props changed)
  projects/pseries/amd64/include/xen/   (props changed)
  projects/pseries/boot/   (props changed)
  projects/pseries/boot/i386/efi/   (props changed)
  projects/pseries/boot/ia64/efi/   (props changed)
  projects/pseries/boot/ia64/ski/   (props changed)
  projects/pseries/boot/powerpc/boot1.chrp/   (props changed)
  projects/pseries/boot/powerpc/ofw/   (props changed)
  projects/pseries/cddl/contrib/opensolaris/   (props changed)
  projects/pseries/conf/   (props changed)
  projects/pseries/contrib/dev/acpica/   (props changed)
  projects/pseries/contrib/octeon-sdk/   (props changed)
  projects/pseries/contrib/pf/   (props changed)
  projects/pseries/contrib/x86emu/   (props changed)

Modified: projects/pseries/amd64/acpica/acpi_wakeup.c
==============================================================================
--- projects/pseries/amd64/acpica/acpi_wakeup.c	Thu Jul  7 01:22:50 2011	(r223832)
+++ projects/pseries/amd64/acpica/acpi_wakeup.c	Thu Jul  7 05:07:25 2011	(r223833)
@@ -226,7 +226,8 @@ acpi_sleep_machdep(struct acpi_softc *sc
 		return (ret);
 
 #ifdef SMP
-	wakeup_cpus = PCPU_GET(other_cpus);
+	wakeup_cpus = all_cpus;
+	CPU_CLR(PCPU_GET(cpuid), &wakeup_cpus);
 #endif
 
 	AcpiSetFirmwareWakingVector(WAKECODE_PADDR(sc));

Modified: projects/pseries/amd64/amd64/mp_machdep.c
==============================================================================
--- projects/pseries/amd64/amd64/mp_machdep.c	Thu Jul  7 01:22:50 2011	(r223832)
+++ projects/pseries/amd64/amd64/mp_machdep.c	Thu Jul  7 05:07:25 2011	(r223833)
@@ -604,10 +604,10 @@ cpu_mp_announce(void)
 void
 init_secondary(void)
 {
-	cpuset_t tcpuset, tallcpus;
 	struct pcpu *pc;
 	struct nmi_pcpu *np;
 	u_int64_t msr, cr0;
+	u_int cpuid;
 	int cpu, gsel_tss, x;
 	struct region_descriptor ap_gdt;
 
@@ -711,8 +711,9 @@ init_secondary(void)
 	fpuinit();
 
 	/* A quick check from sanity claus */
+	cpuid = PCPU_GET(cpuid);
 	if (PCPU_GET(apic_id) != lapic_id()) {
-		printf("SMP: cpuid = %d\n", PCPU_GET(cpuid));
+		printf("SMP: cpuid = %d\n", cpuid);
 		printf("SMP: actual apic_id = %d\n", lapic_id());
 		printf("SMP: correct apic_id = %d\n", PCPU_GET(apic_id));
 		panic("cpuid mismatch! boom!!");
@@ -734,19 +735,13 @@ init_secondary(void)
 
 	smp_cpus++;
 
-	CTR1(KTR_SMP, "SMP: AP CPU #%d Launched", PCPU_GET(cpuid));
-	printf("SMP: AP CPU #%d Launched!\n", PCPU_GET(cpuid));
-	tcpuset = PCPU_GET(cpumask);
+	CTR1(KTR_SMP, "SMP: AP CPU #%d Launched", cpuid);
+	printf("SMP: AP CPU #%d Launched!\n", cpuid);
 
 	/* Determine if we are a logical CPU. */
 	/* XXX Calculation depends on cpu_logical being a power of 2, e.g. 2 */
 	if (cpu_logical > 1 && PCPU_GET(apic_id) % cpu_logical != 0)
-		CPU_OR(&logical_cpus_mask, &tcpuset);
-
-	/* Build our map of 'other' CPUs. */
-	tallcpus = all_cpus;
-	CPU_NAND(&tallcpus, &tcpuset);
-	PCPU_SET(other_cpus, tallcpus);
+		CPU_SET(cpuid, &logical_cpus_mask);
 
 	if (bootverbose)
 		lapic_dump("AP");
@@ -893,7 +888,6 @@ assign_cpu_ids(void)
 static int
 start_all_aps(void)
 {
-	cpuset_t tallcpus, tcpuset;
 	vm_offset_t va = boot_address + KERNBASE;
 	u_int64_t *pt4, *pt3, *pt2;
 	u_int32_t mpbioswarmvec;
@@ -961,12 +955,6 @@ start_all_aps(void)
 		CPU_SET(cpu, &all_cpus);	/* record AP in CPU map */
 	}
 
-	/* build our map of 'other' CPUs */
-	tallcpus = all_cpus;
-	tcpuset = PCPU_GET(cpumask);
-	CPU_NAND(&tallcpus, &tcpuset);
-	PCPU_SET(other_cpus, tallcpus);
-
 	/* restore the warmstart vector */
 	*(u_int32_t *) WARMBOOT_OFF = mpbioswarmvec;
 
@@ -1150,9 +1138,7 @@ smp_targeted_tlb_shootdown(cpuset_t mask
 		if (othercpus < 1)
 			return;
 	} else {
-		sched_pin();
-		CPU_NAND(&mask, PCPU_PTR(cpumask));
-		sched_unpin();
+		CPU_CLR(PCPU_GET(cpuid), &mask);
 		if (CPU_EMPTY(&mask))
 			return;
 	}
@@ -1349,11 +1335,13 @@ ipi_cpu(int cpu, u_int ipi)
 void
 ipi_all_but_self(u_int ipi)
 {
+	cpuset_t other_cpus;
+
+	other_cpus = all_cpus;
+	CPU_CLR(PCPU_GET(cpuid), &other_cpus);
 
-	sched_pin();
 	if (IPI_IS_BITMAPED(ipi)) {
-		ipi_selected(PCPU_GET(other_cpus), ipi);
-		sched_unpin();
+		ipi_selected(other_cpus, ipi);
 		return;
 	}
 
@@ -1363,8 +1351,7 @@ ipi_all_but_self(u_int ipi)
 	 * Set the mask of receiving CPUs for this purpose.
 	 */
 	if (ipi == IPI_STOP_HARD)
-		CPU_OR_ATOMIC(&ipi_nmi_pending, PCPU_PTR(other_cpus));
-	sched_unpin();
+		CPU_OR_ATOMIC(&ipi_nmi_pending, &other_cpus);
 
 	CTR2(KTR_SMP, "%s: ipi: %x", __func__, ipi);
 	lapic_ipi_vectored(ipi, APIC_IPI_DEST_OTHERS);
@@ -1373,7 +1360,7 @@ ipi_all_but_self(u_int ipi)
 int
 ipi_nmi_handler()
 {
-	cpuset_t cpumask;
+	u_int cpuid;
 
 	/*
 	 * As long as there is not a simple way to know about a NMI's
@@ -1381,13 +1368,11 @@ ipi_nmi_handler()
 	 * the global pending bitword an IPI_STOP_HARD has been issued
 	 * and should be handled.
 	 */
-	sched_pin();
-	cpumask = PCPU_GET(cpumask);
-	sched_unpin();
-	if (!CPU_OVERLAP(&ipi_nmi_pending, &cpumask))
+	cpuid = PCPU_GET(cpuid);
+	if (!CPU_ISSET(cpuid, &ipi_nmi_pending))
 		return (1);
 
-	CPU_NAND_ATOMIC(&ipi_nmi_pending, &cpumask);
+	CPU_CLR_ATOMIC(cpuid, &ipi_nmi_pending);
 	cpustop_handler();
 	return (0);
 }
@@ -1399,25 +1384,21 @@ ipi_nmi_handler()
 void
 cpustop_handler(void)
 {
-	cpuset_t cpumask;
 	u_int cpu;
 
-	sched_pin();
 	cpu = PCPU_GET(cpuid);
-	cpumask = PCPU_GET(cpumask);
-	sched_unpin();
 
 	savectx(&stoppcbs[cpu]);
 
 	/* Indicate that we are stopped */
-	CPU_OR_ATOMIC(&stopped_cpus, &cpumask);
+	CPU_SET_ATOMIC(cpu, &stopped_cpus);
 
 	/* Wait for restart */
-	while (!CPU_OVERLAP(&started_cpus, &cpumask))
+	while (!CPU_ISSET(cpu, &started_cpus))
 	    ia32_pause();
 
-	CPU_NAND_ATOMIC(&started_cpus, &cpumask);
-	CPU_NAND_ATOMIC(&stopped_cpus, &cpumask);
+	CPU_CLR_ATOMIC(cpu, &started_cpus);
+	CPU_CLR_ATOMIC(cpu, &stopped_cpus);
 
 	if (cpu == 0 && cpustop_restartfunc != NULL) {
 		cpustop_restartfunc();
@@ -1432,19 +1413,17 @@ cpustop_handler(void)
 void
 cpususpend_handler(void)
 {
-	cpuset_t cpumask;
 	register_t cr3, rf;
 	u_int cpu;
 
 	cpu = PCPU_GET(cpuid);
-	cpumask = PCPU_GET(cpumask);
 
 	rf = intr_disable();
 	cr3 = rcr3();
 
 	if (savectx(susppcbs[cpu])) {
 		wbinvd();
-		CPU_OR_ATOMIC(&stopped_cpus, &cpumask);
+		CPU_SET_ATOMIC(cpu, &stopped_cpus);
 	} else {
 		pmap_init_pat();
 		PCPU_SET(switchtime, 0);
@@ -1452,11 +1431,11 @@ cpususpend_handler(void)
 	}
 
 	/* Wait for resume */
-	while (!CPU_OVERLAP(&started_cpus, &cpumask))
+	while (!CPU_ISSET(cpu, &started_cpus))
 		ia32_pause();
 
-	CPU_NAND_ATOMIC(&started_cpus, &cpumask);
-	CPU_NAND_ATOMIC(&stopped_cpus, &cpumask);
+	CPU_CLR_ATOMIC(cpu, &started_cpus);
+	CPU_CLR_ATOMIC(cpu, &stopped_cpus);
 
 	/* Restore CR3 and enable interrupts */
 	load_cr3(cr3);

Modified: projects/pseries/amd64/amd64/pmap.c
==============================================================================
--- projects/pseries/amd64/amd64/pmap.c	Thu Jul  7 01:22:50 2011	(r223832)
+++ projects/pseries/amd64/amd64/pmap.c	Thu Jul  7 05:07:25 2011	(r223833)
@@ -925,16 +925,18 @@ pmap_update_pde_invalidate(vm_offset_t v
 void
 pmap_invalidate_page(pmap_t pmap, vm_offset_t va)
 {
-	cpuset_t cpumask, other_cpus;
+	cpuset_t other_cpus;
+	u_int cpuid;
 
 	sched_pin();
 	if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) {
 		invlpg(va);
 		smp_invlpg(va);
 	} else {
-		cpumask = PCPU_GET(cpumask);
-		other_cpus = PCPU_GET(other_cpus);
-		if (CPU_OVERLAP(&pmap->pm_active, &cpumask))
+		cpuid = PCPU_GET(cpuid);
+		other_cpus = all_cpus;
+		CPU_CLR(cpuid, &other_cpus);
+		if (CPU_ISSET(cpuid, &pmap->pm_active))
 			invlpg(va);
 		CPU_AND(&other_cpus, &pmap->pm_active);
 		if (!CPU_EMPTY(&other_cpus))
@@ -946,8 +948,9 @@ pmap_invalidate_page(pmap_t pmap, vm_off
 void
 pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva)
 {
-	cpuset_t cpumask, other_cpus;
+	cpuset_t other_cpus;
 	vm_offset_t addr;
+	u_int cpuid;
 
 	sched_pin();
 	if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) {
@@ -955,9 +958,10 @@ pmap_invalidate_range(pmap_t pmap, vm_of
 			invlpg(addr);
 		smp_invlpg_range(sva, eva);
 	} else {
-		cpumask = PCPU_GET(cpumask);
-		other_cpus = PCPU_GET(other_cpus);
-		if (CPU_OVERLAP(&pmap->pm_active, &cpumask))
+		cpuid = PCPU_GET(cpuid);
+		other_cpus = all_cpus;
+		CPU_CLR(cpuid, &other_cpus);
+		if (CPU_ISSET(cpuid, &pmap->pm_active))
 			for (addr = sva; addr < eva; addr += PAGE_SIZE)
 				invlpg(addr);
 		CPU_AND(&other_cpus, &pmap->pm_active);
@@ -970,16 +974,18 @@ pmap_invalidate_range(pmap_t pmap, vm_of
 void
 pmap_invalidate_all(pmap_t pmap)
 {
-	cpuset_t cpumask, other_cpus;
+	cpuset_t other_cpus;
+	u_int cpuid;
 
 	sched_pin();
 	if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) {
 		invltlb();
 		smp_invltlb();
 	} else {
-		cpumask = PCPU_GET(cpumask);
-		other_cpus = PCPU_GET(other_cpus);
-		if (CPU_OVERLAP(&pmap->pm_active, &cpumask))
+		cpuid = PCPU_GET(cpuid);
+		other_cpus = all_cpus;
+		CPU_CLR(cpuid, &other_cpus);
+		if (CPU_ISSET(cpuid, &pmap->pm_active))
 			invltlb();
 		CPU_AND(&other_cpus, &pmap->pm_active);
 		if (!CPU_EMPTY(&other_cpus))
@@ -999,11 +1005,11 @@ pmap_invalidate_cache(void)
 }
 
 struct pde_action {
-	cpuset_t store;		/* processor that updates the PDE */
 	cpuset_t invalidate;	/* processors that invalidate their TLB */
 	vm_offset_t va;
 	pd_entry_t *pde;
 	pd_entry_t newpde;
+	u_int store;		/* processor that updates the PDE */
 };
 
 static void
@@ -1011,12 +1017,8 @@ pmap_update_pde_action(void *arg)
 {
 	struct pde_action *act = arg;
 
-	sched_pin();
-	if (!CPU_CMP(&act->store, PCPU_PTR(cpumask))) {
-		sched_unpin();
+	if (act->store == PCPU_GET(cpuid))
 		pde_store(act->pde, act->newpde);
-	} else
-		sched_unpin();
 }
 
 static void
@@ -1024,12 +1026,8 @@ pmap_update_pde_teardown(void *arg)
 {
 	struct pde_action *act = arg;
 
-	sched_pin();
-	if (CPU_OVERLAP(&act->invalidate, PCPU_PTR(cpumask))) {
-		sched_unpin();
+	if (CPU_ISSET(PCPU_GET(cpuid), &act->invalidate))
 		pmap_update_pde_invalidate(act->va, act->newpde);
-	} else
-		sched_unpin();
 }
 
 /*
@@ -1044,28 +1042,30 @@ static void
 pmap_update_pde(pmap_t pmap, vm_offset_t va, pd_entry_t *pde, pd_entry_t newpde)
 {
 	struct pde_action act;
-	cpuset_t active, cpumask, other_cpus;
+	cpuset_t active, other_cpus;
+	u_int cpuid;
 
 	sched_pin();
-	cpumask = PCPU_GET(cpumask);
-	other_cpus = PCPU_GET(other_cpus);
+	cpuid = PCPU_GET(cpuid);
+	other_cpus = all_cpus;
+	CPU_CLR(cpuid, &other_cpus);
 	if (pmap == kernel_pmap)
 		active = all_cpus;
 	else
 		active = pmap->pm_active;
 	if (CPU_OVERLAP(&active, &other_cpus)) { 
-		act.store = cpumask;
+		act.store = cpuid;
 		act.invalidate = active;
 		act.va = va;
 		act.pde = pde;
 		act.newpde = newpde;
-		CPU_OR(&cpumask, &active);
-		smp_rendezvous_cpus(cpumask,
+		CPU_SET(cpuid, &active);
+		smp_rendezvous_cpus(active,
 		    smp_no_rendevous_barrier, pmap_update_pde_action,
 		    pmap_update_pde_teardown, &act);
 	} else {
 		pde_store(pde, newpde);
-		if (CPU_OVERLAP(&active, &cpumask))
+		if (CPU_ISSET(cpuid, &active))
 			pmap_update_pde_invalidate(va, newpde);
 	}
 	sched_unpin();
@@ -2104,7 +2104,7 @@ pmap_collect(pmap_t locked_pmap, struct 
 	vm_page_t m, free;
 
 	TAILQ_FOREACH(m, &vpq->pl, pageq) {
-		if (m->hold_count || m->busy)
+		if ((m->flags & PG_MARKER) != 0 || m->hold_count || m->busy)
 			continue;
 		TAILQ_FOREACH_SAFE(pv, &m->md.pv_list, pv_list, next_pv) {
 			va = pv->pv_va;
@@ -2847,8 +2847,8 @@ pmap_remove_all(vm_page_t m)
 	vm_offset_t va;
 	vm_page_t free;
 
-	KASSERT((m->flags & PG_FICTITIOUS) == 0,
-	    ("pmap_remove_all: page %p is fictitious", m));
+	KASSERT((m->flags & (PG_FICTITIOUS | PG_UNMANAGED)) == 0,
+	    ("pmap_remove_all: page %p is not managed", m));
 	free = NULL;
 	vm_page_lock_queues();
 	pvh = pa_to_pvh(VM_PAGE_TO_PHYS(m));
@@ -5095,17 +5095,19 @@ void
 pmap_activate(struct thread *td)
 {
 	pmap_t	pmap, oldpmap;
+	u_int	cpuid;
 	u_int64_t  cr3;
 
 	critical_enter();
 	pmap = vmspace_pmap(td->td_proc->p_vmspace);
 	oldpmap = PCPU_GET(curpmap);
+	cpuid = PCPU_GET(cpuid);
 #ifdef SMP
-	CPU_NAND_ATOMIC(&oldpmap->pm_active, PCPU_PTR(cpumask));
-	CPU_OR_ATOMIC(&pmap->pm_active, PCPU_PTR(cpumask));
+	CPU_CLR_ATOMIC(cpuid, &oldpmap->pm_active);
+	CPU_SET_ATOMIC(cpuid, &pmap->pm_active);
 #else
-	CPU_NAND(&oldpmap->pm_active, PCPU_PTR(cpumask));
-	CPU_OR(&pmap->pm_active, PCPU_PTR(cpumask));
+	CPU_CLR(cpuid, &oldpmap->pm_active);
+	CPU_SET(cpuid, &pmap->pm_active);
 #endif
 	cr3 = DMAP_TO_PHYS((vm_offset_t)pmap->pm_pml4);
 	td->td_pcb->pcb_cr3 = cr3;

Modified: projects/pseries/amd64/amd64/sys_machdep.c
==============================================================================
--- projects/pseries/amd64/amd64/sys_machdep.c	Thu Jul  7 01:22:50 2011	(r223832)
+++ projects/pseries/amd64/amd64/sys_machdep.c	Thu Jul  7 05:07:25 2011	(r223833)
@@ -33,7 +33,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "opt_capabilities.h"
+#include "opt_capsicum.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -180,28 +180,30 @@ sysarch(td, uap)
 	uint64_t a64base;
 	struct i386_ioperm_args iargs;
 
-#ifdef CAPABILITIES
+#ifdef CAPABILITY_MODE
 	/*
-	 * Whitelist of operations which are safe enough for capability mode.
+	 * When adding new operations, add a new case statement here to
+	 * explicitly indicate whether or not the operation is safe to
+	 * perform in capability mode.
 	 */
 	if (IN_CAPABILITY_MODE(td)) {
 		switch (uap->op) {
-			case I386_GET_LDT:
-			case I386_SET_LDT:
-			case I386_GET_IOPERM:
-			case I386_GET_FSBASE:
-			case I386_SET_FSBASE:
-			case I386_GET_GSBASE:
-			case I386_SET_GSBASE:
-			case AMD64_GET_FSBASE:
-			case AMD64_SET_FSBASE:
-			case AMD64_GET_GSBASE:
-			case AMD64_SET_GSBASE:
-				break;
+		case I386_GET_LDT:
+		case I386_SET_LDT:
+		case I386_GET_IOPERM:
+		case I386_GET_FSBASE:
+		case I386_SET_FSBASE:
+		case I386_GET_GSBASE:
+		case I386_SET_GSBASE:
+		case AMD64_GET_FSBASE:
+		case AMD64_SET_FSBASE:
+		case AMD64_GET_GSBASE:
+		case AMD64_SET_GSBASE:
+			break;
 
-			case I386_SET_IOPERM:
-			default:
-				return (ECAPMODE);
+		case I386_SET_IOPERM:
+		default:
+			return (ECAPMODE);
 		}
 	}
 #endif

Modified: projects/pseries/amd64/amd64/vm_machdep.c
==============================================================================
--- projects/pseries/amd64/amd64/vm_machdep.c	Thu Jul  7 01:22:50 2011	(r223832)
+++ projects/pseries/amd64/amd64/vm_machdep.c	Thu Jul  7 05:07:25 2011	(r223833)
@@ -59,7 +59,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/mutex.h>
 #include <sys/pioctl.h>
 #include <sys/proc.h>
-#include <sys/sched.h>
 #include <sys/sf_buf.h>
 #include <sys/smp.h>
 #include <sys/sysctl.h>
@@ -535,8 +534,8 @@ cpu_reset()
 	u_int cnt;
 
 	if (smp_active) {
-		sched_pin();
-		map = PCPU_GET(other_cpus);
+		map = all_cpus;
+		CPU_CLR(PCPU_GET(cpuid), &map);
 		CPU_NAND(&map, &stopped_cpus);
 		if (!CPU_EMPTY(&map)) {
 			printf("cpu_reset: Stopping other CPUs\n");
@@ -545,7 +544,6 @@ cpu_reset()
 
 		if (PCPU_GET(cpuid) != 0) {
 			cpu_reset_proxyid = PCPU_GET(cpuid);
-			sched_unpin();
 			cpustop_restartfunc = cpu_reset_proxy;
 			cpu_reset_proxy_active = 0;
 			printf("cpu_reset: Restarting BSP\n");
@@ -564,8 +562,7 @@ cpu_reset()
 
 			while (1);
 			/* NOTREACHED */
-		} else
-			sched_unpin();
+		}
 
 		DELAY(1000000);
 	}

Modified: projects/pseries/amd64/include/cpufunc.h
==============================================================================
--- projects/pseries/amd64/include/cpufunc.h	Thu Jul  7 01:22:50 2011	(r223832)
+++ projects/pseries/amd64/include/cpufunc.h	Thu Jul  7 05:07:25 2011	(r223833)
@@ -467,16 +467,18 @@ load_es(u_short sel)
 }
 
 static __inline void
-cpu_monitor(const void *addr, int extensions, int hints)
+cpu_monitor(const void *addr, u_long extensions, u_int hints)
 {
-	__asm __volatile("monitor;"
-	    : :"a" (addr), "c" (extensions), "d"(hints));
+
+	__asm __volatile("monitor"
+	    : : "a" (addr), "c" (extensions), "d" (hints));
 }
 
 static __inline void
-cpu_mwait(int extensions, int hints)
+cpu_mwait(u_long extensions, u_int hints)
 {
-	__asm __volatile("mwait;" : :"a" (hints), "c" (extensions));
+
+	__asm __volatile("mwait" : : "a" (hints), "c" (extensions));
 }
 
 #ifdef _KERNEL

Modified: projects/pseries/arm/arm/pmap.c
==============================================================================
--- projects/pseries/arm/arm/pmap.c	Thu Jul  7 01:22:50 2011	(r223832)
+++ projects/pseries/arm/arm/pmap.c	Thu Jul  7 05:07:25 2011	(r223833)
@@ -3120,8 +3120,8 @@ pmap_remove_all(vm_page_t m)
 	pmap_t curpm;
 	int flags = 0;
 
-	KASSERT((m->flags & PG_FICTITIOUS) == 0,
-	    ("pmap_remove_all: page %p is fictitious", m));
+	KASSERT((m->flags & (PG_FICTITIOUS | PG_UNMANAGED)) == 0,
+	    ("pmap_remove_all: page %p is not managed", m));
 	if (TAILQ_EMPTY(&m->md.pv_list))
 		return;
 	vm_page_lock_queues();

Modified: projects/pseries/arm/arm/sys_machdep.c
==============================================================================
--- projects/pseries/arm/arm/sys_machdep.c	Thu Jul  7 01:22:50 2011	(r223832)
+++ projects/pseries/arm/arm/sys_machdep.c	Thu Jul  7 05:07:25 2011	(r223833)
@@ -36,7 +36,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include "opt_capabilities.h"
+#include "opt_capsicum.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -107,20 +107,22 @@ sysarch(td, uap)
 {
 	int error;
 
-#ifdef CAPABILITIES
+#ifdef CAPABILITY_MODE
 	/*
-	 * Whitelist of operations which are safe enough for capability mode.
+	 * When adding new operations, add a new case statement here to
+	 * explicitly indicate whether or not the operation is safe to
+	 * perform in capability mode.
 	 */
 	if (IN_CAPABILITY_MODE(td)) {
 		switch (uap->op) {
-			case ARM_SYNC_ICACHE:
-			case ARM_DRAIN_WRITEBUF:
-			case ARM_SET_TP:
-			case ARM_GET_TP:
-				break;
+		case ARM_SYNC_ICACHE:
+		case ARM_DRAIN_WRITEBUF:
+		case ARM_SET_TP:
+		case ARM_GET_TP:
+			break;
 
-			default:
-				return (ECAPMODE);
+		default:
+			return (ECAPMODE);
 		}
 	}
 #endif

Modified: projects/pseries/arm/at91/at91_machdep.c
==============================================================================
--- projects/pseries/arm/at91/at91_machdep.c	Thu Jul  7 01:22:50 2011	(r223832)
+++ projects/pseries/arm/at91/at91_machdep.c	Thu Jul  7 05:07:25 2011	(r223833)
@@ -91,7 +91,6 @@ __FBSDID("$FreeBSD$");
 #include <arm/at91/at91var.h>
 #include <arm/at91/at91rm92reg.h>
 #include <arm/at91/at91sam9g20reg.h>
-#include <arm/at91/at91board.h>
 
 #define KERNEL_PT_SYS		0	/* Page table for mapping proc0 zero page */
 #define KERNEL_PT_KERN		1

Modified: projects/pseries/arm/conf/CAMBRIA
==============================================================================
--- projects/pseries/arm/conf/CAMBRIA	Thu Jul  7 01:22:50 2011	(r223832)
+++ projects/pseries/arm/conf/CAMBRIA	Thu Jul  7 05:07:25 2011	(r223833)
@@ -130,7 +130,7 @@ options 	ATH_DIAGAPI
 #options 	ATH_TX99_DIAG
 device		ath_rate_sample	# SampleRate tx rate control for ath
 
-options 	AH_DEBUG
+#options 	AH_DEBUG
 #options 	AH_ASSERT
 options 	AH_PRIVATE_DIAG
 #device		ath_ar5210

Modified: projects/pseries/arm/mv/common.c
==============================================================================
--- projects/pseries/arm/mv/common.c	Thu Jul  7 01:22:50 2011	(r223832)
+++ projects/pseries/arm/mv/common.c	Thu Jul  7 05:07:25 2011	(r223833)
@@ -122,7 +122,7 @@ static struct soc_node_spec soc_nodes[] 
 	{ "mrvl,sata", &decode_win_sata_setup, NULL },
 	{ "mrvl,xor", &decode_win_xor_setup, &decode_win_xor_dump },
 	{ "mrvl,idma", &decode_win_idma_setup, &decode_win_idma_dump },
-	{ "mvrl,pcie", &decode_win_pcie_setup, NULL },
+	{ "mrvl,pcie", &decode_win_pcie_setup, NULL },
 	{ NULL, NULL, NULL },
 };
 

Modified: projects/pseries/arm/sa11x0/assabet_machdep.c
==============================================================================
--- projects/pseries/arm/sa11x0/assabet_machdep.c	Thu Jul  7 01:22:50 2011	(r223832)
+++ projects/pseries/arm/sa11x0/assabet_machdep.c	Thu Jul  7 05:07:25 2011	(r223833)
@@ -77,7 +77,6 @@ __FBSDID("$FreeBSD$");
 
 #include <vm/vm.h>
 #include <vm/pmap.h>
-#include <vm/vm.h>
 #include <vm/vm_object.h>
 #include <vm/vm_page.h>
 #include <vm/vm_pager.h>

Modified: projects/pseries/arm/sa11x0/sa11x0.c
==============================================================================
--- projects/pseries/arm/sa11x0/sa11x0.c	Thu Jul  7 01:22:50 2011	(r223832)
+++ projects/pseries/arm/sa11x0/sa11x0.c	Thu Jul  7 05:07:25 2011	(r223833)
@@ -58,7 +58,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/kernel.h>
 #include <sys/reboot.h>
 #include <sys/malloc.h>
-#include <sys/bus.h>
 #include <sys/interrupt.h>
 #include <sys/module.h>
 #include <sys/rman.h>
@@ -74,7 +73,6 @@ __FBSDID("$FreeBSD$");
 #include <arm/sa11x0/sa11x0_dmacreg.h>
 #include <arm/sa11x0/sa11x0_ppcreg.h>
 #include <arm/sa11x0/sa11x0_gpioreg.h>
-#include <machine/bus.h>
 
 extern void sa11x0_activateirqs(void);
 

Modified: projects/pseries/boot/Makefile
==============================================================================
--- projects/pseries/boot/Makefile	Thu Jul  7 01:22:50 2011	(r223832)
+++ projects/pseries/boot/Makefile	Thu Jul  7 05:07:25 2011	(r223833)
@@ -8,10 +8,6 @@
 SUBDIR+=		ficl
 .endif
 
-.if ${MK_FDT} != "no"
-SUBDIR+=		fdt
-.endif
-
 # Pick the machine-dependent subdir based on the target architecture.
 ADIR=			${MACHINE:S/amd64/i386/:S/powerpc64/powerpc/}
 .if exists(${.CURDIR}/${ADIR}/.)

Modified: projects/pseries/boot/Makefile.amd64
==============================================================================
--- projects/pseries/boot/Makefile.amd64	Thu Jul  7 01:22:50 2011	(r223832)
+++ projects/pseries/boot/Makefile.amd64	Thu Jul  7 05:07:25 2011	(r223833)
@@ -2,3 +2,4 @@
 
 SUBDIR+=		efi
 SUBDIR+=		zfs
+SUBDIR+=		userboot

Modified: projects/pseries/boot/Makefile.arm
==============================================================================
--- projects/pseries/boot/Makefile.arm	Thu Jul  7 01:22:50 2011	(r223832)
+++ projects/pseries/boot/Makefile.arm	Thu Jul  7 05:07:25 2011	(r223833)
@@ -1,3 +1,7 @@
 # $FreeBSD$
 
+.if ${MK_FDT} != "no"
+SUBDIR+=		fdt
+.endif
+
 SUBDIR+=		uboot

Modified: projects/pseries/boot/Makefile.powerpc
==============================================================================
--- projects/pseries/boot/Makefile.powerpc	Thu Jul  7 01:22:50 2011	(r223832)
+++ projects/pseries/boot/Makefile.powerpc	Thu Jul  7 05:07:25 2011	(r223833)
@@ -1,4 +1,8 @@
 # $FreeBSD$
 
+.if ${MK_FDT} != "no"
+SUBDIR+=		fdt
+.endif
+
 SUBDIR+=		ofw
 SUBDIR+=		uboot

Modified: projects/pseries/boot/common/Makefile.inc
==============================================================================
--- projects/pseries/boot/common/Makefile.inc	Thu Jul  7 01:22:50 2011	(r223832)
+++ projects/pseries/boot/common/Makefile.inc	Thu Jul  7 05:07:25 2011	(r223833)
@@ -1,6 +1,6 @@
 # $FreeBSD$
 
-SRCS+=	boot.c commands.c console.c devopen.c interp.c 
+SRCS+=	boot.c commands.c console.c devopen.c disk.c interp.c 
 SRCS+=	interp_backslash.c interp_parse.c ls.c misc.c 
 SRCS+=	module.c panic.c
 

Copied: projects/pseries/boot/common/disk.c (from r223832, head/sys/boot/common/disk.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/pseries/boot/common/disk.c	Thu Jul  7 05:07:25 2011	(r223833, copy of r223832, head/sys/boot/common/disk.c)
@@ -0,0 +1,799 @@
+/*-
+ * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
+ * 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 <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * MBR/GPT partitioned disk device handling.
+ *
+ * Ideas and algorithms from:
+ *
+ * - NetBSD libi386/biosdisk.c
+ * - FreeBSD biosboot/disk.c
+ *
+ */
+
+#include <stand.h>
+
+#include <sys/diskmbr.h>
+#include <sys/disklabel.h>
+#include <sys/gpt.h>
+
+#include <stdarg.h>
+#include <uuid.h>
+
+#include <bootstrap.h>
+
+#include "disk.h"
+
+#ifdef DISK_DEBUG
+# define DEBUG(fmt, args...)	printf("%s: " fmt "\n" , __func__ , ## args)
+#else
+# define DEBUG(fmt, args...)
+#endif
+
+/*
+ * Search for a slice with the following preferences:
+ *
+ * 1: Active FreeBSD slice
+ * 2: Non-active FreeBSD slice
+ * 3: Active Linux slice
+ * 4: non-active Linux slice
+ * 5: Active FAT/FAT32 slice
+ * 6: non-active FAT/FAT32 slice
+ */
+#define PREF_RAWDISK	0
+#define PREF_FBSD_ACT	1
+#define PREF_FBSD	2
+#define PREF_LINUX_ACT	3
+#define PREF_LINUX	4
+#define PREF_DOS_ACT	5
+#define PREF_DOS	6
+#define PREF_NONE	7
+
+#ifdef LOADER_GPT_SUPPORT
+
+struct gpt_part {
+	int		gp_index;
+	uuid_t		gp_type;
+	uint64_t	gp_start;
+	uint64_t	gp_end;
+};
+
+static uuid_t efi = GPT_ENT_TYPE_EFI;
+static uuid_t freebsd_boot = GPT_ENT_TYPE_FREEBSD_BOOT;
+static uuid_t freebsd_ufs = GPT_ENT_TYPE_FREEBSD_UFS;
+static uuid_t freebsd_swap = GPT_ENT_TYPE_FREEBSD_SWAP;
+static uuid_t freebsd_zfs = GPT_ENT_TYPE_FREEBSD_ZFS;
+static uuid_t ms_basic_data = GPT_ENT_TYPE_MS_BASIC_DATA;
+
+#endif
+
+#if defined(LOADER_GPT_SUPPORT) || defined(LOADER_MBR_SUPPORT)
+
+/* Given a size in 512 byte sectors, convert it to a human-readable number. */
+static char *
+display_size(uint64_t size)
+{
+	static char buf[80];
+	char unit;
+
+	size /= 2;
+	unit = 'K';
+	if (size >= 10485760000LL) {
+		size /= 1073741824;
+		unit = 'T';
+	} else if (size >= 10240000) {
+		size /= 1048576;
+		unit = 'G';
+	} else if (size >= 10000) {
+		size /= 1024;
+		unit = 'M';
+	}
+	sprintf(buf, "%.6ld%cB", (long)size, unit);
+	return (buf);
+}
+
+#endif
+
+#ifdef LOADER_MBR_SUPPORT
+
+static void
+disk_checkextended(struct disk_devdesc *dev,
+    struct dos_partition *slicetab, int slicenum, int *nslicesp)
+{
+	uint8_t			buf[DISK_SECSIZE];
+	struct dos_partition	*dp;
+	uint32_t		base;
+	int			rc, i, start, end;
+
+	dp = &slicetab[slicenum];
+	start = *nslicesp;
+
+	if (dp->dp_size == 0)
+		goto done;
+	if (dp->dp_typ != DOSPTYP_EXT)
+		goto done;
+	rc = dev->d_dev->dv_strategy(dev, F_READ, dp->dp_start, DISK_SECSIZE,
+		(char *) buf, NULL);
+	if (rc)
+		goto done;
+	if (buf[0x1fe] != 0x55 || buf[0x1ff] != 0xaa) {
+		DEBUG("no magic in extended table");
+		goto done;
+	}
+	base = dp->dp_start;
+	dp = (struct dos_partition *) &buf[DOSPARTOFF];
+	for (i = 0; i < NDOSPART; i++, dp++) {
+		if (dp->dp_size == 0)
+			continue;
+		if (*nslicesp == NEXTDOSPART)
+			goto done;
+		dp->dp_start += base;
+		bcopy(dp, &slicetab[*nslicesp], sizeof(*dp));
+		(*nslicesp)++;
+	}
+	end = *nslicesp;
+
+	/*
+	 * now, recursively check the slices we just added
+	 */
+	for (i = start; i < end; i++)
+		disk_checkextended(dev, slicetab, i, nslicesp);
+done:
+	return;
+}
+
+static int
+disk_readslicetab(struct disk_devdesc *dev,
+    struct dos_partition **slicetabp, int *nslicesp)
+{
+	struct dos_partition	*slicetab = NULL;
+	int			nslices, i;
+	int			rc;
+	uint8_t			buf[DISK_SECSIZE];
+
+	/*
+	 * Find the slice in the DOS slice table.
+	 */
+	rc = dev->d_dev->dv_strategy(dev, F_READ, 0, DISK_SECSIZE,
+		(char *) buf, NULL);
+	if (rc) {
+		DEBUG("error reading MBR");
+		return (rc);
+	}
+
+	/*
+	 * Check the slice table magic.
+	 */
+	if (buf[0x1fe] != 0x55 || buf[0x1ff] != 0xaa) {
+		DEBUG("no slice table/MBR (no magic)");
+		return (rc);
+	}
+
+	/*
+	 * copy the partition table, then pick up any extended partitions.
+	 */
+	slicetab = malloc(NEXTDOSPART * sizeof(struct dos_partition));
+	bcopy(buf + DOSPARTOFF, slicetab,
+		sizeof(struct dos_partition) * NDOSPART);
+	nslices = NDOSPART;		/* extended slices start here */
+	for (i = 0; i < NDOSPART; i++)
+		disk_checkextended(dev, slicetab, i, &nslices);
+
+	*slicetabp = slicetab;
+	*nslicesp = nslices;
+	return (0);
+}
+
+/*
+ * Search for the best MBR slice (typically the first FreeBSD slice).
+ */
+static int
+disk_bestslice(struct dos_partition *slicetab, int nslices)
+{
+	struct dos_partition *dp;
+	int pref, preflevel;
+	int i, prefslice;
+
+	prefslice = 0;
+	preflevel = PREF_NONE;
+
+	dp = &slicetab[0];
+	for (i = 0; i < nslices; i++, dp++) {
+		switch (dp->dp_typ) {
+		case DOSPTYP_386BSD:		/* FreeBSD */
+			pref = dp->dp_flag & 0x80 ? PREF_FBSD_ACT : PREF_FBSD;
+			break;
+
+		case DOSPTYP_LINUX:
+			pref = dp->dp_flag & 0x80 ? PREF_LINUX_ACT : PREF_LINUX;
+			break;
+
+		case 0x01:		/* DOS/Windows */
+		case 0x04:
+		case 0x06:
+		case 0x0b:
+		case 0x0c:
+		case 0x0e:
+			pref = dp->dp_flag & 0x80 ? PREF_DOS_ACT : PREF_DOS;
+			break;
+
+		default:
+		        pref = PREF_NONE;
+		}
+		if (pref < preflevel) {
+			preflevel = pref;
+			prefslice = i + 1;
+		}
+	}
+	return (prefslice);
+}
+
+static int
+disk_openmbr(struct disk_devdesc *dev)
+{
+	struct dos_partition	*slicetab = NULL, *dptr;
+	int			nslices, sector, slice;
+	int			rc;
+	uint8_t			buf[DISK_SECSIZE];
+	struct disklabel	*lp;
+
+	/*
+	 * Following calculations attempt to determine the correct value
+	 * for dev->d_offset by looking for the slice and partition specified,
+	 * or searching for reasonable defaults.
+	 */
+	rc = disk_readslicetab(dev, &slicetab, &nslices);
+	if (rc)
+		return (rc);
+
+	/*
+	 * if a slice number was supplied but not found, this is an error.
+	 */
+	if (dev->d_slice > 0) {
+		slice = dev->d_slice - 1;
+		if (slice >= nslices) {
+			DEBUG("slice %d not found", slice);
+			rc = EPART;
+			goto out;
+		}
+	}
+
+	/*
+	 * Check for the historically bogus MBR found on true dedicated disks
+	 */
+	if (slicetab[3].dp_typ == DOSPTYP_386BSD &&
+	    slicetab[3].dp_start == 0 && slicetab[3].dp_size == 50000) {
+		sector = 0;
+		goto unsliced;
+	}
+
+	/*
+	 * Try to auto-detect the best slice; this should always give
+	 * a slice number
+	 */

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



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