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