bare-metal: Add uart0_puthex function
Some checks failed
Build host tools / build (push) Has been cancelled
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:
parent
c507149dbf
commit
4f144b3344
23
bare-metal.c
23
bare-metal.c
@ -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)
|
int get_boot_device(const struct soc_info *soc)
|
||||||
{
|
{
|
||||||
u32 *spl_signature = (void *)soc->sram.a1_base + 0x4;
|
u32 *spl_signature = (void *)soc->sram.a1_base + 0x4;
|
||||||
|
|||||||
@ -56,6 +56,7 @@
|
|||||||
typedef unsigned int u32;
|
typedef unsigned int u32;
|
||||||
typedef unsigned short int u16;
|
typedef unsigned short int u16;
|
||||||
typedef unsigned char u8;
|
typedef unsigned char u8;
|
||||||
|
typedef int bool;
|
||||||
|
|
||||||
#ifndef NULL
|
#ifndef NULL
|
||||||
#define NULL ((void*)0)
|
#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_init(const struct soc_info *soc);
|
||||||
void uart0_putc(char c);
|
void uart0_putc(char c);
|
||||||
void uart0_puts(const char *s);
|
void uart0_puts(const char *s);
|
||||||
|
void uart0_puthex(unsigned long hex, bool new_line);
|
||||||
int get_boot_device(const struct soc_info *soc);
|
int get_boot_device(const struct soc_info *soc);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user