log.c
777 Bytes
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
#include "rcp.h"
#include "log.h"
void LogEntry(unsigned int);
unsigned int *LogPtr;
void
LogInit()
{
LogPtr = (unsigned int *)LOG_ADDRESS;
/* Clear the log buffer */
while (LogPtr < (unsigned int *)MAX_LOG_ADDRESS) {
LogEntry(0);
}
LogEntry(0xffffffff);
LogEntry(0xffffffff);
LogEntry(0xffffffff);
LogEntry(0xffffffff);
LogPtr = (unsigned int *)LOG_ADDRESS;
}
void
LogEntry(unsigned int data)
{
volatile unsigned int stat;
if (LogPtr >= (unsigned int *)MAX_LOG_ADDRESS) {
LogPtr = (unsigned int *)LOG_ADDRESS;
}
/* Assume that log address is in RamRom space */
do {
stat = IO_READ(PI_STATUS_REG);
} while (stat & (PI_STATUS_DMA_BUSY|PI_STATUS_IO_BUSY));
*LogPtr++ = data;
}