summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>1999-04-20 20:45:38 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>1999-04-20 20:45:38 +0000
commite12099da70fac838dcbe8c7a7255ade4478285e4 (patch)
tree315f7d2cd62809382ba086663bdce8db563a511b /sys/arch
parentfd3f16229fd14f66586358ca0f3e246972428d37 (diff)
some cpu_* routines, uvm
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/hppa/hppa/vm_machdep.c113
1 files changed, 88 insertions, 25 deletions
diff --git a/sys/arch/hppa/hppa/vm_machdep.c b/sys/arch/hppa/hppa/vm_machdep.c
index f88c8178770..93eba876597 100644
--- a/sys/arch/hppa/hppa/vm_machdep.c
+++ b/sys/arch/hppa/hppa/vm_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_machdep.c,v 1.3 1999/02/25 19:08:50 mickey Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.4 1999/04/20 20:45:37 mickey Exp $ */
#include <sys/param.h>
#include <sys/systm.h>
@@ -7,11 +7,16 @@
#include <sys/buf.h>
#include <sys/vnode.h>
#include <sys/user.h>
+#include <sys/ptrace.h>
+#include <sys/exec.h>
+#include <sys/core.h>
-#include <vm/vm_kern.h>
#include <machine/pmap.h>
+#include <machine/pcb.h>
#include <vm/vm.h>
+#include <vm/vm_kern.h>
+#include <uvm/uvm.h>
/*
@@ -24,7 +29,36 @@ cpu_coredump(p, vp, cred, core)
struct ucred *cred;
struct core *core;
{
- return EIO;
+ struct md_coredump md_core;
+ struct coreseg cseg;
+ off_t off;
+ int error;
+
+ CORE_SETMAGIC(*core, COREMAGIC, MID_ZERO, 0);
+ core->c_hdrsize = ALIGN(sizeof(*core));
+ core->c_seghdrsize = ALIGN(sizeof(cseg));
+ core->c_cpusize = sizeof(md_core);
+
+ process_read_regs(p, &md_core.md_reg);
+
+ CORE_SETMAGIC(cseg, CORESEGMAGIC, MID_ZERO, CORE_CPU);
+ cseg.c_addr = 0;
+ cseg.c_size = core->c_cpusize;
+
+#define write(vp, addr, n) vn_rdwr(UIO_WRITE, (vp), (caddr_t)(addr), (n), off, \
+ UIO_SYSSPACE, IO_NODELOCKED|IO_UNIT, cred, NULL, p)
+
+ off = core->c_hdrsize;
+ if ((error = write(vp, &cseg, core->c_seghdrsize)))
+ return error;
+ off += core->c_seghdrsize;
+ if ((error = write(vp, (caddr_t)&md_core, sizeof md_core)))
+ return error;
+
+#undef write
+ core->c_nseg++;
+
+ return error;
}
/*
@@ -55,52 +89,81 @@ void
cpu_swapin(p)
struct proc *p;
{
-
+ /* nothing yet, move to macros later */
}
void
cpu_swapout(p)
struct proc *p;
{
-
+ /* FPU save state */
}
void
cpu_fork(p1, p2)
struct proc *p1, *p2;
{
- p2->p_md.md_flags = p1->p_md.md_flags;
-
- p2->p_addr->u_pcb = p1->p_addr->u_pcb;
-
- /* TODO: create the child's kernel stack */
+ register struct pcb *pcbp;
+ register struct trapframe *tf;
+ register struct hppa_frame *sp;
+
+ pcbp = &p2->p_addr->u_pcb;
+ *pcbp = p1->p_addr->u_pcb;
+ /* space is cached for the copy{in,out}'s pleasure */
+ pcbp->pcb_space = p2->p_vmspace->vm_pmap.pmap_space;
+
+#ifdef DIAGNOSTIC
+ if (round_page(sizeof(struct user)) >= USPACE)
+ panic("USPACE too small for user");
+#endif
+
+ p2->p_md.md_regs = tf = &pcbp->pcb_tf;
+ sp = (struct hppa_frame *)((register_t)p2->p_addr +
+ round_page(sizeof(struct user)));
+ /* setup initial stack frame */
+ bzero(sp, sizeof(struct hppa_frame));
+ tf->tf_sp = (register_t)(sp + 1);
+
+ /*
+ * everybody recomends to note here the inline version of
+ * the cpu_set_kpc(), so note it !
+ */
+ tf->tf_arg0 = KERNMODE(child_return);
+ tf->tf_arg1 = (register_t)p2;
+ tf->tf_iioq_tail = tf->tf_iioq_head = (register_t)switch_trampoline;
}
void
-cpu_exit(p)
+cpu_set_kpc(p, pc, arg)
struct proc *p;
+ void (*pc) __P((void *));
+ void *arg;
{
- /* TODO: anything to be done about FPU */
+ register struct pcb *pcbp = &p->p_addr->u_pcb;
- vmspace_free(p->p_vmspace);
- /* to the switch */
-}
+ pcbp->pcb_tf.tf_arg0 = (register_t)pc;
+ pcbp->pcb_tf.tf_arg1 = (register_t)arg;
+ pcbp->pcb_tf.tf_iioq_tail = pcbp->pcb_tf.tf_iioq_head =
+ (register_t)switch_trampoline;
+}
void
-cpu_wait(p)
+cpu_exit(p)
struct proc *p;
{
+ /* FPU: save state */
-}
+ uvmexp.swtch++;
-void
-cpu_set_kpc(p, pc, arg)
- struct proc *p;
- void (*pc) __P((void *));
- void *arg;
-{
+ curproc = NULL;
+ uvmspace_free(p->p_vmspace);
+
+ /* XXX should be in the locore? */
+ uvm_km_free(kernel_map, (vaddr_t)p->p_addr, USPACE);
+ splhigh();
+ switch_exit(p);
}
/*
@@ -120,7 +183,7 @@ vmapbuf(bp, len)
faddr = trunc_page(bp->b_saveaddr = bp->b_data);
off = (vm_offset_t)bp->b_data - faddr;
len = round_page(off + len);
- taddr = kmem_alloc_wait(phys_map, len);
+ taddr = uvm_km_valloc_wait(phys_map, len);
bp->b_data = (caddr_t)(taddr + off);
len = atop(len);
while (len--) {
@@ -149,7 +212,7 @@ vunmapbuf(bp, len)
addr = trunc_page(bp->b_data);
off = (vm_offset_t)bp->b_data - addr;
len = round_page(off + len);
- kmem_free_wakeup(phys_map, addr, len);
+ uvm_km_free_wakeup(phys_map, addr, len);
bp->b_data = bp->b_saveaddr;
bp->b_saveaddr = NULL;