ia64/xen-unstable
changeset 3846:7645e7facda9
bitkeeper revision 1.1214 (4214242enp-tUaPA2f1ysNS2qvLPHQ)
More serial cleanups.
Signed-off-by: Keir Fraser <keir@xensource.com>
More serial cleanups.
Signed-off-by: Keir Fraser <keir@xensource.com>
author | kaf24@scramble.cl.cam.ac.uk |
---|---|
date | Thu Feb 17 04:57:18 2005 +0000 (2005-02-17) |
parents | 46c3f40cba0b |
children | 02a6b1fa80df |
files | xen/drivers/char/serial.c xen/include/asm-x86/serial.h xen/include/xen/serial.h |
line diff
1.1 --- a/xen/drivers/char/serial.c Wed Feb 16 16:26:32 2005 +0000 1.2 +++ b/xen/drivers/char/serial.c Thu Feb 17 04:57:18 2005 +0000 1.3 @@ -18,6 +18,11 @@ 1.4 #include <xen/serial.h> 1.5 #include <asm/io.h> 1.6 1.7 +/* Config serial port with a string <baud>,DPS,<io-base>,<irq>. */ 1.8 +static unsigned char opt_com1[30] = OPT_COM1_STR, opt_com2[30] = OPT_COM2_STR; 1.9 +string_param("com1", opt_com1); 1.10 +string_param("com2", opt_com2); 1.11 + 1.12 /* Register offsets */ 1.13 #define RBR 0x00 /* receive buffer */ 1.14 #define THR 0x00 /* transmit holding */ 1.15 @@ -74,16 +79,16 @@ 1.16 1.17 #define RXBUFSZ 32 1.18 #define MASK_RXBUF_IDX(_i) ((_i)&(RXBUFSZ-1)) 1.19 -typedef struct { 1.20 +struct uart { 1.21 int baud, data_bits, parity, stop_bits, io_base, irq; 1.22 serial_rx_fn rx_lo, rx_hi, rx; 1.23 spinlock_t lock; 1.24 unsigned char rxbuf[RXBUFSZ]; 1.25 unsigned int rxbufp, rxbufc; 1.26 struct irqaction irqaction; 1.27 -} uart_t; 1.28 +}; 1.29 1.30 -static uart_t com[2] = { 1.31 +static struct uart com[2] = { 1.32 { 0, 0, 0, 0, 0x3f8, 4, 1.33 NULL, NULL, NULL, 1.34 SPIN_LOCK_UNLOCKED }, 1.35 @@ -95,20 +100,12 @@ static uart_t com[2] = { 1.36 #define UART_ENABLED(_u) ((_u)->baud != 0) 1.37 #define DISABLE_UART(_u) ((_u)->baud = 0) 1.38 1.39 -/* Architecture-specific private definitions. */ 1.40 -#include <asm/serial.h> 1.41 - 1.42 -/* opt_com[12]: Config serial port with a string <baud>,DPS,<io-base>,<irq>. */ 1.43 -static unsigned char opt_com1[30] = OPT_COM1_STR, opt_com2[30] = OPT_COM2_STR; 1.44 -string_param("com1", opt_com1); 1.45 -string_param("com2", opt_com2); 1.46 - 1.47 1.48 /*********************** 1.49 * PRIVATE FUNCTIONS 1.50 */ 1.51 1.52 -static void uart_rx(uart_t *uart, struct xen_regs *regs) 1.53 +static void uart_rx(struct uart *uart, struct xen_regs *regs) 1.54 { 1.55 unsigned char c; 1.56 1.57 @@ -134,12 +131,14 @@ static void uart_rx(uart_t *uart, struct 1.58 } 1.59 } 1.60 1.61 -static void serial_interrupt(int irq, void *dev_id, struct xen_regs *regs) 1.62 +static void serial_interrupt( 1.63 + int irq, void *dev_id, struct xen_regs *regs) 1.64 { 1.65 - uart_rx((uart_t *)dev_id, regs); 1.66 + uart_rx((struct uart *)dev_id, regs); 1.67 } 1.68 1.69 -static inline void __serial_putc(uart_t *uart, int handle, unsigned char c) 1.70 +static inline void __serial_putc( 1.71 + struct uart *uart, int handle, unsigned char c) 1.72 { 1.73 unsigned long flags; 1.74 int space; 1.75 @@ -167,7 +166,7 @@ static inline void __serial_putc(uart_t 1.76 return; \ 1.77 } while ( 0 ) 1.78 1.79 -static void parse_port_config(char *conf, uart_t *uart) 1.80 +static void parse_port_config(char *conf, struct uart *uart) 1.81 { 1.82 if ( *conf == '\0' ) 1.83 return; 1.84 @@ -233,7 +232,7 @@ static void parse_port_config(char *conf 1.85 } 1.86 } 1.87 1.88 -static void uart_config_stage1(uart_t *uart) 1.89 +static void uart_config_stage1(struct uart *uart) 1.90 { 1.91 unsigned char lcr; 1.92 1.93 @@ -258,7 +257,7 @@ static void uart_config_stage1(uart_t *u 1.94 outb(FCR_ENABLE | FCR_CLRX | FCR_CLTX | FCR_TRG14, uart->io_base + FCR); 1.95 } 1.96 1.97 -static void uart_config_stage2(uart_t *uart) 1.98 +static void uart_config_stage2(struct uart *uart) 1.99 { 1.100 int rc; 1.101 1.102 @@ -348,7 +347,7 @@ int parse_serial_handle(char *conf) 1.103 1.104 void serial_set_rx_handler(int handle, serial_rx_fn fn) 1.105 { 1.106 - uart_t *uart = &com[handle & SERHND_IDX]; 1.107 + struct uart *uart = &com[handle & SERHND_IDX]; 1.108 unsigned long flags; 1.109 1.110 if ( handle == -1 ) 1.111 @@ -389,7 +388,7 @@ void serial_set_rx_handler(int handle, s 1.112 1.113 void serial_putc(int handle, unsigned char c) 1.114 { 1.115 - uart_t *uart = &com[handle & SERHND_IDX]; 1.116 + struct uart *uart = &com[handle & SERHND_IDX]; 1.117 1.118 if ( handle == -1 ) 1.119 return; 1.120 @@ -399,7 +398,7 @@ void serial_putc(int handle, unsigned ch 1.121 1.122 void serial_puts(int handle, const unsigned char *s) 1.123 { 1.124 - uart_t *uart = &com[handle & SERHND_IDX]; 1.125 + struct uart *uart = &com[handle & SERHND_IDX]; 1.126 1.127 if ( handle == -1 ) 1.128 return; 1.129 @@ -426,7 +425,7 @@ static int byte_matches(int handle, unsi 1.130 1.131 unsigned char irq_serial_getc(int handle) 1.132 { 1.133 - uart_t *uart = &com[handle & SERHND_IDX]; 1.134 + struct uart *uart = &com[handle & SERHND_IDX]; 1.135 unsigned char c; 1.136 1.137 1.138 @@ -451,7 +450,7 @@ unsigned char irq_serial_getc(int handle 1.139 1.140 unsigned char serial_getc(int handle) 1.141 { 1.142 - uart_t *uart = &com[handle & SERHND_IDX]; 1.143 + struct uart *uart = &com[handle & SERHND_IDX]; 1.144 unsigned char c; 1.145 unsigned long flags; 1.146 1.147 @@ -476,7 +475,7 @@ unsigned char serial_getc(int handle) 1.148 1.149 void serial_force_unlock(int handle) 1.150 { 1.151 - uart_t *uart = &com[handle & SERHND_IDX]; 1.152 + struct uart *uart = &com[handle & SERHND_IDX]; 1.153 if ( handle != -1 ) 1.154 uart->lock = SPIN_LOCK_UNLOCKED; 1.155 }
2.1 --- a/xen/include/asm-x86/serial.h Wed Feb 16 16:26:32 2005 +0000 2.2 +++ b/xen/include/asm-x86/serial.h Thu Feb 17 04:57:18 2005 +0000 2.3 @@ -1,9 +1,4 @@ 2.4 /* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */ 2.5 -/****************************************************************************** 2.6 - * asm-x86/serial.h 2.7 - * 2.8 - * Architecture-specific private serial definitions. 2.9 - */ 2.10 2.11 #ifndef __ASM_X86_SERIAL_H__ 2.12 #define __ASM_X86_SERIAL_H__ 2.13 @@ -11,12 +6,8 @@ 2.14 #define OPT_COM1_STR "" 2.15 #define OPT_COM2_STR "" 2.16 2.17 -static inline int arch_serial_putc(uart_t *uart, unsigned char c) 2.18 -{ 2.19 - int space; 2.20 - if ( (space = (inb(uart->io_base + LSR) & LSR_THRE)) ) 2.21 - outb(c, uart->io_base + THR); 2.22 - return space; 2.23 -} 2.24 +#define arch_serial_putc(_uart, _c) \ 2.25 + ( (inb((_uart)->io_base + LSR) & LSR_THRE) ? \ 2.26 + (outb((_c), (_uart)->io_base + THR), 1) : 0 ) 2.27 2.28 #endif /* __ASM_X86_SERIAL_H__ */
3.1 --- a/xen/include/xen/serial.h Wed Feb 16 16:26:32 2005 +0000 3.2 +++ b/xen/include/xen/serial.h Thu Feb 17 04:57:18 2005 +0000 3.3 @@ -6,9 +6,6 @@ 3.4 * it permits debugging of seriously-toasted machines (e.g., in situations 3.5 * where a device driver within a guest OS would be inaccessible). 3.6 * 3.7 - * This file contains public definitions. The arch-specific header 3.8 - * contains only private hooks, and is not included from this file. 3.9 - * 3.10 * Copyright (c) 2003-2005, K A Fraser 3.11 */ 3.12 3.13 @@ -16,6 +13,7 @@ 3.14 #define __XEN_SERIAL_H__ 3.15 3.16 #include <asm/regs.h> 3.17 +#include <asm/serial.h> 3.18 3.19 /* 'Serial handles' are comprise the following fields. */ 3.20 #define SERHND_IDX (1<<0) /* COM1 or COM2? */