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