Rewrite doboot() so that it turns off the MMU, rather than relying

on the ROM space being mapped where it would like to be.
This commit is contained in:
scottr 1998-05-24 06:15:50 +00:00
parent 71f42e433f
commit 9df06931ab
3 changed files with 81 additions and 45 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore.s,v 1.98 1998/05/23 20:51:11 is Exp $ */
/* $NetBSD: locore.s,v 1.99 1998/05/24 06:15:50 scottr Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -132,6 +132,18 @@ ASENTRY_NOPROFILE(start)
movc d0,sfc | as source
movc d0,dfc | and destination of transfers
/*
* Some parameters provided by MacOS
*
* LAK: This section is the new way to pass information from the booter
* to the kernel. At A1 there is an environment variable which has
* a bunch of stuff in ascii format, "VAR=value\0VAR=value\0\0".
*/
movl a1,sp@- | Address of buffer
movl d4,sp@- | Some flags... (mostly not used)
jbsr _C_LABEL(getenvvars) | Parse the environment buffer
addql #8,sp
/* Determine MMU/MPU from what we can test empirically */
movl #0x200,d0 | data freeze bit
movc d0,cacr | only exists on 68030
@ -201,17 +213,6 @@ Lstart1:
jra Ldoboot1
Lstart2:
/*
* Some parameters provided by MacOS
*
* LAK: This section is the new way to pass information from the booter
* to the kernel. At A1 there is an environment variable which has
* a bunch of stuff in ascii format, "VAR=value\0VAR=value\0\0".
*/
movl a1,sp@- | Address of buffer
movl d4,sp@- | Some flags... (mostly not used)
jbsr _C_LABEL(getenvvars) | Parse the environment buffer
addql #8,sp
jbsr _C_LABEL(setmachdep) | Set some machine-dep stuff
jbsr _C_LABEL(consinit) | XXX Should only be if graybar on
@ -1588,33 +1589,55 @@ Lm68881rdone:
/*
* Handle the nitty-gritty of rebooting the machine.
* Basically we just jump to the appropriate ROM routine after mapping
* the ROM into its proper home (back in machdep).
* Basically we just turn off the MMU and jump to the appropriate ROM routine.
* Note that we must be running in an address range that is mapped one-to-one
* logical to physical so that the PC is still valid immediately after the MMU
* is turned off. We have conveniently mapped the last page of physical
* memory this way.
*/
ENTRY_NOPROFILE(doboot)
movw #PSL_HIGHIPL,sr | no interrupts
#if defined(M68040)
cmpl #MMU_68040,_C_LABEL(mmutype) | 68040?
jne Ldobootnot040 | yes, skip
movl #CACHE40_OFF,d0 | 68040 cache disable
movc d0, cacr
.word 0xf4f8 | cpusha bc - push and invalidate caches
jra Ldoboot1
Ldobootnot040:
jeq Lnocache5 | yes, skip
#endif
movl #CACHE_OFF,d0
movc d0,cacr | disable on-chip cache(s)
#ifdef __notyet__
tstl _C_LABEL(ectype) | external cache?
jeq Ldoboot1 | no, skip
| Disable external cache here.
Lnocache5:
movl _C_LABEL(maxaddr),a0 | last page of physical memory
lea Lbootcode,a1 | start of boot code
lea Lebootcode,a3 | end of boot code
Lbootcopy:
movw a1@+,a0@+ | copy a word
cmpl a3,a1 | done yet?
jcs Lbootcopy | no, keep going
#if defined(M68040)
cmpl #MMU_68040,_C_LABEL(mmutype) | 68040?
jne LmotommuE | no, skip
.word 0xf4f8 | cpusha bc
LmotommuE:
#endif
movl _C_LABEL(maxaddr),a0
jmp a0@ | jump to last page
Lbootcode:
lea a0@(0x800),sp | physical SP in case of NMI
#if defined(M68040)
cmpl #MMU_68040,_C_LABEL(mmutype) | 68040?
jne LmotommuF | no, skip
movl #0,d0
movc d0,cacr | caches off
.long 0x4e7b0003 | movc d0,tc (disable MMU)
jra Ldoboot1
LmotommuF:
#endif
movl #0,a3@ | value for pmove to TC (turn off MMU)
pmove a3@,tc | disable MMU
Ldoboot1:
movl _C_LABEL(MacOSROMBase),_C_LABEL(ROMBase) | Load MacOS ROMBase
movl #0x90,a1 | offset of ROM reset routine
addl _C_LABEL(ROMBase),a1 | add to ROM base
jra a1@ | and jump to ROM to reset machine
movl _C_LABEL(MacOSROMBase),a1 | Load MacOS ROMBase
lea a1@(0x90),a1 | offset of ROM reset routine
jmp a1@ | and jump to ROM to reset machine
Lebootcode:
/*
* u_long ptest040(caddr_t addr, u_int fc);

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.196 1998/05/23 20:51:11 is Exp $ */
/* $NetBSD: machdep.c,v 1.197 1998/05/24 06:15:50 scottr Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -707,7 +707,7 @@ cpu_reboot(howto, bootstr)
int howto;
char *bootstr;
{
extern u_long MacOSROMBase;
extern u_long maxaddr;
extern int cold;
#if __GNUC__ /* XXX work around lame compiler problem (gcc 2.7.2) */
@ -768,12 +768,9 @@ cpu_reboot(howto, bootstr)
(void)cngetc();
}
/*
* Map ROM where the MacOS likes it, so we can reboot,
* hopefully.
*/
pmap_map(MacOSROMBase, MacOSROMBase, MacOSROMBase + 4 * 1024 * 1024,
VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE);
/* Map the last physical page VA = PA for doboot() */
pmap_enter(pmap_kernel(), (vm_offset_t)maxaddr, (vm_offset_t)maxaddr,
VM_PROT_ALL, TRUE);
printf("rebooting...\n");
DELAY(1000000);
@ -1296,6 +1293,11 @@ getenvvars(flag, buf)
(flag & 0x40000)) && bootdev == 0)
bootdev = MAKEBOOTDEV(4, 0, 0, root_scsi_id, 0);
/*
* Booter 1.11.3 and later pass a BOOTHOWTO variable with the
* appropriate bits set.
*/
boothowto = getenv("BOOTHOWTO");
if (boothowto == 0)
boothowto = getenv("SINGLE_USER");

