Skip to content

Commit

Permalink
Use appropriate macro during pmap initialization:
Browse files Browse the repository at this point in the history
- use SYSMAP_VA, SEGSHIFT for Sysmap address and table entries
- use TIA_SIZE, TIB_SIZE for sizes of table entries

Now page size dependent numbers are almost replaced with proper macro.

Tested on atari, hp300, and news68k.
  • Loading branch information
tsutsui committed Dec 11, 2009
1 parent 35b591f commit 789c747
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 110 deletions.
16 changes: 10 additions & 6 deletions sys/arch/amiga/amiga/amiga_init.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: amiga_init.c,v 1.116 2009/12/06 06:41:28 tsutsui Exp $ */
/* $NetBSD: amiga_init.c,v 1.117 2009/12/11 22:23:08 tsutsui Exp $ */

/*
* Copyright (c) 1994 Michael L. Hitch
Expand Down Expand Up @@ -36,7 +36,7 @@
#include "opt_devreload.h"

#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: amiga_init.c,v 1.116 2009/12/06 06:41:28 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: amiga_init.c,v 1.117 2009/12/11 22:23:08 tsutsui Exp $");

#include <sys/param.h>
#include <sys/systm.h>
Expand Down Expand Up @@ -402,7 +402,7 @@ start_c(id, fphystart, fphysize, cphysize, esym_addr, flags, inh_sync,
/*
* Sysmap is now placed at the end of Supervisor virtual address space.
*/
RELOC(Sysmap, u_int *) = (u_int *)-(NPTEPG * PAGE_SIZE);
RELOC(Sysmap, u_int *) = (u_int *)SYSMAP_VA;

