bare-metal: Add uart0_puthex function
Some checks failed
Build host tools / build (push) Has been cancelled

This is useful to print register values.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
This commit is contained in:
Paul Kocialkowski 2025-04-16 12:36:54 +02:00 committed by Andre Przywara
parent c507149dbf
commit 4f144b3344
2 changed files with 25 additions and 0 deletions

View File

@ -594,6 +594,29 @@ void uart0_puts(const char *s)
}
}
void uart0_puthex(unsigned long hex, bool new_line)
{
unsigned int chunks = sizeof(hex) * 2;
unsigned int i;
uart0_puts("0x");
for (i = 0; i < chunks; i++) {
unsigned int offset = (chunks - 1 - i) * 4;
unsigned int extract = (hex & (0xf << offset)) >> offset;
if (extract >= 0xa)
uart0_putc('a' + (extract - 0xa));
else
uart0_putc('0' + extract);
}
if (new_line) {
uart0_putc('\r');
uart0_putc('\n');
}
}
int get_boot_device(const struct soc_info *soc)
{
u32 *spl_signature = (void *)soc->sram.a1_base + 0x4;

View File

@ -56,6 +56,7 @@
typedef unsigned int u32;
typedef unsigned short int u16;
typedef unsigned char u8;
typedef int bool;
#ifndef NULL
#define NULL ((void*)0)
@ -219,6 +220,7 @@ void jtag_init(const struct soc_info *soc);
void uart0_init(const struct soc_info *soc);
void uart0_putc(char c);
void uart0_puts(const char *s);
void uart0_puthex(unsigned long hex, bool new_line);
int get_boot_device(const struct soc_info *soc);
#endif