Annotation of sys/arch/m88k/include/cpu.h, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: cpu.h,v 1.22 2007/05/19 20:34:32 miod Exp $ */
! 2: /*
! 3: * Copyright (c) 1996 Nivas Madhur
! 4: * Copyright (c) 1992, 1993
! 5: * The Regents of the University of California. All rights reserved.
! 6: *
! 7: * This software was developed by the Computer Systems Engineering group
! 8: * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
! 9: * contributed to Berkeley.
! 10: *
! 11: * All advertising materials mentioning features or use of this software
! 12: * must display the following acknowledgement:
! 13: * This product includes software developed by the University of
! 14: * California, Lawrence Berkeley Laboratory.
! 15: *
! 16: * Redistribution and use in source and binary forms, with or without
! 17: * modification, are permitted provided that the following conditions
! 18: * are met:
! 19: * 1. Redistributions of source code must retain the above copyright
! 20: * notice, this list of conditions and the following disclaimer.
! 21: * 2. Redistributions in binary form must reproduce the above copyright
! 22: * notice, this list of conditions and the following disclaimer in the
! 23: * documentation and/or other materials provided with the distribution.
! 24: * 3. Neither the name of the University nor the names of its contributors
! 25: * may be used to endorse or promote products derived from this software
! 26: * without specific prior written permission.
! 27: *
! 28: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
! 29: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! 30: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! 31: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
! 32: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! 33: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
! 34: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 35: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
! 36: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
! 37: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! 38: * SUCH DAMAGE.
! 39: */
! 40:
! 41: #ifndef __M88K_CPU_H__
! 42: #define __M88K_CPU_H__
! 43:
! 44: /*
! 45: * CTL_MACHDEP definitinos.
! 46: */
! 47: #define CPU_CONSDEV 1 /* dev_t: console terminal device */
! 48: #define CPU_MAXID 2 /* number of valid machdep ids */
! 49:
! 50: #define CTL_MACHDEP_NAMES { \
! 51: { 0, 0 }, \
! 52: { "console_device", CTLTYPE_STRUCT }, \
! 53: }
! 54:
! 55: #ifdef _KERNEL
! 56:
! 57: #include <machine/atomic.h>
! 58: #include <machine/pcb.h>
! 59: #include <machine/psl.h>
! 60: #include <machine/intr.h>
! 61: #include <sys/sched.h>
! 62:
! 63: #if defined(MULTIPROCESSOR)
! 64: #if !defined(MAX_CPUS) || MAX_CPUS > 4
! 65: #undef MAX_CPUS
! 66: #define MAX_CPUS 4
! 67: #endif
! 68: #else
! 69: #if !defined(MAX_CPUS)
! 70: #undef MAX_CPUS
! 71: #define MAX_CPUS 1
! 72: #endif
! 73: #endif
! 74:
! 75: #ifndef _LOCORE
! 76:
! 77: extern u_int max_cpus;
! 78:
! 79: /*
! 80: * Per-CPU data structure
! 81: */
! 82:
! 83: struct cpu_info {
! 84: u_int ci_alive; /* nonzero if CPU present */
! 85:
! 86: struct proc *ci_curproc; /* current process... */
! 87: struct pcb *ci_curpcb; /* ...and its pcb */
! 88:
! 89: u_int ci_cpuid; /* cpu number */
! 90: u_int ci_primary; /* set if master cpu */
! 91: u_int ci_pfsr_i0, ci_pfsr_i1; /* instruction... */
! 92: u_int ci_pfsr_d0, ci_pfsr_d1; /* ... and data CMMU PFSRs */
! 93:
! 94: struct schedstate_percpu ci_schedstate; /* scheduling state */
! 95: int ci_want_resched; /* need_resched() invoked */
! 96:
! 97: struct pcb *ci_idle_pcb; /* idle pcb (and stack) */
! 98:
! 99: u_int ci_intrdepth; /* interrupt depth */
! 100:
! 101: u_long ci_spin_locks; /* spin locks counter */
! 102:
! 103: volatile int ci_ddb_state; /* ddb status */
! 104: #define CI_DDB_RUNNING 0
! 105: #define CI_DDB_ENTERDDB 1
! 106: #define CI_DDB_INDDB 2
! 107: #define CI_DDB_PAUSE 3
! 108:
! 109: volatile int ci_ipi; /* pending ipis */
! 110: #define CI_IPI_NOTIFY 0x00000001
! 111: #define CI_IPI_HARDCLOCK 0x00000002
! 112: #define CI_IPI_STATCLOCK 0x00000004
! 113: #define CI_IPI_DDB 0x00000008
! 114: };
! 115:
! 116: extern cpuid_t master_cpu;
! 117: extern struct cpu_info m88k_cpus[MAX_CPUS];
! 118:
! 119: #define CPU_INFO_ITERATOR cpuid_t
! 120: #define CPU_INFO_FOREACH(cii, ci) \
! 121: for ((cii) = 0; (cii) < MAX_CPUS; (cii)++) \
! 122: if (((ci) = &m88k_cpus[cii])->ci_alive != 0)
! 123: #define CPU_INFO_UNIT(ci) ((ci)->ci_cpuid)
! 124:
! 125: #if defined(MULTIPROCESSOR)
! 126:
! 127: #define curcpu() \
! 128: ({ \
! 129: struct cpu_info *cpuptr; \
! 130: \
! 131: __asm__ __volatile__ ("ldcr %0, cr17" : "=r" (cpuptr)); \
! 132: cpuptr; \
! 133: })
! 134:
! 135: #define CPU_IS_PRIMARY(ci) ((ci)->ci_primary != 0)
! 136:
! 137: void cpu_boot_secondary_processors(void);
! 138: void m88k_send_ipi(int, cpuid_t);
! 139: void m88k_broadcast_ipi(int);
! 140:
! 141: #else /* MULTIPROCESSOR */
! 142:
! 143: #define curcpu() (&m88k_cpus[0])
! 144: #define CPU_IS_PRIMARY(ci) 1
! 145:
! 146: #endif /* MULTIPROCESSOR */
! 147:
! 148: void set_cpu_number(cpuid_t);
! 149:
! 150: /*
! 151: * The md code may hardcode this in some very specific situations.
! 152: */
! 153: #if !defined(cpu_number)
! 154: #define cpu_number() curcpu()->ci_cpuid
! 155: #endif
! 156:
! 157: #define curpcb curcpu()->ci_curpcb
! 158:
! 159: #endif /* _LOCORE */
! 160:
! 161: /*
! 162: * definitions of cpu-dependent requirements
! 163: * referenced in generic code
! 164: */
! 165: #define cpu_exec(p) do { /* nothing */ } while (0)
! 166: #define cpu_wait(p) do { /* nothing */ } while (0)
! 167:
! 168: #if defined(MULTIPROCESSOR)
! 169: #include <sys/lock.h>
! 170: #include <sys/mplock.h>
! 171: #endif
! 172:
! 173: /*
! 174: * Arguments to hardclock and gatherstats encapsulate the previous
! 175: * machine state in an opaque clockframe. CLKF_INTR is only valid
! 176: * if the process is in kernel mode. Clockframe is really trapframe,
! 177: * so pointer to clockframe can be safely cast into a pointer to
! 178: * trapframe.
! 179: */
! 180: struct clockframe {
! 181: struct trapframe tf;
! 182: };
! 183:
! 184: #define CLKF_USERMODE(framep) (((framep)->tf.tf_epsr & PSR_MODE) == 0)
! 185: #define CLKF_PC(framep) ((framep)->tf.tf_sxip & XIP_ADDR)
! 186: #define CLKF_INTR(framep) \
! 187: (((struct cpu_info *)(framep)->tf.tf_cpu)->ci_intrdepth > 1)
! 188:
! 189: /*
! 190: * Get interrupt glue.
! 191: */
! 192: #include <machine/intr.h>
! 193:
! 194: #define SIR_NET 0x01
! 195: #define SIR_CLOCK 0x02
! 196:
! 197: extern unsigned int ssir;
! 198: #define setsoftint(x) atomic_setbits_int(&ssir, x)
! 199: #define setsoftnet() setsoftint(SIR_NET)
! 200: #define setsoftclock() setsoftint(SIR_CLOCK)
! 201:
! 202: #define aston(p) ((p)->p_md.md_astpending = 1)
! 203:
! 204: /*
! 205: * This is used during profiling to integrate system time.
! 206: */
! 207: #define PC_REGS(regs) \
! 208: (CPU_IS88110 ? ((regs)->exip & XIP_ADDR) : \
! 209: ((regs)->sxip & XIP_V ? (regs)->sxip & XIP_ADDR : \
! 210: ((regs)->snip & NIP_V ? (regs)->snip & NIP_ADDR : \
! 211: (regs)->sfip & FIP_ADDR)))
! 212: #define PROC_PC(p) PC_REGS((struct reg *)((p)->p_md.md_tf))
! 213:
! 214: /*
! 215: * Preempt the current process if in interrupt from user mode,
! 216: * or after the current trap/syscall if in system mode.
! 217: */
! 218: #define need_resched(ci) \
! 219: do { \
! 220: ci->ci_want_resched = 1; \
! 221: if (ci->ci_curproc != NULL) \
! 222: aston(ci->ci_curproc); \
! 223: } while (0)
! 224:
! 225: /*
! 226: * Give a profiling tick to the current process when the user profiling
! 227: * buffer pages are invalid. On the m88k, request an ast to send us
! 228: * through trap(), marking the proc as needing a profiling tick.
! 229: */
! 230: #define need_proftick(p) aston(p)
! 231:
! 232: void signotify(struct proc *);
! 233:
! 234: /*
! 235: * switchframe - should be double word aligned.
! 236: */
! 237: struct switchframe {
! 238: u_int sf_pc; /* pc */
! 239: void *sf_proc; /* proc pointer */
! 240: };
! 241:
! 242: int badaddr(vaddr_t addr, int size);
! 243:
! 244: #endif /* _KERNEL */
! 245: #endif /* __M88K_CPU_H__ */
CVSweb