Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/uebayasi-xip]: src/sys/arch/powerpc/ibm4xx Merge botch.
details: https://anonhg.NetBSD.org/src/rev/dea9f879dd66
branches: uebayasi-xip
changeset: 751811:dea9f879dd66
user: uebayasi <uebayasi%NetBSD.org@localhost>
date: Fri Oct 22 07:37:27 2010 +0000
description:
Merge botch.
diffstat:
sys/arch/powerpc/ibm4xx/pmap.c.work | 1922 -----------------------------------
1 files changed, 0 insertions(+), 1922 deletions(-)
diffs (truncated from 1926 to 300 lines):
diff -r 21da4891eec2 -r dea9f879dd66 sys/arch/powerpc/ibm4xx/pmap.c.work
--- a/sys/arch/powerpc/ibm4xx/pmap.c.work Fri Oct 22 07:21:53 2010 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1922 +0,0 @@
-/* $NetBSD: pmap.c.work,v 1.1.2.1 2010/08/17 06:45:02 uebayasi Exp $ */
-
-/*
- * Copyright 2001 Wasabi Systems, Inc.
- * All rights reserved.
- *
- * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed for the NetBSD Project by
- * Wasabi Systems, Inc.
- * 4. The name of Wasabi Systems, Inc. may not be used to endorse
- * or promote products derived from this software without specific prior
- * written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
- * 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.
- */
-
-/*
- * Copyright (C) 1995, 1996 Wolfgang Solfrank.
- * Copyright (C) 1995, 1996 TooLs GmbH.
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by TooLs GmbH.
- * 4. The name of TooLs GmbH may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c.work,v 1.1.2.1 2010/08/17 06:45:02 uebayasi Exp $");
-
-#include "opt_xip.h"
-
-#include <sys/param.h>
-#include <sys/malloc.h>
-#include <sys/proc.h>
-#include <sys/queue.h>
-#include <sys/systm.h>
-#include <sys/pool.h>
-#include <sys/device.h>
-
-#include <uvm/uvm.h>
-
-#include <machine/cpu.h>
-#include <machine/pcb.h>
-#include <machine/powerpc.h>
-
-#include <powerpc/spr.h>
-#include <powerpc/ibm4xx/spr.h>
-#include <machine/tlb.h>
-
-/*
- * kernmap is an array of PTEs large enough to map in
- * 4GB. At 16KB/page it is 256K entries or 2MB.
- */
-#define KERNMAP_SIZE ((0xffffffffU/PAGE_SIZE)+1)
-void *kernmap;
-
-#define MINCTX 2
-#define NUMCTX 256
-
-volatile struct pmap *ctxbusy[NUMCTX];
-
-#define TLBF_USED 0x1
-#define TLBF_REF 0x2
-#define TLBF_LOCKED 0x4
-#define TLB_LOCKED(i) (tlb_info[(i)].ti_flags & TLBF_LOCKED)
-
-typedef struct tlb_info_s {
- char ti_flags;
- char ti_ctx; /* TLB_PID assiciated with the entry */
- u_int ti_va;
-} tlb_info_t;
-
-volatile tlb_info_t tlb_info[NTLB];
-/* We'll use a modified FIFO replacement policy cause it's cheap */
-volatile int tlbnext;
-
-static int tlb_nreserved = 0;
-static int pmap_bootstrap_done = 0;
-
-/* Event counters */
-struct evcnt tlbmiss_ev = EVCNT_INITIALIZER(EVCNT_TYPE_TRAP,
- NULL, "cpu", "tlbmiss");
-struct evcnt tlbhit_ev = EVCNT_INITIALIZER(EVCNT_TYPE_TRAP,
- NULL, "cpu", "tlbhit");
-struct evcnt tlbflush_ev = EVCNT_INITIALIZER(EVCNT_TYPE_TRAP,
- NULL, "cpu", "tlbflush");
-struct evcnt tlbenter_ev = EVCNT_INITIALIZER(EVCNT_TYPE_TRAP,
- NULL, "cpu", "tlbenter");
-
-struct pmap kernel_pmap_;
-struct pmap *const kernel_pmap_ptr = &kernel_pmap_;
-
-static int npgs;
-static u_int nextavail;
-#ifndef MSGBUFADDR
-extern paddr_t msgbuf_paddr;
-#endif
-
-static struct mem_region *mem, *avail;
-
-#define PV_WIRED 0x1
-#define PV_WIRE(pv) ((pv)->pv_va |= PV_WIRED)
-#define PV_UNWIRE(pv) ((pv)->pv_va &= ~PV_WIRED)
-#define PV_ISWIRED(pv) ((pv)->pv_va & PV_WIRED)
-#define PV_CMPVA(va,pv) (!(((pv)->pv_va ^ (va)) & (~PV_WIRED)))
-
-struct pv_entry {
- struct pv_entry *pv_next; /* Linked list of mappings */
- vaddr_t pv_va; /* virtual address of mapping */
- struct pmap *pv_pm;
-};
-
-/* Each index corresponds to TLB_SIZE_* value. */
-static size_t tlbsize[] = {
- 1024, /* TLB_SIZE_1K */
- 4096, /* TLB_SIZE_4K */
- 16384, /* TLB_SIZE_16K */
- 65536, /* TLB_SIZE_64K */
- 262144, /* TLB_SIZE_256K */
- 1048576, /* TLB_SIZE_1M */
- 4194304, /* TLB_SIZE_4M */
- 16777216, /* TLB_SIZE_16M */
-};
-
-static struct pool pv_pool;
-
-static int pmap_initialized;
-
-static int ctx_flush(int);
-
-inline struct pv_entry *pa_to_pv(paddr_t);
-static inline char *pa_to_attr(paddr_t);
-
-static inline volatile u_int *pte_find(struct pmap *, vaddr_t);
-static inline int pte_enter(struct pmap *, vaddr_t, u_int);
-
-static inline int pmap_enter_pv(struct pmap *, vaddr_t, paddr_t, int);
-static void pmap_remove_pv(struct pmap *, vaddr_t, paddr_t);
-
-static int ppc4xx_tlb_size_mask(size_t, int *, int *);
-
-
-inline struct pv_entry *
-pa_to_pv(paddr_t pa)
-{
- int bank, pg;
-
-#ifdef XIP
- bank = vm_physseg_find_device(atop(pa), &pg);
- if (bank != -1)
- return &VM_PHYSDEV_PTR(bank)->pmseg.pvent[pg];
-#endif
- bank = vm_physseg_find(atop(pa), &pg);
- if (bank != -1)
- return &VM_PHYSMEM_PTR(bank)->pmseg.pvent[pg];
- return NULL;
-}
-
-static inline char *
-pa_to_attr(paddr_t pa)
-{
- int bank, pg;
-
-#ifdef XIP
- bank = vm_physseg_find_device(atop(pa), &pg);
- if (bank != -1)
- return &VM_PHYSDEV_PTR(bank)->pmseg.attrs[pg];
-#endif
- bank = vm_physseg_find(atop(pa), &pg);
- if (bank != -1)
- return &VM_PHYSMEM_PTR(bank)->pmseg.attrs[pg];
- return NULL;
-}
-
-/*
- * Insert PTE into page table.
- */
-int
-pte_enter(struct pmap *pm, vaddr_t va, u_int pte)
-{
- int seg = STIDX(va);
- int ptn = PTIDX(va);
- u_int oldpte;
-
- if (!pm->pm_ptbl[seg]) {
- /* Don't allocate a page to clear a non-existent mapping. */
- if (!pte)
- return (0);
- /* Allocate a page XXXX this will sleep! */
- pm->pm_ptbl[seg] =
- (uint *)uvm_km_alloc(kernel_map, PAGE_SIZE, 0,
- UVM_KMF_WIRED | UVM_KMF_ZERO);
- }
- oldpte = pm->pm_ptbl[seg][ptn];
- pm->pm_ptbl[seg][ptn] = pte;
-
- /* Flush entry. */
- ppc4xx_tlb_flush(va, pm->pm_ctx);
- if (oldpte != pte) {
- if (pte == 0)
- pm->pm_stats.resident_count--;
- else
- pm->pm_stats.resident_count++;
- }
- return (1);
-}
-
-/*
- * Get a pointer to a PTE in a page table.
- */
-volatile u_int *
-pte_find(struct pmap *pm, vaddr_t va)
-{
- int seg = STIDX(va);
- int ptn = PTIDX(va);
-
- if (pm->pm_ptbl[seg])
- return (&pm->pm_ptbl[seg][ptn]);
-
- return (NULL);
-}
-
-/*
- * This is called during initppc, before the system is really initialized.
- */
-void
-pmap_bootstrap(u_int kernelstart, u_int kernelend)
-{
- struct mem_region *mp, *mp1;
- int cnt, i;
- u_int s, e, sz;
-
- tlbnext = tlb_nreserved;
-
- /*
- * Allocate the kernel page table at the end of
- * kernel space so it's in the locked TTE.
- */
- kernmap = (void *)kernelend;
-
- /*
- * Initialize kernel page table.
- */
- for (i = 0; i < STSZ; i++) {
- pmap_kernel()->pm_ptbl[i] = 0;
- }
- ctxbusy[0] = ctxbusy[1] = pmap_kernel();
-
- /*
- * Announce page-size to the VM-system
- */
- uvmexp.pagesize = NBPG;
- uvm_setpagesize();
-
Home |
Main Index |
Thread Index |
Old Index