OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_67/] [or1ksim/] [peripheral/] [16450.c] - Diff between revs 252 and 261

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 252 Rev 261
Line 193... Line 193...
        int i;
        int i;
 
 
        printf("Resetting %u UART(s).\n", NR_UARTS);
        printf("Resetting %u UART(s).\n", NR_UARTS);
        memset(uarts, 0, sizeof(uarts));
        memset(uarts, 0, sizeof(uarts));
 
 
        for(i = 0; i < NR_UARTS; i++)
  if (!config.uarts_enabled)
 
    config.nuarts = 0;
 
 
 
        for(i = 0; i < config.nuarts; i++)
                if (config.uarts[i].txfile) { /* MM: Try to create stream.  */
                if (config.uarts[i].txfile) { /* MM: Try to create stream.  */
                        if (!(uarts[i].rxfs = fopen(config.uarts[i].rxfile, "r"))
                        if (!(uarts[i].rxfs = fopen(config.uarts[i].rxfile, "r"))
                                && !(uarts[i].rxfs = fopen(config.uarts[i].rxfile, "r+"))) {
                                && !(uarts[i].rxfs = fopen(config.uarts[i].rxfile, "r+"))) {
                                printf("UART%d has problems with RX file stream.\n", i);
                                printf("UART%d has problems with RX file stream.\n", i);
                                continue;
                                continue;
Line 207... Line 210...
                        if (uarts[i].rxfs && uarts[i].txfs) {
                        if (uarts[i].rxfs && uarts[i].txfs) {
                                printf("UART%d at 0x%.8x uses ", i, uarts[i].baseaddr);
                                printf("UART%d at 0x%.8x uses ", i, 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
                                printf("UART%d has problems with TX file stream.\n", i);
                                printf("UART%d has problems with TX file stream.\n", i);
                        register_memoryarea(uarts[i].baseaddr, UART_ADDR_SPACE, 1, uart_read_byte, uart_write_byte, 0);
                        register_memoryarea(uarts[i].baseaddr, UART_ADDR_SPACE, 1, uart_read_byte, uart_write_byte);
                }
                }
}
}
 
 
/* Simulation hook. Must be called every clock cycle to simulate all UART
/* Simulation hook. Must be called every clock cycle to simulate all UART
   devices. It does internal functional UART simulation. */
   devices. It does internal functional UART simulation. */
void uart_clock()
void uart_clock()
{
{
        int i, retval;
        int i, retval;
 
 
        for(i = 0; i < NR_UARTS; i++) {
        for(i = 0; i < config.nuarts; i++) {
                if (!uarts[i].txfs) {
                if (!uarts[i].txfs) {
                        continue;
                        continue;
                }
                }
 
 
                /* Transmit */
                /* Transmit */
Line 318... Line 321...
/* Print register values on stdout. */
/* Print register values on stdout. */
void uart_status()
void uart_status()
{
{
        int i;
        int i;
 
 
        for(i = 0; i < NR_UARTS; i++) {
        for(i = 0; i < config.nuarts; i++) {
                if ( !uarts[i].baseaddr )
                if ( !uarts[i].baseaddr )
                        continue;
                        continue;
                printf("\nUART%d visible registers at 0x%.8x:\n", i, uarts[i].baseaddr);
                printf("\nUART%d visible registers at 0x%.8x:\n", i, uarts[i].baseaddr);
                printf("RXBUF: %.2x  TXBUF: %.2x\n", uarts[i].regs.rxbuf, uarts[i].regs.txbuf);
                printf("RXBUF: %.2x  TXBUF: %.2x\n", uarts[i].regs.rxbuf, 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);

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.