diff --git a/sys/arch/m68k/conf/files.m68k b/sys/arch/m68k/conf/files.m68k new file mode 100644 index 000000000000..466d2f06f622 --- /dev/null +++ b/sys/arch/m68k/conf/files.m68k @@ -0,0 +1,6 @@ +# $Id: files.m68k,v 1.1 1994/01/08 11:15:53 cgd Exp $ +# +arch/m68k/m68k/process_machdep.c standard +arch/m68k/m68k/in_cksum.c optional inet +arch/m68k/m68k/ns_cksum.c optional ns +arch/m68k/m68k/oc_cksum.s optional inet diff --git a/sys/arch/m68k/conf/files.m68k.oldconf b/sys/arch/m68k/conf/files.m68k.oldconf new file mode 100644 index 000000000000..90763dcedb90 --- /dev/null +++ b/sys/arch/m68k/conf/files.m68k.oldconf @@ -0,0 +1,6 @@ +# $Id: files.m68k.oldconf,v 1.1 1994/01/08 11:15:53 cgd Exp $ +# +arch/m68k/m68k/process_machdep.c standard +arch/m68k/m68k/in_cksum.c optional inet +arch/m68k/m68k/ns_cksum.c optional ns +arch/m68k/m68k/oc_cksum.s optional inet diff --git a/sys/arch/m68k/include/ptrace.h b/sys/arch/m68k/include/ptrace.h new file mode 100644 index 000000000000..c472b61e9e47 --- /dev/null +++ b/sys/arch/m68k/include/ptrace.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 1993 Christopher G. Demetriou + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Christopher G. Demetriou. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software withough specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 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. + * + * $Id: ptrace.h,v 1.1 1994/01/08 11:17:00 cgd Exp $ + */ + +/* + * m68k-dependent ptrace definitions + */ +#define PT_GETREGS (PT_FIRSTMACH + 0) +#define PT_SETREGS (PT_FIRSTMACH + 1) +#define PT_GETFPREGS (PT_FIRSTMACH + 2) +#define PT_SETFPREGS (PT_FIRSTMACH + 3) + diff --git a/sys/arch/m68k/m68k/in_cksum.c b/sys/arch/m68k/m68k/in_cksum.c index bc07ffc63a35..59d717376560 100644 --- a/sys/arch/m68k/m68k/in_cksum.c +++ b/sys/arch/m68k/m68k/in_cksum.c @@ -32,17 +32,17 @@ * * from: Utah Hdr: in_cksum.c 1.1 90/07/09 * from: @(#)in_cksum.c 7.3 (Berkeley) 12/16/90 - * $Id: in_cksum.c,v 1.3 1993/08/01 19:24:43 mycroft Exp $ + * $Id: in_cksum.c,v 1.4 1994/01/08 11:17:23 cgd Exp $ */ /* * in_cksum - checksum routine for the Internet Protocol family. */ -#include "sys/param.h" -#include "sys/mbuf.h" -#include "netinet/in.h" -#include "netinet/in_systm.h" +#include +#include +#include +#include extern int oc_cksum(); diff --git a/sys/arch/m68k/m68k/ns_cksum.c b/sys/arch/m68k/m68k/ns_cksum.c index 5c1ad53c7553..3f6285a776e7 100644 --- a/sys/arch/m68k/m68k/ns_cksum.c +++ b/sys/arch/m68k/m68k/ns_cksum.c @@ -31,11 +31,11 @@ * SUCH DAMAGE. * * from: @(#)ns_cksum.c 7.7 (Berkeley) 4/29/91 - * $Id: ns_cksum.c,v 1.2 1993/05/22 07:57:36 cgd Exp $ + * $Id: ns_cksum.c,v 1.3 1994/01/08 11:17:27 cgd Exp $ */ -#include "sys/param.h" -#include "sys/mbuf.h" +#include +#include /* * Checksum routine for Network Systems Protocol Packets (Big-Endian). diff --git a/sys/arch/m68k/m68k/process_machdep.c b/sys/arch/m68k/m68k/process_machdep.c new file mode 100644 index 000000000000..b9eb3096db4d --- /dev/null +++ b/sys/arch/m68k/m68k/process_machdep.c @@ -0,0 +1,176 @@ +/* + * Copyright (c) 1993 Christopher G. Demetriou + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Christopher G. Demetriou. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software withough specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 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. + * + * $Id: process_machdep.c,v 1.1 1994/01/08 11:17:29 cgd Exp $ + */ + +/* + * This file may seem a bit stylized, but that so that it's easier to port. + * Functions to be implemented here are: + * + * process_read_regs(proc, regs) + * Get the current user-visible register set from the process + * and copy it into the regs structure (). + * The process is stopped at the time read_regs is called. + * + * process_write_regs(proc, regs) + * Update the current register set from the passed in regs + * structure. Take care to avoid clobbering special CPU + * registers or privileged bits in the PSL. + * The process is stopped at the time write_regs is called. + * + * process_sstep(proc) + * Arrange for the process to trap after executing a single instruction. + * + * process_fix_sstep(proc) + * Cleanup process state after executing a single-step instruction. + * + * process_set_pc(proc) + * Set the process's program counter. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern char kstack[]; /* XXX */ + +int +process_read_regs(p, regs) + struct proc *p; + struct reg *regs; +{ + struct frame *frame; + + if ((p->p_flag & SLOAD) == 0) + return EIO; + + frame = (struct frame *) + ((char *)p->p_addr + ((char *)p->p_regs - (char *)kstack)); + + bcopy(frame->f_regs, regs->r_regs, sizeof(frame->f_regs)); + regs->r_sr = frame->f_sr; + regs->r_pc = frame->f_pc; + + return 0; +} + +int +process_write_regs(p, regs) + struct proc *p; + struct reg *regs; +{ + struct frame *frame; + + if ((p->p_flag & SLOAD) == 0) + return EIO; + + frame = (struct frame *) + ((char *)p->p_addr + ((char *)p->p_regs - (char *)kstack)); + + /* + * in the hp300 machdep.c _write_regs, PC alignment wasn't + * checked. If an odd address is placed in the PC and the + * program is allowed to run, it will cause an Address Error + * which will be transmitted to the process by a SIGBUS. + * No reasonable debugger would let this happen, but + * it's not our problem. + */ + + /* + * XXX + * in hp300 machdep.c, it just cleared/set these bits + * automatically. here, we barf. well-written programs + * shouldn't munge them. + */ + if ((regs->r_sr & PSL_USERCLR) != 0 || + (regs->r_sr & PSL_USERSET) != PSL_USERSET) + return EPERM; + + bcopy(regs->r_regs, frame->f_regs, sizeof(frame->f_regs)); + frame->f_sr = regs->r_sr; + frame->f_pc = regs->r_pc; + + return 0; +} + +int +process_sstep(p) + struct proc *p; +{ + int error; + struct reg r; + + error = process_read_regs(p, &r); + if (error == 0) { + r.r_sr |= PSL_T; + error = process_write_regs(p, &r); + } + + return (error); +} + +int +process_fix_sstep(p) + struct proc *p; +{ + return 0; +} + +int +process_set_pc(p, addr) + struct proc *p; + u_int addr; +{ + int error; + struct reg r; + + /* + * in the hp300 machdep.c _set_pc, PC alignment is guaranteed + * by chopping off the low order bit of the new pc. + * If an odd address was placed in the PC and the program + * is allowed to run, it will cause an Address Error + * which will be transmitted to the process by a SIGBUS. + * No reasonable debugger would let this happen, but + * it's not our problem. + */ + error = process_read_regs(p, &r); + if (error == 0) { + r.r_pc = addr; + error = process_write_regs(p, &r); + } + + return (error); +}