Util.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /****************************************************************
  2. ****************************************************************
  3. ** **
  4. ** (C)Copyright 2005-2006, American Megatrends Inc. **
  5. ** **
  6. ** All Rights Reserved. **
  7. ** **
  8. ** 6145-F, Northbelt Parkway, Norcross, **
  9. ** **
  10. ** Georgia - 30071, USA. Phone-(770)-246-8600. **
  11. ** **
  12. ****************************************************************
  13. ****************************************************************/
  14. /*****************************************************************
  15. *
  16. * util.h
  17. * Utility functions.
  18. *
  19. * Author: Govind Kothandapani <govindk@ami.com>
  20. *
  21. *****************************************************************/
  22. #ifndef UTIL_H
  23. #define UTIL_H
  24. #include "com_IPMIDefs.h"
  25. #include <stdio.h>
  26. /**
  27. * Returns the maximum of two values
  28. **/
  29. #define UTIL_MAX(val1, val2) \
  30. ((val1 > val2) ? val1 : val2)
  31. /**
  32. * Returns the minimum of two values
  33. **/
  34. #define UTIL_MIN(val1, val2) \
  35. ((val1 < val2) ? val1 : val2)
  36. /**
  37. * @brief Extracts the contents of the bits corresponding to the mask.
  38. **/
  39. uint8_t GetBits (uint8_t Val, uint8_t Mask);
  40. /**
  41. * @brief Sets the bits corresponding to the mask according to the value.
  42. **/
  43. uint8_t SetBits (uint8_t Mask, uint8_t Val);
  44. /**
  45. * @brief Find the checksum
  46. **/
  47. uint8_t CalculateCheckSum (uint8_t* Data, uint16_t Len);
  48. // *
  49. // *@ brief Retrieves the value from sysctl
  50. // int GetJiffySysCtlvalue (const char *TagName, long long *SysVal);
  51. /*
  52. index = 0,1,2,3,4,5
  53. */
  54. uint8_t mac2hex(const char *strMac, uint8_t index);
  55. /*
  56. index = 0,1,2,3
  57. */
  58. uint8_t ip2dec(const char *strIp, uint8_t index);
  59. #endif /* UTIL_H */