Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/powerpc Make things a bit more LP64 friendly.



details:   https://anonhg.NetBSD.org/src/rev/795b2e14a27e
branches:  trunk
changeset: 542730:795b2e14a27e
user:      matt <matt%NetBSD.org@localhost>
date:      Wed Feb 05 07:05:19 2003 +0000

description:
Make things a bit more LP64 friendly.

diffstat:

 sys/arch/powerpc/include/oea/bat.h  |   18 +-
 sys/arch/powerpc/include/oea/pmap.h |   20 +--
 sys/arch/powerpc/include/oea/pte.h  |   29 +++-
 sys/arch/powerpc/oea/oea_machdep.c  |    4 +-
 sys/arch/powerpc/oea/pmap.c         |  237 ++++++++++++++++-------------------
 5 files changed, 147 insertions(+), 161 deletions(-)

diffs (truncated from 875 to 300 lines):

diff -r 8bc1ec6abddf -r 795b2e14a27e sys/arch/powerpc/include/oea/bat.h
--- a/sys/arch/powerpc/include/oea/bat.h        Wed Feb 05 05:10:58 2003 +0000
+++ b/sys/arch/powerpc/include/oea/bat.h        Wed Feb 05 07:05:19 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bat.h,v 1.1 2003/02/03 17:10:05 matt Exp $     */
+/*     $NetBSD: bat.h,v 1.2 2003/02/05 07:05:19 matt Exp $     */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -71,25 +71,25 @@
 #define        _POWERPC_OEA_BAT_H_
 
 struct bat {
-       u_int32_t batu;
-       u_int32_t batl;
+       register_t batu;
+       register_t batl;
 };
 
 /* Lower BAT bits (all but PowerPC 601): */
-#define        BAT_PBS         0xfffe0000      /* physical block start */
+#define        BAT_RPN         0xfffe0000      /* physical block start */
 #define        BAT_W           0x00000040      /* 1 = write-through, 0 = write-back */
 #define        BAT_I           0x00000020      /* cache inhibit */
 #define        BAT_M           0x00000010      /* memory coherency enable */
 #define        BAT_G           0x00000008      /* guarded region (not on 601) */
 
-#define        BAT_PP      0x00000003  /* PP mask */
+#define        BAT_PP          0x00000003      /* PP mask */
 #define        BAT_PP_NONE     0x00000000      /* no access permission */
 #define        BAT_PP_RO_S     0x00000001      /* read-only (soft) */
 #define        BAT_PP_RW       0x00000002      /* read/write */
 #define        BAT_PP_RO       0x00000003      /* read-only */
 
 /* Upper BAT bits (all but PowerPC 601): */
-#define        BAT_EBS         0xfffe0000      /* effective block start */
+#define        BAT_EPI         0xfffe0000      /* effective block start */
 #define        BAT_BL          0x00001ffc      /* block length */
 #define        BAT_Vs          0x00000002      /* valid in supervisor mode */
 #define        BAT_Vu          0x00000001      /* valid in user mode */
@@ -111,13 +111,13 @@
 #define        BAT_BL_256M     0x00001ffc
 
 #define        BATU(va, len, v)                                                \
-       (((va) & BAT_EBS) | ((len) & BAT_BL) | ((v) & BAT_V))
+       (((va) & BAT_EPI) | ((len) & BAT_BL) | ((v) & BAT_V))
 
 #define        BATL(pa, wimg, pp)                                              \
-       (((pa) & BAT_PBS) | (wimg) | (pp))
+       (((pa) & BAT_RPN) | (wimg) | (pp))
 
 #define BAT_VA_MATCH_P(batu,va) \
-  (((~(((batu)&BAT_BL)<<15))&(va)&BAT_EBS)==((batu)&BAT_EBS))
+  (((~(((batu)&BAT_BL)<<15))&(va)&BAT_EPI)==((batu)&BAT_EPI))
 
 #define BAT_VALID_P(batu, msr) \
   (((msr)&PSL_PR)?(((batu)&BAT_Vu)==BAT_Vu):(((batu)&BAT_Vs)==BAT_Vs))
