display_options.h 3.1 KB

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