2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (c) 2016 Cavium Inc. (support@cavium.com).
11 * Module to support operations on bitmap of cores. Coremask can be used to
12 * select a specific core, a group of cores, or all available cores, for
13 * initialization and differentiation of roles within a single shared binary
16 * The core numbers used in this file are the same value as what is found in
17 * the COP0_EBASE register and the rdhwr 0 instruction.
19 * For the CN78XX and other multi-node environments the core numbers are not
20 * contiguous. The core numbers for the CN78XX are as follows:
22 * Node 0: Cores 0 - 47
23 * Node 1: Cores 128 - 175
24 * Node 2: Cores 256 - 303
25 * Node 3: Cores 384 - 431
29 #ifndef __CVMX_COREMASK_H__
30 #define __CVMX_COREMASK_H__
32 #define CVMX_MIPS_MAX_CORES 1024
34 #define CVMX_COREMASK_ELTSZ 64
36 /* cvmx_coremask_t's size in u64 */
37 #define CVMX_COREMASK_BMPSZ (CVMX_MIPS_MAX_CORES / CVMX_COREMASK_ELTSZ)
41 struct cvmx_coremask
{
42 u64 coremask_bitmap
[CVMX_COREMASK_BMPSZ
];
46 * Is ``core'' set in the coremask?
48 static inline bool cvmx_coremask_is_core_set(const struct cvmx_coremask
*pcm
,
53 n
= core
% CVMX_COREMASK_ELTSZ
;
54 i
= core
/ CVMX_COREMASK_ELTSZ
;
56 return (pcm
->coremask_bitmap
[i
] & ((u64
)1 << n
)) != 0;
60 * Make a copy of a coremask
62 static inline void cvmx_coremask_copy(struct cvmx_coremask
*dest
,
63 const struct cvmx_coremask
*src
)
65 memcpy(dest
, src
, sizeof(*dest
));
69 * Set the lower 64-bit of the coremask.
71 static inline void cvmx_coremask_set64(struct cvmx_coremask
*pcm
,
74 pcm
->coremask_bitmap
[0] = coremask_64
;
78 * Clear ``core'' from the coremask.
80 static inline void cvmx_coremask_clear_core(struct cvmx_coremask
*pcm
, int core
)
84 n
= core
% CVMX_COREMASK_ELTSZ
;
85 i
= core
/ CVMX_COREMASK_ELTSZ
;
86 pcm
->coremask_bitmap
[i
] &= ~(1ull << n
);
89 #endif /* __CVMX_COREMASK_H__ */