Make setthetime() static per the prototype.
[dragonfly.git] / lib / libcaps / globaldata.h
1 /*
2  * GLOBALDATA.H
3  */
4 /*
5  * Copyright (c) 2003 Matthew Dillon <dillon@backplane.com>
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * $DragonFly: src/lib/libcaps/globaldata.h,v 1.8 2004/04/24 09:26:25 joerg Exp $
30  */
31
32 #ifndef _LIBCAPS_GLOBALDATA_H_
33 #define _LIBCAPS_GLOBALDATA_H_
34
35 #ifndef _LIBCAPS_THREAD_H_
36 #include "thread.h"
37 #endif
38 #ifndef _SYS_THREAD_H_
39 #include <sys/thread.h>
40 #endif
41 #ifndef _SYS_UPCALL_H_
42 #include <sys/upcall.h>
43 #endif
44 #ifndef _LIBCAPS_SLABALLOC_H_
45 #include "slaballoc.h"
46 #endif
47 #ifndef _ASSERT_H_
48 #include <assert.h>
49 #endif
50 #ifndef _SYS_QUEUE_H_
51 #include <sys/queue.h>
52 #endif
53 #ifndef _MACHINE_LOCK_H_
54 #include <machine/lock.h>
55 #endif
56
57 struct globaldata;
58 typedef struct globaldata *globaldata_t;
59
60 #include "md_globaldata.h"
61
62 extern int smp_active;
63 extern int ncpus;
64 extern int hz;
65 extern u_int32_t stopped_cpus;
66 extern char *panicstr;
67
68 struct globaldata {
69         struct globaldata *gd_self;             /* self pointer */
70         struct upcall   gd_upcall;              /* upcall for this cpu */
71         int             gd_upcid;               /* upcall id */
72         int             gd_pid;                 /* user pid for rfork'd cpu */
73         int             gd_tdfreecount;
74         TAILQ_HEAD(,thread) gd_tdallq;          /* all threads */
75         TAILQ_HEAD(,thread) gd_tdfreeq;         /* new thread cache */
76         TAILQ_HEAD(,thread) gd_tdrunq[32];      /* runnable threads */
77         __uint32_t      gd_runqmask;            /* which queues? */
78         __uint32_t      gd_cpuid;
79         cpumask_t       gd_cpumask;             /* mask = 1<<cpuid */
80         cpumask_t       gd_other_cpus;
81         int             gd_intr_nesting_level;
82         struct thread   gd_idlethread;
83         SLGlobalData    gd_slab;                /* slab allocator */
84         int             gd_num_threads;         /* Number of threads */
85         int             gd_sys_threads;         /* Number of threads */
86         struct lwkt_ipiq *gd_ipiq;
87         lwkt_tokref_t   gd_tokreqbase;          /* requests from other cpus */
88         struct lwkt_ipiq gd_cpusyncq;           /* ipiq for cpu synchro */
89 };
90
91 #define gd_reqflags     gd_upcall.upc_pending
92 #define gd_curthread    gd_upcall.upc_uthread
93
94 #define RQB_IPIQ       0
95 #define RQB_INTPEND    1
96 #define RQB_AST_OWEUPC 2
97 #define RQB_AST_SIGNAL 3
98 #define RQB_AST_RESCHED        4
99 #define RQB_AST_UPCALL 5
100
101
102 #define RQF_IPIQ       (1 << RQB_IPIQ)
103 #define RQF_INTPEND    (1 << RQB_INTPEND)
104 #define RQF_AST_OWEUPC (1 << RQB_AST_OWEUPC)
105 #define RQF_AST_SIGNAL (1 << RQB_AST_SIGNAL)
106 #define RQF_AST_RESCHED        (1 << RQB_AST_RESCHED)
107 #define RQF_AST_UPCALL (1 << RQB_AST_UPCALL)
108 #define RQF_AST_MASK   (RQF_AST_OWEUPC|RQF_AST_SIGNAL|RQF_AST_RESCHED|\
109                         RQF_AST_UPCALL)
110
111 #define RQF_IDLECHECK_MASK     (RQF_IPIQ|RQF_INTPEND)
112
113 #define KASSERT(exp, printargs) \
114         do { if (!(exp)) { panic printargs; } } while(0)
115 #define KKASSERT(exp)   assert(exp)
116
117 #define MAXVCPU         32
118
119 #define curthread       (mycpu->gd_curthread)
120
121 extern cpumask_t smp_active_mask;
122
123 extern struct globaldata *globaldata_find(int cpu);
124
125 void globaldata_init(struct thread *td);
126 void splz(void);
127 int need_lwkt_resched(void);
128 void cpu_halt(void);
129 void cpu_send_ipiq(int dcpu);
130 void mi_gdinit1(globaldata_t gd, int cpuid);
131 void mi_gdinit2(globaldata_t gd);
132 __dead2 void panic(const char *, ...);
133
134 #endif