/*
* initialize segment table and page table map
Expand Down Expand Up @@ -488,7 +488,7 @@ start_c(id, fphystart, fphysize, cphysize, esym_addr, flags, inh_sync,
while (pg < epg)
*pg++ = SG_NV;
pg = (pt_entry_t *)Sysptmap_pa;
pg = &pg[256 - 1]; /* XXX */
pg = &pg[SYSMAP_VA >> SEGSHIFT];
*pg = Sysptmap_pa | PG_RW | PG_CI | PG_V;
} else
#endif /* M68040 */
Expand All @@ -511,12 +511,16 @@ start_c(id, fphystart, fphysize, cphysize, esym_addr, flags, inh_sync,
/*
* invalidate the remainder of each table
*/
/* XXX PAGE_SIZE dependent constant: 256 or 1024 */
epg = (pt_entry_t *)(Sysptmap_pa + (256 - 1) * sizeof(st_entry_t));
epg = (pt_entry_t *)Sysptmap_pa;
epg = &epg[TIA_SIZE];
while (pg < epg) {
*sg++ = SG_NV;
*pg++ = PG_NV;
}
sg = (st_entry_t *)RELOC(Sysseg_pa, u_int);
sg = &sg[SYSMAP_VA >> SEGSHIFT];
pg = (pt_entry_t *)Sysptmap_pa;
pg = &pg[SYSMAP_VA >> SEGSHIFT];
*sg = Sysptmap_pa | SG_RW | SG_V;
*pg = Sysptmap_pa | PG_RW | PG_CI | PG_V;
/* XXX zero out rest of page? */
Expand Down
18 changes: 9 additions & 9 deletions sys/arch/atari/atari/atari_init.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: atari_init.c,v 1.91 2009/12/06 06:41:29 tsutsui Exp $ */
/* $NetBSD: atari_init.c,v 1.92 2009/12/11 22:23:08 tsutsui Exp $ */

/*
* Copyright (c) 1995 Leo Weppelman
Expand Down Expand Up @@ -33,7 +33,7 @@
*/

#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: atari_init.c,v 1.91 2009/12/06 06:41:29 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: atari_init.c,v 1.92 2009/12/11 22:23:08 tsutsui Exp $");

#include "opt_ddb.h"
#include "opt_mbtype.h"
Expand Down Expand Up @@ -336,7 +336,7 @@ start_c(int id, u_int ttphystart, u_int ttphysize, u_int stphysize,
/*
* Sysmap is now placed at the end of Supervisor virtual address space.
*/
Sysmap = (pt_entry_t *)-(NPTEPG * PAGE_SIZE);
Sysmap = (pt_entry_t *)SYSMAP_VA;

/*
* Initialize segment tables
Expand Down Expand Up @@ -942,21 +942,21 @@ mmu030_setup(paddr_t sysseg_pa, u_int kstsize, paddr_t ptpa, psize_t ptsize,
* Invalidate the remainder of the tables.
*/
esg = (st_entry_t *)sysseg_pa;
esg = &esg[256]; /* XXX should be TIA_SIZE */
esg = &esg[TIA_SIZE];
while (sg < esg)
*sg++ = SG_NV;
epg = (pt_entry_t *)sysptmap_pa;
epg = &epg[NPTEPG]; /* XXX should be TIB_SIZE */
epg = &epg[TIB_SIZE];
while (pg < epg)
*pg++ = PG_NV;

/*
* Initialize the PTE for the last one to point Sysptmap.
*/
sg = (st_entry_t *)sysseg_pa;
sg = &sg[256 - 1]; /* XXX should be TIA_SIZE */
sg = &sg[SYSMAP_VA >> SEGSHIFT];
pg = (pt_entry_t *)sysptmap_pa;
pg = &pg[256 - 1]; /* XXX should be TIA_SIZE */
pg = &pg[SYSMAP_VA >> SEGSHIFT];
*sg = RELOC_PA(kbase, sysptmap_pa) | SG_RW | SG_V;
*pg = RELOC_PA(kbase, sysptmap_pa) | PG_RW | PG_CI | PG_V;
}
Expand Down Expand Up @@ -1054,15 +1054,15 @@ mmu040_setup(paddr_t sysseg_pa, u_int kstsize, paddr_t ptpa, psize_t ptsize,
* Invalidate rest of Sysptmap page.
*/
epg = (pt_entry_t *)sysptmap_pa;
epg = &epg[NPTEPG]; /* XXX: should be TIB_SIZE */
epg = &epg[TIB_SIZE];
while (pg < epg)
*pg++ = PG_NV;

/*
* Initialize the PTE for the last one to point Sysptmap.
*/
pg = (pt_entry_t *)sysptmap_pa;
pg = &pg[256 - 1]; /* XXX: should be TIA_SIZE */
pg = &pg[SYSMAP_VA >> SEGSHIFT];
*pg = RELOC_PA(kbase, sysptmap_pa) | PG_RW | PG_CI | PG_V;
}
#endif /* M68040 */
Expand Down
25 changes: 12 additions & 13 deletions sys/arch/cesfic/cesfic/pmap_bootstrap.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: pmap_bootstrap.c,v 1.25 2009/12/06 06:41:29 tsutsui Exp $ */
/* $NetBSD: pmap_bootstrap.c,v 1.26 2009/12/11 22:23:08 tsutsui Exp $ */

/*
* Copyright (c) 1991, 1993
Expand Down Expand Up @@ -36,7 +36,7 @@
*/

#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.25 2009/12/06 06:41:29 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.26 2009/12/11 22:23:08 tsutsui Exp $");

#include <sys/param.h>
#include <sys/systm.h>
Expand Down Expand Up @@ -260,7 +260,7 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
* Invalidate all remaining entries.
*/
epte = (pt_entry_t *)kptmpa;
epte = &epte[NPTEPG]; /* XXX: should be TIB_SIZE */
epte = &epte[TIB_SIZE];
while (pte < epte) {
*pte++ = PG_NV;
}
Expand All @@ -269,9 +269,9 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
* table page allocated earlier.
*/
pte = (pt_entry_t *)kptmpa;
pte = &pte[NPTEPG - 2]; /* XXX: should be TIA_SIZE */
pte = &pte[SYSMAP_VA >> SEGSHIFT];
*pte = kptmpa | PG_RW | PG_CI | PG_V;
pte++;
pte++; /* XXX should use [MAXADDR >> SEGSHIFT] */
*pte = lkptpa | PG_RW | PG_CI | PG_V;
} else {
/*
Expand All @@ -293,25 +293,25 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
* Invalidate all remaining entries in both.
*/
este = (st_entry_t *)kstpa;
este = &epte[NPTEPG]; /* XXX: should be TIA_SIZE */
este = &epte[TIA_SIZE];
while (ste < este)
*ste++ = SG_NV;
epte = (pt_entry_t *)kptmpa;
epte = &epte[NPTEPG]; /* XXX: should be TIB_SIZE */
epte = &epte[TIB_SIZE];
while (pte < epte)
*pte++ = PG_NV;
/*
* Initialize the last to point to kptmpa and the page
* table page allocated earlier.
*/
ste = (st_entry_t *)kstpa;
ste = &ste[NPTEPG - 2]; /* XXX: should be TIA_SIZE */
ste = &ste[SYSMAP_VA >> SEGSHIFT];
pte = (pt_entry_t *)kptmpa;
pte = &pte[NPTEPG - 2]; /* XXX: should be TIA_SIZE */
pte = &pte[SYSMAP_VA >> SEGSHIFT];
*ste = kptmpa | SG_RW | SG_V;
*pte = kptmpa | PG_RW | PG_CI | PG_V;
ste++;
pte++;
ste++; /* XXX should use [MAXADDR >> SEGSHIFT] */
pte++; /* XXX should use [MAXADDR >> SEGSHIFT] */
*ste = lkptpa | SG_RW | SG_V;
*pte = lkptpa | PG_RW | PG_CI | PG_V;
}
Expand Down Expand Up @@ -387,8 +387,7 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
* Sysmap: kernel page table (as mapped through Sysptmap)
* Allocated at the end of KVA space.
*/
RELOC(Sysmap, pt_entry_t *) =
(pt_entry_t *)m68k_ptob((NPTEPG - 2) * NPTEPG);
RELOC(Sysmap, pt_entry_t *) = (pt_entry_t *)SYSMAP_VA;

