mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-01-01 10:56:27 -05:00
fw/testfw: Simplify hexdump
This commit is contained in:
parent
7ce1d9fe06
commit
8665031bb4
@ -71,21 +71,22 @@ void puthexn(uint8_t *p, int n)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void hexdump(uint8_t *buf, int len)
|
void hexdump(void *buf, int len)
|
||||||
{
|
{
|
||||||
uint8_t *row;
|
uint8_t *byte_buf = (uint8_t *)buf;
|
||||||
uint8_t *byte;
|
|
||||||
uint8_t *max;
|
|
||||||
|
|
||||||
row = buf;
|
for (int i = 0; i < len; i ++) {
|
||||||
max = &buf[len];
|
puthex(byte_buf[i]);
|
||||||
for (byte = 0; byte != max; row = byte) {
|
if (i % 2 == 1) {
|
||||||
for (byte = row; byte != max && byte != (row + 16); byte++) {
|
writebyte(' ');
|
||||||
puthex(*byte);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
puts("\r\n");
|
if (i != 1 && i % 16 == 1) {
|
||||||
|
puts("\r\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
puts("\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void reverseword(uint32_t *wordp)
|
void reverseword(uint32_t *wordp)
|
||||||
|
@ -30,8 +30,10 @@ static void htif_set_tohost(uint8_t dev, uint8_t cmd, int64_t data)
|
|||||||
{
|
{
|
||||||
/* send data with specified device and command */
|
/* send data with specified device and command */
|
||||||
while (tohost.arr[0]) {
|
while (tohost.arr[0]) {
|
||||||
|
#ifndef S_SPLINT_S
|
||||||
asm volatile("" : : "r"(fromhost.arr[0]));
|
asm volatile("" : : "r"(fromhost.arr[0]));
|
||||||
asm volatile("" : : "r"(fromhost.arr[1]));
|
asm volatile("" : : "r"(fromhost.arr[1]));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
htif_send(dev, cmd, data);
|
htif_send(dev, cmd, data);
|
||||||
}
|
}
|
||||||
@ -49,21 +51,22 @@ int htif_puts(const char *s)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void htif_hexdump(uint8_t *buf, int len)
|
void htif_hexdump(void *buf, int len)
|
||||||
{
|
{
|
||||||
uint8_t *row;
|
uint8_t *byte_buf = (uint8_t *)buf;
|
||||||
uint8_t *byte;
|
|
||||||
uint8_t *max;
|
|
||||||
|
|
||||||
row = buf;
|
for (int i = 0; i < len; i++) {
|
||||||
max = &buf[len];
|
htif_puthex(byte_buf[i]);
|
||||||
for (byte = 0; byte != max; row = byte) {
|
if (i % 2 == 1) {
|
||||||
for (byte = row; byte != max && byte != (row + 16); byte++) {
|
(void)htif_putchar(' ');
|
||||||
htif_puthex(*byte);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
htif_lf();
|
if (i != 1 && i % 16 == 1) {
|
||||||
|
htif_lf();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
htif_lf();
|
||||||
}
|
}
|
||||||
|
|
||||||
void htif_putc(int ch)
|
void htif_putc(int ch)
|
||||||
|
@ -21,7 +21,7 @@ void htif_lf();
|
|||||||
void htif_puthex(uint8_t c);
|
void htif_puthex(uint8_t c);
|
||||||
void htif_putinthex(const uint32_t n);
|
void htif_putinthex(const uint32_t n);
|
||||||
int htif_puts(const char *s);
|
int htif_puts(const char *s);
|
||||||
void htif_hexdump(uint8_t *buf, int len);
|
void htif_hexdump(void *buf, int len);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void *memset(void *dest, int c, unsigned n);
|
void *memset(void *dest, int c, unsigned n);
|
||||||
|
Loading…
Reference in New Issue
Block a user