Author: nwhitehorn
Date: Sun Oct 20 16:14:03 2013
New Revision: 256792
URL: http://svnweb.freebsd.org/changeset/base/256792

Log:
  Unify the AIM and Book-E vm_machdep.c implementations, which previously
  differed only with respect to the AIM version not following style(9) and
  some additional features for 64-bit systems and machines with direct maps
  in the AIM implementation that are no-ops on Book-E (at least for now).

Added:
  head/sys/powerpc/powerpc/vm_machdep.c
     - copied, changed from r256769, head/sys/powerpc/aim/vm_machdep.c
Deleted:
  head/sys/powerpc/aim/vm_machdep.c
  head/sys/powerpc/booke/vm_machdep.c
Modified:
  head/sys/conf/files.powerpc

Modified: head/sys/conf/files.powerpc
==============================================================================
--- head/sys/conf/files.powerpc Sun Oct 20 15:24:44 2013        (r256791)
+++ head/sys/conf/files.powerpc Sun Oct 20 16:14:03 2013        (r256792)
@@ -101,7 +101,6 @@ powerpc/aim/swtch32.S               optional        aim powe
 powerpc/aim/swtch64.S          optional        aim powerpc64
 powerpc/aim/trap.c             optional        aim
 powerpc/aim/uma_machdep.c      optional        aim
-powerpc/aim/vm_machdep.c       optional        aim
 powerpc/booke/clock.c          optional        booke
 powerpc/booke/copyinout.c      optional        booke
 powerpc/booke/interrupt.c      optional        booke
@@ -113,7 +112,6 @@ powerpc/booke/platform_bare.c       optional        m
 powerpc/booke/pmap.c           optional        booke
 powerpc/booke/swtch.S          optional        booke
 powerpc/booke/trap.c           optional        booke
-powerpc/booke/vm_machdep.c     optional        booke
 powerpc/cpufreq/dfs.c          optional        cpufreq
 powerpc/cpufreq/pcr.c          optional        cpufreq aim
 powerpc/fpu/fpu_add.c          optional        fpu_emu powerpc
@@ -214,6 +212,7 @@ powerpc/powerpc/suswintr.c  standard
 powerpc/powerpc/syncicache.c   standard
 powerpc/powerpc/sys_machdep.c  standard
 powerpc/powerpc/uio_machdep.c  standard
+powerpc/powerpc/vm_machdep.c   standard
 powerpc/ps3/ehci_ps3.c         optional        ps3 ehci
 powerpc/ps3/ohci_ps3.c         optional        ps3 ohci
 powerpc/ps3/if_glc.c           optional        ps3 glc

Copied and modified: head/sys/powerpc/powerpc/vm_machdep.c (from r256769, 
head/sys/powerpc/aim/vm_machdep.c)
==============================================================================
--- head/sys/powerpc/aim/vm_machdep.c   Sat Oct 19 10:00:51 2013        
(r256769, copy source)
+++ head/sys/powerpc/powerpc/vm_machdep.c       Sun Oct 20 16:14:03 2013        
(r256792)
@@ -108,7 +108,7 @@
  */
 
 #ifndef NSFBUFS
-#define NSFBUFS         (512 + maxusers * 16)
+#define NSFBUFS                (512 + maxusers * 16)
 #endif
 
 static int nsfbufs;