/*
* Remember the u-area address so it can be loaded in the lwp0
Expand Down
28 changes: 15 additions & 13 deletions sys/arch/hp300/hp300/pmap_bootstrap.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: pmap_bootstrap.c,v 1.45 2009/12/06 06:41:30 tsutsui Exp $ */
/* $NetBSD: pmap_bootstrap.c,v 1.46 2009/12/11 22:23:08 tsutsui Exp $ */

/*
* Copyright (c) 1991, 1993
Expand Down Expand Up @@ -36,7 +36,7 @@
*/

#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.45 2009/12/06 06:41:30 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.46 2009/12/11 22:23:08 tsutsui Exp $");

#include <sys/param.h>

Expand Down Expand Up @@ -265,7 +265,7 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
* Invalidate all remaining entries.
*/
epte = (pt_entry_t *)kptmpa;
epte = &epte[NPTEPG]; /* XXX: should be TIB_SIZE */
epte = &epte[TIB_SIZE];
while (pte < epte) {
*pte++ = PG_NV;
}
Expand All @@ -274,9 +274,10 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
* table page allocated earlier.
*/
pte = (pt_entry_t *)kptmpa;
pte = &pte[NPTEPG - 2]; /* XXX: should be TIA_SIZE */
pte = &pte[SYSMAP_VA >> SEGSHIFT];
*pte = kptmpa | PG_RW | PG_CI | PG_V;
pte++;
pte = (pt_entry_t *)kptmpa;
pte = &pte[MAXADDR >> SEGSHIFT];
*pte = lkptpa | PG_RW | PG_CI | PG_V;
} else {
/*
Expand All @@ -298,25 +299,27 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
* Invalidate all remaining entries in both.
*/
este = (st_entry_t *)kstpa;
este = &epte[NPTEPG]; /* XXX: should be TIA_SIZE */
este = &epte[TIA_SIZE];
while (ste < este)
*ste++ = SG_NV;
epte = (pt_entry_t *)kptmpa;
epte = &epte[NPTEPG]; /* XXX: should be TIB_SIZE */
epte = &epte[TIB_SIZE];
while (pte < epte)
*pte++ = PG_NV;
/*
* Initialize the last ones to point to kptmpa and the page
* table page allocated earlier.
*/
ste = (st_entry_t *)kstpa;
ste = &ste[NPTEPG - 2]; /* XXX: should be TIA_SIZE */
ste = &ste[SYSMAP_VA >> SEGSHIFT];
pte = (pt_entry_t *)kptmpa;
pte = &pte[NPTEPG - 2]; /* XXX: should be TIA_SIZE */
pte = &pte[SYSMAP_VA >> SEGSHIFT];
*ste = kptmpa | SG_RW | SG_V;
*pte = kptmpa | PG_RW | PG_CI | PG_V;
ste++;
pte++;
ste = (st_entry_t *)kstpa;
ste = &ste[MAXADDR >> SEGSHIFT];
pte = (pt_entry_t *)kptmpa;
pte = &pte[MAXADDR >> SEGSHIFT];
*ste = lkptpa | SG_RW | SG_V;
*pte = lkptpa | PG_RW | PG_CI | PG_V;
}
Expand Down Expand Up @@ -417,8 +420,7 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
* Sysmap: kernel page table (as mapped through Sysptmap)
* Allocated at the end of KVA space.
*/
RELOC(Sysmap, pt_entry_t *) =
(pt_entry_t *)m68k_ptob((NPTEPG - 2) * NPTEPG);
RELOC(Sysmap, pt_entry_t *) = (pt_entry_t *)SYSMAP_VA;
/*
* CLKbase, MMUbase: important registers in internal IO space
* accessed from assembly language.
Expand Down
25 changes: 11 additions & 14 deletions sys/arch/luna68k/luna68k/pmap_bootstrap.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: pmap_bootstrap.c,v 1.26 2009/12/11 20:00:49 tsutsui Exp $ */
/* $NetBSD: pmap_bootstrap.c,v 1.27 2009/12/11 22:23:09 tsutsui Exp $ */

