Home | History | Annotate | Line # | Download | only in include
cpu.h revision 1.178
      1  1.178   cherry /*	$NetBSD: cpu.h,v 1.178 2011/12/30 17:57:49 cherry Exp $	*/
      2   1.24      cgd 
      3    1.1      cgd /*-
      4    1.1      cgd  * Copyright (c) 1990 The Regents of the University of California.
      5    1.1      cgd  * All rights reserved.
      6    1.1      cgd  *
      7    1.1      cgd  * This code is derived from software contributed to Berkeley by
      8    1.1      cgd  * William Jolitz.
      9    1.1      cgd  *
     10    1.1      cgd  * Redistribution and use in source and binary forms, with or without
     11    1.1      cgd  * modification, are permitted provided that the following conditions
     12    1.1      cgd  * are met:
     13    1.1      cgd  * 1. Redistributions of source code must retain the above copyright
     14    1.1      cgd  *    notice, this list of conditions and the following disclaimer.
     15    1.1      cgd  * 2. Redistributions in binary form must reproduce the above copyright
     16    1.1      cgd  *    notice, this list of conditions and the following disclaimer in the
     17    1.1      cgd  *    documentation and/or other materials provided with the distribution.
     18  1.103      agc  * 3. Neither the name of the University nor the names of its contributors
     19    1.1      cgd  *    may be used to endorse or promote products derived from this software
     20    1.1      cgd  *    without specific prior written permission.
     21    1.1      cgd  *
     22    1.1      cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     23    1.1      cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24    1.1      cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25    1.1      cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     26    1.1      cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27    1.1      cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28    1.1      cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29    1.1      cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30    1.1      cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31    1.1      cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32    1.1      cgd  * SUCH DAMAGE.
     33    1.1      cgd  *
     34   1.24      cgd  *	@(#)cpu.h	5.4 (Berkeley) 5/9/91
     35    1.1      cgd  */
     36    1.1      cgd 
     37   1.14  mycroft #ifndef _I386_CPU_H_
     38   1.14  mycroft #define _I386_CPU_H_
     39   1.14  mycroft 
     40  1.173       ad #include <x86/cpu.h>
     41   1.82     fvdl 
     42  1.174       ad #ifdef _KERNEL
     43  1.174       ad 
     44  1.176    pooka #if defined(__GNUC__) && !defined(_MODULE)
     45  1.146       ad static struct cpu_info *x86_curcpu(void);
     46  1.146       ad static lwp_t *x86_curlwp(void);
     47  1.105     yamt 
     48  1.153    perry __inline static struct cpu_info * __unused
     49  1.146       ad x86_curcpu(void)
     50  1.105     yamt {
     51  1.105     yamt 	struct cpu_info *ci;
     52  1.105     yamt 
     53  1.119    perry 	__asm volatile("movl %%fs:%1, %0" :
     54  1.105     yamt 	    "=r" (ci) :
     55  1.105     yamt 	    "m"
     56  1.115     yamt 	    (*(struct cpu_info * const *)offsetof(struct cpu_info, ci_self)));
     57  1.105     yamt 	return ci;
     58  1.105     yamt }
     59  1.105     yamt 
     60  1.175       ad __inline static lwp_t * __attribute__ ((const))
     61  1.146       ad x86_curlwp(void)
     62  1.146       ad {
     63  1.146       ad 	lwp_t *l;
     64  1.146       ad 
     65  1.146       ad 	__asm volatile("movl %%fs:%1, %0" :
     66  1.146       ad 	    "=r" (l) :
     67  1.146       ad 	    "m"
     68  1.146       ad 	    (*(struct cpu_info * const *)offsetof(struct cpu_info, ci_curlwp)));
     69  1.146       ad 	return l;
     70  1.146       ad }
     71  1.177     yamt 
     72  1.168       ad __inline static void __unused
     73  1.168       ad cpu_set_curpri(int pri)
     74  1.168       ad {
     75  1.168       ad 
     76  1.168       ad 	__asm volatile(
     77  1.168       ad 	    "movl %1, %%fs:%0" :
     78  1.168       ad 	    "=m" (*(struct cpu_info *)offsetof(struct cpu_info, ci_schedstate.spc_curpriority)) :
     79  1.168       ad 	    "r" (pri)
     80  1.168       ad 	);
     81  1.168       ad }
     82  1.158   bouyer #endif
     83    1.1      cgd 
     84  1.118     cube #define	CLKF_USERMODE(frame)	USERMODE((frame)->cf_if.if_cs, (frame)->cf_if.if_eflags)
     85  1.118     cube #define	CLKF_PC(frame)		((frame)->cf_if.if_eip)
     86  1.130     yamt #define	CLKF_INTR(frame)	(curcpu()->ci_idepth > 0)
     87   1.95  thorpej #define	LWP_PC(l)		((l)->l_md.md_regs->tf_eip)
     88   1.12  mycroft 
     89  1.178   cherry #ifdef PAE
     90  1.178   cherry void cpu_alloc_l3_page(struct cpu_info *);
     91  1.178   cherry #endif /* PAE */
     92  1.178   cherry 
     93  1.174       ad #endif	/* _KERNEL */
     94  1.174       ad 
     95   1.14  mycroft #endif /* !_I386_CPU_H_ */
     96