diff -r 8bc1ec6abddf -r 795b2e14a27e sys/arch/powerpc/include/oea/pmap.h
--- a/sys/arch/powerpc/include/oea/pmap.h       Wed Feb 05 05:10:58 2003 +0000
+++ b/sys/arch/powerpc/include/oea/pmap.h       Wed Feb 05 07:05:19 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.h,v 1.1 2003/02/03 17:10:05 matt Exp $    */
+/*     $NetBSD: pmap.h,v 1.2 2003/02/05 07:05:19 matt Exp $    */
 
 /*-
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -36,31 +36,21 @@
 
 #include <powerpc/oea/pte.h>
 
-/*
- * Segment registers
- */
-#ifndef        _LOCORE
-typedef u_int sr_t;
-#endif /* _LOCORE */
-#define        SR_TYPE         0x80000000
-#define        SR_SUKEY        0x40000000
-#define        SR_PRKEY        0x20000000
-#define        SR_VSID         0x00ffffff
-
 #ifndef _LOCORE
 /*
  * Pmap stuff
  */
 struct pmap {
-       sr_t pm_sr[16];         /* segments used in this pmap */
-       int pm_refs;            /* ref count */
+       register_t pm_sr[16];                   /* segments used in this pmap */
+       int pm_refs;                            /* ref count */
        struct pmap_statistics pm_stats;        /* pmap statistics */
-       unsigned int pm_evictions;      /* pvo's not in page table */
+       unsigned int pm_evictions;              /* pvo's not in page table */
 };
 
 typedef        struct pmap *pmap_t;
 
 #ifdef _KERNEL
+extern register_t iosrtable[];
 extern int pmap_use_altivec;
 extern struct pmap kernel_pmap_;
 #define        pmap_kernel()   (&kernel_pmap_)
diff -r 8bc1ec6abddf -r 795b2e14a27e sys/arch/powerpc/include/oea/pte.h
--- a/sys/arch/powerpc/include/oea/pte.h        Wed Feb 05 05:10:58 2003 +0000
+++ b/sys/arch/powerpc/include/oea/pte.h        Wed Feb 05 07:05:19 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pte.h,v 1.1 2003/02/03 17:10:05 matt Exp $     */
+/*     $NetBSD: pte.h,v 1.2 2003/02/05 07:05:19 matt Exp $     */
 
 /*-
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -41,15 +41,23 @@
  */
 #ifndef        _LOCORE
 struct pte {
-       u_int pte_hi;
-       u_int pte_lo;
+       register_t pte_hi;
+       register_t pte_lo;
+};
+
+struct pteg {
+       struct pte pt[8];
 };
 #endif /* _LOCORE */
+
 /* High word: */
 #define        PTE_VALID       0x80000000
+#define        PTE_VSID        0x7fffff80
 #define        PTE_VSID_SHFT   7
+#define        PTE_VSID_LEN    24
 #define        PTE_HID         0x00000040
 #define        PTE_API         0x0000003f
+#define        PTE_API_SHFT    0
 /* Low word: */
 #define        PTE_RPGN        0xfffff000
 #define        PTE_RPGN_SHFT   12
@@ -71,10 +79,6 @@
 
 #define        PTE_EXEC        0x00000200      /* pseudo bit in attrs; page is exec */
 
-#ifndef        _LOCORE
-typedef        struct pte pte_t;
-#endif /* _LOCORE */
-
 /*
  * Extract bits from address
  */
@@ -83,5 +87,16 @@
 #define        ADDR_PIDX_SHFT  12
 #define        ADDR_API_SHFT   22
 #define        ADDR_POFF       0x00000fff
+#define        ADDR_SEG_WIDTH  4
+
+/*
+ * Segment registers
+ */
+#define SR_KEY_LEN     4               /* key bit width */
+#define        SR_TYPE         0x80000000      /* T=0 selects memory format */
+#define        SR_SUKEY        0x40000000      /* Supervisor protection key */
+#define        SR_PRKEY        0x20000000      /* User protection key */
+#define        SR_NOEXEC       0x10000000      /* No-execute protection bit */
+#define        SR_VSID         0x00ffffff      /* Virtual segment ID */
 
 #endif /* _POWERPC_OEA_PTE_H_ */
diff -r 8bc1ec6abddf -r 795b2e14a27e sys/arch/powerpc/oea/oea_machdep.c
--- a/sys/arch/powerpc/oea/oea_machdep.c        Wed Feb 05 05:10:58 2003 +0000
+++ b/sys/arch/powerpc/oea/oea_machdep.c        Wed Feb 05 07:05:19 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: oea_machdep.c,v 1.1 2003/02/03 17:10:10 matt Exp $     */
+/*     $NetBSD: oea_machdep.c,v 1.2 2003/02/05 07:05:20 matt Exp $     */
 
 /*
  * Copyright (C) 2002 Matt Thomas
@@ -95,7 +95,7 @@
 extern struct user *proc0paddr;
 
 struct bat battable[512];
-sr_t iosrtable[16];    /* I/O segments, for kernel_pmap setup */
+register_t iosrtable[16];      /* I/O segments, for kernel_pmap setup */
 paddr_t msgbuf_paddr;
 
 void
