aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>2008-05-04 21:42:11 +0000
committeraurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>2008-05-04 21:42:11 +0000
commitb6cd0ea1205dd4623ccfe796ee6c1a4da3141d99 (patch)
tree605d7f0c534aeeeb2d8f077593638db7dc34c149 /hw/serial.c
parent8250: throttle TX-completion IRQs (diff)
downloadqemu-kvm-b6cd0ea1205dd4623ccfe796ee6c1a4da3141d99.tar.gz
qemu-kvm-b6cd0ea1205dd4623ccfe796ee6c1a4da3141d99.tar.bz2
qemu-kvm-b6cd0ea1205dd4623ccfe796ee6c1a4da3141d99.zip
8250: Customized base baudrate
(Jan Kiszka) git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4336 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw/serial.c')
-rw-r--r--hw/serial.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/hw/serial.c b/hw/serial.c
index b5ac6f1de..ffd6ac9c8 100644
--- a/hw/serial.c
+++ b/hw/serial.c
@@ -99,6 +99,7 @@ struct SerialState {
int last_break_enable;
target_phys_addr_t base;
int it_shift;
+ int baudbase;
QEMUTimer *tx_timer;
int tx_burst;
};
@@ -135,7 +136,7 @@ static void serial_tx_done(void *opaque)
/* We assume 10 bits/char, OK for this purpose. */
s->tx_burst = THROTTLE_TX_INTERVAL * 1000 /
- (1000000 * 10 / (115200 / divider));
+ (1000000 * 10 / (s->baudbase / divider));
}
s->thr_ipending = 1;
s->lsr |= UART_LSR_THRE;
@@ -163,7 +164,7 @@ static void serial_update_parameters(SerialState *s)
data_bits = (s->lcr & 0x03) + 5;
if (s->divider == 0)
return;
- speed = 115200 / s->divider;
+ speed = s->baudbase / s->divider;
ssp.speed = speed;
ssp.parity = parity;
ssp.data_bits = data_bits;
@@ -413,7 +414,8 @@ static void serial_reset(void *opaque)
}
/* If fd is zero, it means that the serial device uses the console */
-SerialState *serial_init(int base, qemu_irq irq, CharDriverState *chr)
+SerialState *serial_init(int base, qemu_irq irq, int baudbase,
+ CharDriverState *chr)
{
SerialState *s;
@@ -421,6 +423,7 @@ SerialState *serial_init(int base, qemu_irq irq, CharDriverState *chr)
if (!s)
return NULL;
s->irq = irq;
+ s->baudbase = baudbase;
s->tx_timer = qemu_new_timer(vm_clock, serial_tx_done, s);
if (!s->tx_timer)
@@ -512,8 +515,8 @@ static CPUWriteMemoryFunc *serial_mm_write[] = {
};
SerialState *serial_mm_init (target_phys_addr_t base, int it_shift,
- qemu_irq irq, CharDriverState *chr,
- int ioregister)
+ qemu_irq irq, int baudbase,
+ CharDriverState *chr, int ioregister)
{
SerialState *s;
int s_io_memory;
@@ -524,6 +527,7 @@ SerialState *serial_mm_init (target_phys_addr_t base, int it_shift,
s->irq = irq;
s->base = base;
s->it_shift = it_shift;
+ s->baudbase= baudbase;
s->tx_timer = qemu_new_timer(vm_clock, serial_tx_done, s);
if (!s->tx_timer)