@@ -205,7 +205,9 @@ cpu_fork(struct thread *td1, struct proc
        #else
        pcb->pcb_lr = (register_t)fork_trampoline;
        #endif
+       #ifdef AIM
        pcb->pcb_cpu.aim.usr_vsid = 0;
+       #endif
 
        /* Setup to release spin count in fork_exit(). */
        td2->td_md.md_spinlock_count = 1;
@@ -223,12 +225,9 @@ cpu_fork(struct thread *td1, struct proc
  * This is needed to make kernel threads stay in kernel mode.
  */
 void
-cpu_set_fork_handler(td, func, arg)
-       struct thread *td;
-       void (*func)(void *);
-       void *arg;
+cpu_set_fork_handler(struct thread *td, void (*func)(void *), void *arg)
 {
-       struct  callframe *cf;
+       struct callframe *cf;
 
        CTR4(KTR_PROC, "%s called with td=%p func=%p arg=%p",
            __func__, td, func, arg);
@@ -240,9 +239,9 @@ cpu_set_fork_handler(td, func, arg)
 }
 
 void
-cpu_exit(td)
-       register struct thread *td;
+cpu_exit(struct thread *td)
 {
+
 }
 
 /*
@@ -251,29 +250,29 @@ cpu_exit(td)
 static void
 sf_buf_init(void *arg)
 {
-        struct sf_buf *sf_bufs;
-        vm_offset_t sf_base;
-        int i;
+       struct sf_buf *sf_bufs;
+       vm_offset_t sf_base;
+       int i;
 
        /* Don't bother on systems with a direct map */
-
        if (hw_direct_map)
                return;
 
-        nsfbufs = NSFBUFS;
-        TUNABLE_INT_FETCH("kern.ipc.nsfbufs", &nsfbufs);
+       nsfbufs = NSFBUFS;
+       TUNABLE_INT_FETCH("kern.ipc.nsfbufs", &nsfbufs);
 
-        sf_buf_active = hashinit(nsfbufs, M_TEMP, &sf_buf_hashmask);
-        TAILQ_INIT(&sf_buf_freelist);
-        sf_base = kva_alloc(nsfbufs * PAGE_SIZE);
-        sf_bufs = malloc(nsfbufs * sizeof(struct sf_buf), M_TEMP, M_NOWAIT | 
M_ZERO);
-
-        for (i = 0; i < nsfbufs; i++) {
-                sf_bufs[i].kva = sf_base + i * PAGE_SIZE;
-                TAILQ_INSERT_TAIL(&sf_buf_freelist, &sf_bufs[i], free_entry);
-        }
-        sf_buf_alloc_want = 0;
-        mtx_init(&sf_buf_lock, "sf_buf", NULL, MTX_DEF);
+       sf_buf_active = hashinit(nsfbufs, M_TEMP, &sf_buf_hashmask);
+       TAILQ_INIT(&sf_buf_freelist);
+       sf_base = kva_alloc(nsfbufs * PAGE_SIZE);
+       sf_bufs = malloc(nsfbufs * sizeof(struct sf_buf), M_TEMP,
+           M_NOWAIT | M_ZERO);
+
+       for (i = 0; i < nsfbufs; i++) {
+               sf_bufs[i].kva = sf_base + i * PAGE_SIZE;
+               TAILQ_INSERT_TAIL(&sf_buf_freelist, &sf_bufs[i], free_entry);
+       }
+       sf_buf_alloc_want = 0;
+       mtx_init(&sf_buf_lock, "sf_buf", NULL, MTX_DEF);
 }
 
 /*
@@ -282,64 +281,63 @@ sf_buf_init(void *arg)
 struct sf_buf *
 sf_buf_alloc(struct vm_page *m, int flags)
 {
-        struct sf_head *hash_list;
-        struct sf_buf *sf;
-        int error;
+       struct sf_head *hash_list;
+       struct sf_buf *sf;
+       int error;
 
        if (hw_direct_map) {
                /* Shortcut the direct mapped case */
-
                return ((struct sf_buf *)m);
        }
 
