Merge branch 'tty-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6
* 'tty-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6: tty: update MAINTAINERS file due to driver movement tty: move drivers/serial/ to drivers/tty/serial/ tty: move hvc drivers to drivers/tty/hvc/
This commit is contained in:
commit
fc887b15d9
140 changed files with 42 additions and 41 deletions
50
MAINTAINERS
50
MAINTAINERS
|
|
@ -162,7 +162,7 @@ L: linux-serial@vger.kernel.org
|
|||
W: http://serial.sourceforge.net
|
||||
S: Maintained
|
||||
T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6.git
|
||||
F: drivers/serial/8250*
|
||||
F: drivers/tty/serial/8250*
|
||||
F: include/linux/serial_8250.h
|
||||
|
||||
8390 NETWORK DRIVERS [WD80x3/SMC-ELITE, SMC-ULTRA, NE2000, 3C503, etc.]
|
||||
|
|
@ -888,8 +888,8 @@ F: arch/arm/mach-msm/
|
|||
F: drivers/video/msm/
|
||||
F: drivers/mmc/host/msm_sdcc.c
|
||||
F: drivers/mmc/host/msm_sdcc.h
|
||||
F: drivers/serial/msm_serial.h
|
||||
F: drivers/serial/msm_serial.c
|
||||
F: drivers/tty/serial/msm_serial.h
|
||||
F: drivers/tty/serial/msm_serial.c
|
||||
T: git git://codeaurora.org/quic/kernel/davidb/linux-msm.git
|
||||
S: Maintained
|
||||
|
||||
|
|
@ -1256,7 +1256,7 @@ F: drivers/mmc/host/atmel-mci-regs.h
|
|||
ATMEL AT91 / AT32 SERIAL DRIVER
|
||||
M: Nicolas Ferre <nicolas.ferre@atmel.com>
|
||||
S: Supported
|
||||
F: drivers/serial/atmel_serial.c
|
||||
F: drivers/tty/serial/atmel_serial.c
|
||||
|
||||
ATMEL LCDFB DRIVER
|
||||
M: Nicolas Ferre <nicolas.ferre@atmel.com>
|
||||
|
|
@ -1412,7 +1412,7 @@ M: Sonic Zhang <sonic.zhang@analog.com>
|
|||
L: uclinux-dist-devel@blackfin.uclinux.org
|
||||
W: http://blackfin.uclinux.org
|
||||
S: Supported
|
||||
F: drivers/serial/bfin_5xx.c
|
||||
F: drivers/tty/serial/bfin_5xx.c
|
||||
|
||||
BLACKFIN WATCHDOG DRIVER
|
||||
M: Mike Frysinger <vapier.adi@gmail.com>
|
||||
|
|
@ -1877,7 +1877,7 @@ L: linux-cris-kernel@axis.com
|
|||
W: http://developer.axis.com
|
||||
S: Maintained
|
||||
F: arch/cris/
|
||||
F: drivers/serial/crisv10.*
|
||||
F: drivers/tty/serial/crisv10.*
|
||||
|
||||
CRYPTO API
|
||||
M: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
|
|
@ -2216,7 +2216,7 @@ F: drivers/net/wan/dscc4.c
|
|||
DZ DECSTATION DZ11 SERIAL DRIVER
|
||||
M: "Maciej W. Rozycki" <macro@linux-mips.org>
|
||||
S: Maintained
|
||||
F: drivers/serial/dz.*
|
||||
F: drivers/tty/serial/dz.*
|
||||
|
||||
EATA-DMA SCSI DRIVER
|
||||
M: Michael Neuffer <mike@i-Connect.Net>
|
||||
|
|
@ -2643,7 +2643,7 @@ FREESCALE QUICC ENGINE UCC UART DRIVER
|
|||
M: Timur Tabi <timur@freescale.com>
|
||||
L: linuxppc-dev@lists.ozlabs.org
|
||||
S: Supported
|
||||
F: drivers/serial/ucc_uart.c
|
||||
F: drivers/tty/serial/ucc_uart.c
|
||||
|
||||
FREESCALE SOC SOUND DRIVERS
|
||||
M: Timur Tabi <timur@freescale.com>
|
||||
|
|
@ -3350,7 +3350,7 @@ IOC3 SERIAL DRIVER
|
|||
M: Pat Gefre <pfg@sgi.com>
|
||||
L: linux-serial@vger.kernel.org
|
||||
S: Maintained
|
||||
F: drivers/serial/ioc3_serial.c
|
||||
F: drivers/tty/serial/ioc3_serial.c
|
||||
|
||||
IP MASQUERADING
|
||||
M: Juanjo Ciarlante <jjciarla@raiz.uncu.edu.ar>
|
||||
|
|
@ -3527,7 +3527,7 @@ JSM Neo PCI based serial card
|
|||
M: Breno Leitao <leitao@linux.vnet.ibm.com>
|
||||
L: linux-serial@vger.kernel.org
|
||||
S: Maintained
|
||||
F: drivers/serial/jsm/
|
||||
F: drivers/tty/serial/jsm/
|
||||
|
||||
K10TEMP HARDWARE MONITORING DRIVER
|
||||
M: Clemens Ladisch <clemens@ladisch.de>
|
||||
|
|
@ -3677,7 +3677,7 @@ L: kgdb-bugreport@lists.sourceforge.net
|
|||
S: Maintained
|
||||
F: Documentation/DocBook/kgdb.tmpl
|
||||
F: drivers/misc/kgdbts.c
|
||||
F: drivers/serial/kgdboc.c
|
||||
F: drivers/tty/serial/kgdboc.c
|
||||
F: include/linux/kdb.h
|
||||
F: include/linux/kgdb.h
|
||||
F: kernel/debug/
|
||||
|
|
@ -5545,7 +5545,7 @@ M: Pat Gefre <pfg@sgi.com>
|
|||
L: linux-ia64@vger.kernel.org
|
||||
S: Supported
|
||||
F: Documentation/ia64/serial.txt
|
||||
F: drivers/serial/ioc?_serial.c
|
||||
F: drivers/tty/serial/ioc?_serial.c
|
||||
F: include/linux/ioc?.h
|
||||
|
||||
SGI VISUAL WORKSTATION 320 AND 540
|
||||
|
|
@ -5567,7 +5567,7 @@ L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
|
|||
S: Maintained
|
||||
F: Documentation/arm/Sharp-LH/ADC-LH7-Touchscreen
|
||||
F: arch/arm/mach-lh7a40x/
|
||||
F: drivers/serial/serial_lh7a40x.c
|
||||
F: drivers/tty/serial/serial_lh7a40x.c
|
||||
F: drivers/usb/gadget/lh7a40*
|
||||
F: drivers/usb/host/ohci-lh7a40*
|
||||
|
||||
|
|
@ -5787,14 +5787,14 @@ L: sparclinux@vger.kernel.org
|
|||
T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6.git
|
||||
T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-next-2.6.git
|
||||
S: Maintained
|
||||
F: drivers/serial/suncore.c
|
||||
F: drivers/serial/suncore.h
|
||||
F: drivers/serial/sunhv.c
|
||||
F: drivers/serial/sunsab.c
|
||||
F: drivers/serial/sunsab.h
|
||||
F: drivers/serial/sunsu.c
|
||||
F: drivers/serial/sunzilog.c
|
||||
F: drivers/serial/sunzilog.h
|
||||
F: drivers/tty/serial/suncore.c
|
||||
F: drivers/tty/serial/suncore.h
|
||||
F: drivers/tty/serial/sunhv.c
|
||||
F: drivers/tty/serial/sunsab.c
|
||||
F: drivers/tty/serial/sunsab.h
|
||||
F: drivers/tty/serial/sunsu.c
|
||||
F: drivers/tty/serial/sunzilog.c
|
||||
F: drivers/tty/serial/sunzilog.h
|
||||
|
||||
SPEAR PLATFORM SUPPORT
|
||||
M: Viresh Kumar <viresh.kumar@st.com>
|
||||
|
|
@ -6124,8 +6124,8 @@ TTY LAYER
|
|||
M: Greg Kroah-Hartman <gregkh@suse.de>
|
||||
S: Maintained
|
||||
T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6.git
|
||||
F: drivers/char/tty_*
|
||||
F: drivers/serial/serial_core.c
|
||||
F: drivers/tty/*
|
||||
F: drivers/tty/serial/serial_core.c
|
||||
F: include/linux/serial_core.h
|
||||
F: include/linux/serial.h
|
||||
F: include/linux/tty.h
|
||||
|
|
@ -6870,7 +6870,7 @@ XILINX UARTLITE SERIAL DRIVER
|
|||
M: Peter Korsgaard <jacmet@sunsite.dk>
|
||||
L: linux-serial@vger.kernel.org
|
||||
S: Maintained
|
||||
F: drivers/serial/uartlite.c
|
||||
F: drivers/tty/serial/uartlite.c
|
||||
|
||||
YAM DRIVER FOR AX.25
|
||||
M: Jean-Paul Roubelat <jpr@f6fbb.org>
|
||||
|
|
@ -6916,7 +6916,7 @@ F: drivers/media/video/zoran/
|
|||
ZS DECSTATION Z85C30 SERIAL DRIVER
|
||||
M: "Maciej W. Rozycki" <macro@linux-mips.org>
|
||||
S: Maintained
|
||||
F: drivers/serial/zs.*
|
||||
F: drivers/tty/serial/zs.*
|
||||
|
||||
GRE DEMULTIPLEXER DRIVER
|
||||
M: Dmitry Kozlov <xeb@mail.ru>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ obj-$(CONFIG_XEN) += xen/
|
|||
# regulators early, since some subsystems rely on them to initialize
|
||||
obj-$(CONFIG_REGULATOR) += regulator/
|
||||
|
||||
# char/ comes before serial/ etc so that the VT console is the boot-time
|
||||
# tty/ comes before char/ so that the VT console is the boot-time
|
||||
# default.
|
||||
obj-y += tty/
|
||||
obj-y += char/
|
||||
|
|
@ -38,7 +38,6 @@ obj-$(CONFIG_CONNECTOR) += connector/
|
|||
obj-$(CONFIG_FB_I810) += video/i810/
|
||||
obj-$(CONFIG_FB_INTEL) += video/intelfb/
|
||||
|
||||
obj-y += serial/
|
||||
obj-$(CONFIG_PARPORT) += parport/
|
||||
obj-y += base/ block/ misc/ mfd/ nfc/
|
||||
obj-$(CONFIG_NUBUS) += nubus/
|
||||
|
|
|
|||
|
|
@ -426,7 +426,7 @@ config SGI_MBCS
|
|||
If you have an SGI Altix with an attached SABrick
|
||||
say Y or M here, otherwise say N.
|
||||
|
||||
source "drivers/serial/Kconfig"
|
||||
source "drivers/tty/serial/Kconfig"
|
||||
|
||||
config UNIX98_PTYS
|
||||
bool "Unix98 PTY support" if EMBEDDED
|
||||
|
|
|
|||
|
|
@ -30,25 +30,12 @@ obj-$(CONFIG_SYNCLINK_GT) += synclink_gt.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_vio.o hvsi.o
|
||||
obj-$(CONFIG_HVC_ISERIES) += hvc_iseries.o
|
||||
obj-$(CONFIG_HVC_RTAS) += hvc_rtas.o
|
||||
obj-$(CONFIG_HVC_TILE) += hvc_tile.o
|
||||
obj-$(CONFIG_HVC_DCC) += hvc_dcc.o
|
||||
obj-$(CONFIG_HVC_BEAT) += hvc_beat.o
|
||||
obj-$(CONFIG_HVC_DRIVER) += hvc_console.o
|
||||
obj-$(CONFIG_HVC_IRQ) += hvc_irq.o
|
||||
obj-$(CONFIG_HVC_XEN) += hvc_xen.o
|
||||
obj-$(CONFIG_HVC_IUCV) += hvc_iucv.o
|
||||
obj-$(CONFIG_HVC_UDBG) += hvc_udbg.o
|
||||
obj-$(CONFIG_VIRTIO_CONSOLE) += virtio_console.o
|
||||
obj-$(CONFIG_RAW_DRIVER) += raw.o
|
||||
obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o
|
||||
obj-$(CONFIG_MSPEC) += mspec.o
|
||||
obj-$(CONFIG_MMTIMER) += mmtimer.o
|
||||
obj-$(CONFIG_UV_MMTIMER) += uv_mmtimer.o
|
||||
obj-$(CONFIG_VIOTAPE) += viotape.o
|
||||
obj-$(CONFIG_HVCS) += hvcs.o
|
||||
obj-$(CONFIG_IBM_BSR) += bsr.o
|
||||
obj-$(CONFIG_SGI_MBCS) += mbcs.o
|
||||
obj-$(CONFIG_BRIQ_PANEL) += briq_panel.o
|
||||
|
|
|
|||
|
|
@ -9,3 +9,5 @@ obj-$(CONFIG_N_GSM) += n_gsm.o
|
|||
obj-$(CONFIG_R3964) += n_r3964.o
|
||||
|
||||
obj-y += vt/
|
||||
obj-$(CONFIG_HVC_DRIVER) += hvc/
|
||||
obj-y += serial/
|
||||
|
|
|
|||
13
drivers/tty/hvc/Makefile
Normal file
13
drivers/tty/hvc/Makefile
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
obj-$(CONFIG_HVC_CONSOLE) += hvc_vio.o hvsi.o
|
||||
obj-$(CONFIG_HVC_ISERIES) += hvc_iseries.o
|
||||
obj-$(CONFIG_HVC_RTAS) += hvc_rtas.o
|
||||
obj-$(CONFIG_HVC_TILE) += hvc_tile.o
|
||||
obj-$(CONFIG_HVC_DCC) += hvc_dcc.o
|
||||
obj-$(CONFIG_HVC_BEAT) += hvc_beat.o
|
||||
obj-$(CONFIG_HVC_DRIVER) += hvc_console.o
|
||||
obj-$(CONFIG_HVC_IRQ) += hvc_irq.o
|
||||
obj-$(CONFIG_HVC_XEN) += hvc_xen.o
|
||||
obj-$(CONFIG_HVC_IUCV) += hvc_iucv.o
|
||||
obj-$(CONFIG_HVC_UDBG) += hvc_udbg.o
|
||||
obj-$(CONFIG_HVCS) += hvcs.o
|
||||
obj-$(CONFIG_VIRTIO_CONSOLE) += virtio_console.o
|
||||
134
drivers/tty/hvc/hvc_beat.c
Normal file
134
drivers/tty/hvc/hvc_beat.c
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
* Beat hypervisor console driver
|
||||
*
|
||||
* (C) Copyright 2006 TOSHIBA CORPORATION
|
||||
*
|
||||
* This code is based on drivers/char/hvc_rtas.c:
|
||||
* (C) Copyright IBM Corporation 2001-2005
|
||||
* (C) Copyright Red Hat, Inc. 2005
|
||||
*
|
||||
* 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.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/console.h>
|
||||
#include <asm/prom.h>
|
||||
#include <asm/hvconsole.h>
|
||||
#include <asm/firmware.h>
|
||||
|
||||
#include "hvc_console.h"
|
||||
|
||||
extern int64_t beat_get_term_char(uint64_t, uint64_t *, uint64_t *, uint64_t *);
|
||||
extern int64_t beat_put_term_char(uint64_t, uint64_t, uint64_t, uint64_t);
|
||||
|
||||
struct hvc_struct *hvc_beat_dev = NULL;
|
||||
|
||||
/* bug: only one queue is available regardless of vtermno */
|
||||
static int hvc_beat_get_chars(uint32_t vtermno, char *buf, int cnt)
|
||||
{
|
||||
static unsigned char q[sizeof(unsigned long) * 2]
|
||||
__attribute__((aligned(sizeof(unsigned long))));
|
||||
static int qlen = 0;
|
||||
u64 got;
|
||||
|
||||
again:
|
||||
if (qlen) {
|
||||
if (qlen > cnt) {
|
||||
memcpy(buf, q, cnt);
|
||||
qlen -= cnt;
|
||||
memmove(q + cnt, q, qlen);
|
||||
return cnt;
|
||||
} else { /* qlen <= cnt */
|
||||
int r;
|
||||
|
||||
memcpy(buf, q, qlen);
|
||||
r = qlen;
|
||||
qlen = 0;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
if (beat_get_term_char(vtermno, &got,
|
||||
((u64 *)q), ((u64 *)q) + 1) == 0) {
|
||||
qlen = got;
|
||||
goto again;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hvc_beat_put_chars(uint32_t vtermno, const char *buf, int cnt)
|
||||
{
|
||||
unsigned long kb[2];
|
||||
int rest, nlen;
|
||||
|
||||
for (rest = cnt; rest > 0; rest -= nlen) {
|
||||
nlen = (rest > 16) ? 16 : rest;
|
||||
memcpy(kb, buf, nlen);
|
||||
beat_put_term_char(vtermno, nlen, kb[0], kb[1]);
|
||||
buf += nlen;
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
static const struct hv_ops hvc_beat_get_put_ops = {
|
||||
.get_chars = hvc_beat_get_chars,
|
||||
.put_chars = hvc_beat_put_chars,
|
||||
};
|
||||
|
||||
static int hvc_beat_useit = 1;
|
||||
|
||||
static int hvc_beat_config(char *p)
|
||||
{
|
||||
hvc_beat_useit = simple_strtoul(p, NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __init hvc_beat_console_init(void)
|
||||
{
|
||||
if (hvc_beat_useit && of_machine_is_compatible("Beat")) {
|
||||
hvc_instantiate(0, 0, &hvc_beat_get_put_ops);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* temp */
|
||||
static int __init hvc_beat_init(void)
|
||||
{
|
||||
struct hvc_struct *hp;
|
||||
|
||||
if (!firmware_has_feature(FW_FEATURE_BEAT))
|
||||
return -ENODEV;
|
||||
|
||||
hp = hvc_alloc(0, NO_IRQ, &hvc_beat_get_put_ops, 16);
|
||||
if (IS_ERR(hp))
|
||||
return PTR_ERR(hp);
|
||||
hvc_beat_dev = hp;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit hvc_beat_exit(void)
|
||||
{
|
||||
if (hvc_beat_dev)
|
||||
hvc_remove(hvc_beat_dev);
|
||||
}
|
||||
|
||||
module_init(hvc_beat_init);
|
||||
module_exit(hvc_beat_exit);
|
||||
|
||||
__setup("hvc_beat=", hvc_beat_config);
|
||||
|
||||
console_initcall(hvc_beat_console_init);
|
||||
914
drivers/tty/hvc/hvc_console.c
Normal file
914
drivers/tty/hvc/hvc_console.c
Normal file
|
|
@ -0,0 +1,914 @@
|
|||
/*
|
||||
* Copyright (C) 2001 Anton Blanchard <anton@au.ibm.com>, IBM
|
||||
* Copyright (C) 2001 Paul Mackerras <paulus@au.ibm.com>, IBM
|
||||
* Copyright (C) 2004 Benjamin Herrenschmidt <benh@kernel.crashing.org>, IBM Corp.
|
||||
* Copyright (C) 2004 IBM Corporation
|
||||
*
|
||||
* Additional Author(s):
|
||||
* Ryan S. Arnold <rsa@us.ibm.com>
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <linux/console.h>
|
||||
#include <linux/cpumask.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/kbd_kern.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/kthread.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/major.h>
|
||||
#include <linux/sysrq.h>
|
||||
#include <linux/tty.h>
|
||||
#include <linux/tty_flip.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/freezer.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include <asm/uaccess.h>
|
||||
|
||||
#include "hvc_console.h"
|
||||
|
||||
#define HVC_MAJOR 229
|
||||
#define HVC_MINOR 0
|
||||
|
||||
/*
|
||||
* Wait this long per iteration while trying to push buffered data to the
|
||||
* hypervisor before allowing the tty to complete a close operation.
|
||||
*/
|
||||
#define HVC_CLOSE_WAIT (HZ/100) /* 1/10 of a second */
|
||||
|
||||
/*
|
||||
* These sizes are most efficient for vio, because they are the
|
||||
* native transfer size. We could make them selectable in the
|
||||
* future to better deal with backends that want other buffer sizes.
|
||||
*/
|
||||
#define N_OUTBUF 16
|
||||
#define N_INBUF 16
|
||||
|
||||
#define __ALIGNED__ __attribute__((__aligned__(sizeof(long))))
|
||||
|
||||
static struct tty_driver *hvc_driver;
|
||||
static struct task_struct *hvc_task;
|
||||
|
||||
/* Picks up late kicks after list walk but before schedule() */
|
||||
static int hvc_kicked;
|
||||
|
||||
static int hvc_init(void);
|
||||
|
||||
#ifdef CONFIG_MAGIC_SYSRQ
|
||||
static int sysrq_pressed;
|
||||
#endif
|
||||
|
||||
/* dynamic list of hvc_struct instances */
|
||||
static LIST_HEAD(hvc_structs);
|
||||
|
||||
/*
|
||||
* Protect the list of hvc_struct instances from inserts and removals during
|
||||
* list traversal.
|
||||
*/
|
||||
static DEFINE_SPINLOCK(hvc_structs_lock);
|
||||
|
||||
/*
|
||||
* This value is used to assign a tty->index value to a hvc_struct based
|
||||
* upon order of exposure via hvc_probe(), when we can not match it to
|
||||
* a console candidate registered with hvc_instantiate().
|
||||
*/
|
||||
static int last_hvc = -1;
|
||||
|
||||
/*
|
||||
* Do not call this function with either the hvc_structs_lock or the hvc_struct
|
||||
* lock held. If successful, this function increments the kref reference
|
||||
* count against the target hvc_struct so it should be released when finished.
|
||||
*/
|
||||
static struct hvc_struct *hvc_get_by_index(int index)
|
||||
{
|
||||
struct hvc_struct *hp;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock(&hvc_structs_lock);
|
||||
|
||||
list_for_each_entry(hp, &hvc_structs, next) {
|
||||
spin_lock_irqsave(&hp->lock, flags);
|
||||
if (hp->index == index) {
|
||||
kref_get(&hp->kref);
|
||||
spin_unlock_irqrestore(&hp->lock, flags);
|
||||
spin_unlock(&hvc_structs_lock);
|
||||
return hp;
|
||||
}
|
||||
spin_unlock_irqrestore(&hp->lock, flags);
|
||||
}
|
||||
hp = NULL;
|
||||
|
||||
spin_unlock(&hvc_structs_lock);
|
||||
return hp;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Initial console vtermnos for console API usage prior to full console
|
||||
* initialization. Any vty adapter outside this range will not have usable
|
||||
* console interfaces but can still be used as a tty device. This has to be
|
||||
* static because kmalloc will not work during early console init.
|
||||
*/
|
||||
static const struct hv_ops *cons_ops[MAX_NR_HVC_CONSOLES];
|
||||
static uint32_t vtermnos[MAX_NR_HVC_CONSOLES] =
|
||||
{[0 ... MAX_NR_HVC_CONSOLES - 1] = -1};
|
||||
|
||||
/*
|
||||
* Console APIs, NOT TTY. These APIs are available immediately when
|
||||
* hvc_console_setup() finds adapters.
|
||||
*/
|
||||
|
||||
static void hvc_console_print(struct console *co, const char *b,
|
||||
unsigned count)
|
||||
{
|
||||
char c[N_OUTBUF] __ALIGNED__;
|
||||
unsigned i = 0, n = 0;
|
||||
int r, donecr = 0, index = co->index;
|
||||
|
||||
/* Console access attempt outside of acceptable console range. */
|
||||
if (index >= MAX_NR_HVC_CONSOLES)
|
||||
return;
|
||||
|
||||
/* This console adapter was removed so it is not usable. */
|
||||
if (vtermnos[index] == -1)
|
||||
return;
|
||||
|
||||
while (count > 0 || i > 0) {
|
||||
if (count > 0 && i < sizeof(c)) {
|
||||
if (b[n] == '\n' && !donecr) {
|
||||
c[i++] = '\r';
|
||||
donecr = 1;
|
||||
} else {
|
||||
c[i++] = b[n++];
|
||||
donecr = 0;
|
||||
--count;
|
||||
}
|
||||
} else {
|
||||
r = cons_ops[index]->put_chars(vtermnos[index], c, i);
|
||||
if (r <= 0) {
|
||||
/* throw away chars on error */
|
||||
i = 0;
|
||||
} else if (r > 0) {
|
||||
i -= r;
|
||||
if (i > 0)
|
||||
memmove(c, c+r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static struct tty_driver *hvc_console_device(struct console *c, int *index)
|
||||
{
|
||||
if (vtermnos[c->index] == -1)
|
||||
return NULL;
|
||||
|
||||
*index = c->index;
|
||||
return hvc_driver;
|
||||
}
|
||||
|
||||
static int __init hvc_console_setup(struct console *co, char *options)
|
||||
{
|
||||
if (co->index < 0 || co->index >= MAX_NR_HVC_CONSOLES)
|
||||
return -ENODEV;
|
||||
|
||||
if (vtermnos[co->index] == -1)
|
||||
return -ENODEV;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct console hvc_console = {
|
||||
.name = "hvc",
|
||||
.write = hvc_console_print,
|
||||
.device = hvc_console_device,
|
||||
.setup = hvc_console_setup,
|
||||
.flags = CON_PRINTBUFFER,
|
||||
.index = -1,
|
||||
};
|
||||
|
||||
/*
|
||||
* Early console initialization. Precedes driver initialization.
|
||||
*
|
||||
* (1) we are first, and the user specified another driver
|
||||
* -- index will remain -1
|
||||
* (2) we are first and the user specified no driver
|
||||
* -- index will be set to 0, then we will fail setup.
|
||||
* (3) we are first and the user specified our driver
|
||||
* -- index will be set to user specified driver, and we will fail
|
||||
* (4) we are after driver, and this initcall will register us
|
||||
* -- if the user didn't specify a driver then the console will match
|
||||
*
|
||||
* Note that for cases 2 and 3, we will match later when the io driver
|
||||
* calls hvc_instantiate() and call register again.
|
||||
*/
|
||||
static int __init hvc_console_init(void)
|
||||
{
|
||||
register_console(&hvc_console);
|
||||
return 0;
|
||||
}
|
||||
console_initcall(hvc_console_init);
|
||||
|
||||
/* callback when the kboject ref count reaches zero. */
|
||||
static void destroy_hvc_struct(struct kref *kref)
|
||||
{
|
||||
struct hvc_struct *hp = container_of(kref, struct hvc_struct, kref);
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock(&hvc_structs_lock);
|
||||
|
||||
spin_lock_irqsave(&hp->lock, flags);
|
||||
list_del(&(hp->next));
|
||||
spin_unlock_irqrestore(&hp->lock, flags);
|
||||
|
||||
spin_unlock(&hvc_structs_lock);
|
||||
|
||||
kfree(hp);
|
||||
}
|
||||
|
||||
/*
|
||||
* hvc_instantiate() is an early console discovery method which locates
|
||||
* consoles * prior to the vio subsystem discovering them. Hotplugged
|
||||
* vty adapters do NOT get an hvc_instantiate() callback since they
|
||||
* appear after early console init.
|
||||
*/
|
||||
int hvc_instantiate(uint32_t vtermno, int index, const struct hv_ops *ops)
|
||||
{
|
||||
struct hvc_struct *hp;
|
||||
|
||||
if (index < 0 || index >= MAX_NR_HVC_CONSOLES)
|
||||
return -1;
|
||||
|
||||
if (vtermnos[index] != -1)
|
||||
return -1;
|
||||
|
||||
/* make sure no no tty has been registered in this index */
|
||||
hp = hvc_get_by_index(index);
|
||||
if (hp) {
|
||||
kref_put(&hp->kref, destroy_hvc_struct);
|
||||
return -1;
|
||||
}
|
||||
|
||||
vtermnos[index] = vtermno;
|
||||
cons_ops[index] = ops;
|
||||
|
||||
/* reserve all indices up to and including this index */
|
||||
if (last_hvc < index)
|
||||
last_hvc = index;
|
||||
|
||||
/* if this index is what the user requested, then register
|
||||
* now (setup won't fail at this point). It's ok to just
|
||||
* call register again if previously .setup failed.
|
||||
*/
|
||||
if (index == hvc_console.index)
|
||||
register_console(&hvc_console);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(hvc_instantiate);
|
||||
|
||||
/* Wake the sleeping khvcd */
|
||||
void hvc_kick(void)
|
||||
{
|
||||
hvc_kicked = 1;
|
||||
wake_up_process(hvc_task);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(hvc_kick);
|
||||
|
||||
static void hvc_unthrottle(struct tty_struct *tty)
|
||||
{
|
||||
hvc_kick();
|
||||
}
|
||||
|
||||
/*
|
||||
* The TTY interface won't be used until after the vio layer has exposed the vty
|
||||
* adapter to the kernel.
|
||||
*/
|
||||
static int hvc_open(struct tty_struct *tty, struct file * filp)
|
||||
{
|
||||
struct hvc_struct *hp;
|
||||
unsigned long flags;
|
||||
int rc = 0;
|
||||
|
||||
/* Auto increments kref reference if found. */
|
||||
if (!(hp = hvc_get_by_index(tty->index)))
|
||||
return -ENODEV;
|
||||
|
||||
spin_lock_irqsave(&hp->lock, flags);
|
||||
/* Check and then increment for fast path open. */
|
||||
if (hp->count++ > 0) {
|
||||
tty_kref_get(tty);
|
||||
spin_unlock_irqrestore(&hp->lock, flags);
|
||||
hvc_kick();
|
||||
return 0;
|
||||
} /* else count == 0 */
|
||||
|
||||
tty->driver_data = hp;
|
||||
|
||||
hp->tty = tty_kref_get(tty);
|
||||
|
||||
spin_unlock_irqrestore(&hp->lock, flags);
|
||||
|
||||
if (hp->ops->notifier_add)
|
||||
rc = hp->ops->notifier_add(hp, hp->data);
|
||||
|
||||
/*
|
||||
* If the notifier fails we return an error. The tty layer
|
||||
* will call hvc_close() after a failed open but we don't want to clean
|
||||
* up there so we'll clean up here and clear out the previously set
|
||||
* tty fields and return the kref reference.
|
||||
*/
|
||||
if (rc) {
|
||||
spin_lock_irqsave(&hp->lock, flags);
|
||||
hp->tty = NULL;
|
||||
spin_unlock_irqrestore(&hp->lock, flags);
|
||||
tty_kref_put(tty);
|
||||
tty->driver_data = NULL;
|
||||
kref_put(&hp->kref, destroy_hvc_struct);
|
||||
printk(KERN_ERR "hvc_open: request_irq failed with rc %d.\n", rc);
|
||||
}
|
||||
/* Force wakeup of the polling thread */
|
||||
hvc_kick();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void hvc_close(struct tty_struct *tty, struct file * filp)
|
||||
{
|
||||
struct hvc_struct *hp;
|
||||
unsigned long flags;
|
||||
|
||||
if (tty_hung_up_p(filp))
|
||||
return;
|
||||
|
||||
/*
|
||||
* No driver_data means that this close was issued after a failed
|
||||
* hvc_open by the tty layer's release_dev() function and we can just
|
||||
* exit cleanly because the kref reference wasn't made.
|
||||
*/
|
||||
if (!tty->driver_data)
|
||||
return;
|
||||
|
||||
hp = tty->driver_data;
|
||||
|
||||
spin_lock_irqsave(&hp->lock, flags);
|
||||
|
||||
if (--hp->count == 0) {
|
||||
/* We are done with the tty pointer now. */
|
||||
hp->tty = NULL;
|
||||
spin_unlock_irqrestore(&hp->lock, flags);
|
||||
|
||||
if (hp->ops->notifier_del)
|
||||
hp->ops->notifier_del(hp, hp->data);
|
||||
|
||||
/* cancel pending tty resize work */
|
||||
cancel_work_sync(&hp->tty_resize);
|
||||
|
||||
/*
|
||||
* Chain calls chars_in_buffer() and returns immediately if
|
||||
* there is no buffered data otherwise sleeps on a wait queue
|
||||
* waking periodically to check chars_in_buffer().
|
||||
*/
|
||||
tty_wait_until_sent(tty, HVC_CLOSE_WAIT);
|
||||
} else {
|
||||
if (hp->count < 0)
|
||||
printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
|
||||
hp->vtermno, hp->count);
|
||||
spin_unlock_irqrestore(&hp->lock, flags);
|
||||
}
|
||||
|
||||
tty_kref_put(tty);
|
||||
kref_put(&hp->kref, destroy_hvc_struct);
|
||||
}
|
||||
|
||||
static void hvc_hangup(struct tty_struct *tty)
|
||||
{
|
||||
struct hvc_struct *hp = tty->driver_data;
|
||||
unsigned long flags;
|
||||
int temp_open_count;
|
||||
|
||||
if (!hp)
|
||||
return;
|
||||
|
||||
/* cancel pending tty resize work */
|
||||
cancel_work_sync(&hp->tty_resize);
|
||||
|
||||
spin_lock_irqsave(&hp->lock, flags);
|
||||
|
||||
/*
|
||||
* The N_TTY line discipline has problems such that in a close vs
|
||||
* open->hangup case this can be called after the final close so prevent
|
||||
* that from happening for now.
|
||||
*/
|
||||
if (hp->count <= 0) {
|
||||
spin_unlock_irqrestore(&hp->lock, flags);
|
||||
return;
|
||||
}
|
||||
|
||||
temp_open_count = hp->count;
|
||||
hp->count = 0;
|
||||
hp->n_outbuf = 0;
|
||||
hp->tty = NULL;
|
||||
|
||||
spin_unlock_irqrestore(&hp->lock, flags);
|
||||
|
||||
if (hp->ops->notifier_hangup)
|
||||
hp->ops->notifier_hangup(hp, hp->data);
|
||||
|
||||
while(temp_open_count) {
|
||||
--temp_open_count;
|
||||
tty_kref_put(tty);
|
||||
kref_put(&hp->kref, destroy_hvc_struct);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Push buffered characters whether they were just recently buffered or waiting
|
||||
* on a blocked hypervisor. Call this function with hp->lock held.
|
||||
*/
|
||||
static int hvc_push(struct hvc_struct *hp)
|
||||
{
|
||||
int n;
|
||||
|
||||
n = hp->ops->put_chars(hp->vtermno, hp->outbuf, hp->n_outbuf);
|
||||
if (n <= 0) {
|
||||
if (n == 0) {
|
||||
hp->do_wakeup = 1;
|
||||
return 0;
|
||||
}
|
||||
/* throw away output on error; this happens when
|
||||
there is no session connected to the vterm. */
|
||||
hp->n_outbuf = 0;
|
||||
} else
|
||||
hp->n_outbuf -= n;
|
||||
if (hp->n_outbuf > 0)
|
||||
memmove(hp->outbuf, hp->outbuf + n, hp->n_outbuf);
|
||||
else
|
||||
hp->do_wakeup = 1;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count)
|
||||
{
|
||||
struct hvc_struct *hp = tty->driver_data;
|
||||
unsigned long flags;
|
||||
int rsize, written = 0;
|
||||
|
||||
/* This write was probably executed during a tty close. */
|
||||
if (!hp)
|
||||
return -EPIPE;
|
||||
|
||||
if (hp->count <= 0)
|
||||
return -EIO;
|
||||
|
||||
spin_lock_irqsave(&hp->lock, flags);
|
||||
|
||||
/* Push pending writes */
|
||||
if (hp->n_outbuf > 0)
|
||||
hvc_push(hp);
|
||||
|
||||
while (count > 0 && (rsize = hp->outbuf_size - hp->n_outbuf) > 0) {
|
||||
if (rsize > count)
|
||||
rsize = count;
|
||||
memcpy(hp->outbuf + hp->n_outbuf, buf, rsize);
|
||||
count -= rsize;
|
||||
buf += rsize;
|
||||
hp->n_outbuf += rsize;
|
||||
written += rsize;
|
||||
hvc_push(hp);
|
||||
}
|
||||
spin_unlock_irqrestore(&hp->lock, flags);
|
||||
|
||||
/*
|
||||
* Racy, but harmless, kick thread if there is still pending data.
|
||||
*/
|
||||
if (hp->n_outbuf)
|
||||
hvc_kick();
|
||||
|
||||
return written;
|
||||
}
|
||||
|
||||
/**
|
||||
* hvc_set_winsz() - Resize the hvc tty terminal window.
|
||||
* @work: work structure.
|
||||
*
|
||||
* The routine shall not be called within an atomic context because it
|
||||
* might sleep.
|
||||
*
|
||||
* Locking: hp->lock
|
||||
*/
|
||||
static void hvc_set_winsz(struct work_struct *work)
|
||||
{
|
||||
struct hvc_struct *hp;
|
||||
unsigned long hvc_flags;
|
||||
struct tty_struct *tty;
|
||||
struct winsize ws;
|
||||
|
||||
hp = container_of(work, struct hvc_struct, tty_resize);
|
||||
|
||||
spin_lock_irqsave(&hp->lock, hvc_flags);
|
||||
if (!hp->tty) {
|
||||
spin_unlock_irqrestore(&hp->lock, hvc_flags);
|
||||
return;
|
||||
}
|
||||
ws = hp->ws;
|
||||
tty = tty_kref_get(hp->tty);
|
||||
spin_unlock_irqrestore(&hp->lock, hvc_flags);
|
||||
|
||||
tty_do_resize(tty, &ws);
|
||||
tty_kref_put(tty);
|
||||
}
|
||||
|
||||
/*
|
||||
* This is actually a contract between the driver and the tty layer outlining
|
||||
* how much write room the driver can guarantee will be sent OR BUFFERED. This
|
||||
* driver MUST honor the return value.
|
||||
*/
|
||||
static int hvc_write_room(struct tty_struct *tty)
|
||||
{
|
||||
struct hvc_struct *hp = tty->driver_data;
|
||||
|
||||
if (!hp)
|
||||
return -1;
|
||||
|
||||
return hp->outbuf_size - hp->n_outbuf;
|
||||
}
|
||||
|
||||
static int hvc_chars_in_buffer(struct tty_struct *tty)
|
||||
{
|
||||
struct hvc_struct *hp = tty->driver_data;
|
||||
|
||||
if (!hp)
|
||||
return 0;
|
||||
return hp->n_outbuf;
|
||||
}
|
||||
|
||||
/*
|
||||
* timeout will vary between the MIN and MAX values defined here. By default
|
||||
* and during console activity we will use a default MIN_TIMEOUT of 10. When
|
||||
* the console is idle, we increase the timeout value on each pass through
|
||||
* msleep until we reach the max. This may be noticeable as a brief (average
|
||||
* one second) delay on the console before the console responds to input when
|
||||
* there has been no input for some time.
|
||||
*/
|
||||
#define MIN_TIMEOUT (10)
|
||||
#define MAX_TIMEOUT (2000)
|
||||
static u32 timeout = MIN_TIMEOUT;
|
||||
|
||||
#define HVC_POLL_READ 0x00000001
|
||||
#define HVC_POLL_WRITE 0x00000002
|
||||
|
||||
int hvc_poll(struct hvc_struct *hp)
|
||||
{
|
||||
struct tty_struct *tty;
|
||||
int i, n, poll_mask = 0;
|
||||
char buf[N_INBUF] __ALIGNED__;
|
||||
unsigned long flags;
|
||||
int read_total = 0;
|
||||
int written_total = 0;
|
||||
|
||||
spin_lock_irqsave(&hp->lock, flags);
|
||||
|
||||
/* Push pending writes */
|
||||
if (hp->n_outbuf > 0)
|
||||
written_total = hvc_push(hp);
|
||||
|
||||
/* Reschedule us if still some write pending */
|
||||
if (hp->n_outbuf > 0) {
|
||||
poll_mask |= HVC_POLL_WRITE;
|
||||
/* If hvc_push() was not able to write, sleep a few msecs */
|
||||
timeout = (written_total) ? 0 : MIN_TIMEOUT;
|
||||
}
|
||||
|
||||
/* No tty attached, just skip */
|
||||
tty = tty_kref_get(hp->tty);
|
||||
if (tty == NULL)
|
||||
goto bail;
|
||||
|
||||
/* Now check if we can get data (are we throttled ?) */
|
||||
if (test_bit(TTY_THROTTLED, &tty->flags))
|
||||
goto throttled;
|
||||
|
||||
/* If we aren't notifier driven and aren't throttled, we always
|
||||
* request a reschedule
|
||||
*/
|
||||
if (!hp->irq_requested)
|
||||
poll_mask |= HVC_POLL_READ;
|
||||
|
||||
/* Read data if any */
|
||||
for (;;) {
|
||||
int count = tty_buffer_request_room(tty, N_INBUF);
|
||||
|
||||
/* If flip is full, just reschedule a later read */
|
||||
if (count == 0) {
|
||||
poll_mask |= HVC_POLL_READ;
|
||||
break;
|
||||
}
|
||||
|
||||
n = hp->ops->get_chars(hp->vtermno, buf, count);
|
||||
if (n <= 0) {
|
||||
/* Hangup the tty when disconnected from host */
|
||||
if (n == -EPIPE) {
|
||||
spin_unlock_irqrestore(&hp->lock, flags);
|
||||
tty_hangup(tty);
|
||||
spin_lock_irqsave(&hp->lock, flags);
|
||||
} else if ( n == -EAGAIN ) {
|
||||
/*
|
||||
* Some back-ends can only ensure a certain min
|
||||
* num of bytes read, which may be > 'count'.
|
||||
* Let the tty clear the flip buff to make room.
|
||||
*/
|
||||
poll_mask |= HVC_POLL_READ;
|
||||
}
|
||||
break;
|
||||
}
|
||||
for (i = 0; i < n; ++i) {
|
||||
#ifdef CONFIG_MAGIC_SYSRQ
|
||||
if (hp->index == hvc_console.index) {
|
||||
/* Handle the SysRq Hack */
|
||||
/* XXX should support a sequence */
|
||||
if (buf[i] == '\x0f') { /* ^O */
|
||||
/* if ^O is pressed again, reset
|
||||
* sysrq_pressed and flip ^O char */
|
||||
sysrq_pressed = !sysrq_pressed;
|
||||
if (sysrq_pressed)
|
||||
continue;
|
||||
} else if (sysrq_pressed) {
|
||||
handle_sysrq(buf[i]);
|
||||
sysrq_pressed = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_MAGIC_SYSRQ */
|
||||
tty_insert_flip_char(tty, buf[i], 0);
|
||||
}
|
||||
|
||||
read_total += n;
|
||||
}
|
||||
throttled:
|
||||
/* Wakeup write queue if necessary */
|
||||
if (hp->do_wakeup) {
|
||||
hp->do_wakeup = 0;
|
||||
tty_wakeup(tty);
|
||||
}
|
||||
bail:
|
||||
spin_unlock_irqrestore(&hp->lock, flags);
|
||||
|
||||
if (read_total) {
|
||||
/* Activity is occurring, so reset the polling backoff value to
|
||||
a minimum for performance. */
|
||||
timeout = MIN_TIMEOUT;
|
||||
|
||||
tty_flip_buffer_push(tty);
|
||||
}
|
||||
if (tty)
|
||||
tty_kref_put(tty);
|
||||
|
||||
return poll_mask;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(hvc_poll);
|
||||
|
||||
/**
|
||||
* __hvc_resize() - Update terminal window size information.
|
||||
* @hp: HVC console pointer
|
||||
* @ws: Terminal window size structure
|
||||
*
|
||||
* Stores the specified window size information in the hvc structure of @hp.
|
||||
* The function schedule the tty resize update.
|
||||
*
|
||||
* Locking: Locking free; the function MUST be called holding hp->lock
|
||||
*/
|
||||
void __hvc_resize(struct hvc_struct *hp, struct winsize ws)
|
||||
{
|
||||
hp->ws = ws;
|
||||
schedule_work(&hp->tty_resize);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__hvc_resize);
|
||||
|
||||
/*
|
||||
* This kthread is either polling or interrupt driven. This is determined by
|
||||
* calling hvc_poll() who determines whether a console adapter support
|
||||
* interrupts.
|
||||
*/
|
||||
static int khvcd(void *unused)
|
||||
{
|
||||
int poll_mask;
|
||||
struct hvc_struct *hp;
|
||||
|
||||
set_freezable();
|
||||
do {
|
||||
poll_mask = 0;
|
||||
hvc_kicked = 0;
|
||||
try_to_freeze();
|
||||
wmb();
|
||||
if (!cpus_are_in_xmon()) {
|
||||
spin_lock(&hvc_structs_lock);
|
||||
list_for_each_entry(hp, &hvc_structs, next) {
|
||||
poll_mask |= hvc_poll(hp);
|
||||
}
|
||||
spin_unlock(&hvc_structs_lock);
|
||||
} else
|
||||
poll_mask |= HVC_POLL_READ;
|
||||
if (hvc_kicked)
|
||||
continue;
|
||||
set_current_state(TASK_INTERRUPTIBLE);
|
||||
if (!hvc_kicked) {
|
||||
if (poll_mask == 0)
|
||||
schedule();
|
||||
else {
|
||||
if (timeout < MAX_TIMEOUT)
|
||||
timeout += (timeout >> 6) + 1;
|
||||
|
||||
msleep_interruptible(timeout);
|
||||
}
|
||||
}
|
||||
__set_current_state(TASK_RUNNING);
|
||||
} while (!kthread_should_stop());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct tty_operations hvc_ops = {
|
||||
.open = hvc_open,
|
||||
.close = hvc_close,
|
||||
.write = hvc_write,
|
||||
.hangup = hvc_hangup,
|
||||
.unthrottle = hvc_unthrottle,
|
||||
.write_room = hvc_write_room,
|
||||
.chars_in_buffer = hvc_chars_in_buffer,
|
||||
};
|
||||
|
||||
struct hvc_struct *hvc_alloc(uint32_t vtermno, int data,
|
||||
const struct hv_ops *ops,
|
||||
int outbuf_size)
|
||||
{
|
||||
struct hvc_struct *hp;
|
||||
int i;
|
||||
|
||||
/* We wait until a driver actually comes along */
|
||||
if (!hvc_driver) {
|
||||
int err = hvc_init();
|
||||
if (err)
|
||||
return ERR_PTR(err);
|
||||
}
|
||||
|
||||
hp = kzalloc(ALIGN(sizeof(*hp), sizeof(long)) + outbuf_size,
|
||||
GFP_KERNEL);
|
||||
if (!hp)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
hp->vtermno = vtermno;
|
||||
hp->data = data;
|
||||
hp->ops = ops;
|
||||
hp->outbuf_size = outbuf_size;
|
||||
hp->outbuf = &((char *)hp)[ALIGN(sizeof(*hp), sizeof(long))];
|
||||
|
||||
kref_init(&hp->kref);
|
||||
|
||||
INIT_WORK(&hp->tty_resize, hvc_set_winsz);
|
||||
spin_lock_init(&hp->lock);
|
||||
spin_lock(&hvc_structs_lock);
|
||||
|
||||
/*
|
||||
* find index to use:
|
||||
* see if this vterm id matches one registered for console.
|
||||
*/
|
||||
for (i=0; i < MAX_NR_HVC_CONSOLES; i++)
|
||||
if (vtermnos[i] == hp->vtermno &&
|
||||
cons_ops[i] == hp->ops)
|
||||
break;
|
||||
|
||||
/* no matching slot, just use a counter */
|
||||
if (i >= MAX_NR_HVC_CONSOLES)
|
||||
i = ++last_hvc;
|
||||
|
||||
hp->index = i;
|
||||
|
||||
list_add_tail(&(hp->next), &hvc_structs);
|
||||
spin_unlock(&hvc_structs_lock);
|
||||
|
||||
return hp;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(hvc_alloc);
|
||||
|
||||
int hvc_remove(struct hvc_struct *hp)
|
||||
{
|
||||
unsigned long flags;
|
||||
struct tty_struct *tty;
|
||||
|
||||
spin_lock_irqsave(&hp->lock, flags);
|
||||
tty = tty_kref_get(hp->tty);
|
||||
|
||||
if (hp->index < MAX_NR_HVC_CONSOLES)
|
||||
vtermnos[hp->index] = -1;
|
||||
|
||||
/* Don't whack hp->irq because tty_hangup() will need to free the irq. */
|
||||
|
||||
spin_unlock_irqrestore(&hp->lock, flags);
|
||||
|
||||
/*
|
||||
* We 'put' the instance that was grabbed when the kref instance
|
||||
* was initialized using kref_init(). Let the last holder of this
|
||||
* kref cause it to be removed, which will probably be the tty_vhangup
|
||||
* below.
|
||||
*/
|
||||
kref_put(&hp->kref, destroy_hvc_struct);
|
||||
|
||||
/*
|
||||
* This function call will auto chain call hvc_hangup.
|
||||
*/
|
||||
if (tty) {
|
||||
tty_vhangup(tty);
|
||||
tty_kref_put(tty);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(hvc_remove);
|
||||
|
||||
/* Driver initialization: called as soon as someone uses hvc_alloc(). */
|
||||
static int hvc_init(void)
|
||||
{
|
||||
struct tty_driver *drv;
|
||||
int err;
|
||||
|
||||
/* We need more than hvc_count adapters due to hotplug additions. */
|
||||
drv = alloc_tty_driver(HVC_ALLOC_TTY_ADAPTERS);
|
||||
if (!drv) {
|
||||
err = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
drv->owner = THIS_MODULE;
|
||||
drv->driver_name = "hvc";
|
||||
drv->name = "hvc";
|
||||
drv->major = HVC_MAJOR;
|
||||
drv->minor_start = HVC_MINOR;
|
||||
drv->type = TTY_DRIVER_TYPE_SYSTEM;
|
||||
drv->init_termios = tty_std_termios;
|
||||
drv->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS;
|
||||
tty_set_operations(drv, &hvc_ops);
|
||||
|
||||
/* Always start the kthread because there can be hotplug vty adapters
|
||||
* added later. */
|
||||
hvc_task = kthread_run(khvcd, NULL, "khvcd");
|
||||
if (IS_ERR(hvc_task)) {
|
||||
printk(KERN_ERR "Couldn't create kthread for console.\n");
|
||||
err = PTR_ERR(hvc_task);
|
||||
goto put_tty;
|
||||
}
|
||||
|
||||
err = tty_register_driver(drv);
|
||||
if (err) {
|
||||
printk(KERN_ERR "Couldn't register hvc console driver\n");
|
||||
goto stop_thread;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make sure tty is fully registered before allowing it to be
|
||||
* found by hvc_console_device.
|
||||
*/
|
||||
smp_mb();
|
||||
hvc_driver = drv;
|
||||
return 0;
|
||||
|
||||
stop_thread:
|
||||
kthread_stop(hvc_task);
|
||||
hvc_task = NULL;
|
||||
put_tty:
|
||||
put_tty_driver(drv);
|
||||
out:
|
||||
return err;
|
||||
}
|
||||
|
||||
/* This isn't particularly necessary due to this being a console driver
|
||||
* but it is nice to be thorough.
|
||||
*/
|
||||
static void __exit hvc_exit(void)
|
||||
{
|
||||
if (hvc_driver) {
|
||||
kthread_stop(hvc_task);
|
||||
|
||||
tty_unregister_driver(hvc_driver);
|
||||
/* return tty_struct instances allocated in hvc_init(). */
|
||||
put_tty_driver(hvc_driver);
|
||||
unregister_console(&hvc_console);
|
||||
}
|
||||
}
|
||||
module_exit(hvc_exit);
|
||||
119
drivers/tty/hvc/hvc_console.h
Normal file
119
drivers/tty/hvc/hvc_console.h
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* hvc_console.h
|
||||
* Copyright (C) 2005 IBM Corporation
|
||||
*
|
||||
* Author(s):
|
||||
* Ryan S. Arnold <rsa@us.ibm.com>
|
||||
*
|
||||
* hvc_console header information:
|
||||
* moved here from arch/powerpc/include/asm/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/kref.h>
|
||||
#include <linux/tty.h>
|
||||
#include <linux/spinlock.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
|
||||
|
||||
/*
|
||||
* The Linux TTY code does not support dynamic addition of tty derived devices
|
||||
* so we need to know how many tty devices we might need when space is allocated
|
||||
* for the tty device. Since this driver supports hotplug of vty adapters we
|
||||
* need to make sure we have enough allocated.
|
||||
*/
|
||||
#define HVC_ALLOC_TTY_ADAPTERS 8
|
||||
|
||||
struct hvc_struct {
|
||||
spinlock_t lock;
|
||||
int index;
|
||||
struct tty_struct *tty;
|
||||
int count;
|
||||
int do_wakeup;
|
||||
char *outbuf;
|
||||
int outbuf_size;
|
||||
int n_outbuf;
|
||||
uint32_t vtermno;
|
||||
const struct hv_ops *ops;
|
||||
int irq_requested;
|
||||
int data;
|
||||
struct winsize ws;
|
||||
struct work_struct tty_resize;
|
||||
struct list_head next;
|
||||
struct kref kref; /* ref count & hvc_struct lifetime */
|
||||
};
|
||||
|
||||
/* 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);
|
||||
|
||||
/* Callbacks for notification. Called in open, close and hangup */
|
||||
int (*notifier_add)(struct hvc_struct *hp, int irq);
|
||||
void (*notifier_del)(struct hvc_struct *hp, int irq);
|
||||
void (*notifier_hangup)(struct hvc_struct *hp, int irq);
|
||||
};
|
||||
|
||||
/* Register a vterm and a slot index for use as a console (console_init) */
|
||||
extern int hvc_instantiate(uint32_t vtermno, int index,
|
||||
const struct hv_ops *ops);
|
||||
|
||||
/* register a vterm for hvc tty operation (module_init or hotplug add) */
|
||||
extern struct hvc_struct * hvc_alloc(uint32_t vtermno, int data,
|
||||
const struct hv_ops *ops, int outbuf_size);
|
||||
/* remove a vterm from hvc tty operation (module_exit or hotplug remove) */
|
||||
extern int hvc_remove(struct hvc_struct *hp);
|
||||
|
||||
/* data available */
|
||||
int hvc_poll(struct hvc_struct *hp);
|
||||
void hvc_kick(void);
|
||||
|
||||
/* Resize hvc tty terminal window */
|
||||
extern void __hvc_resize(struct hvc_struct *hp, struct winsize ws);
|
||||
|
||||
static inline void hvc_resize(struct hvc_struct *hp, struct winsize ws)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&hp->lock, flags);
|
||||
__hvc_resize(hp, ws);
|
||||
spin_unlock_irqrestore(&hp->lock, flags);
|
||||
}
|
||||
|
||||
/* default notifier for irq based notification */
|
||||
extern int notifier_add_irq(struct hvc_struct *hp, int data);
|
||||
extern void notifier_del_irq(struct hvc_struct *hp, int data);
|
||||
extern void notifier_hangup_irq(struct hvc_struct *hp, int data);
|
||||
|
||||
|
||||
#if defined(CONFIG_XMON) && defined(CONFIG_SMP)
|
||||
#include <asm/xmon.h>
|
||||
#else
|
||||
static inline int cpus_are_in_xmon(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // HVC_CONSOLE_H
|
||||
133
drivers/tty/hvc/hvc_dcc.c
Normal file
133
drivers/tty/hvc/hvc_dcc.c
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
* only version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <linux/console.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
#include <asm/processor.h>
|
||||
|
||||
#include "hvc_console.h"
|
||||
|
||||
/* DCC Status Bits */
|
||||
#define DCC_STATUS_RX (1 << 30)
|
||||
#define DCC_STATUS_TX (1 << 29)
|
||||
|
||||
static inline u32 __dcc_getstatus(void)
|
||||
{
|
||||
u32 __ret;
|
||||
|
||||
asm("mrc p14, 0, %0, c0, c1, 0 @ read comms ctrl reg"
|
||||
: "=r" (__ret) : : "cc");
|
||||
|
||||
return __ret;
|
||||
}
|
||||
|
||||
|
||||
#if defined(CONFIG_CPU_V7)
|
||||
static inline char __dcc_getchar(void)
|
||||
{
|
||||
char __c;
|
||||
|
||||
asm("get_wait: mrc p14, 0, pc, c0, c1, 0 \n\
|
||||
bne get_wait \n\
|
||||
mrc p14, 0, %0, c0, c5, 0 @ read comms data reg"
|
||||
: "=r" (__c) : : "cc");
|
||||
|
||||
return __c;
|
||||
}
|
||||
#else
|
||||
static inline char __dcc_getchar(void)
|
||||
{
|
||||
char __c;
|
||||
|
||||
asm("mrc p14, 0, %0, c0, c5, 0 @ read comms data reg"
|
||||
: "=r" (__c));
|
||||
|
||||
return __c;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_CPU_V7)
|
||||
static inline void __dcc_putchar(char c)
|
||||
{
|
||||
asm("put_wait: mrc p14, 0, pc, c0, c1, 0 \n\
|
||||
bcs put_wait \n\
|
||||
mcr p14, 0, %0, c0, c5, 0 "
|
||||
: : "r" (c) : "cc");
|
||||
}
|
||||
#else
|
||||
static inline void __dcc_putchar(char c)
|
||||
{
|
||||
asm("mcr p14, 0, %0, c0, c5, 0 @ write a char"
|
||||
: /* no output register */
|
||||
: "r" (c));
|
||||
}
|
||||
#endif
|
||||
|
||||
static int hvc_dcc_put_chars(uint32_t vt, const char *buf, int count)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
while (__dcc_getstatus() & DCC_STATUS_TX)
|
||||
cpu_relax();
|
||||
|
||||
__dcc_putchar((char)(buf[i] & 0xFF));
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static int hvc_dcc_get_chars(uint32_t vt, char *buf, int count)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
int c = -1;
|
||||
|
||||
if (__dcc_getstatus() & DCC_STATUS_RX)
|
||||
c = __dcc_getchar();
|
||||
if (c < 0)
|
||||
break;
|
||||
buf[i] = c;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static const struct hv_ops hvc_dcc_get_put_ops = {
|
||||
.get_chars = hvc_dcc_get_chars,
|
||||
.put_chars = hvc_dcc_put_chars,
|
||||
};
|
||||
|
||||
static int __init hvc_dcc_console_init(void)
|
||||
{
|
||||
hvc_instantiate(0, 0, &hvc_dcc_get_put_ops);
|
||||
return 0;
|
||||
}
|
||||
console_initcall(hvc_dcc_console_init);
|
||||
|
||||
static int __init hvc_dcc_init(void)
|
||||
{
|
||||
hvc_alloc(0, 0, &hvc_dcc_get_put_ops, 128);
|
||||
return 0;
|
||||
}
|
||||
device_initcall(hvc_dcc_init);
|
||||
49
drivers/tty/hvc/hvc_irq.c
Normal file
49
drivers/tty/hvc/hvc_irq.c
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright IBM Corp. 2001,2008
|
||||
*
|
||||
* This file contains the IRQ specific code for hvc_console
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/interrupt.h>
|
||||
|
||||
#include "hvc_console.h"
|
||||
|
||||
static irqreturn_t hvc_handle_interrupt(int irq, void *dev_instance)
|
||||
{
|
||||
/* if hvc_poll request a repoll, then kick the hvcd thread */
|
||||
if (hvc_poll(dev_instance))
|
||||
hvc_kick();
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
/*
|
||||
* For IRQ based systems these callbacks can be used
|
||||
*/
|
||||
int notifier_add_irq(struct hvc_struct *hp, int irq)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (!irq) {
|
||||
hp->irq_requested = 0;
|
||||
return 0;
|
||||
}
|
||||
rc = request_irq(irq, hvc_handle_interrupt, IRQF_DISABLED,
|
||||
"hvc_console", hp);
|
||||
if (!rc)
|
||||
hp->irq_requested = 1;
|
||||
return rc;
|
||||
}
|
||||
|
||||
void notifier_del_irq(struct hvc_struct *hp, int irq)
|
||||
{
|
||||
if (!hp->irq_requested)
|
||||
return;
|
||||
free_irq(irq, hp);
|
||||
hp->irq_requested = 0;
|
||||
}
|
||||
|
||||
void notifier_hangup_irq(struct hvc_struct *hp, int irq)
|
||||
{
|
||||
notifier_del_irq(hp, irq);
|
||||
}
|
||||
598
drivers/tty/hvc/hvc_iseries.c
Normal file
598
drivers/tty/hvc/hvc_iseries.c
Normal file
|
|
@ -0,0 +1,598 @@
|
|||
/*
|
||||
* iSeries vio driver interface to hvc_console.c
|
||||
*
|
||||
* This code is based heavily on hvc_vio.c and viocons.c
|
||||
*
|
||||
* Copyright (C) 2006 Stephen Rothwell, IBM Corporation
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
#include <stdarg.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/console.h>
|
||||
|
||||
#include <asm/hvconsole.h>
|
||||
#include <asm/vio.h>
|
||||
#include <asm/prom.h>
|
||||
#include <asm/firmware.h>
|
||||
#include <asm/iseries/vio.h>
|
||||
#include <asm/iseries/hv_call.h>
|
||||
#include <asm/iseries/hv_lp_config.h>
|
||||
#include <asm/iseries/hv_lp_event.h>
|
||||
|
||||
#include "hvc_console.h"
|
||||
|
||||
#define VTTY_PORTS 10
|
||||
|
||||
static DEFINE_SPINLOCK(consolelock);
|
||||
static DEFINE_SPINLOCK(consoleloglock);
|
||||
|
||||
static const char hvc_driver_name[] = "hvc_console";
|
||||
|
||||
#define IN_BUF_SIZE 200
|
||||
|
||||
/*
|
||||
* Our port information.
|
||||
*/
|
||||
static struct port_info {
|
||||
HvLpIndex lp;
|
||||
u64 seq; /* sequence number of last HV send */
|
||||
u64 ack; /* last ack from HV */
|
||||
struct hvc_struct *hp;
|
||||
int in_start;
|
||||
int in_end;
|
||||
unsigned char in_buf[IN_BUF_SIZE];
|
||||
} port_info[VTTY_PORTS] = {
|
||||
[ 0 ... VTTY_PORTS - 1 ] = {
|
||||
.lp = HvLpIndexInvalid
|
||||
}
|
||||
};
|
||||
|
||||
#define viochar_is_console(pi) ((pi) == &port_info[0])
|
||||
|
||||
static struct vio_device_id hvc_driver_table[] __devinitdata = {
|
||||
{"serial", "IBM,iSeries-vty"},
|
||||
{ "", "" }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(vio, hvc_driver_table);
|
||||
|
||||
static void hvlog(char *fmt, ...)
|
||||
{
|
||||
int i;
|
||||
unsigned long flags;
|
||||
va_list args;
|
||||
static char buf[256];
|
||||
|
||||
spin_lock_irqsave(&consoleloglock, flags);
|
||||
va_start(args, fmt);
|
||||
i = vscnprintf(buf, sizeof(buf) - 1, fmt, args);
|
||||
va_end(args);
|
||||
buf[i++] = '\r';
|
||||
HvCall_writeLogBuffer(buf, i);
|
||||
spin_unlock_irqrestore(&consoleloglock, flags);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the common fields in a charLpEvent
|
||||
*/
|
||||
static void init_data_event(struct viocharlpevent *viochar, HvLpIndex lp)
|
||||
{
|
||||
struct HvLpEvent *hev = &viochar->event;
|
||||
|
||||
memset(viochar, 0, sizeof(struct viocharlpevent));
|
||||
|
||||
hev->flags = HV_LP_EVENT_VALID | HV_LP_EVENT_DEFERRED_ACK |
|
||||
HV_LP_EVENT_INT;
|
||||
hev->xType = HvLpEvent_Type_VirtualIo;
|
||||
hev->xSubtype = viomajorsubtype_chario | viochardata;
|
||||
hev->xSourceLp = HvLpConfig_getLpIndex();
|
||||
hev->xTargetLp = lp;
|
||||
hev->xSizeMinus1 = sizeof(struct viocharlpevent);
|
||||
hev->xSourceInstanceId = viopath_sourceinst(lp);
|
||||
hev->xTargetInstanceId = viopath_targetinst(lp);
|
||||
}
|
||||
|
||||
static int get_chars(uint32_t vtermno, char *buf, int count)
|
||||
{
|
||||
struct port_info *pi;
|
||||
int n = 0;
|
||||
unsigned long flags;
|
||||
|
||||
if (vtermno >= VTTY_PORTS)
|
||||
return -EINVAL;
|
||||
if (count == 0)
|
||||
return 0;
|
||||
|
||||
pi = &port_info[vtermno];
|
||||
spin_lock_irqsave(&consolelock, flags);
|
||||
|
||||
if (pi->in_end == 0)
|
||||
goto done;
|
||||
|
||||
n = pi->in_end - pi->in_start;
|
||||
if (n > count)
|
||||
n = count;
|
||||
memcpy(buf, &pi->in_buf[pi->in_start], n);
|
||||
pi->in_start += n;
|
||||
if (pi->in_start == pi->in_end) {
|
||||
pi->in_start = 0;
|
||||
pi->in_end = 0;
|
||||
}
|
||||
done:
|
||||
spin_unlock_irqrestore(&consolelock, flags);
|
||||
return n;
|
||||
}
|
||||
|
||||
static int put_chars(uint32_t vtermno, const char *buf, int count)
|
||||
{
|
||||
struct viocharlpevent *viochar;
|
||||
struct port_info *pi;
|
||||
HvLpEvent_Rc hvrc;
|
||||
unsigned long flags;
|
||||
int sent = 0;
|
||||
|
||||
if (vtermno >= VTTY_PORTS)
|
||||
return -EINVAL;
|
||||
|
||||
pi = &port_info[vtermno];
|
||||
|
||||
spin_lock_irqsave(&consolelock, flags);
|
||||
|
||||
if (viochar_is_console(pi) && !viopath_isactive(pi->lp)) {
|
||||
HvCall_writeLogBuffer(buf, count);
|
||||
sent = count;
|
||||
goto done;
|
||||
}
|
||||
|
||||
viochar = vio_get_event_buffer(viomajorsubtype_chario);
|
||||
if (viochar == NULL) {
|
||||
hvlog("\n\rviocons: Can't get viochar buffer.");
|
||||
goto done;
|
||||
}
|
||||
|
||||
while ((count > 0) && ((pi->seq - pi->ack) < VIOCHAR_WINDOW)) {
|
||||
int len;
|
||||
|
||||
len = (count > VIOCHAR_MAX_DATA) ? VIOCHAR_MAX_DATA : count;
|
||||
|
||||
if (viochar_is_console(pi))
|
||||
HvCall_writeLogBuffer(buf, len);
|
||||
|
||||
init_data_event(viochar, pi->lp);
|
||||
|
||||
viochar->len = len;
|
||||
viochar->event.xCorrelationToken = pi->seq++;
|
||||
viochar->event.xSizeMinus1 =
|
||||
offsetof(struct viocharlpevent, data) + len;
|
||||
|
||||
memcpy(viochar->data, buf, len);
|
||||
|
||||
hvrc = HvCallEvent_signalLpEvent(&viochar->event);
|
||||
if (hvrc)
|
||||
hvlog("\n\rerror sending event! return code %d\n\r",
|
||||
(int)hvrc);
|
||||
sent += len;
|
||||
count -= len;
|
||||
buf += len;
|
||||
}
|
||||
|
||||
vio_free_event_buffer(viomajorsubtype_chario, viochar);
|
||||
done:
|
||||
spin_unlock_irqrestore(&consolelock, flags);
|
||||
return sent;
|
||||
}
|
||||
|
||||
static const struct hv_ops hvc_get_put_ops = {
|
||||
.get_chars = get_chars,
|
||||
.put_chars = put_chars,
|
||||
.notifier_add = notifier_add_irq,
|
||||
.notifier_del = notifier_del_irq,
|
||||
.notifier_hangup = notifier_hangup_irq,
|
||||
};
|
||||
|
||||
static int __devinit hvc_vio_probe(struct vio_dev *vdev,
|
||||
const struct vio_device_id *id)
|
||||
{
|
||||
struct hvc_struct *hp;
|
||||
struct port_info *pi;
|
||||
|
||||
/* probed with invalid parameters. */
|
||||
if (!vdev || !id)
|
||||
return -EPERM;
|
||||
|
||||
if (vdev->unit_address >= VTTY_PORTS)
|
||||
return -ENODEV;
|
||||
|
||||
pi = &port_info[vdev->unit_address];
|
||||
|
||||
hp = hvc_alloc(vdev->unit_address, vdev->irq, &hvc_get_put_ops,
|
||||
VIOCHAR_MAX_DATA);
|
||||
if (IS_ERR(hp))
|
||||
return PTR_ERR(hp);
|
||||
pi->hp = hp;
|
||||
dev_set_drvdata(&vdev->dev, pi);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __devexit hvc_vio_remove(struct vio_dev *vdev)
|
||||
{
|
||||
struct port_info *pi = dev_get_drvdata(&vdev->dev);
|
||||
struct hvc_struct *hp = pi->hp;
|
||||
|
||||
return hvc_remove(hp);
|
||||
}
|
||||
|
||||
static struct vio_driver hvc_vio_driver = {
|
||||
.id_table = hvc_driver_table,
|
||||
.probe = hvc_vio_probe,
|
||||
.remove = __devexit_p(hvc_vio_remove),
|
||||
.driver = {
|
||||
.name = hvc_driver_name,
|
||||
.owner = THIS_MODULE,
|
||||
}
|
||||
};
|
||||
|
||||
static void hvc_open_event(struct HvLpEvent *event)
|
||||
{
|
||||
unsigned long flags;
|
||||
struct viocharlpevent *cevent = (struct viocharlpevent *)event;
|
||||
u8 port = cevent->virtual_device;
|
||||
struct port_info *pi;
|
||||
int reject = 0;
|
||||
|
||||
if (hvlpevent_is_ack(event)) {
|
||||
if (port >= VTTY_PORTS)
|
||||
return;
|
||||
|
||||
spin_lock_irqsave(&consolelock, flags);
|
||||
|
||||
pi = &port_info[port];
|
||||
if (event->xRc == HvLpEvent_Rc_Good) {
|
||||
pi->seq = pi->ack = 0;
|
||||
/*
|
||||
* This line allows connections from the primary
|
||||
* partition but once one is connected from the
|
||||
* primary partition nothing short of a reboot
|
||||
* of linux will allow access from the hosting
|
||||
* partition again without a required iSeries fix.
|
||||
*/
|
||||
pi->lp = event->xTargetLp;
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&consolelock, flags);
|
||||
if (event->xRc != HvLpEvent_Rc_Good)
|
||||
printk(KERN_WARNING
|
||||
"hvc: handle_open_event: event->xRc == (%d).\n",
|
||||
event->xRc);
|
||||
|
||||
if (event->xCorrelationToken != 0) {
|
||||
atomic_t *aptr= (atomic_t *)event->xCorrelationToken;
|
||||
atomic_set(aptr, 1);
|
||||
} else
|
||||
printk(KERN_WARNING
|
||||
"hvc: weird...got open ack without atomic\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* This had better require an ack, otherwise complain */
|
||||
if (!hvlpevent_need_ack(event)) {
|
||||
printk(KERN_WARNING "hvc: viocharopen without ack bit!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
spin_lock_irqsave(&consolelock, flags);
|
||||
|
||||
/* Make sure this is a good virtual tty */
|
||||
if (port >= VTTY_PORTS) {
|
||||
event->xRc = HvLpEvent_Rc_SubtypeError;
|
||||
cevent->subtype_result_code = viorc_openRejected;
|
||||
/*
|
||||
* Flag state here since we can't printk while holding
|
||||
* the consolelock spinlock.
|
||||
*/
|
||||
reject = 1;
|
||||
} else {
|
||||
pi = &port_info[port];
|
||||
if ((pi->lp != HvLpIndexInvalid) &&
|
||||
(pi->lp != event->xSourceLp)) {
|
||||
/*
|
||||
* If this is tty is already connected to a different
|
||||
* partition, fail.
|
||||
*/
|
||||
event->xRc = HvLpEvent_Rc_SubtypeError;
|
||||
cevent->subtype_result_code = viorc_openRejected;
|
||||
reject = 2;
|
||||
} else {
|
||||
pi->lp = event->xSourceLp;
|
||||
event->xRc = HvLpEvent_Rc_Good;
|
||||
cevent->subtype_result_code = viorc_good;
|
||||
pi->seq = pi->ack = 0;
|
||||
}
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&consolelock, flags);
|
||||
|
||||
if (reject == 1)
|
||||
printk(KERN_WARNING "hvc: open rejected: bad virtual tty.\n");
|
||||
else if (reject == 2)
|
||||
printk(KERN_WARNING "hvc: open rejected: console in exclusive "
|
||||
"use by another partition.\n");
|
||||
|
||||
/* Return the acknowledgement */
|
||||
HvCallEvent_ackLpEvent(event);
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle a close charLpEvent. This should ONLY be an Interrupt because the
|
||||
* virtual console should never actually issue a close event to the hypervisor
|
||||
* because the virtual console never goes away. A close event coming from the
|
||||
* hypervisor simply means that there are no client consoles connected to the
|
||||
* virtual console.
|
||||
*/
|
||||
static void hvc_close_event(struct HvLpEvent *event)
|
||||
{
|
||||
unsigned long flags;
|
||||
struct viocharlpevent *cevent = (struct viocharlpevent *)event;
|
||||
u8 port = cevent->virtual_device;
|
||||
|
||||
if (!hvlpevent_is_int(event)) {
|
||||
printk(KERN_WARNING
|
||||
"hvc: got unexpected close acknowledgement\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (port >= VTTY_PORTS) {
|
||||
printk(KERN_WARNING
|
||||
"hvc: close message from invalid virtual device.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* For closes, just mark the console partition invalid */
|
||||
spin_lock_irqsave(&consolelock, flags);
|
||||
|
||||
if (port_info[port].lp == event->xSourceLp)
|
||||
port_info[port].lp = HvLpIndexInvalid;
|
||||
|
||||
spin_unlock_irqrestore(&consolelock, flags);
|
||||
}
|
||||
|
||||
static void hvc_data_event(struct HvLpEvent *event)
|
||||
{
|
||||
unsigned long flags;
|
||||
struct viocharlpevent *cevent = (struct viocharlpevent *)event;
|
||||
struct port_info *pi;
|
||||
int n;
|
||||
u8 port = cevent->virtual_device;
|
||||
|
||||
if (port >= VTTY_PORTS) {
|
||||
printk(KERN_WARNING "hvc: data on invalid virtual device %d\n",
|
||||
port);
|
||||
return;
|
||||
}
|
||||
if (cevent->len == 0)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Change 05/01/2003 - Ryan Arnold: If a partition other than
|
||||
* the current exclusive partition tries to send us data
|
||||
* events then just drop them on the floor because we don't
|
||||
* want his stinking data. He isn't authorized to receive
|
||||
* data because he wasn't the first one to get the console,
|
||||
* therefore he shouldn't be allowed to send data either.
|
||||
* This will work without an iSeries fix.
|
||||
*/
|
||||
pi = &port_info[port];
|
||||
if (pi->lp != event->xSourceLp)
|
||||
return;
|
||||
|
||||
spin_lock_irqsave(&consolelock, flags);
|
||||
|
||||
n = IN_BUF_SIZE - pi->in_end;
|
||||
if (n > cevent->len)
|
||||
n = cevent->len;
|
||||
if (n > 0) {
|
||||
memcpy(&pi->in_buf[pi->in_end], cevent->data, n);
|
||||
pi->in_end += n;
|
||||
}
|
||||
spin_unlock_irqrestore(&consolelock, flags);
|
||||
if (n == 0)
|
||||
printk(KERN_WARNING "hvc: input buffer overflow\n");
|
||||
}
|
||||
|
||||
static void hvc_ack_event(struct HvLpEvent *event)
|
||||
{
|
||||
struct viocharlpevent *cevent = (struct viocharlpevent *)event;
|
||||
unsigned long flags;
|
||||
u8 port = cevent->virtual_device;
|
||||
|
||||
if (port >= VTTY_PORTS) {
|
||||
printk(KERN_WARNING "hvc: data on invalid virtual device\n");
|
||||
return;
|
||||
}
|
||||
|
||||
spin_lock_irqsave(&consolelock, flags);
|
||||
port_info[port].ack = event->xCorrelationToken;
|
||||
spin_unlock_irqrestore(&consolelock, flags);
|
||||
}
|
||||
|
||||
static void hvc_config_event(struct HvLpEvent *event)
|
||||
{
|
||||
struct viocharlpevent *cevent = (struct viocharlpevent *)event;
|
||||
|
||||
if (cevent->data[0] == 0x01)
|
||||
printk(KERN_INFO "hvc: window resized to %d: %d: %d: %d\n",
|
||||
cevent->data[1], cevent->data[2],
|
||||
cevent->data[3], cevent->data[4]);
|
||||
else
|
||||
printk(KERN_WARNING "hvc: unknown config event\n");
|
||||
}
|
||||
|
||||
static void hvc_handle_event(struct HvLpEvent *event)
|
||||
{
|
||||
int charminor;
|
||||
|
||||
if (event == NULL)
|
||||
return;
|
||||
|
||||
charminor = event->xSubtype & VIOMINOR_SUBTYPE_MASK;
|
||||
switch (charminor) {
|
||||
case viocharopen:
|
||||
hvc_open_event(event);
|
||||
break;
|
||||
case viocharclose:
|
||||
hvc_close_event(event);
|
||||
break;
|
||||
case viochardata:
|
||||
hvc_data_event(event);
|
||||
break;
|
||||
case viocharack:
|
||||
hvc_ack_event(event);
|
||||
break;
|
||||
case viocharconfig:
|
||||
hvc_config_event(event);
|
||||
break;
|
||||
default:
|
||||
if (hvlpevent_is_int(event) && hvlpevent_need_ack(event)) {
|
||||
event->xRc = HvLpEvent_Rc_InvalidSubtype;
|
||||
HvCallEvent_ackLpEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int __init send_open(HvLpIndex remoteLp, void *sem)
|
||||
{
|
||||
return HvCallEvent_signalLpEventFast(remoteLp,
|
||||
HvLpEvent_Type_VirtualIo,
|
||||
viomajorsubtype_chario | viocharopen,
|
||||
HvLpEvent_AckInd_DoAck, HvLpEvent_AckType_ImmediateAck,
|
||||
viopath_sourceinst(remoteLp),
|
||||
viopath_targetinst(remoteLp),
|
||||
(u64)(unsigned long)sem, VIOVERSION << 16,
|
||||
0, 0, 0, 0);
|
||||
}
|
||||
|
||||
static int __init hvc_vio_init(void)
|
||||
{
|
||||
atomic_t wait_flag;
|
||||
int rc;
|
||||
|
||||
if (!firmware_has_feature(FW_FEATURE_ISERIES))
|
||||
return -EIO;
|
||||
|
||||
/* +2 for fudge */
|
||||
rc = viopath_open(HvLpConfig_getPrimaryLpIndex(),
|
||||
viomajorsubtype_chario, VIOCHAR_WINDOW + 2);
|
||||
if (rc)
|
||||
printk(KERN_WARNING "hvc: error opening to primary %d\n", rc);
|
||||
|
||||
if (viopath_hostLp == HvLpIndexInvalid)
|
||||
vio_set_hostlp();
|
||||
|
||||
/*
|
||||
* And if the primary is not the same as the hosting LP, open to the
|
||||
* hosting lp
|
||||
*/
|
||||
if ((viopath_hostLp != HvLpIndexInvalid) &&
|
||||
(viopath_hostLp != HvLpConfig_getPrimaryLpIndex())) {
|
||||
printk(KERN_INFO "hvc: open path to hosting (%d)\n",
|
||||
viopath_hostLp);
|
||||
rc = viopath_open(viopath_hostLp, viomajorsubtype_chario,
|
||||
VIOCHAR_WINDOW + 2); /* +2 for fudge */
|
||||
if (rc)
|
||||
printk(KERN_WARNING
|
||||
"error opening to partition %d: %d\n",
|
||||
viopath_hostLp, rc);
|
||||
}
|
||||
|
||||
if (vio_setHandler(viomajorsubtype_chario, hvc_handle_event) < 0)
|
||||
printk(KERN_WARNING
|
||||
"hvc: error seting handler for console events!\n");
|
||||
|
||||
/*
|
||||
* First, try to open the console to the hosting lp.
|
||||
* Wait on a semaphore for the response.
|
||||
*/
|
||||
atomic_set(&wait_flag, 0);
|
||||
if ((viopath_isactive(viopath_hostLp)) &&
|
||||
(send_open(viopath_hostLp, &wait_flag) == 0)) {
|
||||
printk(KERN_INFO "hvc: hosting partition %d\n", viopath_hostLp);
|
||||
while (atomic_read(&wait_flag) == 0)
|
||||
mb();
|
||||
atomic_set(&wait_flag, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If we don't have an active console, try the primary
|
||||
*/
|
||||
if ((!viopath_isactive(port_info[0].lp)) &&
|
||||
(viopath_isactive(HvLpConfig_getPrimaryLpIndex())) &&
|
||||
(send_open(HvLpConfig_getPrimaryLpIndex(), &wait_flag) == 0)) {
|
||||
printk(KERN_INFO "hvc: opening console to primary partition\n");
|
||||
while (atomic_read(&wait_flag) == 0)
|
||||
mb();
|
||||
}
|
||||
|
||||
/* Register as a vio device to receive callbacks */
|
||||
rc = vio_register_driver(&hvc_vio_driver);
|
||||
|
||||
return rc;
|
||||
}
|
||||
module_init(hvc_vio_init); /* after drivers/char/hvc_console.c */
|
||||
|
||||
static void __exit hvc_vio_exit(void)
|
||||
{
|
||||
vio_unregister_driver(&hvc_vio_driver);
|
||||
}
|
||||
module_exit(hvc_vio_exit);
|
||||
|
||||
/* the device tree order defines our numbering */
|
||||
static int __init hvc_find_vtys(void)
|
||||
{
|
||||
struct device_node *vty;
|
||||
int num_found = 0;
|
||||
|
||||
for (vty = of_find_node_by_name(NULL, "vty"); vty != NULL;
|
||||
vty = of_find_node_by_name(vty, "vty")) {
|
||||
const uint32_t *vtermno;
|
||||
|
||||
/* We have statically defined space for only a certain number
|
||||
* of console adapters.
|
||||
*/
|
||||
if ((num_found >= MAX_NR_HVC_CONSOLES) ||
|
||||
(num_found >= VTTY_PORTS)) {
|
||||
of_node_put(vty);
|
||||
break;
|
||||
}
|
||||
|
||||
vtermno = of_get_property(vty, "reg", NULL);
|
||||
if (!vtermno)
|
||||
continue;
|
||||
|
||||
if (!of_device_is_compatible(vty, "IBM,iSeries-vty"))
|
||||
continue;
|
||||
|
||||
if (num_found == 0)
|
||||
add_preferred_console("hvc", 0, NULL);
|
||||
hvc_instantiate(*vtermno, num_found, &hvc_get_put_ops);
|
||||
++num_found;
|
||||
}
|
||||
|
||||
return num_found;
|
||||
}
|
||||
console_initcall(hvc_find_vtys);
|
||||
1337
drivers/tty/hvc/hvc_iucv.c
Normal file
1337
drivers/tty/hvc/hvc_iucv.c
Normal file
File diff suppressed because it is too large
Load diff
133
drivers/tty/hvc/hvc_rtas.c
Normal file
133
drivers/tty/hvc/hvc_rtas.c
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
/*
|
||||
* IBM RTAS driver interface to hvc_console.c
|
||||
*
|
||||
* (C) Copyright IBM Corporation 2001-2005
|
||||
* (C) Copyright Red Hat, Inc. 2005
|
||||
*
|
||||
* Author(s): Maximino Augilar <IBM STI Design Center>
|
||||
* : Ryan S. Arnold <rsa@us.ibm.com>
|
||||
* : Utz Bacher <utz.bacher@de.ibm.com>
|
||||
* : David Woodhouse <dwmw2@infradead.org>
|
||||
*
|
||||
* inspired by drivers/char/hvc_console.c
|
||||
* written by Anton Blanchard and Paul Mackerras
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <linux/console.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
#include <asm/irq.h>
|
||||
#include <asm/rtas.h>
|
||||
#include "hvc_console.h"
|
||||
|
||||
#define hvc_rtas_cookie 0x67781e15
|
||||
struct hvc_struct *hvc_rtas_dev;
|
||||
|
||||
static int rtascons_put_char_token = RTAS_UNKNOWN_SERVICE;
|
||||
static int rtascons_get_char_token = RTAS_UNKNOWN_SERVICE;
|
||||
|
||||
static inline int hvc_rtas_write_console(uint32_t vtermno, const char *buf,
|
||||
int count)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (rtas_call(rtascons_put_char_token, 1, 1, NULL, buf[i]))
|
||||
break;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static int hvc_rtas_read_console(uint32_t vtermno, char *buf, int count)
|
||||
{
|
||||
int i, c;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (rtas_call(rtascons_get_char_token, 0, 2, &c))
|
||||
break;
|
||||
|
||||
buf[i] = c;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static const struct hv_ops hvc_rtas_get_put_ops = {
|
||||
.get_chars = hvc_rtas_read_console,
|
||||
.put_chars = hvc_rtas_write_console,
|
||||
};
|
||||
|
||||
static int __init hvc_rtas_init(void)
|
||||
{
|
||||
struct hvc_struct *hp;
|
||||
|
||||
if (rtascons_put_char_token == RTAS_UNKNOWN_SERVICE)
|
||||
rtascons_put_char_token = rtas_token("put-term-char");
|
||||
if (rtascons_put_char_token == RTAS_UNKNOWN_SERVICE)
|
||||
return -EIO;
|
||||
|
||||
if (rtascons_get_char_token == RTAS_UNKNOWN_SERVICE)
|
||||
rtascons_get_char_token = rtas_token("get-term-char");
|
||||
if (rtascons_get_char_token == RTAS_UNKNOWN_SERVICE)
|
||||
return -EIO;
|
||||
|
||||
BUG_ON(hvc_rtas_dev);
|
||||
|
||||
/* Allocate an hvc_struct for the console device we instantiated
|
||||
* earlier. Save off hp so that we can return it on exit */
|
||||
hp = hvc_alloc(hvc_rtas_cookie, NO_IRQ, &hvc_rtas_get_put_ops, 16);
|
||||
if (IS_ERR(hp))
|
||||
return PTR_ERR(hp);
|
||||
|
||||
hvc_rtas_dev = hp;
|
||||
|
||||
return 0;
|
||||
}
|
||||
module_init(hvc_rtas_init);
|
||||
|
||||
/* This will tear down the tty portion of the driver */
|
||||
static void __exit hvc_rtas_exit(void)
|
||||
{
|
||||
/* Really the fun isn't over until the worker thread breaks down and
|
||||
* the tty cleans up */
|
||||
if (hvc_rtas_dev)
|
||||
hvc_remove(hvc_rtas_dev);
|
||||
}
|
||||
module_exit(hvc_rtas_exit);
|
||||
|
||||
/* This will happen prior to module init. There is no tty at this time? */
|
||||
static int __init hvc_rtas_console_init(void)
|
||||
{
|
||||
rtascons_put_char_token = rtas_token("put-term-char");
|
||||
if (rtascons_put_char_token == RTAS_UNKNOWN_SERVICE)
|
||||
return -EIO;
|
||||
|
||||
rtascons_get_char_token = rtas_token("get-term-char");
|
||||
if (rtascons_get_char_token == RTAS_UNKNOWN_SERVICE)
|
||||
return -EIO;
|
||||
|
||||
hvc_instantiate(hvc_rtas_cookie, 0, &hvc_rtas_get_put_ops);
|
||||
add_preferred_console("hvc", 0, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
console_initcall(hvc_rtas_console_init);
|
||||
68
drivers/tty/hvc/hvc_tile.c
Normal file
68
drivers/tty/hvc/hvc_tile.c
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Copyright 2010 Tilera Corporation. All Rights Reserved.
|
||||
*
|
||||
* 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, version 2.
|
||||
*
|
||||
* 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, GOOD TITLE or
|
||||
* NON INFRINGEMENT. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* Tilera TILE Processor hypervisor console
|
||||
*/
|
||||
|
||||
#include <linux/console.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
#include <hv/hypervisor.h>
|
||||
|
||||
#include "hvc_console.h"
|
||||
|
||||
static int hvc_tile_put_chars(uint32_t vt, const char *buf, int count)
|
||||
{
|
||||
return hv_console_write((HV_VirtAddr)buf, count);
|
||||
}
|
||||
|
||||
static int hvc_tile_get_chars(uint32_t vt, char *buf, int count)
|
||||
{
|
||||
int i, c;
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
c = hv_console_read_if_ready();
|
||||
if (c < 0)
|
||||
break;
|
||||
buf[i] = c;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static const struct hv_ops hvc_tile_get_put_ops = {
|
||||
.get_chars = hvc_tile_get_chars,
|
||||
.put_chars = hvc_tile_put_chars,
|
||||
};
|
||||
|
||||
static int __init hvc_tile_console_init(void)
|
||||
{
|
||||
extern void disable_early_printk(void);
|
||||
hvc_instantiate(0, 0, &hvc_tile_get_put_ops);
|
||||
add_preferred_console("hvc", 0, NULL);
|
||||
disable_early_printk();
|
||||
return 0;
|
||||
}
|
||||
console_initcall(hvc_tile_console_init);
|
||||
|
||||
static int __init hvc_tile_init(void)
|
||||
{
|
||||
struct hvc_struct *s;
|
||||
s = hvc_alloc(0, 0, &hvc_tile_get_put_ops, 128);
|
||||
return IS_ERR(s) ? PTR_ERR(s) : 0;
|
||||
}
|
||||
device_initcall(hvc_tile_init);
|
||||
96
drivers/tty/hvc/hvc_udbg.c
Normal file
96
drivers/tty/hvc/hvc_udbg.c
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* udbg interface to hvc_console.c
|
||||
*
|
||||
* (C) Copyright David Gibson, IBM Corporation 2008.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <linux/console.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/irq.h>
|
||||
|
||||
#include <asm/udbg.h>
|
||||
|
||||
#include "hvc_console.h"
|
||||
|
||||
struct hvc_struct *hvc_udbg_dev;
|
||||
|
||||
static int hvc_udbg_put(uint32_t vtermno, const char *buf, int count)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
udbg_putc(buf[i]);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static int hvc_udbg_get(uint32_t vtermno, char *buf, int count)
|
||||
{
|
||||
int i, c;
|
||||
|
||||
if (!udbg_getc_poll)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if ((c = udbg_getc_poll()) == -1)
|
||||
break;
|
||||
buf[i] = c;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static const struct hv_ops hvc_udbg_ops = {
|
||||
.get_chars = hvc_udbg_get,
|
||||
.put_chars = hvc_udbg_put,
|
||||
};
|
||||
|
||||
static int __init hvc_udbg_init(void)
|
||||
{
|
||||
struct hvc_struct *hp;
|
||||
|
||||
BUG_ON(hvc_udbg_dev);
|
||||
|
||||
hp = hvc_alloc(0, NO_IRQ, &hvc_udbg_ops, 16);
|
||||
if (IS_ERR(hp))
|
||||
return PTR_ERR(hp);
|
||||
|
||||
hvc_udbg_dev = hp;
|
||||
|
||||
return 0;
|
||||
}
|
||||
module_init(hvc_udbg_init);
|
||||
|
||||
static void __exit hvc_udbg_exit(void)
|
||||
{
|
||||
if (hvc_udbg_dev)
|
||||
hvc_remove(hvc_udbg_dev);
|
||||
}
|
||||
module_exit(hvc_udbg_exit);
|
||||
|
||||
static int __init hvc_udbg_console_init(void)
|
||||
{
|
||||
hvc_instantiate(0, 0, &hvc_udbg_ops);
|
||||
add_preferred_console("hvc", 0, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
console_initcall(hvc_udbg_console_init);
|
||||
173
drivers/tty/hvc/hvc_vio.c
Normal file
173
drivers/tty/hvc/hvc_vio.c
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
/*
|
||||
* vio driver interface to hvc_console.c
|
||||
*
|
||||
* This code was moved here to allow the remaing code to be reused as a
|
||||
* generic polling mode with semi-reliable transport driver core to the
|
||||
* console and tty subsystems.
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2001 Anton Blanchard <anton@au.ibm.com>, IBM
|
||||
* Copyright (C) 2001 Paul Mackerras <paulus@au.ibm.com>, IBM
|
||||
* Copyright (C) 2004 Benjamin Herrenschmidt <benh@kernel.crashing.org>, IBM Corp.
|
||||
* Copyright (C) 2004 IBM Corporation
|
||||
*
|
||||
* Additional Author(s):
|
||||
* Ryan S. Arnold <rsa@us.ibm.com>
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/init.h>
|
||||
|
||||
#include <asm/hvconsole.h>
|
||||
#include <asm/vio.h>
|
||||
#include <asm/prom.h>
|
||||
#include <asm/firmware.h>
|
||||
|
||||
#include "hvc_console.h"
|
||||
|
||||
static const char hvc_driver_name[] = "hvc_console";
|
||||
|
||||
static struct vio_device_id hvc_driver_table[] __devinitdata = {
|
||||
{"serial", "hvterm1"},
|
||||
{ "", "" }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(vio, hvc_driver_table);
|
||||
|
||||
static int filtered_get_chars(uint32_t vtermno, char *buf, int count)
|
||||
{
|
||||
unsigned long got;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* Vio firmware will read up to SIZE_VIO_GET_CHARS at its own discretion
|
||||
* so we play safe and avoid the situation where got > count which could
|
||||
* overload the flip buffer.
|
||||
*/
|
||||
if (count < SIZE_VIO_GET_CHARS)
|
||||
return -EAGAIN;
|
||||
|
||||
got = hvc_get_chars(vtermno, buf, count);
|
||||
|
||||
/*
|
||||
* Work around a HV bug where it gives us a null
|
||||
* after every \r. -- paulus
|
||||
*/
|
||||
for (i = 1; i < got; ++i) {
|
||||
if (buf[i] == 0 && buf[i-1] == '\r') {
|
||||
--got;
|
||||
if (i < got)
|
||||
memmove(&buf[i], &buf[i+1],
|
||||
got - i);
|
||||
}
|
||||
}
|
||||
return got;
|
||||
}
|
||||
|
||||
static const struct hv_ops hvc_get_put_ops = {
|
||||
.get_chars = filtered_get_chars,
|
||||
.put_chars = hvc_put_chars,
|
||||
.notifier_add = notifier_add_irq,
|
||||
.notifier_del = notifier_del_irq,
|
||||
.notifier_hangup = notifier_hangup_irq,
|
||||
};
|
||||
|
||||
static int __devinit hvc_vio_probe(struct vio_dev *vdev,
|
||||
const struct vio_device_id *id)
|
||||
{
|
||||
struct hvc_struct *hp;
|
||||
|
||||
/* probed with invalid parameters. */
|
||||
if (!vdev || !id)
|
||||
return -EPERM;
|
||||
|
||||
hp = hvc_alloc(vdev->unit_address, vdev->irq, &hvc_get_put_ops,
|
||||
MAX_VIO_PUT_CHARS);
|
||||
if (IS_ERR(hp))
|
||||
return PTR_ERR(hp);
|
||||
dev_set_drvdata(&vdev->dev, hp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __devexit hvc_vio_remove(struct vio_dev *vdev)
|
||||
{
|
||||
struct hvc_struct *hp = dev_get_drvdata(&vdev->dev);
|
||||
|
||||
return hvc_remove(hp);
|
||||
}
|
||||
|
||||
static struct vio_driver hvc_vio_driver = {
|
||||
.id_table = hvc_driver_table,
|
||||
.probe = hvc_vio_probe,
|
||||
.remove = __devexit_p(hvc_vio_remove),
|
||||
.driver = {
|
||||
.name = hvc_driver_name,
|
||||
.owner = THIS_MODULE,
|
||||
}
|
||||
};
|
||||
|
||||
static int __init hvc_vio_init(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (firmware_has_feature(FW_FEATURE_ISERIES))
|
||||
return -EIO;
|
||||
|
||||
/* Register as a vio device to receive callbacks */
|
||||
rc = vio_register_driver(&hvc_vio_driver);
|
||||
|
||||
return rc;
|
||||
}
|
||||
module_init(hvc_vio_init); /* after drivers/char/hvc_console.c */
|
||||
|
||||
static void __exit hvc_vio_exit(void)
|
||||
{
|
||||
vio_unregister_driver(&hvc_vio_driver);
|
||||
}
|
||||
module_exit(hvc_vio_exit);
|
||||
|
||||
/* the device tree order defines our numbering */
|
||||
static int hvc_find_vtys(void)
|
||||
{
|
||||
struct device_node *vty;
|
||||
int num_found = 0;
|
||||
|
||||
for (vty = of_find_node_by_name(NULL, "vty"); vty != NULL;
|
||||
vty = of_find_node_by_name(vty, "vty")) {
|
||||
const uint32_t *vtermno;
|
||||
|
||||
/* We have statically defined space for only a certain number
|
||||
* of console adapters.
|
||||
*/
|
||||
if (num_found >= MAX_NR_HVC_CONSOLES) {
|
||||
of_node_put(vty);
|
||||
break;
|
||||
}
|
||||
|
||||
vtermno = of_get_property(vty, "reg", NULL);
|
||||
if (!vtermno)
|
||||
continue;
|
||||
|
||||
if (of_device_is_compatible(vty, "hvterm1")) {
|
||||
hvc_instantiate(*vtermno, num_found, &hvc_get_put_ops);
|
||||
++num_found;
|
||||
}
|
||||
}
|
||||
|
||||
return num_found;
|
||||
}
|
||||
console_initcall(hvc_find_vtys);
|
||||
271
drivers/tty/hvc/hvc_xen.c
Normal file
271
drivers/tty/hvc/hvc_xen.c
Normal file
|
|
@ -0,0 +1,271 @@
|
|||
/*
|
||||
* xen console driver interface to hvc_console.c
|
||||
*
|
||||
* (c) 2007 Gerd Hoffmann <kraxel@suse.de>
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <linux/console.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
#include <asm/xen/hypervisor.h>
|
||||
|
||||
#include <xen/xen.h>
|
||||
#include <xen/page.h>
|
||||
#include <xen/events.h>
|
||||
#include <xen/interface/io/console.h>
|
||||
#include <xen/hvc-console.h>
|
||||
|
||||
#include "hvc_console.h"
|
||||
|
||||
#define HVC_COOKIE 0x58656e /* "Xen" in hex */
|
||||
|
||||
static struct hvc_struct *hvc;
|
||||
static int xencons_irq;
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
static unsigned long console_pfn = ~0ul;
|
||||
|
||||
static inline struct xencons_interface *xencons_interface(void)
|
||||
{
|
||||
if (console_pfn == ~0ul)
|
||||
return mfn_to_virt(xen_start_info->console.domU.mfn);
|
||||
else
|
||||
return __va(console_pfn << PAGE_SHIFT);
|
||||
}
|
||||
|
||||
static inline void notify_daemon(void)
|
||||
{
|
||||
/* Use evtchn: this is called early, before irq is set up. */
|
||||
notify_remote_via_evtchn(xen_start_info->console.domU.evtchn);
|
||||
}
|
||||
|
||||
static int __write_console(const char *data, int len)
|
||||
{
|
||||
struct xencons_interface *intf = xencons_interface();
|
||||
XENCONS_RING_IDX cons, prod;
|
||||
int sent = 0;
|
||||
|
||||
cons = intf->out_cons;
|
||||
prod = intf->out_prod;
|
||||
mb(); /* update queue values before going on */
|
||||
BUG_ON((prod - cons) > sizeof(intf->out));
|
||||
|
||||
while ((sent < len) && ((prod - cons) < sizeof(intf->out)))
|
||||
intf->out[MASK_XENCONS_IDX(prod++, intf->out)] = data[sent++];
|
||||
|
||||
wmb(); /* write ring before updating pointer */
|
||||
intf->out_prod = prod;
|
||||
|
||||
if (sent)
|
||||
notify_daemon();
|
||||
return sent;
|
||||
}
|
||||
|
||||
static int domU_write_console(uint32_t vtermno, const char *data, int len)
|
||||
{
|
||||
int ret = len;
|
||||
|
||||
/*
|
||||
* Make sure the whole buffer is emitted, polling if
|
||||
* necessary. We don't ever want to rely on the hvc daemon
|
||||
* because the most interesting console output is when the
|
||||
* kernel is crippled.
|
||||
*/
|
||||
while (len) {
|
||||
int sent = __write_console(data, len);
|
||||
|
||||
data += sent;
|
||||
len -= sent;
|
||||
|
||||
if (unlikely(len))
|
||||
HYPERVISOR_sched_op(SCHEDOP_yield, NULL);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int domU_read_console(uint32_t vtermno, char *buf, int len)
|
||||
{
|
||||
struct xencons_interface *intf = xencons_interface();
|
||||
XENCONS_RING_IDX cons, prod;
|
||||
int recv = 0;
|
||||
|
||||
cons = intf->in_cons;
|
||||
prod = intf->in_prod;
|
||||
mb(); /* get pointers before reading ring */
|
||||
BUG_ON((prod - cons) > sizeof(intf->in));
|
||||
|
||||
while (cons != prod && recv < len)
|
||||
buf[recv++] = intf->in[MASK_XENCONS_IDX(cons++, intf->in)];
|
||||
|
||||
mb(); /* read ring before consuming */
|
||||
intf->in_cons = cons;
|
||||
|
||||
notify_daemon();
|
||||
return recv;
|
||||
}
|
||||
|
||||
static struct hv_ops domU_hvc_ops = {
|
||||
.get_chars = domU_read_console,
|
||||
.put_chars = domU_write_console,
|
||||
.notifier_add = notifier_add_irq,
|
||||
.notifier_del = notifier_del_irq,
|
||||
.notifier_hangup = notifier_hangup_irq,
|
||||
};
|
||||
|
||||
static int dom0_read_console(uint32_t vtermno, char *buf, int len)
|
||||
{
|
||||
return HYPERVISOR_console_io(CONSOLEIO_read, len, buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Either for a dom0 to write to the system console, or a domU with a
|
||||
* debug version of Xen
|
||||
*/
|
||||
static int dom0_write_console(uint32_t vtermno, const char *str, int len)
|
||||
{
|
||||
int rc = HYPERVISOR_console_io(CONSOLEIO_write, len, (char *)str);
|
||||
if (rc < 0)
|
||||
return 0;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static struct hv_ops dom0_hvc_ops = {
|
||||
.get_chars = dom0_read_console,
|
||||
.put_chars = dom0_write_console,
|
||||
.notifier_add = notifier_add_irq,
|
||||
.notifier_del = notifier_del_irq,
|
||||
.notifier_hangup = notifier_hangup_irq,
|
||||
};
|
||||
|
||||
static int __init xen_hvc_init(void)
|
||||
{
|
||||
struct hvc_struct *hp;
|
||||
struct hv_ops *ops;
|
||||
|
||||
if (!xen_pv_domain())
|
||||
return -ENODEV;
|
||||
|
||||
if (xen_initial_domain()) {
|
||||
ops = &dom0_hvc_ops;
|
||||
xencons_irq = bind_virq_to_irq(VIRQ_CONSOLE, 0);
|
||||
} else {
|
||||
if (!xen_start_info->console.domU.evtchn)
|
||||
return -ENODEV;
|
||||
|
||||
ops = &domU_hvc_ops;
|
||||
xencons_irq = bind_evtchn_to_irq(xen_start_info->console.domU.evtchn);
|
||||
}
|
||||
if (xencons_irq < 0)
|
||||
xencons_irq = 0; /* NO_IRQ */
|
||||
|
||||
hp = hvc_alloc(HVC_COOKIE, xencons_irq, ops, 256);
|
||||
if (IS_ERR(hp))
|
||||
return PTR_ERR(hp);
|
||||
|
||||
hvc = hp;
|
||||
|
||||
console_pfn = mfn_to_pfn(xen_start_info->console.domU.mfn);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void xen_console_resume(void)
|
||||
{
|
||||
if (xencons_irq)
|
||||
rebind_evtchn_irq(xen_start_info->console.domU.evtchn, xencons_irq);
|
||||
}
|
||||
|
||||
static void __exit xen_hvc_fini(void)
|
||||
{
|
||||
if (hvc)
|
||||
hvc_remove(hvc);
|
||||
}
|
||||
|
||||
static int xen_cons_init(void)
|
||||
{
|
||||
struct hv_ops *ops;
|
||||
|
||||
if (!xen_pv_domain())
|
||||
return 0;
|
||||
|
||||
if (xen_initial_domain())
|
||||
ops = &dom0_hvc_ops;
|
||||
else
|
||||
ops = &domU_hvc_ops;
|
||||
|
||||
hvc_instantiate(HVC_COOKIE, 0, ops);
|
||||
return 0;
|
||||
}
|
||||
|
||||
module_init(xen_hvc_init);
|
||||
module_exit(xen_hvc_fini);
|
||||
console_initcall(xen_cons_init);
|
||||
|
||||
#ifdef CONFIG_EARLY_PRINTK
|
||||
static void xenboot_write_console(struct console *console, const char *string,
|
||||
unsigned len)
|
||||
{
|
||||
unsigned int linelen, off = 0;
|
||||
const char *pos;
|
||||
|
||||
dom0_write_console(0, string, len);
|
||||
|
||||
if (xen_initial_domain())
|
||||
return;
|
||||
|
||||
domU_write_console(0, "(early) ", 8);
|
||||
while (off < len && NULL != (pos = strchr(string+off, '\n'))) {
|
||||
linelen = pos-string+off;
|
||||
if (off + linelen > len)
|
||||
break;
|
||||
domU_write_console(0, string+off, linelen);
|
||||
domU_write_console(0, "\r\n", 2);
|
||||
off += linelen + 1;
|
||||
}
|
||||
if (off < len)
|
||||
domU_write_console(0, string+off, len-off);
|
||||
}
|
||||
|
||||
struct console xenboot_console = {
|
||||
.name = "xenboot",
|
||||
.write = xenboot_write_console,
|
||||
.flags = CON_PRINTBUFFER | CON_BOOT | CON_ANYTIME,
|
||||
};
|
||||
#endif /* CONFIG_EARLY_PRINTK */
|
||||
|
||||
void xen_raw_console_write(const char *str)
|
||||
{
|
||||
dom0_write_console(0, str, strlen(str));
|
||||
}
|
||||
|
||||
void xen_raw_printk(const char *fmt, ...)
|
||||
{
|
||||
static char buf[512];
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
xen_raw_console_write(buf);
|
||||
}
|
||||
1604
drivers/tty/hvc/hvcs.c
Normal file
1604
drivers/tty/hvc/hvcs.c
Normal file
File diff suppressed because it is too large
Load diff
1314
drivers/tty/hvc/hvsi.c
Normal file
1314
drivers/tty/hvc/hvsi.c
Normal file
File diff suppressed because it is too large
Load diff
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue