Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * This file is subject to the terms and conditions of the GNU General Public
0003  * License.  See the file "COPYING" in the main directory of this archive
0004  * for more details.
0005  *
0006  * Copyright (c) 2016  Cavium Inc. (support@cavium.com).
0007  *
0008  */
0009 
0010 /*
0011  * Module to support operations on bitmap of cores. Coremask can be used to
0012  * select a specific core, a group of cores, or all available cores, for
0013  * initialization and differentiation of roles within a single shared binary
0014  * executable image.
0015  *
0016  * The core numbers used in this file are the same value as what is found in
0017  * the COP0_EBASE register and the rdhwr 0 instruction.
0018  *
0019  * For the CN78XX and other multi-node environments the core numbers are not
0020  * contiguous.  The core numbers for the CN78XX are as follows:
0021  *
0022  * Node 0:  Cores 0 - 47
0023  * Node 1:  Cores 128 - 175
0024  * Node 2:  Cores 256 - 303
0025  * Node 3:  Cores 384 - 431
0026  *
0027  */
0028 
0029 #ifndef __CVMX_COREMASK_H__
0030 #define __CVMX_COREMASK_H__
0031 
0032 #define CVMX_MIPS_MAX_CORES 1024
0033 /* bits per holder */
0034 #define CVMX_COREMASK_ELTSZ 64
0035 
0036 /* cvmx_coremask_t's size in u64 */
0037 #define CVMX_COREMASK_BMPSZ (CVMX_MIPS_MAX_CORES / CVMX_COREMASK_ELTSZ)
0038 
0039 
0040 /* cvmx_coremask_t */
0041 struct cvmx_coremask {
0042     u64 coremask_bitmap[CVMX_COREMASK_BMPSZ];
0043 };
0044 
0045 /*
0046  * Is ``core'' set in the coremask?
0047  */
0048 static inline bool cvmx_coremask_is_core_set(const struct cvmx_coremask *pcm,
0049                         int core)
0050 {
0051     int n, i;
0052 
0053     n = core % CVMX_COREMASK_ELTSZ;
0054     i = core / CVMX_COREMASK_ELTSZ;
0055 
0056     return (pcm->coremask_bitmap[i] & ((u64)1 << n)) != 0;
0057 }
0058 
0059 /*
0060  * Make a copy of a coremask
0061  */
0062 static inline void cvmx_coremask_copy(struct cvmx_coremask *dest,
0063                       const struct cvmx_coremask *src)
0064 {
0065     memcpy(dest, src, sizeof(*dest));
0066 }
0067 
0068 /*
0069  * Set the lower 64-bit of the coremask.
0070  */
0071 static inline void cvmx_coremask_set64(struct cvmx_coremask *pcm,
0072                        uint64_t coremask_64)
0073 {
0074     pcm->coremask_bitmap[0] = coremask_64;
0075 }
0076 
0077 /*
0078  * Clear ``core'' from the coremask.
0079  */
0080 static inline void cvmx_coremask_clear_core(struct cvmx_coremask *pcm, int core)
0081 {
0082     int n, i;
0083 
0084     n = core % CVMX_COREMASK_ELTSZ;
0085     i = core / CVMX_COREMASK_ELTSZ;
0086     pcm->coremask_bitmap[i] &= ~(1ull << n);
0087 }
0088 
0089 #endif /* __CVMX_COREMASK_H__ */