-        hash_list = &sf_buf_active[SF_BUF_HASH(m)];
-        mtx_lock(&sf_buf_lock);
-        LIST_FOREACH(sf, hash_list, list_entry) {
-                if (sf->m == m) {
-                        sf->ref_count++;
-                        if (sf->ref_count == 1) {
-                                TAILQ_REMOVE(&sf_buf_freelist, sf, free_entry);
-                                nsfbufsused++;
-                                nsfbufspeak = imax(nsfbufspeak, nsfbufsused);
-                        }
-                        goto done;
-                }
-        }
-
-        while ((sf = TAILQ_FIRST(&sf_buf_freelist)) == NULL) {
-                if (flags & SFB_NOWAIT)
-                        goto done;
-
-                sf_buf_alloc_want++;
-                SFSTAT_INC(sf_allocwait);
-                error = msleep(&sf_buf_freelist, &sf_buf_lock,
-                    (flags & SFB_CATCH) ? PCATCH | PVM : PVM, "sfbufa", 0);
-                sf_buf_alloc_want--;
-
-                /*
-                 * If we got a signal, don't risk going back to sleep.
-                 */
-                if (error)
-                        goto done;
-        }
-
-        TAILQ_REMOVE(&sf_buf_freelist, sf, free_entry);
-        if (sf->m != NULL)
-                LIST_REMOVE(sf, list_entry);
-
-        LIST_INSERT_HEAD(hash_list, sf, list_entry);
-        sf->ref_count = 1;
-        sf->m = m;
-        nsfbufsused++;
-        nsfbufspeak = imax(nsfbufspeak, nsfbufsused);
-        pmap_qenter(sf->kva, &sf->m, 1);
+       hash_list = &sf_buf_active[SF_BUF_HASH(m)];
+       mtx_lock(&sf_buf_lock);
+       LIST_FOREACH(sf, hash_list, list_entry) {
+               if (sf->m == m) {
+                       sf->ref_count++;
+                       if (sf->ref_count == 1) {
+                               TAILQ_REMOVE(&sf_buf_freelist, sf, free_entry);
+                               nsfbufsused++;
+                               nsfbufspeak = imax(nsfbufspeak, nsfbufsused);
+                       }
+                       goto done;
+               }
+       }
+
+       while ((sf = TAILQ_FIRST(&sf_buf_freelist)) == NULL) {
+               if (flags & SFB_NOWAIT)
+                       goto done;
+
+               sf_buf_alloc_want++;
+               SFSTAT_INC(sf_allocwait);
+               error = msleep(&sf_buf_freelist, &sf_buf_lock,
+                   (flags & SFB_CATCH) ? PCATCH | PVM : PVM, "sfbufa", 0);
+               sf_buf_alloc_want--;
+
+               /*
+                * If we got a signal, don't risk going back to sleep.
+                */
+               if (error)
+                       goto done;
+       }
+
+       TAILQ_REMOVE(&sf_buf_freelist, sf, free_entry);
+       if (sf->m != NULL)
+               LIST_REMOVE(sf, list_entry);
+
+       LIST_INSERT_HEAD(hash_list, sf, list_entry);
+       sf->ref_count = 1;
+       sf->m = m;
+       nsfbufsused++;
+       nsfbufspeak = imax(nsfbufspeak, nsfbufsused);
+       pmap_qenter(sf->kva, &sf->m, 1);
 done:
-        mtx_unlock(&sf_buf_lock);
-        return (sf);
+       mtx_unlock(&sf_buf_lock);
+       return (sf);
 }
 
 /*
- * Detatch mapped page and release resources back to the system.
+ * Detach mapped page and release resources back to the system.
  *
  * Remove a reference from the given sf_buf, adding it to the free
  * list when its reference count reaches zero. A freed sf_buf still,
@@ -352,16 +350,16 @@ sf_buf_free(struct sf_buf *sf)
        if (hw_direct_map)
                return;
 
-        mtx_lock(&sf_buf_lock);
-        sf->ref_count--;
-        if (sf->ref_count == 0) {
-                TAILQ_INSERT_TAIL(&sf_buf_freelist, sf, free_entry);
-                nsfbufsused--;
-
-                if (sf_buf_alloc_want > 0)
-                        wakeup(&sf_buf_freelist);
-        }
-        mtx_unlock(&sf_buf_lock);
+       mtx_lock(&sf_buf_lock);
+       sf->ref_count--;
+       if (sf->ref_count == 0) {
+               TAILQ_INSERT_TAIL(&sf_buf_freelist, sf, free_entry);
+               nsfbufsused--;
+
+               if (sf_buf_alloc_want > 0)
+                       wakeup(&sf_buf_freelist);
+       }
+       mtx_unlock(&sf_buf_lock);
 }
 
 /*
@@ -381,18 +379,15 @@ swi_vm(void *dummy)
  * dumping the ``ISA memory hole'' which could cause indefinite hangs,
  * or other unpredictable behaviour.
  */
-
-
 int
-is_physical_memory(addr)
-       vm_offset_t addr;
+is_physical_memory(vm_offset_t addr)
 {
+
        /*
         * stuff other tests for known memory-mapped devices (PCI?)
         * here
         */
-
-       return 1;
+       return (1);
 }
 
 /*
@@ -404,10 +399,12 @@ is_physical_memory(addr)
 void
 cpu_thread_swapin(struct thread *td)
 {
+
 }
 
 void
 cpu_thread_swapout(struct thread *td)
 {
+
 }
 
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to