Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions libmicrokit/include/microkit.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,21 @@ void microkit_dbg_put8(seL4_Uint8 x);
*/
void microkit_dbg_put32(seL4_Uint32 x);

/*
* Output the decimal representation of an 64-bit integer to the debug console.
*/
void microkit_dbg_put64(seL4_Uint64 x);

/*
* Output the hexadecimal representation of an 32-bit integer to the debug console.
*/
void microkit_dbg_puthex32(seL4_Uint32 x);

/*
* Output the hexadecimal representation of an 64-bit integer to the debug console.
*/
void microkit_dbg_puthex64(seL4_Uint64 x);

static inline void microkit_internal_crash(seL4_Error err)
{
/*
Expand Down
44 changes: 44 additions & 0 deletions libmicrokit/src/dbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,50 @@ void microkit_dbg_put32(seL4_Uint32 x)
microkit_dbg_puts(&tmp[i]);
}

void microkit_dbg_put64(seL4_Uint64 x)
{
char tmp[21];
unsigned i = 20;
tmp[20] = 0;
do {
seL4_Uint8 c = x % 10;
tmp[--i] = '0' + c;
x /= 10;
} while (x);
microkit_dbg_puts(&tmp[i]);
}

static char hexchar(unsigned int v)
{
return v < 10 ? '0' + v : ('a' - 10) + v;
}

void microkit_dbg_puthex32(seL4_Uint32 val)
{
char buffer[8 + 3];
buffer[0] = '0';
buffer[1] = 'x';
buffer[8 + 3 - 1] = 0;
for (unsigned i = 8 + 1; i > 1; i--) {
buffer[i] = hexchar(val & 0xf);
val >>= 4;
}
microkit_dbg_puts(buffer);
}

void microkit_dbg_puthex64(seL4_Uint64 val)
{
char buffer[16 + 3];
buffer[0] = '0';
buffer[1] = 'x';
buffer[16 + 3 - 1] = 0;
for (unsigned i = 16 + 1; i > 1; i--) {
buffer[i] = hexchar(val & 0xf);
val >>= 4;
}
microkit_dbg_puts(buffer);
}

/*
* We have to provide an implementation for libsel4 debug asserts, make it
* weak so users can override with their own libc etc.
Expand Down
Loading