View File

@ -1,4 +1,4 @@
/* $NetBSD: pmap_bootstrap.c,v 1.42 1998/04/26 03:59:18 scottr Exp $ */
/* $NetBSD: pmap_bootstrap.c,v 1.43 1998/05/24 06:15:50 scottr Exp $ */
/*
* Copyright (c) 1991, 1993
@ -64,7 +64,7 @@ extern char *extiobase, *proc0paddr;
extern st_entry_t *Sysseg;
extern pt_entry_t *Sysptmap, *Sysmap;
extern int maxmem, physmem;
extern int physmem;
extern int avail_remaining, avail_range, avail_end;
extern vm_offset_t avail_start, avail_next;
extern vm_offset_t virtual_avail, virtual_end;
@ -76,9 +76,10 @@ extern int zsinited;
/*
* These are used to map the RAM:
*/
int numranges; /* = 0 == don't use the ranges */
int numranges; /* = 0 == don't use the ranges */
u_long low[8];
u_long high[8];
u_long maxaddr; /* PA of the last physical page */
int vidlen;
#define VIDMAPSIZE btoc(vidlen)
extern u_int32_t mac68k_vidlog;
@ -317,7 +318,7 @@ pmap_bootstrap(nextpa, firstpa)
*pte = lkptpa | PG_RW | PG_CI | PG_V;
}
/*
* Invalidate all but the final entry in the last kernel PT page
* Invalidate all entries in the last kernel PT page
* (u-area PTEs will be validated later).
*/
pte = PA2VA(lkptpa, u_int *);
@ -445,6 +446,15 @@ pmap_bootstrap(nextpa, firstpa)
/*
* VM data structures are now initialized, set up data for
* the pmap module.
*
* Note about avail_end: msgbuf is initialized just after
* avail_end in machdep.c. Since the last page is used
* for rebooting the system (code is copied there and
* excution continues from copied code before the MMU
* is disabled), the msgbuf will get trounced between
* reboots if it's placed in the last physical page.
* To work around this, we move avail_end back one more
* page so the msgbuf can be preserved.
*/
avail_next = avail_start = m68k_round_page(nextpa);
avail_remaining = 0;
@ -459,8 +469,9 @@ pmap_bootstrap(nextpa, firstpa)
}
physmem = m68k_btop(avail_remaining + nextpa - firstpa);
avail_remaining -= m68k_round_page(MSGBUFSIZE);
high[numranges - 1] -= m68k_round_page(MSGBUFSIZE);
maxaddr = high[numranges - 1] - m68k_ptob(1);
high[numranges - 1] -= (m68k_round_page(MSGBUFSIZE) + m68k_ptob(1));
avail_remaining -= (m68k_round_page(MSGBUFSIZE) + m68k_ptob(1));
avail_end = high[numranges - 1];
avail_remaining = m68k_btop(m68k_trunc_page(avail_remaining));