Line 241... |
Line 241... |
}
|
}
|
}
|
}
|
|
|
static void send_char (int uart, int bits_send)
|
static void send_char (int uart, int bits_send)
|
{
|
{
|
printf ("'%c'\n", uarts[uart].iregs.txser);
|
PRINTF ("'%c'\n", uarts[uart].iregs.txser);
|
debug(4, "TX \'%c\' via UART%d...\n", uarts[uart].iregs.txser, uart);
|
debug(4, "TX \'%c\' via UART%d...\n", uarts[uart].iregs.txser, uart);
|
if (uarts[uart].regs.mcr & UART_MCR_LOOP)
|
if (uarts[uart].regs.mcr & UART_MCR_LOOP)
|
uarts[uart].iregs.loopback = uarts[uart].iregs.txser;
|
uarts[uart].iregs.loopback = uarts[uart].iregs.txser;
|
else {
|
else {
|
/* Send to either VAPI or to file */
|
/* Send to either VAPI or to file */
|
Line 302... |
Line 302... |
if (uarts[uart].vapi.lcr & UART_LCR_STOP)
|
if (uarts[uart].vapi.lcr & UART_LCR_STOP)
|
fe |= ((packet >> (nbits++)) & 1) ^ 1;
|
fe |= ((packet >> (nbits++)) & 1) ^ 1;
|
|
|
debug (4, "lcr vapi %02x, uart %02x\n", uarts[uart].vapi.lcr, uarts[uart].regs.lcr);
|
debug (4, "lcr vapi %02x, uart %02x\n", uarts[uart].vapi.lcr, uarts[uart].regs.lcr);
|
data |= (uarts[uart].vapi.lcr << 8) | (pe << 16) | (fe << 17) | (uarts[uart].vapi.lcr << 8);
|
data |= (uarts[uart].vapi.lcr << 8) | (pe << 16) | (fe << 17) | (uarts[uart].vapi.lcr << 8);
|
printf ("vapi_send (%08x, %08x)\n", config.uarts[uart].vapi_id, data);
|
PRINTF ("vapi_send (%08x, %08x)\n", config.uarts[uart].vapi_id, data);
|
debug (4, "vapi_send (%08x, %08x)\n", config.uarts[uart].vapi_id, data);
|
debug (4, "vapi_send (%08x, %08x)\n", config.uarts[uart].vapi_id, data);
|
vapi_send (config.uarts[uart].vapi_id, data);
|
vapi_send (config.uarts[uart].vapi_id, data);
|
} else {
|
} else {
|
fputc((int)(uarts[uart].iregs.txser & 0xFF), uarts[uart].txfs);
|
fputc((int)(uarts[uart].iregs.txser & 0xFF), uarts[uart].txfs);
|
fflush(uarts[uart].txfs);
|
fflush(uarts[uart].txfs);
|
Line 398... |
Line 398... |
if (uarts[i].vapi.cur_break_cnt > UART_BREAK_COUNT * uarts[i].vapi.char_clks) {
|
if (uarts[i].vapi.cur_break_cnt > UART_BREAK_COUNT * uarts[i].vapi.char_clks) {
|
if (!uarts[i].istat.break_set) {
|
if (!uarts[i].istat.break_set) {
|
unsigned lsr;
|
unsigned lsr;
|
uarts[i].istat.break_set = 1;
|
uarts[i].istat.break_set = 1;
|
lsr = UART_LSR_BREAK | UART_LSR_RXERR | UART_LSR_RDRDY;
|
lsr = UART_LSR_BREAK | UART_LSR_RXERR | UART_LSR_RDRDY;
|
printf ("[%x]\n", uarts[i].regs.lsr);
|
PRINTF ("[%x]\n", uarts[i].regs.lsr);
|
uarts[i].istat.rxser_full = 0;
|
uarts[i].istat.rxser_full = 0;
|
uarts[i].istat.rxser_clks = 0;
|
uarts[i].istat.rxser_clks = 0;
|
uart_add_char (i, lsr << 8);
|
uart_add_char (i, lsr << 8);
|
} else
|
} else
|
uarts[i].vapi.cur_break_cnt = 0;
|
uarts[i].vapi.cur_break_cnt = 0;
|
Line 553... |
Line 553... |
(re)opens all RX/TX file streams and places devices in memory address
|
(re)opens all RX/TX file streams and places devices in memory address
|
space. */
|
space. */
|
void uart_reset()
|
void uart_reset()
|
{
|
{
|
int i;
|
int i;
|
if (config.sim.verbose && config.nuarts) printf("Resetting %u UART(s).\n", config.nuarts);
|
if (config.sim.verbose && config.nuarts) PRINTF("Resetting %u UART(s).\n", config.nuarts);
|
memset(uarts, 0, sizeof(uarts));
|
memset(uarts, 0, sizeof(uarts));
|
|
|
for(i = 0; i < config.nuarts; i++) {
|
for(i = 0; i < config.nuarts; i++) {
|
if (config.uarts[i].vapi_id) {
|
if (config.uarts[i].vapi_id) {
|
if ((config.uarts[i].vapi_id & VAPI_DEVICE_ID) != i) {
|
if ((config.uarts[i].vapi_id & VAPI_DEVICE_ID) != i) {
|
Line 574... |
Line 574... |
debug (0, "WARNING: UART%d has problems with RX file stream.\n", i);
|
debug (0, "WARNING: UART%d has problems with RX file stream.\n", i);
|
continue;
|
continue;
|
}
|
}
|
uarts[i].txfs = fopen(config.uarts[i].txfile, "a");
|
uarts[i].txfs = fopen(config.uarts[i].txfile, "a");
|
if (uarts[i].rxfs && uarts[i].txfs && config.sim.verbose) {
|
if (uarts[i].rxfs && uarts[i].txfs && config.sim.verbose) {
|
printf("UART%d at 0x%.8x uses ", i, config.uarts[i].baseaddr);
|
PRINTF("UART%d at 0x%.8x uses ", i, config.uarts[i].baseaddr);
|
printf("%s for RX and %s for TX.\n", config.uarts[i].rxfile, config.uarts[i].txfile);
|
PRINTF("%s for RX and %s for TX.\n", config.uarts[i].rxfile, config.uarts[i].txfile);
|
} else
|
} else
|
debug (1, "WARNING: UART%d has problems with TX file stream.\n", i);
|
debug (1, "WARNING: UART%d has problems with TX file stream.\n", i);
|
register_memoryarea(config.uarts[i].baseaddr, UART_ADDR_SPACE, 1, 0, uart_read_byte, uart_write_byte);
|
register_memoryarea(config.uarts[i].baseaddr, UART_ADDR_SPACE, 1, 0, uart_read_byte, uart_write_byte);
|
}
|
}
|
|
|
Line 597... |
Line 597... |
uarts[i].slowdown = UART_FGETC_SLOWDOWN;
|
uarts[i].slowdown = UART_FGETC_SLOWDOWN;
|
|
|
uarts[i].regs.lcr = UART_LCR_RESET;
|
uarts[i].regs.lcr = UART_LCR_RESET;
|
uarts[i].vapi.cur_break = uarts[i].vapi.cur_break_cnt = uarts[i].vapi.next_break = 0;
|
uarts[i].vapi.cur_break = uarts[i].vapi.cur_break_cnt = uarts[i].vapi.next_break = 0;
|
uarts[i].vapi.next_break_cnt = -1;
|
uarts[i].vapi.next_break_cnt = -1;
|
printf ("%i\n", i);
|
PRINTF ("%i\n", i);
|
SCHED_ADD (uart_clock16, i, runtime.sim.cycles + UART_CLOCK_DIVIDER);
|
SCHED_ADD (uart_clock16, i, runtime.sim.cycles + UART_CLOCK_DIVIDER);
|
}
|
}
|
}
|
}
|
|
|
/* Print register values on stdout. */
|
/* Print register values on stdout. */
|
Line 610... |
Line 610... |
int i, j;
|
int i, j;
|
|
|
for(i = 0; i < config.nuarts; i++) {
|
for(i = 0; i < config.nuarts; i++) {
|
if ( !config.uarts[i].baseaddr )
|
if ( !config.uarts[i].baseaddr )
|
continue;
|
continue;
|
printf("\nUART%d visible registers at 0x%.8x:\n", i, config.uarts[i].baseaddr);
|
PRINTF("\nUART%d visible registers at 0x%.8x:\n", i, config.uarts[i].baseaddr);
|
printf("RXBUF:");
|
PRINTF("RXBUF:");
|
for (j = uarts[i].istat.rxbuf_head; j != uarts[i].istat.rxbuf_tail; j = (j + 1) % uarts[i].fifo_len)
|
for (j = uarts[i].istat.rxbuf_head; j != uarts[i].istat.rxbuf_tail; j = (j + 1) % uarts[i].fifo_len)
|
printf (" %.2x", uarts[i].regs.rxbuf[j]);
|
PRINTF (" %.2x", uarts[i].regs.rxbuf[j]);
|
printf(" TXBUF: %.2x\n", uarts[i].regs.txbuf);
|
PRINTF(" TXBUF: %.2x\n", uarts[i].regs.txbuf);
|
printf("DLL : %.2x DLH : %.2x\n", uarts[i].regs.dll, uarts[i].regs.dlh);
|
PRINTF("DLL : %.2x DLH : %.2x\n", uarts[i].regs.dll, uarts[i].regs.dlh);
|
printf("IER : %.2x IIR : %.2x\n", uarts[i].regs.ier, uarts[i].regs.iir);
|
PRINTF("IER : %.2x IIR : %.2x\n", uarts[i].regs.ier, uarts[i].regs.iir);
|
printf("LCR : %.2x MCR : %.2x\n", uarts[i].regs.lcr, uarts[i].regs.mcr);
|
PRINTF("LCR : %.2x MCR : %.2x\n", uarts[i].regs.lcr, uarts[i].regs.mcr);
|
printf("LSR : %.2x MSR : %.2x\n", uarts[i].regs.lsr, uarts[i].regs.msr);
|
PRINTF("LSR : %.2x MSR : %.2x\n", uarts[i].regs.lsr, uarts[i].regs.msr);
|
printf("SCR : %.2x\n", uarts[i].regs.scr);
|
PRINTF("SCR : %.2x\n", uarts[i].regs.scr);
|
|
|
printf("\nInternal registers (sim debug):\n");
|
PRINTF("\nInternal registers (sim debug):\n");
|
printf("RXSER: %.2x TXSER: %.2x\n", uarts[i].iregs.rxser, uarts[i].iregs.txser);
|
PRINTF("RXSER: %.2x TXSER: %.2x\n", uarts[i].iregs.rxser, uarts[i].iregs.txser);
|
|
|
printf("\nInternal status (sim debug):\n");
|
PRINTF("\nInternal status (sim debug):\n");
|
printf("char_clks: %d\n", uarts[i].char_clks);
|
PRINTF("char_clks: %d\n", uarts[i].char_clks);
|
printf("rxser_clks: %d txser_clks: %d\n", uarts[i].istat.rxser_clks, uarts[i].istat.txser_clks);
|
PRINTF("rxser_clks: %d txser_clks: %d\n", uarts[i].istat.rxser_clks, uarts[i].istat.txser_clks);
|
printf("rxser: %d txser: %d\n", uarts[i].istat.rxser_full, uarts[i].istat.txser_full);
|
PRINTF("rxser: %d txser: %d\n", uarts[i].istat.rxser_full, uarts[i].istat.txser_full);
|
printf("rxbuf: %d txbuf: %d\n", uarts[i].istat.rxbuf_full, uarts[i].istat.txbuf_full);
|
PRINTF("rxbuf: %d txbuf: %d\n", uarts[i].istat.rxbuf_full, uarts[i].istat.txbuf_full);
|
printf("Using IRQ%i\n", config.uarts[i].irq);
|
PRINTF("Using IRQ%i\n", config.uarts[i].irq);
|
if (config.uarts[i].vapi_id)
|
if (config.uarts[i].vapi_id)
|
printf ("Connected to vapi ID=%x\n\n", config.uarts[i].vapi_id);
|
PRINTF ("Connected to vapi ID=%x\n\n", config.uarts[i].vapi_id);
|
else
|
else
|
printf("RX fs: %p TX fs: %p\n\n", uarts[i].rxfs, uarts[i].txfs);
|
PRINTF("RX fs: %p TX fs: %p\n\n", uarts[i].rxfs, uarts[i].txfs);
|
}
|
}
|
}
|
}
|
|
|
No newline at end of file
|
No newline at end of file
|