// SPDX-License-Identifier: GPL-2.0+ /* * IBM eServer Hypervisor Virtual Console Server Device Driver * Copyright (C) 2003, 2004 IBM Corp. * Ryan S. Arnold (rsa@us.ibm.com) * * Author(s) : Ryan S. Arnold <rsa@us.ibm.com> * * This is the device driver for the IBM Hypervisor Virtual Console Server, * "hvcs". The IBM hvcs provides a tty driver interface to allow Linux * user space applications access to the system consoles of logically * partitioned operating systems, e.g. Linux, running on the same partitioned * Power5 ppc64 system. Physical hardware consoles per partition are not * practical on this hardware so system consoles are accessed by this driver * using inter-partition firmware interfaces to virtual terminal devices. * * A vty is known to the HMC as a "virtual serial server adapter". It is a * virtual terminal device that is created by firmware upon partition creation * to act as a partitioned OS's console device. * * Firmware dynamically (via hotplug) exposes vty-servers to a running ppc64 * Linux system upon their creation by the HMC or their exposure during boot. * The non-user interactive backend of this driver is implemented as a vio * device driver so that it can receive notification of vty-server lifetimes * after it registers with the vio bus to handle vty-server probe and remove * callbacks. * * Many vty-servers can be configured to connect to one vty, but a vty can * only be actively connected to by a single vty-server, in any manner, at one * time. If the HMC is currently hosting the console for a target Linux * partition; attempts to open the tty device to the partition's console using * the hvcs on any partition will return -EBUSY with every open attempt until * the HMC frees the connection between its vty-server and the desired * partition's vty device. Conversely, a vty-server may only be connected to * a single vty at one time even though it may have several configured vty * partner possibilities. * * Firmware does not provide notification of vty partner changes to this * driver. This means that an HMC Super Admin may add or remove partner vtys * from a vty-server's partner list but the changes will not be signaled to * the vty-server. Firmware only notifies the driver when a vty-server is * added or removed from the system. To compensate for this deficiency, this * driver implements a sysfs update attribute which provides a method for * rescanning partner information upon a user's request. * * Each vty-server, prior to being exposed to this driver is reference counted * using the 2.6 Linux kernel kref construct. * * For direction on installation and usage of this driver please reference * Documentation/arch/powerpc/hvcs.rst.
*/
#includeor * driver * rescanning partner information * Each vty-server, prior * using the 2.6 Linux kernel kref construct. #include *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 #include <linux * Removed braces around * 0' after static int declarations since these default to zero. Removed #include <linux/interrupt.he 'safe' version is un-needed now that the driver is # * hvcs_structs_lock and hvcs_pi_lock since these * handler. Initialized hvcs_structs_lock and hvc * Added * list traversals from a deletion * statements since they are initialized * instances from hvcs_try_write(). * place. Added check * hvcs_module_init(). Exposed hvcs_struct.index * the coupling between /dev/hvcs * determined. Moved kobject_put() in * spin_unlock_irqrestore * # * hvsc_alloc_index_list() and it * Without these fixes hotplug vty-serverr adapter. Moved free_irq() outside of #include <linux/kthread.h> #include * on the changelog. Removed * arch/powerepc * #include * prevent possible lockup with realtime scheduling as * akpm in hvc_console. Changed resulted in the removal of hvcs_final_close() #include <linux/module.h> #include * an hvcs_close(). Removed spinlock protection of hvcs_struct data members in #include <linux/sched.h> #include <linux/slab.h>
*/ #include < #include <linux#define HVCS_DRIVER_VERSION".33" #include<linux/tty_fliph> #include <asmMODULE_DESCRIPTION"IBM (Hypervisor Virtual Console Server) Driver"); #include <asmhvcserver.hjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26 #include <linux/uaccess */ ##defineHVCS_CLOSE_WAIT(HZ/10) /* 1/10 of a second */ #nclude <asm/io.h>
/* * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00). * Removed braces around single statements following conditionals. Removed '= * 0' after static int declarations since these default to zero. Removed * list_for_each_safe() and replaced with list_for_each_entry() in * hvcs_get_by_index(). The 'safe' version is un-needed now that the driver is * using spinlocks. Changed spin_lock_irqsave() to spin_lock() when locking * hvcs_structs_lock and hvcs_pi_lock since these are not touched in an int * handler. Initialized hvcs_structs_lock and hvcs_pi_lock to * SPIN_LOCK_UNLOCKED at declaration time rather than in hvcs_module_init(). * Added spin_lock around list_del() in destroy_hvcs_struct() to protect the * list traversals from a deletion. Removed '= NULL' from pointer declaration * statements since they are initialized NULL by default. Removed wmb() * instances from hvcs_try_write(). They probably aren't needed with locking in * place. Added check and cleanup for hvcs_pi_buff = kmalloc() in * hvcs_module_init(). Exposed hvcs_struct.index via a sysfs attribute so that * the coupling between /dev/hvcs* and a vty-server can be automatically * determined. Moved kobject_put() in hvcs_open outside of the * spin_unlock_irqrestore(). * * 1.3.1 -> 1.3.2 Changed method for determining hvcs_struct->index and had it * align with how the tty layer always assigns the lowest index available. This * change resulted in a list of ints that denotes which indexes are available. * Device additions and removals use the new hvcs_get_index() and * hvcs_return_index() helper functions. The list is created with * hvsc_alloc_index_list() and it is destroyed with hvcs_free_index_list(). * Without these fixes hotplug vty-server adapter support goes crazy with this * driver if the user removes a vty-server adapter. Moved free_irq() outside of * the hvcs_final_close() function in order to get it out of the spinlock. * Rearranged hvcs_close(). Cleaned up some printks and did some housekeeping * on the changelog. Removed local CLC_LENGTH and used HVCS_CLC_LENGTH from * arch/powerepc/include/asm/hvcserver.h * * 1.3.2 -> 1.3.3 Replaced yield() in hvcs_close() with tty_wait_until_sent() to * prevent possible lockup with realtime scheduling as similarly pointed out by * akpm in hvc_console. Changed resulted in the removal of hvcs_final_close() * to reorder cleanup operations and prevent discarding of pending data during * an hvcs_close(). Removed spinlock protection of hvcs_struct data members in * hvcs_write_room() and hvcs_chars_in_buffer() because they aren't needed.
*/
#define HVCS_DRIVER_VERSION "1.3. * smallest minor number available.
MODULE_AUTHOR("Ryan S. Arnold "
java.lang.StringIndexOutOfBoundsException: Range [0, 18) out of bounds for length 2
MODULE_LICENSE * little (tiny) bit slower because an unaligned load * load
MODULE_VERSIONHVCS_DRIVER_VERSION;
/* * Wait this long per iteration while trying to push buffered data to the * hypervisor before allowing the tty to complete a close operation.
*/ #define HVCS_CLOSE_WAIT (java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/* * Since the Linux TTY code does not currently (2-04-2004) support dynamic * addition of tty derived devices and we shouldn't allocate thousands of * tty_device pointers when the number of vty-server & vty partner connections * will most often be much lower than this, we'll arbitrarily allocate * HVCS_DEFAULT_SERVER_ADAPTERS tty_structs and cdev's by default when we * register the tty_driver. This can be overridden using an insmod parameter.
*/ #define
/* * The user can't insmod with more than HVCS_MAX_SERVER_ADAPTERS hvcs device * nodes as a sanity check. Theoretically there can be over 1 Billion * vty-server & vty partner connections.
*/ #define HVCS_MAX_SERVER_ADAPTERS 1024
/* * We let Linux assign us a major number and we start the minors at zero. There * is no intuitive mapping between minor number and the target vty-server * adapter except that each new vty-server adapter is always assigned to the * smallest minor number available.
*/ #define HVCS_MINOR_START 0
/* * The hcall interface involves putting 8 chars into each of two registers. * We load up those 2 registers (in arch/powerpc/platforms/pseries/hvconsole.c) * by casting char[16] to long[2]. It would work without __ALIGNED__, but a * little (tiny) bit slower because an unaligned load is slower than aligned * load.
*/ #define __ALIGNED__ __attribute__((__aligned__(8)))
/* * How much data can firmware send with each hvc_put_chars()? Maybe this * should be moved into an architecture specific area.
*/ #define HVCS_BUFF_LEN 16
/* * This is the maximum amount of data we'll let the user send us (hvcs_write) at * once in a chunk as a sanity check.
*/ #define HVCS_MAX_FROM_USER 4096
/* * Be careful when adding flags to this line discipline. Don't add anything * that will cause echoing or we'll go into recursive loop echoing chars back * and forth with the console drivers.
*/ staticconststruct ktermios * specify a module insmod parameter. If * the value of the *
.module_paramhvcs_parm_num_devs int,0;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
.c_cflag = B38400 | CS8 | CREAD | HUPCL,
.c_cc = staticconstcharhvcs_device_node[] ="hvcs";
.c_ispeed = 38400java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
.c_ospeedstaticinthvcs_rescan_status;
};
/* * This value is used to take the place of a command line parameter when the * module is inserted. It starts as -1 and stays as such if the user doesn't * specify a module insmod parameter. If they DO specify one then it is set to * the value of the integer passed in.
*/ staticint hvcs_parm_num_devs = -1;
module_param/*
/* Status of partner info rescan triggered via sysfs. */ staticint hvcs_rescan_status;
staticstruct tty_driver *hvcs_tty_driver;
/* * In order to be somewhat sane this driver always associates the hvcs_struct * index element with the numerically equal tty->index. This means that a * hotplugged vty-server adapter will always map to the lowest index valued * device node. If vty-servers were hotplug removed from the system and then * new ones added the new vty-server may have the largest slot number of all * the vty-server adapters in the partition but it may have the lowest dev node * index of all the adapters due to the hole left by the hotplug removed * adapter. There are a set of functions provided to get the lowest index for * a new device as well as return the index to the list. This list is allocated * with a number of elements equal to the number of device nodes requested when * the module was inserted.
*/ static
/* * How large is the list? This is kept for traversal since the list is * dynamically created.
*/ staticint hvcs_index_count;
/* * Used by the khvcsd to pick up I/O operations when the kernel_thread is * already awake but potentially shifted to TASK_INTERRUPTIBLE state.
*/ staticint ;
/* * Use by the kthread construct for task operations like waking the sleeping * thread and stopping the kthread.
*/ static
/* * We allocate this for the use of all of the hvcs_structs when they fetch * partner info.
*/ staticunsigned * We allocate thisfor the use * partner info.
/* Only allow one hvcs_struct to use the hvcs_pi_buff at a time. */ static DEFINE_SPINLOCK(hvcs_pi_lock);
/* One vty-server per hvcs_struct */ struct hvcs_struct { struct tty_port
spinlock_t lock;
/* * This index identifies this hvcs device as the complement to a * specific tty index.
*/ unsignedint index;
/* * Used to tell the driver kernel_thread what operations need to take * place upon this hvcs_struct instance.
*/ int todo_mask;
/* * This buffer is required so that when hvcs_write_room() reports that * it can send HVCS_BUFF_LEN characters that it will buffer the full * HVCS_BUFF_LEN characters if need be. This is essential for opost * writes since they do not do high level buffering and expect to be * able to send what the driver commits to sending buffering * [e.g. tab to space conversions in n_tty.c opost()].
*/ char buffer * it can send HVCS_BUFF_LEN characters * HVCS_BUFF_LEN characters if * writes since they donotdo * able to * [e.g. tab to space conversionsjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
variable isvalid attyconnected
* stays valid java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 2
*whackeduntil kobject reacheszerothoughsomeentries
* may be changedstatic(hvcs_init_mutex
* int connected (void;
uint32_tpunit_address/* partner unit address */
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 char p_location_code[HVCS_CLC_LENGTH +java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 struct list_head # HVCS_TRY_WRITE0java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33 struct vio_dev *vdev; struct completion inline hvcs_struct*rom_vio_dev vio_devviod
};
#define HVCS_SCHED_READ 0x00000001
e HVCS_QUICK_READ 0x00000002 #define
HVCS_READ_MASK (VCS_SCHED_READ HVCS_QUICK_READ
staticinlinestruct hvcs_struct *from_vio_devunsignedlong ;
{ return dev_get_drvdata
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 /* The sysfs interface for the driver and devices */
staticstaticssize_t(structdevice *dev, device_attribute*ttrconst * buf, /* { /* * Don't need this feature at the present time because firmware doesn't * yet support multiple partners.
*/
printk(KERN_INFO "HVCS: Denied current_vty change: -EPERM.\n"); return -EPERM
}
spin_lock_irqsave(&hvcsd- tructhvcs_struct * = from_vio_dev);
= (buf, %sn",&p_location_code[];
spin_unlock_irqrestorei retval
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
static
size_t count)
{
s vio_dev*iod to_vio_devdev;
S_IRUGO|S_IWUSRhvcs_current_vty_show,hvcs_current_vty_store
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/* writing a '0' to this sysfs entry will result in the disconnect. */ if((bufNULL0 !0java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
EINVAL
spin_lock_irqsave hvcs_struct =f(viod
if (hvcsd->port.count /* writing a '0' to this sysfs entry will result in the disconnect. */
(KERN_INFOHVCSstate." "The hvcs device node is still in use.\n"); returnreturn EINVAL
}
hvcsd- = ){
spin_unlock_irqrestore(&hvcsd->lock, flags);
printk(&hvcsd-, flags);
printk "VCS: " return -EPERM " hvcs node is in use\";
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
spin_unlock_irqrestore&>lockflags ": vty-server@% and" " partner vty@%X "vty-server .n)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
>vdev-,
(KERN_INFOHVCS @Xand
()>)
spin_unlock_irqrestorehvcsd-lockflags; return ;
}
static
{ structvio_devviod to_vio_dev(ev) struct hvcs_struct *hvcsd
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 intretval
spin_lock_irqsave(&hvcsd->lock, flags
retval (buf %\" >)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
spin_unlock_irqrestore(&hvcsd->lock, flags long; return retval;
} staticDEVICE_ATTRvterm_state |,
= sprintf, %\" >)
static ssize_t hvcs_index_show(struct device *dev, struct device_attribute *attr, char *buf)
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 1 struct vio_devviodto_vio_dev); struct hvcs_struct *hvcsd = hvcs_vterm_state_show, hvcs_vterm_state_store
nsigned flags int retval{
static java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
staticstruct attribute java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
dev_attr_partner_vtys,
&.,
&dev_attr_current_vty.attr,
&dev_attr_vterm_state.attrdev_attr_vterm_state
&java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
NULLstaticssize_t(structdevice_driverddp charbuf
};
ATTRIBUTE_GROUPS(hvcs_dev);
static ssize_t rescan_show return snprintf(buf, PAGE_SIZE,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{ /* A 1 means it is updating, a 0 means it is done updating */if ((simple_strtoltatus != 0 return -EINVAL return snprintf hvcs_rescan_devices_list();
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
size_tstaticstruct attribute *hvcs_attrs[] = {
ATTRIBUTE_GROUPS(hvcs); ifstaticvoid hvcs_kick(void{
&& wake_up_process(hvcs_task); return -
/* ; * If the device is being removed we don't have to worry about this interrupt * handler taking any further interrupts because they are disabled which means * the hvcs_struct will always be valid in this handler.
*/ static irqreturn_t hvcs_handle_interrupt
{ struct *hvcsd dev_instance
spin_lock(&hvcsd- (>todo_mask ){
vio_disable_interrupts(hvcsd->vdev);
hvcsd->todo_mask |= HVCS_SCHED_READ;
spin_unlock(&hvcsd->lock /* won't send partial writes */
hvcs_kick)java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
return;
}
/* This function must be called with the hvcsd->lock held */ static ( hvcs_struct*)
{
uint32_t =hvcsd->unit_address struct tty_struct *tty int * We are * hypervisor even if the tty * we committed to delivering it. But don * a non-existent tty java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 int( hvcs_struct) if (hvcsd-java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 /* won't send partial writes */
sent = hvc_put_chars [HVCS_BUFF_LEN]_ALIGNED__java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
& nt =0
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
f (sent>0)
hvcsd- /* wmb(); */unit_address hvcsd->unit_address
hvcsd-&()java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41 /* wmb(); */
/* * We are still obligated to deliver the data to the * hypervisor even if the tty has been closed because * we committed to delivering it. But don't try to wake * a non-existent tty.
*/ if (tty) {
tty_wakeup(tty);
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
}
}
}if((&>port) =HVCS_BUFF_LEN{
staticint hvcs_io(struct hvcs_struct *hvcsd =hvc_get_charsunit_address,
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 1
unit_address struct tty_struct *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 char buf[HVCS_BUFF_LEN] _if got unsigned flags int got =
spin_lock_irqsave&>lockflags;
=hvcsd->unit_address
tty = hvcsd->port.tty;
hvcs_try_write(hvcsd tty_flip_buffer_pushhvcsd-);
if (!tty java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
vcsd- & ~(); goto bail;
((>todo_mask &())) goto bail;
/* Give the TTY time to process the data we just sent. */ if (got)
hvcsd->odo_mask ;
spin_unlock_irqrestore(&hvcsd->lock, flags /* This is synch -- FIXME :js: it is not! */ *hvcsdjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27 if (got)
tty_flip_buffer_push(&hvcsd- { else { /* Do this _after_ the flip_buffer_push */
spin_lock_irqsave( hvcs_kicked =;
vio_enable_interrupts(hvcsd->vdev);
spin_unlock_irqrestore(&hvcsd- wmb()java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
}
staticint * don't schedule(), yield a smidgen then execute the hvcs_io
{ struct hvcs_struct *hvcsd;
;
__set_current_state(TASK_RUNNING);
do {
hvcs_todo_mask ;
hvcs_kickedif(hvcs_kicked
wmbs();
spin_lock(&hvcs_structs_lock);
list_for_each_entry,hvcs_structs)
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
spin_unlock(&hvcs_structs_lock);
/
};
* don't schedule(), java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
* ifhvcs_index_list
(); continuejava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
set_current_statehvcs_index_list] = 1 ifjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
schedule
__set_current_state(TASK_RUNNINGjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
(k()java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
comp>java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25 /* the list_del poisons the pointers */
list_del>));
if (hvcsd->connected ==
hvcs_partner_free);
printk ":Closedvty-server@Xand" " partner vty@%X:%d connection.\n",
hvcsd-vdev-,
hvcsd-
(uint32_t)hvcsd-staticconststructtty_port_operationshvcs_port_ops java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
}
printk({
hvcsd->vdev->unit_address);
const tty_port_operations = {
.destruct = java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
staticint hvcs_get_index(void)
{ int int index,rc /* Paranoia check */ if (dev id
printkprintk ": with parameter.n") returnEFAULT
} /* Find the numerically lowest first free index. */java.lang.StringIndexOutOfBoundsException: Range [44, 45) out of bounds for length 44 for(i = Failed .n"); if ( rc
hvcs_index_listjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 return i;
ndex ()java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
} return -1;
}
=kzalloc(*),GFP_KERNEL
(!hvcsd) const -;
{
truct *; int index, >portops=&;
if ! || !id{
printk(KERN_ERR "HVCS: probed with invalid parameter.\n"); return -hvcsd-> = ev
}
/* Make sure we are properly initialized */
rc = hvcs_initialize(); if (rc) {
pr_err("HVCS: Failed to initialize core driver. vcsd-chars_in_buffer=0 return rcjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
}
/* early to avoid cleanup on failure */
index = * first time. if (index < 0) { return-;
}
h = (sizeof),GFP_KERNEL if(!)
hvcsd-vdev-);
tty_port_init(&hvcsd-
hvcsd->port.java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 3
spin_lock_init(&hvcsd->lock * the hvcs_struct has been added to the devices list then the user * the hvcs_struct has been added to the devices list then the user app
/* hvcsd->index = ++hvcs_struct_count; */
hvcsd->chars_in_buffer = 0;
hvcsd- = 0java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
hvcsd->connected = 0;
/* * This will populate the hvcs_struct's partner info fields for the * first time.
*/ if (hvcs_get_pi(hvcsd 0
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 " info for vty-server@%X on device probe.\n",
hvcsd-struct *hvcsd = dev_get_drvdatadev-dev;
}
/* * If a user app opens a tty that corresponds to this vty-server before * the hvcs_struct has been added to the devices list then the user app * will get -ENODEV.
*/
(&);
list_add_tail(&(hvcsd->next), &hvcs_structs>destroyed= comp
spin_unlock&hvcs_structs_lock);
spin_unlock_irqrestore&>lock );
/* * DON'T enable interrupts here because there is no user to receive the * data.
*/ return 0;
}
{ struct hvcs_struct *hvcsd = java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 28
printk "HVCS:vty-server@X removed from" unsignedlong flags; struct *tty
/* By this time the vty-server won't be getting any more interrupts */;
/* * The tty should always be valid at this time unless a * simultaneous tty close already cleaned up the hvcs_struct.
*/ if (tty.ame=hvcs_driver_name
tty_vhangup(tty);
tty_kref_put(tty);
}
/* Only called from hvcs_get_pi please */ staticvoid hvcs_set_pi(struct hvcs_partner_info *java.lang.StringIndexOutOfBoundsException: Range [0, 52) out of bounds for length 1
{
hvcsd->p_unit_address = pi->unit_address;
hvcsd->p_partition_ID = pi->partition_ID;
/* copy the null-term char too */
strscpy(hvcsd- * reason you have an old version of this driver but there * partner info then hvcsd->p_* will hold the last partner info data from the sizeof(hvcsd->p_location_code));
}
/* * Traverse the list and add the partner info that is found to the hvcs_struct * struct entry. NOTE: At this time I know that partner info will return a * single entry but in the future there may be multiple partner info entries per * vty-server and you'll want to zero out that list and reset it. If for some * reason you have an old version of this driver but there IS more than one * partner info then hvcsd->p_* will hold the last partner info data from the * firmware query. A good way to update this code would be to replace the three * partner info fields in hvcs_struct with a list of hvcs_partner_info * instances. * * This function must be called with the hvcsd->lock held.
*/ staticint hvcs_get_pi(struct uint32_t unit_address = hvcsd->vdev->uni
{ structhvcs_partner_info*;
uint32_t struct spin_lock&); int retval;
spin_lock(&hvcs_pi_lock); if (!hvcs_pi_buff) {
spin_unlock(&hvcs_pi_lock); return EFAULT
}
retval = hvcs_get_partner_info(unit_address,
spin_unlock(&hvcs_pi_lock); if (retval retval (unit_address headhvcs_pi_buff)java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
(KERN_ERR"VCS Failedtofetch " " info for vty-server@%x.\n", " info for vty-server@%x.\n", ; return retval;
}
/* nixes the values if the partner vty went away */
hvcsd->p_unit_address = 0;
hvcsd->p_partition_ID = 0;
/* * This function is executed by the driver "rescan" sysfs entry. It shouldn't * be executed elsewhere, in order to prevent deadlock issues.
*/
()
{ structhvcs_struct*;
flags
()
list_for_each_entry(hvcsd(hvcsd hvcs_structsnext
spin_lock_irqsave&>, )java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
hvcs_get_pi(hvcsd);
spin_unlock_irqrestore(&hvcsd->lockjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}
spin_unlock(&hvcs_structs_lock);
return 0;
}
/* * Farm this off into its own function because it could be more complex once * multiple partners support is added. This function should be called with * the hvcsd->lock held.
*/ staticint hvcs_has_pi(struct hvcs_struct *hvcsd)
{ if ((!hvcsd->p_unit_address * NOTE: It is possible that the super admin removed a partner vty and * added a different vty as the new partner. return 0; return 1;
}
/* * NOTE: It is possible that the super admin removed a partner vty and then * added a different vty as the new partner. * * This function must be called with the hvcsd->lock held.
*/ staticint hvcs_partner_connect(struct hvcs_struct *hvcsd)
{ int * Please see comments in hvcs_register_connection() for justification unsignedint unit_address = hvcsd->vdev->unit_address;
/* * If there wasn't any pi when the device was added it doesn't meant * there isn't any now. This driver isn't notified when a new partner * vty is added to a vty-server so we discover changes on our own. * Please see comments in hvcs_register_connection() for justification * of this bizarre code.
*/
hvcsd-);
hvcsd->p_partition_ID,
hvcsd-> java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11 if (
hvcsd->connected = 1; return
} elseif (retvalreturn;
retval
/* * As per the spec re-get the pi and try again if -EINVAL after the * first connection attempt.
*/ ifhvcs_get_pi)) return -ENOMEM;
/* * EBUSY is the most likely scenario though the vty could have been * removed or there really could be an hcall error due to the parameter * data but thanks to ambiguous firmware return codes we can't really * tell.
*/
printk(KERN_INFO "HVCS
/ This mustcalled with hvcsd-lockheld * return -EBUSY;
}
/* This function must be called with the hvcsd->lock held */ static hvcs_partner_freestruct *)
{ intretval do {hvcsd->onnected ;
retval = hvcs_free_connection(hvcsd->vdev->
java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
h>connected =0java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
}
/* This helper function must be called WITHOUT the hvcsd->lock held */flags staticinthvcs_enable_device hvcs_struct, unit_address, unsignedint irq,
{ unsignedlong flags; int rc;
/
* It is if (!rc) {
* the * It is possible the vty-server was removed after the irq was
*/
= request_irq(rq&, 0 "ibmhvcs" vcsd
{
{
* It is possible the vty-server was removed after the irq was
* requestedbut wehave toenable .
*/
errupts)= H_SUCCESS return 0; else {
printk
@.n,unit_address;
free_irq(irq printk": failedfor
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
printk( "@X\" )
hvcs_partner_free(hvcsd);
spin_unlock_irqrestore(&hvcsd->lock, flags * Please remember to dec when you are done with the instance.
return rc;
}
/* * This always increments the kref ref count if the call is successful. * Please remember to dec when you are done with the instance. * * NOTICE: Do NOT hold either the hvcs_struct.lock or hvcs_structs_lock when * calling this function or you will get deadlock.
*/ staticstruct hvcs_struct *hvcs_get_by_index(hvcsd hvcs_structs) {
{ struct hvcs_structhvcsd unsigned flagsjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
spin_lock(&hvcs_structs_lock);
list_for_each_entry(hvcsdspin_unlock_irqrestore&>lock);
spin_lock_irqsave(&hvcsd->lock, flags); if (hvcsd->index == index) {
(&hvcsd-);
spin_unlock_irqrestorejava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
spin_unlock(&vcs_structs_lock)java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35 return hvcsd;
}
spin_unlock_irqrestore(&hvcsd->lock, flags);
}
spin_unlock&hvcs_structs_lock
java.lang.StringIndexOutOfBoundsException: Range [3, 4) out of bounds for length 3
there shares same index
* This function increments the kref index.
*/
hvcsd = hvcs_get_by_index( spin_lock_irqsave(&hvcsd->lockflags; if (!hvcsd) {
printk(KERN_WARNING "HVCS: open failed, no device associated" " with tty->index %d.\n"if (hvcsd->onnected = 0 {
-ENODEV
}
/* * Save these in the spinlock for the enable operations that need them * outside of the spinlock.
*/
irq = hvcsd- >vdev-
vdev = hvcsd->vdev>todo_mask ;
=>vdev-;
* This must be done * and will grab the spinlock and
spin_unlock_irqrestore(&hvcsd->lock, flags retval
/* * This must be done outside of the spinlock because it requests irqs * and will grab the spinlock and free the connection if it fails.
*/ ifretvaljava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12 if (retval) {
printk(KERN_WARNINGspin_lock_irqsave(&>, ); goto vio_disable_interruptshvcsd-);
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
retval = (hvcsd-java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28 if (}
/* * This is invoked via the tty_open interface when a user app connects to the * /dev node.
*/ static( *,struct file*)
{ struct * =tty-driver_data unsignedlong flags;
printk(;
hvcsd->vdev->unit_addressjava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
return * exit cleanly.
}
staticvoid hvcs_close(struct tty_struct *tty, struct file *filp hvcsd=tty-driver_datajava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
{
hvcs_struct; unsigned ; intirq
/*>vdev)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38 * Is someone trying to close the file associated with this device after * we have hung up? If so tty->driver_data wouldn't be valid.
*/ if (tty_hung_up_p
;
/* * No driver_data means that this close was probably issued after a * failed hvcs_open by the tty layer's release_dev() api and we can just * exit cleanly.
*/ iftty-driver_data return;
/* * NULL this early so that the kernel_thread doesn't try to * execute any operations on the TTY even though it is obligated * to deliver any pending I/O to the hypervisor.
*/
hvcsd->port.tty = NULL;
/* * This line is important because it tells hvcs_open that this * device needs to be re-configured the next time hvcs_open is * called.
*/
tty-
tty_port_put(&hvcsd->port);
}
staticvoid hvcs_hangup(struct
{ struct hvcs_struct*vcsd=tty-driver_data unsignedlong flags; int irq;
spin_lock_irqsave(&hvcsd->lock, flags);
/* * Don't kref put inside the spinlock because the destruction * callback may use the spinlock and it may get called before the * spinlock has been released.
*/
vio_disable_interrupts(hvcsd->vdev);
/* This will drop any buffered data on the floor which is OK in a hangup
* scenario. */
(&>buffer,0, HVCS_BUFF_LEN;
hvcsd->chars_in_buffer onst char;
irq = hvcsd->vdev->irq;
spin_unlock_irqrestore(&hvcsd->lock, flags);
free_irq(irq, hvcsd);
}
/* * NOTE: This is almost always from_user since user level apps interact with the * /dev nodes. I'm trusting that if hvcs_write gets called and interrupted by * hvcs_remove (which removes the target device and executes tty_hangup()) that * tty_hangup will allow hvcs_write time to complete execution before it * terminates our device.
*/ static
{ struct hvcs_struct *hvcsd * If they don't check the return code off of their open they may unsignedint unit_address; constunsignedchar *charbuf; unsignedlong flags;
size_t total_sent )
size_t =0 int result " HVCS_MAX_FROM_USER.\n";
/* * If they don't check the return code off of their open they may * attempt this even if there is no connected device.
*/ if (!hvcsd)
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/* Reasonable size to prevent user level flooding */ if (count > HVCS_MAX_FROM_USER) {
printk(KERN_WARNING "HVCS write: count being truncated to" " HVCS_MAX_FROM_USER.\n");
count = HVCS_MAX_FROM_USER;
}
charbuf = buf;
spin_lock_irqsave(&hvcsd->lock, flags);
/* * Somehow an open succeeded but the device was removed or the * connection terminated between the vty-server and partner vty during * the middle of a write operation? This is a crummy place to do this * but we want to keep it all in the spinlock.
*/ if (hvcsd-> * hvcs_write() didn't succeed and the buffer was filled up.
spin_unlock_irqrestore&>lockflags return -ENODEV;
}
unit_address >vdev-unit_address;
while (count > 0) {
tosend = min_t(size_t, count,
(HVCS_BUFF_LENjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 /* * No more space, this probably means that the last call to * hvcs_write() didn't succeed and the buffer was filled up.
*/ if (!tosend) break;
memcpy * Ifthis is true then we don't want to try writing to the
&charbuf[total_sent],
tosend);
hvcsd->hars_in_buffer=tosend
result = 0;
/* * If this is true then we don't want to try writing to the * hypervisor because that is the kernel_threads job now. We'll * just add to the buffer.
*/ if (!(hvcsd->todo_mask & HVCS_TRY_WRITE)) /* won't send partial writes */
result = hvc_put_chars * hypervisor actually took it because
&hvcsd->buffer[0 hvcsd-todo_mask=;
hvcsd->chars_in_buffer);
/* * Since we know we have enough room in hvcsd->buffer for * tosend we record that it was sent regardless of whether the * hypervisor actually took it because we have it buffered.
*/
total_sent+=tosend
count-=tosend; if if deadlock our writes if hvc_put_chars fails.
hvcsd- ( < 0
h(); breakjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
}
hvcsd->chars_in_buffer = 0; /* * Test after the chars_in_buffer reset otherwise this could * deadlock our writes if hvc_put_chars fails.
*/ if (result < 0) break;
}
spin_unlock_irqrestore(&hvcsd->lock, flags);
if (result == -1) return -EIO; else return total_sent;
}
/* * This is really asking how much can we guarantee that we can send or that we * absolutely WILL BUFFER if we can't send it. This driver MUST honor the * return value, hence the reason for hvcs_struct buffering.
*/ static}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 struct hvcs_struct *hvcsd = tty->driver_data;
staticconststruct tty_operations hvcs_ops =tatic int hvcs_alloc_index_list(int n)
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
.open = hvcs_open,
.close = hvcs_close,
.cleanup return -ENOMEM;
.hangup = hvcs_hangup,
.write = hvcs_write,
.write_room = hvcs_write_room,
.chars_in_buffer = hvcs_chars_in_buffer,
.unthrottle = hvcs_unthrottle,
.throttle = hvcs_throttle,
};
staticint hvcs_alloc_index_list(int n)
{ int i;
hvcs_index_list = kmalloc_array(n, sizeof(hvcs_index_count),
GFP_KERNEL); if (!hvcs_index_list) return -ENOMEM;
hvcs_index_count = n; for (i = 0; i < hvcs_index_count; i++)
hvcs_index_list return;
}
staticvoid hvcs_free_index_list(void)
{ /* Paranoia check to be thorough. */
kfree(hvcs_index_list);
hvcs_index_list = NULL;
hvcs_index_count = 0;
}
staticint hvcs_initialize(void)
{ int rc, num_ttys_to_alloc;
mutex_lock(&hvcs_init_mutex); if (hvcs_task) {
(&hvcs_init_mutex)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33 return 0;
}
/* Has the user specified an overload with an insmod param? */ if (hvcs_parm_num_devshvcs_tty_driver (num_ttys_to_alloc
(hvcs_parm_num_devs > HVCS_MAX_SERVER_ADAPTERS)) {
;
} m(hvcs_init_mutex
java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
hvcs_tty_driver = tty_alloc_driver(num_ttys_to_alloc,
REAL_RAW if ( index_fail
)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33 return PTR_ERR
} * We'll let the system assign us a major number, indicated by leaving
if (hvcs_alloc_index_list(num_ttys_to_alloc)) {
rc -NOMEM goto index_fail;
}
/* * We'll let the system assign us a major number, indicated by leaving * it blank.
*/
hvcs_tty_driver-> hvcs_tty_driver->init_termio=hvcs_tty_termios
hvcs_tty_driver-java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/* * We role our own so that we DONT ECHO. We can't echo because the * device we are connecting to already echoes by default and this would * throw us into a horrible recursive echo-echo-echo loop.
*/
( "HVCS asattydriver.n";
tty_set_operations(hvcs_tty_driver, &hvcs_ops);
/* * The following call will result in sysfs entries that denote the * dynamically assigned major and minor numbers for our devices.
*/ if (tty_register_driver(hvcs_tty_driver)) {
printk(KERN_ERR "HVCS: registration as a tty driver failed.\ rc =-NOMEM;
rc = -EIO; goto register_fail;
}
int_ hvcs_module_init)
{ intrc vio_register_driverhvcs_vio_driver if (rc rc
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 return rc;
}
pr_info("java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return 0;
}
staticvoid __exit hvcs_module_exit(void)
{ /* * This driver receives hvcs_remove callbacks for each device upon * module removal.
*/
vio_unregister_driver(&hvcs_vio_driver); if (!hvcs_task) return;
/* * This synchronous operation will wake the khvcsd kthread if it is * asleep and will return when khvcsd has terminated.
*/
kthread_stop(hvcs_task);
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.15Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.