Cleanup some and make these look more like hp300 versions.

This commit is contained in:
briggs 1995-06-21 03:14:06 +00:00
parent 23622438bf
commit 5dd8297b11
2 changed files with 94 additions and 63 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: pmap.h,v 1.9 1995/04/10 12:42:07 mycroft Exp $ */
/* $NetBSD: pmap.h,v 1.10 1995/06/21 03:14:06 briggs Exp $ */
/*
* Copyright (c) 1987 Carnegie-Mellon University
@ -77,17 +77,26 @@
#ifndef _PMAP_MACHINE_
#define _PMAP_MACHINE_
#define MAC_PAGE_SIZE NBPG
#include <machine/pte.h>
#if defined(M68040)
#define MAC_SEG_SIZE (mmutype == MMU_68040 ? 0x40000 : NBSEG)
#else
#define MAC_SEG_SIZE NBSEG
#endif
#define mac68k_trunc_seg(x) (((unsigned)(x)) & ~(MAC_SEG_SIZE-1))
#define mac68k_round_seg(x) mac68k_trunc_seg((unsigned)(x)+MAC_SEG_SIZE-1)
/*
* Pmap stuff
*/
struct pmap {
struct pte *pm_ptab; /* KVA of page table */
struct ste *pm_stab; /* KVA of segment table */
struct ste *pm_rtab; /* KVA of 68040 root table */
pt_entry_t *pm_ptab; /* KVA of page table */
st_entry_t *pm_stab; /* KVA of segment table */
int pm_stchanged; /* ST changed */
int pm_stfree; /* 040: free lev2 blocks */
st_entry_t *pm_stpa; /* 040: ST phys addr */
short pm_sref; /* segment table ref count */
short pm_count; /* pmap reference count */
simple_lock_data_t pm_lock; /* lock on pmap */
@ -97,14 +106,28 @@ struct pmap {
typedef struct pmap *pmap_t;
/*
* On the 040, we keep track of which level 2 blocks are already in use
* with the pm_stfree mask. Bits are arranged from LSB (block 0) to MSB
* (block 31). For convenience, the level 1 table is considered to be
* block 0.
*
* MAX[KU]L2SIZE control how many pages of level 2 descriptors are allowed
* for the kernel and users. 8 implies only the initial "segment table"
* page is used. WARNING: don't change MAXUL2SIZE unless you can allocate
* physically contiguous pages for the ST in pmap.c!
*/
#define MAXKL2SIZE 32
#define MAXUL2SIZE 8
#define l2tobm(n) (1 << (n))
#define bmtol2(n) (ffs(n) - 1)
/*
* Macros for speed
*/
#define PMAP_ACTIVATE(pmapp, pcbp, iscurproc) \
if ((pmapp) != NULL && (pmapp)->pm_stchanged) { \
(pcbp)->pcb_ustp = \
mac68k_btop(pmap_extract(pmap_kernel(), (vm_offset_t) \
(cpu040 ? (pmapp)->pm_rtab : (pmapp)->pm_stab))); \
if ((pmapp)->pm_stchanged) { \
(pcbp)->pcb_ustp = mac68k_btop((vm_offset_t)(pmapp)->pm_stpa); \
if (iscurproc) \
loadustp((pcbp)->pcb_ustp); \
(pmapp)->pm_stchanged = FALSE; \
@ -119,7 +142,7 @@ typedef struct pv_entry {
struct pv_entry *pv_next; /* next pv_entry */
struct pmap *pv_pmap; /* pmap where mapping lies */
vm_offset_t pv_va; /* virtual address for mapping */
struct ste *pv_ptste; /* non-zero if VA maps a PT page */
st_entry_t *pv_ptste; /* non-zero if VA maps a PT page */
struct pmap *pv_ptpmap; /* if pv_ptste, pmap for PT page */
int pv_flags; /* flags */
} *pv_entry_t;
@ -127,22 +150,41 @@ typedef struct pv_entry {
#define PV_CI 0x01 /* all entries must be cache inhibited */
#define PV_PTPAGE 0x02 /* entry maps a page table page */
struct pv_page;
struct pv_page_info {
TAILQ_ENTRY(pv_page) pgi_list;
struct pv_entry *pgi_freelist;
int pgi_nfree;
};
/*
* This is basically:
* ((NBPG - sizeof(struct pv_page_info)) / sizeof(struct pv_entry))
*/
#define NPVPPG 170
struct pv_page {
struct pv_page_info pvp_pgi;
struct pv_entry pvp_pv[NPVPPG];
};
#ifdef _KERNEL
pv_entry_t pv_table; /* array of entries, one per page */
struct pmap kernel_pmap_store;
#ifdef MACHINE_NONCONTIG
#define pa_index(pa) pmap_page_index(pa)
#else
#define pa_index(pa) atop(pa - vm_first_phys)
#endif
#define pa_to_pvh(pa) (&pv_table[pa_index(pa)])
#define pmap_kernel() (&kernel_pmap_store)
#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count)
#define active_pmap(pm) \
((pm) == pmap_kernel() || (pm) == curproc->p_vmspace->vm_map.pmap)
extern struct pte *Sysmap;
extern struct pv_entry *pv_table; /* array of entries, one per page */
#define pmap_page_index(pa) pmap_page_index(pa)
#define pa_to_pvh(pa) (&pv_table[pmap_page_index(pa)])
#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count)
#define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count)
extern pt_entry_t *Sysmap;
extern char *vmmap; /* map for mem, dumps, etc. */
#endif /* _KERNEL */

View File

@ -1,4 +1,4 @@
/* $NetBSD: pte.h,v 1.7 1994/10/26 08:46:43 cgd Exp $ */
/* $NetBSD: pte.h,v 1.8 1995/06/21 03:14:11 briggs Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -83,29 +83,8 @@
* Mac hardware segment/page table entries
*/
struct ste {
unsigned int sg_pfnum:20; /* page table frame number */
unsigned int :8; /* reserved at 0 */
unsigned int :1; /* reserved at 1 */
unsigned int sg_prot:1; /* write protect bit */
unsigned int sg_v:2; /* valid bits */
};
struct pte {
unsigned int pg_pfnum:20; /* page frame number or 0 */
unsigned int :3;
unsigned int pg_w:1; /* is wired */
unsigned int :1; /* reserved at zero */
unsigned int pg_ci:1; /* cache inhibit bit */
unsigned int pg_cm1:1; /* cache mode, lsb (68040) */
unsigned int pg_m:1; /* hardware modified (dirty) bit */
unsigned int pg_u:1; /* hardware used (reference) bit */
unsigned int pg_prot:1; /* write protect bit */
unsigned int pg_v:2; /* valid bit */
};
typedef struct ste st_entry_t; /* segment table entry */
typedef struct pte pt_entry_t; /* Mach page table entry */
typedef int st_entry_t; /* segment table entry */
typedef int pt_entry_t; /* Mach page table entry */
#define PT_ENTRY_NULL ((pt_entry_t *) 0)
#define ST_ENTRY_NULL ((st_entry_t *) 0)
@ -115,18 +94,26 @@ typedef struct pte pt_entry_t; /* Mach page table entry */
#define SG_PROT 0x00000004 /* access protection mask */
#define SG_RO 0x00000004
#define SG_RW 0x00000000
#define SG_U 0x00000008 /* modified bit (68040) */
#define SG_FRAME 0xfffff000
#define SG_IMASK1 0xfe000000
#define SG_IMASK2 0x01fc0000
#define SG_040IMASK 0xfffc0000
#define SG_040PMASK 0x0003f000
#define SG_ISHIFT1 25
#define SG_040ISHIFT 18
#define SG_IMASK 0xffc00000
#define SG_PMASK 0x003ff000
#define SG_ISHIFT 22
#define SG_PMASK 0x003ff000
#define SG_PSHIFT 12
/* 68040 additions */
#define SG4_MASK1 0xfe000000
#define SG4_SHIFT1 25
#define SG4_MASK2 0x01fc0000
#define SG4_SHIFT2 18
#define SG4_MASK3 0x0003f000
#define SG4_SHIFT3 12
#define SG4_ADDR1 0xfffffe00
#define SG4_ADDR2 0xffffff00
#define SG4_LEV1SIZE 128
#define SG4_LEV2SIZE 128
#define SG4_LEV3SIZE 64
#define PG_V 0x00000001
#define PG_NV 0x00000000
#define PG_PROT 0x00000004
@ -135,20 +122,24 @@ typedef struct pte pt_entry_t; /* Mach page table entry */
#define PG_W 0x00000100
#define PG_RO 0x00000004
#define PG_RW 0x00000000
#define PG_CI 0x00000040
#define PG_CCB 0x00000020
#define PG_CIN 0x00000060
#define PG_FRAME 0xfffff000
#define PG_CI 0x00000040
#define PG_SHIFT 12
#define PG_PFNUM(x) (((x) & PG_FRAME) >> PG_SHIFT)
#define MAC_040RTSIZE 512 /* root (level 1) table size */
#define MAC_040STSIZE 512 /* segment (level 2) table size */
#define MAC_040PTSIZE 256 /* page (level 3) table size */
#define MAC_STSIZE MAC_PAGE_SIZE /* segment table size */
#define MAC_MAX_PTSIZE MAC_SEG_SIZE /* max size of UPT */
/* 68040 additions */
#define PG_CMASK 0x00000060 /* cache mode mask */
#define PG_CWT 0x00000000 /* writethrough caching */
#define PG_CCB 0x00000020 /* copyback caching */
#define PG_CIS 0x00000040 /* cache inhibited serialized */
#define PG_CIN 0x00000060 /* cache inhibited nonserialized */
#define PG_SO 0x00000080 /* supervisor only */
#define MAC_STSIZE (MAXUL2SIZE*SG4_LEV2SIZE*sizeof(st_entry_t))
/* user process segment table size */
#define MAC_MAX_PTSIZE 0x400000 /* max size of UPT */
#define MAC_MAX_KPTSIZE 0x100000 /* max memory to allocate to KPT */
#define MAC_PTBASE 0x60100000 /* UPT map base address */
#define MAC_PTBASE 0x10000000 /* UPT map base address */
#define MAC_PTMAXSIZE 0x70000000 /* UPT map maximum size */
/*
@ -156,8 +147,6 @@ typedef struct pte pt_entry_t; /* Mach page table entry */
*/
#define kvtopte(va) \
(&Sysmap[((unsigned)(va) - VM_MIN_KERNEL_ADDRESS) >> PGSHIFT])
#define kvtoste(va) \
(&Sysseg[((unsigned)(va) - VM_MIN_KERNEL_ADDRESS) >> SEGSHIFT])
#define ptetokv(pt) \
((((pt_entry_t *)(pt) - Sysmap) << PGSHIFT) + VM_MIN_KERNEL_ADDRESS)
#define kvtophys(va) \