diff -r 8bc1ec6abddf -r 795b2e14a27e sys/arch/powerpc/oea/pmap.c
--- a/sys/arch/powerpc/oea/pmap.c       Wed Feb 05 05:10:58 2003 +0000
+++ b/sys/arch/powerpc/oea/pmap.c       Wed Feb 05 07:05:19 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.1 2003/02/03 17:10:10 matt Exp $    */
+/*     $NetBSD: pmap.c,v 1.2 2003/02/05 07:05:20 matt Exp $    */
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -101,16 +101,11 @@
 #define        STATIC  static
 #endif
 
-struct pteg {
-       pte_t pt[8];
-};
-typedef struct pteg pteg_t;
-
 #ifdef ALTIVEC
 int pmap_use_altivec;
 #endif
 
-volatile pteg_t *pmap_pteg_table;
+volatile struct pteg *pmap_pteg_table;
 unsigned int pmap_pteg_cnt;
 unsigned int pmap_pteg_mask;
 paddr_t pmap_memlimit = -NBPG;         /* there is no limit */
@@ -131,8 +126,6 @@
 static struct mem_region *mem, *avail;
 static u_int mem_cnt, avail_cnt;
 
-extern sr_t iosrtable[16];
-
 #ifdef __HAVE_PMAP_PHYSSEG
 /*
  * This is a cache of referenced/modified bits.
@@ -205,7 +198,7 @@
 };
 
 #if defined(DEBUG) || defined(PMAPCHECK) || defined(DDB)
-void pmap_pte_print(volatile pte_t *);
+void pmap_pte_print(volatile struct pte *);
 #endif
 
 #ifdef DDB
@@ -231,12 +224,12 @@
 #else
 #define        PMAP_PVO_CHECK(pvo)     do { } while (/*CONSTCOND*/0)
 #endif
-STATIC int pmap_pte_insert(int, pte_t *);
+STATIC int pmap_pte_insert(int, struct pte *);
 STATIC int pmap_pvo_enter(pmap_t, struct pool *, struct pvo_head *,
-       vaddr_t, paddr_t, u_int, int);
+       vaddr_t, paddr_t, register_t, int);
 STATIC void pmap_pvo_remove(struct pvo_entry *, int);
 STATIC struct pvo_entry *pmap_pvo_find_va(pmap_t, vaddr_t, int *); 
-STATIC volatile pte_t *pmap_pvo_to_pte(const struct pvo_entry *, int);
+STATIC volatile struct pte *pmap_pvo_to_pte(const struct pvo_entry *, int);
 
 STATIC void tlbia(void);
 
@@ -404,25 +397,25 @@
 #define        MFSRIN(va)      mfsrin(va)
 #define        MFTB()          mfrtcltbl()
 
-static __inline sr_t
+static __inline register_t
 mfsrin(vaddr_t va)
 {
-       sr_t sr;
+       register_t sr;
        __asm __volatile ("mfsrin %0,%1" : "=r"(sr) : "r"(va));
        return sr;
 }
 
-static __inline u_int32_t
+static __inline register_t
 pmap_interrupts_off(void)
 {
-       u_int32_t msr = MFMSR();
+       register_t msr = MFMSR();
        if (msr & PSL_EE)
                MTMSR(msr & ~PSL_EE);
        return msr;
 }
 
 static void
-pmap_interrupts_restore(u_int32_t msr)
+pmap_interrupts_restore(register_t msr)
 {
        if (msr & PSL_EE)
                MTMSR(msr);
@@ -464,18 +457,18 @@
        SYNC();
 }
 
-static __inline int
-va_to_sr(sr_t *sr, vaddr_t va)
+static __inline register_t
+va_to_vsid(const struct pmap *pm, vaddr_t addr)
 {
-       return sr[(uintptr_t)va >> ADDR_SR_SHFT];
+       return (pm->pm_sr[addr >> ADDR_SR_SHFT] & SR_VSID);
 }
 
-static __inline int
-va_to_pteg(sr_t sr, vaddr_t addr)
+static __inline register_t
+va_to_pteg(const struct pmap *pm, vaddr_t addr)
 {
-       int hash;
-       
-       hash = (sr & SR_VSID) ^ (((u_int)addr & ADDR_PIDX) >> ADDR_PIDX_SHFT);
+       register_t hash;
+
+       hash = va_to_vsid(pm, addr) ^ ((addr & ADDR_PIDX) >> ADDR_PIDX_SHFT);
        return hash & pmap_pteg_mask;



Home | Main Index | Thread Index | Old Index