Skip to content

Commit 6ebd3eb

Browse files
bare-metal: Add uart0_puthex function
This is useful to print register values. Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
1 parent cb7c065 commit 6ebd3eb

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

bare-metal.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,24 @@ void uart0_puts(const char *s)
609609
}
610610
}
611611

612+
void uart0_puthex(unsigned long hex)
613+
{
614+
unsigned int chunks = sizeof(hex) * 2;
615+
unsigned int i;
616+
617+
uart0_puts("0x");
618+
619+
for (i = 0; i < chunks; i++) {
620+
unsigned int offset = (chunks - 1 - i) * 4;
621+
unsigned int extract = (hex & (0xf << offset)) >> offset;
622+
623+
if (extract >= 0xa)
624+
uart0_putc('a' + (extract - 0xa));
625+
else
626+
uart0_putc('0' + extract);
627+
}
628+
}
629+
612630
int get_boot_device(const struct soc_info *soc)
613631
{
614632
u32 *spl_signature = (void *)soc->sram.a1_base + 0x4;

bare-metal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ void jtag_init(const struct soc_info *soc);
223223
void uart0_init(const struct soc_info *soc);
224224
void uart0_putc(char c);
225225
void uart0_puts(const char *s);
226+
void uart0_puthex(unsigned long hex);
226227
int get_boot_device(const struct soc_info *soc);
227228

228229
#endif

0 commit comments

Comments
 (0)