Pull up following revision(s) (requested by tsutsui in ticket #1590):

sys/arch/next68k/include/vmparam.h: revision 1.29
	sys/arch/next68k/next68k/machdep.c: revision 1.118
	sys/arch/next68k/include/param.h: revision 1.13
	sys/arch/next68k/next68k/pmap_bootstrap.c: revision 1.45
	sys/arch/next68k/next68k/locore.s: revision 1.70
	sys/arch/next68k/next68k/locore.s: revision 1.71

Use explicit CPU strings and remove hp300 derived stuff.

Remove #ifdef'ed out hp300 specific stuff.

Remove leftover "last kernel PT page" settings derived from hp300.

Whilehere, also remove VM definitions for obsolete COMPAT_HPUX stuff.

All hp300 machines has RAMs at a region from the highest address
i.e. 0xFFFFFFFF to smaller address (as HP claims "it's the MSB first"),
so kernels have to prepare PA==KVA mappings as the "last PT page" to
guarantee the running kernel works both before and after the MMU is
turned on.  For such a special mapping, we have to set up necessary
segment table and page table during early startup, in pmap_bootstrap()
invoked from locore.s.

On the other hand, NeXT machines have RAMs at a region from 0x40000000
to below (i.e. to larger address) so we still need a PA==KVA mapping.
However currently NetBSD/next68k just uses the transparent translation
registers to achieve the PA==KVA mapping, so unlike hp300 we don't have
to prepare special segment table and page table for it.

Note many other m68k ports (like luna68k, news68k, x68k etc.) have
RAMs at a region from 0x00000000 so usually we can assume PA==KVA
and don't have to bother to prepare such speicial mappings.

No user visible changes (except now freed wasted pages for the tables).

Tested on my NeXTstation slab.
This commit is contained in:
martin 2023-02-12 11:47:10 +00:00
parent 6a8fda3af3
commit 6676131d63
5 changed files with 40 additions and 206 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: param.h,v 1.12 2012/02/10 17:35:48 para Exp $ */
/* $NetBSD: param.h,v 1.12.52.1 2023/02/12 11:47:10 martin Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -50,7 +50,7 @@
#define PGSHIFT 12 /* LOG2(NBPG) */
#define KERNBASE 0x00000000 /* start of kernel virtual */
#define UPAGES 3 /* pages of u-area */
#define UPAGES 2 /* pages of u-area */
#include <m68k/param.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: vmparam.h,v 1.26.2.1 2020/02/10 18:46:39 martin Exp $ */
/* $NetBSD: vmparam.h,v 1.26.2.2 2023/02/12 11:47:10 martin Exp $ */
/*
* This file was taken from from mvme68k/include/vmparam.h and
@ -59,16 +59,8 @@
/*
* USRSTACK is the top (end) of the user stack.
*
* NOTE: the ONLY reason that HIGHPAGES is 0x100 instead of UPAGES (3)
* is for HPUX compatibility. Why?? Because HPUX's debuggers
* have the user's stack hard-wired at FFF00000 for post-mortems,
* and we must be compatible...
*/
#define USRSTACK (-HIGHPAGES*PAGE_SIZE) /* Start of user stack */
#define BTOPUSRSTACK (0x100000-HIGHPAGES) /* btop(USRSTACK) */
#define P1PAGES 0x100000
#define HIGHPAGES (0x100000/PAGE_SIZE)
#define USRSTACK VM_MAXUSER_ADDRESS /* Start of user stack */
/*
* Virtual memory related constants, all in bytes
@ -106,7 +98,7 @@
#define VM_MAXUSER_ADDRESS ((vaddr_t)0xFFF00000)
#define VM_MAX_ADDRESS ((vaddr_t)0xFFF00000)
#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)0)
#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)(0-PAGE_SIZE*NPTEPG*2))
#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)(0-PAGE_SIZE*NPTEPG))
/* virtual sizes (bytes) for various kernel submaps */
#define VM_PHYS_SIZE (USRIOSIZE*PAGE_SIZE)
@ -131,4 +123,4 @@ struct pmap_physseg {
struct pv_header *pvheader; /* pv table for this seg */
};
#endif /* _MVME68K_VMPARAM_H_ */
#endif /* _NEXT68K_VMPARAM_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore.s,v 1.66 2018/12/19 13:57:49 maxv Exp $ */
/* $NetBSD: locore.s,v 1.66.4.1 2023/02/12 11:47:10 martin Exp $ */
/*
* Copyright (c) 1998 Darrin B. Jewell
@ -229,10 +229,6 @@ Lnot68030:
movl #CPU_68040,%a0@ | and a 68040 CPU
RELOC(fputype, %a0)
movl #FPU_68040,%a0@ | ...and FPU
#if defined(ENABLE_HP_CODE)
RELOC(ectype, %a0)
movl #EC_NONE,%a0@ | and no cache (for now XXX)
#endif
RELOC(machineid, %a0)
movl #40,%a0@ | @@@ useless
jra Lstart1
@ -324,20 +320,16 @@ Lstart3:
* Prepare to enable MMU.
* Since the kernel is not mapped logical == physical we must insure
* that when the MMU is turned on, all prefetched addresses (including
* the PC) are valid. In order guarantee that, we use the last physical
* page (which is conveniently mapped == VA) and load it up with enough
* code to defeat the prefetch, then we execute the jump back to here.
*
* Is this all really necessary, or am I paranoid??
* the PC) are valid. In order guarantee that, we use the transparent
* translation registers (which provide PA == VA mappings) and just
* turns on the MMU, then jump from the VA == PA address (at 0x40XXXXXX)
* to the actual kernel virtual address (at 0x00XXXXXX) code via a far
* jump instruction so that we can defeat the prefetch.
*/
RELOC(Sysseg_pa, %a0) | system segment table addr
movl %a0@,%d1 | read value (a PA)
RELOC(mmutype, %a0)
#if defined(ENABLE_HP_CODE)
tstl %a0@ | HP MMU?
jeq Lhpmmu2 | yes, skip
#endif
cmpl #MMU_68040,%a0@ | 68040?
jne Lmotommu1 | no, skip
.long 0x4e7b1807 | movc %d1,%srp
@ -349,31 +341,7 @@ Lmotommu1:
pmove %a0@,%srp | load the supervisor root pointer
movl #0x80000002,%a0@ | reinit upper half for CRP loads
#if defined(ENABLE_HP_CODE)
jra Lstploaddone | done
Lhpmmu2:
moveq #PGSHIFT,%d2
lsrl %d2,%d1 | convert to page frame
movl %d1,INTIOBASE+MMUBASE+MMUSSTP | load in sysseg table register
#endif
Lstploaddone:
#if defined(ENABLE_MAXADDR_TRAMPOLINE)
lea MAXADDR,%a2 | PA of last RAM page
ASRELOC(Lhighcode, %a1) | addr of high code
ASRELOC(Lehighcode, %a3) | end addr
Lcodecopy:
movw %a1@+,%a2@+ | copy a word
cmpl %a3,%a1 | done yet?
jcs Lcodecopy | no, keep going
jmp MAXADDR | go for it!
/*
* BEGIN MMU TRAMPOLINE. This section of code is not
* executed in-place. It's copied to the last page
* of RAM (mapped va == pa) and executed there.
*/
Lhighcode:
#endif /* ENABLE_MAXADDR_TRAMPOLINE */
/*
* Set up the vector table, and race to get the MMU
@ -387,21 +355,12 @@ Lhighcode:
movc %d0,%vbr
RELOC(mmutype, %a0)
#if defined(ENABLE_HP_CODE)
tstl %a0@ | HP MMU?
jeq Lhpmmu3 | yes, skip
#endif
cmpl #MMU_68040,%a0@ | 68040?
jne Lmotommu2 | no, skip
#if defined(ENABLE_HP_CODE)
movw #0,INTIOBASE+MMUBASE+MMUCMD+2
movw #MMU_IEN+MMU_CEN+MMU_FPE,INTIOBASE+MMUBASE+MMUCMD+2
| enable FPU and caches
#endif
| This is a hack to get PA=KVA when turning on MMU
| it will only work on 68040's. We should fix something
| to boot 68030's later.
| This is a hack to get PA=KVA when turning on MMU as mentioned above.
| Currintly this will only work on 68040's. We should also provide
| %tt0 and %tt1 settings to boot 68030's later.
movel #0x0200c040,%d0 | intio devices are at 0x02000000
.long 0x4e7b0004 | movc %d0,%itt0
.long 0x4e7b0006 | movc %d0,%dtt0
@ -425,28 +384,11 @@ Lturnoffttr:
.long 0x4e7b0007 | movc %d0,%dtt1
jmp Lenab1
Lmotommu2:
#if defined(ENABLE_HP_CODE)
movl #MMU_IEN+MMU_FPE,INTIOBASE+MMUBASE+MMUCMD
| enable 68881 and i-cache
#endif
pflusha
RELOC(prototc, %a2)
movl #0x82c0aa00,%a2@ | value to load TC with
pmove %a2@,%tc | load it
jmp Lenab1:l | force absolute (not pc-relative) jmp
#if defined(ENABLE_HP_CODE)
Lhpmmu3:
movl #0,INTIOBASE+MMUBASE+MMUCMD | clear external cache
movl #MMU_ENAB,INTIOBASE+MMUBASE+MMUCMD | turn on MMU
jmp Lenab1:l | jmp to mapped code
#endif
#if defined(ENABLE_MAXADDR_TRAMPOLINE)
Lehighcode:
/*
* END MMU TRAMPOLINE. Address register %a5 is now free.
*/
#endif
/*
* Should be running mapped from this point on
@ -478,7 +420,7 @@ Lenab2:
movc %d0,%cacr | clear cache(s)
jra Lenab3
Ltbia040:
.word 0xf518
.word 0xf518 | pflusha
Lenab3:
jbsr _C_LABEL(next68k_init)
@ -944,24 +886,6 @@ Lsldone:
rts
#endif
#if defined(ENABLE_HP_CODE)
ENTRY(ecacheon)
tstl _C_LABEL(ectype)
jeq Lnocache7
MMUADDR(%a0)
orl #MMU_CEN,%a0@(MMUCMD)
Lnocache7:
rts
ENTRY(ecacheoff)
tstl _C_LABEL(ectype)
jeq Lnocache8
MMUADDR(%a0)
andl #~MMU_CEN,%a0@(MMUCMD)
Lnocache8:
rts
#endif
/*
* Load a new user segment table pointer.
*/
@ -1140,11 +1064,6 @@ GLOBAL(mmutype)
GLOBAL(cputype)
.long 0xdeadbeef | default to 68020 CPU
#if defined(ENABLE_HP_CODE)
GLOBAL(ectype)
.long EC_NONE | external cache type, default to none
#endif
GLOBAL(fputype)
.long 0xdeadbeef | default to 68882 FPU
@ -1178,20 +1097,6 @@ ASLOCAL(save_vbr) | VBR from ROM
GLOBAL(monbootflag)
.long 0
#if defined(ENABLE_HP_CODE)
GLOBAL(extiobase)
.long 0 | KVA of base of external IO space
GLOBAL(CLKbase)
.long 0 | KVA of base of clock registers
GLOBAL(MMUbase)
.long 0 | KVA of base of HP MMU registers
GLOBAL(pagezero)
.long 0 | PA of first page of kernel text
#endif
#ifdef USELEDS
ASLOCAL(heartbeat)
.long 0 | clock ticks since last pulse of heartbeat

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.112.4.1 2023/02/01 18:56:44 martin Exp $ */
/* $NetBSD: machdep.c,v 1.112.4.2 2023/02/12 11:47:10 martin Exp $ */
/*
* Copyright (c) 1998 Darrin B. Jewell
@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.112.4.1 2023/02/01 18:56:44 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.112.4.2 2023/02/12 11:47:10 martin Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -321,7 +321,7 @@ cpu_startup(void)
void
identifycpu(void)
{
const char *mc, *mmu_str, *fpu_str, *cache_str;
const char *cpu_str, *mmu_str, *fpu_str, *cache_str;
extern int turbo;
/*
@ -329,21 +329,23 @@ identifycpu(void)
*/
switch (cputype) {
case CPU_68040:
mc = "40";
cpu_str = "MC68040";
cpuspeed = turbo ? 33 : 25;
delay_divisor = 759 / cpuspeed;
break;
case CPU_68030:
mc = "30";
cpu_str = "MC68030";
cpuspeed = 25;
delay_divisor = 2048 / cpuspeed;
break;
#if 0
case CPU_68020:
mc = "20";
cpu_str = "MC68020";
break;
#endif
default:
printf("\nunknown cputype %d\n", cputype);
goto lose;
panic("startup");
}
/*
@ -354,14 +356,13 @@ identifycpu(void)
case MMU_68030:
mmu_str = "+MMU";
break;
#if 0
case MMU_68851:
mmu_str = ", MC68851 MMU";
break;
case MMU_HP:
mmu_str = ", HP MMU";
break;
#endif
default:
printf("MC680%s: unknown MMU type %d\n", mc, mmutype);
printf("%s: unknown MMU type %d\n", cpu_str, mmutype);
panic("startup");
}
@ -376,7 +377,7 @@ identifycpu(void)
fpu_str = ", MC68882 FPU";
break;
case FPU_68881:
fpu_str = ", MHz MC68881 FPU";
fpu_str = ", MC68881 FPU";
break;
default:
fpu_str = ", unknown FPU";
@ -387,30 +388,11 @@ identifycpu(void)
*/
if (cputype == CPU_68040)
cache_str = ", 4k on-chip physical I/D caches";
else {
#if defined(ENABLE_HP_CODE)
switch (ectype) {
case EC_VIRT:
cache_str = ", virtual-address cache";
break;
case EC_PHYS:
cache_str = ", physical-address cache";
break;
default:
cache_str = "";
break;
}
#else
else
cache_str = "";
#endif
}
cpu_setmodel("NeXT/MC680%s CPU%s%s%s", mc, mmu_str, fpu_str, cache_str);
cpu_setmodel("NeXT/%s CPU%s%s%s", cpu_str, mmu_str, fpu_str, cache_str);
printf("%s\n", cpu_getmodel());
return;
lose:
panic("startup");
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: pmap_bootstrap.c,v 1.44 2016/12/23 10:48:12 maya Exp $ */
/* $NetBSD: pmap_bootstrap.c,v 1.44.20.1 2023/02/12 11:47:10 martin Exp $ */
/*
* This file was taken from mvme68k/mvme68k/pmap_bootstrap.c
@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.44 2016/12/23 10:48:12 maya Exp $");
__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.44.20.1 2023/02/12 11:47:10 martin Exp $");
#include "opt_m68k_arch.h"
@ -100,7 +100,6 @@ void
pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
{
paddr_t lwp0upa, kstpa, kptmpa, kptpa;
paddr_t lkptpa;
u_int nptpages, kstsize;
st_entry_t protoste, *ste, *este;
pt_entry_t protopte, *pte, *epte;
@ -156,8 +155,6 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
*
* kptmpa kernel PT map 1 page
*
* lkptpa last kernel PT page 1 page
*
* kptpa statically allocated
* kernel PT pages Sysptsize+ pages
*
@ -180,8 +177,6 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
nextpa += kstsize * PAGE_SIZE;
kptmpa = nextpa;
nextpa += PAGE_SIZE;
lkptpa = nextpa;
nextpa += PAGE_SIZE;
kptpa = nextpa;
nptpages = RELOC(Sysptsize, int) + howmany(RELOC(physmem, int), NPTEPG) +
(IIOMAPSIZE + MONOMAPSIZE + COLORMAPSIZE + NPTEPG - 1) / NPTEPG;
@ -207,18 +202,8 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
* each mapping 256kb. Note that there may be additional "segment
* table" pages depending on how large MAXKL2SIZE is.
*
* Portions of the last two segment of KVA space (0xFF800000 -
* 0xFFFFFFFF) are mapped for a couple of purposes.
* The first segment (0xFF800000 - 0xFFBFFFFF) is mapped
* for the kernel page tables.
*
* XXX: It looks this was copied from hp300 and not sure if
* XXX: last physical page mapping is really needed on this port.
* The very last page (0xFFFFF000) in the second segment is mapped
* to the last physical page of RAM to give us a region in which
* PA == VA. We use the first part of this page for enabling
* and disabling mapping. The last part of this page also contains
* info left by the boot ROM.
* Portions of the last segment of KVA space (0xFFC00000 -
* 0xFFFFFFFF) are mapped for the kernel page tables.
*
* XXX cramming two levels of mapping into the single "segment"
* table on the 68040 is intended as a temporary hack to get things
@ -276,23 +261,17 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
*ste = protoste;
/*
* Now initialize the final portion of that block of
* descriptors to map Sysmap and the "last PT page".
* descriptors to map Sysmap.
*/
i = SG4_LEV1SIZE + (nl1desc * SG4_LEV2SIZE);
ste = (st_entry_t *)kstpa;
ste = &ste[i + SG4_LEV2SIZE - (NPTEPG / SG4_LEV3SIZE) * 2];
ste = &ste[i + SG4_LEV2SIZE - (NPTEPG / SG4_LEV3SIZE)];
este = &ste[NPTEPG / SG4_LEV3SIZE];
protoste = kptmpa | SG_U | SG_RW | SG_V;
while (ste < este) {
*ste++ = protoste;
protoste += (SG4_LEV3SIZE * sizeof(st_entry_t));
}
este = &ste[NPTEPG / SG4_LEV3SIZE];
protoste = lkptpa | SG_U | SG_RW | SG_V;
while (ste < este) {
*ste++ = protoste;
protoste += (SG4_LEV3SIZE * sizeof(st_entry_t));
}
/*
* Calculate the free level 2 descriptor mask
* noting that we have used:
@ -305,7 +284,7 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
/* mark entries for map page tables */
for (i = 1; i <= nl1desc; i++)
stfree &= ~l2tobm(i);
/* mark an entry for kptmpa and lkptpa */
/* mark an entry for kptmpa */
stfree &= ~l2tobm(i);
/* mark entries not available */
for (i = MAXKL2SIZE; i < sizeof(stfree) * NBBY; i++)
@ -330,14 +309,11 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
*pte++ = PG_NV;
}
/*
* Initialize the last ones to point to Sysptmap and the page
* table page allocated earlier.
* Initialize the last one to point to Sysptmap.
*/
pte = (pt_entry_t *)kptmpa;
pte = &pte[SYSMAP_VA >> SEGSHIFT];
*pte = kptmpa | PG_RW | PG_CI | PG_V;
pte++; /* XXX should use [MAXADDR >> SEGSHIFT] */
*pte = lkptpa | PG_RW | PG_CI | PG_U | PG_V;
} else
#endif /* M68040 || M68060 */
{
@ -368,8 +344,7 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
while (pte < epte)
*pte++ = PG_NV;
/*
* Initialize the last ones to point to Sysptmap and the page
* table page allocated earlier.
* Initialize the last one to point to Sysptmap.
*/
ste = (st_entry_t *)kstpa;
ste = &ste[SYSMAP_VA >> SEGSHIFT];
@ -377,28 +352,8 @@ pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
pte = &pte[SYSMAP_VA >> SEGSHIFT];
*ste = kptmpa | SG_RW | SG_V;
*pte = kptmpa | PG_RW | PG_CI | PG_V;
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;
}
/*
* Invalidate all but the final entry in the last kernel PT page.
* The final entry maps the last page of physical memory to
* prepare a page that is PA == VA to turn on the MMU.
*
* XXX: This looks copied from hp300 where PA != VA, but
* XXX: it's suspicious if this is also required on this port.
*/
pte = (pt_entry_t *)lkptpa;
epte = &pte[NPTEPG - 1];
while (pte < epte)
*pte++ = PG_NV;
#ifdef MAXADDR
/* tmp double-map for CPUs with physmem at the end of memory */
*pte = MAXADDR | PG_RW | PG_CI | PG_U | PG_V;
#endif
/*
* Initialize kernel page table.
* Start by invalidating the `nptpages' that we have allocated.