os/kernel/debugging.c

32 lines
595 B
C

#include <kernel/tty.h>
#include <stdint.h>
#include <stdbool.h>
#include <strlib.h>
void print_hex_digit(uint8_t digit)
{
digit = digit & 0xf;
if (digit < 0xA) {
terminal_putchar(digit + 0x30);
} else {
terminal_putchar(digit + 0x41 - 0xA);
}
}
void print_hex_byte(uint8_t byte)
{
int upper = byte >> 4;
int lower = byte & 0x0F;
print_hex_digit(upper);
print_hex_digit(lower);
}
void print_hex_bytes(void* bytes, size_t len)
{
uint8_t* value = bytes;
for (size_t i = len; i > 0; i--) {
print_hex_byte(value[i - 1]);
}
}