/*
* Copyright (c) 1991, 1993
Expand Down Expand Up @@ -36,7 +36,7 @@
*/

#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.26 2009/12/11 20:00:49 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.27 2009/12/11 22:23:09 tsutsui Exp $");

#include <sys/param.h>

Expand Down Expand Up @@ -242,7 +242,7 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
* Invalidate all remaining entries.
*/
epte = (pt_entry_t *)kptmpa;
epte = &epte[NPTEPG];
epte = &epte[TIB_SIZE];
while (pte < epte) {
*pte++ = PG_NV;
}
Expand All @@ -251,9 +251,8 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
* to point to Sysptmap.
*/
pte = (pt_entry_t *)kptmpa;
/* XXX should be (TIA_SIZE * PAGE_SIZE) */
pte[SYSMAP_VA / (NPTEPG * PAGE_SIZE)] =
kptmpa | PG_RW | PG_CI | PG_V;
pte = &pte[SYSMAP_VA >> SEGSHIFT];
*pte = kptmpa | PG_RW | PG_CI | PG_V;
} else
#endif
{
Expand All @@ -276,25 +275,23 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
* Invalidate all remaining entries in both.
*/
este = (st_entry_t *)kstpa;
este = &este[NPTEPG]; /* XXX: should be TIA_SIZE */
este = &este[TIA_SIZE];
while (ste < este)
*ste++ = SG_NV;
epte = (pt_entry_t *)kptmpa;
epte = &epte[NPTEPG]; /* XXX: should be TIB_SIZE */
epte = &epte[TIB_SIZE];
while (pte < epte)
*pte++ = PG_NV;
/*
* Initialize the one corresponding to SYSMAP_VA
* to point to Sysptmap.
*/
ste = (st_entry_t *)kstpa;
ste = &ste[SYSMAP_VA >> SEGSHIFT];
*ste = kptmpa | SG_RW | SG_V;
pte = (pt_entry_t *)kptmpa;
/* XXX should be (TIA_SIZE * PAGE_SIZE) */
ste[SYSMAP_VA / (NPTEPG * PAGE_SIZE)] =
kptmpa | SG_RW | SG_V;
/* XXX should be (TIA_SIZE * PAGE_SIZE) */
pte[SYSMAP_VA / (NPTEPG * PAGE_SIZE)] =
kptmpa | PG_RW | PG_CI | PG_V;
pte = &pte[SYSMAP_VA >> SEGSHIFT];
*pte = kptmpa | PG_RW | PG_CI | PG_V;
}

/*
Expand Down

0 comments on commit 789c747

Please sign in to comment.