From 0b395e6b0115b8bf5ce7a4be6fa38fe20eceeed8 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Sat, 8 Jan 2011 22:51:10 +0200 Subject: [PATCH] kvm: Fix magic numbers in 8250 support Signed-off-by: Pekka Enberg --- tools/kvm/early_printk.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/tools/kvm/early_printk.c b/tools/kvm/early_printk.c index ffc405fa86c6..a10d35846309 100644 --- a/tools/kvm/early_printk.c +++ b/tools/kvm/early_printk.c @@ -23,21 +23,15 @@ /* Interrupt identification register */ #define IIR 2 +#define UART_IIR_NO_INT 0x01 + /* 16550 FIFO Control Register */ #define FCR 2 /* Line control register */ #define LCR 3 -enum { - DLAB = 1 << 7, /* Divisor latch access bit (DLAB) */ - /* bit 7 - set break enable */ - PM2 = 1 << 5, - PM1 = 1 << 4, - PM0 = 1 << 3, - STB = 1 << 2, - WLS1 = 1 << 1, - WLS0 = 1 << 0, -}; + +#define UART_LCR_DLAB 0x80 /* Modem control register */ #define MCR 4 @@ -45,9 +39,13 @@ enum { /* Line status register */ #define LSR 5 +#define UART_LSR_THRE 0x20 + /* Modem status register */ #define MSR 6 +#define UART_MSR_CTS 0x10 + /* Scratch register */ #define SCR 7 @@ -70,7 +68,7 @@ static bool serial8250_out(struct kvm *self, uint16_t port, void *data, int size { uint16_t offset = port - device.iobase; - if (device.lcr & DLAB) { + if (device.lcr & UART_LCR_DLAB) { switch (offset) { case DLL: device.dll = ioport__read8(data); @@ -127,7 +125,7 @@ static bool serial8250_in(struct kvm *self, uint16_t port, void *data, int size, { uint16_t offset = port - device.iobase; - if (device.lcr & DLAB) + if (device.lcr & UART_LCR_DLAB) return false; switch (offset) { @@ -138,7 +136,7 @@ static bool serial8250_in(struct kvm *self, uint16_t port, void *data, int size, ioport__write8(data, device.ier); break; case IIR: - ioport__write8(data, 0x01); /* no interrupt pending */ + ioport__write8(data, UART_IIR_NO_INT); break; case LCR: ioport__write8(data, device.lcr); @@ -147,10 +145,10 @@ static bool serial8250_in(struct kvm *self, uint16_t port, void *data, int size, ioport__write8(data, device.mcr); break; case LSR: - ioport__write8(data, 0x20); /* XMTRDY */ + ioport__write8(data, UART_LSR_THRE); break; case MSR: - ioport__write8(data, 0x01); /* clear to send */ + ioport__write8(data, UART_MSR_CTS); break; case SCR: ioport__write8(data, device.scr); -- 2.39.5