Subject: make paddr_t 64bit on arc port
To: None <port-mips@netbsd.org>
From: Noriyuki Soda <soda@sra.co.jp>
List: port-mips
Date: 06/07/2000 23:16:30
I'd like to change paddr_t from 32bit to 64bit on arc port before
NetBSD-1.5 branch cut by introducing symbol "_MIPS_PADDR_T_64BIT" in
<machine/types.h>.
e.g. the following will be <machine/types.h> of arc port:
#define _MIPS_PADDR_T_64BIT
#include <mips/types.h>
The relevant changes to port-independent mips part is attached below,
Is there any problem with this?
I will also rename
vad_to_pfn() -> mips_paddr_to_tlbpfn()
pfn_to_vad() -> mips_tlbpfn_to_paddr()
as Jason suggested on port-mips, Mar 27.
--
soda
Index: include/mips3_pte.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/mips/include/mips3_pte.h,v
retrieving revision 1.11
diff -u -r1.11 mips3_pte.h
--- mips3_pte.h 2000/03/27 02:55:13 1.11
+++ mips3_pte.h 2000/06/07 14:00:30
@@ -117,10 +117,9 @@
/* pte accessor macros */
#define mips3_pfn_is_ext(x) ((x) & 0x3c000000)
-#define mips3_vad_to_pfn(x) (((unsigned)(x) >> MIPS3_PG_SHIFT) & MIPS3_PG_FRAME)
-#define mips3_vad_to_pfn64(x) (((quad_t)(x) >> MIPS3_PG_SHIFT) & MIPS3_PG_FRAME)
-#define mips3_pfn_to_vad(x) (((x) & MIPS3_PG_FRAME) << MIPS3_PG_SHIFT)
-#define mips3_vad_to_vpn(x) ((unsigned)(x) & MIPS3_PG_SVPN)
+#define mips3_vad_to_pfn(x) (((paddr_t)(x) >> MIPS3_PG_SHIFT) & MIPS3_PG_FRAME)
+#define mips3_pfn_to_vad(x) ((paddr_t)((x) & MIPS3_PG_FRAME) << MIPS3_PG_SHIFT)
+#define mips3_vad_to_vpn(x) ((vaddr_t)(x) & MIPS3_PG_SVPN)
#define mips3_vpn_to_vad(x) ((x) & MIPS3_PG_SVPN)
#define MIPS3_PTE_TO_PADDR(pte) (mips3_pfn_to_vad(pte))
Index: include/mips_param.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/mips/include/mips_param.h,v
retrieving revision 1.19
diff -u -r1.19 mips_param.h
--- mips_param.h 2000/03/27 02:55:14 1.19
+++ mips_param.h 2000/06/07 14:00:30
@@ -73,7 +73,17 @@
/*
* Mach derived conversion macros
*/
#define mips_round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1))
#define mips_trunc_page(x) ((unsigned)(x) & ~(NBPG-1))
-#define mips_btop(x) ((unsigned)(x) >> PGSHIFT)
-#define mips_ptob(x) ((unsigned)(x) << PGSHIFT)
+#define mips_btop(x) ((paddr_t)(x) >> PGSHIFT)
+#define mips_ptob(x) ((paddr_t)(x) << PGSHIFT)
Index: include/pte.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/mips/include/pte.h,v
retrieving revision 1.8
diff -u -r1.8 pte.h
--- pte.h 1999/05/28 07:23:38 1.8
+++ pte.h 2000/06/07 14:00:30
@@ -140,11 +140,11 @@
mips_pg_ropage_bit(void),
mips_pg_cwpage_bit(void),
mips_pg_rwpage_bit(void),
- mips_pg_global_bit(void),
- PTE_TO_PADDR(unsigned int entry);
+ mips_pg_global_bit(void);
+static __inline paddr_t PTE_TO_PADDR(unsigned int pte);
-static __inline vaddr_t pfn_to_vad(unsigned int x);
-static __inline int vad_to_pfn(vaddr_t x);
+static __inline paddr_t pfn_to_vad(unsigned int pfn);
+static __inline unsigned int vad_to_pfn(paddr_t pa);
static __inline int
@@ -230,7 +230,7 @@
return (MIPS1_PG_WIRED);
}
-static __inline unsigned int
+static __inline paddr_t
PTE_TO_PADDR(pte)
unsigned int pte;
{
@@ -249,22 +249,22 @@
return (MIPS1_PAGE_IS_RDONLY(pte, va));
}
-static __inline vaddr_t
-pfn_to_vad(x)
- unsigned int x;
+static __inline paddr_t
+pfn_to_vad(pfn)
+ unsigned int pfn;
{
if (CPUISMIPS3)
- return (mips3_pfn_to_vad(x));
- return (mips1_pfn_to_vad(x));
+ return (mips3_pfn_to_vad(pfn));
+ return (mips1_pfn_to_vad(pfn));
}
-static __inline int
-vad_to_pfn(x)
- vaddr_t x;
+static __inline unsigned int
+vad_to_pfn(pa)
+ paddr_t pa;
{
if (CPUISMIPS3)
- return (mips3_vad_to_pfn(x));
- return (mips1_vad_to_pfn(x));
+ return (mips3_vad_to_pfn(pa));
+ return (mips1_vad_to_pfn(pa));
}
#endif
Index: include/types.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/mips/include/types.h,v
retrieving revision 1.23
diff -u -r1.23 types.h
--- types.h 2000/06/06 02:24:02 1.23
+++ types.h 2000/06/07 14:00:30
@@ -72,8 +72,13 @@
/* NB: This should probably be if defined(_KERNEL) */
#if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
+#ifdef _MIPS_PADDR_T_64BIT
+typedef unsigned long long paddr_t;
+typedef unsigned long long psize_t;
+#else
typedef unsigned long paddr_t;
typedef unsigned long psize_t;
+#endif
typedef unsigned long vaddr_t;
typedef unsigned long vsize_t;
#endif
Index: mips/pmap.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/mips/mips/pmap.c,v
retrieving revision 1.97
diff -u -r1.97 pmap.c
--- pmap.c 2000/05/09 13:40:13 1.97
+++ pmap.c 2000/06/07 14:00:37
@@ -704,7 +704,7 @@
/* remove entries from kernel pmap */
#ifdef PARANOIADIAG
- if (sva < VM_MIN_KERNEL_ADDRESS || eva > virtual_end)
+ if (sva < VM_MIN_KERNEL_ADDRESS || eva >= virtual_end)
panic("pmap_remove: kva not in range");
#endif
pte = kvtopte(sva);
@@ -893,7 +893,7 @@
* read-only.
*/
#ifdef PARANOIADIAG
- if (sva < VM_MIN_KERNEL_ADDRESS || eva > virtual_end)
+ if (sva < VM_MIN_KERNEL_ADDRESS || eva >= virtual_end)
panic("pmap_protect: kva not in range");
#endif
pte = kvtopte(sva);
@@ -976,13 +976,16 @@
pmap = p->p_vmspace->vm_map.pmap;
if (CPUISMIPS3) {
+#ifdef MIPS3
#if 0
printf("pmap_procwr: va %lx len %lx\n", va, len);
#endif
MachFlushDCache(va, len);
MachFlushICache(MIPS_PHYS_TO_KSEG0(va &
(mips_L1ICacheSize - 1)), len);
+#endif /* MIPS3 */
} else {
+#ifdef MIPS1
pt_entry_t *pte;
unsigned entry;
@@ -1004,6 +1007,7 @@
#if 0
printf("\n");
#endif
+#endif /* MIPS1 */
}
}
@@ -1118,21 +1122,27 @@
#ifdef PARANOIADIAG
if (!pmap)
panic("pmap_enter: pmap");
+#endif
+#if defined(DEBUG) || defined(DIAGNOSTIC) || defined(PARANOIADIAG)
if (pmap == pmap_kernel()) {
#ifdef DEBUG
enter_stats.kernel++;
#endif
if (va < VM_MIN_KERNEL_ADDRESS || va >= virtual_end)
- panic("pmap_enter: kva");
+ panic("pmap_enter: kva too big");
} else {
#ifdef DEBUG
enter_stats.user++;
#endif
if (va >= VM_MAXUSER_ADDRESS)
- panic("pmap_enter: uva");
+ panic("pmap_enter: uva too big");
}
- if (pa & 0x80000000)
+#endif
+#ifdef PARANOIADIAG
+#if defined(cobalt) || defined(newsmips) || defined(pmax) /* otherwise ok */
+ if (pa & 0x80000000) /* this is not error in general. */
panic("pmap_enter: pa");
+#endif
if (!(prot & VM_PROT_READ))
panic("pmap_enter: prot");
#endif
@@ -1847,7 +1857,7 @@
#endif
}
-vaddr_t
+paddr_t
pmap_phys_address(ppn)
int ppn;
{