svn commit: r212559 - head/sys/powerpc/powerpc

2010-09-13 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Sep 13 15:36:42 2010
New Revision: 212559
URL: http://svn.freebsd.org/changeset/base/212559

Log:
  Fix a subtle bug uncovered by the recent one-shot timer import in which
  any spin locks acquired between the enabling of interrupts in
  machdep_ap_bootstrap() and the invocation of the scheduler would fail to
  have interrupts disabled due to the fake spinlock already held by the
  idle thread. sched_throw(NULL) will enable interrupts by itself when
  exiting this spinlock, so just let it do that and don't enable interrupts
  here.

Modified:
  head/sys/powerpc/powerpc/mp_machdep.c

Modified: head/sys/powerpc/powerpc/mp_machdep.c
==
--- head/sys/powerpc/powerpc/mp_machdep.c   Mon Sep 13 15:30:09 2010
(r212558)
+++ head/sys/powerpc/powerpc/mp_machdep.c   Mon Sep 13 15:36:42 2010
(r212559)
@@ -94,9 +94,6 @@ machdep_ap_bootstrap(void)
/* Start per-CPU event timers. */
cpu_initclocks_ap();
 
-   /* Let the DEC and external interrupts go */
-   mtmsr(mfmsr() | PSL_EE);
-
/* Announce ourselves awake, and enter the scheduler */
sched_throw(NULL);
 }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r212572 - in head/sys: dev/cxgb kern sys vm

2010-09-13 Thread Nathan Whitehorn
On Mon, 13 Sep 2010 15:18:38 -0400
John Baldwin  wrote:

> On Monday, September 13, 2010 2:48:23 pm Matthew D Fleming wrote:
> > Author: mdf
> > Date: Mon Sep 13 18:48:23 2010
> > New Revision: 212572
> > URL: http://svn.freebsd.org/changeset/base/212572
> > 
> > Log:
> >   Revert r212370, as it causes a LOR on powerpc.  powerpc does a few
> >   unexpected things in copyout(9) and so wiring the user buffer is
> > not sufficient to perform a copyout(9) while holding a random mutex.
> >   
> >   Requested by: nwhitehorn
> 
> Hmmm, that is going to break several other sysctls as well then.
> Many sysctls use sysctl_wire_old_buffer() explicitly so that they can
> then call SYSCTL_OUT() without dropping a lock.  The pcblist sysctls
> do this for example I think.  In general code in the kernel assumes
> that copyout(9) to/from a wired buffer is safe while holding mutexes
> or rwlocks.
> 

Yes. The issue here is that powerpc64 copyin/out() needs to acquire
the PMAP lock, so holding normal mutexes is fine, but calling
into copyout() with non-sleepable locks like this code did is
not. Matthew and I are working on a better solution that fixes this on
the powerpc copyout() side, but it is tricky for a variety of reasons
and will take a little while. In the meantime, this keeps powerpc64
systems bootable.
-Nathan
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r212586 - head/sys/powerpc/powerpc

2010-09-13 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Sep 13 22:50:05 2010
New Revision: 212586
URL: http://svn.freebsd.org/changeset/base/212586

Log:
  Fix a missing set of parantheses that could cause recent versions of libthr
  to crash deferencing a NULL pointer to the user context on powerpc64
  systems with COMPAT_FREEBSD32 defined.

Modified:
  head/sys/powerpc/powerpc/exec_machdep.c

Modified: head/sys/powerpc/powerpc/exec_machdep.c
==
--- head/sys/powerpc/powerpc/exec_machdep.c Mon Sep 13 22:40:10 2010
(r212585)
+++ head/sys/powerpc/powerpc/exec_machdep.c Mon Sep 13 22:50:05 2010
(r212586)
@@ -251,9 +251,9 @@ sendsig(sig_t catcher, ksiginfo_t *ksi, 
tf->fixreg[FIRSTARG] = sig;
#ifdef COMPAT_FREEBSD32
tf->fixreg[FIRSTARG+2] = (register_t)usfp +
-   (p->p_sysent->sv_flags & SV_ILP32) ?
+   ((p->p_sysent->sv_flags & SV_ILP32) ?
offsetof(struct sigframe32, sf_uc) :
-   offsetof(struct sigframe, sf_uc);
+   offsetof(struct sigframe, sf_uc));
#else
tf->fixreg[FIRSTARG+2] = (register_t)usfp +
offsetof(struct sigframe, sf_uc);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r212658 - stable/8/sys/powerpc/aim

2010-09-15 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Wed Sep 15 13:43:43 2010
New Revision: 212658
URL: http://svn.freebsd.org/changeset/base/212658

Log:
  MFC r211967,212044,212278,212322,212331:
  
  Fix a variety of race conditions and errors in VSID allocation in both
  the 32 and 64-bit PMAP modules, some dating back to the original PMAP
  import from NetBSD. This fixes a variety of potential crashes and memory
  corruption bugs, especially on SMP systems under heavy load.

Modified:
  stable/8/sys/powerpc/aim/mmu_oea.c
  stable/8/sys/powerpc/aim/mmu_oea64.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/powerpc/aim/mmu_oea.c
==
--- stable/8/sys/powerpc/aim/mmu_oea.c  Wed Sep 15 11:05:41 2010
(r212657)
+++ stable/8/sys/powerpc/aim/mmu_oea.c  Wed Sep 15 13:43:43 2010
(r212658)
@@ -203,6 +203,7 @@ extern struct pmap ofw_pmap;
  * Lock for the pteg and pvo tables.
  */
 struct mtx moea_table_mutex;
+struct mtx moea_vsid_mutex;
 
 /* tlbie instruction synchronization */
 static struct mtx tlbie_mtx;
@@ -817,6 +818,7 @@ moea_bootstrap(mmu_t mmup, vm_offset_t k
 */
mtx_init(&moea_table_mutex, "pmap table", NULL, MTX_DEF |
MTX_RECURSE);
+   mtx_init(&moea_vsid_mutex, "VSID table", NULL, MTX_DEF);
 
mtx_init(&tlbie_mtx, "tlbie", NULL, MTX_SPIN);
 
@@ -1535,6 +1537,7 @@ moea_pinit(mmu_t mmu, pmap_t pmap)
}

 
+   mtx_lock(&moea_vsid_mutex);
/*
 * Allocate some segment registers for this pmap.
 */
@@ -1561,7 +1564,7 @@ moea_pinit(mmu_t mmu, pmap_t pmap)
entropy = (moea_vsidcontext >> 20);
continue;
}
-   i = ffs(~moea_vsid_bitmap[i]) - 1;
+   i = ffs(~moea_vsid_bitmap[n]) - 1;
mask = 1 << i;
hash &= 0xf & ~(VSID_NBPW - 1);
hash |= i;
@@ -1569,9 +1572,11 @@ moea_pinit(mmu_t mmu, pmap_t pmap)
moea_vsid_bitmap[n] |= mask;
for (i = 0; i < 16; i++)
pmap->pm_sr[i] = VSID_MAKE(i, hash);
+   mtx_unlock(&moea_vsid_mutex);
return;
}
 
+   mtx_unlock(&moea_vsid_mutex);
panic("moea_pinit: out of segments");
 }
 
@@ -1683,10 +1688,12 @@ moea_release(mmu_t mmu, pmap_t pmap)
 if (pmap->pm_sr[0] == 0)
 panic("moea_release");
 
+   mtx_lock(&moea_vsid_mutex);
 idx = VSID_TO_HASH(pmap->pm_sr[0]) & (NPMAPS-1);
 mask = 1 << (idx % VSID_NBPW);
 idx /= VSID_NBPW;
 moea_vsid_bitmap[idx] &= ~mask;
+   mtx_unlock(&moea_vsid_mutex);
PMAP_LOCK_DESTROY(pmap);
 }
 

Modified: stable/8/sys/powerpc/aim/mmu_oea64.c
==
--- stable/8/sys/powerpc/aim/mmu_oea64.cWed Sep 15 11:05:41 2010
(r212657)
+++ stable/8/sys/powerpc/aim/mmu_oea64.cWed Sep 15 13:43:43 2010
(r212658)
@@ -277,6 +277,7 @@ extern void bs_remap_earlyboot(void);
  * Lock for the pteg and pvo tables.
  */
 struct mtx moea64_table_mutex;
+struct mtx moea64_slb_mutex;
 
 /*
  * PTEG data.
@@ -841,6 +842,7 @@ moea64_bridge_bootstrap(mmu_t mmup, vm_o
 */
mtx_init(&moea64_table_mutex, "pmap table", NULL, MTX_DEF |
MTX_RECURSE);
+   mtx_init(&moea64_slb_mutex, "SLB table", NULL, MTX_DEF);
 
/*
 * Initialize the TLBIE lock. TLBIE can only be executed by one CPU.
@@ -1721,6 +1723,7 @@ moea64_pinit(mmu_t mmu, pmap_t pmap)
/*
 * Allocate some segment registers for this pmap.
 */
+   mtx_lock(&moea64_slb_mutex);
for (i = 0; i < NPMAPS; i += VSID_NBPW) {
u_int   hash, n;
 
@@ -1744,19 +1747,24 @@ moea64_pinit(mmu_t mmu, pmap_t pmap)
entropy = (moea64_vsidcontext >> 20);
continue;
}
-   i = ffs(~moea64_vsid_bitmap[i]) - 1;
+   i = ffs(~moea64_vsid_bitmap[n]) - 1;
mask = 1 << i;
hash &= 0xf & ~(VSID_NBPW - 1);
hash |= i;
}
+   KASSERT(!(moea64_vsid_bitmap[n] & mask),
+   ("Allocating in-use VSID %#zx\n", hash));
moea64_vsid_bitmap[n] |= mask;
+   mtx_unlock(&moea64_slb_mutex);
+
for (i = 0; i < 16; i++) {
pmap->pm_sr[i] = VSID_MAKE(i, hash);
}

svn commit: r212659 - stable/8/sys/powerpc/aim

2010-09-15 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Wed Sep 15 13:45:06 2010
New Revision: 212659
URL: http://svn.freebsd.org/changeset/base/212659

Log:
  MFC r212363:
  
  Reorder statistics tracking and table lock acquisitions already in place
  to avoid race conditions updating the PVO statistics.

Modified:
  stable/8/sys/powerpc/aim/mmu_oea64.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/powerpc/aim/mmu_oea64.c
