From: "Jan Beulich" Subject: [PATCH RFC 2/8] console: prepare for non-COMn port support Date: Tue, 11 Sep 2012 11:14:37 +0100 Message-ID: <504F2B2D020000780009A7FC@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part6554771D.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part6554771D.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Widen SERHND_IDX (and use it where needed), introduce a flush low level driver method, and remove unnecessary peeking of the common code at the (driver specific) serial port identification string in the "console=3D" command line option value. Signed-off-by: Jan Beulich --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -1017,7 +1017,7 @@ void __init smp_intr_init(void) * Also ensure serial interrupts are high priority. We do not * want them to be blocked by unacknowledged guest-bound interrupts. */ - for ( seridx =3D 0; seridx < 2; seridx++ ) + for ( seridx =3D 0; seridx <=3D SERHND_IDX; seridx++ ) { if ( (irq =3D serial_irq(seridx)) < 0 ) continue; --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -539,6 +539,7 @@ void printk(const char *fmt, ...) void __init console_init_preirq(void) { char *p; + int sh; =20 serial_init_preirq(); =20 @@ -551,8 +552,9 @@ void __init console_init_preirq(void) vga_init(); else if ( !strncmp(p, "none", 4) ) continue; - else if ( strncmp(p, "com", 3) || - (sercon_handle =3D serial_parse_handle(p)) =3D=3D -1 ) + else if ( (sh =3D serial_parse_handle(p)) >=3D 0 ) + sercon_handle =3D sh; + else { char *q =3D strchr(p, ','); if ( q !=3D NULL ) --- a/xen/drivers/char/serial.c +++ b/xen/drivers/char/serial.c @@ -22,9 +22,11 @@ size_param("serial_tx_buffer", serial_tx #define mask_serial_rxbuf_idx(_i) ((_i)&(serial_rxbufsz-1)) #define mask_serial_txbuf_idx(_i) ((_i)&(serial_txbufsz-1)) =20 -static struct serial_port com[2] =3D { - { .rx_lock =3D SPIN_LOCK_UNLOCKED, .tx_lock =3D SPIN_LOCK_UNLOCKED = },=20 - { .rx_lock =3D SPIN_LOCK_UNLOCKED, .tx_lock =3D SPIN_LOCK_UNLOCKED } +static struct serial_port com[SERHND_IDX + 1] =3D { + [0 ... SERHND_IDX] =3D { + .rx_lock =3D SPIN_LOCK_UNLOCKED, + .tx_lock =3D SPIN_LOCK_UNLOCKED + } }; =20 void serial_rx_interrupt(struct serial_port *port, struct cpu_user_regs = *regs) @@ -81,6 +83,8 @@ void serial_tx_interrupt(struct serial_p port->driver->putc( port, port->txbuf[mask_serial_txbuf_idx(port->txbufc++)]);= } + if ( i && port->driver->flush ) + port->driver->flush(port); } =20 spin_unlock(&port->tx_lock); @@ -175,6 +179,9 @@ void serial_putc(int handle, char c) =20 __serial_putc(port, c); =20 + if ( port->driver->flush ) + port->driver->flush(port); + spin_unlock_irqrestore(&port->tx_lock, flags); } =20 @@ -206,6 +213,9 @@ void serial_puts(int handle, const char=20 __serial_putc(port, c); } =20 + if ( port->driver->flush ) + port->driver->flush(port); + spin_unlock_irqrestore(&port->tx_lock, flags); } =20 @@ -261,10 +271,10 @@ int __init serial_parse_handle(char *con switch ( conf[3] ) { case '1': - handle =3D 0; + handle =3D SERHND_COM1; break; case '2': - handle =3D 1; + handle =3D SERHND_COM2; break; default: goto fail; @@ -365,6 +375,8 @@ void serial_start_sync(int handle) port->driver->putc( port, port->txbuf[mask_serial_txbuf_idx(port->txbufc++)]);= } + if ( port->driver->flush ) + port->driver->flush(port); } =20 spin_unlock_irqrestore(&port->tx_lock, flags); --- a/xen/include/xen/serial.h +++ b/xen/include/xen/serial.h @@ -60,6 +60,8 @@ struct uart_driver { int (*tx_empty)(struct serial_port *); /* Put a character onto the serial line. */ void (*putc)(struct serial_port *, char); + /* Flush accumulated characters. */ + void (*flush)(struct serial_port *); /* Get a character from the serial line: returns 0 if none available. = */ int (*getc)(struct serial_port *, char *); /* Get IRQ number for this port's serial line: returns -1 if none. */ @@ -67,10 +69,12 @@ struct uart_driver { }; =20 /* 'Serial handles' are composed from the following fields. */ -#define SERHND_IDX (1<<0) /* COM1 or COM2? = */ -#define SERHND_HI (1<<1) /* Mux/demux each transferred char by MSB. = */ -#define SERHND_LO (1<<2) /* Ditto, except that the MSB is cleared. = */ -#define SERHND_COOKED (1<<3) /* Newline/carriage-return translation? = */ +#define SERHND_IDX (3<<0) /* COM1 or COM2? = */ +# define SERHND_COM1 (0<<0) +# define SERHND_COM2 (1<<0) +#define SERHND_HI (1<<2) /* Mux/demux each transferred char by MSB. = */ +#define SERHND_LO (1<<3) /* Ditto, except that the MSB is cleared. = */ +#define SERHND_COOKED (1<<4) /* Newline/carriage-return translation? = */ =20 /* Two-stage initialisation (before/after IRQ-subsystem initialisation). = */ void serial_init_preirq(void); --=__Part6554771D.0__= Content-Type: text/plain; name="sercon-non-com.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="sercon-non-com.patch" console: prepare for non-COMn port support=0A=0AWiden SERHND_IDX (and use = it where needed), introduce a flush low level=0Adriver method, and remove = unnecessary peeking of the common code at the=0A(driver specific) serial = port identification string in the "console=3D"=0Acommand line option = value.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- = a/xen/arch/x86/smpboot.c=0A+++ b/xen/arch/x86/smpboot.c=0A@@ -1017,7 = +1017,7 @@ void __init smp_intr_init(void)=0A * Also ensure serial = interrupts are high priority. We do not=0A * want them to be blocked = by unacknowledged guest-bound interrupts.=0A */=0A- for ( seridx = =3D 0; seridx < 2; seridx++ )=0A+ for ( seridx =3D 0; seridx <=3D = SERHND_IDX; seridx++ )=0A {=0A if ( (irq =3D serial_irq(seridx)= ) < 0 )=0A continue;=0A--- a/xen/drivers/char/console.c=0A+++ = b/xen/drivers/char/console.c=0A@@ -539,6 +539,7 @@ void printk(const char = *fmt, ...)=0A void __init console_init_preirq(void)=0A {=0A char = *p;=0A+ int sh;=0A =0A serial_init_preirq();=0A =0A@@ -551,8 +552,9 = @@ void __init console_init_preirq(void)=0A vga_init();=0A = else if ( !strncmp(p, "none", 4) )=0A continue;=0A- = else if ( strncmp(p, "com", 3) ||=0A- (sercon_handle =3D = serial_parse_handle(p)) =3D=3D -1 )=0A+ else if ( (sh =3D serial_par= se_handle(p)) >=3D 0 )=0A+ sercon_handle =3D sh;=0A+ = else=0A {=0A char *q =3D strchr(p, ',');=0A = if ( q !=3D NULL )=0A--- a/xen/drivers/char/serial.c=0A+++ b/xen/drivers/c= har/serial.c=0A@@ -22,9 +22,11 @@ size_param("serial_tx_buffer", = serial_tx=0A #define mask_serial_rxbuf_idx(_i) ((_i)&(serial_rxbufsz-1))=0A= #define mask_serial_txbuf_idx(_i) ((_i)&(serial_txbufsz-1))=0A =0A-static = struct serial_port com[2] =3D {=0A- { .rx_lock =3D SPIN_LOCK_UNLOCKED, = .tx_lock =3D SPIN_LOCK_UNLOCKED }, =0A- { .rx_lock =3D SPIN_LOCK_UNLOCKE= D, .tx_lock =3D SPIN_LOCK_UNLOCKED }=0A+static struct serial_port = com[SERHND_IDX + 1] =3D {=0A+ [0 ... SERHND_IDX] =3D {=0A+ = .rx_lock =3D SPIN_LOCK_UNLOCKED,=0A+ .tx_lock =3D SPIN_LOCK_UNLOCKED= =0A+ }=0A };=0A =0A void serial_rx_interrupt(struct serial_port *port, = struct cpu_user_regs *regs)=0A@@ -81,6 +83,8 @@ void serial_tx_interrupt(st= ruct serial_p=0A port->driver->putc(=0A port, = port->txbuf[mask_serial_txbuf_idx(port->txbufc++)]);=0A }=0A+ = if ( i && port->driver->flush )=0A+ port->driver->flush(port);= =0A }=0A =0A spin_unlock(&port->tx_lock);=0A@@ -175,6 +179,9 @@ = void serial_putc(int handle, char c)=0A =0A __serial_putc(port, c);=0A = =0A+ if ( port->driver->flush )=0A+ port->driver->flush(port);=0A= +=0A spin_unlock_irqrestore(&port->tx_lock, flags);=0A }=0A =0A@@ = -206,6 +213,9 @@ void serial_puts(int handle, const char =0A = __serial_putc(port, c);=0A }=0A =0A+ if ( port->driver->flush )=0A+ = port->driver->flush(port);=0A+=0A spin_unlock_irqrestore(&port->= tx_lock, flags);=0A }=0A =0A@@ -261,10 +271,10 @@ int __init serial_parse_h= andle(char *con=0A switch ( conf[3] )=0A {=0A case '1':=0A- = handle =3D 0;=0A+ handle =3D SERHND_COM1;=0A break;=0A = case '2':=0A- handle =3D 1;=0A+ handle =3D SERHND_COM2;=0A= break;=0A default:=0A goto fail;=0A@@ -365,6 +375,8 = @@ void serial_start_sync(int handle)=0A port->driver->putc(=0A= port, port->txbuf[mask_serial_txbuf_idx(port->txbufc++)]);= =0A }=0A+ if ( port->driver->flush )=0A+ = port->driver->flush(port);=0A }=0A =0A spin_unlock_irqrestore(&port= ->tx_lock, flags);=0A--- a/xen/include/xen/serial.h=0A+++ b/xen/include/xen= /serial.h=0A@@ -60,6 +60,8 @@ struct uart_driver {=0A int (*tx_empty)(= struct serial_port *);=0A /* Put a character onto the serial line. = */=0A void (*putc)(struct serial_port *, char);=0A+ /* Flush = accumulated characters. */=0A+ void (*flush)(struct serial_port *);=0A = /* Get a character from the serial line: returns 0 if none available. = */=0A int (*getc)(struct serial_port *, char *);=0A /* Get IRQ = number for this port's serial line: returns -1 if none. */=0A@@ -67,10 = +69,12 @@ struct uart_driver {=0A };=0A =0A /* 'Serial handles' are = composed from the following fields. */=0A-#define SERHND_IDX (1<<0) = /* COM1 or COM2? */=0A-#define SERHND_HI = (1<<1) /* Mux/demux each transferred char by MSB. */=0A-#define SERHND_LO = (1<<2) /* Ditto, except that the MSB is cleared. */=0A-#define = SERHND_COOKED (1<<3) /* Newline/carriage-return translation? = */=0A+#define SERHND_IDX (3<<0) /* COM1 or COM2? = */=0A+# define SERHND_COM1 (0<<0)=0A+# define SERHND_COM2 = (1<<0)=0A+#define SERHND_HI (1<<2) /* Mux/demux each transferred = char by MSB. */=0A+#define SERHND_LO (1<<3) /* Ditto, except that = the MSB is cleared. */=0A+#define SERHND_COOKED (1<<4) /* Newline/carria= ge-return translation? */=0A =0A /* Two-stage initialisation (before/aft= er IRQ-subsystem initialisation). */=0A void serial_init_preirq(void);=0A --=__Part6554771D.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part6554771D.0__=--