[RFC PATCH 1/3] move hvc_console headers around
Milton Miller
miltonm at bga.com
Sat Dec 17 16:02:12 EST 2005
On Dec 16, 2005, at 6:10 PM, Arnd Bergmann wrote:
> This patch shuffles around some data-type declarations and moves some
> functions out of include/asm-ppc64/hvconsole.h and into a new
> drivers/char/hvc_console.h file.
>
> Signed-off-by: "Ryan S. Arnold" <rsa at us.ibm.com>
> Signed-off-by: Arnd Bergmann <arndb at de.ibm.com>
>
> Index: linux-2.6.15-rc/drivers/char/hvc_console.c
> ===================================================================
> --- linux-2.6.15-rc.orig/drivers/char/hvc_console.c
> +++ linux-2.6.15-rc/drivers/char/hvc_console.c
> @@ -39,8 +39,10 @@
> #include <linux/sched.h>
> #include <linux/spinlock.h>
> #include <linux/delay.h>
> +
> #include <asm/uaccess.h>
> -#include <asm/hvconsole.h>
> +
> +#include "hvc_console.h"
>
> #define HVC_MAJOR 229
> #define HVC_MINOR 0
> @@ -61,10 +63,17 @@
> */
> #define HVC_ALLOC_TTY_ADAPTERS 8
This patch misses the requested cleanup of moving this define for the
total number of tty devices registered to the .h and sanitizing that
against the number of consoles.
Currently we can recoginse the first 16 devices in the device tree and
choose any one of them as the kernel console, but we only allow the
first 8 to have a tty (and hence allow /dev/console to be opened).
>
> +
> +/*
> + * This is a design shortcoming, the number '16' is a vio required
> buffer
> + * size. This should be changeable per architecture, but hvc_struct
> relies
> + * upon it and that struct is used by all hvc_console backend
> drivers. This
> + * needs to be fixed.
> + */
This is a bit strong. vio requires inbuf to be at least 16, and will
process upto 16 in outbound. They could be bigger, it will only cause
the hvc_driver to loop. Outbound couuld be smaller, but it would
reduce the efficency.
> #define N_OUTBUF 16
> #define N_INBUF 16
>
> -#define __ALIGNED__ __attribute__((__aligned__(8)))
> +#define __ALIGNED__ __attribute__((__aligned__(sizeof(long))))
>
> static struct tty_driver *hvc_driver;
> static struct task_struct *hvc_task;
> @@ -154,7 +163,7 @@ static uint32_t vtermnos[MAX_NR_HVC_CONS
>
> void hvc_console_print(struct console *co, const char *b, unsigned
> count)
> {
> - char c[16] __ALIGNED__;
> + char c[N_OUTBUF] __ALIGNED__;
> unsigned i = 0, n = 0;
> int r, donecr = 0, index = co->index;
>
> Index: linux-2.6.15-rc/drivers/char/hvc_console.h
> ===================================================================
> --- /dev/null
> +++ linux-2.6.15-rc/drivers/char/hvc_console.h
> @@ -0,0 +1,58 @@
> +/*
> + * hvc_console.h
> + * Copyright (C) 2005 IBM Corporation
> + *
> + * Author(s):
> + * Ryan S. Arnold <rsa at us.ibm.com>
> + *
> + * hvc_console header information:
> + * moved here from include/asm-powerpc/hvconsole.h
> + * and drivers/char/hvc_console.c
> + *
> + * This program is free software; you can redistribute it and/or
> modify
> + * it under the terms of the GNU General Public License as published
> by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
> 02111-1307 USA
> + */
> +
> +#ifndef HVC_CONSOLE_H
> +#define HVC_CONSOLE_H
> +
> +#include <linux/spinlock.h>
> +#include <linux/list.h>
> +#include <linux/kobject.h>
> +
Since we removed thie actual definition of the struct, these includes
should go back to hvc_console.c (and any other file that needs them).
> +/*
> + * This is the max number of console adapters that can/will be found
> as
> + * console devices on first stage console init. Any number beyond
> this range
> + * can't be used as a console device but is still a valid tty device.
> + */
> +#define MAX_NR_HVC_CONSOLES 16
> +
> +/* implemented by a low level driver */
> +struct hv_ops {
> + int (*get_chars)(uint32_t vtermno, char *buf, int count);
> + int (*put_chars)(uint32_t vtermno, const char *buf, int count);
> +};
> +
> +struct hvc_struct;
> +
> +/* Register a vterm and a slot index for use as a console
> (console_init) */
> +extern int hvc_instantiate(uint32_t vtermno, int index, struct hv_ops
> *ops);
> +
> +/* register a vterm for hvc tty operation (module_init or hotplug
> add) */
> +extern struct hvc_struct * __devinit hvc_alloc(uint32_t vtermno, int
> irq,
> + struct hv_ops *ops);
> +/* remove a vterm from hvc tty operation (modele_exit or hotplug
> remove) */
> +extern int __devexit hvc_remove(struct hvc_struct *hp);
> +
> +#endif // HVC_CONSOLE_H
> Index: linux-2.6.15-rc/include/asm-powerpc/hvconsole.h
> ===================================================================
> --- linux-2.6.15-rc.orig/include/asm-powerpc/hvconsole.h
> +++ linux-2.6.15-rc/include/asm-powerpc/hvconsole.h
> @@ -22,28 +22,7 @@
> #ifndef _PPC64_HVCONSOLE_H
> #define _PPC64_HVCONSOLE_H
>
> -/*
> - * This is the max number of console adapters that can/will be found
> as
> - * console devices on first stage console init. Any number beyond
> this range
> - * can't be used as a console device but is still a valid tty device.
> - */
> -#define MAX_NR_HVC_CONSOLES 16
> -
> -/* implemented by a low level driver */
> -struct hv_ops {
> - int (*get_chars)(uint32_t vtermno, char *buf, int count);
> - int (*put_chars)(uint32_t vtermno, const char *buf, int count);
> -};
> extern int hvc_get_chars(uint32_t vtermno, char *buf, int count);
> extern int hvc_put_chars(uint32_t vtermno, const char *buf, int
> count);
>
> -struct hvc_struct;
> -
> -/* Register a vterm and a slot index for use as a console
> (console_init) */
> -extern int hvc_instantiate(uint32_t vtermno, int index, struct hv_ops
> *ops);
> -/* register a vterm for hvc tty operation (module_init or hotplug
> add) */
> -extern struct hvc_struct * __devinit hvc_alloc(uint32_t vtermno, int
> irq,
> - struct hv_ops *ops);
> -/* remove a vterm from hvc tty operation (modele_exit or hotplug
> remove) */
> -extern int __devexit hvc_remove(struct hvc_struct *hp);
> #endif /* _PPC64_HVCONSOLE_H */
> Index: linux-2.6.15-rc/drivers/char/Kconfig
> ===================================================================
> --- linux-2.6.15-rc.orig/drivers/char/Kconfig
> +++ linux-2.6.15-rc/drivers/char/Kconfig
> @@ -552,9 +552,19 @@ config TIPAR
>
> If unsure, say N.
>
> +config HVC_DRIVER
> + bool
> + help
> + Users of pSeries machines that want to utilize the hvc console
> front-end
> + module for their backend console driver should select this option.
> + It will automatically be selected if one of the back-end console
> drivers
> + is selected.
> +
> +
> config HVC_CONSOLE
> bool "pSeries Hypervisor Virtual Console support"
> depends on PPC_PSERIES
> + select HVC_DRIVER
> help
> pSeries machines when partitioned support a hypervisor virtual
> console. This driver allows each pSeries partition to have a
> console
> Index: linux-2.6.15-rc/drivers/char/Makefile
> ===================================================================
> --- linux-2.6.15-rc.orig/drivers/char/Makefile
> +++ linux-2.6.15-rc/drivers/char/Makefile
> @@ -40,11 +40,12 @@ obj-$(CONFIG_N_HDLC) += n_hdlc.o
> obj-$(CONFIG_AMIGA_BUILTIN_SERIAL) += amiserial.o
> obj-$(CONFIG_SX) += sx.o generic_serial.o
> obj-$(CONFIG_RIO) += rio/ generic_serial.o
> -obj-$(CONFIG_HVC_CONSOLE) += hvc_console.o hvc_vio.o hvsi.o
> +obj-$(CONFIG_HVC_DRIVER) += hvc_console.o
> +obj-$(CONFIG_HVC_CONSOLE) += hvc_vio.o hvsi.o
> obj-$(CONFIG_RAW_DRIVER) += raw.o
> obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o
> obj-$(CONFIG_MMTIMER) += mmtimer.o
> -obj-$(CONFIG_VIOCONS) += viocons.o
> +obj-$(CONFIG_VIOCONS) += viocons.o
> obj-$(CONFIG_VIOTAPE) += viotape.o
> obj-$(CONFIG_HVCS) += hvcs.o
> obj-$(CONFIG_SGI_MBCS) += mbcs.o
> Index: linux-2.6.15-rc/drivers/char/hvc_vio.c
> ===================================================================
> --- linux-2.6.15-rc.orig/drivers/char/hvc_vio.c
> +++ linux-2.6.15-rc/drivers/char/hvc_vio.c
> @@ -31,10 +31,13 @@
>
> #include <linux/types.h>
> #include <linux/init.h>
> +
> #include <asm/hvconsole.h>
> #include <asm/vio.h>
> #include <asm/prom.h>
>
> +#include "hvc_console.h"
> +
> char hvc_driver_name[] = "hvc_console";
>
> static struct vio_device_id hvc_driver_table[] __devinitdata = {
>
> --
>
More information about the Linuxppc64-dev
mailing list