==
--- stable/8/sys/powerpc/aim/mmu_oea64.cWed Sep 15 13:43:43 2010
(r212658)
+++ stable/8/sys/powerpc/aim/mmu_oea64.cWed Sep 15 13:45:06 2010
(r212659)
@@ -2028,7 +2028,6 @@ moea64_pvo_enter(pmap_t pm, uma_zone_t z
 * the bootstrap pool.
 */
 
-   moea64_pvo_enter_calls++;
first = 0;
bootstrap = (flags & PVO_BOOTSTRAP);
 
@@ -2048,6 +2047,8 @@ moea64_pvo_enter(pmap_t pm, uma_zone_t z
 */
LOCK_TABLE();
 
+   moea64_pvo_enter_calls++;
+
LIST_FOREACH(pvo, &moea64_pvo_table[ptegidx], pvo_olink) {
if (pvo->pvo_pmap == pm && PVO_VADDR(pvo) == va) {
if ((pvo->pvo_pte.lpte.pte_lo & LPTE_RPGN) == pa &&
@@ -2190,14 +2191,15 @@ moea64_pvo_remove(struct pvo_entry *pvo,
 * if we aren't going to reuse it.
 */
LIST_REMOVE(pvo, pvo_olink);
+
+   moea64_pvo_entries--;
+   moea64_pvo_remove_calls++;
+
UNLOCK_TABLE();
 
if (!(pvo->pvo_vaddr & PVO_BOOTSTRAP))
uma_zfree((pvo->pvo_vaddr & PVO_MANAGED) ? moea64_mpvo_zone :
moea64_upvo_zone, pvo);
-
-   moea64_pvo_entries--;
-   moea64_pvo_remove_calls++;
 }
 
 static __inline int
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r212715 - in head/sys/powerpc: aim include

2010-09-15 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Thu Sep 16 00:22:25 2010
New Revision: 212715
URL: http://svn.freebsd.org/changeset/base/212715

Log:
  Replace the SLB backing store splay tree used on 64-bit PowerPC AIM
  hardware with a lockless sparse tree design. This marginally improves
  the performance of PMAP and allows copyin()/copyout() to run without
  acquiring locks when used on wired mappings.
  
  Submitted by: mdf

Modified:
  head/sys/powerpc/aim/copyinout.c
  head/sys/powerpc/aim/mmu_oea64.c
  head/sys/powerpc/aim/slb.c
  head/sys/powerpc/aim/trap.c
  head/sys/powerpc/include/pcb.h
  head/sys/powerpc/include/pmap.h

Modified: head/sys/powerpc/aim/copyinout.c
==
--- head/sys/powerpc/aim/copyinout.cWed Sep 15 23:56:25 2010
(r212714)
+++ head/sys/powerpc/aim/copyinout.cThu Sep 16 00:22:25 2010
(r212715)
@@ -80,16 +80,28 @@ int setfault(faultbuf); /* defined in lo
 static __inline void
 set_user_sr(pmap_t pm, const void *addr)
 {
+   struct slb *slb;
register_t esid, vsid, slb1, slb2;
 
esid = USER_ADDR >> ADDR_SR_SHFT;
-   PMAP_LOCK(pm);
-   vsid = va_to_vsid(pm, (vm_offset_t)addr);
-   PMAP_UNLOCK(pm);
+
+   /* Try lockless look-up first */
+   slb = user_va_to_slb_entry(pm, (vm_offset_t)addr);
+
+   if (slb == NULL) {
+   /* If it isn't there, we need to pre-fault the VSID */
+   PMAP_LOCK(pm);
+   vsid = va_to_vsid(pm, (vm_offset_t)addr);
+   PMAP_UNLOCK(pm);
+   } else {
+   vsid = slb->slbv >> SLBV_VSID_SHIFT;
+   }
 
slb1 = vsid << SLBV_VSID_SHIFT;
slb2 = (esid << SLBE_ESID_SHIFT) | SLBE_VALID | USER_SR;
 
+   curthread->td_pcb->pcb_cpu.aim.usr_segm =
+   (uintptr_t)addr >> ADDR_SR_SHFT;
__asm __volatile ("slbie %0; slbmte %1, %2" :: "r"(esid << 28),
"r"(slb1), "r"(slb2));
isync();

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cWed Sep 15 23:56:25 2010
(r212714)
+++ head/sys/powerpc/aim/mmu_oea64.cThu Sep 16 00:22:25 2010
(r212715)
@@ -2097,7 +2097,7 @@ moea64_pinit(mmu_t mmu, pmap_t pmap)
 {
PMAP_LOCK_INIT(pmap);
 
-   SPLAY_INIT(&pmap->pm_slbtree);
+   pmap->pm_slb_tree_root = slb_alloc_tree();
pmap->pm_slb = slb_alloc_user_cache();
 }
 #else
@@ -2252,7 +2252,7 @@ moea64_release(mmu_t mmu, pmap_t pmap)
 * Free segment registers' VSIDs
 */
 #ifdef __powerpc64__
-   free_vsids(pmap);
+   slb_free_tree(pmap);
slb_free_user_cache(pmap->pm_slb);
 #else
KASSERT(pmap->pm_sr[0] != 0, ("moea64_release: pm_sr[0] = 0"));
@@ -2622,18 +2622,25 @@ moea64_pvo_find_va(pmap_t pm, vm_offset_
int ptegidx;
uint64_tvsid;
#ifdef __powerpc64__
-   struct slb  slb;
+   uint64_tslbv;
 
-   /* The page is not mapped if the segment isn't */
-   if (va_to_slb_entry(pm, va, &slb) != 0)
-   return NULL;
+   if (pm == kernel_pmap) {
+   slbv = kernel_va_to_slbv(va);
+   } else {
+   struct slb *slb;
+   slb = user_va_to_slb_entry(pm, va);
+   /* The page is not mapped if the segment isn't */
+   if (slb == NULL)
+   return NULL;
+   slbv = slb->slbv;
+   }
 
-   vsid = (slb.slbv & SLBV_VSID_MASK) >> SLBV_VSID_SHIFT;
-   if (slb.slbv & SLBV_L)
+   vsid = (slbv & SLBV_VSID_MASK) >> SLBV_VSID_SHIFT;
+   if (slbv & SLBV_L)
va &= ~moea64_large_page_mask;
else
va &= ~ADDR_POFF;
-   ptegidx = va_to_pteg(vsid, va, slb.slbv & SLBV_L);
+   ptegidx = va_to_pteg(vsid, va, slbv & SLBV_L);
#else
va &= ~ADDR_POFF;
vsid = va_to_vsid(pm, va);

Modified: head/sys/powerpc/aim/slb.c
==
--- head/sys/powerpc/aim/slb.c  Wed Sep 15 23:56:25 2010(r212714)
+++ head/sys/powerpc/aim/slb.c  Thu Sep 16 00:22:25 2010(r212715)
@@ -32,7 +32,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
@@ -45,65 +44,212 @@
 
 uintptr_t moea64_get_unique_vsid(void);
 void moea64_release_vsid(uint64_t vsid);
+static void slb_zone_init(void *);
+
+uma_zone_t slbt_zone;
+uma_zone_t slb_cache_zone;
 
-struct slbcontainer {
-   struct slb slb;
-   SPLAY_ENTRY(slbcontainer) slb_node;
+SYSINIT(slb_zone_init, SI_SUB_KMEM, SI_ORDER_ANY, slb_zone_init, NULL);
+
+struct slbtnode {
+   uint16_tua_alloc;
+   uint8_t ua_level;
+   /* Only 36 bits needed for full 64-bit address space. */
+   uint64_tua_base;
+   union {
+   struct slbtnode *ua_child[16];
+   struct slb 

svn commit: r212722 - in head/sys/powerpc: aim include

2010-09-15 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Thu Sep 16 03:46:17 2010
New Revision: 212722
URL: http://svn.freebsd.org/changeset/base/212722

Log:
  Split the SLB mirror cache into two kinds of object, one for kernel maps
  which are similar to the previous ones, and one for user maps, which
  are arrays of pointers into the SLB tree. This changes makes user SLB
  updates atomic, closing a window for memory corruption. While here,
  rearrange the allocation functions to make context switches faster.

Modified:
  head/sys/powerpc/aim/mmu_oea64.c
  head/sys/powerpc/aim/slb.c
  head/sys/powerpc/aim/trap.c
  head/sys/powerpc/aim/trap_subr64.S
  head/sys/powerpc/include/pcpu.h
  head/sys/powerpc/include/pmap.h
  head/sys/powerpc/include/sr.h

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cThu Sep 16 02:59:25 2010
(r212721)
+++ head/sys/powerpc/aim/mmu_oea64.cThu Sep 16 03:46:17 2010
(r212722)
@@ -838,7 +838,7 @@ moea64_bootstrap_slb_prefault(vm_offset_
if (large)
entry.slbv |= SLBV_L;
 
-   slb_insert(kernel_pmap, cache, &entry);
+   slb_insert_kernel(entry.slbe, entry.slbv);
 }
 #endif
 
@@ -2099,6 +2099,7 @@ moea64_pinit(mmu_t mmu, pmap_t pmap)
 
pmap->pm_slb_tree_root = slb_alloc_tree();
pmap->pm_slb = slb_alloc_user_cache();
+   pmap->pm_slb_len = 0;
 }
 #else
 void

Modified: head/sys/powerpc/aim/slb.c
==
--- head/sys/powerpc/aim/slb.c  Thu Sep 16 02:59:25 2010(r212721)
+++ head/sys/powerpc/aim/slb.c  Thu Sep 16 03:46:17 2010(r212722)
@@ -263,13 +263,14 @@ va_to_vsid(pmap_t pm, vm_offset_t va)
entry = user_va_to_slb_entry(pm, va);
 
if (entry == NULL)
-   return (allocate_vsid(pm, (uintptr_t)va >> ADDR_SR_SHFT, 0));
+   return (allocate_user_vsid(pm,
+   (uintptr_t)va >> ADDR_SR_SHFT, 0));
 
return ((entry->slbv & SLBV_VSID_MASK) >> SLBV_VSID_SHIFT);
 }
 
 uint64_t
-allocate_vsid(pmap_t pm, uint64_t esid, int large)
+allocate_user_vsid(pmap_t pm, uint64_t esid, int large)
 {
uint64_t vsid, slbv;
struct slbtnode *ua, *next, *inter;
@@ -327,7 +328,7 @@ allocate_vsid(pmap_t pm, uint64_t esid, 
 * SLB mapping, so pre-spill this entry.
 */
eieio();
-   slb_insert(pm, pm->pm_slb, slb);
+   slb_insert_user(pm, slb);
 
return (vsid);
 }
@@ -410,57 +411,68 @@ slb_alloc_tree(void)
(slbe & SLBE_ESID_MASK) > 16*SEGMENT_LENGTH) || \
(slbe & SLBE_ESID_MASK) > VM_MAX_KERNEL_ADDRESS)
 void
-slb_insert(pmap_t pm, struct slb *slbcache, struct slb *slb_entry)
+slb_insert_kernel(uint64_t slbe, uint64_t slbv)
 {
-   uint64_t slbe, slbv;
-   int i, j, to_spill;
+   struct slb *slbcache;
+   int i, j;
 
/* We don't want to be preempted while modifying the kernel map */
critical_enter();
 
-   to_spill = -1;
-   slbv = slb_entry->slbv;
-   slbe = slb_entry->slbe;
+   slbcache = PCPU_GET(slb);
 
-   /* Hunt for a likely candidate */
+   /* Check for an unused slot, abusing the USER_SR slot as a full flag */
+   if (slbcache[USER_SR].slbe == 0) {
+   for (i = 0; i < USER_SR; i++) {
+   if (!(slbcache[i].slbe & SLBE_VALID)) 
+   goto fillkernslb;
+   }
+
+   if (i == USER_SR)
+   slbcache[USER_SR].slbe = 1;
+   }
 
for (i = mftb() % 64, j = 0; j < 64; j++, i = (i+1) % 64) {
-   if (pm == kernel_pmap && i == USER_SR)
-   continue;
+   if (i == USER_SR)
+   continue;
 
-   if (!(slbcache[i].slbe & SLBE_VALID)) {
-   to_spill = i;
+   if (SLB_SPILLABLE(slbcache[i].slbe))
break;
-   }
-
-   if (to_spill < 0 && (pm != kernel_pmap ||
-   SLB_SPILLABLE(slbcache[i].slbe)))
-   to_spill = i;
-   }
-
-   if (to_spill < 0)
-   panic("SLB spill on ESID %#lx, but no available candidates!\n",
-  (slbe & SLBE_ESID_MASK) >> SLBE_ESID_SHIFT);
-
-   if (slbcache[to_spill].slbe & SLBE_VALID) {
-   /* Invalidate this first to avoid races */
-   slbcache[to_spill].slbe = 0;
-   mb();
}
-   slbcache[to_spill].slbv = slbv;
-   slbcache[to_spill].slbe = slbe | (uint64_t)to_spill;
+
+   KASSERT(j < 64, ("All kernel SLB slots locked!"));
+
+fillkernslb:
+   slbcache[i].slbv = slbv;
+   slbcache[i].slbe = slbe | (uint64_t)i;
 
/* If it is for this CPU, put it in the SLB right away */
-   if (pm == kernel_pmap && pmap_bootstrapped) {
+   if (pmap_bootstrapped) {

Re: svn commit: r213098 - in head/sys: amd64/conf i386/conf pc98/conf powerpc/conf sparc64/conf

2010-09-25 Thread Nathan Whitehorn
On 09/24/10 11:04, David Xu wrote:
> Author: davidxu
> Date: Fri Sep 24 09:04:16 2010
> New Revision: 213098
> URL: http://svn.freebsd.org/changeset/base/213098
> 
> Log:
>   Now userland POSIX semaphore is based on umtx. The kernel module
>   is only used to support binary compatible, if want to run old
>   binary, you need to kldload the module.
> 
> Modified:
>   head/sys/amd64/conf/GENERIC
>   head/sys/i386/conf/GENERIC
>   head/sys/pc98/conf/GENERIC
>   head/sys/powerpc/conf/GENERIC
>   head/sys/sparc64/conf/GENERIC
> 

You missed the powerpc64 GENERIC, which is named
/sys/powerpc/conf/GENERIC64. It looks like you skipped sun4v too.
-Nathan
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r213185 - head/contrib/gcc/config/rs6000

2010-09-26 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Sep 26 14:20:09 2010
New Revision: 213185
URL: http://svn.freebsd.org/changeset/base/213185

Log:
  Check for NULL link registers as found in initial stack frames when doing
  stack unwinding, instead of naively trying to check the instruction at
  that location. This fixes signal handling in threaded applications after
  recent changes regarding unwinding in libthr. While here, clean up our
  MD_FROB_UPDATE_CONTEXT() implementation a little.

Modified:
  head/contrib/gcc/config/rs6000/freebsd.h

Modified: head/contrib/gcc/config/rs6000/freebsd.h
==
--- head/contrib/gcc/config/rs6000/freebsd.hSun Sep 26 12:52:23 2010
(r213184)
+++ head/contrib/gcc/config/rs6000/freebsd.hSun Sep 26 14:20:09 2010
(r213185)
@@ -219,17 +219,16 @@
   | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4))\
: DW_EH_PE_absptr)
 
+#ifdef __powerpc64__
 #define MD_FROB_UPDATE_CONTEXT(CTX, FS)
\
-  if (TARGET_64BIT) {  \
 if ((FS)->regs.reg[2].how == REG_UNSAVED)  \
   {
\
-   unsigned int *insn  \
- = (unsigned int *)\
+   unsigned int *insn = (unsigned int *)   \
_Unwind_GetGR ((CTX), LINK_REGISTER_REGNUM);\
-   if (*insn == 0xE8410028)\
+   if (insn != NULL && *insn == 0xE8410028)\
  _Unwind_SetGRPtr ((CTX), 2, (CTX)->cfa + 40); \
-  }
\
-  }
+  }
+#endif
 
 /* FreeBSD doesn't support saving and restoring 64-bit regs with a 32-bit
kernel. This is supported when running on a 64-bit kernel with
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r213291 - in stable/8/sys/dev/ata: . chipsets

2010-09-29 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Thu Sep 30 04:03:14 2010
New Revision: 213291
URL: http://svn.freebsd.org/changeset/base/213291

Log:
  MFC r212359:
  
  Fix a problem where device detection would work unreliably on Serverworks
  K2 SATA controllers. The chip's status register must be read first, and
  as a long, for other registers to be correctly updated after a command, and
  this includes the command sequence in device detection as well as the
  previously handled case after interrupts. While here, clean up some
  previous hacks related to this controller.

Modified:
  stable/8/sys/dev/ata/ata-all.h
  stable/8/sys/dev/ata/ata-lowlevel.c
  stable/8/sys/dev/ata/chipsets/ata-serverworks.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/ata/ata-all.h
==
--- stable/8/sys/dev/ata/ata-all.h  Thu Sep 30 03:16:35 2010
(r213290)
+++ stable/8/sys/dev/ata/ata-all.h  Thu Sep 30 04:03:14 2010
(r213291)
@@ -566,6 +566,7 @@ struct ata_channel {
 #define ATA_SATA   0x80
 #define ATA_DMA_BEFORE_CMD 0x100
 #define ATA_KNOWN_PRESENCE 0x200
+#define ATA_STATUS_IS_LONG 0x400
 
 intpm_level;   /* power management 
level */
 int devices;/* what is present */

Modified: stable/8/sys/dev/ata/ata-lowlevel.c
==
--- stable/8/sys/dev/ata/ata-lowlevel.c Thu Sep 30 03:16:35 2010
(r213290)
+++ stable/8/sys/dev/ata/ata-lowlevel.c Thu Sep 30 04:03:14 2010
(r213291)
@@ -516,10 +516,13 @@ ata_generic_reset(device_t dev)
if ((mask & 0x01) && (stat0 & ATA_S_BUSY)) {
ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_DEV(ATA_MASTER));
DELAY(10);
+   if (ch->flags & ATA_STATUS_IS_LONG)
+   stat0 = ATA_IDX_INL(ch, ATA_STATUS) & 0xff;
+   else
+   stat0 = ATA_IDX_INB(ch, ATA_STATUS);
err = ATA_IDX_INB(ch, ATA_ERROR);
lsb = ATA_IDX_INB(ch, ATA_CYL_LSB);
msb = ATA_IDX_INB(ch, ATA_CYL_MSB);
-   stat0 = ATA_IDX_INB(ch, ATA_STATUS);
if (bootverbose)
device_printf(dev,
  "stat0=0x%02x err=0x%02x lsb=0x%02x msb=0x%02x\n",
@@ -546,10 +549,13 @@ ata_generic_reset(device_t dev)
!((mask & 0x01) && (stat0 & ATA_S_BUSY))) {
ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_DEV(ATA_SLAVE));
DELAY(10);
+   if (ch->flags & ATA_STATUS_IS_LONG)
+   stat1 = ATA_IDX_INL(ch, ATA_STATUS) & 0xff;
+   else
+   stat1 = ATA_IDX_INB(ch, ATA_STATUS);
err = ATA_IDX_INB(ch, ATA_ERROR);
lsb = ATA_IDX_INB(ch, ATA_CYL_LSB);
msb = ATA_IDX_INB(ch, ATA_CYL_MSB);
-   stat1 = ATA_IDX_INB(ch, ATA_STATUS);
if (bootverbose)
device_printf(dev,
  "stat1=0x%02x err=0x%02x lsb=0x%02x msb=0x%02x\n",

Modified: stable/8/sys/dev/ata/chipsets/ata-serverworks.c
==
--- stable/8/sys/dev/ata/chipsets/ata-serverworks.c Thu Sep 30 03:16:35 
2010(r213290)
+++ stable/8/sys/dev/ata/chipsets/ata-serverworks.c Thu Sep 30 04:03:14 
2010(r213291)
@@ -61,9 +61,8 @@ static int ata_serverworks_ch_detach(dev
 static void ata_serverworks_tf_read(struct ata_request *request);
 static void ata_serverworks_tf_write(struct ata_request *request);
 static int ata_serverworks_setmode(device_t dev, int target, int mode);
-#ifdef __powerpc__
+static void ata_serverworks_sata_reset(device_t dev);
 static int ata_serverworks_status(device_t dev);
-#endif
 
 /* misc defines */
 #define SWKS_330
@@ -104,7 +103,6 @@ ata_serverworks_probe(device_t dev)
 return (BUS_PROBE_DEFAULT);
 }
 
-#ifdef __powerpc__
 static int
 ata_serverworks_status(device_t dev)
 {
@@ -126,7 +124,6 @@ ata_serverworks_status(device_t dev)
 
 return ata_pci_status(dev);
 }
-#endif
 
 static int
 ata_serverworks_chipinit(device_t dev)
@@ -148,6 +145,7 @@ ata_serverworks_chipinit(device_t dev)
ctlr->ch_detach = ata_serverworks_ch_detach;
ctlr->setmode = ata_sata_setmode;
ctlr->getrev = ata_sata_getrev;
+   ctlr->reset = ata_serverworks_sata_reset;
return 0;
 }
 else if (ctlr->chip->cfg1 == SWKS_33) {
@@ -213,14 +211,11 @@ ata_serverworks_ch_attach(device_t dev)
 ch->r_io[ATA_SERROR].offset = ch_offset + 0x44;
 ch->r_io[ATA_SCONTROL].offs

svn commit: r213292 - stable/8/sys/boot/ofw/libofw

2010-09-29 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Thu Sep 30 04:06:16 2010
New Revision: 213292
URL: http://svn.freebsd.org/changeset/base/213292

Log:
  MFC r212165:
  
  In the case of non-sequential mappings, ofw_mapmem() could ask Open
  Firmware to map a memory region with negative length, causing crashes
  and Undefined Behavior. Add the appropriate check to make the behavior
  defined.

Modified:
  stable/8/sys/boot/ofw/libofw/ofw_copy.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/boot/ofw/libofw/ofw_copy.c
==
--- stable/8/sys/boot/ofw/libofw/ofw_copy.c Thu Sep 30 04:03:14 2010
(r213291)
+++ stable/8/sys/boot/ofw/libofw/ofw_copy.c Thu Sep 30 04:06:16 2010
(r213292)
@@ -68,7 +68,7 @@ ofw_mapmem(vm_offset_t dest, const size_
/*
 * Trim area covered by existing mapping, if any
 */
-   if (dest < (last_dest + last_len)) {
+   if (dest < (last_dest + last_len) && dest >= last_dest) {
nlen -= (last_dest + last_len) - dest;
dest = last_dest + last_len;
}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r213307 - in head/sys/powerpc: aim include powerpc

2010-09-30 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Thu Sep 30 18:14:12 2010
New Revision: 213307
URL: http://svn.freebsd.org/changeset/base/213307

Log:
  Add support for memory attributes (pmap_mapdev_attr() and friends) on
  PowerPC/AIM. This is currently stubbed out on Book-E, since I have no
  idea how to implement it there.

Modified:
  head/sys/powerpc/aim/mmu_oea.c
  head/sys/powerpc/aim/mmu_oea64.c
  head/sys/powerpc/include/pmap.h
  head/sys/powerpc/include/vm.h
  head/sys/powerpc/powerpc/bus_machdep.c
  head/sys/powerpc/powerpc/mmu_if.m
  head/sys/powerpc/powerpc/pmap_dispatch.c

Modified: head/sys/powerpc/aim/mmu_oea.c
==
--- head/sys/powerpc/aim/mmu_oea.c  Thu Sep 30 17:37:08 2010
(r213306)
+++ head/sys/powerpc/aim/mmu_oea.c  Thu Sep 30 18:14:12 2010
(r213307)
@@ -328,9 +328,12 @@ void moea_deactivate(mmu_t, struct threa
 void moea_cpu_bootstrap(mmu_t, int);
 void moea_bootstrap(mmu_t, vm_offset_t, vm_offset_t);
 void *moea_mapdev(mmu_t, vm_offset_t, vm_size_t);
+void *moea_mapdev_attr(mmu_t, vm_offset_t, vm_size_t, vm_memattr_t);
 void moea_unmapdev(mmu_t, vm_offset_t, vm_size_t);
 vm_offset_t moea_kextract(mmu_t, vm_offset_t);
+void moea_kenter_attr(mmu_t, vm_offset_t, vm_offset_t, vm_memattr_t);
 void moea_kenter(mmu_t, vm_offset_t, vm_offset_t);
+void moea_page_set_memattr(mmu_t mmu, vm_page_t m, vm_memattr_t ma);
 boolean_t moea_dev_direct_mapped(mmu_t, vm_offset_t, vm_size_t);
 static void moea_sync_icache(mmu_t, pmap_t, vm_offset_t, vm_size_t);
 
@@ -366,14 +369,17 @@ static mmu_method_t moea_methods[] = {
MMUMETHOD(mmu_zero_page_idle,   moea_zero_page_idle),
MMUMETHOD(mmu_activate, moea_activate),
MMUMETHOD(mmu_deactivate,   moea_deactivate),
+   MMUMETHOD(mmu_page_set_memattr, moea_page_set_memattr),
 
/* Internal interfaces */
MMUMETHOD(mmu_bootstrap,moea_bootstrap),
MMUMETHOD(mmu_cpu_bootstrap,moea_cpu_bootstrap),
+   MMUMETHOD(mmu_mapdev_attr,  moea_mapdev_attr),
MMUMETHOD(mmu_mapdev,   moea_mapdev),
MMUMETHOD(mmu_unmapdev, moea_unmapdev),
MMUMETHOD(mmu_kextract, moea_kextract),
MMUMETHOD(mmu_kenter,   moea_kenter),
+   MMUMETHOD(mmu_kenter_attr,  moea_kenter_attr),
MMUMETHOD(mmu_dev_direct_mapped,moea_dev_direct_mapped),
 
{ 0, 0 }
@@ -381,6 +387,40 @@ static mmu_method_t moea_methods[] = {
 
 MMU_DEF(oea_mmu, MMU_TYPE_OEA, moea_methods, 0);
 
+static __inline uint32_t
+moea_calc_wimg(vm_offset_t pa, vm_memattr_t ma)
+{
+   uint32_t pte_lo;
+   int i;
+
+   if (ma != VM_MEMATTR_DEFAULT) {
+   switch (ma) {
+   case VM_MEMATTR_UNCACHEABLE:
+   return (PTE_I | PTE_G);
+   case VM_MEMATTR_WRITE_COMBINING:
+   case VM_MEMATTR_WRITE_BACK:
+   case VM_MEMATTR_PREFETCHABLE:
+   return (PTE_I);
+   case VM_MEMATTR_WRITE_THROUGH:
+   return (PTE_W | PTE_M);
+   }
+   }
+
+   /*
+* Assume the page is cache inhibited and access is guarded unless
+* it's in our available memory array.
+*/
+   pte_lo = PTE_I | PTE_G;
+   for (i = 0; i < pregions_sz; i++) {
+   if ((pa >= pregions[i].mr_start) &&
+   (pa < (pregions[i].mr_start + pregions[i].mr_size))) {
+   pte_lo = PTE_M;
+   break;
+   }
+   }
+
+   return pte_lo;
+}
 
 static void
 tlbie(vm_offset_t va)
@@ -1086,7 +1126,7 @@ moea_enter_locked(pmap_t pmap, vm_offset
struct  pvo_head *pvo_head;
uma_zone_t  zone;
vm_page_t   pg;
-   u_int   pte_lo, pvo_flags, was_exec, i;
+   u_int   pte_lo, pvo_flags, was_exec;
int error;
 
if (!moea_initialized) {
@@ -1128,19 +1168,7 @@ moea_enter_locked(pmap_t pmap, vm_offset
}
}
 
-   /*
-* Assume the page is cache inhibited and access is guarded unless
-* it's in our available memory array.
-*/
-   pte_lo = PTE_I | PTE_G;
-   for (i = 0; i < pregions_sz; i++) {
-   if ((VM_PAGE_TO_PHYS(m) >= pregions[i].mr_start) &&
-   (VM_PAGE_TO_PHYS(m) < 
-   (pregions[i].mr_start + pregions[i].mr_size))) {
-   pte_lo = PTE_M;
-   break;
-   }
-   }
+   pte_lo = moea_calc_wimg(VM_PAGE_TO_PHYS(m), VM_MEMATTR_DEFAULT);
 
if (prot & VM_PROT_WRITE) {
pte_lo |= PTE_BW;
@@ -1416,14 +1444,53 @@ moea_ts_referenced(mmu_t mmu, vm_page_t 
 }
 
 /*
+ * Modify the WIMG settings of all mappings for a page.
+ */
+void
+moea_page_set_memattr(mmu_t mmu, vm_page_t m, vm_memattr_t ma)
+{
+   struct  pvo_entry *pvo;
+   struct  pte 

svn commit: r213335 - head/sys/powerpc/aim

2010-10-01 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Oct  1 18:59:30 2010
New Revision: 213335
URL: http://svn.freebsd.org/changeset/base/213335

Log:
  Fix pmap_page_set_memattr() behavior in the presence of fictitious pages
  by just caching the mode for later use by pmap_enter(), following amd64.
  While here, correct some mismerges from mmu_oea64 -> mmu_oea and clean
  up some dead code found while fixing the fictitious page behavior.

Modified:
  head/sys/powerpc/aim/mmu_oea.c
  head/sys/powerpc/aim/mmu_oea64.c

Modified: head/sys/powerpc/aim/mmu_oea.c
==
--- head/sys/powerpc/aim/mmu_oea.c  Fri Oct  1 17:51:55 2010
(r213334)
+++ head/sys/powerpc/aim/mmu_oea.c  Fri Oct  1 18:59:30 2010
(r213335)
@@ -221,8 +221,6 @@ u_int   moea_pteg_mask;
 struct pvo_head *moea_pvo_table;   /* pvo entries by pteg index */
 struct pvo_head moea_pvo_kunmanaged =
 LIST_HEAD_INITIALIZER(moea_pvo_kunmanaged);/* list of unmanaged 
pages */
-struct pvo_head moea_pvo_unmanaged =
-LIST_HEAD_INITIALIZER(moea_pvo_unmanaged); /* list of unmanaged pages */
 
 uma_zone_t moea_upvo_zone; /* zone for pvo entries for unmanaged pages */
 uma_zone_t moea_mpvo_zone; /* zone for pvo entries for managed pages */
@@ -463,22 +461,6 @@ va_to_pteg(u_int sr, vm_offset_t addr)
 }
 
 static __inline struct pvo_head *
-pa_to_pvoh(vm_offset_t pa, vm_page_t *pg_p)
-{
-   struct  vm_page *pg;
-
-   pg = PHYS_TO_VM_PAGE(pa);
-
-   if (pg_p != NULL)
-   *pg_p = pg;
-
-   if (pg == NULL)
-   return (&moea_pvo_unmanaged);
-
-   return (&pg->md.mdpg_pvoh);
-}
-
-static __inline struct pvo_head *
 vm_page_to_pvoh(vm_page_t m)
 {
 
@@ -919,6 +901,7 @@ moea_bootstrap(mmu_t mmup, vm_offset_t k
struct  vm_page m;
 
m.phys_addr = translations[i].om_pa + off;
+   m.md.mdpg_cache_attrs = VM_MEMATTR_DEFAULT;
m.oflags = VPO_BUSY;
PMAP_LOCK(&ofw_pmap);
moea_enter_locked(&ofw_pmap,
@@ -1168,7 +1151,7 @@ moea_enter_locked(pmap_t pmap, vm_offset
}
}
 
-   pte_lo = moea_calc_wimg(VM_PAGE_TO_PHYS(m), VM_MEMATTR_DEFAULT);
+   pte_lo = moea_calc_wimg(VM_PAGE_TO_PHYS(m), pmap_page_get_memattr(m));
 
if (prot & VM_PROT_WRITE) {
pte_lo |= PTE_BW;
@@ -1450,16 +1433,23 @@ void
 moea_page_set_memattr(mmu_t mmu, vm_page_t m, vm_memattr_t ma)
 {
struct  pvo_entry *pvo;
+   struct  pvo_head *pvo_head;
struct  pte *pt;
pmap_t  pmap;
u_int   lo;
 
+   if (m->flags & PG_FICTITIOUS) {
+   m->md.mdpg_cache_attrs = ma;
+   return;
+   }
+
vm_page_lock_queues();
+   pvo_head = vm_page_to_pvoh(m);
lo = moea_calc_wimg(VM_PAGE_TO_PHYS(m), ma);
-   LIST_FOREACH(pvo, vm_page_to_pvoh(m), pvo_vlink) {
+
+   LIST_FOREACH(pvo, pvo_head, pvo_vlink) {
pmap = pvo->pvo_pmap;
PMAP_LOCK(pmap);
-   mtx_lock(&moea_table_mutex);
pt = moea_pvo_to_pte(pvo, -1);
pvo->pvo_pte.pte.pte_lo &= ~PTE_WIMG;
pvo->pvo_pte.pte.pte_lo |= lo;

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cFri Oct  1 17:51:55 2010
(r213334)
+++ head/sys/powerpc/aim/mmu_oea64.cFri Oct  1 18:59:30 2010
(r213335)
@@ -298,11 +298,8 @@ u_int  moea64_pteg_mask;
  * PVO data.
  */
 struct pvo_head *moea64_pvo_table; /* pvo entries by pteg index */
-/* lists of unmanaged pages */
-struct pvo_head moea64_pvo_kunmanaged =
+struct pvo_head moea64_pvo_kunmanaged =/* list of unmanaged pages */
 LIST_HEAD_INITIALIZER(moea64_pvo_kunmanaged);
-struct pvo_head moea64_pvo_unmanaged =
-LIST_HEAD_INITIALIZER(moea64_pvo_unmanaged);
 
 uma_zone_t moea64_upvo_zone; /* zone for pvo entries for unmanaged pages */
 uma_zone_t moea64_mpvo_zone; /* zone for pvo entries for managed pages */
@@ -495,22 +492,6 @@ va_to_pteg(uint64_t vsid, vm_offset_t ad
 }
 
 static __inline struct pvo_head *
-pa_to_pvoh(vm_offset_t pa, vm_page_t *pg_p)
-{
-   struct  vm_page *pg;
-
-   pg = PHYS_TO_VM_PAGE(pa);
-
-   if (pg_p != NULL)
-   *pg_p = pg;
-
-   if (pg == NULL)
-   return (&moea64_pvo_unmanaged);
-
-   return (&pg->md.mdpg_pvoh);
-}
-
-static __inline struct pvo_head *
 vm_page_to_pvoh(vm_page_t m)
 {
 
@@ -1917,13 +1898,20 @@ void
 moea64_page_set_memattr(mmu_t mmu, vm_page_t m, vm_memattr_t ma)
 {
struct  pvo_entry *pvo;
+   struct  pvo_head *pvo_head;
struct  lpte *pt;
pmap_t  pmap;
uint64_t lo;
 
+   if (m->flags & PG_FICTITIOUS) {
+   m->md.mdpg_cache_att

svn commit: r213336 - head/sys/powerpc/ofw

2010-10-01 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Oct  1 19:02:31 2010
New Revision: 213336
URL: http://svn.freebsd.org/changeset/base/213336

Log:
  Map the Open Firmware framebuffer console with write combining turned on,
  and set memory attributes appropriately for mmap() calls on /dev/console.
  Xorg no longer uses /dev/console to mmap the framebuffer, so framebuffer
  write combining support in X will arrive in the next patch.

Modified:
  head/sys/powerpc/ofw/ofw_syscons.c

Modified: head/sys/powerpc/ofw/ofw_syscons.c
==
--- head/sys/powerpc/ofw/ofw_syscons.c  Fri Oct  1 18:59:30 2010
(r213335)
+++ head/sys/powerpc/ofw/ofw_syscons.c  Fri Oct  1 19:02:31 2010
(r213336)
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -280,7 +281,7 @@ ofwfb_configure(int flags)
OF_getprop(node, "address", &fb_phys, sizeof(fb_phys));
 
bus_space_map(&bs_be_tag, fb_phys, sc->sc_height * sc->sc_stride,
-   0, &sc->sc_addr);
+   BUS_SPACE_MAP_PREFETCHABLE, &sc->sc_addr);
 
/*
 * Get the PCI addresses of the adapter. The node may be the
@@ -632,8 +633,25 @@ ofwfb_mmap(video_adapter_t *adp, vm_ooff
 
sc = (struct ofwfb_softc *)adp;
 
-   if (sc->sc_num_pciaddrs == 0)
-   return (ENOMEM);
+   /*
+* Make sure the requested address lies within the PCI device's
+* assigned addrs
+*/
+   for (i = 0; i < sc->sc_num_pciaddrs; i++)
+ if (offset >= sc->sc_pciaddrs[i].phys_lo &&
+   offset < (sc->sc_pciaddrs[i].phys_lo + sc->sc_pciaddrs[i].size_lo))
+   {
+   /*
+* If this is a prefetchable BAR, we can (and should)
+* enable write-combining.
+*/
+   if (sc->sc_pciaddrs[i].phys_hi &
+   OFW_PCI_PHYS_HI_PREFETCHABLE)
+   *memattr = VM_MEMATTR_WRITE_COMBINING;
+
+   *paddr = offset;
+   return (0);
+   }
 
/*
 * Hack for Radeon...
@@ -644,16 +662,6 @@ ofwfb_mmap(video_adapter_t *adp, vm_ooff
}
 
/*
-* Make sure the requested address lies within the PCI device's 
assigned addrs
-*/
-   for (i = 0; i < sc->sc_num_pciaddrs; i++)
-   if (offset >= sc->sc_pciaddrs[i].phys_lo &&
-   offset < (sc->sc_pciaddrs[i].phys_lo + 
sc->sc_pciaddrs[i].size_lo)) {
-   *paddr = offset;
-   return (0);
-   }
-
-   /*
 * This might be a legacy VGA mem request: if so, just point it at the
 * framebuffer, since it shouldn't be touched
 */
@@ -662,6 +670,12 @@ ofwfb_mmap(video_adapter_t *adp, vm_ooff
return (0);
}
 
+   /*
+* Error if we didn't have a better idea.
+*/
+   if (sc->sc_num_pciaddrs == 0)
+   return (ENOMEM);
+
return (EINVAL);
 }
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r213360 - head/sys/powerpc/powerpc

2010-10-02 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Oct  2 17:19:38 2010
New Revision: 213360
URL: http://svn.freebsd.org/changeset/base/213360

Log:
  Fix some KTR arguments that were breaking the LINT build.
  
  Pointy hat to:me

Modified:
  head/sys/powerpc/powerpc/pmap_dispatch.c

Modified: head/sys/powerpc/powerpc/pmap_dispatch.c
==
--- head/sys/powerpc/powerpc/pmap_dispatch.cSat Oct  2 16:04:50 2010
(r213359)
+++ head/sys/powerpc/powerpc/pmap_dispatch.cSat Oct  2 17:19:38 2010
(r213360)
@@ -437,7 +437,7 @@ void *
 pmap_mapdev_attr(vm_offset_t pa, vm_size_t size, vm_memattr_t attr)
 {
 
-   CTR3(KTR_PMAP, "%s(%#x, %#x)", __func__, pa, size);
+   CTR4(KTR_PMAP, "%s(%#x, %#x, %#x)", __func__, pa, size, attr);
return (MMU_MAPDEV_ATTR(mmu_obj, pa, size, attr));
 }
 
@@ -445,7 +445,7 @@ void
 pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma)
 {
 
-   CTR3(KTR_PMAP, "%s(%#x, %#x)", __func__, pa, size);
+   CTR3(KTR_PMAP, "%s(%p, %#x)", __func__, m, ma);
return (MMU_PAGE_SET_MEMATTR(mmu_obj, m, ma));
 }
 
@@ -477,7 +477,7 @@ void
 pmap_kenter_attr(vm_offset_t va, vm_offset_t pa, vm_memattr_t ma)
 {
 
-   CTR3(KTR_PMAP, "%s(%#x, %#x)", __func__, va, pa);
+   CTR4(KTR_PMAP, "%s(%#x, %#x, %#x)", __func__, va, pa, ma);
MMU_KENTER_ATTR(mmu_obj, va, pa, ma);
 }
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r213383 - in head/sys: conf modules/mem powerpc/include powerpc/powerpc

2010-10-03 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Oct  3 16:02:53 2010
New Revision: 213383
URL: http://svn.freebsd.org/changeset/base/213383

Log:
  Add a memory-range interface to /dev/mem on PowerPC using PAT attributes.
  Unlike actual MTRR, this only controls the mapping attributes for
  subsequent mmap() of /dev/mem. Nonetheless, the support is sufficiently
  MTRR-like that Xorg can use it, which translates into an enormous increase
  in graphics performance on PowerPC.
  
  MFC after:2 weeks

Modified:
  head/sys/conf/files.powerpc
  head/sys/modules/mem/Makefile
  head/sys/powerpc/include/memdev.h
  head/sys/powerpc/powerpc/mem.c

Modified: head/sys/conf/files.powerpc
==
--- head/sys/conf/files.powerpc Sun Oct  3 13:52:17 2010(r213382)
+++ head/sys/conf/files.powerpc Sun Oct  3 16:02:53 2010(r213383)
@@ -27,6 +27,7 @@ dev/fb/fb.c   optionalsc
 dev/fdt/fdt_powerpc.c  optionalfdt
 dev/hwpmc/hwpmc_powerpc.c  optionalhwpmc
 dev/kbd/kbd.c  optionalsc
+dev/mem/memutil.c  optionalmem
 dev/ofw/openfirm.c optionalaim | fdt
 dev/ofw/openfirmio.c   optionalaim | fdt
 dev/ofw/ofw_bus_if.m   optionalaim | fdt

Modified: head/sys/modules/mem/Makefile
==
--- head/sys/modules/mem/Makefile   Sun Oct  3 13:52:17 2010
(r213382)
+++ head/sys/modules/mem/Makefile   Sun Oct  3 16:02:53 2010
(r213383)
@@ -6,7 +6,7 @@
 
 KMOD=  mem
 SRCS=  memdev.c mem.c
-.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
+.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" || 
${MACHINE_CPUARCH} = "powerpc"
 SRCS+= memutil.c
 .endif
 .if ${MACHINE_CPUARCH} == "i386"

Modified: head/sys/powerpc/include/memdev.h
==
--- head/sys/powerpc/include/memdev.h   Sun Oct  3 13:52:17 2010
(r213382)
+++ head/sys/powerpc/include/memdev.h   Sun Oct  3 16:02:53 2010
(r213383)
@@ -31,7 +31,7 @@
 
 d_open_t   memopen;
 d_read_t   memrw;
-#definememioctl(d_ioctl_t *)NULL
+d_ioctl_t  memioctl;
 d_mmap_t   memmmap;
 
 void   dev_mem_md_init(void);

Modified: head/sys/powerpc/powerpc/mem.c
==
--- head/sys/powerpc/powerpc/mem.c  Sun Oct  3 13:52:17 2010
(r213382)
+++ head/sys/powerpc/powerpc/mem.c  Sun Oct  3 16:02:53 2010
(r213383)
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -68,7 +69,21 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
-struct mem_range_softc mem_range_softc;
+static void ppc_mrinit(struct mem_range_softc *);
+static int ppc_mrset(struct mem_range_softc *, struct mem_range_desc *, int *);
+
+MALLOC_DEFINE(M_MEMDESC, "memdesc", "memory range descriptors");
+
+static struct mem_range_ops ppc_mem_range_ops = {
+   ppc_mrinit,
+   ppc_mrset,
+   NULL,
+   NULL
+};
+struct mem_range_softc mem_range_softc = {
+   &ppc_mem_range_ops,
+   0, 0, 0
+}; 
 
 /* ARGSUSED */
 int
@@ -162,6 +177,8 @@ int
 memmmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr,
 int prot, vm_memattr_t *memattr)
 {
+   int i;
+
/*
 * /dev/mem is the only one that makes sense through this
 * interface.  For /dev/kmem any physaddr we return here
@@ -178,10 +195,143 @@ memmmap(struct cdev *dev, vm_ooffset_t o
 
*paddr = offset;
 
+   for (i = 0; i < mem_range_softc.mr_ndesc; i++) {
+   if (!(mem_range_softc.mr_desc[i].mr_flags & MDF_ACTIVE))
+   continue;
+
+   if (offset >= mem_range_softc.mr_desc[i].mr_base &&
+   offset < mem_range_softc.mr_desc[i].mr_base +
+   mem_range_softc.mr_desc[i].mr_len) {
+   switch (mem_range_softc.mr_desc[i].mr_flags &
+   MDF_ATTRMASK) {
+   case MDF_WRITEBACK:
+   *memattr = VM_MEMATTR_WRITE_BACK;
+   break;
+   case MDF_WRITECOMBINE:
+   *memattr = VM_MEMATTR_WRITE_COMBINING;
+   break;
+   case MDF_UNCACHEABLE:
+   *memattr = VM_MEMATTR_UNCACHEABLE;
+   break;
+   case MDF_WRITETHROUGH:
+   *memattr = VM_MEMATTR_WRITE_THROUGH;
+   break;
+   }
+
+   break;
+   }
+   }
+
return (0);
 }
 
 void
 dev_mem_md_init(void)
 {
+   mem_range_softc.mr_op-

svn commit: r213386 - head/usr.sbin/sysinstall

2010-10-03 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Oct  3 17:50:43 2010
New Revision: 213386
URL: http://svn.freebsd.org/changeset/base/213386

Log:
  Extend sysinstall to handle powerpc64 by teaching it that powerpc64 has
  a lib32 distribution, and that the GENERIC kernel is named GENERIC64.
  More modifications will be required later for installations from ftp due
  to the shared platform name with 32-bit powerpc, but this is enough for
  snapshot CDs to work.
  
  Reviewed by:  brucec

Modified:
  head/usr.sbin/sysinstall/dist.c
  head/usr.sbin/sysinstall/dist.h
  head/usr.sbin/sysinstall/install.c
  head/usr.sbin/sysinstall/menus.c
  head/usr.sbin/sysinstall/sysinstall.8

Modified: head/usr.sbin/sysinstall/dist.c
==
--- head/usr.sbin/sysinstall/dist.c Sun Oct  3 17:05:25 2010
(r213385)
+++ head/usr.sbin/sysinstall/dist.c Sun Oct  3 17:50:43 2010
(r213386)
@@ -87,7 +87,7 @@ static Distribution DistTable[] = {
 DTE_TARBALL("proflibs", &Dists, PROFLIBS, "/"),
 DTE_TARBALL("dict",&Dists, DICT, "/"),
 DTE_TARBALL("info",&Dists, INFO, "/"),
-#ifdef __amd64__
+#if defined(__amd64__) || defined(__powerpc64__)
 DTE_TARBALL("lib32",&Dists, LIB32,"/"),
 #endif
 DTE_SUBDIST("src", &Dists, SRC,  SrcDistTable),
@@ -98,7 +98,7 @@ static Distribution DistTable[] = {
 
 /* The kernel distributions */
 static Distribution KernelDistTable[] = {
-DTE_TARBALL("GENERIC",  &KernelDists, KERNEL_GENERIC, "/boot"),
+DTE_TARBALL(GENERIC_KERNEL_NAME,  &KernelDists, KERNEL_GENERIC, "/boot"),
 DTE_END,
 };
 

Modified: head/usr.sbin/sysinstall/dist.h
==
--- head/usr.sbin/sysinstall/dist.h Sun Oct  3 17:05:25 2010
(r213385)
+++ head/usr.sbin/sysinstall/dist.h Sun Oct  3 17:50:43 2010
(r213386)
@@ -16,7 +16,7 @@
 #define DIST_CATPAGES  0x00200
 #define DIST_PORTS 0x00400
 #define DIST_LOCAL 0x00800
-#ifdef __amd64__
+#if defined(__amd64__) || defined(__powerpc64__)
 #define DIST_LIB32 0x01000
 #endif
 #defineDIST_KERNEL 0x02000
@@ -75,6 +75,12 @@
 #define DIST_KERNEL_SMP0x2
 #define DIST_KERNEL_ALL0xF
 
+#ifdef __powerpc64__
+#define GENERIC_KERNEL_NAME"GENERIC64"
+#else
+#define GENERIC_KERNEL_NAME"GENERIC"
+#endif
+
 /* Canned distribution sets */
 
 #define _DIST_USER \

Modified: head/usr.sbin/sysinstall/install.c
==
--- head/usr.sbin/sysinstall/install.c  Sun Oct  3 17:05:25 2010
(r213385)
+++ head/usr.sbin/sysinstall/install.c  Sun Oct  3 17:50:43 2010
(r213386)
@@ -979,7 +979,7 @@ installFixupKernel(dialogMenuItem *self,
 * already and the /boot/kernel we remove is empty.
 */
vsystem("rm -rf /boot/kernel");
-   vsystem("mv /boot/GENERIC /boot/kernel");
+   vsystem("mv /boot/" GENERIC_KERNEL_NAME " /boot/kernel");
 }
 return DITEM_SUCCESS | DITEM_RESTORE;
 }

Modified: head/usr.sbin/sysinstall/menus.c
==
--- head/usr.sbin/sysinstall/menus.cSun Oct  3 17:05:25 2010
(r213385)
+++ head/usr.sbin/sysinstall/menus.cSun Oct  3 17:50:43 2010
(r213386)
@@ -993,7 +993,7 @@ DMenu MenuSubDistributions = {
dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_GAMES },
   { " info",   "GNU info files",
dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_INFO },
-#ifdef __amd64__
+#if defined(__amd64__) || defined(__powerpc64__)
   { " lib32",  "32-bit runtime compatibility libraries",
dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_LIB32 },
 #endif

Modified: head/usr.sbin/sysinstall/sysinstall.8
==
--- head/usr.sbin/sysinstall/sysinstall.8   Sun Oct  3 17:05:25 2010
(r213385)
+++ head/usr.sbin/sysinstall/sysinstall.8   Sun Oct  3 17:50:43 2010
(r213386)
@@ -428,7 +428,7 @@ Dictionary information (for tools like s
 .It Li info
 GNU info files and other extra docs.
 .It Li lib32
-(amd64 only)
+(amd64 and powerpc64 only)
 32-bit runtime compatibility libraries.
 .It Li ports
 The ports collection.
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r213388 - head/sys/modules/mem

2010-10-03 Thread Nathan Whitehorn

On 10/03/10 15:04, Antoine Brodin wrote:

Author: antoine
Date: Sun Oct  3 20:04:11 2010
New Revision: 213388
URL: http://svn.freebsd.org/changeset/base/213388

Log:
   Unbreak build.
   


Ack! Thanks for fixing it, and sorry for the breakage.
-Nathan
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r213406 - head/libexec/rtld-elf/powerpc

2010-10-04 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Oct  4 16:02:11 2010
New Revision: 213406
URL: http://svn.freebsd.org/changeset/base/213406

Log:
  Fix two subtle problems in PPC32 RTLD. The first is a concurrency issue
  where long PLT calls in multi-threaded environments could end up with
  incorrect jmptab values. The second is that, after the addition of extended
  PLT support, I forgot to update the PLT icache synchronization code to cover
  the extended PLT instead of just the basic PLT.
  
  MFC after:10 days

Modified:
  head/libexec/rtld-elf/powerpc/reloc.c

Modified: head/libexec/rtld-elf/powerpc/reloc.c
==
--- head/libexec/rtld-elf/powerpc/reloc.c   Mon Oct  4 15:48:03 2010
(r213405)
+++ head/libexec/rtld-elf/powerpc/reloc.c   Mon Oct  4 16:02:11 2010
(r213406)
@@ -38,6 +38,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "debug.h"
@@ -481,6 +482,7 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr
 
jmptab = obj->pltgot + JMPTAB_BASE(N);
jmptab[reloff] = target;
+   powerpc_mb(); /* Order jmptab update before next changes */
 
if (reloff < PLT_EXTENDED_BEGIN) {
/* for extended PLT entries, we keep the old code */
@@ -489,7 +491,8 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr
 
/* li   r11,reloff */
/* bpltcall  # use indirect pltcall routine */
-   wherep[0] = 0x3960 | reloff;
+
+   /* first instruction same as before */
wherep[1] = 0x4800 | (distance & 0x03fc);
__syncicache(wherep, 8);
}
@@ -577,7 +580,7 @@ init_pltgot(Obj_Entry *obj)
 * Sync the icache for the byte range represented by the
 * trampoline routines and call slots.
 */
-   __syncicache(pltcall, 72 + N * 8);
+   __syncicache(obj->pltgot, JMPTAB_BASE(N)*4);
 }
 
 void
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r213407 - head/sys/powerpc/aim

2010-10-04 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Oct  4 16:07:48 2010
New Revision: 213407
URL: http://svn.freebsd.org/changeset/base/213407

Log:
  Follow exactly the steps in architecture manual for correctly invalidating
  TLB entries instead of trying to cut corners.

Modified:
  head/sys/powerpc/aim/mmu_oea.c
  head/sys/powerpc/aim/mmu_oea64.c

Modified: head/sys/powerpc/aim/mmu_oea.c
==
--- head/sys/powerpc/aim/mmu_oea.c  Mon Oct  4 16:02:11 2010
(r213406)
+++ head/sys/powerpc/aim/mmu_oea.c  Mon Oct  4 16:07:48 2010
(r213407)
@@ -425,9 +425,9 @@ tlbie(vm_offset_t va)
 {
 
mtx_lock_spin(&tlbie_mtx);
+   __asm __volatile("ptesync");
__asm __volatile("tlbie %0" :: "r"(va));
-   __asm __volatile("tlbsync");
-   powerpc_sync();
+   __asm __volatile("eieio; tlbsync; ptesync");
mtx_unlock_spin(&tlbie_mtx);
 }
 

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cMon Oct  4 16:02:11 2010
(r213406)
+++ head/sys/powerpc/aim/mmu_oea64.cMon Oct  4 16:07:48 2010
(r213407)
@@ -211,14 +211,14 @@ TLBIE(uint64_t vpn) {
mfmsr %0; \
mr %1, %0; \
insrdi %1,%5,1,0; \
-   mtmsrd %1; \
+   mtmsrd %1; isync; \
ptesync; \
\
sld %1,%2,%4; \
or %1,%1,%3; \
tlbie %1; \
\
-   mtmsrd %0; \
+   mtmsrd %0; isync; \
eieio; \
tlbsync; \
ptesync;" 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r213456 - in head/sys/powerpc: aim include

2010-10-05 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Tue Oct  5 18:08:07 2010
New Revision: 213456
URL: http://svn.freebsd.org/changeset/base/213456

Log:
  Handle vector assist traps without a kernel panic, by setting denormalized
  values to zero. A correct solution would involve emulating vector
  operations on denormalized values, but this has little effect on accuracy
  and is much less complicated for now.
  
  MFC after:2 weeks

Modified:
  head/sys/powerpc/aim/machdep.c
  head/sys/powerpc/aim/trap.c
  head/sys/powerpc/include/altivec.h
  head/sys/powerpc/include/pcb.h
  head/sys/powerpc/include/trap_aim.h

Modified: head/sys/powerpc/aim/machdep.c
==
--- head/sys/powerpc/aim/machdep.c  Tue Oct  5 17:06:51 2010
(r213455)
+++ head/sys/powerpc/aim/machdep.c  Tue Oct  5 18:08:07 2010
(r213456)
@@ -489,8 +489,8 @@ powerpc_init(vm_offset_t startkernel, vm
bcopy(generictrap, (void *)EXC_SC,   (size_t)&trapsize);
bcopy(generictrap, (void *)EXC_FPA,  (size_t)&trapsize);
bcopy(generictrap, (void *)EXC_VEC,  (size_t)&trapsize);
-   bcopy(generictrap, (void *)EXC_VECAST, (size_t)&trapsize);
-   bcopy(generictrap, (void *)EXC_THRM, (size_t)&trapsize);
+   bcopy(generictrap, (void *)EXC_VECAST_G4, (size_t)&trapsize);
+   bcopy(generictrap, (void *)EXC_VECAST_G5, (size_t)&trapsize);
__syncicache(EXC_RSVD, EXC_LAST - EXC_RSVD);
 
/*

Modified: head/sys/powerpc/aim/trap.c
==
--- head/sys/powerpc/aim/trap.c Tue Oct  5 17:06:51 2010(r213455)
+++ head/sys/powerpc/aim/trap.c Tue Oct  5 18:08:07 2010(r213456)
@@ -203,9 +203,19 @@ trap(struct trapframe *frame)
enable_vec(td);
break;
 
-   case EXC_VECAST:
-   printf("Vector assist exception!\n");
-   sig = SIGILL;
+   case EXC_VECAST_G4:
+   case EXC_VECAST_G5:
+   /*
+* We get a VPU assist exception for IEEE mode
+* vector operations on denormalized floats.
+* Emulating this is a giant pain, so for now,
+* just switch off IEEE mode and treat them as
+* zero.
+*/
+
+   save_vec(td);
+   td->td_pcb->pcb_vec.vscr |= ALTIVEC_VSCR_NJ;
+   enable_vec(td);
break;
 
case EXC_ALI:

Modified: head/sys/powerpc/include/altivec.h
==
--- head/sys/powerpc/include/altivec.h  Tue Oct  5 17:06:51 2010
(r213455)
+++ head/sys/powerpc/include/altivec.h  Tue Oct  5 18:08:07 2010
(r213456)
@@ -29,6 +29,9 @@
 #ifndef_MACHINE_ALTIVEC_H_
 #define_MACHINE_ALTIVEC_H_
 
+#define ALTIVEC_VSCR_NJ0x0001  /* Enable non-Java mode 
*/
+#define ALTIVEC_VSCR_SAT   0x0001  /* Saturation status bit */
+
 voidenable_vec(struct thread *);
 voidsave_vec(struct thread *);
 

Modified: head/sys/powerpc/include/pcb.h
==
--- head/sys/powerpc/include/pcb.h  Tue Oct  5 17:06:51 2010
(r213455)
+++ head/sys/powerpc/include/pcb.h  Tue Oct  5 18:08:07 2010
(r213456)
@@ -59,7 +59,7 @@ struct pcb {
uint32_t vr[32][4];
register_t vrsave;
register_t spare[2];
-   register_t vscr;
+   register_t vscr;/* aligned at vector element 3 */
} pcb_vec __aligned(16);/* Vector processor */
unsigned intpcb_veccpu; /* which CPU had our vector
stuff. */

Modified: head/sys/powerpc/include/trap_aim.h
==
--- head/sys/powerpc/include/trap_aim.h Tue Oct  5 17:06:51 2010
(r213455)
+++ head/sys/powerpc/include/trap_aim.h Tue Oct  5 18:08:07 2010
(r213456)
@@ -54,9 +54,12 @@
 /* The following is only available on the 601: */
 #defineEXC_RUNMODETRC  0x2000  /* Run Mode/Trace Exception */
 
+/* The following are only available on 970(G5): */
+#defineEXC_VECAST_G5   0x1700  /* AltiVec Assist */
+
 /* The following are only available on 7400(G4): */
 #defineEXC_VEC 0x0f20  /* AltiVec Unavailable */
-#defineEXC_VECAST  0x1600  /* AltiVec Assist */
+#defineEXC_VECAST_G4   0x1600  /* AltiVec Assist */
 
 /* The following are only available on 604/750/7400: */
 #defineEXC_PERF0x0f00  /* Performance Monitoring */
__

svn commit: r213833 - stable/8/libexec/rtld-elf/powerpc

2010-10-14 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Thu Oct 14 13:56:26 2010
New Revision: 213833
URL: http://svn.freebsd.org/changeset/base/213833

Log:
  MFC r213406:
  
  Fix two subtle problems in PPC32 RTLD. The first is a concurrency issue
  where long PLT calls in multi-threaded environments could end up with
  incorrect jmptab values. The second is that, after the addition of extended
  PLT support, I forgot to update the PLT icache synchronization code to cover
  the extended PLT instead of just the basic PLT.

Modified:
  stable/8/libexec/rtld-elf/powerpc/reloc.c
Directory Properties:
  stable/8/libexec/rtld-elf/   (props changed)

Modified: stable/8/libexec/rtld-elf/powerpc/reloc.c
==
--- stable/8/libexec/rtld-elf/powerpc/reloc.c   Thu Oct 14 12:32:49 2010
(r213832)
+++ stable/8/libexec/rtld-elf/powerpc/reloc.c   Thu Oct 14 13:56:26 2010
(r213833)
@@ -38,6 +38,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "debug.h"
@@ -485,6 +486,7 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr
 
jmptab = obj->pltgot + JMPTAB_BASE(N);
jmptab[reloff] = target;
+   powerpc_mb(); /* Order jmptab update before next changes */
 
if (reloff < PLT_EXTENDED_BEGIN) {
/* for extended PLT entries, we keep the old code */
@@ -493,7 +495,8 @@ reloc_jmpslot(Elf_Addr *wherep, Elf_Addr
 
/* li   r11,reloff */
/* bpltcall  # use indirect pltcall routine */
-   wherep[0] = 0x3960 | reloff;
+
+   /* first instruction same as before */
wherep[1] = 0x4800 | (distance & 0x03fc);
__syncicache(wherep, 8);
}
@@ -581,7 +584,7 @@ init_pltgot(Obj_Entry *obj)
 * Sync the icache for the byte range represented by the
 * trampoline routines and call slots.
 */
-   __syncicache(pltcall, 72 + N * 8);
+   __syncicache(obj->pltgot, JMPTAB_BASE(N)*4);
 }
 
 void
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r213892 - head

2010-10-15 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Oct 15 14:34:34 2010
New Revision: 213892
URL: http://svn.freebsd.org/changeset/base/213892

Log:
  Prevent the ofwdump manpage from being deleted by make delete-old on
  PowerPC.

Modified:
  head/ObsoleteFiles.inc

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Fri Oct 15 14:33:46 2010(r213891)
+++ head/ObsoleteFiles.inc  Fri Oct 15 14:34:34 2010(r213892)
@@ -4971,7 +4971,7 @@ OLD_FILES+=usr/share/man/man5/usbd.conf.
 .if ${TARGET_ARCH} != "i386" && ${TARGET_ARCH} != "amd64"
 OLD_FILES+=usr/share/man/man8/boot_i386.8.gz
 .endif
-.if ${TARGET_ARCH} != "powerpc" && ${TARGET_ARCH} != "sparc64"
+.if ${TARGET_ARCH} != "powerpc" && ${TARGET_ARCH} != "powerpc64" && 
${TARGET_ARCH} != "sparc64"
 OLD_FILES+=usr/share/man/man8/ofwdump.8.gz
 .endif
 OLD_FILES+=usr/share/man/man8/mount_reiserfs.8.gz
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r213979 - in stable/8/sys/powerpc: aim include powerpc

2010-10-17 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Oct 17 15:22:59 2010
New Revision: 213979
URL: http://svn.freebsd.org/changeset/base/213979

Log:
  MFC r213307,213335:
  
  Add support for memory attributes (pmap_mapdev_attr() and friends) on
  PowerPC/AIM. This is currently stubbed out on Book-E, since I have no
  idea how to implement it there.

Modified:
  stable/8/sys/powerpc/aim/mmu_oea.c
  stable/8/sys/powerpc/aim/mmu_oea64.c
  stable/8/sys/powerpc/include/pmap.h
  stable/8/sys/powerpc/include/vm.h
  stable/8/sys/powerpc/powerpc/bus_machdep.c
  stable/8/sys/powerpc/powerpc/mmu_if.m
  stable/8/sys/powerpc/powerpc/pmap_dispatch.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/powerpc/aim/mmu_oea.c
==
--- stable/8/sys/powerpc/aim/mmu_oea.c  Sun Oct 17 14:48:53 2010
(r213978)
+++ stable/8/sys/powerpc/aim/mmu_oea.c  Sun Oct 17 15:22:59 2010
(r213979)
@@ -221,8 +221,6 @@ u_int   moea_pteg_mask;
 struct pvo_head *moea_pvo_table;   /* pvo entries by pteg index */
 struct pvo_head moea_pvo_kunmanaged =
 LIST_HEAD_INITIALIZER(moea_pvo_kunmanaged);/* list of unmanaged 
pages */
-struct pvo_head moea_pvo_unmanaged =
-LIST_HEAD_INITIALIZER(moea_pvo_unmanaged); /* list of unmanaged pages */
 
 uma_zone_t moea_upvo_zone; /* zone for pvo entries for unmanaged pages */
 uma_zone_t moea_mpvo_zone; /* zone for pvo entries for managed pages */
@@ -327,9 +325,12 @@ void moea_deactivate(mmu_t, struct threa
 void moea_cpu_bootstrap(mmu_t, int);
 void moea_bootstrap(mmu_t, vm_offset_t, vm_offset_t);
 void *moea_mapdev(mmu_t, vm_offset_t, vm_size_t);
+void *moea_mapdev_attr(mmu_t, vm_offset_t, vm_size_t, vm_memattr_t);
 void moea_unmapdev(mmu_t, vm_offset_t, vm_size_t);
 vm_offset_t moea_kextract(mmu_t, vm_offset_t);
+void moea_kenter_attr(mmu_t, vm_offset_t, vm_offset_t, vm_memattr_t);
 void moea_kenter(mmu_t, vm_offset_t, vm_offset_t);
+void moea_page_set_memattr(mmu_t mmu, vm_page_t m, vm_memattr_t ma);
 boolean_t moea_dev_direct_mapped(mmu_t, vm_offset_t, vm_size_t);
 static void moea_sync_icache(mmu_t, pmap_t, vm_offset_t, vm_size_t);
 
@@ -364,14 +365,17 @@ static mmu_method_t moea_methods[] = {
MMUMETHOD(mmu_zero_page_idle,   moea_zero_page_idle),
MMUMETHOD(mmu_activate, moea_activate),
MMUMETHOD(mmu_deactivate,   moea_deactivate),
+   MMUMETHOD(mmu_page_set_memattr, moea_page_set_memattr),
 
/* Internal interfaces */
MMUMETHOD(mmu_bootstrap,moea_bootstrap),
MMUMETHOD(mmu_cpu_bootstrap,moea_cpu_bootstrap),
+   MMUMETHOD(mmu_mapdev_attr,  moea_mapdev_attr),
MMUMETHOD(mmu_mapdev,   moea_mapdev),
MMUMETHOD(mmu_unmapdev, moea_unmapdev),
MMUMETHOD(mmu_kextract, moea_kextract),
MMUMETHOD(mmu_kenter,   moea_kenter),
+   MMUMETHOD(mmu_kenter_attr,  moea_kenter_attr),
MMUMETHOD(mmu_dev_direct_mapped,moea_dev_direct_mapped),
 
{ 0, 0 }
@@ -384,6 +388,41 @@ static mmu_def_t oea_mmu = {
 };
 MMU_DEF(oea_mmu);
 
+static __inline uint32_t
+moea_calc_wimg(vm_offset_t pa, vm_memattr_t ma)
+{
+   uint32_t pte_lo;
+   int i;
+
+   if (ma != VM_MEMATTR_DEFAULT) {
+   switch (ma) {
+   case VM_MEMATTR_UNCACHEABLE:
+   return (PTE_I | PTE_G);
+   case VM_MEMATTR_WRITE_COMBINING:
+   case VM_MEMATTR_WRITE_BACK:
+   case VM_MEMATTR_PREFETCHABLE:
+   return (PTE_I);
+   case VM_MEMATTR_WRITE_THROUGH:
+   return (PTE_W | PTE_M);
+   }
+   }
+
+   /*
+* Assume the page is cache inhibited and access is guarded unless
+* it's in our available memory array.
+*/
+   pte_lo = PTE_I | PTE_G;
+   for (i = 0; i < pregions_sz; i++) {
+   if ((pa >= pregions[i].mr_start) &&
+   (pa < (pregions[i].mr_start + pregions[i].mr_size))) {
+   pte_lo = PTE_M;
+   break;
+   }
+   }
+
+   return pte_lo;
+}
+
 static void
 tlbie(vm_offset_t va)
 {
@@ -425,22 +464,6 @@ va_to_pteg(u_int sr, vm_offset_t addr)
 }
 
 static __inline struct pvo_head *
-pa_to_pvoh(vm_offset_t pa, vm_page_t *pg_p)
-{
-   struct  vm_page *pg;
-
-   pg = PHYS_TO_VM_PAGE(pa);
-
-   if (pg_p != NULL)
-   *pg_p = pg;
-
-   if (pg == NULL)
-   return (&moea_pvo_unmanaged);
-
-   return (&pg->md.mdpg_pvoh);
-}
-
-static __inline struct pvo_head *
 vm_page_to_pvoh(vm_page_t m)
 {
 
@@ -881,6 +904,7 @@

svn commit: r213982 - stable/8/sys/powerpc/powerpc

2010-10-17 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Oct 17 15:55:46 2010
New Revision: 213982
URL: http://svn.freebsd.org/changeset/base/213982

Log:
  MFC r213360:
  
  Missed some changes in the last commit required to build LINT.

Modified:
  stable/8/sys/powerpc/powerpc/pmap_dispatch.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/powerpc/powerpc/pmap_dispatch.c
==
--- stable/8/sys/powerpc/powerpc/pmap_dispatch.cSun Oct 17 15:47:27 
2010(r213981)
+++ stable/8/sys/powerpc/powerpc/pmap_dispatch.cSun Oct 17 15:55:46 
2010(r213982)
@@ -429,7 +429,7 @@ void *
 pmap_mapdev_attr(vm_offset_t pa, vm_size_t size, vm_memattr_t attr)
 {
 
-   CTR3(KTR_PMAP, "%s(%#x, %#x)", __func__, pa, size);
+   CTR4(KTR_PMAP, "%s(%#x, %#x, %#x)", __func__, pa, size, attr);
return (MMU_MAPDEV_ATTR(mmu_obj, pa, size, attr));
 }
 
@@ -437,7 +437,7 @@ void
 pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma)
 {
 
-   CTR3(KTR_PMAP, "%s(%#x, %#x)", __func__, pa, size);
+   CTR3(KTR_PMAP, "%s(%p, %#x)", __func__, m, ma);
return (MMU_PAGE_SET_MEMATTR(mmu_obj, m, ma));
 }
 
@@ -469,7 +469,7 @@ void
 pmap_kenter_attr(vm_offset_t va, vm_offset_t pa, vm_memattr_t ma)
 {
 
-   CTR3(KTR_PMAP, "%s(%#x, %#x)", __func__, va, pa);
+   CTR4(KTR_PMAP, "%s(%#x, %#x, %#x)", __func__, va, pa, ma);
MMU_KENTER_ATTR(mmu_obj, va, pa, ma);
 }
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r213986 - head/sys/kern

2010-10-17 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Oct 17 17:31:49 2010
New Revision: 213986
URL: http://svn.freebsd.org/changeset/base/213986

Log:
  Fix an XXX comment by answering 'no'. OS X does not set the day-of-week
  counter on SMU-based systems, which causes FreeBSD to reject the RTC time
  when used in a dual-boot environment. Since we don't use the day-of-week
  counter anyway, solve this by just not checking that it matches.
  
  MFC after:3 weeks

Modified:
  head/sys/kern/subr_clock.c

Modified: head/sys/kern/subr_clock.c
==
--- head/sys/kern/subr_clock.c  Sun Oct 17 16:46:54 2010(r213985)
+++ head/sys/kern/subr_clock.c  Sun Oct 17 17:31:49 2010(r213986)
@@ -164,10 +164,6 @@ clock_ct_to_ts(struct clocktime *ct, str
days += days_in_month(year, i);
days += (ct->day - 1);
 
-   /* XXX Dow sanity check. Dow is not used, so should we check it? */
-   if (ct->dow != -1 && ct->dow != day_of_week(days))
-   return (EINVAL);
-
/* Add hours, minutes, seconds. */
secs = ((days * 24 + ct->hour) * 60 + ct->min) * 60 + ct->sec;
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214348 - head/sys/powerpc/mambo

2010-10-25 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Oct 25 15:41:12 2010
New Revision: 214348
URL: http://svn.freebsd.org/changeset/base/214348

Log:
  Don't create spurious /dev entries.
  
  Submitted by: andreast

Modified:
  head/sys/powerpc/mambo/mambo_console.c

Modified: head/sys/powerpc/mambo/mambo_console.c
==
--- head/sys/powerpc/mambo/mambo_console.c  Mon Oct 25 15:31:13 2010
(r214347)
+++ head/sys/powerpc/mambo/mambo_console.c  Mon Oct 25 15:41:12 2010
(r214348)
@@ -86,7 +86,6 @@ cn_drvinit(void *unused)
tp = tty_alloc(&mambo_ttydevsw, NULL);
tty_init_console(tp, 0);
tty_makedev(tp, NULL, "%s", "mambocons");
-   tty_makealias(tp, "mambocons");
 
polltime = 1;
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214349 - in head/sys/dev: pci usb/controller

2010-10-25 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Oct 25 15:51:43 2010
New Revision: 214349
URL: http://svn.freebsd.org/changeset/base/214349

Log:
  The EHCI_CAPLENGTH and EHCI_HCIVERSION registers are actually sub-registers
  within the first 4 bytes of the EHCI memory space. For controllers that
  use big-endian MMIO, reading them with 1- and 2-byte reads would then
  return the wrong values. Instead, read the combined register with a 4-byte
  read and mask out the interesting quantities.

Modified:
  head/sys/dev/pci/pci.c
  head/sys/dev/usb/controller/ehci.c
  head/sys/dev/usb/controller/ehcireg.h

Modified: head/sys/dev/pci/pci.c
==
--- head/sys/dev/pci/pci.c  Mon Oct 25 15:41:12 2010(r214348)
+++ head/sys/dev/pci/pci.c  Mon Oct 25 15:51:43 2010(r214349)
@@ -2803,7 +2803,7 @@ ehci_early_takeover(device_t self)
"SMM does not respond\n");
}
/* Disable interrupts */
-   offs = bus_read_1(res, EHCI_CAPLENGTH);
+   offs = EHCI_CAPLENGTH(bus_read_4(res, EHCI_CAPLEN_HCIVERSION));
bus_write_4(res, offs + EHCI_USBINTR, 0);
}
bus_release_resource(self, SYS_RES_MEMORY, rid, res);

Modified: head/sys/dev/usb/controller/ehci.c
==
--- head/sys/dev/usb/controller/ehci.c  Mon Oct 25 15:41:12 2010
(r214348)
+++ head/sys/dev/usb/controller/ehci.c  Mon Oct 25 15:51:43 2010
(r214349)
@@ -270,9 +270,9 @@ ehci_init(ehci_softc_t *sc)
}
 #endif
 
-   sc->sc_offs = EREAD1(sc, EHCI_CAPLENGTH);
+   sc->sc_offs = EHCI_CAPLENGTH(EREAD4(sc, EHCI_CAPLEN_HCIVERSION));
 
-   version = EREAD2(sc, EHCI_HCIVERSION);
+   version = EHCI_HCIVERSION(EREAD4(sc, EHCI_CAPLEN_HCIVERSION));
device_printf(sc->sc_bus.bdev, "EHCI version %x.%x\n",
version >> 8, version & 0xff);
 

Modified: head/sys/dev/usb/controller/ehcireg.h
==
--- head/sys/dev/usb/controller/ehcireg.h   Mon Oct 25 15:41:12 2010
(r214348)
+++ head/sys/dev/usb/controller/ehcireg.h   Mon Oct 25 15:51:43 2010
(r214349)
@@ -54,9 +54,13 @@
 #defineEHCI_LEGSUP_USBLEGCTLSTS0x04
 
 /* EHCI capability registers */
-#defineEHCI_CAPLENGTH  0x00/* RO Capability register 
length field */
-#defineEHCI_RESERVED   0x01/* Reserved register */
-#defineEHCI_HCIVERSION 0x02/* RO Interface version number 
*/
+#defineEHCI_CAPLEN_HCIVERSION  0x00/* RO Capability register length
+* (least-significant byte) and 
+* interface version number (two
+* most significant)
+*/
+#define EHCI_CAPLENGTH(x)  ((x) & 0xff)
+#define EHCI_HCIVERSION(x) (((x) >> 16) & 0x)
 #defineEHCI_HCSPARAMS  0x04/* RO Structural parameters */
 #defineEHCI_HCS_DEBUGPORT(x)   (((x) >> 20) & 0xf)
 #defineEHCI_HCS_P_INDICATOR(x) ((x) & 0x1)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214376 - in stable/8/sys/powerpc: aim include

2010-10-26 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Tue Oct 26 14:56:46 2010
New Revision: 214376
URL: http://svn.freebsd.org/changeset/base/214376

Log:
  MFC r213456:
  Handle vector assist traps without a kernel panic, by setting denormalized
  values to zero. A correct solution would involve emulating vector
  operations on denormalized values, but this has little effect on accuracy
  and is much less complicated for now.

Modified:
  stable/8/sys/powerpc/aim/machdep.c
  stable/8/sys/powerpc/aim/trap.c
  stable/8/sys/powerpc/include/altivec.h
  stable/8/sys/powerpc/include/pcb.h
  stable/8/sys/powerpc/include/trap_aim.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/powerpc/aim/machdep.c
==
--- stable/8/sys/powerpc/aim/machdep.c  Tue Oct 26 14:06:59 2010
(r214375)
+++ stable/8/sys/powerpc/aim/machdep.c  Tue Oct 26 14:56:46 2010
(r214376)
@@ -474,8 +474,8 @@ powerpc_init(u_int startkernel, u_int en
bcopy(generictrap, (void *)EXC_SC,   (size_t)&trapsize);
bcopy(generictrap, (void *)EXC_FPA,  (size_t)&trapsize);
bcopy(generictrap, (void *)EXC_VEC,  (size_t)&trapsize);
-   bcopy(generictrap, (void *)EXC_VECAST, (size_t)&trapsize);
-   bcopy(generictrap, (void *)EXC_THRM, (size_t)&trapsize);
+   bcopy(generictrap, (void *)EXC_VECAST_G4, (size_t)&trapsize);
+   bcopy(generictrap, (void *)EXC_VECAST_G5, (size_t)&trapsize);
__syncicache(EXC_RSVD, EXC_LAST - EXC_RSVD);
 
/*

Modified: stable/8/sys/powerpc/aim/trap.c
==
--- stable/8/sys/powerpc/aim/trap.c Tue Oct 26 14:06:59 2010
(r214375)
+++ stable/8/sys/powerpc/aim/trap.c Tue Oct 26 14:56:46 2010
(r214376)
@@ -196,9 +196,19 @@ trap(struct trapframe *frame)
enable_vec(td);
break;
 
-   case EXC_VECAST:
-   printf("Vector assist exception!\n");
-   sig = SIGILL;
+   case EXC_VECAST_G4:
+   case EXC_VECAST_G5:
+   /*
+* We get a VPU assist exception for IEEE mode
+* vector operations on denormalized floats.
+* Emulating this is a giant pain, so for now,
+* just switch off IEEE mode and treat them as
+* zero.
+*/
+
+   save_vec(td);
+   td->td_pcb->pcb_vec.vscr |= ALTIVEC_VSCR_NJ;
+   enable_vec(td);
break;
 
case EXC_ALI:

Modified: stable/8/sys/powerpc/include/altivec.h
==
--- stable/8/sys/powerpc/include/altivec.h  Tue Oct 26 14:06:59 2010
(r214375)
+++ stable/8/sys/powerpc/include/altivec.h  Tue Oct 26 14:56:46 2010
(r214376)
@@ -29,6 +29,9 @@
 #ifndef_MACHINE_ALTIVEC_H_
 #define_MACHINE_ALTIVEC_H_
 
+#define ALTIVEC_VSCR_NJ0x0001  /* Enable non-Java mode 
*/
+#define ALTIVEC_VSCR_SAT   0x0001  /* Saturation status bit */
+
 voidenable_vec(struct thread *);
 voidsave_vec(struct thread *);
 

Modified: stable/8/sys/powerpc/include/pcb.h
==
--- stable/8/sys/powerpc/include/pcb.h  Tue Oct 26 14:06:59 2010
(r214375)
+++ stable/8/sys/powerpc/include/pcb.h  Tue Oct 26 14:56:46 2010
(r214376)
@@ -58,7 +58,7 @@ struct pcb {
uint32_t vr[32][4];
register_t vrsave;
register_t spare[2];
-   register_t vscr;
+   register_t vscr;/* aligned at vector element 3 */
} pcb_vec __attribute__((aligned(16))); /* Vector processor */
unsigned intpcb_veccpu; /* which CPU had our vector
stuff. */

Modified: stable/8/sys/powerpc/include/trap_aim.h
==
--- stable/8/sys/powerpc/include/trap_aim.h Tue Oct 26 14:06:59 2010
(r214375)
+++ stable/8/sys/powerpc/include/trap_aim.h Tue Oct 26 14:56:46 2010
(r214376)
@@ -52,9 +52,12 @@
 /* The following is only available on the 601: */
 #defineEXC_RUNMODETRC  0x2000  /* Run Mode/Trace Exception */
 
+/* The following are only available on 970(G5): */
+#defineEXC_VECAST_G5   0x1700  /* AltiVec Assist */
+
 /* The following a

svn commit: r214377 - stable/8/sys/vm

2010-10-26 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Tue Oct 26 14:59:35 2010
New Revision: 214377
URL: http://svn.freebsd.org/changeset/base/214377

Log:
  MFC r212360:
  On architectures with non-tree-based page tables like PowerPC, every page
  in a range must be checked when calling pmap_remove(). Calling
  pmap_remove() from vm_pageout_map_deactivate_pages() with the entire range
  of the map could result in attempting to demap an extraordinary number
  of pages (> 10^15), so iterate through each map entry and unmap each of
  them individually.

Modified:
  stable/8/sys/vm/vm_pageout.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/vm/vm_pageout.c
==
--- stable/8/sys/vm/vm_pageout.cTue Oct 26 14:56:46 2010
(r214376)
+++ stable/8/sys/vm/vm_pageout.cTue Oct 26 14:59:35 2010
(r214377)
@@ -661,8 +661,11 @@ vm_pageout_map_deactivate_pages(map, des
 * table pages.
 */
if (desired == 0 && nothingwired) {
-   pmap_remove(vm_map_pmap(map), vm_map_min(map),
-   vm_map_max(map));
+   tmpe = map->header.next;
+   while (tmpe != &map->header) {
+   pmap_remove(vm_map_pmap(map), tmpe->start, tmpe->end);
+   tmpe = tmpe->next;
+   }
}
vm_map_unlock(map);
 }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214493 - in head/sys/boot/ofw: common libofw

2010-10-28 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Thu Oct 28 23:46:05 2010
New Revision: 214493
URL: http://svn.freebsd.org/changeset/base/214493

Log:
  Fix some memory management issues discovered when trying to boot the PPC
  OF loader on systems where address cells and size cells are both 2 (the
  Mambo simulator) and fix an error where cons_probe() was called before
  init_heap() but used malloc() to set environment variables.
  
  MFC after:1 month

Modified:
  head/sys/boot/ofw/common/main.c
  head/sys/boot/ofw/libofw/ofw_memory.c
  head/sys/boot/ofw/libofw/openfirm.c

Modified: head/sys/boot/ofw/common/main.c
==
--- head/sys/boot/ofw/common/main.c Thu Oct 28 22:34:49 2010
(r214492)
+++ head/sys/boot/ofw/common/main.c Thu Oct 28 23:46:05 2010
(r214493)
@@ -41,7 +41,7 @@ extern char bootprog_rev[];
 extern char bootprog_date[];
 extern char bootprog_maker[];
 
-u_int32_t  acells;
+u_int32_t  acells, scells;
 
 static char bootargs[128];
 
@@ -64,25 +64,20 @@ uint64_t
 memsize(void)
 {
phandle_t   memoryp;
-   struct ofw_reg  reg[4];
-   struct ofw_reg2 reg2[8];
-   int i;
-   u_int64_t   sz, memsz;
+   cell_t  reg[24];
+   int i, sz;
+   u_int64_t   memsz;
 
+   memsz = 0;
memoryp = OF_instance_to_package(memory);
 
-   if (acells == 1) {
-   sz = OF_getprop(memoryp, "reg", ®, sizeof(reg));
-   sz /= sizeof(struct ofw_reg);
-
-   for (i = 0, memsz = 0; i < sz; i++)
-   memsz += reg[i].size;
-   } else if (acells == 2) {
-   sz = OF_getprop(memoryp, "reg", ®2, sizeof(reg2));
-   sz /= sizeof(struct ofw_reg2);
+   sz = OF_getprop(memoryp, "reg", ®, sizeof(reg));
+   sz /= sizeof(reg[0]);
 
-   for (i = 0, memsz = 0; i < sz; i++)
-   memsz += reg2[i].size;
+   for (i = 0; i < sz; i += (acells + scells)) {
+   if (scells > 1)
+   memsz += (uint64_t)reg[i + acells] << 32;
+   memsz += reg[i + acells + scells - 1];
}
 
return (memsz);
@@ -105,13 +100,9 @@ main(int (*openfirm)(void *))
 
root = OF_finddevice("/");
 
-   acells = 1;
+   scells = acells = 1;
OF_getprop(root, "#address-cells", &acells, sizeof(acells));
-
-   /*
- * Set up console.
- */
-   cons_probe();
+   OF_getprop(root, "#size-cells", &scells, sizeof(scells));
 
/*
 * Initialise the heap as early as possible.  Once this is done,
@@ -121,6 +112,11 @@ main(int (*openfirm)(void *))
init_heap();
 
/*
+ * Set up console.
+ */
+   cons_probe();
+
+   /*
 * March through the device switch probing for things.
 */
for (i = 0; devsw[i] != NULL; i++)

Modified: head/sys/boot/ofw/libofw/ofw_memory.c
==
--- head/sys/boot/ofw/libofw/ofw_memory.c   Thu Oct 28 22:34:49 2010
(r214492)
+++ head/sys/boot/ofw/libofw/ofw_memory.c   Thu Oct 28 23:46:05 2010
(r214493)
@@ -118,13 +118,19 @@ ofw_memmap(int acells)
 void *
 ofw_alloc_heap(unsigned int size)
 {
-   phandle_t   memoryp;
-   struct  ofw_reg available;
+   phandle_t   memoryp, root;
+   cell_t  available[4];
+   cell_t  acells;
+
+   root = OF_finddevice("/");
+   acells = 1;
+   OF_getprop(root, "#address-cells", &acells, sizeof(acells));
 
memoryp = OF_instance_to_package(memory);
-   OF_getprop(memoryp, "available", &available, sizeof(available));
+   OF_getprop(memoryp, "available", available, sizeof(available));
 
-   heap_base = OF_claim((void *)available.base, size, sizeof(register_t));
+   heap_base = OF_claim((void *)available[acells-1], size,
+   sizeof(register_t));
 
if (heap_base != (void *)-1) {
heap_size = size;

Modified: head/sys/boot/ofw/libofw/openfirm.c
==
--- head/sys/boot/ofw/libofw/openfirm.c Thu Oct 28 22:34:49 2010
(r214492)
+++ head/sys/boot/ofw/libofw/openfirm.c Thu Oct 28 23:46:05 2010
(r214493)
@@ -80,8 +80,13 @@ OF_init(int (*openfirm)(void *))
 
if ((chosen = OF_finddevice("/chosen")) == -1)
OF_exit();
-   if (OF_getprop(chosen, "memory", &memory, sizeof(memory)) == -1)
-   OF_exit();
+   if (OF_getprop(chosen, "memory", &memory, sizeof(memory)) == -1) {
+   memory = OF_open("/memory");
+   if (memory == -1)
+   memory = OF_open("/mem...@0");
+   if (memory == -1)
+   OF_exit();
+   }
if (OF_getprop(chosen, "mmu", &mmu, sizeof(mmu)) == -1)
   

svn commit: r214494 - head/sys/boot/ofw/libofw

2010-10-28 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Oct 29 00:36:44 2010
New Revision: 214494
URL: http://svn.freebsd.org/changeset/base/214494

Log:
  Fix netboot on some Apple machines on which calling dma-free on the
  network device can hang the machine. This causes the loss of 64 KB of
  accessible memory on netbooted machines.

Modified:
  head/sys/boot/ofw/libofw/ofw_net.c

Modified: head/sys/boot/ofw/libofw/ofw_net.c
==
--- head/sys/boot/ofw/libofw/ofw_net.c  Thu Oct 28 23:46:05 2010
(r214493)
+++ head/sys/boot/ofw/libofw/ofw_net.c  Fri Oct 29 00:36:44 2010
(r214494)
@@ -230,7 +230,10 @@ punt:
 static void
 ofwn_end(struct netif *nif)
 {
+#ifdef BROKEN
+   /* dma-free freezes at least some Apple ethernet controllers */
OF_call_method("dma-free", netinstance, 2, 0, dmabuf, MAXPHYS);
+#endif
OF_close(netinstance);
 }
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214495 - head/sys/boot/ofw/common

2010-10-28 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Oct 29 00:37:35 2010
New Revision: 214495
URL: http://svn.freebsd.org/changeset/base/214495

Log:
  Fix the printf() in init_heap so that it can run before the console is up.
  
  Pointed out by:   marius

Modified:
  head/sys/boot/ofw/common/main.c

Modified: head/sys/boot/ofw/common/main.c
==
--- head/sys/boot/ofw/common/main.c Fri Oct 29 00:36:44 2010
(r214494)
+++ head/sys/boot/ofw/common/main.c Fri Oct 29 00:37:35 2010
(r214495)
@@ -47,13 +47,17 @@ static char bootargs[128];
 
 #defineHEAP_SIZE   0x8
 
+#define OF_puts(fd, text) OF_write(fd, text, strlen(text))
+
 void
 init_heap(void)
 {
void*base;
+   ihandle_t stdout;
 
if ((base = ofw_alloc_heap(HEAP_SIZE)) == (void *)0x) {
-   printf("Heap memory claim failed!\n");
+   OF_getprop(chosen, "stdout", &stdout, sizeof(stdout));
+   OF_puts(stdout, "Heap memory claim failed!\n");
OF_enter();
}
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214574 - in head/sys/powerpc: aim include powerpc

2010-10-30 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Oct 30 23:07:30 2010
New Revision: 214574
URL: http://svn.freebsd.org/changeset/base/214574

Log:
  Restructure the way the copyin/copyout segment is stored to prevent a
  concurrency bug. Since all SLB/SR entries were invalidated during an
  exception, a decrementer exception could cause the user segment to be
  invalidated during a copyin()/copyout() without a thread switch that
  would cause it to be restored from the PCB, potentially causing the
  operation to continue on invalid memory. This is now handled by explicit
  restoration of segment 12 from the PCB on 32-bit systems and a check in
  the Data Segment Exception handler on 64-bit.
  
  While here, cause copyin()/copyout() to check whether the requested
  user segment is already installed, saving some pipeline flushes, and
  fix the synchronization primitives around the mtsr and slbmte
  instructions to prevent accessing stale segments.
  
  MFC after:2 weeks

Modified:
  head/sys/powerpc/aim/copyinout.c
  head/sys/powerpc/aim/slb.c
  head/sys/powerpc/aim/swtch64.S
  head/sys/powerpc/aim/trap.c
  head/sys/powerpc/aim/trap_subr32.S
  head/sys/powerpc/aim/trap_subr64.S
  head/sys/powerpc/aim/vm_machdep.c
  head/sys/powerpc/include/pcb.h
  head/sys/powerpc/include/slb.h
  head/sys/powerpc/include/sr.h
  head/sys/powerpc/powerpc/exec_machdep.c
  head/sys/powerpc/powerpc/genassym.c

Modified: head/sys/powerpc/aim/copyinout.c
==
--- head/sys/powerpc/aim/copyinout.cSat Oct 30 23:04:54 2010
(r214573)
+++ head/sys/powerpc/aim/copyinout.cSat Oct 30 23:07:30 2010
(r214574)
@@ -81,9 +81,7 @@ static __inline void
 set_user_sr(pmap_t pm, const void *addr)
 {
struct slb *slb;
-   register_t esid, vsid, slb1, slb2;
-
-   esid = USER_ADDR >> ADDR_SR_SHFT;
+   register_t slbv;
 
/* Try lockless look-up first */
slb = user_va_to_slb_entry(pm, (vm_offset_t)addr);
@@ -91,20 +89,21 @@ set_user_sr(pmap_t pm, const void *addr)
if (slb == NULL) {
/* If it isn't there, we need to pre-fault the VSID */
PMAP_LOCK(pm);
-   vsid = va_to_vsid(pm, (vm_offset_t)addr);
+   slbv = va_to_vsid(pm, (vm_offset_t)addr) << SLBV_VSID_SHIFT;
PMAP_UNLOCK(pm);
} else {
-   vsid = slb->slbv >> SLBV_VSID_SHIFT;
+   slbv = slb->slbv;
}
 
-   slb1 = vsid << SLBV_VSID_SHIFT;
-   slb2 = (esid << SLBE_ESID_SHIFT) | SLBE_VALID | USER_SR;
+   /* If we have already set this VSID, we can just return */
+   if (curthread->td_pcb->pcb_cpu.aim.usr_vsid == slbv) 
+   return;
 
+   __asm __volatile ("isync; slbie %0; slbmte %1, %2; isync" ::
+   "r"(USER_ADDR), "r"(slbv), "r"(USER_SLB_SLBE));
curthread->td_pcb->pcb_cpu.aim.usr_segm =
(uintptr_t)addr >> ADDR_SR_SHFT;
-   __asm __volatile ("slbie %0; slbmte %1, %2" :: "r"(esid << 28),
-   "r"(slb1), "r"(slb2));
-   isync();
+   curthread->td_pcb->pcb_cpu.aim.usr_vsid = slbv;
 }
 #else
 static __inline void
@@ -114,9 +113,13 @@ set_user_sr(pmap_t pm, const void *addr)
 
vsid = va_to_vsid(pm, (vm_offset_t)addr);
 
-   isync();
-   __asm __volatile ("mtsr %0,%1" :: "n"(USER_SR), "r"(vsid));
-   isync();
+   /* If we have already set this VSID, we can just return */
+   if (curthread->td_pcb->pcb_cpu.aim.usr_vsid == vsid)
+   return;
+
+   __asm __volatile ("sync; mtsr %0,%1; sync; isync" :: "n"(USER_SR),
+   "r"(vsid));
+   curthread->td_pcb->pcb_cpu.aim.usr_vsid = vsid;
 }
 #endif
 

Modified: head/sys/powerpc/aim/slb.c
==
--- head/sys/powerpc/aim/slb.c  Sat Oct 30 23:04:54 2010(r214573)
+++ head/sys/powerpc/aim/slb.c  Sat Oct 30 23:07:30 2010(r214574)
@@ -200,7 +200,7 @@ kernel_va_to_slbv(vm_offset_t va)
esid = (uintptr_t)va >> ADDR_SR_SHFT;
 
/* Set kernel VSID to deterministic value */
-   slbv = va_to_vsid(kernel_pmap, va) << SLBV_VSID_SHIFT;
+   slbv = (KERNEL_VSID((uintptr_t)va >> ADDR_SR_SHFT)) << SLBV_VSID_SHIFT;
 
/* Figure out if this is a large-page mapping */
if (hw_direct_map && va < VM_MIN_KERNEL_ADDRESS) {
@@ -421,19 +421,19 @@ slb_insert_kernel(uint64_t slbe, uint64_
 
slbcache = PCPU_GET(slb);
 
-   /* Check for an unused slot, abusing the USER_SR slot as a full flag */
-   if (slbcache[USER_SR].slbe == 0) {
-   for (i = 0; i < USER_SR; i++) {
+   /* Check for an unused slot, abusing the user slot as a full flag */
+   if (slbcache[USER_SLB_SLOT].slbe == 0) {
+   for (i = 0; i < USER_SLB_SLOT; i++) {
if (!(slbcache[i].slbe & SLBE_VALID)) 
goto fillkernslb;
}
 
-   if

svn commit: r214575 - head/sys/powerpc/powermac

2010-10-30 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Oct 30 23:09:56 2010
New Revision: 214575
URL: http://svn.freebsd.org/changeset/base/214575

Log:
  Allow access to the HT I/O port space on the IBM CPC9X5 northbridge chips.
  
  MFC after:2 weeks

Modified:
  head/sys/powerpc/powermac/cpcht.c

Modified: head/sys/powerpc/powermac/cpcht.c
==
--- head/sys/powerpc/powermac/cpcht.c   Sat Oct 30 23:07:30 2010
(r214574)
+++ head/sys/powerpc/powermac/cpcht.c   Sat Oct 30 23:09:56 2010
(r214575)
@@ -162,6 +162,7 @@ struct cpcht_softc {
vm_offset_t sc_data;
uint64_tsc_populated_slots;
struct  rman sc_mem_rman;
+   struct  rman sc_io_rman;
 
struct cpcht_irqhtirq_map[128];
struct mtx  htirq_mtx;
@@ -177,6 +178,9 @@ static devclass_t   cpcht_devclass;
 
 DRIVER_MODULE(cpcht, nexus, cpcht_driver, cpcht_devclass, 0, 0);
 
+#define CPCHT_IOPORT_BASE  0xf400UL /* Hardwired */
+#define CPCHT_IOPORT_SIZE  0x0040UL
+
 #define HTAPIC_REQUEST_EOI 0x20
 #define HTAPIC_TRIGGER_LEVEL   0x02
 #define HTAPIC_MASK0x01
@@ -236,7 +240,14 @@ cpcht_attach(device_t dev)
sc->sc_mem_rman.rm_type = RMAN_ARRAY;
sc->sc_mem_rman.rm_descr = "CPCHT Device Memory";
error = rman_init(&sc->sc_mem_rman);
+   if (error) {
+   device_printf(dev, "rman_init() failed. error = %d\n", error);
+   return (error);
+   }
 
+   sc->sc_io_rman.rm_type = RMAN_ARRAY;
+   sc->sc_io_rman.rm_descr = "CPCHT I/O Memory";
+   error = rman_init(&sc->sc_io_rman);
if (error) {
device_printf(dev, "rman_init() failed. error = %d\n", error);
return (error);
@@ -248,6 +259,9 @@ cpcht_attach(device_t dev)
 * where we get the HT interrupts properties.
 */
 
+   /* I/O port mappings are usually not in the device tree */
+   rman_manage_region(&sc->sc_io_rman, 0, CPCHT_IOPORT_SIZE - 1);
+
bzero(sc->htirq_map, sizeof(sc->htirq_map));
mtx_init(&sc->htirq_mtx, "cpcht irq", NULL, MTX_DEF);
for (i = 0; i < 8; i++)
@@ -299,6 +313,9 @@ cpcht_configure_htbridge(device_t dev, p
case OFW_PCI_PHYS_HI_SPACE_CONFIG:
break;
case OFW_PCI_PHYS_HI_SPACE_IO:
+   rman_manage_region(&sc->sc_io_rman, rp->pci_lo,
+   rp->pci_lo + rp->size_lo - 1);
+   break;
case OFW_PCI_PHYS_HI_SPACE_MEM32:
rman_manage_region(&sc->sc_mem_rman, rp->pci_lo,
rp->pci_lo + rp->size_lo - 1);
@@ -507,8 +524,9 @@ cpcht_alloc_resource(device_t bus, devic
switch (type) {
case SYS_RES_IOPORT:
end = min(end, start + count);
+   rm = &sc->sc_io_rman;
+   break;
 
-   /* FALLTHROUGH */
case SYS_RES_MEMORY:
rm = &sc->sc_mem_rman;
break;
@@ -562,6 +580,9 @@ cpcht_activate_resource(device_t bus, de
 
start = (vm_offset_t)rman_get_start(res);
 
+   if (type == SYS_RES_IOPORT)
+   start += CPCHT_IOPORT_BASE;
+
if (bootverbose)
printf("cpcht mapdev: start %zx, len %ld\n", start,
rman_get_size(res));
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214601 - head/sys/powerpc/aim

2010-10-31 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Oct 31 15:07:09 2010
New Revision: 214601
URL: http://svn.freebsd.org/changeset/base/214601

Log:
  Add some missing parentheses so that moea_bat_mapped() actually works.
  
  Submitted by: alc
  MFC after:3 days

Modified:
  head/sys/powerpc/aim/mmu_oea.c

Modified: head/sys/powerpc/aim/mmu_oea.c
==
--- head/sys/powerpc/aim/mmu_oea.c  Sun Oct 31 12:08:16 2010
(r214600)
+++ head/sys/powerpc/aim/mmu_oea.c  Sun Oct 31 15:07:09 2010
(r214601)
@@ -2430,7 +2430,7 @@ moea_bat_mapped(int idx, vm_offset_t pa,
/*
 * Return immediately if not a valid mapping
 */
-   if (!battable[idx].batu & BAT_Vs)
+   if (!(battable[idx].batu & BAT_Vs))
return (EINVAL);
 
/*
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214603 - in head/sys: conf dev/agp modules modules/agp powerpc/conf

2010-10-31 Thread Nathan Whitehorn
ed: head/sys/dev/agp/agp_apple.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/agp/agp_apple.cSun Oct 31 18:27:05 2010
(r214603)
@@ -0,0 +1,302 @@
+/*-
+ * Copyright (c) 2010 Nathan Whitehorn
+ * 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 "opt_bus.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#define UNIN_AGP_GART_BASE 0x8c
+#define UNIN_AGP_BASE_ADDR 0x90
+#define UNIN_AGP_GART_CONTROL  0x94
+
+#define UNIN_AGP_GART_INVAL0x0001
+#define UNIN_AGP_GART_ENABLE   0x0100
+#define UNIN_AGP_GART_2XRESET  0x0001
+#define UNIN_AGP_U3_GART_PERFRD0x0008
+
+struct agp_apple_softc {
+   struct agp_softc agp;
+   uint32_taperture;
+   struct agp_gatt *gatt;
+   int u3;
+   int needs_2x_reset;
+};
+
+static int
+agp_apple_probe(device_t dev)
+{
+
+   if (resource_disabled("agp", device_get_unit(dev)))
+   return (ENXIO);
+
+   if (pci_get_class(dev) != PCIC_BRIDGE
+   || pci_get_subclass(dev) != PCIS_BRIDGE_HOST)
+   return (ENXIO);
+
+   if (agp_find_caps(dev) == 0)
+   return (ENXIO);
+
+   if (pci_get_class(dev) != PCIC_BRIDGE
+   || pci_get_subclass(dev) != PCIS_BRIDGE_HOST)
+   return (ENXIO);
+
+   switch (pci_get_devid(dev)) {
+   case 0x0020106b:
+   case 0x0027106b:
+   device_set_desc(dev, "Apple UniNorth AGP Bridge");
+   return (BUS_PROBE_DEFAULT);
+   case 0x002d106b:
+   device_set_desc(dev, "Apple UniNorth 1.5 AGP Bridge");
+   return (BUS_PROBE_DEFAULT);
+   case 0x0034106b:
+   device_set_desc(dev, "Apple UniNorth 2 AGP Bridge");
+   return (BUS_PROBE_DEFAULT);
+   case 0x004b106b:
+   case 0x0058106b:
+   case 0x0059106b:
+   device_set_desc(dev, "Apple U3 AGP Bridge");
+   return (BUS_PROBE_DEFAULT);
+   case 0x0066106b:
+   device_set_desc(dev, "Apple Intrepid AGP Bridge");
+   return (BUS_PROBE_DEFAULT);
+   }
+
+   return (ENXIO);
+}
+
+static int
+agp_apple_attach(device_t dev)
+{
+   struct agp_apple_softc *sc = device_get_softc(dev);
+   int error;
+
+   /* Record quirks */
+   sc->needs_2x_reset = 0;
+   sc->u3 = 0;
+   switch (pci_get_devid(dev)) {
+   case 0x0020106b:
+   case 0x0027106b:
+   sc->needs_2x_reset = 1;
+   break;
+   case 0x004b106b:
+   case 0x0058106b:
+   case 0x0059106b:
+   sc->u3 = 1;
+   break;
+   }
+
+   /* Set the aperture bus address base (must be 0) */
+   pci_write_config(dev, UNIN_AGP_BASE_ADDR, 0, 4);
+   agp_set_aperture_resource(dev, -1);
+
+   error = agp_generic_attach(dev);
+   if (error)
+   return (error);
+
+   sc->aperture = 256*1024*1024;
+
+   for (sc->aperture = 256*1024*1024; sc->aperture >= 4*1024*1024;
+   sc->aperture /= 2) {
+   sc->gatt = agp_alloc_gatt(dev);
+   if (sc->gatt)
+   break;
+   }
+   if (sc->aperture < 4*1024*1024) {
+   agp_generic_detach(dev);
+   return ENOMEM;
+  

svn commit: r214607 - head/sys/powerpc/aim

2010-10-31 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Oct 31 22:55:51 2010
New Revision: 214607
URL: http://svn.freebsd.org/changeset/base/214607

Log:
  Next-to-leading-order perturbation of synchronization operations for
  switching the user segment register. All races should now be closed and
  a minimum of pipelines flushes be required to close them.

Modified:
  head/sys/powerpc/aim/copyinout.c
  head/sys/powerpc/aim/swtch32.S
  head/sys/powerpc/aim/swtch64.S

Modified: head/sys/powerpc/aim/copyinout.c
==
--- head/sys/powerpc/aim/copyinout.cSun Oct 31 22:46:39 2010
(r214606)
+++ head/sys/powerpc/aim/copyinout.cSun Oct 31 22:55:51 2010
(r214607)
@@ -117,9 +117,9 @@ set_user_sr(pmap_t pm, const void *addr)
if (curthread->td_pcb->pcb_cpu.aim.usr_vsid == vsid)
return;
 
-   __asm __volatile ("sync; mtsr %0,%1; sync; isync" :: "n"(USER_SR),
-   "r"(vsid));
+   __asm __volatile("isync");
curthread->td_pcb->pcb_cpu.aim.usr_vsid = vsid;
+   __asm __volatile("mtsr %0,%1; isync" :: "n"(USER_SR), "r"(vsid));
 }
 #endif
 

Modified: head/sys/powerpc/aim/swtch32.S
==
--- head/sys/powerpc/aim/swtch32.S  Sun Oct 31 22:46:39 2010
(r214606)
+++ head/sys/powerpc/aim/swtch32.S  Sun Oct 31 22:55:51 2010
(r214607)
@@ -89,7 +89,6 @@ ENTRY(cpu_switch)
mflr%r16/* Save the link register */
stw %r16,PCB_LR(%r6)
mfsr%r16,USER_SR/* Save USER_SR for copyin/out */
-   isync
stw %r16,PCB_AIM_USR_VSID(%r6)
stw %r1,PCB_SP(%r6) /* Save the stack pointer */
stw %r2,PCB_TOC(%r6)/* Save the TOC pointer */
@@ -162,6 +161,7 @@ blocked_loop:
lwz %r5,PCB_LR(%r3) /* Load the link register */
mtlr%r5
lwz %r5,PCB_AIM_USR_VSID(%r3) /* Load the USER_SR segment reg */
+   isync
mtsrUSER_SR,%r5
isync
lwz %r1,PCB_SP(%r3) /* Load the stack pointer */

Modified: head/sys/powerpc/aim/swtch64.S
==
--- head/sys/powerpc/aim/swtch64.S  Sun Oct 31 22:46:39 2010
(r214606)
+++ head/sys/powerpc/aim/swtch64.S  Sun Oct 31 22:55:51 2010
(r214607)
@@ -113,7 +113,6 @@ ENTRY(cpu_switch)
li  %r15,0  /* Save user segment for copyin/out */
li  %r16,USER_SLB_SLOT
slbmfev %r15, %r16
-   isync
std %r15,PCB_AIM_USR_VSID(%r6)
 
mr  %r14,%r3/* Copy the old thread ptr... */
@@ -222,6 +221,7 @@ blocked_loop:
ori %r5,%r5,user_a...@highera
sldi%r5,%r5,32
oris%r5,%r5,user_a...@ha
+   isync
slbie   %r5
lis %r6,user_slb_s...@highesta
ori %r6,%r6,user_slb_s...@highera
@@ -230,8 +230,8 @@ blocked_loop:
ori %r6,%r6,user_slb_s...@l
ld  %r5,PCB_AIM_USR_VSID(%r3)
slbmte  %r5,%r6
-
isync
+
/*
 * Perform a dummy stdcx. to clear any reservations we may have
 * inherited from the previous thread. It doesn't matter if the
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214610 - head/sys/powerpc/aim

2010-10-31 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Oct 31 23:04:15 2010
New Revision: 214610
URL: http://svn.freebsd.org/changeset/base/214610

Log:
  Add a security nit to recent copyin/out changes: map the user segment
  no-execute in case of exploitable kernel bugs.
  
  MFC after:1 week

Modified:
  head/sys/powerpc/aim/copyinout.c

Modified: head/sys/powerpc/aim/copyinout.c
==
--- head/sys/powerpc/aim/copyinout.cSun Oct 31 23:03:11 2010
(r214609)
+++ head/sys/powerpc/aim/copyinout.cSun Oct 31 23:04:15 2010
(r214610)
@@ -95,6 +95,9 @@ set_user_sr(pmap_t pm, const void *addr)
slbv = slb->slbv;
}
 
+   /* Mark segment no-execute */
+   slbv |= SLBV_N;
+
/* If we have already set this VSID, we can just return */
if (curthread->td_pcb->pcb_cpu.aim.usr_vsid == slbv) 
return;
@@ -117,6 +120,9 @@ set_user_sr(pmap_t pm, const void *addr)
if (curthread->td_pcb->pcb_cpu.aim.usr_vsid == vsid)
return;
 
+   /* Mark segment no-execute */
+   vsid |= SR_N;
+
__asm __volatile("isync");
curthread->td_pcb->pcb_cpu.aim.usr_vsid = vsid;
__asm __volatile("mtsr %0,%1; isync" :: "n"(USER_SR), "r"(vsid));
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r227775 - in head: lib/clang share/mk

2011-11-20 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Nov 21 00:49:46 2011
New Revision: 227775
URL: http://svn.freebsd.org/changeset/base/227775

Log:
  Connect LLVM/clang to the build on powerpc64. After the binutils 2.17.50
  import, it works without issue.

Modified:
  head/lib/clang/clang.build.mk
  head/share/mk/bsd.own.mk

Modified: head/lib/clang/clang.build.mk
==
--- head/lib/clang/clang.build.mk   Mon Nov 21 00:02:49 2011
(r227774)
+++ head/lib/clang/clang.build.mk   Mon Nov 21 00:49:46 2011
(r227775)
@@ -9,7 +9,7 @@ CFLAGS+=-I${LLVM_SRCS}/include -I${CLANG
-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS #-DNDEBUG
 
 # Correct for gcc miscompilation when compiling on PPC with -O2
-.if ${MACHINE_ARCH} == "powerpc"
+.if ${MACHINE_CPUARCH} == "powerpc"
 CFLAGS+= -O1
 .endif
 

Modified: head/share/mk/bsd.own.mk
==
--- head/share/mk/bsd.own.mkMon Nov 21 00:02:49 2011(r227774)
+++ head/share/mk/bsd.own.mkMon Nov 21 00:49:46 2011(r227775)
@@ -428,15 +428,14 @@ __T=${TARGET_ARCH}
 .else
 __T=${MACHINE_ARCH}
 .endif
-# Clang is only for x86 and 32-bit powerpc right now, by default.
-.if ${__T} == "amd64" || ${__T} == "i386" || ${__T} == "powerpc"
+# Clang is only for x86 and powerpc right now, by default.
+.if ${__T} == "amd64" || ${__T} == "i386" || ${__T:Mpowerpc*}
 __DEFAULT_YES_OPTIONS+=CLANG
 .else
 __DEFAULT_NO_OPTIONS+=CLANG
 .endif
-# FDT is needed only for arm, mips and powerpc (and not powerpc64)
-.if ${__T} == "arm" || ${__T} == "armeb" || ${__T} == "powerpc" || \
-${__T:Mmips*}
+# FDT is needed only for arm, mips and powerpc
+.if ${__T:Marm*} || ${__T:Mpowerpc*} || ${__T:Mmips*}
 __DEFAULT_YES_OPTIONS+=FDT
 .else
 __DEFAULT_NO_OPTIONS+=FDT
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r227779 - head/sys/powerpc/ps3

2011-11-20 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Nov 21 04:35:23 2011
New Revision: 227779
URL: http://svn.freebsd.org/changeset/base/227779

Log:
  The PPC IRQ layer assumes that the IPI IRQ is the last IRQ on the PIC.
  This assumption is invalid and the code should be fixed, but humor it for
  now and set the "IPI" for PS3s in the non-SMP case to a large number. This
  fixes boot with a non-SMP kernel.
  
  Submitted by: geoffrey dot levand at mail dot ru
  MFC after:1 week

Modified:
  head/sys/powerpc/ps3/ps3pic.c

Modified: head/sys/powerpc/ps3/ps3pic.c
==
--- head/sys/powerpc/ps3/ps3pic.c   Mon Nov 21 04:17:24 2011
(r227778)
+++ head/sys/powerpc/ps3/ps3pic.c   Mon Nov 21 04:35:23 2011
(r227779)
@@ -142,6 +142,8 @@ ps3pic_attach(device_t dev)
lv1_construct_event_receive_port(&sc->sc_ipi_outlet[1]);
lv1_connect_irq_plug_ext(ppe, !thread, sc->sc_ipi_outlet[0],
sc->sc_ipi_outlet[1], 0);
+#else
+   sc->sc_ipi_outlet[0] = sc->sc_ipi_outlet[1] = 63;
 #endif
 
powerpc_register_pic(dev, 0, sc->sc_ipi_outlet[0], 1, FALSE);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r228154 - svnadmin/conf

2011-11-30 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Wed Nov 30 14:17:20 2011
New Revision: 228154
URL: http://svn.freebsd.org/changeset/base/228154

Log:
  Welcome Justin Hibbits (jhibbits) as a new src committer! I'll be mentoring
  him and his initial work will be related to better support of Apple
  PowerPC hardware.
  
  Approved by:  core

Modified:
  svnadmin/conf/access
  svnadmin/conf/mentors

Modified: svnadmin/conf/access
==
--- svnadmin/conf/accessWed Nov 30 13:33:09 2011(r228153)
+++ svnadmin/conf/accessWed Nov 30 14:17:20 2011(r228154)
@@ -115,6 +115,7 @@ jfv
 jh
 jhay
 jhb
+jhibbits
 jilles
 jinmei
 jkim

Modified: svnadmin/conf/mentors
==
--- svnadmin/conf/mentors   Wed Nov 30 13:33:09 2011(r228153)
+++ svnadmin/conf/mentors   Wed Nov 30 14:17:20 2011(r228154)
@@ -18,6 +18,7 @@ eri   mlaier  Co-mentor: thompsa
 gber   cognet
 gleb   mdf
 jceel  wkoszek Co-mentor: cognet
+jhibbits   nwhitehorn
 jinmei gnn
 jonathan   rwatson
 jpaetzel   kib
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r228194 - head/usr.sbin/bsdinstall/scripts

2011-12-01 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Dec  2 02:05:26 2011
New Revision: 228194
URL: http://svn.freebsd.org/changeset/base/228194

Log:
  Prevent user astonishment by providing the shell option at the end, after
  any installer-provided configuration files have been copied. This allows
  users to edit their fstab, if desired, and to see what the installer has
  placed in rc.conf.
  
  Requested by: phk
  MFC after:1 day

Modified:
  head/usr.sbin/bsdinstall/scripts/auto

Modified: head/usr.sbin/bsdinstall/scripts/auto
==
--- head/usr.sbin/bsdinstall/scripts/auto   Fri Dec  2 01:06:33 2011
(r228193)
+++ head/usr.sbin/bsdinstall/scripts/auto   Fri Dec  2 02:05:26 2011
(r228194)
@@ -157,7 +157,7 @@ finalconfig() {
exec 3>&1
REVISIT=$(dialog --backtitle "FreeBSD Installer" \
--title "Final Configuration" --no-cancel --menu \
-   "Setup of your FreeBSD system is nearly complete. You can now 
modify your configuration choices or apply more complex changes using a shell." 
0 0 0 \
+   "Setup of your FreeBSD system is nearly complete. You can now 
modify your configuration choices. After this screen, you will have an 
opportunity to make more complex changes using a shell." 0 0 0 \
"Exit" "Apply configuration and exit installer" \
"Add User" "Add a user to the system" \
"Root Password" "Change root password" \
@@ -165,8 +165,7 @@ finalconfig() {
"Network" "Networking configuration" \
"Services" "Set daemons to run on startup" \
"Time Zone" "Set system timezone" \
-   "Handbook" "Install FreeBSD Handbook (requires network)" \
-   "Shell" "Open a shell in the new system" 2>&1 1>&3)
+   "Handbook" "Install FreeBSD Handbook (requires network)" 2>&1 
1>&3)
exec 3>&-
 
case "$REVISIT" in
@@ -198,15 +197,6 @@ finalconfig() {
bsdinstall docsinstall
finalconfig
;;
-   "Shell")
-   clear
-   echo This shell is operating in a chroot in the new system. \
-   When finished making configuration changes, type \"exit\".
-   chroot "$BSDINSTALL_CHROOT" /bin/sh 2>&1
-   # Don't hose local rc.conf changes
-   cp $BSDINSTALL_CHROOT/etc/rc.conf 
$BSDINSTALL_TMPETC/rc.conf.manual
-   finalconfig
-   ;;
esac
 }
 
@@ -222,5 +212,14 @@ if [ ! -z "$BSDINSTALL_FETCHDEST" ]; the
rm -rf "$BSDINSTALL_FETCHDEST"
 fi
 
+dialog --backtitle "FreeBSD Installer" --title "Manual Configuration" \
+--yesno "The installation is now finished. Before exiting the installer, 
would you like to open a shell in the new system to make any final manual 
modifications?" 0 0
+if [ $? -eq 0 ]; then
+   clear
+   echo This shell is operating in a chroot in the new system. \
+   When finished making configuration changes, type \"exit\".
+   chroot "$BSDINSTALL_CHROOT" /bin/sh 2>&1
+fi
+
 echo "Installation Completed at $(date)" >> $BSDINSTALL_LOG
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r228192 - head/usr.sbin/bsdinstall/scripts

2011-12-02 Thread Nathan Whitehorn

On 12/02/11 09:17, John Baldwin wrote:

On 12/2/11 4:44 AM, Joel Dahl wrote:

On 02-12-2011  0:38, Ken Smith wrote:

Author: kensmith
Date: Fri Dec  2 00:38:47 2011
New Revision: 228192
URL: http://svn.freebsd.org/changeset/base/228192

Log:
   Add a screen that asks if the user would like to enable crash dumps,
   giving them a very brief description of the trade-offs.  Whether the
   user opts in or out add an entry to what will become /etc/rc.conf
   explaining what dumpdev is and how to turn on/off crash dumps.  
The folks
   who handle interacting with users submitting PRs have asked for 
this.


Hmm. Two things I'd like to bring up:

* Not specifically aimed at this commit, but my recommendation
   would be that we keep bsdinstall as simple as possible: installing 
FreeBSD
   should require a minimum amount of keystrokes. I realise this is 
just one

   more screen, but I hope we don't turn bsdinstall into a configuration
   utility where you can disable/enable just about anything in rc.conf.

* Mentioning future system crashes during installation feels awkward. 
Is that
   really what we want? I understand the problem and how this helps 
us with
   debugging, but this is like saying to users that what they are 
installing
   is unstable and that it'll eventuelly crash and die. I know we 
discussed
   ways of making crash dumps smarter in order to not fill up /var, 
which in
   turn would allow us to always have it on. Maybe that is the right 
path?


All non-trivial software has bugs and eventually crashes.  I don't 
expect this to be a surprise to someone installing a UNIX-like 
operating system.  Note that this isn't the PC-BSD installer, but the 
FreeBSD installer.  Also, there have been long discussions about this 
and ample time for other patches to be developed but they haven't.  If 
you want this changed, implement the alternate solution.  Until then 
this is better than not having it at all.




This was also my conclusion when Ken asked me to review this patch. I 
also don't want the installer to become bloated and made the same 
original objection, but (a) this patch existed and (b) the long 
discussion meant that Ken felt it was a particular important decision 
that deserved its own screen. In particular, the explanation of why you 
might or might not want it was larger than could fit in a line in the 
regular services screen and the matter may require some thought.

-Nathan
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r228240 - stable/9/usr.sbin/bsdinstall/scripts

2011-12-03 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Dec  3 17:15:16 2011
New Revision: 228240
URL: http://svn.freebsd.org/changeset/base/228240

Log:
  MFC r228194:
  
  Prevent user astonishment by providing the shell option at the end, after
  any installer-provided configuration files have been copied. This allows
  users to edit their fstab, if desired, and to see what the installer has
  placed in rc.conf.
  
  Requested by: phk
  Approved by:  re (kensmith)

Modified:
  stable/9/usr.sbin/bsdinstall/scripts/auto
Directory Properties:
  stable/9/usr.sbin/bsdinstall/   (props changed)
  stable/9/usr.sbin/bsdinstall/scripts/   (props changed)

Modified: stable/9/usr.sbin/bsdinstall/scripts/auto
==
--- stable/9/usr.sbin/bsdinstall/scripts/auto   Sat Dec  3 17:03:48 2011
(r228239)
+++ stable/9/usr.sbin/bsdinstall/scripts/auto   Sat Dec  3 17:15:16 2011
(r228240)
@@ -157,7 +157,7 @@ finalconfig() {
exec 3>&1
REVISIT=$(dialog --backtitle "FreeBSD Installer" \
--title "Final Configuration" --no-cancel --menu \
-   "Setup of your FreeBSD system is nearly complete. You can now 
modify your configuration choices or apply more complex changes using a shell." 
0 0 0 \
+   "Setup of your FreeBSD system is nearly complete. You can now 
modify your configuration choices. After this screen, you will have an 
opportunity to make more complex changes using a shell." 0 0 0 \
"Exit" "Apply configuration and exit installer" \
"Add User" "Add a user to the system" \
"Root Password" "Change root password" \
@@ -165,8 +165,7 @@ finalconfig() {
"Network" "Networking configuration" \
"Services" "Set daemons to run on startup" \
"Time Zone" "Set system timezone" \
-   "Handbook" "Install FreeBSD Handbook (requires network)" \
-   "Shell" "Open a shell in the new system" 2>&1 1>&3)
+   "Handbook" "Install FreeBSD Handbook (requires network)" 2>&1 
1>&3)
exec 3>&-
 
case "$REVISIT" in
@@ -198,15 +197,6 @@ finalconfig() {
bsdinstall docsinstall
finalconfig
;;
-   "Shell")
-   clear
-   echo This shell is operating in a chroot in the new system. \
-   When finished making configuration changes, type \"exit\".
-   chroot "$BSDINSTALL_CHROOT" /bin/sh 2>&1
-   # Don't hose local rc.conf changes
-   cp $BSDINSTALL_CHROOT/etc/rc.conf 
$BSDINSTALL_TMPETC/rc.conf.manual
-   finalconfig
-   ;;
esac
 }
 
@@ -222,5 +212,14 @@ if [ ! -z "$BSDINSTALL_FETCHDEST" ]; the
rm -rf "$BSDINSTALL_FETCHDEST"
 fi
 
+dialog --backtitle "FreeBSD Installer" --title "Manual Configuration" \
+--yesno "The installation is now finished. Before exiting the installer, 
would you like to open a shell in the new system to make any final manual 
modifications?" 0 0
+if [ $? -eq 0 ]; then
+   clear
+   echo This shell is operating in a chroot in the new system. \
+   When finished making configuration changes, type \"exit\".
+   chroot "$BSDINSTALL_CHROOT" /bin/sh 2>&1
+fi
+
 echo "Installation Completed at $(date)" >> $BSDINSTALL_LOG
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r228241 - releng/9.0/usr.sbin/bsdinstall/scripts

2011-12-03 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Dec  3 17:17:32 2011
New Revision: 228241
URL: http://svn.freebsd.org/changeset/base/228241

Log:
  MFC r228194, MF9 r228240:
  
  Prevent user astonishment by providing the shell option at the end, after
  any installer-provided configuration files have been copied. This allows
  users to edit their fstab, if desired, and to see what the installer has
  placed in rc.conf.
  
  Requested by: phk
  Approved by:  re (kensmith)

Modified:
  releng/9.0/usr.sbin/bsdinstall/scripts/auto
Directory Properties:
  releng/9.0/usr.sbin/bsdinstall/   (props changed)
  releng/9.0/usr.sbin/bsdinstall/scripts/   (props changed)

Modified: releng/9.0/usr.sbin/bsdinstall/scripts/auto
==
--- releng/9.0/usr.sbin/bsdinstall/scripts/auto Sat Dec  3 17:15:16 2011
(r228240)
+++ releng/9.0/usr.sbin/bsdinstall/scripts/auto Sat Dec  3 17:17:32 2011
(r228241)
@@ -157,7 +157,7 @@ finalconfig() {
exec 3>&1
REVISIT=$(dialog --backtitle "FreeBSD Installer" \
--title "Final Configuration" --no-cancel --menu \
-   "Setup of your FreeBSD system is nearly complete. You can now 
modify your configuration choices or apply more complex changes using a shell." 
0 0 0 \
+   "Setup of your FreeBSD system is nearly complete. You can now 
modify your configuration choices. After this screen, you will have an 
opportunity to make more complex changes using a shell." 0 0 0 \
"Exit" "Apply configuration and exit installer" \
"Add User" "Add a user to the system" \
"Root Password" "Change root password" \
@@ -165,8 +165,7 @@ finalconfig() {
"Network" "Networking configuration" \
"Services" "Set daemons to run on startup" \
"Time Zone" "Set system timezone" \
-   "Handbook" "Install FreeBSD Handbook (requires network)" \
-   "Shell" "Open a shell in the new system" 2>&1 1>&3)
+   "Handbook" "Install FreeBSD Handbook (requires network)" 2>&1 
1>&3)
exec 3>&-
 
case "$REVISIT" in
@@ -198,15 +197,6 @@ finalconfig() {
bsdinstall docsinstall
finalconfig
;;
-   "Shell")
-   clear
-   echo This shell is operating in a chroot in the new system. \
-   When finished making configuration changes, type \"exit\".
-   chroot "$BSDINSTALL_CHROOT" /bin/sh 2>&1
-   # Don't hose local rc.conf changes
-   cp $BSDINSTALL_CHROOT/etc/rc.conf 
$BSDINSTALL_TMPETC/rc.conf.manual
-   finalconfig
-   ;;
esac
 }
 
@@ -222,5 +212,14 @@ if [ ! -z "$BSDINSTALL_FETCHDEST" ]; the
rm -rf "$BSDINSTALL_FETCHDEST"
 fi
 
+dialog --backtitle "FreeBSD Installer" --title "Manual Configuration" \
+--yesno "The installation is now finished. Before exiting the installer, 
would you like to open a shell in the new system to make any final manual 
modifications?" 0 0
+if [ $? -eq 0 ]; then
+   clear
+   echo This shell is operating in a chroot in the new system. \
+   When finished making configuration changes, type \"exit\".
+   chroot "$BSDINSTALL_CHROOT" /bin/sh 2>&1
+fi
+
 echo "Installation Completed at $(date)" >> $BSDINSTALL_LOG
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r228412 - in head/sys/powerpc: aim include

2011-12-11 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Dec 11 17:19:48 2011
New Revision: 228412
URL: http://svn.freebsd.org/changeset/base/228412

Log:
  Keep track of PVO entries in each pmap, which allows much faster
  pmap_remove() for large sparse requests. This can prevent pmap_remove()
  operations on 64-bit process destruction or swapout that would take
  several hundred times the lifetime of the universe to complete. This
  behavior is largely indistinguishable from a hang.

Modified:
  head/sys/powerpc/aim/mmu_oea.c
  head/sys/powerpc/aim/mmu_oea64.c
  head/sys/powerpc/include/pmap.h

Modified: head/sys/powerpc/aim/mmu_oea.c
==
--- head/sys/powerpc/aim/mmu_oea.c  Sun Dec 11 17:10:33 2011
(r228411)
+++ head/sys/powerpc/aim/mmu_oea.c  Sun Dec 11 17:19:48 2011
(r228412)
@@ -824,6 +824,7 @@ moea_bootstrap(mmu_t mmup, vm_offset_t k
for (i = 0; i < 16; i++)
kernel_pmap->pm_sr[i] = EMPTY_SEGMENT + i;
CPU_FILL(&kernel_pmap->pm_active);
+   LIST_INIT(&kernel_pmap->pmap_pvo);
 
/*
 * Set up the Open Firmware mappings
@@ -1582,6 +1583,7 @@ moea_pinit(mmu_t mmu, pmap_t pmap)
 
KASSERT((int)pmap < VM_MIN_KERNEL_ADDRESS, ("moea_pinit: virt pmap"));
PMAP_LOCK_INIT(pmap);
+   LIST_INIT(&pmap->pmap_pvo);
 
entropy = 0;
__asm __volatile("mftb %0" : "=r"(entropy));
@@ -1765,10 +1767,17 @@ moea_remove(mmu_t mmu, pmap_t pm, vm_off
 
vm_page_lock_queues();
PMAP_LOCK(pm);
-   for (; sva < eva; sva += PAGE_SIZE) {
-   pvo = moea_pvo_find_va(pm, sva, &pteidx);
-   if (pvo != NULL) {
-   moea_pvo_remove(pvo, pteidx);
+   if ((eva - sva)/PAGE_SIZE < 10) {
+   for (; sva < eva; sva += PAGE_SIZE) {
+   pvo = moea_pvo_find_va(pm, sva, &pteidx);
+   if (pvo != NULL)
+   moea_pvo_remove(pvo, pteidx);
+   }
+   } else {
+   LIST_FOREACH(pvo, &pm->pmap_pvo, pvo_plink) {
+   if (PVO_VADDR(pvo) < sva || PVO_VADDR(pvo) >= eva)
+   continue;
+   moea_pvo_remove(pvo, -1);
}
}
PMAP_UNLOCK(pm);
@@ -1931,6 +1940,11 @@ moea_pvo_enter(pmap_t pm, uma_zone_t zon
moea_pte_create(&pvo->pvo_pte.pte, sr, va, pa | pte_lo);
 
/*
+* Add to pmap list
+*/
+   LIST_INSERT_HEAD(&pm->pmap_pvo, pvo, pvo_plink);
+
+   /*
 * Remember if the list was empty and therefore will be the first
 * item.
 */
@@ -1996,9 +2010,10 @@ moea_pvo_remove(struct pvo_entry *pvo, i
}
 
/*
-* Remove this PVO from the PV list.
+* Remove this PVO from the PV and pmap lists.
 */
LIST_REMOVE(pvo, pvo_vlink);
+   LIST_REMOVE(pvo, pvo_plink);
 
/*
 * Remove this from the overflow list and return it to the pool

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cSun Dec 11 17:10:33 2011
(r228411)
+++ head/sys/powerpc/aim/mmu_oea64.cSun Dec 11 17:19:48 2011
(r228412)
@@ -831,6 +831,7 @@ moea64_mid_bootstrap(mmu_t mmup, vm_offs
 
kernel_pmap->pmap_phys = kernel_pmap;
CPU_FILL(&kernel_pmap->pm_active);
+   LIST_INIT(&kernel_pmap->pmap_pvo);
 
PMAP_LOCK_INIT(kernel_pmap);
 
@@ -1855,6 +1856,7 @@ void
 moea64_pinit(mmu_t mmu, pmap_t pmap)
 {
PMAP_LOCK_INIT(pmap);
+   LIST_INIT(&pmap->pmap_pvo);
 
pmap->pm_slb_tree_root = slb_alloc_tree();
pmap->pm_slb = slb_alloc_user_cache();
@@ -1868,6 +1870,7 @@ moea64_pinit(mmu_t mmu, pmap_t pmap)
uint32_t hash;
 
PMAP_LOCK_INIT(pmap);
+   LIST_INIT(&pmap->pmap_pvo);
 
if (pmap_bootstrapped)
pmap->pmap_phys = (pmap_t)moea64_kextract(mmu,
@@ -2034,10 +2037,18 @@ moea64_remove(mmu_t mmu, pmap_t pm, vm_o
 
vm_page_lock_queues();
PMAP_LOCK(pm);
-   for (; sva < eva; sva += PAGE_SIZE) {
-   pvo = moea64_pvo_find_va(pm, sva);
-   if (pvo != NULL)
+   if ((eva - sva)/PAGE_SIZE < 10) {
+   for (; sva < eva; sva += PAGE_SIZE) {
+   pvo = moea64_pvo_find_va(pm, sva);
+   if (pvo != NULL)
+   moea64_pvo_remove(mmu, pvo);
+   }
+   } else {
+   LIST_FOREACH(pvo, &pm->pmap_pvo, pvo_plink) {
+   if (PVO_VADDR(pvo) < sva || PVO_VADDR(pvo) >= eva)
+   continue;
moea64_pvo_remove(mmu, pvo);
+   }
}
vm_page_unlock_queues();
PMAP_UNLOCK(pm);
@@ -2231,6 +2242,11 @@ moea64_pvo_enter(mmu_t mmu, pmap_t pm, u
(uint64_t

svn commit: r228413 - head/sys/powerpc/include

2011-12-11 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Dec 11 17:23:03 2011
New Revision: 228413
URL: http://svn.freebsd.org/changeset/base/228413

Log:
  Increase the available virtual address space for user programs on PowerPC
  AIM systems to 4 GB on 32-bit systems and 2^64 bytes on 64-bit systems.
  VM_MAXUSER_ADDRESS remains at 2 GB on pending Book-E, pending review of
  an increase to 3 GB by those more familiar with Book-E.

Modified:
  head/sys/powerpc/include/vmparam.h

Modified: head/sys/powerpc/include/vmparam.h
==
--- head/sys/powerpc/include/vmparam.h  Sun Dec 11 17:19:48 2011
(r228412)
+++ head/sys/powerpc/include/vmparam.h  Sun Dec 11 17:23:03 2011
(r228413)
@@ -57,29 +57,34 @@
 #defineMAXSSIZ (64*1024*1024)  /* max stack size */
 #endif
 
+#ifdef AIM
+#defineVM_MAXUSER_ADDRESS32((vm_offset_t)0xf000)
+#else
+#defineVM_MAXUSER_ADDRESS32((vm_offset_t)0x7000)
+#endif
+
 /*
  * Would like to have MAX addresses = 0, but this doesn't (currently) work
  */
 #if !defined(LOCORE)
 #ifdef __powerpc64__
 #defineVM_MIN_ADDRESS  (0xUL)
-#defineVM_MAXUSER_ADDRESS  (0x7000UL)
-#defineSHAREDPAGE  (VM_MAXUSER_ADDRESS - PAGE_SIZE)
+#defineVM_MAXUSER_ADDRESS  (0xf000UL)
 #defineVM_MAX_ADDRESS  (0xUL)
 #else
 #defineVM_MIN_ADDRESS  ((vm_offset_t)0)
-#defineVM_MAXUSER_ADDRESS  ((vm_offset_t)0x7000)
-#defineSHAREDPAGE  (VM_MAXUSER_ADDRESS - PAGE_SIZE)
-#defineVM_MAX_ADDRESS  VM_MAXUSER_ADDRESS
+#defineVM_MAXUSER_ADDRESS  VM_MAXUSER_ADDRESS32
+#defineVM_MAX_ADDRESS  ((vm_offset_t)0x)
 #endif
+#defineSHAREDPAGE  (VM_MAXUSER_ADDRESS - PAGE_SIZE)
 #else /* LOCORE */
-#ifndef __powerpc64__
+#if !defined(__powerpc64__) && defined(E500)
 #defineVM_MIN_ADDRESS  0
 #defineVM_MAXUSER_ADDRESS  0x7000
 #endif
 #endif /* LOCORE */
 
-#defineFREEBSD32_SHAREDPAGE(0x7000 - PAGE_SIZE)
+#defineFREEBSD32_SHAREDPAGE(VM_MAXUSER_ADDRESS32 - PAGE_SIZE)
 #defineFREEBSD32_USRSTACK  FREEBSD32_SHAREDPAGE
 
 #ifdef AIM
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r228605 - head/sys/powerpc/aim

2011-12-16 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Dec 16 23:40:56 2011
New Revision: 228605
URL: http://svn.freebsd.org/changeset/base/228605

Log:
  Zero BSS on start, in case the ELF loader that started the kernel did not
  do this for us. This can happen on some embedded systems.
  
  Submitted by: rpaulo

Modified:
  head/sys/powerpc/aim/locore32.S

Modified: head/sys/powerpc/aim/locore32.S
==
--- head/sys/powerpc/aim/locore32.S Fri Dec 16 23:15:11 2011
(r228604)
+++ head/sys/powerpc/aim/locore32.S Fri Dec 16 23:40:56 2011
(r228605)
@@ -128,6 +128,17 @@ __start:
sync
isync
 
+   /* Zero bss, in case we were started by something unhelpful */
+   li  0,0
+   lis 8,_edata@ha
+   addi8,8,_edata@l
+   lis 9,_end@ha
+   addi9,9,_end@l
+2: stw 0,0(8)
+   addi8,8,4
+   cmplw   8,9
+   blt 2b
+   
/* Save the argument pointer and length */
mr  20,6
mr  21,7
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r228609 - head/sys/powerpc/aim

2011-12-16 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Dec 16 23:46:05 2011
New Revision: 228609
URL: http://svn.freebsd.org/changeset/base/228609

Log:
  Allow this to work on embedded systems without Open Firmware by making
  lack of a /chosen non-fatal, and manually removing memory in use by the
  kernel from the physical memory map.
  
  Submitted by: rpaulo

Modified:
  head/sys/powerpc/aim/mmu_oea.c

Modified: head/sys/powerpc/aim/mmu_oea.c
==
--- head/sys/powerpc/aim/mmu_oea.c  Fri Dec 16 23:44:16 2011
(r228608)
+++ head/sys/powerpc/aim/mmu_oea.c  Fri Dec 16 23:46:05 2011
(r228609)
@@ -153,6 +153,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include "mmu_if.h"
 
@@ -759,6 +760,38 @@ moea_bootstrap(mmu_t mmup, vm_offset_t k
phys_avail_count++;
physsz += regions[i].mr_size;
}
+
+   /* Check for overlap with the kernel and exception vectors */
+   for (j = 0; j < 2*phys_avail_count; j+=2) {
+   if (phys_avail[j] < EXC_LAST)
+   phys_avail[j] += EXC_LAST;
+
+   if (kernelstart >= phys_avail[j] &&
+   kernelstart < phys_avail[j+1]) {
+   if (kernelend < phys_avail[j+1]) {
+   phys_avail[2*phys_avail_count] =
+   (kernelend & ~PAGE_MASK) + PAGE_SIZE;
+   phys_avail[2*phys_avail_count + 1] =
+   phys_avail[j+1];
+   phys_avail_count++;
+   }
+
+   phys_avail[j+1] = kernelstart & ~PAGE_MASK;
+   }
+
+   if (kernelend >= phys_avail[j] &&
+   kernelend < phys_avail[j+1]) {
+   if (kernelstart > phys_avail[j]) {
+   phys_avail[2*phys_avail_count] = phys_avail[j];
+   phys_avail[2*phys_avail_count + 1] =
+   kernelstart & ~PAGE_MASK;
+   phys_avail_count++;
+   }
+
+   phys_avail[j] = (kernelend & ~PAGE_MASK) + PAGE_SIZE;
+   }
+   }
+
physmem = btoc(physsz);
 
/*
@@ -829,44 +862,43 @@ moea_bootstrap(mmu_t mmup, vm_offset_t k
/*
 * Set up the Open Firmware mappings
 */
-   if ((chosen = OF_finddevice("/chosen")) == -1)
-   panic("moea_bootstrap: can't find /chosen");
-   OF_getprop(chosen, "mmu", &mmui, 4);
-   if ((mmu = OF_instance_to_package(mmui)) == -1)
-   panic("moea_bootstrap: can't get mmu package");
-   if ((sz = OF_getproplen(mmu, "translations")) == -1)
-   panic("moea_bootstrap: can't get ofw translation count");
-   translations = NULL;
-   for (i = 0; phys_avail[i] != 0; i += 2) {
-   if (phys_avail[i + 1] >= sz) {
-   translations = (struct ofw_map *)phys_avail[i];
-   break;
+   chosen = OF_finddevice("/chosen");
+   if (chosen != -1 && OF_getprop(chosen, "mmu", &mmui, 4) != -1 &&
+   (mmu = OF_instance_to_package(mmui)) != -1 && 
+   (sz = OF_getproplen(mmu, "translations")) != -1) {
+   translations = NULL;
+   for (i = 0; phys_avail[i] != 0; i += 2) {
+   if (phys_avail[i + 1] >= sz) {
+   translations = (struct ofw_map *)phys_avail[i];
+   break;
+   }
}
-   }
-   if (translations == NULL)
-   panic("moea_bootstrap: no space to copy translations");
-   bzero(translations, sz);
-   if (OF_getprop(mmu, "translations", translations, sz) == -1)
-   panic("moea_bootstrap: can't get ofw translations");
-   CTR0(KTR_PMAP, "moea_bootstrap: translations");
-   sz /= sizeof(*translations);
-   qsort(translations, sz, sizeof (*translations), om_cmp);
-   for (i = 0; i < sz; i++) {
-   CTR3(KTR_PMAP, "translation: pa=%#x va=%#x len=%#x",
-   translations[i].om_pa, translations[i].om_va,
-   translations[i].om_len);
+   if (translations == NULL)
+   panic("moea_bootstrap: no space to copy translations");
+   bzero(translations, sz);
+   if (OF_getprop(mmu, "translations", translations, sz) == -1)
+   panic("moea_bootstrap: can't get ofw translations");
+   CTR0(KTR_PMAP, "moea_bootstrap: translations");
+   sz /= sizeof(*translations);
+   qsort(translations, sz, sizeof (*translations), om_cmp);
+   for (i = 0; i < sz; i++) {
+   CTR3(KTR_PMAP, "translation: pa=%#x va=%#x len=%#x",
+   translati

Re: svn commit: r228435 - in head/libexec/rtld-elf: . amd64 arm i386 ia64 mips powerpc powerpc64 sparc64

2011-12-17 Thread Nathan Whitehorn
This broke PowerPC really, really badly. Basically every 
dynamically-linked executable dies with an illegal instruction trap.

-Nathan

On 12/12/11 05:03, Konstantin Belousov wrote:

Author: kib
Date: Mon Dec 12 11:03:14 2011
New Revision: 228435
URL: http://svn.freebsd.org/changeset/base/228435

Log:
   Add support for STT_GNU_IFUNC and R_MACHINE_IRELATIVE GNU extensions to
   rtld on 386 and amd64. This adds runtime bits neccessary for the use
   of the dispatch functions from the dynamically-linked executables and
   shared libraries.

   To allow use of external references from the dispatch function, resolution
   of the R_MACHINE_IRESOLVE relocations in PLT is postponed until GOT entries
   for PLT are prepared, and normal resolution of the GOT entries is finished.
   Similar to how it is done by GNU, IRELATIVE relocations are resolved in
   advance, instead of normal lazy handling for PLT.

   Move the init_pltgot() call before the relocations for the object are
   processed.

   MFC after:   3 weeks

Modified:
   head/libexec/rtld-elf/amd64/reloc.c
   head/libexec/rtld-elf/arm/reloc.c
   head/libexec/rtld-elf/i386/reloc.c
   head/libexec/rtld-elf/ia64/reloc.c
   head/libexec/rtld-elf/mips/reloc.c
   head/libexec/rtld-elf/powerpc/reloc.c
   head/libexec/rtld-elf/powerpc64/reloc.c
   head/libexec/rtld-elf/rtld.c
   head/libexec/rtld-elf/rtld.h
   head/libexec/rtld-elf/sparc64/reloc.c

Modified: head/libexec/rtld-elf/amd64/reloc.c
==
--- head/libexec/rtld-elf/amd64/reloc.c Mon Dec 12 10:10:49 2011
(r228434)
+++ head/libexec/rtld-elf/amd64/reloc.c Mon Dec 12 11:03:14 2011
(r228435)
@@ -344,11 +344,22 @@ reloc_plt(Obj_Entry *obj)
  for (rela = obj->pltrela;  rela<  relalim;  rela++) {
Elf_Addr *where;

-   assert(ELF_R_TYPE(rela->r_info) == R_X86_64_JMP_SLOT);
-
-   /* Relocate the GOT slot pointing into the PLT. */
-   where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
-   *where += (Elf_Addr)obj->relocbase;
+   switch(ELF_R_TYPE(rela->r_info)) {
+   case R_X86_64_JMP_SLOT:
+ /* Relocate the GOT slot pointing into the PLT. */
+ where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
+ *where += (Elf_Addr)obj->relocbase;
+ break;
+
+   case R_X86_64_IRELATIVE:
+ obj->irelative = true;
+ break;
+
+   default:
+ _rtld_error("Unknown relocation type %x in PLT",
+   (unsigned int)ELF_R_TYPE(rela->r_info));
+ return (-1);
+   }
  }
  return 0;
  }
@@ -368,19 +379,91 @@ reloc_jmpslots(Obj_Entry *obj, RtldLockS
const Elf_Sym *def;
const Obj_Entry *defobj;

-   assert(ELF_R_TYPE(rela->r_info) == R_X86_64_JMP_SLOT);
-   where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
-   def = find_symdef(ELF_R_SYM(rela->r_info), obj,&defobj, true, NULL,
-   lockstate);
-   if (def == NULL)
-   return -1;
-   target = (Elf_Addr)(defobj->relocbase + def->st_value + rela->r_addend);
-   reloc_jmpslot(where, target, defobj, obj, (const Elf_Rel *)rela);
+   switch (ELF_R_TYPE(rela->r_info)) {
+   case R_X86_64_JMP_SLOT:
+ where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
+ def = find_symdef(ELF_R_SYM(rela->r_info), obj,&defobj, true, NULL,
+ lockstate);
+ if (def == NULL)
+ return (-1);
+ if (ELF_ST_TYPE(def->st_info) == STT_GNU_IFUNC) {
+ obj->gnu_ifunc = true;
+ continue;
+ }
+ target = (Elf_Addr)(defobj->relocbase + def->st_value + 
rela->r_addend);
+ reloc_jmpslot(where, target, defobj, obj, (const Elf_Rel *)rela);
+ break;
+
+   case R_X86_64_IRELATIVE:
+ break;
+
+   default:
+ _rtld_error("Unknown relocation type %x in PLT",
+   (unsigned int)ELF_R_TYPE(rela->r_info));
+ return (-1);
+   }
  }
  obj->jmpslots_done = true;
  return 0;
  }

+int
+reloc_iresolve(Obj_Entry *obj, RtldLockState *lockstate)
+{
+const Elf_Rela *relalim;
+const Elf_Rela *rela;
+
+relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
+for (rela = obj->pltrela;  rela<  relalim;  rela++) {
+   Elf_Addr *where, target, *ptr;
+
+   switch (ELF_R_TYPE(rela->r_info)) {
+   case R_X86_64_JMP_SLOT:
+ break;
+
+   case R_X86_64_IRELATIVE:
+ ptr = (Elf_Addr *)(obj->relocbase + rela->r_addend);
+ where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
+ target = ((Elf_Addr (*)(void))ptr)();
+ *where = target;
+ break;
+   }
+}
+return (0);
+}
+
+int
+reloc_gnu_ifunc(Obj_Entry *obj, RtldLockState *lockstate)
+{
+const Elf_Rela *relalim;
+const Elf_Rela *rela;
+
+if (!obj->gnu_ifunc)
+   return (0);
+relalim = (const Elf_Rela *)((char *)obj->pltrela + obj->pltrelasize);
+for (r

svn commit: r228635 - head/libexec/rtld-elf/powerpc

2011-12-17 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Dec 17 15:31:00 2011
New Revision: 228635
URL: http://svn.freebsd.org/changeset/base/228635

Log:
  Fix RTLD on PowerPC after r228435. Changing the order of init_pltgot()
  caused the icache to be invalidated at the wrong time, resulting in
  an icache full of nonsense in the PLT section.

Modified:
  head/libexec/rtld-elf/powerpc/reloc.c

Modified: head/libexec/rtld-elf/powerpc/reloc.c
==
--- head/libexec/rtld-elf/powerpc/reloc.c   Sat Dec 17 15:26:34 2011
(r228634)
+++ head/libexec/rtld-elf/powerpc/reloc.c   Sat Dec 17 15:31:00 2011
(r228635)
@@ -366,7 +366,7 @@ reloc_plt_object(Obj_Entry *obj, const E

 
/*
-* The icache will be sync'd in init_pltgot, which is called
+* The icache will be sync'd in reloc_plt, which is called
 * after all the slots have been updated
 */
 
@@ -382,6 +382,7 @@ reloc_plt(Obj_Entry *obj)
 {
const Elf_Rela *relalim;
const Elf_Rela *rela;
+   int N = obj->pltrelasize / sizeof(Elf_Rela);
 
if (obj->pltrelasize != 0) {
 
@@ -396,6 +397,13 @@ reloc_plt(Obj_Entry *obj)
}
}
 
+   /*
+* Sync the icache for the byte range represented by the
+* trampoline routines and call slots.
+*/
+   if (obj->pltgot != NULL)
+   __syncicache(obj->pltgot, JMPTAB_BASE(N)*4);
+
return (0);
 }
 
@@ -595,10 +603,9 @@ init_pltgot(Obj_Entry *obj)
pltresolve[4] |= _ppc_la(obj);
 
/*
-* Sync the icache for the byte range represented by the
-* trampoline routines and call slots.
+* The icache will be sync'd in reloc_plt, which is called
+* after all the slots have been updated
 */
-   __syncicache(obj->pltgot, JMPTAB_BASE(N)*4);
 }
 
 void
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r228435 - in head/libexec/rtld-elf: . amd64 arm i386 ia64 mips powerpc powerpc64 sparc64

2011-12-17 Thread Nathan Whitehorn

Fixed in r228635.
-Nathan

On 12/17/11 09:09, Nathan Whitehorn wrote:
This broke PowerPC really, really badly. Basically every 
dynamically-linked executable dies with an illegal instruction trap.

-Nathan

On 12/12/11 05:03, Konstantin Belousov wrote:

Author: kib
Date: Mon Dec 12 11:03:14 2011
New Revision: 228435
URL: http://svn.freebsd.org/changeset/base/228435

Log:
   Add support for STT_GNU_IFUNC and R_MACHINE_IRELATIVE GNU 
extensions to

   rtld on 386 and amd64. This adds runtime bits neccessary for the use
   of the dispatch functions from the dynamically-linked executables and
   shared libraries.

   To allow use of external references from the dispatch function, 
resolution
   of the R_MACHINE_IRESOLVE relocations in PLT is postponed until 
GOT entries
   for PLT are prepared, and normal resolution of the GOT entries is 
finished.
   Similar to how it is done by GNU, IRELATIVE relocations are 
resolved in

   advance, instead of normal lazy handling for PLT.

   Move the init_pltgot() call before the relocations for the object are
   processed.

   MFC after:3 weeks

Modified:
   head/libexec/rtld-elf/amd64/reloc.c
   head/libexec/rtld-elf/arm/reloc.c
   head/libexec/rtld-elf/i386/reloc.c
   head/libexec/rtld-elf/ia64/reloc.c
   head/libexec/rtld-elf/mips/reloc.c
   head/libexec/rtld-elf/powerpc/reloc.c
   head/libexec/rtld-elf/powerpc64/reloc.c
   head/libexec/rtld-elf/rtld.c
   head/libexec/rtld-elf/rtld.h
   head/libexec/rtld-elf/sparc64/reloc.c

Modified: head/libexec/rtld-elf/amd64/reloc.c
== 

--- head/libexec/rtld-elf/amd64/reloc.cMon Dec 12 10:10:49 
2011(r228434)
+++ head/libexec/rtld-elf/amd64/reloc.cMon Dec 12 11:03:14 
2011(r228435)

@@ -344,11 +344,22 @@ reloc_plt(Obj_Entry *obj)
  for (rela = obj->pltrela;  rela<  relalim;  rela++) {
  Elf_Addr *where;

-assert(ELF_R_TYPE(rela->r_info) == R_X86_64_JMP_SLOT);
-
-/* Relocate the GOT slot pointing into the PLT. */
-where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
-*where += (Elf_Addr)obj->relocbase;
+switch(ELF_R_TYPE(rela->r_info)) {
+case R_X86_64_JMP_SLOT:
+  /* Relocate the GOT slot pointing into the PLT. */
+  where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
+  *where += (Elf_Addr)obj->relocbase;
+  break;
+
+case R_X86_64_IRELATIVE:
+  obj->irelative = true;
+  break;
+
+default:
+  _rtld_error("Unknown relocation type %x in PLT",
+(unsigned int)ELF_R_TYPE(rela->r_info));
+  return (-1);
+}
  }
  return 0;
  }
@@ -368,19 +379,91 @@ reloc_jmpslots(Obj_Entry *obj, RtldLockS
  const Elf_Sym *def;
  const Obj_Entry *defobj;

-assert(ELF_R_TYPE(rela->r_info) == R_X86_64_JMP_SLOT);
-where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
-def = find_symdef(ELF_R_SYM(rela->r_info), obj,&defobj, true, NULL,
-lockstate);
-if (def == NULL)
-return -1;
-target = (Elf_Addr)(defobj->relocbase + def->st_value + 
rela->r_addend);

-reloc_jmpslot(where, target, defobj, obj, (const Elf_Rel *)rela);
+switch (ELF_R_TYPE(rela->r_info)) {
+case R_X86_64_JMP_SLOT:
+  where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
+  def = find_symdef(ELF_R_SYM(rela->r_info), obj,&defobj, true, 
NULL,

+  lockstate);
+  if (def == NULL)
+  return (-1);
+  if (ELF_ST_TYPE(def->st_info) == STT_GNU_IFUNC) {
+  obj->gnu_ifunc = true;
+  continue;
+  }
+  target = (Elf_Addr)(defobj->relocbase + def->st_value + 
rela->r_addend);

+  reloc_jmpslot(where, target, defobj, obj, (const Elf_Rel *)rela);
+  break;
+
+case R_X86_64_IRELATIVE:
+  break;
+
+default:
+  _rtld_error("Unknown relocation type %x in PLT",
+(unsigned int)ELF_R_TYPE(rela->r_info));
+  return (-1);
+}
  }
  obj->jmpslots_done = true;
  return 0;
  }

+int
+reloc_iresolve(Obj_Entry *obj, RtldLockState *lockstate)
+{
+const Elf_Rela *relalim;
+const Elf_Rela *rela;
+
+relalim = (const Elf_Rela *)((char *)obj->pltrela + 
obj->pltrelasize);

+for (rela = obj->pltrela;  rela<  relalim;  rela++) {
+Elf_Addr *where, target, *ptr;
+
+switch (ELF_R_TYPE(rela->r_info)) {
+case R_X86_64_JMP_SLOT:
+  break;
+
+case R_X86_64_IRELATIVE:
+  ptr = (Elf_Addr *)(obj->relocbase + rela->r_addend);
+  where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
+  target = ((Elf_Addr (*)(void))ptr)();
+  *where = target;
+  break;
+}
+}
+return (0);
+}
+
+int
+reloc_gnu_ifunc(Obj_Entry *obj, RtldLockState *lockstate)
+{
+const Elf_Rela *relalim;
+const Elf_Rela *rela;
+
+if (!obj->gnu_ifunc)
+return (0);
+relalim = (const Elf_Rel

svn commit: r228646 - in head/libexec/rtld-elf: powerpc powerpc64

2011-12-17 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Dec 17 16:20:27 2011
New Revision: 228646
URL: http://svn.freebsd.org/changeset/base/228646

Log:
  Additional icache paranoia: non-PLT relocations can modify the text segment.
  It is then important to make sure the icache is synchronized again to
  prevent (rare) random seg faults and illegal instructions.
  
  MFC after:3 days

Modified:
  head/libexec/rtld-elf/powerpc/reloc.c
  head/libexec/rtld-elf/powerpc64/reloc.c

Modified: head/libexec/rtld-elf/powerpc/reloc.c
==
--- head/libexec/rtld-elf/powerpc/reloc.c   Sat Dec 17 16:10:14 2011
(r228645)
+++ head/libexec/rtld-elf/powerpc/reloc.c   Sat Dec 17 16:20:27 2011
(r228646)
@@ -317,6 +317,10 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry 
 done:
if (cache != NULL)
free(cache);
+
+   /* Synchronize icache for text seg in case we made any changes */
+   __syncicache(obj->mapbase, obj->textsize);
+
return (r);
 }
 

Modified: head/libexec/rtld-elf/powerpc64/reloc.c
==
--- head/libexec/rtld-elf/powerpc64/reloc.c Sat Dec 17 16:10:14 2011
(r228645)
+++ head/libexec/rtld-elf/powerpc64/reloc.c Sat Dec 17 16:20:27 2011
(r228646)
@@ -313,9 +313,12 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry 
}
r = 0;
 done:
-   if (cache) {
+   if (cache)
munmap(cache, bytes);
-   }
+
+   /* Synchronize icache for text seg in case we made any changes */
+   __syncicache(obj->mapbase, obj->textsize);
+
return (r);
 }
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r228688 - head/sys/powerpc/ps3

2011-12-18 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Dec 18 16:53:03 2011
New Revision: 228688
URL: http://svn.freebsd.org/changeset/base/228688

Log:
  Add version header to output file.

Modified:
  head/sys/powerpc/ps3/ps3-hv-asm.awk

Modified: head/sys/powerpc/ps3/ps3-hv-asm.awk
==
--- head/sys/powerpc/ps3/ps3-hv-asm.awk Sun Dec 18 15:36:21 2011
(r228687)
+++ head/sys/powerpc/ps3/ps3-hv-asm.awk Sun Dec 18 16:53:03 2011
(r228688)
@@ -9,6 +9,7 @@
 # $FreeBSD$
 
 BEGIN {
+   printf("/* $FreeBSD$ */\n\n");
printf("#include \n\n");
printf("#define hc .long 0x4422\n\n");
 }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r228689 - head/sys/powerpc/ps3

2011-12-18 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Dec 18 16:53:21 2011
New Revision: 228689
URL: http://svn.freebsd.org/changeset/base/228689

Log:
  Support infrastructure for X11 on PS3.
  
  Submitted by: geoffrey dot levand at mail dot ru
  MFC after:1 week

Modified:
  head/sys/powerpc/ps3/ps3-hvcall.S
  head/sys/powerpc/ps3/ps3-hvcall.h
  head/sys/powerpc/ps3/ps3-hvcall.master
  head/sys/powerpc/ps3/ps3_syscons.c

Modified: head/sys/powerpc/ps3/ps3-hvcall.S
==
--- head/sys/powerpc/ps3/ps3-hvcall.S   Sun Dec 18 16:53:03 2011
(r228688)
+++ head/sys/powerpc/ps3/ps3-hvcall.S   Sun Dec 18 16:53:21 2011
(r228689)
@@ -1081,13 +1081,25 @@ ASENTRY(lv1_gpu_memory_free)
 ASENTRY(lv1_gpu_context_allocate)
mflr%r0
std %r0,16(%r1)
-   stdu%r1,-56(%r1)
+   stdu%r1,-88(%r1)
std %r5,48(%r1)
+   std %r6,56(%r1)
+   std %r7,64(%r1)
+   std %r8,72(%r1)
+   std %r9,80(%r1)
li  %r11,217
hc
extsw   %r3,%r3
ld  %r11,48(%r1)
std %r4,0(%r11)
+   ld  %r11,56(%r1)
+   std %r5,0(%r11)
+   ld  %r11,64(%r1)
+   std %r6,0(%r11)
+   ld  %r11,72(%r1)
+   std %r7,0(%r11)
+   ld  %r11,80(%r1)
+   std %r8,0(%r11)
ld  %r1,0(%r1)
ld  %r0,16(%r1)
mtlr%r0
@@ -1144,6 +1156,18 @@ ASENTRY(lv1_gpu_context_intr)
mtlr%r0
blr
 
+ASENTRY(lv1_gpu_attribute)
+   mflr%r0
+   std %r0,16(%r1)
+   stdu%r1,-48(%r1)
+   li  %r11,228
+   hc
+   extsw   %r3,%r3
+   ld  %r1,0(%r1)
+   ld  %r0,16(%r1)
+   mtlr%r0
+   blr
+
 ASENTRY(lv1_get_rtc)
mflr%r0
std %r0,16(%r1)

Modified: head/sys/powerpc/ps3/ps3-hvcall.h
==
--- head/sys/powerpc/ps3/ps3-hvcall.h   Sun Dec 18 16:53:03 2011
(r228688)
+++ head/sys/powerpc/ps3/ps3-hvcall.h   Sun Dec 18 16:53:21 2011
(r228689)
@@ -124,11 +124,12 @@ int lv1_gpu_device_map(uint64_t dev, uin
 int lv1_gpu_device_unmap(uint64_t dev);
 int lv1_gpu_memory_allocate(uint64_t ddr_size, uint64_t zero1, uint64_t zero2, 
uint64_t zero3, uint64_t zero4, uint64_t *handle, uint64_t *ddr_lpar);
 int lv1_gpu_memory_free(uint64_t handle);
-int lv1_gpu_context_allocate(uint64_t handle, uint64_t , uint64_t *zero);
+int lv1_gpu_context_allocate(uint64_t handle, uint64_t flags, uint64_t 
*chandle, uint64_t *lpar_dma_control, uint64_t *lpar_driver_info, uint64_t 
*lpar_reports, uint64_t *lpar_reports_size);
 int lv1_gpu_context_free(uint64_t chandle);
 int lv1_gpu_context_iomap(uint64_t changle, uint64_t gpu_ioif, uint64_t 
xdr_lpar, uint64_t fbsize, uint64_t ioflags);
 int lv1_gpu_context_attribute(uint64_t chandle, uint64_t op, uint64_t p1, 
uint64_t p2, uint64_t p3, uint64_t p4);
 int lv1_gpu_context_intr(uint64_t chandle, uint64_t *v1);
+int lv1_gpu_attribute(uint64_t p1, uint64_t p2, uint64_t p3, uint64_t p4, 
uint64_t p5);
 int lv1_get_rtc(uint64_t *rtc_val, uint64_t *timebase);
 int lv1_storage_read(uint64_t dev, uint64_t region, uint64_t sector, uint64_t 
nsectors, uint64_t flags, uint64_t buf, uint64_t *dma_tag);
 int lv1_storage_write(uint64_t dev, uint64_t region, uint64_t sector, uint64_t 
nsectors, uint64_t flags, uint64_t buf, uint64_t *dma_tag);

Modified: head/sys/powerpc/ps3/ps3-hvcall.master
==
--- head/sys/powerpc/ps3/ps3-hvcall.master  Sun Dec 18 16:53:03 2011
(r228688)
+++ head/sys/powerpc/ps3/ps3-hvcall.master  Sun Dec 18 16:53:21 2011
(r228689)
@@ -125,11 +125,12 @@ HVCALL212 lv1_gpu_device_map  
dev l
 HVCALL 213 lv1_gpu_device_unmapdev
 HVCALL 214 lv1_gpu_memory_allocate 
ddr_size,zero1,zero2,zero3,zero4handle,ddr_lpar
 HVCALL 216 lv1_gpu_memory_free handle
-HVCALL 217 lv1_gpu_context_allocatehandle, zero
chandle,lpar_dma_control,lpar_driver_info,lpar_reports,lpar_reports_size
+HVCALL 217 lv1_gpu_context_allocatehandle,flags
chandle,lpar_dma_control,lpar_driver_info,lpar_reports,lpar_reports_size
 HVCALL 218 lv1_gpu_context_freechandle
 HVCALL 221 lv1_gpu_context_iomap   
changle,gpu_ioif,xdr_lpar,fbsize,ioflags
 HVCALL 225 lv1_gpu_context_attribute   chandle,op,p1,p2,p3,p4
 HVCALL 227 lv1_gpu_context_intrchandle 
v1
+HVCALL 228 lv1_gpu_attribute   p1,p2,p3,p4,p5
 HVCALL 232 lv1_get_rtc UNUSED  
rtc_val,timebase
 HVCALL 245 

svn commit: r229113 - in stable/9/libexec/rtld-elf: powerpc powerpc64

2011-12-31 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Dec 31 15:08:33 2011
New Revision: 229113
URL: http://svn.freebsd.org/changeset/base/229113

Log:
  MFC r228646:
  Additional icache paranoia: non-PLT relocations can modify the text segment.
  It is then important to make sure the icache is synchronized again to
  prevent (rare) random seg faults and illegal instructions.

Modified:
  stable/9/libexec/rtld-elf/powerpc/reloc.c
  stable/9/libexec/rtld-elf/powerpc64/reloc.c
Directory Properties:
  stable/9/libexec/rtld-elf/   (props changed)

Modified: stable/9/libexec/rtld-elf/powerpc/reloc.c
==
--- stable/9/libexec/rtld-elf/powerpc/reloc.c   Sat Dec 31 15:03:29 2011
(r229112)
+++ stable/9/libexec/rtld-elf/powerpc/reloc.c   Sat Dec 31 15:08:33 2011
(r229113)
@@ -317,6 +317,10 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry 
 done:
if (cache != NULL)
free(cache);
+
+   /* Synchronize icache for text seg in case we made any changes */
+   __syncicache(obj->mapbase, obj->textsize);
+
return (r);
 }
 

Modified: stable/9/libexec/rtld-elf/powerpc64/reloc.c
==
--- stable/9/libexec/rtld-elf/powerpc64/reloc.c Sat Dec 31 15:03:29 2011
(r229112)
+++ stable/9/libexec/rtld-elf/powerpc64/reloc.c Sat Dec 31 15:08:33 2011
(r229113)
@@ -313,9 +313,12 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry 
}
r = 0;
 done:
-   if (cache) {
+   if (cache)
munmap(cache, bytes);
-   }
+
+   /* Synchronize icache for text seg in case we made any changes */
+   __syncicache(obj->mapbase, obj->textsize);
+
return (r);
 }
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r229114 - stable/9/sys/powerpc/ps3

2011-12-31 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Dec 31 15:11:47 2011
New Revision: 229114
URL: http://svn.freebsd.org/changeset/base/229114

Log:
  MFC r228688,228689:
  Support infrastructure for X11 on PS3.
  
  Submitted by: geoffrey dot levand at mail dot ru

Modified:
  stable/9/sys/powerpc/ps3/ps3-hv-asm.awk
  stable/9/sys/powerpc/ps3/ps3-hvcall.S
  stable/9/sys/powerpc/ps3/ps3-hvcall.h
  stable/9/sys/powerpc/ps3/ps3-hvcall.master
  stable/9/sys/powerpc/ps3/ps3_syscons.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/powerpc/ps3/ps3-hv-asm.awk
==
--- stable/9/sys/powerpc/ps3/ps3-hv-asm.awk Sat Dec 31 15:08:33 2011
(r229113)
+++ stable/9/sys/powerpc/ps3/ps3-hv-asm.awk Sat Dec 31 15:11:47 2011
(r229114)
@@ -9,6 +9,7 @@
 # $FreeBSD$
 
 BEGIN {
+   printf("/* $FreeBSD$ */\n\n");
printf("#include \n\n");
printf("#define hc .long 0x4422\n\n");
 }

Modified: stable/9/sys/powerpc/ps3/ps3-hvcall.S
==
--- stable/9/sys/powerpc/ps3/ps3-hvcall.S   Sat Dec 31 15:08:33 2011
(r229113)
+++ stable/9/sys/powerpc/ps3/ps3-hvcall.S   Sat Dec 31 15:11:47 2011
(r229114)
@@ -1081,13 +1081,25 @@ ASENTRY(lv1_gpu_memory_free)
 ASENTRY(lv1_gpu_context_allocate)
mflr%r0
std %r0,16(%r1)
-   stdu%r1,-56(%r1)
+   stdu%r1,-88(%r1)
std %r5,48(%r1)
+   std %r6,56(%r1)
+   std %r7,64(%r1)
+   std %r8,72(%r1)
+   std %r9,80(%r1)
li  %r11,217
hc
extsw   %r3,%r3
ld  %r11,48(%r1)
std %r4,0(%r11)
+   ld  %r11,56(%r1)
+   std %r5,0(%r11)
+   ld  %r11,64(%r1)
+   std %r6,0(%r11)
+   ld  %r11,72(%r1)
+   std %r7,0(%r11)
+   ld  %r11,80(%r1)
+   std %r8,0(%r11)
ld  %r1,0(%r1)
ld  %r0,16(%r1)
mtlr%r0
@@ -1144,6 +1156,18 @@ ASENTRY(lv1_gpu_context_intr)
mtlr%r0
blr
 
+ASENTRY(lv1_gpu_attribute)
+   mflr%r0
+   std %r0,16(%r1)
+   stdu%r1,-48(%r1)
+   li  %r11,228
+   hc
+   extsw   %r3,%r3
+   ld  %r1,0(%r1)
+   ld  %r0,16(%r1)
+   mtlr%r0
+   blr
+
 ASENTRY(lv1_get_rtc)
mflr%r0
std %r0,16(%r1)

Modified: stable/9/sys/powerpc/ps3/ps3-hvcall.h
==
--- stable/9/sys/powerpc/ps3/ps3-hvcall.h   Sat Dec 31 15:08:33 2011
(r229113)
+++ stable/9/sys/powerpc/ps3/ps3-hvcall.h   Sat Dec 31 15:11:47 2011
(r229114)
@@ -124,11 +124,12 @@ int lv1_gpu_device_map(uint64_t dev, uin
 int lv1_gpu_device_unmap(uint64_t dev);
 int lv1_gpu_memory_allocate(uint64_t ddr_size, uint64_t zero1, uint64_t zero2, 
uint64_t zero3, uint64_t zero4, uint64_t *handle, uint64_t *ddr_lpar);
 int lv1_gpu_memory_free(uint64_t handle);
-int lv1_gpu_context_allocate(uint64_t handle, uint64_t , uint64_t *zero);
+int lv1_gpu_context_allocate(uint64_t handle, uint64_t flags, uint64_t 
*chandle, uint64_t *lpar_dma_control, uint64_t *lpar_driver_info, uint64_t 
*lpar_reports, uint64_t *lpar_reports_size);
 int lv1_gpu_context_free(uint64_t chandle);
 int lv1_gpu_context_iomap(uint64_t changle, uint64_t gpu_ioif, uint64_t 
xdr_lpar, uint64_t fbsize, uint64_t ioflags);
 int lv1_gpu_context_attribute(uint64_t chandle, uint64_t op, uint64_t p1, 
uint64_t p2, uint64_t p3, uint64_t p4);
 int lv1_gpu_context_intr(uint64_t chandle, uint64_t *v1);
+int lv1_gpu_attribute(uint64_t p1, uint64_t p2, uint64_t p3, uint64_t p4, 
uint64_t p5);
 int lv1_get_rtc(uint64_t *rtc_val, uint64_t *timebase);
 int lv1_storage_read(uint64_t dev, uint64_t region, uint64_t sector, uint64_t 
nsectors, uint64_t flags, uint64_t buf, uint64_t *dma_tag);
 int lv1_storage_write(uint64_t dev, uint64_t region, uint64_t sector, uint64_t 
nsectors, uint64_t flags, uint64_t buf, uint64_t *dma_tag);

Modified: stable/9/sys/powerpc/ps3/ps3-hvcall.master
==
--- stable/9/sys/powerpc/ps3/ps3-hvcall.master  Sat Dec 31 15:08:33 2011
(r229113)
+++ stable/9/sys/powerpc/ps3/ps3-hvcall.master  Sat Dec 31 15:11:47 2011
(r229114)
@@ -125,11 +125,12 @@ HVCALL212 lv1_gpu_device_map  
dev l
 HVCALL 213 lv1_gpu_device_unmapdev
 HVCALL 214 lv1_gpu_memory_allocate 
ddr_size,zero1,zero2,zero3,zero4handle,ddr_lpar
 HVCALL 216 lv1_gpu_memory_free handle
-HVCALL 217 lv1_gpu_context_allocatehandle, zero
chandle,lpar_dma_control,lpar_driver_info,lpar_reports,lpar_reports_size
+HVCALL 217 lv1_gpu_context_allocate 

svn commit: r229131 - in stable/9: lib/clang share/mk

2011-12-31 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Dec 31 18:09:31 2011
New Revision: 229131
URL: http://svn.freebsd.org/changeset/base/229131

Log:
  MFC r227775:
  Connect LLVM/clang to the build on powerpc64. After the binutils 2.17.50
  import, it works without issue.

Modified:
  stable/9/lib/clang/clang.build.mk
  stable/9/share/mk/bsd.own.mk
Directory Properties:
  stable/9/lib/clang/   (props changed)
  stable/9/share/mk/   (props changed)

Modified: stable/9/lib/clang/clang.build.mk
==
--- stable/9/lib/clang/clang.build.mk   Sat Dec 31 17:56:05 2011
(r229130)
+++ stable/9/lib/clang/clang.build.mk   Sat Dec 31 18:09:31 2011
(r229131)
@@ -9,7 +9,7 @@ CFLAGS+=-I${LLVM_SRCS}/include -I${CLANG
-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS #-DNDEBUG
 
 # Correct for gcc miscompilation when compiling on PPC with -O2
-.if ${MACHINE_ARCH} == "powerpc"
+.if ${MACHINE_CPUARCH} == "powerpc"
 CFLAGS+= -O1
 .endif
 

Modified: stable/9/share/mk/bsd.own.mk
==
--- stable/9/share/mk/bsd.own.mkSat Dec 31 17:56:05 2011
(r229130)
+++ stable/9/share/mk/bsd.own.mkSat Dec 31 18:09:31 2011
(r229131)
@@ -428,14 +428,14 @@ __T=${TARGET_ARCH}
 .else
 __T=${MACHINE_ARCH}
 .endif
-# Clang is only for x86 and 32-bit powerpc right now, by default.
-.if ${__T} == "amd64" || ${__T} == "i386" || ${__T} == "powerpc"
+# Clang is only for x86 and powerpc right now, by default.
+.if ${__T} == "amd64" || ${__T} == "i386" || ${__T:Mpowerpc*}
 __DEFAULT_YES_OPTIONS+=CLANG
 .else
 __DEFAULT_NO_OPTIONS+=CLANG
 .endif
-# FDT is needed only for arm and powerpc (and not powerpc64)
-.if ${__T} == "arm" || ${__T} == "armeb" || ${__T} == "powerpc"
+# FDT is needed only for arm and powerpc
+.if ${__T:Marm*} || ${__T:Mpowerpc*}
 __DEFAULT_YES_OPTIONS+=FDT
 .else
 __DEFAULT_NO_OPTIONS+=FDT
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r229169 - head/lib/clang

2012-01-01 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Jan  1 15:56:15 2012
New Revision: 229169
URL: http://svn.freebsd.org/changeset/base/229169

Log:
  Instead of forcing -O1 on PowerPC for LLVM and clang, fix the actual
  problem by adding -fno-strict-aliasing to CFLAGS. Since this is a global
  issue that just happened to manifest on PowerPC, add this to CFLAGS
  unconditionally.
  
  MFC after:1 week

Modified:
  head/lib/clang/clang.build.mk

Modified: head/lib/clang/clang.build.mk
==
--- head/lib/clang/clang.build.mk   Sun Jan  1 09:12:21 2012
(r229168)
+++ head/lib/clang/clang.build.mk   Sun Jan  1 15:56:15 2012
(r229169)
@@ -8,10 +8,8 @@ CFLAGS+=-I${LLVM_SRCS}/include -I${CLANG
-DLLVM_ON_UNIX -DLLVM_ON_FREEBSD \
-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS #-DNDEBUG
 
-# Correct for gcc miscompilation when compiling on PPC with -O2
-.if ${MACHINE_CPUARCH} == "powerpc"
-CFLAGS+= -O1
-.endif
+# LLVM is not strict aliasing safe as of 12/31/2011
+CFLAGS+= -fno-strict-aliasing
 
 TARGET_ARCH?=  ${MACHINE_ARCH}
 
CFLAGS+=-DLLVM_HOSTTRIPLE=\"${TARGET_ARCH:C/amd64/x86_64/}-unknown-freebsd10.0\"
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r229170 - stable/9/sys/powerpc/include

2012-01-01 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Jan  1 16:04:02 2012
New Revision: 229170
URL: http://svn.freebsd.org/changeset/base/229170

Log:
  Increase the available virtual address space for user programs on PowerPC
  AIM systems to 4 GB on 32-bit systems and 2^64 bytes on 64-bit systems.
  VM_MAXUSER_ADDRESS remains at 2 GB on Book-E, due to a different memory
  layout used on this platform.

Modified:
  stable/9/sys/powerpc/include/vmparam.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/powerpc/include/vmparam.h
==
--- stable/9/sys/powerpc/include/vmparam.h  Sun Jan  1 15:56:15 2012
(r229169)
+++ stable/9/sys/powerpc/include/vmparam.h  Sun Jan  1 16:04:02 2012
(r229170)
@@ -57,29 +57,34 @@
 #defineMAXSSIZ (64*1024*1024)  /* max stack size */
 #endif
 
+#ifdef AIM
+#defineVM_MAXUSER_ADDRESS32((vm_offset_t)0xf000)
+#else
+#defineVM_MAXUSER_ADDRESS32((vm_offset_t)0x7000)
+#endif
+
 /*
  * Would like to have MAX addresses = 0, but this doesn't (currently) work
  */
 #if !defined(LOCORE)
 #ifdef __powerpc64__
 #defineVM_MIN_ADDRESS  (0xUL)
-#defineVM_MAXUSER_ADDRESS  (0x7000UL)
-#defineSHAREDPAGE  (VM_MAXUSER_ADDRESS - PAGE_SIZE)
+#defineVM_MAXUSER_ADDRESS  (0xf000UL)
 #defineVM_MAX_ADDRESS  (0xUL)
 #else
 #defineVM_MIN_ADDRESS  ((vm_offset_t)0)
-#defineVM_MAXUSER_ADDRESS  ((vm_offset_t)0x7000)
-#defineSHAREDPAGE  (VM_MAXUSER_ADDRESS - PAGE_SIZE)
-#defineVM_MAX_ADDRESS  VM_MAXUSER_ADDRESS
+#defineVM_MAXUSER_ADDRESS  VM_MAXUSER_ADDRESS32
+#defineVM_MAX_ADDRESS  ((vm_offset_t)0x)
 #endif
+#defineSHAREDPAGE  (VM_MAXUSER_ADDRESS - PAGE_SIZE)
 #else /* LOCORE */
-#ifndef __powerpc64__
+#if !defined(__powerpc64__) && defined(E500)
 #defineVM_MIN_ADDRESS  0
 #defineVM_MAXUSER_ADDRESS  0x7000
 #endif
 #endif /* LOCORE */
 
-#defineFREEBSD32_SHAREDPAGE(0x7000 - PAGE_SIZE)
+#defineFREEBSD32_SHAREDPAGE(VM_MAXUSER_ADDRESS32 - PAGE_SIZE)
 #defineFREEBSD32_USRSTACK  FREEBSD32_SHAREDPAGE
 
 #ifdef AIM
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r229171 - in stable/9/sys/powerpc: aim include

2012-01-01 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sun Jan  1 16:05:36 2012
New Revision: 229171
URL: http://svn.freebsd.org/changeset/base/229171

Log:
  Keep track of PVO entries in each pmap, which allows much faster
  pmap_remove() for large sparse requests. This can prevent pmap_remove()
  operations on 64-bit process destruction or swapout that would take
  several hundred times the lifetime of the universe to complete. This
  behavior is largely indistinguishable from a hang.

Modified:
  stable/9/sys/powerpc/aim/mmu_oea.c
  stable/9/sys/powerpc/aim/mmu_oea64.c
  stable/9/sys/powerpc/include/pmap.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/powerpc/aim/mmu_oea.c
==
--- stable/9/sys/powerpc/aim/mmu_oea.c  Sun Jan  1 16:04:02 2012
(r229170)
+++ stable/9/sys/powerpc/aim/mmu_oea.c  Sun Jan  1 16:05:36 2012
(r229171)
@@ -824,6 +824,7 @@ moea_bootstrap(mmu_t mmup, vm_offset_t k
for (i = 0; i < 16; i++)
kernel_pmap->pm_sr[i] = EMPTY_SEGMENT + i;
CPU_FILL(&kernel_pmap->pm_active);
+   LIST_INIT(&kernel_pmap->pmap_pvo);
 
/*
 * Set up the Open Firmware mappings
@@ -1582,6 +1583,7 @@ moea_pinit(mmu_t mmu, pmap_t pmap)
 
KASSERT((int)pmap < VM_MIN_KERNEL_ADDRESS, ("moea_pinit: virt pmap"));
PMAP_LOCK_INIT(pmap);
+   LIST_INIT(&pmap->pmap_pvo);
 
entropy = 0;
__asm __volatile("mftb %0" : "=r"(entropy));
@@ -1763,10 +1765,17 @@ moea_remove(mmu_t mmu, pmap_t pm, vm_off
 
vm_page_lock_queues();
PMAP_LOCK(pm);
-   for (; sva < eva; sva += PAGE_SIZE) {
-   pvo = moea_pvo_find_va(pm, sva, &pteidx);
-   if (pvo != NULL) {
-   moea_pvo_remove(pvo, pteidx);
+   if ((eva - sva)/PAGE_SIZE < 10) {
+   for (; sva < eva; sva += PAGE_SIZE) {
+   pvo = moea_pvo_find_va(pm, sva, &pteidx);
+   if (pvo != NULL)
+   moea_pvo_remove(pvo, pteidx);
+   }
+   } else {
+   LIST_FOREACH(pvo, &pm->pmap_pvo, pvo_plink) {
+   if (PVO_VADDR(pvo) < sva || PVO_VADDR(pvo) >= eva)
+   continue;
+   moea_pvo_remove(pvo, -1);
}
}
PMAP_UNLOCK(pm);
@@ -1929,6 +1938,11 @@ moea_pvo_enter(pmap_t pm, uma_zone_t zon
moea_pte_create(&pvo->pvo_pte.pte, sr, va, pa | pte_lo);
 
/*
+* Add to pmap list
+*/
+   LIST_INSERT_HEAD(&pm->pmap_pvo, pvo, pvo_plink);
+
+   /*
 * Remember if the list was empty and therefore will be the first
 * item.
 */
@@ -1994,9 +2008,10 @@ moea_pvo_remove(struct pvo_entry *pvo, i
}
 
/*
-* Remove this PVO from the PV list.
+* Remove this PVO from the PV and pmap lists.
 */
LIST_REMOVE(pvo, pvo_vlink);
+   LIST_REMOVE(pvo, pvo_plink);
 
/*
 * Remove this from the overflow list and return it to the pool

Modified: stable/9/sys/powerpc/aim/mmu_oea64.c
==
--- stable/9/sys/powerpc/aim/mmu_oea64.cSun Jan  1 16:04:02 2012
(r229170)
+++ stable/9/sys/powerpc/aim/mmu_oea64.cSun Jan  1 16:05:36 2012
(r229171)
@@ -831,6 +831,7 @@ moea64_mid_bootstrap(mmu_t mmup, vm_offs
 
kernel_pmap->pmap_phys = kernel_pmap;
CPU_FILL(&kernel_pmap->pm_active);
+   LIST_INIT(&kernel_pmap->pmap_pvo);
 
PMAP_LOCK_INIT(kernel_pmap);
 
@@ -1855,6 +1856,7 @@ void
 moea64_pinit(mmu_t mmu, pmap_t pmap)
 {
PMAP_LOCK_INIT(pmap);
+   LIST_INIT(&pmap->pmap_pvo);
 
pmap->pm_slb_tree_root = slb_alloc_tree();
pmap->pm_slb = slb_alloc_user_cache();
@@ -1868,6 +1870,7 @@ moea64_pinit(mmu_t mmu, pmap_t pmap)
uint32_t hash;
 
PMAP_LOCK_INIT(pmap);
+   LIST_INIT(&pmap->pmap_pvo);
 
if (pmap_bootstrapped)
pmap->pmap_phys = (pmap_t)moea64_kextract(mmu,
@@ -2034,10 +2037,18 @@ moea64_remove(mmu_t mmu, pmap_t pm, vm_o
 
vm_page_lock_queues();
PMAP_LOCK(pm);
-   for (; sva < eva; sva += PAGE_SIZE) {
-   pvo = moea64_pvo_find_va(pm, sva);
-   if (pvo != NULL)
+   if ((eva - sva)/PAGE_SIZE < 10) {
+   for (; sva < eva; sva += PAGE_SIZE) {
+   pvo = moea64_pvo_find_va(pm, sva);
+   if (pvo != NULL)
+   moea64_pvo_remove(mmu, pvo);
+   }
+   } else {
+   LIST_FOREACH(pvo, &pm->pmap_pvo, pvo_plink) {
+   if (PVO_VADDR(pvo) < sva || PVO_VADDR(pvo) >= eva)
+   continue;
moea64_pvo_remove(mmu, pvo);
+   }
}
vm_page_unlock_queues();
PMAP_UNLOC

Re: svn commit: r229169 - head/lib/clang

2012-01-01 Thread Nathan Whitehorn

On 01/01/12 10:11, Dimitry Andric wrote:

On 2012-01-01 16:56, Nathan Whitehorn wrote:

Author: nwhitehorn
Date: Sun Jan  1 15:56:15 2012
New Revision: 229169
URL: http://svn.freebsd.org/changeset/base/229169

Log:
   Instead of forcing -O1 on PowerPC for LLVM and clang, fix the actual
   problem by adding -fno-strict-aliasing to CFLAGS. Since this is a 
global

   issue that just happened to manifest on PowerPC, add this to CFLAGS
   unconditionally.

   MFC after:1 week

Modified:
   head/lib/clang/clang.build.mk

Modified: head/lib/clang/clang.build.mk
== 

--- head/lib/clang/clang.build.mkSun Jan  1 09:12:21 2012
(r229168)
+++ head/lib/clang/clang.build.mkSun Jan  1 15:56:15 2012
(r229169)

@@ -8,10 +8,8 @@ CFLAGS+=-I${LLVM_SRCS}/include -I${CLANG
  -DLLVM_ON_UNIX -DLLVM_ON_FREEBSD \
  -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS #-DNDEBUG

-# Correct for gcc miscompilation when compiling on PPC with -O2
-.if ${MACHINE_CPUARCH} == "powerpc"
-CFLAGS+= -O1
-.endif
+# LLVM is not strict aliasing safe as of 12/31/2011
+CFLAGS+= -fno-strict-aliasing


Actually, LLVM is strict-aliasing safe, but not for gcc 4.2.1. :)

There is some sort of problem with gcc's optimizer that made a few LLVM
tests fails mysteriously in the past.  At a certain point, these
problems went away for x86, but apparently not for non-x86...

In any case, this option should only have to be added when the compiler
is base gcc.


Ah, interesting. I'm not quite sure how to express "is compiler base 
GCC", but I'm guessing you have more experience there. Would you mind 
fixing that?

-Nathan
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214739 - head/sys/powerpc/aim

2010-11-03 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Wed Nov  3 15:15:48 2010
New Revision: 214739
URL: http://svn.freebsd.org/changeset/base/214739

Log:
  Clean up the user segment handling code a little more. Now that
  set_user_sr() itself caches the user segment VSID, there is no need for
  cpu_switch() to do it again. This change also unifies the 32 and 64-bit
  code paths for kernel faults on user pages and remaps the user SLB slot
  on 64-bit systems when taking a syscall to avoid some unnecessary segment
  exception traps.

Modified:
  head/sys/powerpc/aim/copyinout.c
  head/sys/powerpc/aim/swtch32.S
  head/sys/powerpc/aim/swtch64.S
  head/sys/powerpc/aim/trap.c

Modified: head/sys/powerpc/aim/copyinout.c
==
--- head/sys/powerpc/aim/copyinout.cWed Nov  3 13:42:59 2010
(r214738)
+++ head/sys/powerpc/aim/copyinout.cWed Nov  3 15:15:48 2010
(r214739)
@@ -102,11 +102,12 @@ set_user_sr(pmap_t pm, const void *addr)
if (curthread->td_pcb->pcb_cpu.aim.usr_vsid == slbv) 
return;
 
-   __asm __volatile ("isync; slbie %0; slbmte %1, %2; isync" ::
-   "r"(USER_ADDR), "r"(slbv), "r"(USER_SLB_SLBE));
+   __asm __volatile("isync");
curthread->td_pcb->pcb_cpu.aim.usr_segm =
(uintptr_t)addr >> ADDR_SR_SHFT;
curthread->td_pcb->pcb_cpu.aim.usr_vsid = slbv;
+   __asm __volatile ("slbie %0; slbmte %1, %2; isync" ::
+   "r"(USER_ADDR), "r"(slbv), "r"(USER_SLB_SLBE));
 }
 #else
 static __inline void
@@ -124,6 +125,8 @@ set_user_sr(pmap_t pm, const void *addr)
vsid |= SR_N;
 
__asm __volatile("isync");
+   curthread->td_pcb->pcb_cpu.aim.usr_segm =
+   (uintptr_t)addr >> ADDR_SR_SHFT;
curthread->td_pcb->pcb_cpu.aim.usr_vsid = vsid;
__asm __volatile("mtsr %0,%1; isync" :: "n"(USER_SR), "r"(vsid));
 }

Modified: head/sys/powerpc/aim/swtch32.S
==
--- head/sys/powerpc/aim/swtch32.S  Wed Nov  3 13:42:59 2010
(r214738)
+++ head/sys/powerpc/aim/swtch32.S  Wed Nov  3 15:15:48 2010
(r214739)
@@ -88,8 +88,6 @@ ENTRY(cpu_switch)
stw %r16,PCB_CR(%r6)
mflr%r16/* Save the link register */
stw %r16,PCB_LR(%r6)
-   mfsr%r16,USER_SR/* Save USER_SR for copyin/out */
-   stw %r16,PCB_AIM_USR_VSID(%r6)
stw %r1,PCB_SP(%r6) /* Save the stack pointer */
stw %r2,PCB_TOC(%r6)/* Save the TOC pointer */
 

Modified: head/sys/powerpc/aim/swtch64.S
==
--- head/sys/powerpc/aim/swtch64.S  Wed Nov  3 13:42:59 2010
(r214738)
+++ head/sys/powerpc/aim/swtch64.S  Wed Nov  3 15:15:48 2010
(r214739)
@@ -110,11 +110,6 @@ ENTRY(cpu_switch)
std %r1,PCB_SP(%r6) /* Save the stack pointer */
std %r2,PCB_TOC(%r6)/* Save the TOC pointer */

-   li  %r15,0  /* Save user segment for copyin/out */
-   li  %r16,USER_SLB_SLOT
-   slbmfev %r15, %r16
-   std %r15,PCB_AIM_USR_VSID(%r6)
-
mr  %r14,%r3/* Copy the old thread ptr... */
mr  %r15,%r4/* and the new thread ptr in scratch */
mr  %r16,%r5/* and the new lock */

Modified: head/sys/powerpc/aim/trap.c
==
--- head/sys/powerpc/aim/trap.c Wed Nov  3 13:42:59 2010(r214738)
+++ head/sys/powerpc/aim/trap.c Wed Nov  3 15:15:48 2010(r214739)
@@ -455,6 +455,13 @@ syscall(struct trapframe *frame)
td = PCPU_GET(curthread);
td->td_frame = frame;
 
+   /*
+* Speculatively restore last user SLB segment, which we know is
+* invalid already, since we are likely to do copyin()/copyout().
+*/
+   __asm __volatile ("slbmte %0, %1; isync" ::
+"r"(td->td_pcb->pcb_cpu.aim.usr_vsid), "r"(USER_SLB_SLBE));
+
error = syscallenter(td, &sa);
syscallret(td, error, &sa);
 }
@@ -532,13 +539,7 @@ trap_pfault(struct trapframe *frame, int
 
map = &p->p_vmspace->vm_map;
 
-   #ifdef __powerpc64__
user_sr = td->td_pcb->pcb_cpu.aim.usr_segm;
-   #else
-   __asm ("mfsr %0, %1"
-   : "=r"(user_sr)
-   : "K"(USER_SR));
-   #endif
eva &= ADDR_PIDX | ADDR_POFF;
eva |= user_sr << ADDR_SR_SHFT;
} else {
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-

svn commit: r214741 - stable/8/sys/powerpc/aim

2010-11-03 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Wed Nov  3 15:24:25 2010
New Revision: 214741
URL: http://svn.freebsd.org/changeset/base/214741

Log:
  MFC r214601:
  Add some missing parentheses so that moea_bat_mapped() actually works.
  
  Submitted by: alc

Modified:
  stable/8/sys/powerpc/aim/mmu_oea.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/powerpc/aim/mmu_oea.c
==
--- stable/8/sys/powerpc/aim/mmu_oea.c  Wed Nov  3 15:22:09 2010
(r214740)
+++ stable/8/sys/powerpc/aim/mmu_oea.c  Wed Nov  3 15:24:25 2010
(r214741)
@@ -2381,7 +2381,7 @@ moea_bat_mapped(int idx, vm_offset_t pa,
/*
 * Return immediately if not a valid mapping
 */
-   if (!battable[idx].batu & BAT_Vs)
+   if (!(battable[idx].batu & BAT_Vs))
return (EINVAL);
 
/*
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214745 - in stable/8/sys/dev: pci usb/controller

2010-11-03 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Wed Nov  3 15:31:37 2010
New Revision: 214745
URL: http://svn.freebsd.org/changeset/base/214745

Log:
  MFC r214349:
  The EHCI_CAPLENGTH and EHCI_HCIVERSION registers are actually sub-registers
  within the first 4 bytes of the EHCI memory space. For controllers that
  use big-endian MMIO, reading them with 1- and 2-byte reads would then
  return the wrong values. Instead, read the combined register with a
  4-byte read and mask out the interesting quantities.
  
  Requested by: marius

Modified:
  stable/8/sys/dev/pci/pci.c
  stable/8/sys/dev/usb/controller/ehci.c
  stable/8/sys/dev/usb/controller/ehcireg.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/pci/pci.c
==
--- stable/8/sys/dev/pci/pci.c  Wed Nov  3 15:31:10 2010(r214744)
+++ stable/8/sys/dev/pci/pci.c  Wed Nov  3 15:31:37 2010(r214745)
@@ -2729,7 +2729,7 @@ ehci_early_takeover(device_t self)
"SMM does not respond\n");
}
/* Disable interrupts */
-   offs = bus_read_1(res, EHCI_CAPLENGTH);
+   offs = EHCI_CAPLENGTH(bus_read_4(res, EHCI_CAPLEN_HCIVERSION));
bus_write_4(res, offs + EHCI_USBINTR, 0);
}
bus_release_resource(self, SYS_RES_MEMORY, rid, res);

Modified: stable/8/sys/dev/usb/controller/ehci.c
==
--- stable/8/sys/dev/usb/controller/ehci.c  Wed Nov  3 15:31:10 2010
(r214744)
+++ stable/8/sys/dev/usb/controller/ehci.c  Wed Nov  3 15:31:37 2010
(r214745)
@@ -268,9 +268,9 @@ ehci_init(ehci_softc_t *sc)
}
 #endif
 
-   sc->sc_offs = EREAD1(sc, EHCI_CAPLENGTH);
+   sc->sc_offs = EHCI_CAPLENGTH(EREAD4(sc, EHCI_CAPLEN_HCIVERSION));
 
-   version = EREAD2(sc, EHCI_HCIVERSION);
+   version = EHCI_HCIVERSION(EREAD4(sc, EHCI_CAPLEN_HCIVERSION));
device_printf(sc->sc_bus.bdev, "EHCI version %x.%x\n",
version >> 8, version & 0xff);
 

Modified: stable/8/sys/dev/usb/controller/ehcireg.h
==
--- stable/8/sys/dev/usb/controller/ehcireg.h   Wed Nov  3 15:31:10 2010
(r214744)
+++ stable/8/sys/dev/usb/controller/ehcireg.h   Wed Nov  3 15:31:37 2010
(r214745)
@@ -61,9 +61,13 @@
 #defineEHCI_LEGSUP_USBLEGCTLSTS0x04
 
 /* EHCI capability registers */
-#defineEHCI_CAPLENGTH  0x00/* RO Capability register 
length field */
-/* reserved0x01 */
-#defineEHCI_HCIVERSION 0x02/* RO Interface version number 
*/
+#defineEHCI_CAPLEN_HCIVERSION  0x00/* RO Capability register length
+* (least-significant byte) and 
+* interface version number (two
+* most significant)
+*/
+#define EHCI_CAPLENGTH(x)  ((x) & 0xff)
+#define EHCI_HCIVERSION(x) (((x) >> 16) & 0x)
 #defineEHCI_HCSPARAMS  0x04/* RO Structural parameters */
 #defineEHCI_HCS_DEBUGPORT(x)   (((x) >> 20) & 0xf)
 #defineEHCI_HCS_P_INDICATOR(x) ((x) & 0x1)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214749 - head/sys/powerpc/aim

2010-11-03 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Wed Nov  3 16:21:47 2010
New Revision: 214749
URL: http://svn.freebsd.org/changeset/base/214749

Log:
  Fix two mistakes on 32-bit systems. The slbmte code in syscall() is 64-bit
  only, and should be protected with an ifdef, and the no-execute bit in
  32-bit set_user_sr() should be set before the comparison, not after, or
  it will never match.

Modified:
  head/sys/powerpc/aim/copyinout.c
  head/sys/powerpc/aim/trap.c

Modified: head/sys/powerpc/aim/copyinout.c
==
--- head/sys/powerpc/aim/copyinout.cWed Nov  3 16:19:35 2010
(r214748)
+++ head/sys/powerpc/aim/copyinout.cWed Nov  3 16:21:47 2010
(r214749)
@@ -117,13 +117,13 @@ set_user_sr(pmap_t pm, const void *addr)
 
vsid = va_to_vsid(pm, (vm_offset_t)addr);
 
+   /* Mark segment no-execute */
+   vsid |= SR_N;
+
/* If we have already set this VSID, we can just return */
if (curthread->td_pcb->pcb_cpu.aim.usr_vsid == vsid)
return;
 
-   /* Mark segment no-execute */
-   vsid |= SR_N;
-
__asm __volatile("isync");
curthread->td_pcb->pcb_cpu.aim.usr_segm =
(uintptr_t)addr >> ADDR_SR_SHFT;

Modified: head/sys/powerpc/aim/trap.c
==
--- head/sys/powerpc/aim/trap.c Wed Nov  3 16:19:35 2010(r214748)
+++ head/sys/powerpc/aim/trap.c Wed Nov  3 16:21:47 2010(r214749)
@@ -455,12 +455,14 @@ syscall(struct trapframe *frame)
td = PCPU_GET(curthread);
td->td_frame = frame;
 
+#ifdef __powerpc64__
/*
 * Speculatively restore last user SLB segment, which we know is
 * invalid already, since we are likely to do copyin()/copyout().
 */
__asm __volatile ("slbmte %0, %1; isync" ::
 "r"(td->td_pcb->pcb_cpu.aim.usr_vsid), "r"(USER_SLB_SLBE));
+#endif
 
error = syscallenter(td, &sa);
syscallret(td, error, &sa);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r214999 - head/sys/dev/iicbus

2010-11-08 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Nov  8 19:53:16 2010
New Revision: 214999
URL: http://svn.freebsd.org/changeset/base/214999

Log:
  Provide support for IIC_M_NOSTOP/IIC_M_NOSTART for bit-banging and
  otherwise low-level controllers.
  
  Reviewed by:  thompsa

Modified:
  head/sys/dev/iicbus/iiconf.c

Modified: head/sys/dev/iicbus/iiconf.c
==
--- head/sys/dev/iicbus/iiconf.cMon Nov  8 19:52:14 2010
(r214998)
+++ head/sys/dev/iicbus/iiconf.cMon Nov  8 19:53:16 2010
(r214999)
@@ -363,7 +363,7 @@ iicbus_transfer(device_t bus, struct iic
 int
 iicbus_transfer_gen(device_t dev, struct iic_msg *msgs, uint32_t nmsgs)
 {
-   int i, error, lenread, lenwrote, nkid;
+   int i, error, lenread, lenwrote, nkid, rpstart, addr;
device_t *children, bus;
 
if ((error = device_get_children(dev, &children, &nkid)) != 0)
@@ -373,14 +373,38 @@ iicbus_transfer_gen(device_t dev, struct
return (EIO);
}
bus = children[0];
+   rpstart = 0;
free(children, M_TEMP);
for (i = 0, error = 0; i < nmsgs && error == 0; i++) {
+   addr = msgs[i].slave;
if (msgs[i].flags & IIC_M_RD)
-   error = iicbus_block_read(bus, msgs[i].slave,
-   msgs[i].buf, msgs[i].len, &lenread);
+   addr |= LSB;
else
-   error = iicbus_block_write(bus, msgs[i].slave,
-   msgs[i].buf, msgs[i].len, &lenwrote);
+   addr &= ~LSB;
+
+   if (!(msgs[i].flags & IIC_M_NOSTART)) {
+   if (rpstart)
+   error = iicbus_repeated_start(bus, addr, 0);
+   else
+   error = iicbus_start(bus, addr, 0);
+   }
+
+   if (error)
+   break;
+
+   if (msgs[i].flags & IIC_M_RD)
+   error = iicbus_read(bus, msgs[i].buf, msgs[i].len,
+   &lenread, IIC_LAST_READ, 0);
+   else
+   error = iicbus_write(bus, msgs[i].buf, msgs[i].len,
+   &lenwrote, 0);
+
+   if (!(msgs[i].flags & IIC_M_NOSTOP)) {
+   rpstart = 0;
+   iicbus_stop(bus);
+   } else {
+   rpstart = 1;/* Next message gets repeated start */
+   }
}
return (error);
 }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215049 - head/sys/dev/ofw

2010-11-09 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Tue Nov  9 19:45:29 2010
New Revision: 215049
URL: http://svn.freebsd.org/changeset/base/215049

Log:
  Make all OF client interface calls return the maximum kind of
  does-not-exist error when no client interface module is installed instead
  of dereferencing NULL pointers. This eases implementation of platforms
  that may or may not have Open Firmware.

Modified:
  head/sys/dev/ofw/openfirm.c

Modified: head/sys/dev/ofw/openfirm.c
==
--- head/sys/dev/ofw/openfirm.c Tue Nov  9 19:43:45 2010(r215048)
+++ head/sys/dev/ofw/openfirm.c Tue Nov  9 19:45:29 2010(r215049)
@@ -76,7 +76,7 @@ MALLOC_DEFINE(M_OFWPROP, "openfirm", "Op
 
 static ihandle_t stdout;
 
-static ofw_def_t   *ofw_def_impl;
+static ofw_def_t   *ofw_def_impl = NULL;
 static ofw_t   ofw_obj;
 static struct ofw_kobj ofw_kernel_obj;
 static struct kobj_ops ofw_kernel_kops;
@@ -118,6 +118,9 @@ OF_init(void *cookie)
phandle_t chosen;
int rv;
 
+   if (ofw_def_impl == NULL)
+   return (-1);
+
ofw_obj = &ofw_kernel_obj;
/*
 * Take care of compiling the selected class, and
@@ -135,7 +138,6 @@ OF_init(void *cookie)
return (rv);
 }
 
-#ifndef FDT
 void
 OF_printf(const char *fmt, ...)
 {
@@ -157,9 +159,11 @@ int
 OF_test(const char *name)
 {
 
+   if (ofw_def_impl == NULL)
+   return (-1);
+
return (OFW_TEST(ofw_obj, name));
 }
-#endif
 
 int
 OF_interpret(const char *cmd, int nreturns, ...)
@@ -169,6 +173,9 @@ OF_interpret(const char *cmd, int nretur
int i = 0;
int status;
 
+   if (ofw_def_impl == NULL)
+   return (-1);
+
status = OFW_INTERPRET(ofw_obj, cmd, nreturns, slots);
if (status == -1)
return (status);
@@ -190,6 +197,9 @@ phandle_t
 OF_peer(phandle_t node)
 {
 
+   if (ofw_def_impl == NULL)
+   return (0);
+
return (OFW_PEER(ofw_obj, node));
 }
 
@@ -198,6 +208,9 @@ phandle_t
 OF_child(phandle_t node)
 {
 
+   if (ofw_def_impl == NULL)
+   return (0);
+
return (OFW_CHILD(ofw_obj, node));
 }
 
@@ -206,6 +219,9 @@ phandle_t
 OF_parent(phandle_t node)
 {
 
+   if (ofw_def_impl == NULL)
+   return (0);
+
return (OFW_PARENT(ofw_obj, node));
 }
 
@@ -214,6 +230,9 @@ phandle_t
 OF_instance_to_package(ihandle_t instance)
 {
 
+   if (ofw_def_impl == NULL)
+   return (-1);
+
return (OFW_INSTANCE_TO_PACKAGE(ofw_obj, instance));
 }
 
@@ -222,6 +241,9 @@ ssize_t
 OF_getproplen(phandle_t package, const char *propname)
 {
 
+   if (ofw_def_impl == NULL)
+   return (-1);
+
return (OFW_GETPROPLEN(ofw_obj, package, propname));
 }
 
@@ -230,6 +252,9 @@ ssize_t
 OF_getprop(phandle_t package, const char *propname, void *buf, size_t buflen)
 {
 
+   if (ofw_def_impl == NULL)
+   return (-1);
+
return (OFW_GETPROP(ofw_obj, package, propname, buf, buflen));
 }
 
@@ -278,6 +303,9 @@ int
 OF_nextprop(phandle_t package, const char *previous, char *buf, size_t size)
 {
 
+   if (ofw_def_impl == NULL)
+   return (-1);
+
return (OFW_NEXTPROP(ofw_obj, package, previous, buf, size));
 }
 
@@ -286,6 +314,9 @@ int
 OF_setprop(phandle_t package, const char *propname, const void *buf, size_t 
len)
 {
 
+   if (ofw_def_impl == NULL)
+   return (-1);
+
return (OFW_SETPROP(ofw_obj, package, propname, buf,len));
 }
 
@@ -294,6 +325,9 @@ ssize_t
 OF_canon(const char *device, char *buf, size_t len)
 {
 
+   if (ofw_def_impl == NULL)
+   return (-1);
+
return (OFW_CANON(ofw_obj, device, buf, len));
 }
 
@@ -302,6 +336,9 @@ phandle_t
 OF_finddevice(const char *device)
 {
 
+   if (ofw_def_impl == NULL)
+   return (-1);
+
return (OFW_FINDDEVICE(ofw_obj, device));
 }
 
@@ -310,6 +347,9 @@ ssize_t
 OF_instance_to_path(ihandle_t instance, char *buf, size_t len)
 {
 
+   if (ofw_def_impl == NULL)
+   return (-1);
+
return (OFW_INSTANCE_TO_PATH(ofw_obj, instance, buf, len));
 }
 
@@ -318,10 +358,12 @@ ssize_t
 OF_package_to_path(phandle_t package, char *buf, size_t len)
 {
 
+   if (ofw_def_impl == NULL)
+   return (-1);
+
return (OFW_PACKAGE_TO_PATH(ofw_obj, package, buf, len));
 }
 
-#ifndef FDT
 /*  Call the method in the scope of a given instance. */
 int
 OF_call_method(const char *method, ihandle_t instance, int nargs, int nreturns,
@@ -331,7 +373,7 @@ OF_call_method(const char *method, ihand
cell_t args_n_results[12];
int n, status;
 
-   if (nargs > 6)
+   if (nargs > 6 || ofw_def_impl == NULL)
return (-1);
va_start(ap, nreturns);
for (n = 0; n < nargs; n++)
@@ -357,6 +399,9 @@ ihandle_t
 OF_open(const char *device)
 {
 
+   if (ofw_def_impl == NULL)
+

svn commit: r215067 - head/sys/powerpc/aim

2010-11-09 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Tue Nov  9 23:53:47 2010
New Revision: 215067
URL: http://svn.freebsd.org/changeset/base/215067

Log:
  Make AIM early-boot code function correctly without Open Firmware.

Modified:
  head/sys/powerpc/aim/mmu_oea64.c
  head/sys/powerpc/aim/nexus.c
  head/sys/powerpc/aim/ofw_machdep.c

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cTue Nov  9 22:32:11 2010
(r215066)
+++ head/sys/powerpc/aim/mmu_oea64.cTue Nov  9 23:53:47 2010
(r215067)
@@ -274,7 +274,6 @@ static struct   mem_region *regions;
 static struct  mem_region *pregions;
 static u_int   phys_avail_count;
 static int regions_sz, pregions_sz;
-extern int ofw_real_mode;
 
 extern struct pmap ofw_pmap;
 
@@ -1118,7 +1117,8 @@ moea64_bootstrap(mmu_t mmup, vm_offset_t
 * mode.
 */
 
-   if (!ofw_real_mode) {
+   chosen = OF_finddevice("/chosen");
+   if (chosen != -1 && OF_getprop(chosen, "mmu", &mmui, 4) != -1) {
#ifndef __powerpc64__
moea64_pinit(mmup, &ofw_pmap);
 
@@ -1126,10 +1126,6 @@ moea64_bootstrap(mmu_t mmup, vm_offset_t
ofw_pmap.pm_sr[i] = kernel_pmap->pm_sr[i];
#endif
 
-   if ((chosen = OF_finddevice("/chosen")) == -1)
-   panic("moea64_bootstrap: can't find /chosen");
-   OF_getprop(chosen, "mmu", &mmui, 4);
-
if ((mmu = OF_instance_to_package(mmui)) == -1)
panic("moea64_bootstrap: can't get mmu package");
if ((sz = OF_getproplen(mmu, "translations")) == -1)

Modified: head/sys/powerpc/aim/nexus.c
==
--- head/sys/powerpc/aim/nexus.cTue Nov  9 22:32:11 2010
(r215066)
+++ head/sys/powerpc/aim/nexus.cTue Nov  9 23:53:47 2010
(r215067)
@@ -213,9 +213,6 @@ nexus_attach(device_t dev)
struct  nexus_softc *sc;
u_long  start, end;
 
-   if ((root = OF_peer(0)) == -1)
-   panic("nexus_probe: OF_peer failed.");
-
sc = device_get_softc(dev);
 
start = 0;
@@ -229,6 +226,9 @@ nexus_attach(device_t dev)
rman_manage_region(&sc->sc_rman, start, end))
panic("nexus_probe IRQ rman");
 
+   if ((root = OF_peer(0)) == 0)
+   return (bus_generic_attach(dev));
+   
/*
 * Now walk the OFW tree to locate top-level devices
 */

Modified: head/sys/powerpc/aim/ofw_machdep.c
==
--- head/sys/powerpc/aim/ofw_machdep.c  Tue Nov  9 22:32:11 2010
(r215066)
+++ head/sys/powerpc/aim/ofw_machdep.c  Tue Nov  9 23:53:47 2010
(r215067)
@@ -333,6 +333,12 @@ OF_initial_setup(void *fdt_ptr, void *ju
#endif
 
fdt = fdt_ptr;
+
+   #ifdef FDT_DTB_STATIC
+   /* Check for a statically included blob */
+   if (fdt == NULL)
+   fdt = &fdt_static_dtb;
+   #endif
 }
 
 boolean_t
@@ -361,7 +367,7 @@ OF_bootstrap()
 * background processes.
 */
ofw_quiesce();
-   } else {
+   } else if (fdt != NULL) {
status = OF_install(OFW_FDT, 0);
 
if (status != TRUE)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215100 - head/sys/powerpc/powermac

2010-11-10 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Wed Nov 10 20:09:05 2010
New Revision: 215100
URL: http://svn.freebsd.org/changeset/base/215100

Log:
  Disabling CPU NAP modes during SMU commands is a hack needed only on U3
  systems. Don't use it on non-U3 systems to allow cpu_idle() to work
  correctly.

Modified:
  head/sys/powerpc/powermac/smu.c

Modified: head/sys/powerpc/powermac/smu.c
==
--- head/sys/powerpc/powermac/smu.c Wed Nov 10 19:33:13 2010
(r215099)
+++ head/sys/powerpc/powermac/smu.c Wed Nov 10 20:09:05 2010
(r215100)
@@ -96,6 +96,7 @@ struct smu_softc {
 
struct resource *sc_memr;
int sc_memrid;
+   int sc_u3;
 
bus_dma_tag_t   sc_dmatag;
bus_space_tag_t sc_bt;
@@ -275,6 +276,10 @@ smu_attach(device_t dev)
sc->sc_cur_cmd = NULL;
sc->sc_doorbellirqid = -1;
 
+   sc->sc_u3 = 0;
+   if (OF_finddevice("/u3") != -1)
+   sc->sc_u3 = 1;
+
/*
 * Map the mailbox area. This should be determined from firmware,
 * but I have not found a simple way to do that.
@@ -417,7 +422,9 @@ smu_send_cmd(device_t dev, struct smu_cm
 
mtx_assert(&sc->sc_mtx, MA_OWNED);
 
-   powerpc_pow_enabled = 0;/* SMU cannot work if we go to NAP */
+   if (sc->sc_u3)
+   powerpc_pow_enabled = 0; /* SMU cannot work if we go to NAP */
+
sc->sc_cur_cmd = cmd;
 
/* Copy the command to the mailbox */
@@ -464,7 +471,8 @@ smu_doorbell_intr(void *xdev)
sizeof(sc->sc_cmd->data));
wakeup(sc->sc_cur_cmd);
sc->sc_cur_cmd = NULL;
-   powerpc_pow_enabled = 1;
+   if (sc->sc_u3)
+   powerpc_pow_enabled = 1;
 
 done:
/* Queue next command if one is pending */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215101 - head/sys/powerpc/powerpc

2010-11-10 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Wed Nov 10 20:28:10 2010
New Revision: 215101
URL: http://svn.freebsd.org/changeset/base/215101

Log:
  Entering deep nap mode on the 970MP requires that both MSR[NAP] and
  MSR[DEEPNAP] be set, not just MSR[DEEPNAP]. Fixing this reduces the idle
  temperature of my CPUs from 57 to 38 degrees and makes one-shot timer
  mode work properly.
  
  Hint from:mav
  MFC after:4 days

Modified:
  head/sys/powerpc/powerpc/cpu.c

Modified: head/sys/powerpc/powerpc/cpu.c
==
--- head/sys/powerpc/powerpc/cpu.c  Wed Nov 10 20:09:05 2010
(r215100)
+++ head/sys/powerpc/powerpc/cpu.c  Wed Nov 10 20:28:10 2010
(r215101)
@@ -455,8 +455,8 @@ cpu_970_setup(int cpuid, uint16_t vers)
/* Configure power-saving mode */
switch (vers) {
case IBM970MP:
-   hid0_hi |= (HID0_DEEPNAP | HID0_DPM);
-   hid0_hi &= ~(HID0_DOZE | HID0_NAP);
+   hid0_hi |= (HID0_DEEPNAP | HID0_NAP | HID0_DPM);
+   hid0_hi &= ~HID0_DOZE;
break;
default:
hid0_hi |= (HID0_NAP | HID0_DPM);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r215101 - head/sys/powerpc/powerpc

2010-11-10 Thread Nathan Whitehorn
On Wed, 10 Nov 2010 20:28:10 + (UTC)
Nathan Whitehorn  wrote:

> Author: nwhitehorn
> Date: Wed Nov 10 20:28:10 2010
> New Revision: 215101
> URL: http://svn.freebsd.org/changeset/base/215101
> 
> Log:
>   Entering deep nap mode on the 970MP requires that both MSR[NAP] and
>   MSR[DEEPNAP] be set, not just MSR[DEEPNAP]. Fixing this reduces the
> idle temperature of my CPUs from 57 to 38 degrees and makes one-shot
> timer mode work properly.

All instances of MSR in this commit message should be HID0.
-Nathan
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215107 - head/sys/powerpc/aim

2010-11-10 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Thu Nov 11 02:40:00 2010
New Revision: 215107
URL: http://svn.freebsd.org/changeset/base/215107

Log:
  Add support for the IMISS, DLMISS, and DSMISS traps required to run
  FreeBSD on a G2 core.
  
  PR:   powerpc/111296
  Submitted by: Andrew Turner

Modified:
  head/sys/powerpc/aim/machdep.c
  head/sys/powerpc/aim/trap_subr32.S

Modified: head/sys/powerpc/aim/machdep.c
==
--- head/sys/powerpc/aim/machdep.c  Thu Nov 11 02:37:50 2010
(r215106)
+++ head/sys/powerpc/aim/machdep.c  Thu Nov 11 02:40:00 2010
(r215107)
@@ -245,6 +245,9 @@ extern void *dsitrap, *dsisize;
 extern void*decrint, *decrsize;
 extern void *extint, *extsize;
 extern void*dblow, *dbsize;
+extern void*imisstrap, *imisssize;
+extern void*dlmisstrap, *dlmisssize;
+extern void*dsmisstrap, *dsmisssize;
 
 uintptr_t
 powerpc_init(vm_offset_t startkernel, vm_offset_t endkernel,
@@ -491,6 +494,12 @@ powerpc_init(vm_offset_t startkernel, vm
bcopy(generictrap, (void *)EXC_VEC,  (size_t)&trapsize);
bcopy(generictrap, (void *)EXC_VECAST_G4, (size_t)&trapsize);
bcopy(generictrap, (void *)EXC_VECAST_G5, (size_t)&trapsize);
+   #ifndef __powerpc64__
+   /* G2-specific TLB miss helper handlers */
+   bcopy(&imisstrap, (void *)EXC_IMISS,  (size_t)&imisssize);
+   bcopy(&dlmisstrap, (void *)EXC_DLMISS,  (size_t)&dlmisssize);
+   bcopy(&dsmisstrap, (void *)EXC_DSMISS,  (size_t)&dsmisssize);
+   #endif
__syncicache(EXC_RSVD, EXC_LAST - EXC_RSVD);
 
/*

Modified: head/sys/powerpc/aim/trap_subr32.S
==
--- head/sys/powerpc/aim/trap_subr32.S  Thu Nov 11 02:37:50 2010
(r215106)
+++ head/sys/powerpc/aim/trap_subr32.S  Thu Nov 11 02:40:00 2010
(r215107)
@@ -362,6 +362,207 @@ CNAME(alitrap):
 CNAME(alisize) = .-CNAME(alitrap)
 
 /*
+ * G2 specific: instuction TLB miss.
+ */
+   .globl  CNAME(imisstrap),CNAME(imisssize)
+CNAME(imisstrap):
+   mfspr %r2, SPR_HASH1/* get first pointer */
+   addi %r1, 0, 8  /* load 8 for counter */
+   mfctr %r0   /* save counter */
+   mfspr %r3, SPR_ICMP /* get first compare value */
+   addi %r2, %r2, -8   /* pre dec the pointer */
+im0:
+   mtctr %r1   /* load counter */
+im1:
+   lwzu %r1, 8(%r2)/* get next pte */
+   cmp 0, %r1, %r3 /* see if found pte */
+   bdnzf 2, im1/* dec count br if cmp ne and if
+* count not zero */
+   bne instr_sec_hash  /* if not found set up second hash
+* or exit */
+   lwz %r1, +4(%r2)/* load tlb entry lower-word */
+   andi. %r3, %r1, 8   /* check G bit */
+   bne do_isi_prot /* if guarded, take an ISI */
+   mtctr %r0   /* restore counter */
+   mfspr %r0, SPR_IMISS/* get the miss address for the tlbli */
+   mfspr %r3, SPR_SRR1 /* get the saved cr0 bits */
+   mtcrf 0x80, %r3 /* restore CR0 */
+   mtspr SPR_RPA, %r1  /* set the pte */
+   ori %r1, %r1, 0x100 /* set reference bit */
+   srwi %r1, %r1, 8/* get byte 7 of pte */
+   tlbli %r0   /* load the itlb */
+   stb %r1, +6(%r2)/* update page table */
+   rfi /* return to executing program */
+
+instr_sec_hash:
+   andi. %r1, %r3, 0x0040  /* see if we have done second hash */
+   bne do_isi  /* if so, go to ISI interrupt */
+   mfspr %r2, SPR_HASH2/* get the second pointer */
+   ori %r3, %r3, 0x0040/* change the compare value */
+   addi %r1, %r0, 8/* load 8 for counter */
+   addi %r2, %r2, -8   /* pre dec for update on load */
+   b im0   /* try second hash */
+
+/* Create a faked ISI interrupt as the address was not found */ 
+do_isi_prot:
+   mfspr %r3, SPR_SRR1 /* get srr1 */
+   andi. %r2, %r3, 0x  /* clean upper srr1 */
+   addis %r2, %r2, 0x0800  /* or in srr<4> = 1 to flag prot
+* violation */
+   b isi1
+do_isi:
+   mfspr %r3, SPR_SRR1 /* get srr1 */
+   andi. %r2, %r3, 0x  /* clean srr1 */
+   addis %r2, %r2, 0x4000  /* or in srr1<1> = 1 to flag pte
+* not found */
+isi1: 
+   mtctr %r0   /* restore counter */
+   mtspr SPR_SRR1, %r2 /* set srr1 */
+   

svn commit: r215123 - stable/8/sys/powerpc/aim

2010-11-11 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Thu Nov 11 14:13:56 2010
New Revision: 215123
URL: http://svn.freebsd.org/changeset/base/215123

Log:
  MFC r198588:
  Turn off Altivec data-stream prefetching before going into power-save
  mode on those CPUs that need it.

Modified:
  stable/8/sys/powerpc/aim/machdep.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/powerpc/aim/machdep.c
==
--- stable/8/sys/powerpc/aim/machdep.c  Thu Nov 11 13:48:48 2010
(r215122)
+++ stable/8/sys/powerpc/aim/machdep.c  Thu Nov 11 14:13:56 2010
(r215123)
@@ -614,8 +614,10 @@ void
 cpu_idle(int busy)
 {
uint32_t msr;
+   uint16_t vers;
 
msr = mfmsr();
+   vers = mfpvr() >> 16;
 
 #ifdef INVARIANTS
if ((msr & PSL_EE) != PSL_EE) {
@@ -625,9 +627,25 @@ cpu_idle(int busy)
}
 #endif
if (powerpc_pow_enabled) {
-   powerpc_sync();
-   mtmsr(msr | PSL_POW);
-   isync();
+   switch (vers) {
+   case IBM970:
+   case IBM970FX:
+   case IBM970MP:
+   case MPC7447A:
+   case MPC7448:
+   case MPC7450:
+   case MPC7455:
+   case MPC7457:
+   __asm __volatile("\
+   dssall; sync; mtmsr %0; isync"
+   :: "r"(msr | PSL_POW));
+   break;
+   default:
+   powerpc_sync();
+   mtmsr(msr | PSL_POW);
+   isync();
+   break;
+   }
}
 }
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215157 - in head/sys/powerpc: aim booke powerpc

2010-11-11 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Nov 12 03:43:22 2010
New Revision: 215157
URL: http://svn.freebsd.org/changeset/base/215157

Log:
  Centralize CPU idle routines into powerpc/cpu.c and use the same
  cpu_idle_hook mechanism that x86 uses for overriding the idle routine.
  This is required for supporting ilding the CPU under PowerPC hypervisors.

Modified:
  head/sys/powerpc/aim/machdep.c
  head/sys/powerpc/booke/machdep.c
  head/sys/powerpc/powerpc/cpu.c

Modified: head/sys/powerpc/aim/machdep.c
==
--- head/sys/powerpc/aim/machdep.c  Fri Nov 12 02:35:21 2010
(r215156)
+++ head/sys/powerpc/aim/machdep.c  Fri Nov 12 03:43:22 2010
(r215157)
@@ -639,64 +639,6 @@ cpu_halt(void)
OF_exit();
 }
 
-void
-cpu_idle(int busy)
-{
-   register_t msr;
-   uint16_t vers;
-
-   msr = mfmsr();
-   vers = mfpvr() >> 16;
-
-#ifdef INVARIANTS
-   if ((msr & PSL_EE) != PSL_EE) {
-   struct thread *td = curthread;
-   printf("td msr %#lx\n", (u_long)td->td_md.md_saved_msr);
-   panic("ints disabled in idleproc!");
-   }
-#endif
-   CTR2(KTR_SPARE2, "cpu_idle(%d) at %d",
-   busy, curcpu);
-   if (powerpc_pow_enabled) {
-   if (!busy) {
-   critical_enter();
-   cpu_idleclock();
-   }
-   switch (vers) {
-   case IBM970:
-   case IBM970FX:
-   case IBM970MP:
-   case MPC7447A:
-   case MPC7448:
-   case MPC7450:
-   case MPC7455:
-   case MPC7457:
-   __asm __volatile("\
-   dssall; sync; mtmsr %0; isync"
-   :: "r"(msr | PSL_POW));
-   break;
-   default:
-   powerpc_sync();
-   mtmsr(msr | PSL_POW);
-   isync();
-   break;
-   }
-   if (!busy) {
-   cpu_activeclock();
-   critical_exit();
-   }
-   }
-   CTR2(KTR_SPARE2, "cpu_idle(%d) at %d done",
-   busy, curcpu);
-}
-
-int
-cpu_idle_wakeup(int cpu)
-{
-
-   return (0);
-}
-
 int
 ptrace_set_pc(struct thread *td, unsigned long addr)
 {

Modified: head/sys/powerpc/booke/machdep.c
==
--- head/sys/powerpc/booke/machdep.cFri Nov 12 02:35:21 2010
(r215156)
+++ head/sys/powerpc/booke/machdep.cFri Nov 12 03:43:22 2010
(r215157)
@@ -468,50 +468,6 @@ cpu_flush_dcache(void *ptr, size_t len)
/* TBD */
 }
 
-/*
- * cpu_idle
- *
- * Set Wait state enable.
- */
-void
-cpu_idle (int busy)
-{
-   register_t msr;
-
-   msr = mfmsr();
-
-#ifdef INVARIANTS
-   if ((msr & PSL_EE) != PSL_EE) {
-   struct thread *td = curthread;
-   printf("td msr %x\n", td->td_md.md_saved_msr);
-   panic("ints disabled in idleproc!");
-   }
-#endif
-
-   CTR2(KTR_SPARE2, "cpu_idle(%d) at %d",
-   busy, curcpu);
-   if (!busy) {
-   critical_enter();
-   cpu_idleclock();
-   }
-   /* Freescale E500 core RM section 6.4.1. */
-   msr = msr | PSL_WE;
-   __asm __volatile("msync; mtmsr %0; isync" :: "r" (msr));
-   if (!busy) {
-   cpu_activeclock();
-   critical_exit();
-   }
-   CTR2(KTR_SPARE2, "cpu_idle(%d) at %d done",
-   busy, curcpu);
-}
-
-int
-cpu_idle_wakeup(int cpu)
-{
-
-   return (0);
-}
-
 void
 spinlock_enter(void)
 {

Modified: head/sys/powerpc/powerpc/cpu.c
==
--- head/sys/powerpc/powerpc/cpu.c  Fri Nov 12 02:35:21 2010
(r215156)
+++ head/sys/powerpc/powerpc/cpu.c  Fri Nov 12 03:43:22 2010
(r215157)
@@ -64,6 +64,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -73,12 +74,15 @@
 #include 
 #include 
 
-int powerpc_pow_enabled;
-
 static voidcpu_6xx_setup(int cpuid, uint16_t vers);
 static voidcpu_e500_setup(int cpuid, uint16_t vers);
 static voidcpu_970_setup(int cpuid, uint16_t vers);
 
+int powerpc_pow_enabled;
+void (*cpu_idle_hook)(void) = NULL;
+static voidcpu_idle_60x(void);
+static voidcpu_idle_e500(void);
+
 struct cputab {
const char  *name;
uint16_tversion;
@@ -374,6 +378,9 @@ cpu_6xx_setup(int cpuid, uint16_t vers)
}
 
printf("cpu%d: HID0 %b\n", cpuid, (int)hid0, bitmask);
+
+   if (cpu_idle_hook == NULL)
+   cpu_idle_hook = cpu_idle_60x;
 }
 
 
@@ -441,6 +448,9 @@ cpu_e500_setup(int cpuid, uint16_t vers)
mtspr(SPR_HID0, hid0);
 
printf("cpu%d: HID0 %b\n", cpuid, (int)hid0, HID0_E500_BITMASK);
+
+

svn commit: r215158 - head/sys/powerpc/aim

2010-11-11 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Nov 12 04:13:48 2010
New Revision: 215158
URL: http://svn.freebsd.org/changeset/base/215158

Log:
  Fix an error in r215067. An existing /chosen/mmu but missing translations
  property just means we shouldn't add any translations, not that we should
  panic.

Modified:
  head/sys/powerpc/aim/mmu_oea64.c

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cFri Nov 12 03:43:22 2010
(r215157)
+++ head/sys/powerpc/aim/mmu_oea64.cFri Nov 12 04:13:48 2010
(r215158)
@@ -1126,14 +1126,14 @@ moea64_bootstrap(mmu_t mmup, vm_offset_t
ofw_pmap.pm_sr[i] = kernel_pmap->pm_sr[i];
#endif
 
-   if ((mmu = OF_instance_to_package(mmui)) == -1)
-   panic("moea64_bootstrap: can't get mmu package");
-   if ((sz = OF_getproplen(mmu, "translations")) == -1)
-   panic("moea64_bootstrap: can't get ofw translation count");
+   mmu = OF_instance_to_package(mmui);
+   if (mmu == -1 || (sz = OF_getproplen(mmu, "translations")) == -1)
+   sz = 0;
if (sz > 6144 /* tmpstksz - 2 KB headroom */)
panic("moea64_bootstrap: too many ofw translations");
 
-   moea64_add_ofw_mappings(mmup, mmu, sz);
+   if (sz > 0)
+   moea64_add_ofw_mappings(mmup, mmu, sz);
}
 
 #ifdef SMP
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215159 - in head/sys: powerpc/aim powerpc/booke powerpc/include powerpc/powerpc sys

2010-11-11 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Nov 12 04:18:19 2010
New Revision: 215159
URL: http://svn.freebsd.org/changeset/base/215159

Log:
  Add some platform KOBJ extensions and continue integrating PowerPC
  hypervisor infrastructure support:
  - Fix coexistence of multiple platform modules in the same kernel
  - Allow platform modules to provide an SMP topology
  - PowerPC hypervisors limit the amount of memory accessible in real mode.
Allow the platform modules to specify the maximum real-mode address,
and modify the bits of the kernel that need to allocate
real-mode-accessible buffers to respect this limits.

Modified:
  head/sys/powerpc/aim/mmu_oea64.c
  head/sys/powerpc/aim/ofw_machdep.c
  head/sys/powerpc/aim/slb.c
  head/sys/powerpc/booke/machdep.c
  head/sys/powerpc/include/platform.h
  head/sys/powerpc/powerpc/mp_machdep.c
  head/sys/powerpc/powerpc/platform.c
  head/sys/powerpc/powerpc/platform_if.m
  head/sys/sys/smp.h

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cFri Nov 12 04:13:48 2010
(r215158)
+++ head/sys/powerpc/aim/mmu_oea64.cFri Nov 12 04:18:19 2010
(r215159)
@@ -2385,6 +2385,9 @@ moea64_bootstrap_alloc(vm_size_t size, u
if (s < phys_avail[i] || e > phys_avail[i + 1])
continue;
 
+   if (s + size > platform_real_maxaddr())
+   continue;
+
if (s == phys_avail[i]) {
phys_avail[i] += size;
} else if (e == phys_avail[i + 1]) {

Modified: head/sys/powerpc/aim/ofw_machdep.c
==
--- head/sys/powerpc/aim/ofw_machdep.c  Fri Nov 12 04:13:48 2010
(r215158)
+++ head/sys/powerpc/aim/ofw_machdep.c  Fri Nov 12 04:18:19 2010
(r215159)
@@ -692,16 +692,3 @@ OF_decode_addr(phandle_t dev, int regno,
return (bus_space_map(*tag, addr, size, 0, handle));
 }
 
-int
-mem_valid(vm_offset_t addr, int len)
-{
-   int i;
-
-   for (i = 0; i < nOFmem; i++)
-   if ((addr >= OFmem[i].mr_start) 
-   && (addr + len < OFmem[i].mr_start + OFmem[i].mr_size))
-   return (0);
-
-   return (EFAULT);
-}
-

Modified: head/sys/powerpc/aim/slb.c
==
--- head/sys/powerpc/aim/slb.c  Fri Nov 12 04:13:48 2010(r215158)
+++ head/sys/powerpc/aim/slb.c  Fri Nov 12 04:18:19 2010(r215159)
@@ -36,9 +36,14 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
+#include 
+#include 
 
 #include 
+#include 
 #include 
 #include 
 
@@ -474,6 +479,51 @@ slb_insert_user(pmap_t pm, struct slb *s
pm->pm_slb[i] = slb;
 }
 
+static void *
+slb_uma_real_alloc(uma_zone_t zone, int bytes, u_int8_t *flags, int wait)
+{
+   static vm_offset_t realmax = 0;
+   void *va;
+   vm_page_t m;
+   int pflags;
+
+   if (realmax == 0)
+   realmax = platform_real_maxaddr();
+
+   *flags = UMA_SLAB_PRIV;
+   if ((wait & (M_NOWAIT|M_USE_RESERVE)) == M_NOWAIT)
+   pflags = VM_ALLOC_INTERRUPT | VM_ALLOC_WIRED;
+   else
+   pflags = VM_ALLOC_SYSTEM | VM_ALLOC_WIRED;
+   if (wait & M_ZERO)
+   pflags |= VM_ALLOC_ZERO;
+
+   for (;;) {
+   m = vm_phys_alloc_contig(1, 0, realmax, PAGE_SIZE,
+   PAGE_SIZE);
+   if (m == NULL) {
+   if (wait & M_NOWAIT)
+   return (NULL);
+   VM_WAIT;
+   } else
+break;
+}
+
+   va = (void *) VM_PAGE_TO_PHYS(m);
+
+   if (!hw_direct_map)
+   pmap_kenter((vm_offset_t)va, VM_PAGE_TO_PHYS(m));
+
+   if ((wait & M_ZERO) && (m->flags & PG_ZERO) == 0)
+   bzero(va, PAGE_SIZE);
+
+   /* vm_phys_alloc_contig does not track wiring */
+   atomic_add_int(&cnt.v_wire_count, 1);
+   m->wire_count = 1;
+
+   return (va);
+}
+
 static void
 slb_zone_init(void *dummy)
 {
@@ -482,6 +532,11 @@ slb_zone_init(void *dummy)
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_VM);
slb_cache_zone = uma_zcreate("SLB cache", 64*sizeof(struct slb *),
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_VM);
+
+   if (platform_real_maxaddr() != VM_MAX_ADDRESS) {
+   uma_zone_set_allocf(slb_cache_zone, slb_uma_real_alloc);
+   uma_zone_set_allocf(slbt_zone, slb_uma_real_alloc);
+   }
 }
 
 struct slb **

Modified: head/sys/powerpc/booke/machdep.c
==
--- head/sys/powerpc/booke/machdep.cFri Nov 12 04:13:48 2010
(r215158)
+++ head/sys/powerpc/booke/machdep.cFri Nov 12 04:18:19 2010
(r215159)
@@ 

svn commit: r215160 - in head/sys/powerpc: aim powerpc

2010-11-11 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Nov 12 04:22:00 2010
New Revision: 215160
URL: http://svn.freebsd.org/changeset/base/215160

Log:
  Remove or conditionalize some hypervisor-unfriendly instruction sequences.

Modified:
  head/sys/powerpc/aim/mmu_oea64.c
  head/sys/powerpc/powerpc/mp_machdep.c

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cFri Nov 12 04:18:19 2010
(r215159)
+++ head/sys/powerpc/aim/mmu_oea64.cFri Nov 12 04:22:00 2010
(r215160)
@@ -1136,10 +1136,6 @@ moea64_bootstrap(mmu_t mmup, vm_offset_t
moea64_add_ofw_mappings(mmup, mmu, sz);
}
 
-#ifdef SMP
-   TLBSYNC();
-#endif
-
/*
 * Calculate the last available physical address.
 */

Modified: head/sys/powerpc/powerpc/mp_machdep.c
==
--- head/sys/powerpc/powerpc/mp_machdep.c   Fri Nov 12 04:18:19 2010
(r215159)
+++ head/sys/powerpc/powerpc/mp_machdep.c   Fri Nov 12 04:22:00 2010
(r215160)
@@ -78,7 +78,13 @@ machdep_ap_bootstrap(void)
;
 
/* Initialize DEC and TB, sync with the BSP values */
+#ifdef __powerpc64__
+   /* Writing to the time base register is hypervisor-privileged */
+   if (mfmsr() & PSL_HV)
+   mttb(ap_timebase);
+#else
mttb(ap_timebase);
+#endif
decr_ap_init();
 
/* Serialize console output and AP count increment */
@@ -240,7 +246,13 @@ cpu_mp_unleash(void *dummy)
/* Let APs continue */
atomic_store_rel_int(&ap_letgo, 1);
 
+#ifdef __powerpc64__
+   /* Writing to the time base register is hypervisor-privileged */
+   if (mfmsr() & PSL_HV)
+   mttb(ap_timebase);
+#else
mttb(ap_timebase);
+#endif
 
while (ap_awake < smp_cpus)
;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215163 - in head/sys: conf powerpc/aim powerpc/ofw

2010-11-11 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Nov 12 05:12:38 2010
New Revision: 215163
URL: http://svn.freebsd.org/changeset/base/215163

Log:
  Remove use of a separate ofw_pmap on 32-bit CPUs. Many Open Firmware
  mappings need to end up in the kernel anyway since the kernel begins
  executing in OF context. Separating them adds needless complexity,
  especially since the powerpc64 and mmu_oea64 code gave up on it a long
  time ago.
  
  As a side effect, the PPC ofw_machdep code is no longer AIM-specific,
  so move it to powerpc/ofw.

Added:
  head/sys/powerpc/ofw/ofw_machdep.c
 - copied, changed from r215159, head/sys/powerpc/aim/ofw_machdep.c
Deleted:
  head/sys/powerpc/aim/ofw_machdep.c
Modified:
  head/sys/conf/files.powerpc
  head/sys/powerpc/aim/machdep.c
  head/sys/powerpc/aim/mmu_oea.c
  head/sys/powerpc/aim/mmu_oea64.c

Modified: head/sys/conf/files.powerpc
==
--- head/sys/conf/files.powerpc Fri Nov 12 05:09:47 2010(r215162)
+++ head/sys/conf/files.powerpc Fri Nov 12 05:12:38 2010(r215163)
@@ -85,7 +85,6 @@ powerpc/aim/mmu_oea.c optionalaim powe
 powerpc/aim/mmu_oea64.coptionalaim
 powerpc/aim/mp_cpudep.coptionalaim smp
 powerpc/aim/nexus.coptionalaim
-powerpc/aim/ofw_machdep.c  optionalaim
 powerpc/aim/ofwmagic.S optionalaim
 powerpc/aim/slb.c  optionalaim powerpc64
 powerpc/aim/swtch32.S  optionalaim powerpc
@@ -131,6 +130,7 @@ powerpc/mpc85xx/nexus.c optionalmpc85x
 powerpc/mpc85xx/openpic_fdt.c  optionalfdt
 powerpc/mpc85xx/pci_fdt.c  optionalpci mpc85xx
 powerpc/ofw/ofw_cpu.c  optionalaim
+powerpc/ofw/ofw_machdep.c  optionalaim
 powerpc/ofw/ofw_pcibus.c   optionalpci aim
 powerpc/ofw/ofw_pcib_pci.c optionalpci aim
 powerpc/ofw/ofw_real.c optionalaim

Modified: head/sys/powerpc/aim/machdep.c
==
--- head/sys/powerpc/aim/machdep.c  Fri Nov 12 05:09:47 2010
(r215162)
+++ head/sys/powerpc/aim/machdep.c  Fri Nov 12 05:12:38 2010
(r215163)
@@ -159,8 +159,6 @@ int setfault(faultbuf); 
 long   Maxmem = 0;
 long   realmem = 0;
 
-struct pmapofw_pmap;
-
 #ifndef __powerpc64__
 struct bat battable[16];
 #endif

Modified: head/sys/powerpc/aim/mmu_oea.c
==
--- head/sys/powerpc/aim/mmu_oea.c  Fri Nov 12 05:09:47 2010
(r215162)
+++ head/sys/powerpc/aim/mmu_oea.c  Fri Nov 12 05:12:38 2010
(r215163)
@@ -197,8 +197,6 @@ static u_intphys_avail_count;
 static int regions_sz, pregions_sz;
 static struct  ofw_map *translations;
 
-extern struct pmap ofw_pmap;
-
 /*
  * Lock for the pteg and pvo tables.
  */
@@ -669,10 +667,7 @@ moea_cpu_bootstrap(mmu_t mmup, int ap)
isync();
 
for (i = 0; i < 16; i++)
-   mtsrin(i << ADDR_SR_SHFT, EMPTY_SEGMENT);
-
-   __asm __volatile("mtsr %0,%1" :: "n"(KERNEL_SR), "r"(KERNEL_SEGMENT));
-   __asm __volatile("mtsr %0,%1" :: "n"(KERNEL2_SR), "r"(KERNEL2_SEGMENT));
+   mtsrin(i << ADDR_SR_SHFT, kernel_pmap->pm_sr[i]);
powerpc_sync();
 
sdr = (u_int)moea_pteg_table | (moea_pteg_mask >> 10);
@@ -859,11 +854,16 @@ moea_bootstrap(mmu_t mmup, vm_offset_t k
moea_vsid_bitmap[0] |= 1;
 
/*
-* Set up the Open Firmware pmap and add it's mappings.
+* Initialize the kernel pmap (which is statically allocated).
+*/
+   PMAP_LOCK_INIT(kernel_pmap);
+   for (i = 0; i < 16; i++)
+   kernel_pmap->pm_sr[i] = EMPTY_SEGMENT + i;
+   kernel_pmap->pm_active = ~0;
+
+   /*
+* Set up the Open Firmware mappings
 */
-   moea_pinit(mmup, &ofw_pmap);
-   ofw_pmap.pm_sr[KERNEL_SR] = KERNEL_SEGMENT;
-   ofw_pmap.pm_sr[KERNEL2_SR] = KERNEL2_SEGMENT;
if ((chosen = OF_finddevice("/chosen")) == -1)
panic("moea_bootstrap: can't find /chosen");
OF_getprop(chosen, "mmu", &mmui, 4);
@@ -900,16 +900,8 @@ moea_bootstrap(mmu_t mmup, vm_offset_t k
 
/* Enter the pages */
for (off = 0; off < translations[i].om_len; off += PAGE_SIZE) {
-   struct  vm_page m;
-
-   m.phys_addr = translations[i].om_pa + off;
-   m.md.mdpg_cache_attrs = VM_MEMATTR_DEFAULT;
-   m.oflags = VPO_BUSY;
-   PMAP_LOCK(&ofw_pmap);
-   moea_enter_locked(&ofw_pmap,
-  translations[i].om_va + off, &m,
-  VM_PROT_ALL, 1);
-   PMAP_UNLOCK(&ofw_pmap);
+   

svn commit: r215182 - in head/sys/powerpc: aim include powerpc

2010-11-12 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Nov 12 15:20:10 2010
New Revision: 215182
URL: http://svn.freebsd.org/changeset/base/215182

Log:
  Add CPU support code for the IBM Cell Broadband Engine.

Modified:
  head/sys/powerpc/aim/mp_cpudep.c
  head/sys/powerpc/include/cpufunc.h
  head/sys/powerpc/include/spr.h
  head/sys/powerpc/powerpc/cpu.c

Modified: head/sys/powerpc/aim/mp_cpudep.c
==
--- head/sys/powerpc/aim/mp_cpudep.cFri Nov 12 14:40:20 2010
(r215181)
+++ head/sys/powerpc/aim/mp_cpudep.cFri Nov 12 15:20:10 2010
(r215182)
@@ -228,6 +228,21 @@ cpudep_save_config(void *dummy)
powerpc_sync();
 
break;
+#ifdef __powerpc64__
+   case IBMCELLBE:
+   if (mfmsr() & PSL_HV) {
+   bsp_state[0] = mfspr(SPR_HID0);
+   bsp_state[1] = mfspr(SPR_HID1);
+   bsp_state[2] = mfspr(SPR_HID4);
+   bsp_state[3] = mfspr(SPR_HID6);
+
+   bsp_state[4] = mfspr(SPR_CELL_TSCR);
+   }
+
+   bsp_state[5] = mfspr(SPR_CELL_TSRL);
+
+   break;
+#endif
case MPC7450:
case MPC7455:
case MPC7457:
@@ -288,6 +303,21 @@ cpudep_ap_setup()
 
powerpc_sync();
break;
+#ifdef __powerpc64__
+   case IBMCELLBE:
+   if (mfmsr() & PSL_HV) {
+   mtspr(SPR_HID0, bsp_state[0]);
+   mtspr(SPR_HID1, bsp_state[1]);
+   mtspr(SPR_HID4, bsp_state[2]);
+   mtspr(SPR_HID6, bsp_state[3]);
+
+   mtspr(SPR_CELL_TSCR, bsp_state[4]);
+   }
+
+   mtspr(SPR_CELL_TSRL, bsp_state[5]);
+
+   break;
+#endif
case MPC7450:
case MPC7455:
case MPC7457:

Modified: head/sys/powerpc/include/cpufunc.h
==
--- head/sys/powerpc/include/cpufunc.h  Fri Nov 12 14:40:20 2010
(r215181)
+++ head/sys/powerpc/include/cpufunc.h  Fri Nov 12 15:20:10 2010
(r215182)
@@ -106,6 +106,17 @@ mfsrin(vm_offset_t va)
 }
 #endif
 
+static __inline register_t
+mfctrl(void)
+{
+   register_t value;
+
+   __asm __volatile ("mfspr %0,136" : "=r"(value));
+
+   return (value);
+}
+
+
 static __inline void
 mtdec(register_t value)
 {

Modified: head/sys/powerpc/include/spr.h
==
--- head/sys/powerpc/include/spr.h  Fri Nov 12 14:40:20 2010
(r215181)
+++ head/sys/powerpc/include/spr.h  Fri Nov 12 15:20:10 2010
(r215182)
@@ -420,6 +420,10 @@
 #defineSPR_HID10x3f1   /* ..8 Hardware Implementation 
Register 1 */
 #defineSPR_HID40x3f4   /* ..8 Hardware Implementation 
Register 4 */
 #defineSPR_HID50x3f6   /* ..8 Hardware Implementation 
Register 5 */
+#defineSPR_HID60x3f9   /* ..8 Hardware Implementation 
Register 6 */
+
+#defineSPR_CELL_TSRL   0x380   /* ... Cell BE Thread Status 
Register */
+#defineSPR_CELL_TSCR   0x399   /* ... Cell BE Thread Switch 
Register */
 
 #if defined(AIM)
 #defineSPR_DBSR0x3f0   /* 4.. Debug Status Register */

Modified: head/sys/powerpc/powerpc/cpu.c
==
--- head/sys/powerpc/powerpc/cpu.c  Fri Nov 12 14:40:20 2010
(r215181)
+++ head/sys/powerpc/powerpc/cpu.c  Fri Nov 12 15:20:10 2010
(r215182)
@@ -149,6 +149,9 @@ static const struct cputab models[] = {
   0, cpu_e500_setup },
 { "Freescale e500v2 core", FSL_E500v2, REVFMT_MAJMIN,
   0, cpu_e500_setup },
+{ "IBM Cell Broadband Engine", IBMCELLBE,  REVFMT_MAJMIN,
+  PPC_FEATURE_64 | PPC_FEATURE_HAS_ALTIVEC | PPC_FEATURE_HAS_FPU,
+  NULL},
 { "Unknown PowerPC CPU",   0,  REVFMT_HEX, 0, NULL },
 };
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215197 - head/sys/powerpc/aim

2010-11-12 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Fri Nov 12 20:26:34 2010
New Revision: 215197
URL: http://svn.freebsd.org/changeset/base/215197

Log:
  Partially revert r215182. There appears to be a silicon bug on the 970
  that causes AP bringup to fail if some of the Cell HID-register code
  is anywhere in the instruction stream. Pending a better solution, cache
  performance on SMP Cell systems running without a hypervisor will be
  suboptimal.

Modified:
  head/sys/powerpc/aim/mp_cpudep.c

Modified: head/sys/powerpc/aim/mp_cpudep.c
==
--- head/sys/powerpc/aim/mp_cpudep.cFri Nov 12 20:01:53 2010
(r215196)
+++ head/sys/powerpc/aim/mp_cpudep.cFri Nov 12 20:26:34 2010
(r215197)
@@ -228,8 +228,8 @@ cpudep_save_config(void *dummy)
powerpc_sync();
 
break;
-#ifdef __powerpc64__
case IBMCELLBE:
+   #ifdef NOTYET /* Causes problems if in instruction stream on 
970 */
if (mfmsr() & PSL_HV) {
bsp_state[0] = mfspr(SPR_HID0);
bsp_state[1] = mfspr(SPR_HID1);
@@ -238,11 +238,11 @@ cpudep_save_config(void *dummy)
 
bsp_state[4] = mfspr(SPR_CELL_TSCR);
}
+   #endif
 
bsp_state[5] = mfspr(SPR_CELL_TSRL);
 
break;
-#endif
case MPC7450:
case MPC7455:
case MPC7457:
@@ -303,8 +303,8 @@ cpudep_ap_setup()
 
powerpc_sync();
break;
-#ifdef __powerpc64__
case IBMCELLBE:
+   #ifdef NOTYET /* Causes problems if in instruction stream on 
970 */
if (mfmsr() & PSL_HV) {
mtspr(SPR_HID0, bsp_state[0]);
mtspr(SPR_HID1, bsp_state[1]);
@@ -313,11 +313,11 @@ cpudep_ap_setup()
 
mtspr(SPR_CELL_TSCR, bsp_state[4]);
}
+   #endif
 
mtspr(SPR_CELL_TSRL, bsp_state[5]);
 
break;
-#endif
case MPC7450:
case MPC7455:
case MPC7457:
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215351 - head/gnu/usr.bin/binutils

2010-11-15 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Nov 15 22:11:18 2010
New Revision: 215351
URL: http://svn.freebsd.org/changeset/base/215351

Log:
  Try including Makefile.${TARGET_ARCH} before Makefile.${TARGET_CPUARCH} if
  it exists in order to allow arch-specific overrides. This fixes the
  binutils (and world) build on powerpc64 after recent TBEMD merges.
  
  Reviewed by:  imp

Modified:
  head/gnu/usr.bin/binutils/Makefile.inc0

Modified: head/gnu/usr.bin/binutils/Makefile.inc0
==
--- head/gnu/usr.bin/binutils/Makefile.inc0 Mon Nov 15 22:05:08 2010
(r215350)
+++ head/gnu/usr.bin/binutils/Makefile.inc0 Mon Nov 15 22:11:18 2010
(r215351)
@@ -36,28 +36,15 @@ CFLAGS+= -DBFD_DEFAULT_TARGET_SIZE=64
 .endif
 
 CFLAGS+= -I.
-.if exists(${.CURDIR}/${TARGET_CPUARCH})
-CFLAGS+= -I${.CURDIR}/${TARGET_CPUARCH}
-.endif
 CFLAGS+= -I${.CURDIR}
 CFLAGS+= -I${.CURDIR}/${RELTOP}/libbfd
 CFLAGS+= -I${.OBJDIR}/${RELTOP}/libbfd
 CFLAGS+= -I${SRCDIR}/include
 
-.if exists(${.CURDIR}/${TARGET_CPUARCH})
-.PATH: ${.CURDIR}/${TARGET_CPUARCH}
-.endif
-
 ARCHS= ${TARGET_CPUARCH}
 
-.for _arch in ${CROSS_ARCH}
-.if (${ARCHS:R:M${_arch:R}} == "")
-ARCHS+= $(_arch)
-.endif
-.endfor
-
-.for _arch in ${ARCHS}
-.if exists(${.CURDIR}/Makefile.${_arch})
-.include "${.CURDIR}/Makefile.${_arch}"
+.if exists(${.CURDIR}/Makefile.${TARGET_ARCH})
+.include "${.CURDIR}/Makefile.${TARGET_ARCH}"
+.elif exists(${.CURDIR}/Makefile.${TARGET_CPUARCH})
+.include "${.CURDIR}/Makefile.${TARGET_CPUARCH}"
 .endif
-.endfor
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215352 - in head/gnu/usr.bin/binutils: as as/powerpc64-freebsd libbfd libopcodes

2010-11-15 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Nov 15 22:12:13 2010
New Revision: 215352
URL: http://svn.freebsd.org/changeset/base/215352

Log:
  Garbage-collect some code made obsolete by the TBEMD import.

Deleted:
  head/gnu/usr.bin/binutils/as/powerpc64-freebsd/
  head/gnu/usr.bin/binutils/libopcodes/Makefile.powerpc64
Modified:
  head/gnu/usr.bin/binutils/as/Makefile
  head/gnu/usr.bin/binutils/libbfd/Makefile

Modified: head/gnu/usr.bin/binutils/as/Makefile
==
--- head/gnu/usr.bin/binutils/as/Makefile   Mon Nov 15 22:11:18 2010
(r215351)
+++ head/gnu/usr.bin/binutils/as/Makefile   Mon Nov 15 22:12:13 2010
(r215352)
@@ -26,7 +26,7 @@ SRCS+=itbl-ops.c itbl-parse.y itbl-lex.
 
 .if ${TARGET_ARCH} == "amd64"
 SRCS+= tc-i386.c
-.elif ${TARGET_ARCH} == "powerpc" || ${TARGET_ARCH} == "powerpc64"
+.elif ${TARGET_CPUARCH} == "powerpc"
 SRCS+= tc-ppc.c
 .elif ${TARGET_ARCH} == "sparc64"
 # change back to tc-sparc.c when new binutils is imported

Modified: head/gnu/usr.bin/binutils/libbfd/Makefile
==
--- head/gnu/usr.bin/binutils/libbfd/Makefile   Mon Nov 15 22:11:18 2010
(r215351)
+++ head/gnu/usr.bin/binutils/libbfd/Makefile   Mon Nov 15 22:12:13 2010
(r215352)
@@ -24,8 +24,6 @@ SELARCH=
 SELARCH= &bfd_i386_arch
 .elif ${TARGET_ARCH} == "sparc64"
 SELARCH= &bfd_sparc_arch
-.elif ${TARGET_ARCH} == "powerpc64"
-SELARCH= &bfd_powerpc_arch,&bfd_rs6000_arch
 .else
 .for _a in ${ARCHS}
 .if ${SELARCH} == ""
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215367 - head/sys/dev/drm

2010-11-15 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Tue Nov 16 03:43:06 2010
New Revision: 215367
URL: http://svn.freebsd.org/changeset/base/215367

Log:
  Make drm(4) build, if not work reliably, on PowerPC.

Modified:
  head/sys/dev/drm/drmP.h
  head/sys/dev/drm/drm_agpsupport.c
  head/sys/dev/drm/drm_drv.c
  head/sys/dev/drm/drm_memory.c
  head/sys/dev/drm/drm_sysctl.c
  head/sys/dev/drm/radeon_cs.c

Modified: head/sys/dev/drm/drmP.h
==
--- head/sys/dev/drm/drmP.h Tue Nov 16 03:20:57 2010(r215366)
+++ head/sys/dev/drm/drmP.h Tue Nov 16 03:43:06 2010(r215367)
@@ -80,7 +80,9 @@ struct drm_file;
 #include 
 #include 
 #include 
+#if defined(__i386__) || defined(__amd64__)
 #include 
+#endif
 #include 
 #include 
 #include 
@@ -246,20 +248,20 @@ typedef u_int8_t u8;
*(volatile u_int8_t *)(((vm_offset_t)(map)->virtual) +  \
(vm_offset_t)(offset))
 #define DRM_READ16(map, offset)
\
-   *(volatile u_int16_t *)(((vm_offset_t)(map)->virtual) + \
-   (vm_offset_t)(offset))
+   le16toh(*(volatile u_int16_t *)(((vm_offset_t)(map)->virtual) + \
+   (vm_offset_t)(offset)))
 #define DRM_READ32(map, offset)
\
-   *(volatile u_int32_t *)(((vm_offset_t)(map)->virtual) + \
-   (vm_offset_t)(offset))
+   le32toh(*(volatile u_int32_t *)(((vm_offset_t)(map)->virtual) + \
+   (vm_offset_t)(offset)))
 #define DRM_WRITE8(map, offset, val)   \
*(volatile u_int8_t *)(((vm_offset_t)(map)->virtual) +  \
(vm_offset_t)(offset)) = val
 #define DRM_WRITE16(map, offset, val)  \
*(volatile u_int16_t *)(((vm_offset_t)(map)->virtual) + \
-   (vm_offset_t)(offset)) = val
+   (vm_offset_t)(offset)) = htole16(val)
 #define DRM_WRITE32(map, offset, val)  \
*(volatile u_int32_t *)(((vm_offset_t)(map)->virtual) + \
-   (vm_offset_t)(offset)) = val
+   (vm_offset_t)(offset)) = htole32(val)
 
 #define DRM_VERIFYAREA_READ( uaddr, size ) \
(!useracc(__DECONST(caddr_t, uaddr), size, VM_PROT_READ))

Modified: head/sys/dev/drm/drm_agpsupport.c
==
--- head/sys/dev/drm/drm_agpsupport.c   Tue Nov 16 03:20:57 2010
(r215366)
+++ head/sys/dev/drm/drm_agpsupport.c   Tue Nov 16 03:43:06 2010
(r215367)
@@ -318,7 +318,7 @@ int drm_agp_bind(struct drm_device *dev,
if (!dev->agp || !dev->agp->acquired)
return EINVAL;
 
-   DRM_DEBUG("agp_bind, page_size=%x\n", PAGE_SIZE);
+   DRM_DEBUG("agp_bind, page_size=%x\n", (int)PAGE_SIZE);
 
entry = drm_agp_lookup_entry(dev, (void *)request->handle);
if (entry == NULL || entry->bound)

Modified: head/sys/dev/drm/drm_drv.c
==
--- head/sys/dev/drm/drm_drv.c  Tue Nov 16 03:20:57 2010(r215366)
+++ head/sys/dev/drm/drm_drv.c  Tue Nov 16 03:43:06 2010(r215367)
@@ -478,7 +478,7 @@ static int drm_load(struct drm_device *d
retcode = ENOMEM;
goto error;
}
-   if (dev->agp != NULL) {
+   if (dev->agp != NULL && dev->agp->info.ai_aperture_base != 0) {
if (drm_mtrr_add(dev->agp->info.ai_aperture_base,
dev->agp->info.ai_aperture_size, DRM_MTRR_WC) == 0)
dev->agp->mtrr = 1;

Modified: head/sys/dev/drm/drm_memory.c
==
--- head/sys/dev/drm/drm_memory.c   Tue Nov 16 03:20:57 2010
(r215366)
+++ head/sys/dev/drm/drm_memory.c   Tue Nov 16 03:43:06 2010
(r215367)
@@ -73,7 +73,7 @@ void drm_mem_uninit(void)
 
 void *drm_ioremap_wc(struct drm_device *dev, drm_local_map_t *map)
 {
-   return pmap_mapdev_attr(map->offset, map->size, PAT_WRITE_COMBINING);
+   return pmap_mapdev_attr(map->offset, map->size, 
VM_MEMATTR_WRITE_COMBINING);
 }
 
 void *drm_ioremap(struct drm_device *dev, drm_local_map_t *map)

Modified: head/sys/dev/drm/drm_sysctl.c
==
--- head/sys/dev/drm/drm_sysctl.c   Tue Nov 16 03:20:57 2010
(r215366)
+++ head/sys/dev/drm/drm_sysctl.c   Tue Nov 16 03:43:06 2010
(r215367)
@@ -259,7 +259,7 @@ static int drm_bufs_info DRM_SYSCTL_HAND
   *(1 << dma->bufs[i].page_order),
   (dma->bufs[i].seg_count
* (1 << dma->bufs[i].page_order))
-  

svn commit: r215688 - stable/8/sys/kern

2010-11-22 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Nov 22 16:58:07 2010
New Revision: 215688
URL: http://svn.freebsd.org/changeset/base/215688

Log:
  MFC r213986:
  Fix an XXX comment by answering 'no'. OS X does not set the day-of-week
  counter on SMU-based systems, which causes FreeBSD to reject the RTC time
  when used in a dual-boot environment. Since we don't use the day-of-week
  counter anyway, solve this by just not checking that it matches.

Modified:
  stable/8/sys/kern/subr_clock.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/kern/subr_clock.c
==
--- stable/8/sys/kern/subr_clock.c  Mon Nov 22 16:47:53 2010
(r215687)
+++ stable/8/sys/kern/subr_clock.c  Mon Nov 22 16:58:07 2010
(r215688)
@@ -165,10 +165,6 @@ clock_ct_to_ts(struct clocktime *ct, str
days += days_in_month(year, i);
days += (ct->day - 1);
 
-   /* XXX Dow sanity check. Dow is not used, so should we check it? */
-   if (ct->dow != -1 && ct->dow != day_of_week(days))
-   return (EINVAL);
-
/* Add hours, minutes, seconds. */
secs = ((days * 24 + ct->hour) * 60 + ct->min) * 60 + ct->sec;
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215689 - stable/8/sys/powerpc/aim

2010-11-22 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Nov 22 17:01:40 2010
New Revision: 215689
URL: http://svn.freebsd.org/changeset/base/215689

Log:
  MFC r214610:
  Map userland copyin/copyout segment no-execute while it is mapped into the
  kernel.

Modified:
  stable/8/sys/powerpc/aim/copyinout.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/powerpc/aim/copyinout.c
==
--- stable/8/sys/powerpc/aim/copyinout.cMon Nov 22 16:58:07 2010
(r215688)
+++ stable/8/sys/powerpc/aim/copyinout.cMon Nov 22 17:01:40 2010
(r215689)
@@ -76,6 +76,9 @@ static __inline void
 set_user_sr(register_t vsid)
 {
 
+   /* Mark segment no-execute */
+   vsid |= SR_N;
+
isync();
__asm __volatile ("mtsr %0,%1" :: "n"(USER_SR), "r"(vsid));
isync();
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215690 - stable/8/sys/powerpc/powermac

2010-11-22 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Nov 22 17:03:09 2010
New Revision: 215690
URL: http://svn.freebsd.org/changeset/base/215690

Log:
  MFC r214575:
  Allow access to the HT I/O port space on the IBM CPC9X5 northbridge chips.

Modified:
  stable/8/sys/powerpc/powermac/cpcht.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/powerpc/powermac/cpcht.c
==
--- stable/8/sys/powerpc/powermac/cpcht.c   Mon Nov 22 17:01:40 2010
(r215689)
+++ stable/8/sys/powerpc/powermac/cpcht.c   Mon Nov 22 17:03:09 2010
(r215690)
@@ -142,6 +142,7 @@ struct cpcht_softc {
vm_offset_t sc_data;
uint64_tsc_populated_slots;
struct  rman sc_mem_rman;
+   struct  rman sc_io_rman;
 
struct cpcht_irqhtirq_map[128];
 };
@@ -156,6 +157,9 @@ static devclass_t   cpcht_devclass;
 
 DRIVER_MODULE(cpcht, nexus, cpcht_driver, cpcht_devclass, 0, 0);
 
+#define CPCHT_IOPORT_BASE  0xf400UL /* Hardwired */
+#define CPCHT_IOPORT_SIZE  0x0040UL
+
 #define HTAPIC_REQUEST_EOI 0x20
 #define HTAPIC_TRIGGER_LEVEL   0x02
 #define HTAPIC_MASK0x01
@@ -215,7 +219,14 @@ cpcht_attach(device_t dev)
sc->sc_mem_rman.rm_type = RMAN_ARRAY;
sc->sc_mem_rman.rm_descr = "CPCHT Device Memory";
error = rman_init(&sc->sc_mem_rman);
+   if (error) {
+   device_printf(dev, "rman_init() failed. error = %d\n", error);
+   return (error);
+   }
 
+   sc->sc_io_rman.rm_type = RMAN_ARRAY;
+   sc->sc_io_rman.rm_descr = "CPCHT I/O Memory";
+   error = rman_init(&sc->sc_io_rman);
if (error) {
device_printf(dev, "rman_init() failed. error = %d\n", error);
return (error);
@@ -227,6 +238,9 @@ cpcht_attach(device_t dev)
 * where we get the HT interrupts properties.
 */
 
+   /* I/O port mappings are usually not in the device tree */
+   rman_manage_region(&sc->sc_io_rman, 0, CPCHT_IOPORT_SIZE - 1);
+
bzero(sc->htirq_map, sizeof(sc->htirq_map));
for (child = OF_child(node); child != 0; child = OF_peer(child))
cpcht_configure_htbridge(dev, child);
@@ -275,6 +289,9 @@ cpcht_configure_htbridge(device_t dev, p
case OFW_PCI_PHYS_HI_SPACE_CONFIG:
break;
case OFW_PCI_PHYS_HI_SPACE_IO:
+   rman_manage_region(&sc->sc_io_rman, rp->pci_lo,
+   rp->pci_lo + rp->size_lo - 1);
+   break;
case OFW_PCI_PHYS_HI_SPACE_MEM32:
rman_manage_region(&sc->sc_mem_rman, rp->pci_lo,
rp->pci_lo + rp->size_lo - 1);
@@ -482,8 +499,9 @@ cpcht_alloc_resource(device_t bus, devic
switch (type) {
case SYS_RES_IOPORT:
end = min(end, start + count);
+   rm = &sc->sc_io_rman;
+   break;
 
-   /* FALLTHROUGH */
case SYS_RES_MEMORY:
rm = &sc->sc_mem_rman;
break;
@@ -537,6 +555,9 @@ cpcht_activate_resource(device_t bus, de
 
start = (vm_offset_t)rman_get_start(res);
 
+   if (type == SYS_RES_IOPORT)
+   start += CPCHT_IOPORT_BASE;
+
if (bootverbose)
printf("cpcht mapdev: start %zx, len %ld\n", start,
rman_get_size(res));
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215691 - stable/8/sys/powerpc/powerpc

2010-11-22 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Nov 22 17:06:24 2010
New Revision: 215691
URL: http://svn.freebsd.org/changeset/base/215691

Log:
  MFC r204127,215101:
  Provide support for the DEEPNAP power-saving mode found on the 970MP.

Modified:
  stable/8/sys/powerpc/powerpc/cpu.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/powerpc/powerpc/cpu.c
==
--- stable/8/sys/powerpc/powerpc/cpu.c  Mon Nov 22 17:03:09 2010
(r215690)
+++ stable/8/sys/powerpc/powerpc/cpu.c  Mon Nov 22 17:06:24 2010
(r215691)
@@ -453,8 +453,16 @@ cpu_970_setup(int cpuid, uint16_t vers)
: "=r" (hid0_hi), "=r" (hid0_lo) : "K" (SPR_HID0));
 
/* Configure power-saving mode */
-   hid0_hi |= (HID0_NAP | HID0_DPM);
-   hid0_hi &= ~(HID0_DOZE | HID0_DEEPNAP);
+   switch (vers) {
+   case IBM970MP:
+   hid0_hi |= (HID0_DEEPNAP | HID0_NAP | HID0_DPM);
+   hid0_hi &= ~HID0_DOZE;
+   break;
+   default:
+   hid0_hi |= (HID0_NAP | HID0_DPM);
+   hid0_hi &= ~(HID0_DOZE | HID0_DEEPNAP);
+   break;
+   }
powerpc_pow_enabled = 1;
 
__asm __volatile (" \
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215692 - stable/8/sys/powerpc/powermac

2010-11-22 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Nov 22 17:09:42 2010
New Revision: 215692
URL: http://svn.freebsd.org/changeset/base/215692

Log:
  MFC r215100:
  Disabling CPU NAP modes during SMU commands is a hack needed only on U3
  systems. Don't use it on non-U3 systems to allow cpu_idle() to work
  correctly.

Modified:
  stable/8/sys/powerpc/powermac/smu.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/powerpc/powermac/smu.c
==
--- stable/8/sys/powerpc/powermac/smu.c Mon Nov 22 17:06:24 2010
(r215691)
+++ stable/8/sys/powerpc/powermac/smu.c Mon Nov 22 17:09:42 2010
(r215692)
@@ -89,6 +89,7 @@ struct smu_softc {
 
struct resource *sc_memr;
int sc_memrid;
+   int sc_u3;
 
bus_dma_tag_t   sc_dmatag;
bus_space_tag_t sc_bt;
@@ -243,6 +244,10 @@ smu_attach(device_t dev)
sc->sc_cur_cmd = NULL;
sc->sc_doorbellirqid = -1;
 
+   sc->sc_u3 = 0;
+   if (OF_finddevice("/u3") != -1)
+   sc->sc_u3 = 1;
+
/*
 * Map the mailbox area. This should be determined from firmware,
 * but I have not found a simple way to do that.
@@ -361,7 +366,9 @@ smu_send_cmd(device_t dev, struct smu_cm
 
mtx_assert(&sc->sc_mtx, MA_OWNED);
 
-   powerpc_pow_enabled = 0;/* SMU cannot work if we go to NAP */
+   if (sc->sc_u3)
+   powerpc_pow_enabled = 0; /* SMU cannot work if we go to NAP */
+
sc->sc_cur_cmd = cmd;
 
/* Copy the command to the mailbox */
@@ -408,7 +415,8 @@ smu_doorbell_intr(void *xdev)
sizeof(sc->sc_cmd->data));
wakeup(sc->sc_cur_cmd);
sc->sc_cur_cmd = NULL;
-   powerpc_pow_enabled = 1;
+   if (sc->sc_u3)
+   powerpc_pow_enabled = 1;
 
 done:
/* Queue next command if one is pending */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215693 - in stable/8/sys/powerpc: aim powermac

2010-11-22 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Nov 22 17:13:04 2010
New Revision: 215693
URL: http://svn.freebsd.org/changeset/base/215693

Log:
  MFC r205506:
  Get nexus(4) out of the RTC business. The interface used by nexus(4)
  in Open Firmware was Apple-specific, and we have complete coverage of Apple
  system controllers, so move RTC responsibilities into the system controller
  drivers. This avoids interesting problems from manipulating these devices
  through Open Firmware behind the backs of their drivers.
  
  Obtained from:NetBSD

Modified:
  stable/8/sys/powerpc/aim/nexus.c
  stable/8/sys/powerpc/powermac/cuda.c
  stable/8/sys/powerpc/powermac/cudavar.h
  stable/8/sys/powerpc/powermac/pmu.c
  stable/8/sys/powerpc/powermac/smu.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/powerpc/aim/nexus.c
==
--- stable/8/sys/powerpc/aim/nexus.cMon Nov 22 17:09:42 2010
(r215692)
+++ stable/8/sys/powerpc/aim/nexus.cMon Nov 22 17:13:04 2010
(r215693)
@@ -60,7 +60,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -74,7 +73,6 @@
 
 #include 
 
-#include "clock_if.h"
 #include "ofw_bus_if.h"
 #include "pic_if.h"
 
@@ -143,12 +141,6 @@ static const char  *nexus_ofw_get_type(de
 static const char  *nexus_ofw_get_compat(device_t, device_t);
 
 /*
- * Clock interface.
- */
-static int nexus_gettime(device_t, struct timespec *);
-static int nexus_settime(device_t, struct timespec *);
-
-/*
  * Local routines
  */
 static device_tnexus_device_from_node(device_t, phandle_t);
@@ -181,10 +173,6 @@ static device_method_t nexus_methods[] =
DEVMETHOD(ofw_bus_get_type, nexus_ofw_get_type),
DEVMETHOD(ofw_bus_get_compat, nexus_ofw_get_compat),
 
-   /* Clock interface */
-   DEVMETHOD(clock_gettime,nexus_gettime),
-   DEVMETHOD(clock_settime,nexus_settime),
-
{ 0, 0 }
 };
 
@@ -240,7 +228,6 @@ nexus_attach(device_t dev)
 
}
 
-   clock_register(dev, 1000);
return (bus_generic_attach(dev));
 }
 
@@ -512,50 +499,3 @@ nexus_ofw_get_compat(device_t bus, devic
return (dinfo->ndi_compatible);
 }
 
-#defineDIFF190419702082844800
-
-static int
-nexus_gettime(device_t dev, struct timespec *ts)
-{
-   char path[128];
-   ihandle_t ih;
-   phandle_t ph;
-   u_int rtc;
-
-   ph = OF_finddevice("rtc");
-   if (ph == -1)
-   return (ENOENT);
-
-   OF_package_to_path(ph, path, sizeof(path));
-   ih = OF_open(path);
-   if (ih == -1)
-   return (ENXIO);
-
-   if (OF_call_method("read-rtc", ih, 0, 1, &rtc))
-   return (EIO);
-
-   ts->tv_sec = rtc - DIFF19041970;
-   ts->tv_nsec = 0;
-   return (0);
-}
-
-static int
-nexus_settime(device_t dev, struct timespec *ts)
-{
-   char path[128];
-   ihandle_t ih;
-   phandle_t ph; 
-   u_int rtc;
-
-   ph = OF_finddevice("rtc"); 
-   if (ph == -1) 
-   return (ENOENT);
-
-   OF_package_to_path(ph, path, sizeof(path));   
-   ih = OF_open(path);
-   if (ih == -1)
-   return (ENXIO);
-
-   rtc = ts->tv_sec + DIFF19041970;
-   return ((OF_call_method("write-rtc", ih, 1, 0, rtc) != 0) ? EIO : 0);
-}

Modified: stable/8/sys/powerpc/powermac/cuda.c
==
--- stable/8/sys/powerpc/powermac/cuda.cMon Nov 22 17:09:42 2010
(r215692)
+++ stable/8/sys/powerpc/powermac/cuda.cMon Nov 22 17:13:04 2010
(r215693)
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -54,6 +55,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
+#include "clock_if.h"
 #include "cudavar.h"
 #include "viareg.h"
 
@@ -71,6 +73,12 @@ static u_int cuda_poll(device_t dev);
 static voidcuda_send_inbound(struct cuda_softc *sc);
 static voidcuda_send_outbound(struct cuda_softc *sc);
 
+/*
+ * Clock interface
+ */
+static int cuda_gettime(device_t dev, struct timespec *ts);
+static int cuda_settime(device_t dev, struct timespec *ts);
+
 static device_method_t  cuda_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, cuda_probe),
@@ -89,6 +97,10 @@ static device_method_t  cuda_methods[] =
DEVMETHOD(adb_hb_controller_poll,   cuda_poll),
DEVMETHOD(adb_hb_set_autopoll_mask, cuda_adb_autopoll),
 
+   /* Clock interface */
+   DEVMETHOD(clock_gettime,cuda_gettime),
+   DEVMETHOD(clock_settime,cuda_settime),
+
{

svn commit: r215694 - stable/8/sys/powerpc/powermac

2010-11-22 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Nov 22 17:14:29 2010
New Revision: 215694
URL: http://svn.freebsd.org/changeset/base/215694

Log:
  MFC r208841:
  Add support for the I2C busses hanging off Apple system management chips.

Modified:
  stable/8/sys/powerpc/powermac/smu.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/powerpc/powermac/smu.c
==
--- stable/8/sys/powerpc/powermac/smu.c Mon Nov 22 17:13:04 2010
(r215693)
+++ stable/8/sys/powerpc/powermac/smu.c Mon Nov 22 17:14:29 2010
(r215694)
@@ -47,12 +47,16 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "clock_if.h"
+#include "iicbus_if.h"
 
 struct smu_cmd {
volatile uint8_t cmd;
@@ -138,6 +142,8 @@ struct smu_softc {
 
 static int smu_probe(device_t);
 static int smu_attach(device_t);
+static const struct ofw_bus_devinfo *
+smu_get_devinfo(device_t bus, device_t dev);
 
 /* cpufreq notification hooks */
 
@@ -152,6 +158,7 @@ static int  smu_settime(device_t dev, str
 static int smu_run_cmd(device_t dev, struct smu_cmd *cmd, int wait);
 static int smu_get_datablock(device_t dev, int8_t id, uint8_t *buf,
size_t len);
+static voidsmu_attach_i2c(device_t dev, phandle_t i2croot);
 static voidsmu_attach_fans(device_t dev, phandle_t fanroot);
 static voidsmu_attach_sensors(device_t dev, phandle_t sensroot);
 static voidsmu_fan_management_proc(void *xdev);
@@ -172,6 +179,16 @@ static device_method_t  smu_methods[] = 
/* Clock interface */
DEVMETHOD(clock_gettime,smu_gettime),
DEVMETHOD(clock_settime,smu_settime),
+
+   /* ofw_bus interface */
+   DEVMETHOD(bus_child_pnpinfo_str,ofw_bus_gen_child_pnpinfo_str),
+   DEVMETHOD(ofw_bus_get_devinfo,  smu_get_devinfo),
+   DEVMETHOD(ofw_bus_get_compat,   ofw_bus_gen_get_compat),
+   DEVMETHOD(ofw_bus_get_model,ofw_bus_gen_get_model),
+   DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name),
+   DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node),
+   DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type),
+
{ 0, 0 },
 };
 
@@ -305,8 +322,14 @@ smu_attach(device_t dev)
 
if (strncmp(name, "sensors", 8) == 0)
smu_attach_sensors(dev, child);
+
+   if (strncmp(name, "smu-i2c-control", 15) == 0)
+   smu_attach_i2c(dev, child);
}
 
+   /* Some SMUs have the I2C children directly under the bus. */
+   smu_attach_i2c(dev, node);
+
/*
 * Collect calibration constants.
 */
@@ -373,7 +396,14 @@ smu_attach(device_t dev)
 */
clock_register(dev, 1000);
 
-   return (0);
+   return (bus_generic_attach(dev));
+}
+
+static const struct ofw_bus_devinfo *
+smu_get_devinfo(device_t bus, device_t dev)
+{
+
+   return (device_get_ivars(dev));
 }
 
 static void
@@ -795,8 +825,8 @@ smu_attach_fans(device_t dev, phandle_t 
CTLTYPE_INT | CTLFLAG_RD, &fan->max_rpm, sizeof(cell_t),
"Maximum allowed RPM");
SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO, "rpm",
-   CTLTYPE_INT | CTLFLAG_RW, dev, sc->sc_nfans,
-   smu_fanrpm_sysctl, "I", "Fan RPM");
+   CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, dev,
+   sc->sc_nfans, smu_fanrpm_sysctl, "I", "Fan RPM");
 
fan++;
sc->sc_nfans++;
@@ -959,8 +989,8 @@ smu_attach_sensors(device_t dev, phandle
sprintf(sysctl_desc,"%s (%s)", sens->location, units);
 
SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(sensroot_oid), OID_AUTO,
-   sysctl_name, CTLTYPE_INT | CTLFLAG_RD, dev, sc->sc_nsensors,
-   smu_sensor_sysctl, "I", sysctl_desc);
+   sysctl_name, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE,
+   dev, sc->sc_nsensors, smu_sensor_sysctl, "I", sysctl_desc);
 
sens++;
sc->sc_nsensors++;
@@ -996,13 +1026,6 @@ smu_manage_fans(device_t smu)
maxtemp = temp;
}
 
-   if (maxtemp < 10) { /* Bail if no good sensors */
-   for (i = 0; i < sc->sc_nfans; i++) 
-   smu_fan_set_rpm(smu, &sc->sc_fans[i],
-   sc->sc_fans[i].unmanaged_rpm);
-   return;
-   }
-
if (maxtemp > sc->sc_critical_temp) {
device_printf(smu, "WARNING: Current system temperature (%d C) "
"exceeds

svn commit: r215695 - in stable/8/sys: conf powerpc/powermac

2010-11-22 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Mon Nov 22 17:15:41 2010
New Revision: 215695
URL: http://svn.freebsd.org/changeset/base/215695

Log:
  MFC r208842:
  Add a driver for the CPU temperature sensors attached over I2C on the
  PowerMac 11,2.

Added:
  stable/8/sys/powerpc/powermac/smusat.c
 - copied unchanged from r208842, head/sys/powerpc/powermac/smusat.c
Modified:
  stable/8/sys/conf/files.powerpc
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/conf/files.powerpc
==
--- stable/8/sys/conf/files.powerpc Mon Nov 22 17:14:29 2010
(r215694)
+++ stable/8/sys/conf/files.powerpc Mon Nov 22 17:15:41 2010
(r215695)
@@ -140,6 +140,7 @@ powerpc/powermac/openpic_macio.c optiona
 powerpc/powermac/pswitch.c optionalpowermac pswitch
 powerpc/powermac/pmu.c optionalpowermac pmu 
 powerpc/powermac/smu.c optionalpowermac smu 
+powerpc/powermac/smusat.c  optionalpowermac smu
 powerpc/powermac/uninorth.coptionalpowermac
 powerpc/powermac/uninorthpci.c optionalpowermac pci
 powerpc/powermac/vcoregpio.c   optionalpowermac 

Copied: stable/8/sys/powerpc/powermac/smusat.c (from r208842, 
head/sys/powerpc/powermac/smusat.c)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/8/sys/powerpc/powermac/smusat.c  Mon Nov 22 17:15:41 2010
(r215695, copy of r208842, head/sys/powerpc/powermac/smusat.c)
@@ -0,0 +1,262 @@
+/*-
+ * Copyright (c) 2010 Nathan Whitehorn
+ * 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 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+struct smu_sensor {
+   cell_t  reg;
+   charlocation[32];
+   enum {
+   SMU_CURRENT_SENSOR,
+   SMU_VOLTAGE_SENSOR,
+   SMU_POWER_SENSOR,
+   SMU_TEMP_SENSOR
+   } type;
+};
+
+static int smusat_probe(device_t);
+static int smusat_attach(device_t);
+static int smusat_sensor_sysctl(SYSCTL_HANDLER_ARGS);
+
+MALLOC_DEFINE(M_SMUSAT, "smusat", "SMU Sattelite Sensors");
+
+static device_method_t  smusat_methods[] = {
+   /* Device interface */
+   DEVMETHOD(device_probe, smusat_probe),
+   DEVMETHOD(device_attach,smusat_attach),
+   { 0, 0 },
+};
+
+struct smusat_softc {
+   struct smu_sensor *sc_sensors;
+   int sc_nsensors;
+
+   uint8_t sc_cache[16];
+   time_t  sc_last_update;
+};
+
+static driver_t smusat_driver = {
+   "smusat",
+   smusat_methods,
+   sizeof(struct smusat_softc)
+};
+
+static devclass_t smusat_devclass;
+
+DRIVER_MODULE(smusat, iicbus, smusat_driver, smusat_devclass, 0, 0);
+
+static int
+smusat_probe(device_t dev)
+{
+   const char *compat = ofw_bus_get_compat(dev);
+
+   if (compat == NULL || strcmp(compat, "smu-sat") != 0)
+   return (ENXIO);
+
+   device_set_desc(dev, "SMU Satellite Sensors");
+   return (0);
+}
+
+static int
+smusat_attach(device_t dev)
+{
+   phandle_t child;
+   struct smu_sensor *sens;
+   struct smusat_softc *sc;
+   struct sysctl_oid *s

svn commit: r215696 - in stable/8/sys: conf powerpc/aim powerpc/booke powerpc/include powerpc/mpc85xx powerpc/powermac powerpc/powerpc

2010-11-22 Thread Nathan Whitehorn
t   cuda_poll(device_t dev);
 static voidcuda_send_inbound(struct cuda_softc *sc);
 static voidcuda_send_outbound(struct cuda_softc *sc);
+static voidcuda_shutdown(void *xsc, int howto);
 
 /*
  * Clock interface
@@ -249,6 +251,8 @@ cuda_attach(device_t dev)
}
 
clock_register(dev, 1000);
+   EVENTHANDLER_REGISTER(shutdown_final, cuda_shutdown, sc,
+   SHUTDOWN_PRI_LAST);
 
return (bus_generic_attach(dev));
 }
@@ -739,6 +743,20 @@ cuda_adb_autopoll(device_t dev, uint16_t
return (0);
 }
 
+static void
+cuda_shutdown(void *xsc, int howto)
+{
+   struct cuda_softc *sc = xsc;
+   uint8_t cmd[] = {CUDA_PSEUDO, 0};
+
+   cmd[1] = (howto & RB_HALT) ? CMD_POWEROFF : CMD_RESET;
+   cuda_poll(sc->sc_dev);
+   cuda_send(sc, 1, 2, cmd);
+
+   while (1)
+   cuda_poll(sc->sc_dev);
+}
+
 #define DIFF19041970   2082844800
 
 static int

Copied: stable/8/sys/powerpc/powermac/platform_powermac.c (from r212054, 
head/sys/powerpc/powermac/platform_powermac.c)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/8/sys/powerpc/powermac/platform_powermac.c   Mon Nov 22 17:39:18 
2010(r215696, copy of r212054, 
head/sys/powerpc/powermac/platform_powermac.c)
@@ -0,0 +1,288 @@
+/*-
+ * Copyright (c) 2008 Marcel Moolenaar
+ * Copyright (c) 2009 Nathan Whitehorn
+ * 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 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "platform_if.h"
+
+#ifdef SMP
+extern void *ap_pcpu;
+#endif
+
+static int powermac_probe(platform_t);
+void powermac_mem_regions(platform_t, struct mem_region **phys, int *physsz,
+struct mem_region **avail, int *availsz);
+static u_long powermac_timebase_freq(platform_t, struct cpuref *cpuref);
+static int powermac_smp_first_cpu(platform_t, struct cpuref *cpuref);
+static int powermac_smp_next_cpu(platform_t, struct cpuref *cpuref);
+static int powermac_smp_get_bsp(platform_t, struct cpuref *cpuref);
+static int powermac_smp_start_cpu(platform_t, struct pcpu *cpu);
+static void powermac_reset(platform_t);
+
+static platform_method_t powermac_methods[] = {
+   PLATFORMMETHOD(platform_probe,  powermac_probe),
+   PLATFORMMETHOD(platform_mem_regions,powermac_mem_regions),
+   PLATFORMMETHOD(platform_timebase_freq,  powermac_timebase_freq),
+   
+   PLATFORMMETHOD(platform_smp_first_cpu,  powermac_smp_first_cpu),
+   PLATFORMMETHOD(platform_smp_next_cpu,   powermac_smp_next_cpu),
+   PLATFORMMETHOD(platform_smp_get_bsp,powermac_smp_get_bsp),
+   PLATFORMMETHOD(platform_smp_start_cpu,  powermac_smp_start_cpu),
+
+   PLATFORMMETHOD(platform_reset,  powermac_reset),
+
+   { 0, 0 }
+};
+
+static platform_def_t powermac_platform = {
+   "powermac",
+   powermac_methods,
+   0
+};
+
+PLATFORM_DEF(powermac_platform);
+
+static int
+powermac_probe(platform_t plat)
+{
+   if (OF_finddevice("/memory") != -1 || OF_finddevice("/mem...@0") != -1)
+   return (BUS_PROBE_GENERIC);
+
+   return (ENXIO);
+}
+
+void
+powermac_mem_regions(platform_t plat, struct mem_region **phys, int *physsz,
+struct mem_region **avail, int *availsz)
+{
+   ofw_mem_regions(phys,physsz,avail,availsz);
+}
+
+static u_long
+powermac_timebase_freq(platform_t plat, struct cpuref *cpuref)
+{
+   phandle_t phandle

svn commit: r215749 - stable/8/sys/dev/iicbus

2010-11-23 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Tue Nov 23 14:13:12 2010
New Revision: 215749
URL: http://svn.freebsd.org/changeset/base/215749

Log:
  MFC r208839,214999:
  Add two new flags (IIC_M_NOSTOP and IIC_M_NOSTART) to struct iic_msg to
  allow consumers of iicbus_transfer() to send messages with repeated starts.
  
  Reviewed by:  imp, thompsa

Modified:
  stable/8/sys/dev/iicbus/iic.h
  stable/8/sys/dev/iicbus/iiconf.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/dev/iicbus/iic.h
==
--- stable/8/sys/dev/iicbus/iic.h   Tue Nov 23 13:55:30 2010
(r215748)
+++ stable/8/sys/dev/iicbus/iic.h   Tue Nov 23 14:13:12 2010
(r215749)
@@ -38,6 +38,8 @@ struct iic_msg
uint16_tflags;
 #defineIIC_M_WR0   /* Fake flag for write */
 #defineIIC_M_RD0x0001  /* read vs write */
+#defineIIC_M_NOSTOP0x0002  /* do not send a I2C stop after message 
*/
+#defineIIC_M_NOSTART   0x0004  /* do not send a I2C start before 
message */
uint16_tlen;/* msg legnth */
uint8_t *   buf;
 };

Modified: stable/8/sys/dev/iicbus/iiconf.c
==
--- stable/8/sys/dev/iicbus/iiconf.cTue Nov 23 13:55:30 2010
(r215748)
+++ stable/8/sys/dev/iicbus/iiconf.cTue Nov 23 14:13:12 2010
(r215749)
@@ -363,7 +363,7 @@ iicbus_transfer(device_t bus, struct iic
 int
 iicbus_transfer_gen(device_t dev, struct iic_msg *msgs, uint32_t nmsgs)
 {
-   int i, error, lenread, lenwrote, nkid;
+   int i, error, lenread, lenwrote, nkid, rpstart, addr;
device_t *children, bus;
 
if ((error = device_get_children(dev, &children, &nkid)) != 0)
@@ -373,14 +373,38 @@ iicbus_transfer_gen(device_t dev, struct
return (EIO);
}
bus = children[0];
+   rpstart = 0;
free(children, M_TEMP);
for (i = 0, error = 0; i < nmsgs && error == 0; i++) {
+   addr = msgs[i].slave;
if (msgs[i].flags & IIC_M_RD)
-   error = iicbus_block_read(bus, msgs[i].slave,
-   msgs[i].buf, msgs[i].len, &lenread);
+   addr |= LSB;
else
-   error = iicbus_block_write(bus, msgs[i].slave,
-   msgs[i].buf, msgs[i].len, &lenwrote);
+   addr &= ~LSB;
+
+   if (!(msgs[i].flags & IIC_M_NOSTART)) {
+   if (rpstart)
+   error = iicbus_repeated_start(bus, addr, 0);
+   else
+   error = iicbus_start(bus, addr, 0);
+   }
+
+   if (error)
+   break;
+
+   if (msgs[i].flags & IIC_M_RD)
+   error = iicbus_read(bus, msgs[i].buf, msgs[i].len,
+   &lenread, IIC_LAST_READ, 0);
+   else
+   error = iicbus_write(bus, msgs[i].buf, msgs[i].len,
+   &lenwrote, 0);
+
+   if (!(msgs[i].flags & IIC_M_NOSTOP)) {
+   rpstart = 0;
+   iicbus_stop(bus);
+   } else {
+   rpstart = 1;/* Next message gets repeated start */
+   }
}
return (error);
 }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215752 - head/usr.bin/locate/locate

2010-11-23 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Tue Nov 23 15:08:56 2010
New Revision: 215752
URL: http://svn.freebsd.org/changeset/base/215752

Log:
  Properly use SCHAR_MAX instead of CHAR_MAX for 0x7f. This fixes operation
  of locate(1) on systems on which char is unsigned by default (ARM and
  PowerPC).
  
  Reported by:  Paul Mather
  MFC after:4 days

Modified:
  head/usr.bin/locate/locate/locate.h

Modified: head/usr.bin/locate/locate/locate.h
==
--- head/usr.bin/locate/locate/locate.h Tue Nov 23 14:36:14 2010
(r215751)
+++ head/usr.bin/locate/locate/locate.h Tue Nov 23 15:08:56 2010
(r215752)
@@ -48,15 +48,15 @@
 #define LDC_MAX28
 
 /* 128-255 bigram codes (128 most common, as determined by 'updatedb') */
-#define BIGRAM_MIN(UCHAR_MAX - CHAR_MAX) 
+#define BIGRAM_MIN(UCHAR_MAX - SCHAR_MAX) 
 #define BIGRAM_MAXUCHAR_MAX
 
 /* 32-127  single character (printable) ascii residue (ie, literal) */
 #define ASCII_MIN  32
-#define ASCII_MAX CHAR_MAX
+#define ASCII_MAX SCHAR_MAX
 
-/* #define TO7BIT(x) (x = ( ((u_char)x) & CHAR_MAX )) */
-#define TO7BIT(x) (x = x & CHAR_MAX )
+/* #define TO7BIT(x) (x = ( ((u_char)x) & SCHAR_MAX )) */
+#define TO7BIT(x) (x = x & SCHAR_MAX )
 
 
 #if UCHAR_MAX >= 4096
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215919 - in stable/8/sys/boot/ofw: common libofw

2010-11-26 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Nov 27 00:36:11 2010
New Revision: 215919
URL: http://svn.freebsd.org/changeset/base/215919

Log:
  MFC r214493,214495:
  Fix some memory management issues discovered when trying to boot the PPC
  OF loader on systems where address cells and size cells are both 2 (the
  Mambo simulator) and fix an error where cons_probe() was called before
  init_heap() but used malloc() to set environment variables.

Modified:
  stable/8/sys/boot/ofw/common/main.c
  stable/8/sys/boot/ofw/libofw/ofw_memory.c
  stable/8/sys/boot/ofw/libofw/openfirm.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/boot/ofw/common/main.c
==
--- stable/8/sys/boot/ofw/common/main.c Sat Nov 27 00:26:19 2010
(r215918)
+++ stable/8/sys/boot/ofw/common/main.c Sat Nov 27 00:36:11 2010
(r215919)
@@ -41,19 +41,23 @@ extern char bootprog_rev[];
 extern char bootprog_date[];
 extern char bootprog_maker[];
 
-u_int32_t  acells;
+u_int32_t  acells, scells;
 
 static char bootargs[128];
 
 #defineHEAP_SIZE   0x8
 
+#define OF_puts(fd, text) OF_write(fd, text, strlen(text))
+
 void
 init_heap(void)
 {
void*base;
+   ihandle_t stdout;
 
if ((base = ofw_alloc_heap(HEAP_SIZE)) == (void *)0x) {
-   printf("Heap memory claim failed!\n");
+   OF_getprop(chosen, "stdout", &stdout, sizeof(stdout));
+   OF_puts(stdout, "Heap memory claim failed!\n");
OF_enter();
}
 
@@ -64,25 +68,20 @@ uint64_t
 memsize(void)
 {
phandle_t   memoryp;
-   struct ofw_reg  reg[4];
-   struct ofw_reg2 reg2[8];
-   int i;
-   u_int64_t   sz, memsz;
+   cell_t  reg[24];
+   int i, sz;
+   u_int64_t   memsz;
 
+   memsz = 0;
memoryp = OF_instance_to_package(memory);
 
-   if (acells == 1) {
-   sz = OF_getprop(memoryp, "reg", ®, sizeof(reg));
-   sz /= sizeof(struct ofw_reg);
-
-   for (i = 0, memsz = 0; i < sz; i++)
-   memsz += reg[i].size;
-   } else if (acells == 2) {
-   sz = OF_getprop(memoryp, "reg", ®2, sizeof(reg2));
-   sz /= sizeof(struct ofw_reg2);
+   sz = OF_getprop(memoryp, "reg", ®, sizeof(reg));
+   sz /= sizeof(reg[0]);
 
-   for (i = 0, memsz = 0; i < sz; i++)
-   memsz += reg2[i].size;
+   for (i = 0; i < sz; i += (acells + scells)) {
+   if (scells > 1)
+   memsz += (uint64_t)reg[i + acells] << 32;
+   memsz += reg[i + acells + scells - 1];
}
 
return (memsz);
@@ -105,13 +104,9 @@ main(int (*openfirm)(void *))
 
root = OF_finddevice("/");
 
-   acells = 1;
+   scells = acells = 1;
OF_getprop(root, "#address-cells", &acells, sizeof(acells));
-
-   /*
- * Set up console.
- */
-   cons_probe();
+   OF_getprop(root, "#size-cells", &scells, sizeof(scells));
 
/*
 * Initialise the heap as early as possible.  Once this is done,
@@ -121,6 +116,11 @@ main(int (*openfirm)(void *))
init_heap();
 
/*
+ * Set up console.
+ */
+   cons_probe();
+
+   /*
 * March through the device switch probing for things.
 */
for (i = 0; devsw[i] != NULL; i++)

Modified: stable/8/sys/boot/ofw/libofw/ofw_memory.c
==
--- stable/8/sys/boot/ofw/libofw/ofw_memory.c   Sat Nov 27 00:26:19 2010
(r215918)
+++ stable/8/sys/boot/ofw/libofw/ofw_memory.c   Sat Nov 27 00:36:11 2010
(r215919)
@@ -118,13 +118,19 @@ ofw_memmap(int acells)
 void *
 ofw_alloc_heap(unsigned int size)
 {
-   phandle_t   memoryp;
-   struct  ofw_reg available;
+   phandle_t   memoryp, root;
+   cell_t  available[4];
+   cell_t  acells;
+
+   root = OF_finddevice("/");
+   acells = 1;
+   OF_getprop(root, "#address-cells", &acells, sizeof(acells));
 
memoryp = OF_instance_to_package(memory);
-   OF_getprop(memoryp, "available", &available, sizeof(available));
+   OF_getprop(memoryp, "available", available, sizeof(available));
 
-   heap_base = OF_claim((void *)available.base, size, sizeof(register_t));
+   heap_base = OF_claim((void *)available[acells-1], size,
+   sizeof(register_t));
 
if (heap_base != (void *)-1) {
heap_size = size;

Modified: stable/8/sys/boot/ofw/libofw/openfirm.c
===

svn commit: r215920 - stable/8/sys/boot/ofw/libofw

2010-11-26 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Nov 27 00:37:13 2010
New Revision: 215920
URL: http://svn.freebsd.org/changeset/base/215920

Log:
  MFC r214494:
  Fix netboot on some Apple machines on which calling dma-free on the
  network device can hang the machine. This causes the loss of 64 KB of
  accessible memory on netbooted machines.

Modified:
  stable/8/sys/boot/ofw/libofw/ofw_net.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/boot/ofw/libofw/ofw_net.c
==
--- stable/8/sys/boot/ofw/libofw/ofw_net.c  Sat Nov 27 00:36:11 2010
(r215919)
+++ stable/8/sys/boot/ofw/libofw/ofw_net.c  Sat Nov 27 00:37:13 2010
(r215920)
@@ -230,7 +230,10 @@ punt:
 static void
 ofwn_end(struct netif *nif)
 {
+#ifdef BROKEN
+   /* dma-free freezes at least some Apple ethernet controllers */
OF_call_method("dma-free", netinstance, 2, 0, dmabuf, MAXPHYS);
+#endif
OF_close(netinstance);
 }
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r215921 - stable/8/usr.bin/locate/locate

2010-11-26 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Sat Nov 27 00:46:57 2010
New Revision: 215921
URL: http://svn.freebsd.org/changeset/base/215921

Log:
  MFC r215752:
  Properly use SCHAR_MAX instead of CHAR_MAX for 0x7f. This fixes operation
  of locate(1) on systems on which char is unsigned by default (ARM and
  PowerPC).
  
  Reported by:  Paul Mather

Modified:
  stable/8/usr.bin/locate/locate/locate.h
Directory Properties:
  stable/8/usr.bin/locate/   (props changed)

Modified: stable/8/usr.bin/locate/locate/locate.h
==
--- stable/8/usr.bin/locate/locate/locate.h Sat Nov 27 00:37:13 2010
(r215920)
+++ stable/8/usr.bin/locate/locate/locate.h Sat Nov 27 00:46:57 2010
(r215921)
@@ -48,15 +48,15 @@
 #define LDC_MAX28
 
 /* 128-255 bigram codes (128 most common, as determined by 'updatedb') */
-#define BIGRAM_MIN(UCHAR_MAX - CHAR_MAX) 
+#define BIGRAM_MIN(UCHAR_MAX - SCHAR_MAX) 
 #define BIGRAM_MAXUCHAR_MAX
 
 /* 32-127  single character (printable) ascii residue (ie, literal) */
 #define ASCII_MIN  32
-#define ASCII_MAX CHAR_MAX
+#define ASCII_MAX SCHAR_MAX
 
-/* #define TO7BIT(x) (x = ( ((u_char)x) & CHAR_MAX )) */
-#define TO7BIT(x) (x = x & CHAR_MAX )
+/* #define TO7BIT(x) (x = ( ((u_char)x) & SCHAR_MAX )) */
+#define TO7BIT(x) (x = x & SCHAR_MAX )
 
 
 #if UCHAR_MAX >= 4096
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r216113 - head/gnu/usr.bin/cc

2010-12-01 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Thu Dec  2 04:58:07 2010
New Revision: 216113
URL: http://svn.freebsd.org/changeset/base/216113

Log:
  The driver-XXX.c files used for host CPU detection with -march=native
  should not be compiled in the cross-tools case (where -march=native makes
  no sense). This fixes cross-building x86 toolchains on non-x86 systems.

Modified:
  head/gnu/usr.bin/cc/Makefile.fe

Modified: head/gnu/usr.bin/cc/Makefile.fe
==
--- head/gnu/usr.bin/cc/Makefile.fe Thu Dec  2 04:28:01 2010
(r216112)
+++ head/gnu/usr.bin/cc/Makefile.fe Thu Dec  2 04:58:07 2010
(r216113)
@@ -19,7 +19,8 @@ CFLAGS+= ${DRIVER_DEFINES}
 
 SRCS=  gcc.c opts-common.c options.c intl.c prefix.c version.c
 
-.if exists(${GCCDIR}/config/${GCC_CPU}/driver-${GCC_CPU}.c)
+.if ${TARGET_ARCH} == ${MACHINE_ARCH} && \
+   exists(${GCCDIR}/config/${GCC_CPU}/driver-${GCC_CPU}.c)
 SRCS+=  driver-${GCC_CPU}.c
 .endif
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


  1   2   3   4   5   6   7   8   9   10   >