Line 33... |
Line 33... |
|
|
#include "abstract.h"
|
#include "abstract.h"
|
#include "16450.h"
|
#include "16450.h"
|
#include "sim-config.h"
|
#include "sim-config.h"
|
#include "pic.h"
|
#include "pic.h"
|
|
#include "vapi.h"
|
|
|
static struct dev_16450 uarts[NR_UARTS];
|
static struct dev_16450 uarts[NR_UARTS];
|
static int thre_int;
|
static int thre_int;
|
|
|
/* Number of clock cycles (one clock cycle is one call to the uart_clock())
|
/* Number of clock cycles (one clock cycle is one call to the uart_clock())
|
Line 183... |
Line 184... |
debug("read out of range (addr %x)\n", addr);
|
debug("read out of range (addr %x)\n", addr);
|
}
|
}
|
return value;
|
return value;
|
}
|
}
|
|
|
|
/* Function that handles incoming VAPI data. */
|
|
void uart_vapi_read (unsigned long id, unsigned long data)
|
|
{
|
|
printf ("UART: id %08x, data %08x\n", id, data);
|
|
}
|
|
|
/* Reset. It initializes all registers of all UART devices to zero values,
|
/* Reset. It initializes all registers of all UART devices to zero values,
|
(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;
|
|
|
printf("Resetting %u UART(s).\n", NR_UARTS);
|
|
memset(uarts, 0, sizeof(uarts));
|
|
|
|
if (!config.uarts_enabled)
|
if (!config.uarts_enabled)
|
config.nuarts = 0;
|
config.nuarts = 0;
|
|
|
|
printf("Resetting %u UART(s).\n", config.nuarts);
|
|
memset(uarts, 0, sizeof(uarts));
|
|
|
for(i = 0; i < config.nuarts; i++)
|
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);
|
Line 211... |
Line 218... |
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);
|
register_memoryarea(uarts[i].baseaddr, UART_ADDR_SPACE, 1, uart_read_byte, uart_write_byte);
|
|
|
|
if (config.uarts[i].vapi_id)
|
|
vapi_install_handler (config.uarts[i].vapi_id, uart_vapi_read);
|
}
|
}
|
}
|
}
|
|
|
/* 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. */
|
Line 341... |
Line 351... |
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, uarts[i].istat.txser);
|
printf("rxser: %d txser: %d\n", uarts[i].istat.rxser, uarts[i].istat.txser);
|
printf("rxbuf: %d txbuf: %d\n", uarts[i].istat.rxbuf, uarts[i].istat.txbuf);
|
printf("rxbuf: %d txbuf: %d\n", uarts[i].istat.rxbuf, uarts[i].istat.txbuf);
|
|
|
|
if (config.uarts[i].vapi_id)
|
|
printf ("Connected to vapi ID=%x\n\n", config.uarts[i].vapi_id);
|
|
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
|