signatures.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* SPDX-License-Identifier: Intel */
  2. /*
  3. * Copyright (C) 2013, Intel Corporation
  4. * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
  5. */
  6. #ifndef __SIGNATURES_H__
  7. #define __SIGNATURES_H__
  8. /**
  9. * Returns a 16-bit signature built from 2 ASCII characters.
  10. *
  11. * This macro returns a 16-bit value built from the two ASCII characters
  12. * specified by A and B.
  13. *
  14. * @A: The first ASCII character.
  15. * @B: The second ASCII character.
  16. *
  17. * @return: A 16-bit value built from the two ASCII characters specified by
  18. * A and B.
  19. */
  20. #define SIGNATURE_16(A, B) ((A) | (B << 8))
  21. /**
  22. * Returns a 32-bit signature built from 4 ASCII characters.
  23. *
  24. * This macro returns a 32-bit value built from the four ASCII characters
  25. * specified by A, B, C, and D.
  26. *
  27. * @A: The first ASCII character.
  28. * @B: The second ASCII character.
  29. * @C: The third ASCII character.
  30. * @D: The fourth ASCII character.
  31. *
  32. * @return: A 32-bit value built from the two ASCII characters specified by
  33. * A, B, C and D.
  34. */
  35. #define SIGNATURE_32(A, B, C, D) \
  36. (SIGNATURE_16(A, B) | (SIGNATURE_16(C, D) << 16))
  37. /**
  38. * Returns a 64-bit signature built from 8 ASCII characters.
  39. *
  40. * This macro returns a 64-bit value built from the eight ASCII characters
  41. * specified by A, B, C, D, E, F, G,and H.
  42. *
  43. * @A: The first ASCII character.
  44. * @B: The second ASCII character.
  45. * @C: The third ASCII character.
  46. * @D: The fourth ASCII character.
  47. * @E: The fifth ASCII character.
  48. * @F: The sixth ASCII character.
  49. * @G: The seventh ASCII character.
  50. * @H: The eighth ASCII character.
  51. *
  52. * @return: A 64-bit value built from the two ASCII characters specified by
  53. * A, B, C, D, E, F, G and H.
  54. */
  55. #define SIGNATURE_64(A, B, C, D, E, F, G, H) \
  56. (SIGNATURE_32(A, B, C, D) | ((u64)(SIGNATURE_32(E, F, G, H)) << 32))
  57. #endif /* __SIGNATURES_H__ */