log.c 777 Bytes

#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;
}