25#define DPRINTF(format, args...) printf("SIO2MAN: (%s): " format, __FUNCTION__ , ## args)
27#define FLUSH_COUNT_MAX 4
31static int logging = 1;
32static int writesize = 0;
33static int flushcount = 0;
34static u8 log[10 * 1024];
37static const char *logfile =
"host0:sio2.log";
39static int log_init(
void)
43 if ((logfd = open(logfile, O_WRONLY | O_CREAT | O_TRUNC)) < 0)
50void log_default(
int type)
57void log_portdata(u32 *pd1, u32 *pd2)
63 log_default(LOG_TRS_PD);
65 for (i = 0; i < 4; i++) {
71void log_regdata(u32 *rd)
77 log_default(LOG_TRS_RD);
79 for (i = 0; i < 16; i++)
83void log_data(
int type, u8 *data, u32 size)
93 for (i = 0; (u32)i < size; i++)
102 if (!logging)
return;
106 log_write32((u32)arg->addr);
107 log_write32(arg->size);
108 log_write32(arg->count);
110 effective = arg->size * 4 * arg->count;
111 if (effective > DMA_MAX)
114 for (i = 0, p = (u8 *)arg->addr; i < effective; i++)
118void log_stat(u32 stat6c, u32 stat70, u32 stat74)
120 if (!logging)
return;
122 log_default(LOG_TRR_STAT);
124 log_write32(stat6c); log_write32(stat70); log_write32(stat74);
127void log_write8(u8 val)
129 if (!init && !log_init())
132 log[writesize++] = val;
135void log_write32(u32 val)
137 if (!init && !log_init())
140 log[writesize] = val & 0xff;
141 log[writesize + 1] = (val >> 8) & 0xff;
142 log[writesize + 2] = (val >> 16) & 0xff;
143 log[writesize + 3] = (val >> 24) & 0xff;
147void log_flush(
int now)
149 if (!init && !log_init())
152 if (!logging || logfd < 0)
return;
156 if (now || flushcount >= FLUSH_COUNT_MAX) {
157 write(logfd, log, writesize);
159 logfd = open(logfile, O_WRONLY | O_APPEND);
166 if (flushcount >= FLUSH_COUNT_MAX)