sbi_const.h 980 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * SPDX-License-Identifier: BSD-2-Clause
  3. *
  4. * Copyright (c) 2019 Western Digital Corporation or its affiliates.
  5. *
  6. * Authors:
  7. * Anup Patel <anup.patel@wdc.com>
  8. */
  9. #ifndef __SBI_CONST_H__
  10. #define __SBI_CONST_H__
  11. /*
  12. * Some constant macros are used in both assembler and
  13. * C code. Therefore we cannot annotate them always with
  14. * 'UL' and other type specifiers unilaterally. We
  15. * use the following macros to deal with this.
  16. *
  17. * Similarly, _AT() will cast an expression with a type in C, but
  18. * leave it unchanged in asm.
  19. */
  20. /* clang-format off */
  21. #ifdef __ASSEMBLER__
  22. #define _AC(X,Y) X
  23. #define _AT(T,X) X
  24. #else
  25. #define __AC(X,Y) (X##Y)
  26. #define _AC(X,Y) __AC(X,Y)
  27. #define _AT(T,X) ((T)(X))
  28. #endif
  29. #define _UL(x) (_AC(x, UL))
  30. #define _ULL(x) (_AC(x, ULL))
  31. #define _BITUL(x) (_UL(1) << (x))
  32. #define _BITULL(x) (_ULL(1) << (x))
  33. #define UL(x) (_UL(x))
  34. #define ULL(x) (_ULL(x))
  35. #define __STR(s) #s
  36. #define STRINGIFY(s) __STR(s)
  37. /* clang-format on */
  38. #endif