display_options.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (c) 2015 Google, Inc
  4. *
  5. * (C) Copyright 2000-2002
  6. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  7. */
  8. #ifndef __DISPLAY_OPTIONS_H
  9. #define __DISPLAY_OPTIONS_H
  10. /**
  11. * print_size() - Print a size with a suffix
  12. *
  13. * Print sizes as "xxx KiB", "xxx.y KiB", "xxx MiB", "xxx.y MiB",
  14. * xxx GiB, xxx.y GiB, etc as needed; allow for optional trailing string
  15. * (like "\n")
  16. *
  17. * @size: Size to print
  18. * @suffix String to print after the size
  19. */
  20. void print_size(uint64_t size, const char *suffix);
  21. /**
  22. * print_freq() - Print a frequency with a suffix
  23. *
  24. * Print frequencies as "x.xx GHz", "xxx kHz", etc as needed; allow for
  25. * optional trailing string (like "\n")
  26. *
  27. * @freq: Frequency to print in Hz
  28. * @suffix String to print after the frequency
  29. */
  30. void print_freq(uint64_t freq, const char *suffix);
  31. /**
  32. * print_buffer() - Print data buffer in hex and ascii form
  33. *
  34. * Data reads are buffered so that each memory address is only read once.
  35. * This is useful when displaying the contents of volatile registers.
  36. *
  37. * @addr: Starting address to display at start of line
  38. * @data: pointer to data buffer
  39. * @width: data value width. May be 1, 2, or 4.
  40. * @count: number of values to display
  41. * @linelen: Number of values to print per line; specify 0 for default length
  42. */
  43. int print_buffer(ulong addr, const void *data, uint width, uint count,
  44. uint linelen);
  45. /*
  46. * Maximum length of an output line is when width == 1
  47. * 9 for address,
  48. * a space, two hex digits and an ASCII character for each byte
  49. * 2 spaces between the hex and ASCII
  50. * \0 terminator
  51. */
  52. #define HEXDUMP_MAX_BUF_LENGTH(bytes) (9 + (bytes) * 4 + 3)
  53. /**
  54. * hexdump_line() - Print out a single line of a hex dump
  55. *
  56. * @addr: Starting address to display at start of line
  57. * @data: pointer to data buffer
  58. * @width: data value width. May be 1, 2, or 4.
  59. * @count: number of values to display
  60. * @linelen: Number of values to print per line; specify 0 for default length
  61. * @out: Output buffer to hold the dump
  62. * @size: Size of output buffer in bytes
  63. * @return number of bytes processed, if OK, -ENOSPC if buffer too small
  64. *
  65. */
  66. int hexdump_line(ulong addr, const void *data, uint width, uint count,
  67. uint linelen, char *out, int size);
  68. /**
  69. * display_options() - display the version string / build tag
  70. *
  71. * This displays the U-Boot version string. If a build tag is available this
  72. * is displayed also.
  73. */
  74. int display_options(void);
  75. /* Suggested length of the buffer to pass to display_options_get_banner() */
  76. #define DISPLAY_OPTIONS_BANNER_LENGTH 200
  77. /**
  78. * display_options_get_banner() - Get the U-Boot banner as a string
  79. *
  80. * This returns the U-Boot banner string
  81. *
  82. * @newlines: true to include two newlines at the start
  83. * @buf: place to put string
  84. * @size: Size of buf (string is truncated to fit)
  85. * @return buf
  86. */
  87. char *display_options_get_banner(bool newlines, char *buf, int size);
  88. /* This function is used for testing only */
  89. char *display_options_get_banner_priv(bool newlines, const char *build_tag,
  90. char *buf, int size);
  91. #endif