xref: /freebsd/sys/powerpc/include/runq.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
160727d8bSWarner Losh /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
371e3c308SPedro F. Giffuni  *
4d2ac2316SJake Burkholder  * Copyright (c) 2001 Jake Burkholder <jake@FreeBSD.org>
5d2ac2316SJake Burkholder  * All rights reserved.
6d2ac2316SJake Burkholder  *
7d2ac2316SJake Burkholder  * Redistribution and use in source and binary forms, with or without
8d2ac2316SJake Burkholder  * modification, are permitted provided that the following conditions
9d2ac2316SJake Burkholder  * are met:
10d2ac2316SJake Burkholder  * 1. Redistributions of source code must retain the above copyright
11d2ac2316SJake Burkholder  *    notice, this list of conditions and the following disclaimer.
12d2ac2316SJake Burkholder  * 2. Redistributions in binary form must reproduce the above copyright
13d2ac2316SJake Burkholder  *    notice, this list of conditions and the following disclaimer in the
14d2ac2316SJake Burkholder  *    documentation and/or other materials provided with the distribution.
15d2ac2316SJake Burkholder  *
16d2ac2316SJake Burkholder  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17d2ac2316SJake Burkholder  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18d2ac2316SJake Burkholder  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19d2ac2316SJake Burkholder  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20d2ac2316SJake Burkholder  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21d2ac2316SJake Burkholder  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22d2ac2316SJake Burkholder  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23d2ac2316SJake Burkholder  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24d2ac2316SJake Burkholder  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25d2ac2316SJake Burkholder  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26d2ac2316SJake Burkholder  * SUCH DAMAGE.
27d2ac2316SJake Burkholder  */
28d2ac2316SJake Burkholder 
29d2ac2316SJake Burkholder #ifndef	_MACHINE_RUNQ_H_
30d2ac2316SJake Burkholder #define	_MACHINE_RUNQ_H_
31d2ac2316SJake Burkholder 
32c3e289e1SNathan Whitehorn #ifdef __powerpc64__
33c3e289e1SNathan Whitehorn #define	RQB_LEN		(1UL)		/* Number of priority status words. */
34c3e289e1SNathan Whitehorn #define	RQB_L2BPW	(6UL)		/* Log2(sizeof(rqb_word_t) * NBBY)). */
35c3e289e1SNathan Whitehorn #else
36d2ac2316SJake Burkholder #define	RQB_LEN		(2)		/* Number of priority status words. */
37d2ac2316SJake Burkholder #define	RQB_L2BPW	(5)		/* Log2(sizeof(rqb_word_t) * NBBY)). */
38c3e289e1SNathan Whitehorn #endif
39c3e289e1SNathan Whitehorn #define	RQB_BPW		(1UL<<RQB_L2BPW) /* Bits in an rqb_word_t. */
40d2ac2316SJake Burkholder 
41c3e289e1SNathan Whitehorn #define	RQB_BIT(pri)	(1UL << ((pri) & (RQB_BPW - 1)))
42d2ac2316SJake Burkholder #define	RQB_WORD(pri)	((pri) >> RQB_L2BPW)
43d2ac2316SJake Burkholder 
44c3e289e1SNathan Whitehorn #define	RQB_FFS(word)	(ffsl(word) - 1)
45d2ac2316SJake Burkholder 
46d2ac2316SJake Burkholder /*
47d2ac2316SJake Burkholder  * Type of run queue status word.
48d2ac2316SJake Burkholder  */
49c3e289e1SNathan Whitehorn #ifdef __powerpc64__
50c3e289e1SNathan Whitehorn typedef	u_int64_t	rqb_word_t;
51c3e289e1SNathan Whitehorn #else
52d2ac2316SJake Burkholder typedef	u_int32_t	rqb_word_t;
53c3e289e1SNathan Whitehorn #endif
54d2ac2316SJake Burkholder 
55d2ac2316SJake Burkholder #endif
56