[BACK]Return to cpu.h CVS log [TXT][DIR] Up to [local] / sys / arch / arm / include

Annotation of sys/arch/arm/include/cpu.h, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: cpu.h,v 1.18 2007/08/14 15:18:07 deraadt Exp $        */
        !             2: /*     $NetBSD: cpu.h,v 1.34 2003/06/23 11:01:08 martin Exp $  */
        !             3:
        !             4: /*
        !             5:  * Copyright (c) 1994-1996 Mark Brinicombe.
        !             6:  * Copyright (c) 1994 Brini.
        !             7:  * All rights reserved.
        !             8:  *
        !             9:  * This code is derived from software written for Brini by Mark Brinicombe
        !            10:  *
        !            11:  * Redistribution and use in source and binary forms, with or without
        !            12:  * modification, are permitted provided that the following conditions
        !            13:  * are met:
        !            14:  * 1. Redistributions of source code must retain the above copyright
        !            15:  *    notice, this list of conditions and the following disclaimer.
        !            16:  * 2. Redistributions in binary form must reproduce the above copyright
        !            17:  *    notice, this list of conditions and the following disclaimer in the
        !            18:  *    documentation and/or other materials provided with the distribution.
        !            19:  * 3. All advertising materials mentioning features or use of this software
        !            20:  *    must display the following acknowledgement:
        !            21:  *     This product includes software developed by Brini.
        !            22:  * 4. The name of the company nor the name of the author may be used to
        !            23:  *    endorse or promote products derived from this software without specific
        !            24:  *    prior written permission.
        !            25:  *
        !            26:  * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED
        !            27:  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
        !            28:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
        !            29:  * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
        !            30:  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
        !            31:  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        !            32:  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            33:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            34:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            35:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            36:  * SUCH DAMAGE.
        !            37:  *
        !            38:  * RiscBSD kernel project
        !            39:  *
        !            40:  * cpu.h
        !            41:  *
        !            42:  * CPU specific symbols
        !            43:  *
        !            44:  * Created      : 18/09/94
        !            45:  *
        !            46:  * Based on kate/katelib/arm6.h
        !            47:  */
        !            48:
        !            49: #ifndef _ARM_CPU_H_
        !            50: #define _ARM_CPU_H_
        !            51:
        !            52: /*
        !            53:  * User-visible definitions
        !            54:  */
        !            55:
        !            56: /*  CTL_MACHDEP definitions. */
        !            57: #define        CPU_DEBUG               1       /* int: misc kernel debug control */
        !            58: #define        CPU_BOOTED_DEVICE       2       /* string: device we booted from */
        !            59: #define        CPU_BOOTED_KERNEL       3       /* string: kernel we booted */
        !            60: #define        CPU_CONSDEV             4       /* struct: dev_t of our console */
        !            61: #define        CPU_POWERSAVE           5       /* int: use CPU powersave mode */
        !            62: #define        CPU_ALLOWAPERTURE       6       /* int: allow mmap of /dev/xf86 */
        !            63: #define CPU_APMWARN            7       /* APM battery warning percentage */
        !            64: #define CPU_KBDRESET           8       /* int: console keyboard reset */
        !            65:                /*              9          formerly int: CPU_ZTSRAWMODE */
        !            66:                /*              10         formerly struct: CPU_ZTSSCALE */
        !            67: #define        CPU_MAXSPEED            11      /* int: number of valid machdep ids */
        !            68: #define CPU_LIDSUSPEND         12      /* int: closing lid causes suspend */
        !            69: #define        CPU_MAXID               13      /* number of valid machdep ids */
        !            70:
        !            71: #define        CTL_MACHDEP_NAMES { \
        !            72:        { 0, 0 }, \
        !            73:        { "debug", CTLTYPE_INT }, \
        !            74:        { "booted_device", CTLTYPE_STRING }, \
        !            75:        { "booted_kernel", CTLTYPE_STRING }, \
        !            76:        { "console_device", CTLTYPE_STRUCT }, \
        !            77:        { "powersave", CTLTYPE_INT }, \
        !            78:        { "allowaperture", CTLTYPE_INT }, \
        !            79:        { "apmwarn", CTLTYPE_INT }, \
        !            80:        { "kbdreset", CTLTYPE_INT }, \
        !            81:        { 0, 0 }, \
        !            82:        { 0, 0 }, \
        !            83:        { "maxspeed", CTLTYPE_INT }, \
        !            84:        { "lidsuspend", CTLTYPE_INT } \
        !            85: }
        !            86:
        !            87: #ifdef _KERNEL
        !            88:
        !            89: /*
        !            90:  * Kernel-only definitions
        !            91:  */
        !            92:
        !            93: #include <arm/cpuconf.h>
        !            94:
        !            95: #include <machine/intr.h>
        !            96: #ifndef _LOCORE
        !            97: #if 0
        !            98: #include <sys/user.h>
        !            99: #endif
        !           100: #include <machine/frame.h>
        !           101: #include <machine/pcb.h>
        !           102: #endif /* !_LOCORE */
        !           103:
        !           104: #include <arm/armreg.h>
        !           105:
        !           106: #ifndef _LOCORE
        !           107: /* 1 == use cpu_sleep(), 0 == don't */
        !           108: extern int cpu_do_powersave;
        !           109: #endif
        !           110:
        !           111: #ifdef __PROG32
        !           112: #ifdef _LOCORE
        !           113: #define IRQdisable \
        !           114:        stmfd   sp!, {r0} ; \
        !           115:        mrs     r0, cpsr ; \
        !           116:        orr     r0, r0, #(I32_bit) ; \
        !           117:        msr     cpsr_c, r0 ; \
        !           118:        ldmfd   sp!, {r0}
        !           119:
        !           120: #define IRQenable \
        !           121:        stmfd   sp!, {r0} ; \
        !           122:        mrs     r0, cpsr ; \
        !           123:        bic     r0, r0, #(I32_bit) ; \
        !           124:        msr     cpsr_c, r0 ; \
        !           125:        ldmfd   sp!, {r0}
        !           126:
        !           127: #else
        !           128: #define IRQdisable __set_cpsr_c(I32_bit, I32_bit);
        !           129: #define IRQenable __set_cpsr_c(I32_bit, 0);
        !           130: #endif /* _LOCORE */
        !           131: #endif
        !           132:
        !           133: #ifndef _LOCORE
        !           134:
        !           135: /* All the CLKF_* macros take a struct clockframe * as an argument. */
        !           136:
        !           137: /*
        !           138:  * CLKF_USERMODE: Return TRUE/FALSE (1/0) depending on whether the
        !           139:  * frame came from USR mode or not.
        !           140:  */
        !           141: #ifdef __PROG32
        !           142: #define CLKF_USERMODE(frame)   ((frame->if_spsr & PSR_MODE) == PSR_USR32_MODE)
        !           143: #else
        !           144: #define CLKF_USERMODE(frame)   ((frame->if_r15 & R15_MODE) == R15_MODE_USR)
        !           145: #endif
        !           146:
        !           147: /*
        !           148:  * CLKF_INTR: True if we took the interrupt from inside another
        !           149:  * interrupt handler.
        !           150:  */
        !           151: extern int current_intr_depth;
        !           152: #ifdef __PROG32
        !           153: /* Hack to treat FPE time as interrupt time so we can measure it */
        !           154: #define CLKF_INTR(frame)                                               \
        !           155:        ((current_intr_depth > 1) ||                                    \
        !           156:            (frame->if_spsr & PSR_MODE) == PSR_UND32_MODE)
        !           157: #else
        !           158: #define CLKF_INTR(frame)       (current_intr_depth > 1)
        !           159: #endif
        !           160:
        !           161: /*
        !           162:  * CLKF_PC: Extract the program counter from a clockframe
        !           163:  */
        !           164: #ifdef __PROG32
        !           165: #define CLKF_PC(frame)         (frame->if_pc)
        !           166: #else
        !           167: #define CLKF_PC(frame)         (frame->if_r15 & R15_PC)
        !           168: #endif
        !           169:
        !           170: /*
        !           171:  * PROC_PC: Find out the program counter for the given process.
        !           172:  */
        !           173: #ifdef __PROG32
        !           174: #define PROC_PC(p)     ((p)->p_addr->u_pcb.pcb_tf->tf_pc)
        !           175: #else
        !           176: #define PROC_PC(p)     ((p)->p_addr->u_pcb.pcb_tf->tf_r15 & R15_PC)
        !           177: #endif
        !           178:
        !           179: /* The address of the vector page. */
        !           180: extern vaddr_t vector_page;
        !           181: #ifdef __PROG32
        !           182: void   arm32_vector_init(vaddr_t, int);
        !           183:
        !           184: #define        ARM_VEC_RESET                   (1 << 0)
        !           185: #define        ARM_VEC_UNDEFINED               (1 << 1)
        !           186: #define        ARM_VEC_SWI                     (1 << 2)
        !           187: #define        ARM_VEC_PREFETCH_ABORT          (1 << 3)
        !           188: #define        ARM_VEC_DATA_ABORT              (1 << 4)
        !           189: #define        ARM_VEC_ADDRESS_EXCEPTION       (1 << 5)
        !           190: #define        ARM_VEC_IRQ                     (1 << 6)
        !           191: #define        ARM_VEC_FIQ                     (1 << 7)
        !           192:
        !           193: #define        ARM_NVEC                        8
        !           194: #define        ARM_VEC_ALL                     0xffffffff
        !           195: #endif
        !           196:
        !           197: /*
        !           198:  * Per-CPU information.  For now we assume one CPU.
        !           199:  */
        !           200:
        !           201: #include <sys/device.h>
        !           202: #include <sys/sched.h>
        !           203: struct cpu_info {
        !           204:        struct proc *ci_curproc;
        !           205:
        !           206:        struct schedstate_percpu ci_schedstate; /* scheduler state */
        !           207: #if defined(DIAGNOSTIC) || defined(LOCKDEBUG)
        !           208:        u_long ci_spin_locks;           /* # of spin locks held */
        !           209:        u_long ci_simple_locks;         /* # of simple locks held */
        !           210: #endif
        !           211:        struct device *ci_dev;          /* Device corresponding to this CPU */
        !           212:        u_int32_t ci_arm_cpuid;         /* aggregate CPU id */
        !           213:        u_int32_t ci_arm_cputype;       /* CPU type */
        !           214:        u_int32_t ci_arm_cpurev;        /* CPU revision */
        !           215:        u_int32_t ci_ctrl;              /* The CPU control register */
        !           216: #ifdef MULTIPROCESSOR
        !           217:        MP_CPU_INFO_MEMBERS
        !           218: #endif
        !           219: };
        !           220:
        !           221: #ifndef MULTIPROCESSOR
        !           222: extern struct cpu_info cpu_info_store;
        !           223: #define        curcpu()        (&cpu_info_store)
        !           224: #define cpu_number()   0
        !           225: #define CPU_IS_PRIMARY(ci)     1
        !           226: #define CPU_INFO_ITERATOR      int
        !           227: #define CPU_INFO_FOREACH(cii, ci) \
        !           228:        for (cii = 0, ci = curcpu(); ci != NULL; ci = NULL)
        !           229: #endif
        !           230:
        !           231: #ifdef __PROG32
        !           232: void   cpu_proc_fork(struct proc *, struct proc *);
        !           233: #else
        !           234: #define        cpu_proc_fork(p1, p2)
        !           235: #endif
        !           236:
        !           237: /*
        !           238:  * Scheduling glue
        !           239:  */
        !           240:
        !           241: extern int astpending;
        !           242: #define setsoftast() (astpending = 1)
        !           243:
        !           244: /*
        !           245:  * Notify the current process (p) that it has a signal pending,
        !           246:  * process as soon as possible.
        !           247:  */
        !           248:
        !           249: #define signotify(p)            setsoftast()
        !           250:
        !           251: #define cpu_wait(p)    /* nothing */
        !           252:
        !           253: /*
        !           254:  * Preempt the current process if in interrupt from user mode,
        !           255:  * or after the current trap/syscall if in system mode.
        !           256:  */
        !           257: extern int want_resched;       /* resched() was called */
        !           258: #define        need_resched(ci)        (want_resched = 1, setsoftast())
        !           259:
        !           260: /*
        !           261:  * Give a profiling tick to the current process when the user profiling
        !           262:  * buffer pages are invalid.  On the i386, request an ast to send us
        !           263:  * through trap(), marking the proc as needing a profiling tick.
        !           264:  */
        !           265: #define        need_proftick(p)        setsoftast()
        !           266:
        !           267: #ifndef acorn26
        !           268: /*
        !           269:  * cpu device glue (belongs in cpuvar.h)
        !           270:  */
        !           271:
        !           272: struct device;
        !           273: void   cpu_attach      (struct device *);
        !           274: int    cpu_alloc_idlepcb       (struct cpu_info *);
        !           275: #endif
        !           276:
        !           277:
        !           278: /*
        !           279:  * Random cruft
        !           280:  */
        !           281:
        !           282: /* locore.S */
        !           283: void atomic_set_bit    (u_int *address, u_int setmask);
        !           284: void atomic_clear_bit  (u_int *address, u_int clearmask);
        !           285:
        !           286: /* cpuswitch.S */
        !           287: struct pcb;
        !           288: void   savectx         (struct pcb *pcb);
        !           289:
        !           290: /* ast.c */
        !           291: void userret           (struct proc *p);
        !           292:
        !           293: /* machdep.h */
        !           294: void bootsync          (int);
        !           295:
        !           296: /* fault.c */
        !           297: int badaddr_read       (void *, size_t, void *);
        !           298:
        !           299: /* syscall.c */
        !           300: void swi_handler       (trapframe_t *);
        !           301:
        !           302: /* machine_machdep.c */
        !           303: void board_startup(void);
        !           304:
        !           305: #endif /* !_LOCORE */
        !           306:
        !           307: #endif /* _KERNEL */
        !           308:
        !           309: #endif /* !_ARM_CPU_H_ */
        !           310:
        !           311: /* End of cpu.h */

CVSweb