Sync with hp300.

This commit is contained in:
scottr 1999-04-06 04:04:45 +00:00
parent 5010389530
commit dc9ec7ace3

View File

@ -1,4 +1,4 @@
/* $NetBSD: vm_machdep.c,v 1.35 1999/03/26 23:41:31 mycroft Exp $ */
/* $NetBSD: vm_machdep.c,v 1.36 1999/04/06 04:04:45 scottr Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -36,8 +36,7 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
*
* from: Utah $Hdr: vm_machdep.c 1.21 91/04/06$
*
* @(#)vm_machdep.c 8.6 (Berkeley) 1/12/94
@ -48,25 +47,20 @@
#include <sys/proc.h>
#include <sys/malloc.h>
#include <sys/buf.h>
#include <sys/user.h>
#include <sys/vnode.h>
#include <sys/user.h>
#include <sys/core.h>
#include <sys/exec.h>
#include <vm/vm.h>
#include <vm/vm_kern.h>
#if 0
#include <vm/vm_map.h>
#endif
#include <uvm/uvm_extern.h>
#include <machine/frame.h>
#include <machine/cpu.h>
#include <machine/pmap.h>
#include <machine/pte.h>
#include <machine/reg.h>
void savectx __P((struct pcb *));
#include <vm/vm.h>
#include <vm/vm_kern.h>
#include <uvm/uvm_extern.h>
/*
* Finish a fork operation, with process p2 nearly set up.
@ -88,7 +82,7 @@ cpu_fork(p1, p2)
p2->p_md.md_flags = p1->p_md.md_flags;
/* Copy pcb from p1 to p2. */
/* Copy pcb from proc p1 to p2. */
if (p1 == curproc) {
/* Sync the PCB before we copy it. */
savectx(curpcb);
@ -100,29 +94,26 @@ cpu_fork(p1, p2)
*pcb = p1->p_addr->u_pcb;
/*
* Copy the trap frame and arrange for the child to return directly
* Copy the trap frame, and arrange for the child to return directly
* through child_return(). Note the in-line cpu_set_kpc().
*/
tf = (struct trapframe *)((u_int)p2->p_addr + USPACE) -1;
tf = (struct trapframe *)((u_int)p2->p_addr + USPACE) - 1;
p2->p_md.md_regs = (int *)tf;
*tf = *(struct trapframe *)p1->p_md.md_regs;
sf = (struct switchframe *)tf - 1;
sf->sf_pc = (u_int)proc_trampoline;
pcb->pcb_regs[6] = (int)child_return; /* A2 */
pcb->pcb_regs[7] = (int)p2; /* A3 */
pcb->pcb_regs[11] = (int)sf; /* SSP */
}
/*
* cpu_set_kpc
* Arrange for in-kernel execution of a process to continue at the
* named PC as if the code at that address had been called as a function
* Arrange for in-kernel execution of a process to continue at the
* named pc, as if the code at that address were called as a function
* with the supplied argument.
*
* Note that it's assumed that whne the named process returns, rei()
* should be invoked to return to user mode.
* Note that it's assumed that when the named process returns, rei()
* should be invoked, to return to user code.
*/
void
cpu_set_kpc(p, pc, arg)
@ -130,18 +121,11 @@ cpu_set_kpc(p, pc, arg)
void (*pc) __P((void *));
void *arg;
{
struct pcb *pcbp;
struct switchframe *sf;
pcbp = &p->p_addr->u_pcb;
sf = (struct switchframe *)pcbp->pcb_regs[11];
sf->sf_pc = (u_int)proc_trampoline;
pcbp->pcb_regs[6] = (int)pc; /* A2 */
pcbp->pcb_regs[7] = (int)arg; /* A3 */
p->p_addr->u_pcb.pcb_regs[6] = (int) pc; /* A2 */
p->p_addr->u_pcb.pcb_regs[7] = (int) arg; /* A3 */
}
void switch_exit __P((struct proc *));
/*
* cpu_exit is called as the last action during exit.
*
@ -153,18 +137,14 @@ cpu_exit(p)
struct proc *p;
{
(void)splhigh();
(void) splhigh();
uvmexp.swtch++;
switch_exit(p);
/* NOTREACHED */
}
/*
* Dump the machine specific segment at the start of a core dump.
* This means the CPU and FPU registers. The format used here is
* the same one ptrace uses, so gdb can be machine independent.
*
* XXX - Generate Sun format core dumps for Sun executables?
* Dump the machine specific header information at the start of a core dump.
*/
struct md_core {
struct reg intreg;
@ -177,11 +157,9 @@ cpu_coredump(p, vp, cred, chdr)
struct ucred *cred;
struct core *chdr;
{
int error;
struct md_core md_core;
struct coreseg cseg;
struct user *up = p->p_addr;
int i;
int error;
CORE_SETMAGIC(*chdr, COREMAGIC, MID_MACHINE, 0);
chdr->c_hdrsize = ALIGN(sizeof(*chdr));
@ -189,28 +167,17 @@ cpu_coredump(p, vp, cred, chdr)
chdr->c_cpusize = sizeof(md_core);
/* Save integer registers. */
{
struct frame *f;
error = process_read_regs(p, &md_core.intreg);
if (error)
return error;
f = (struct frame*)p->p_md.md_regs;
for (i = 0; i < 16; i++) {
md_core.intreg.r_regs[i] = f->f_regs[i];
}
md_core.intreg.r_sr = f->f_sr;
md_core.intreg.r_pc = f->f_pc;
}
if (fputype) {
struct fpframe *f;
f = &up->u_pcb.pcb_fpregs;
m68881_save(f);
for (i = 0; i < (8*3); i++) {
md_core.freg.r_regs[i] = f->fpf_regs[i];
}
md_core.freg.r_fpcr = f->fpf_fpcr;
md_core.freg.r_fpsr = f->fpf_fpsr;
md_core.freg.r_fpiar = f->fpf_fpiar;
/* Save floating point registers. */
error = process_read_fpregs(p, &md_core.freg);
if (error)
return error;
} else {
/* Make sure these are clear. */
bzero((caddr_t)&md_core.freg, sizeof(md_core.freg));
}
@ -219,19 +186,19 @@ cpu_coredump(p, vp, cred, chdr)
cseg.c_size = chdr->c_cpusize;
error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&cseg, chdr->c_seghdrsize,
(off_t)chdr->c_hdrsize, UIO_SYSSPACE,
IO_NODELOCKED|IO_UNIT, cred, NULL, p);
(off_t)chdr->c_hdrsize, UIO_SYSSPACE, IO_NODELOCKED|IO_UNIT, cred,
NULL, p);
if (error)
return error;
error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&md_core, sizeof(md_core),
(off_t)(chdr->c_hdrsize + chdr->c_seghdrsize), UIO_SYSSPACE,
IO_NODELOCKED|IO_UNIT, cred, NULL, p);
if (error)
return error;
if (!error)
chdr->c_nseg++;
return error;
chdr->c_nseg++;
return 0;
}
/*
@ -247,7 +214,7 @@ pagemove(from, to, size)
paddr_t pa;
#ifdef DEBUG
if (size % PAGE_SIZE)
if (size & CLOFSET)
panic("pagemove");
#endif
while (size > 0) {
@ -259,7 +226,7 @@ pagemove(from, to, size)
panic("pagemove 3");
#endif
pmap_remove(pmap_kernel(),
(vaddr_t)from, (vaddr_t)from + PAGE_SIZE);
(vaddr_t)from, (vaddr_t)from + PAGE_SIZE);
pmap_enter(pmap_kernel(),
(vaddr_t)to, pa, VM_PROT_READ|VM_PROT_WRITE, 1,
VM_PROT_READ|VM_PROT_WRITE);
@ -304,29 +271,6 @@ physunaccess(vaddr, size)
TBIAS();
}
void setredzone __P((void *, caddr_t));
/*
* Set a red zone in the kernel stack after the u. area.
* We don't support a redzone right now. It really isn't clear
* that it is a good idea since, if the kernel stack were to roll
* into a write protected page, the processor would lock up (since
* it cannot create an exception frame) and we would get no useful
* post-mortem info. Currently, under the DEBUG option, we just
* check at every clock interrupt to see if the current k-stack has
* gone too far (i.e. into the "redzone" page) and if so, panic.
* Look at _lev6intr in locore.s for more details.
*/
/*ARGSUSED*/
void
setredzone(pte, vaddr)
void *pte;
caddr_t vaddr;
{
}
int kvtop __P((caddr_t addr));
/*
* Convert kernel VA to physical address
*/
@ -355,13 +299,13 @@ extern vm_map_t phys_map;
void
vmapbuf(bp, len)
struct buf *bp;
vm_size_t len;
vsize_t len;
{
struct pmap *upmap, *kpmap;
vaddr_t uva; /* User VA (map from) */
vaddr_t kva; /* Kernel VA (new to) */
paddr_t pa; /* physical address */
vm_size_t off;
paddr_t pa; /* physical address */
vsize_t off;
if ((bp->b_flags & B_PHYS) == 0)
panic("vmapbuf");
@ -391,10 +335,10 @@ vmapbuf(bp, len)
void
vunmapbuf(bp, len)
struct buf *bp;
vm_size_t len;
vsize_t len;
{
vaddr_t kva;
vm_size_t off;
vsize_t off;
if ((bp->b_flags & B_PHYS) == 0)
panic("vunmapbuf");