diff options
Diffstat (limited to 'sys/powerpc')
-rw-r--r-- | sys/powerpc/include/bootinfo.h | 21 | ||||
-rw-r--r-- | sys/powerpc/include/clock.h | 22 | ||||
-rw-r--r-- | sys/powerpc/include/md_var.h | 50 | ||||
-rw-r--r-- | sys/powerpc/powerpc/genassym.c | 212 | ||||
-rw-r--r-- | sys/powerpc/powerpc/procfs_machdep.c | 146 |
5 files changed, 451 insertions, 0 deletions
diff --git a/sys/powerpc/include/bootinfo.h b/sys/powerpc/include/bootinfo.h new file mode 100644 index 0000000..36b3943 --- /dev/null +++ b/sys/powerpc/include/bootinfo.h @@ -0,0 +1,21 @@ +/* + * Kernel-internal structure used to hold important bits of boot + * information. NOT to be used by boot blocks. + * + * Note that not all of the fields from the bootinfo struct(s) + * passed by the boot blocks aren't here (because they're not currently + * used by the kernel!). Fields here which aren't supplied by the + * bootinfo structure passed by the boot blocks are supposed to be + * filled in at startup with sane contents. + */ +struct bootinfo_kernel { + u_long ssym; /* start of syms */ + u_long esym; /* end of syms */ + u_long hwrpb_phys; /* hwrpb physical address */ + u_long hwrpb_size; /* size of hwrpb data */ + char boot_flags[64]; /* boot flags */ + char booted_kernel[64]; /* name of booted kernel */ + char booted_dev[64]; /* name of booted device */ +}; + +extern struct bootinfo_kernel bootinfo; diff --git a/sys/powerpc/include/clock.h b/sys/powerpc/include/clock.h new file mode 100644 index 0000000..95c160f --- /dev/null +++ b/sys/powerpc/include/clock.h @@ -0,0 +1,22 @@ +/* + * Kernel interface to machine-dependent clock driver. + * Garrett Wollman, September 1994. + * This file is in the public domain. + * + * $Id: clock.h,v 1.34 1998/03/05 21:45:42 tegge Exp $ + */ + +#ifndef _MACHINE_CLOCK_H_ +#define _MACHINE_CLOCK_H_ + +#ifdef KERNEL + +extern int wall_cmos_clock; +extern int adjkerntz; + +void DELAY __P((int usec)); +int sysbeep __P((int pitch, int period)); + +#endif /* KERNEL */ + +#endif /* !_MACHINE_CLOCK_H_ */ diff --git a/sys/powerpc/include/md_var.h b/sys/powerpc/include/md_var.h new file mode 100644 index 0000000..d70c1da --- /dev/null +++ b/sys/powerpc/include/md_var.h @@ -0,0 +1,50 @@ +/*- + * Copyright (c) 1998 Doug Rabson + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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$ + */ + +#ifndef _MACHINE_MD_VAR_H_ +#define _MACHINE_MD_VAR_H_ + +/* + * Miscellaneous machine-dependent declarations. + */ + +extern char sigcode[]; +extern int szsigcode; +extern int Maxmem; +extern void (*netisrs[32]) __P((void)); + +void cpu_power_down __P((void)); +void cpu_halt __P((void)); +void cpu_reset __P((void)); +int is_physical_memory __P((vm_offset_t addr)); +void swi_vm __P((void)); +int vm_page_zero_idle __P((void)); +int fill_regs __P((struct proc *, struct reg *)); +int set_regs __P((struct proc *, struct reg *)); + +#endif /* !_MACHINE_MD_VAR_H_ */ diff --git a/sys/powerpc/powerpc/genassym.c b/sys/powerpc/powerpc/genassym.c new file mode 100644 index 0000000..520bd41 --- /dev/null +++ b/sys/powerpc/powerpc/genassym.c @@ -0,0 +1,212 @@ +/*- + * Copyright (c) 1982, 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * 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 the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 + * $Id: genassym.c,v 1.54 1998/04/06 18:59:14 peter Exp $ + */ + +#include <sys/param.h> +#include <sys/buf.h> +#include <sys/errno.h> +#include <sys/proc.h> +#include <sys/mount.h> +#include <sys/socket.h> +#include <sys/resource.h> +#include <sys/resourcevar.h> +#include <machine/frame.h> +#include <sys/vmmeter.h> +#include <vm/vm.h> +#include <vm/vm_param.h> +#include <vm/pmap.h> +#include <vm/vm_map.h> +#define KERNEL /* XXX avoid user headers */ +#include <sys/user.h> +#undef KERNEL +#include <net/if.h> +#include <netinet/in.h> +#include <nfs/nfsv2.h> +#include <nfs/rpcv2.h> +#include <nfs/nfs.h> +#include <nfs/nfsdiskless.h> + +int main __P((void)); +int printf __P((const char *, ...)); + +#define P(name, val) \ + printf(val > 999 ? "#define\t%s 0x%lx\n" : "#define\t%s %ld\n", name, val) + +/* XXX Danger Will Robinson */ +struct prochd { + struct proc *ph_link; /* Linked list of running processes. */ + struct proc *ph_rlink; +}; + +#define OFF(name, type, elem) P(#name, (long)&((type*)0)->elem) +#define CONST2(name, val) P(#name, val) +#define CONST1(name) P(#name, name) + +int +main() +{ + OFF(P_FORW, struct proc, p_procq.tqe_next); + OFF(P_BACK, struct proc, p_procq.tqe_prev); + OFF(P_VMSPACE, struct proc, p_vmspace); + OFF(P_ADDR, struct proc, p_addr); + OFF(P_PRI, struct proc, p_priority); + OFF(P_RTPRIO_TYPE, struct proc, p_rtprio.type); + OFF(P_RTPRIO_PRIO, struct proc, p_rtprio.prio); + OFF(P_STAT, struct proc, p_stat); + OFF(P_WCHAN, struct proc, p_wchan); + OFF(P_FLAG, struct proc, p_flag); + OFF(P_PID, struct proc, p_pid); + OFF(P_RUNTIME, struct proc, p_runtime); + OFF(P_MD_PCBPADDR, struct proc, p_md.md_pcbpaddr); + + OFF(PH_LINK, struct prochd, ph_link); + OFF(PH_RLINK, struct prochd, ph_rlink); + + CONST1(SSLEEP); + CONST1(SRUN); + + OFF(VM_PMAP, struct vmspace, vm_pmap); + OFF(V_TRAP, struct vmmeter, v_trap); + OFF(V_SYSCALL, struct vmmeter, v_trap); + OFF(V_INTR, struct vmmeter, v_trap); + + CONST1(UPAGES); + CONST1(PAGE_SIZE); + CONST1(PAGE_SHIFT); + CONST1(PAGE_MASK); + CONST1(USRSTACK); + CONST1(VM_MAXUSER_ADDRESS); + CONST1(KERNBASE); + CONST1(PTLEV1I); + CONST1(PTESIZE); + + OFF(U_PCB_ONFAULT, struct user, u_pcb.pcb_onfault); + OFF(U_PCB_HWPCB_KSP, struct user, u_pcb.pcb_hw.apcb_ksp); + OFF(U_PCB_CONTEXT, struct user, u_pcb.pcb_context); + OFF(U_PROFSCALE, struct user, u_stats.p_prof.pr_scale); + + OFF(PR_BASE, struct uprof, pr_base); + OFF(PR_SIZE, struct uprof, pr_size); + OFF(PR_OFF, struct uprof, pr_off); + OFF(PR_SCALE, struct uprof, pr_scale); + + OFF(RU_MINFLT, struct rusage, ru_minflt); + + OFF(PCB_HW, struct pcb, pcb_hw); + OFF(PCB_CONTEXT, struct pcb, pcb_context); + OFF(PCB_FP, struct pcb, pcb_fp); + OFF(PCB_ONFAULT, struct pcb, pcb_onfault); + OFF(PCB_ACCESSADDR, struct pcb, pcb_accessaddr); + + OFF(FPREG_FPR_REGS, struct fpreg, fpr_regs); + OFF(FPREG_FPR_CR, struct fpreg, fpr_cr); + + CONST1(B_READ); + CONST1(ENOENT); + CONST1(EFAULT); + CONST1(ENAMETOOLONG); + CONST1(MAXPATHLEN); + + /* Register offsets, for stack frames. */ + CONST1(FRAME_V0), + CONST1(FRAME_T0), + CONST1(FRAME_T1), + CONST1(FRAME_T2), + CONST1(FRAME_T3), + CONST1(FRAME_T4), + CONST1(FRAME_T5), + CONST1(FRAME_T6), + CONST1(FRAME_T7), + CONST1(FRAME_S0), + CONST1(FRAME_S1), + CONST1(FRAME_S2), + CONST1(FRAME_S3), + CONST1(FRAME_S4), + CONST1(FRAME_S5), + CONST1(FRAME_S6), + CONST1(FRAME_A3), + CONST1(FRAME_A4), + CONST1(FRAME_A5), + CONST1(FRAME_T8), + CONST1(FRAME_T9), + CONST1(FRAME_T10), + CONST1(FRAME_T11), + CONST1(FRAME_RA), + CONST1(FRAME_T12), + CONST1(FRAME_AT), + CONST1(FRAME_SP), + + CONST1(FRAME_SW_SIZE), + + CONST1(FRAME_PS), + CONST1(FRAME_PC), + CONST1(FRAME_GP), + CONST1(FRAME_A0), + CONST1(FRAME_A1), + CONST1(FRAME_A2), + + CONST1(FRAME_SIZE), + + /* bits of the PS register */ + CONST1(ALPHA_PSL_USERMODE); + CONST1(ALPHA_PSL_IPL_MASK); + CONST1(ALPHA_PSL_IPL_0); + CONST1(ALPHA_PSL_IPL_SOFT); + CONST1(ALPHA_PSL_IPL_HIGH); + + /* pte bits */ + CONST1(ALPHA_L1SHIFT); + CONST1(ALPHA_L2SHIFT); + CONST1(ALPHA_L3SHIFT); + CONST1(ALPHA_K1SEG_BASE); + CONST1(ALPHA_PTE_VALID); + CONST1(ALPHA_PTE_ASM); + CONST1(ALPHA_PTE_KR); + CONST1(ALPHA_PTE_KW); + + /* Kernel entries */ + CONST1(ALPHA_KENTRY_ARITH); + CONST1(ALPHA_KENTRY_MM); + + CONST1(ALPHA_KENTRY_IF); + CONST1(ALPHA_KENTRY_UNA); + + CONST1(VPTBASE); + + return (0); +} diff --git a/sys/powerpc/powerpc/procfs_machdep.c b/sys/powerpc/powerpc/procfs_machdep.c new file mode 100644 index 0000000..11898d0 --- /dev/null +++ b/sys/powerpc/powerpc/procfs_machdep.c @@ -0,0 +1,146 @@ +/* + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * Copyright (c) 1993 Jan-Simon Pendry + * + * This code is derived from software contributed to Berkeley by + * Jan-Simon Pendry. + * + * 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 the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. + * + * @(#)procfs_machdep.c 8.3 (Berkeley) 1/27/94 + * + * From: + * $Id: procfs_machdep.c,v 1.10 1997/07/20 08:37:22 bde Exp $ + */ + +/* + * Functions to be implemented here are: + * + * procfs_read_regs(proc, regs) + * Get the current user-visible register set from the process + * and copy it into the regs structure (<machine/reg.h>). + * The process is stopped at the time read_regs is called. + * + * procfs_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. + * Depending on the architecture this may have fix-up work to do, + * especially if the IAR or PCW are modified. + * The process is stopped at the time write_regs is called. + * + * procfs_read_fpregs, procfs_write_fpregs + * deal with the floating point register set, otherwise as above. + * + * procfs_sstep(proc) + * Arrange for the process to trap after executing a single instruction. + * + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/proc.h> +#include <sys/ptrace.h> +#include <sys/vnode.h> +#include <machine/reg.h> +#include <machine/md_var.h> +#include <miscfs/procfs/procfs.h> + +#include <vm/vm.h> +#include <sys/lock.h> +#include <vm/pmap.h> +#include <vm/vm_map.h> + +#include <sys/user.h> + +int +procfs_read_regs(p, regs) + struct proc *p; + struct reg *regs; +{ + if ((p->p_flag & P_INMEM) == 0) + return (EIO); + return (fill_regs(p, regs)); +} + +int +procfs_write_regs(p, regs) + struct proc *p; + struct reg *regs; +{ + if ((p->p_flag & P_INMEM) == 0) + return (EIO); + return (set_regs(p, regs)); +} + +/* + * Ptrace doesn't support fpregs at all, and there are no security holes + * or translations for fpregs, so we can just copy them. + */ + +int +procfs_read_fpregs(p, fpregs) + struct proc *p; + struct fpreg *fpregs; +{ + if ((p->p_flag & P_INMEM) == 0) + return (EIO); + + if (p == fpcurproc) { + alpha_pal_wrfen(1); + savefpstate(&p->p_addr->u_pcb.pcb_fp); + alpha_pal_wrfen(0); + } + + bcopy(&p->p_addr->u_pcb.pcb_fp, fpregs, sizeof *fpregs); + return (0); +} + +int +procfs_write_fpregs(p, fpregs) + struct proc *p; + struct fpreg *fpregs; +{ + if ((p->p_flag & P_INMEM) == 0) + return (EIO); + + if (p == fpcurproc) + fpcurproc = NULL; + + bcopy(fpregs, &p->p_addr->u_pcb.pcb_fp, sizeof *fpregs); + return (0); +} + +int +procfs_sstep(p) + struct proc *p; +{ + return (EINVAL); +} |