-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutil.c
More file actions
58 lines (51 loc) · 1.05 KB
/
util.c
File metadata and controls
58 lines (51 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#define DANGER
#include "reg.h"
#include "util.h"
#define DUMPREG(X) {X ## _OFFSET, #X}
struct {
uint32_t offset;
const char *name;
} dump_regs[] = {
DUMPREG(CTRL),
DUMPREG(STATUS),
DUMPREG(RCTL),
DUMPREG(RDBAL),
DUMPREG(RDBAH),
DUMPREG(RDLEN),
DUMPREG(RDH),
DUMPREG(RDT),
DUMPREG(RDTR),
DUMPREG(RXDCTL),
DUMPREG(RAL),
DUMPREG(RAH),
DUMPREG(TCTL),
DUMPREG(TDBAL),
DUMPREG(TDBAH),
DUMPREG(TDLEN),
DUMPREG(TDH),
DUMPREG(TDT),
DUMPREG(TXDCTL),
DUMPREG(TIDV),
};
#undef DUMPREG
void dump_registers() {
for(size_t i=0; i<sizeof(dump_regs)/sizeof(dump_regs[0]); i++) {
uint32_t val;
val = read_reg(dump_regs[i].offset);
printf("%10s(%08x): %08x\n", dump_regs[i].name, dump_regs[i].offset, val);
}
}
void panic(const char *str) {
fprintf(stderr, "[ERROR]:%s\n", str);
exit(-1);
}
void print_log(const char *format, ...) {
va_list arg;
va_start(arg, format);
fprintf(stderr, "[LOG]:");
vfprintf(stderr, format, arg);
fprintf(stderr, "\n");
}