Konstantin Porotchkin | f69ec58 | 2018-06-07 18:31:14 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 Marvell International Ltd. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * https://spdx.org/licenses |
| 6 | */ |
| 7 | |
| 8 | #ifndef _MVEBU_H_ |
| 9 | #define _MVEBU_H_ |
| 10 | |
| 11 | /* Use this functions only when printf is allowed */ |
| 12 | #define debug_enter() VERBOSE("----> Enter %s\n", __func__) |
| 13 | #define debug_exit() VERBOSE("<---- Exit %s\n", __func__) |
| 14 | |
| 15 | /* Macro for testing alignment. Positive if number is NOT aligned */ |
| 16 | #define IS_NOT_ALIGN(number, align) ((number) & ((align) - 1)) |
| 17 | |
| 18 | /* Macro for alignment up. For example, ALIGN_UP(0x0330, 0x20) = 0x0340 */ |
| 19 | #define ALIGN_UP(number, align) (((number) & ((align) - 1)) ? \ |
| 20 | (((number) + (align)) & ~((align)-1)) : (number)) |
| 21 | |
| 22 | /* Macro for testing whether a number is a power of 2. Positive if so */ |
| 23 | #define IS_POWER_OF_2(number) ((number) != 0 && \ |
| 24 | (((number) & ((number) - 1)) == 0)) |
| 25 | |
| 26 | /* |
| 27 | * Macro for ronding up to next power of 2 |
| 28 | * it is done by count leading 0 (clz assembly opcode) and see msb set bit. |
| 29 | * then you can shift it left and get number which power of 2 |
| 30 | * Note: this Macro is for 32 bit number |
| 31 | */ |
| 32 | #define ROUND_UP_TO_POW_OF_2(number) (1 << \ |
| 33 | (32 - __builtin_clz((number) - 1))) |
| 34 | |
Konstantin Porotchkin | e7be6e2 | 2018-10-08 16:53:09 +0300 | [diff] [blame] | 35 | #define _1MB_ (1024ULL * 1024ULL) |
| 36 | #define _1GB_ (_1MB_ * 1024ULL) |
| 37 | #define _2GB_ (2 * _1GB_) |
Konstantin Porotchkin | f69ec58 | 2018-06-07 18:31:14 +0300 | [diff] [blame] | 38 | |
| 39 | #endif /* MVEBU_H */ |