The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/cpu.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: cpu.h,v 1.51 2020/06/15 18:04:42 ad Exp $      */
    2 
    3 /*-
    4  * Copyright (c) 2007 YAMAMOTO Takashi,
    5  * All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  *
   16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   26  * SUCH DAMAGE.
   27  */
   28 
   29 #ifndef _SYS_CPU_H_
   30 #define _SYS_CPU_H_
   31 
   32 #ifndef _LOCORE
   33 
   34 #include <machine/cpu.h>
   35 
   36 #include <sys/lwp.h>
   37 
   38 struct cpu_info;
   39 
   40 #ifdef _KERNEL
   41 #ifndef cpu_idle
   42 void cpu_idle(void);
   43 #endif
   44 
   45 #ifdef CPU_UCODE
   46 #include <sys/cpuio.h>
   47 #include <dev/firmload.h>
   48 #ifdef COMPAT_60
   49 #include <compat/sys/cpuio.h>
   50 #endif
   51 #endif
   52 
   53 #ifndef cpu_need_resched
   54 void cpu_need_resched(struct cpu_info *, struct lwp *, int);
   55 #endif
   56 
   57 /*
   58  * CPU_INFO_ITERATOR() may be supplied by machine dependent code as it
   59  * controls how the cpu_info structures are allocated.
   60  *
   61  * This macro must always iterate just the boot-CPU when the system has
   62  * not attached any cpus via mi_cpu_attach() yet, and the "ncpu" variable
   63  * is zero.
   64  */
   65 #ifndef CPU_INFO_ITERATOR
   66 #define CPU_INFO_ITERATOR               int
   67 #define CPU_INFO_FOREACH(cii, ci)       \
   68     (void)cii, ci = curcpu(); ci != NULL; ci = NULL
   69 #endif
   70 
   71 #ifndef CPU_IS_PRIMARY
   72 #define CPU_IS_PRIMARY(ci)      ((void)ci, 1)
   73 #endif
   74 
   75 #ifdef __HAVE_MD_CPU_OFFLINE
   76 void    cpu_offline_md(void);
   77 #endif
   78 
   79 struct lwp *cpu_switchto(struct lwp *, struct lwp *, bool);
   80 struct  cpu_info *cpu_lookup(u_int);
   81 int     cpu_setmodel(const char *fmt, ...)      __printflike(1, 2);
   82 const char *cpu_getmodel(void);
   83 int     cpu_setstate(struct cpu_info *, bool);
   84 int     cpu_setintr(struct cpu_info *, bool);
   85 bool    cpu_intr_p(void);
   86 bool    cpu_softintr_p(void);
   87 bool    cpu_kpreempt_enter(uintptr_t, int);
   88 void    cpu_kpreempt_exit(uintptr_t);
   89 bool    cpu_kpreempt_disabled(void);
   90 int     cpu_lwp_setprivate(struct lwp *, void *);
   91 void    cpu_intr_redistribute(void);
   92 u_int   cpu_intr_count(struct cpu_info *);
   93 void    cpu_topology_set(struct cpu_info *, u_int, u_int, u_int, u_int);
   94 void    cpu_topology_setspeed(struct cpu_info *, bool);
   95 void    cpu_topology_init(void);
   96 #endif
   97 
   98 #ifdef _KERNEL
   99 extern kmutex_t cpu_lock;
  100 extern u_int maxcpus;
  101 extern struct cpu_info **cpu_infos;
  102 extern kcpuset_t *kcpuset_attached;
  103 extern kcpuset_t *kcpuset_running;
  104 
  105 static __inline u_int
  106 cpu_index(const struct cpu_info *ci)
  107 {
  108         return ci->ci_index;
  109 }
  110 
  111 static __inline char *
  112 cpu_name(struct cpu_info *ci)
  113 {
  114         return ci->ci_data.cpu_name;
  115 }
  116 
  117 #ifdef CPU_UCODE
  118 struct cpu_ucode_softc {
  119         int loader_version;
  120         char *sc_blob;
  121         off_t sc_blobsize;
  122 };
  123 
  124 int cpu_ucode_get_version(struct cpu_ucode_version *);
  125 int cpu_ucode_apply(const struct cpu_ucode *);
  126 #ifdef COMPAT_60
  127 int compat6_cpu_ucode_get_version(struct compat6_cpu_ucode *);
  128 int compat6_cpu_ucode_apply(const struct compat6_cpu_ucode *);
  129 #endif
  130 int cpu_ucode_load(struct cpu_ucode_softc *, const char *);
  131 int cpu_ucode_md_open(firmware_handle_t *, int, const char *);
  132 #endif
  133 
  134 #endif
  135 #endif  /* !_LOCORE */
  136 
  137 /*
  138  * Flags for cpu_need_resched.  RESCHED_KPREEMPT must be greater than
  139  * RESCHED_UPREEMPT; see sched_resched_cpu().
  140  */
  141 #define RESCHED_REMOTE          0x01    /* request is for a remote CPU */
  142 #define RESCHED_IDLE            0x02    /* idle LWP observed */
  143 #define RESCHED_UPREEMPT        0x04    /* immediate user ctx switch */
  144 #define RESCHED_KPREEMPT        0x08    /* immediate kernel ctx switch */
  145 
  146 #endif  /* !_SYS_CPU_H_ */

Cache object: 55cfcfb696d33381de7e5e6cfc73bb3a


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.