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