Initial commit: Linux kernel 4.19 for Unplugged OS

This commit is contained in:
ziv committed 2025-10-06 13:52:42 +00:00
commit d30235b04c
80519 files changed
+35800681

No files matched your search

@@ -0,0 +1,89 @@
This file describes sysfs entries beneath /devices/platform/visorchipset.
What: install/error
Date: 7/18/2014
KernelVersion: TBD
Contact: sparmaintainer@unisys.com
Description: used to send the ID of a string that should be displayed on
s-Par's automatic installation progress screen when an error
is encountered during installation. This field has no effect
if not in installation mode.
Users: sparmaintainer@unisys.com
What: install/remainingsteps
Date: 7/18/2014
KernelVersion: TBD
Contact: sparmaintainer@unisys.com
Description: used to set the value of the progress bar on the s-Par automatic
installation progress screen. This field has no effect if not in
installation mode.
Users: sparmaintainer@unisys.com
What: install/textid
Date: 7/18/2014
KernelVersion: TBD
Contact: sparmaintainer@unisys.com
Description: used to send the ID of a string that should be displayed on
s-Par's automatic installation progress screen. Setting this
field when not in installation mode (boottotool was set on
the previous guest boot) has no effect.
Users: sparmaintainer@unisys.com
What: install/boottotool
Date: 7/18/2014
KernelVersion: TBD
Contact: sparmaintainer@unisys.com
Description: The boottotool flag controls s-Par behavior on the next boot of
this guest. Setting the flag will cause the guest to boot from
the utility and installation image, which will use the value in
the toolaction field to determine what operation is being
requested.
Users: sparmaintainer@unisys.com
What: install/toolaction
Date: 7/18/2014
KernelVersion: TBD
Contact: sparmaintainer@unisys.com
Description: This field is used to tell s-Par which type of recovery tool
action to perform on the next guest boot-up. The meaning of the
value is dependent on the type of installation software used to
commission the guest.
Users: sparmaintainer@unisys.com
What: parahotplug/deviceenabled
Date: 7/18/2014
KernelVersion: TBD
Contact: sparmaintainer@unisys.com
Description: This entry is used by a Unisys support script installed on the
guest, and triggered by a udev event. The support script is
responsible for enabling and disabling SR-IOV devices when the
PF device is being recovered in another guest.
Some SR-IOV devices have problems when the PF is reset without
first disabling all VFs attached to that PF. s-Par handles this
situation by sending a message to guests using these VFs, and
the script will disable the device. When the PF is recovered,
another message is sent to the guests to re-enable the VFs.
The parahotplug/deviceenabled interface is used to acknowledge
the recovery message.
Users: sparmaintainer@unisys.com
What: parahotplug/devicedisabled
Date: 7/18/2014
KernelVersion: TBD
Contact: sparmaintainer@unisys.com
Description: This entry is used by a Unisys support script installed on the
guest, and triggered by a udev event. The support script is
responsible for enabling and disabling SR-IOV devices when the
PF device is being recovered in another guest.
Some SR-IOV devices have problems when the PF is reset without
first disabling all VFs attached to that PF. s-Par handles this
situation by sending a message to guests using these VFs, and
the script will disable the device. When the PF is recovered,
another message is sent to the guests to re-enable the VFs.
The parahotplug/devicedisaabled interface is used to acknowledge
the initial recovery message.
Users: sparmaintainer@unisys.com
@@ -0,0 +1,337 @@
1. Overview
-----------
This document describes the driver set for Unisys Secure Partitioning
(s-Par(R)).
s-Par is firmware that provides hardware partitioning capabilities for
splitting large-scale Intel x86 servers into multiple isolated
partitions. s-Par provides a set of para-virtualized device drivers to
allow guest partitions on the same server to share devices that would
normally be unsharable, specifically:
* visornic - network interface
* visorhba - scsi disk adapter
* visorinput - keyboard and mouse
These drivers conform to the standard Linux bus/device model described
within Documentation/driver-model/, and utilize a driver named visorbus to
present the virtual busses involved. Drivers in the 'visor*' driver set are
commonly referred to as "guest drivers" or "client drivers". All drivers
except visorbus expose a device of a specific usable class to the Linux guest
environment (e.g., block, network, or input), and are collectively referred
to as "function drivers".
The back-end for each device is owned and managed by a small,
single-purpose service partition in the s-Par firmware, which communicates
with each guest partition sharing that device through an area of shared memory
called a "channel". In s-Par nomenclature, the back-end is often referred to
as the "service partition", "IO partition" (for virtual network and scsi disk
devices), or "console partition" (for virtual keyboard and mouse devices).
Each virtual device requires exactly 1 dedicated channel, which the guest
driver and back-end use to communicate. The hypervisor need not intervene
(other than normal interrupt handling) in the interactions that occur across
this channel.
NOT covered in this document:
* s-Par also supports sharing physical PCI adapters via SR-IOV, but
because this requires no specific support in the guest partitions, it will
not be discussed in this document. Shared SR-IOV devices should be used
wherever possible for highest performance.
* Because the s-Par back-end provides a standard EFI framebuffer to each
guest, the already-existing efifb Linux driver is used to provide guest
video access. Thus, the only s-Par-unique support that is necessary to
provide a guest graphics console are for keyboard and mouse (via visorinput).
2. Driver Descriptions
----------------------
2.1. visorbus
-------------
2.1.1. Overview
---------------
The visorbus driver handles the virtual busses on which all of the virtual
devices reside. It provides a registration function named
visorbus_register_visor_driver() that is called by each of the function
drivers at initialization time, which the function driver uses to tell
visorbus about the device classes (via specifying a list of device type
GUIDs) it wants to handle. For use by function drivers, visorbus provides
implementation for struct visor_driver and struct visor_device, as well
as utility functions for communicating with the back-end.
visorbus is associated with ACPI id "PNP0A07" in modules.alias, so if built
as a module it will typically be loaded automatically via standard udev or
systemd (God help us) configurations.
visorbus can similarly force auto-loading of function drivers for virtual
devices it discovers, as it includes a MODALIAS environment variable of this
form in the hotplug uevent environment when each virtual device is
discovered:
visorbus:<device type GUID>
visorbus notifies each function driver when a device of its registered class
arrives and departs, by calling the function driver's probe() and remove()
methods.
The actual struct device objects that correspond to each virtual bus and
each virtual device are created and owned by visorbus. These device objects
are created in response to messages from the s-Par back-end received on a
special control channel called the "controlvm channel" (each guest partition
has access to exactly 1 controlvm channel), and have a lifetime that is
independent of the function drivers that control them.
2.1.2. "struct visor device" Function Driver Interfaces
-------------------------------------------------------
The interface between visorbus and its function drivers is defined in
visorbus.h, and described below.
When a visor function driver loads, it calls visorbus_register_visor_driver()
to register itself with visorbus. The significant information passed in this
exchange is as follows:
* the GUID(s) of the channel type(s) that are handled by this driver, as
well as a "friendly name" identifying each (this will be published under
/sys/devices/visorbus<x>/dev<y>)
* the addresses of callback functions to be called whenever a virtual
device/channel with the appropriate channel-type GUID(s) appears or
disappears
* the address of a "channel_interrupt" function, which will be automatically
called at specific intervals to enable the driver to poll the device
channel for activity
The following functions implemented within each function driver will be
called automatically by the visorbus driver at appropriate times:
* The probe() function notifies about the creation of each new virtual
device/channel instance.
* The remove() function notifies about the destruction of a virtual
device/channel instance.
* The channel_interrupt() function is called at frequent intervals to
give the function driver an opportunity to poll the virtual device channel
for requests. Information is passed to this function to enable the
function driver to use the visorchannel_signalinsert() and
visorchannel_signalremove() functions to respond to and initiate activity
over the channel. (Note that since it is the visorbus driver that
determines when this is called, it is very easy to switch to
interrupt-driven mechanisms when available for particular virtual device
types.)
* The pause() function is called should it ever be necessary to direct the
function driver to temporarily stop accessing the device channel. An
example of when this is needed is when the service partition implementing
the back-end of the virtual device needs to be recovered. After a
successful return of pause(), the function driver must not access the
device channel until a subsequent resume() occurs.
* The resume() function is the "book-end" to pause(), and is described above.
2.1.3. sysfs Advertised Information
-----------------------------------
Because visorbus is a standard Linux bus driver in the model described in
Documentation/driver-model/, the hierarchy of s-Par virtual devices is
published in the sysfs tree beneath /bus/visorbus/, e.g.,
/sys/bus/visorbus/devices/ might look like:
vbus1:dev1 -> ../../../devices/visorbus1/vbus1:dev1
vbus1:dev2 -> ../../../devices/visorbus1/vbus1:dev2
vbus1:dev3 -> ../../../devices/visorbus1/vbus1:dev3
vbus2:dev0 -> ../../../devices/visorbus2/vbus2:dev0
vbus2:dev1 -> ../../../devices/visorbus2/vbus2:dev1
vbus2:dev2 -> ../../../devices/visorbus2/vbus2:dev2
visorbus1 -> ../../../devices/visorbus1
visorbus2 -> ../../../devices/visorbus2
visor_device notes:
* Each visorbus<n> entry denotes the existence of a struct visor_device
denoting virtual bus #<n>. A unique s-Par channel exists for each such
virtual bus.
* Virtual bus numbers uniquely identify s-Par back-end service partitions.
In this example, bus 1 corresponds to the s-Par console partition
(controls keyboard, video, and mouse), whereas bus 2 corresponds to the
s-Par IO partition (controls network and disk).
* Each vbus<x>:dev<y> entry denotes the existence of a struct visor_device
denoting virtual device #<y> outboard of virtual bus #<x>. A unique s-Par
channel exists for each such virtual device.
* If a function driver has loaded and claimed a particular device, the
bus/visorbus/devices/vbus<x>:dev<y>/driver symlink will indicate that
function driver.
Every active visorbus device will have a sysfs subtree under:
/sys/devices/visorbus<x>/vbus<x>:dev<y>/
The following files exist under /sys/devices/visorbus<x>/vbus<x>:dev<y>:
subsystem link to sysfs tree that describes the
visorbus bus type; e.g.:
../../../bus/visorbus
driver link to sysfs tree that describes the
function driver controlling this device;
e.g.:
../../../bus/visorbus/drivers/visorhba
Note that this "driver" link will not exist
if the appropriate function driver has not
been loaded yet.
channel properties of the device channel (all in
ascii text format)
clientpartition handle identifying the guest (client) side
of this channel, e.g. 0x10000000.
nbytes total size of this channel in bytes
physaddr the guest physical address for the base of
the channel
typeguid a GUID identifying the channel type, in
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx notation
typename a "friendly name" for this channel type, e.g.,
"keyboard". Note that this name is provided by
a particular function driver, so "typename"
will return an empty string until AFTER the
appropriate function driver controlling this
channel type is loaded
zoneguid a GUID identifying the channel zone, in
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx notation
2.2. visorhba
-------------
The visorhba driver registers with visorbus as the function driver to
handle virtual scsi disk devices, specified using the
VISOR_VHBA_CHANNEL_GUID type in the visorbus_register_visor_driver()
call. visorhba uses scsi_add_host() to expose a Linux block device
(e.g., /sys/block/) in the guest environment for each s-Par virtual device.
visorhba provides access to a shared SCSI host bus adapter and one or more
disk devices, by proxying SCSI commands between the guest and the service
partition that owns the shared SCSI adapter, using a channel between the
guest and the service partition. The disks that appear on the shared bus
are defined by the s-Par configuration and enforced by the service partition,
while the guest driver handles sending commands and handling responses. Each
disk is shared as a whole to a guest. Sharing the bus adapter in this way
provides resiliency; should the device encounter an error, only the service
partition is rebooted, and the device is reinitialized. This allows
guests to continue running and to recover from the error.
When compiled as a module, visorhba can be autoloaded by visorbus in
standard udev/systemd environments, as it includes the modules.alias
definition:
"visorbus:"+VISOR_VHBA_CHANNEL_GUID_STR
i.e.:
alias visorbus:414815ed-c58c-11da-95a9-00e08161165f visorhba
2.3. visornic
-------------
The visornic driver registers with visorbus as the function driver to
handle virtual network devices, specified using the
VISOR_VNIC_CHANNEL_GUID type in the visorbus_register_visor_driver()
call. visornic uses register_netdev() to expose a Linux device of class net
(e.g., /sys/class/net/) in the guest environment for each s-Par virtual
device.
visornic provides a paravirtualized network interface to a
guest by proxying buffer information between the guest and the service
partition that owns the shared network interface, using a channel
between the guest and the service partition. The connectivity of this
interface with the shared interface and possibly other guest
partitions is defined by the s-Par configuration and enforced by the
service partition; the guest driver handles communication and link
status.
When compiled as a module, visornic can be autoloaded by visorbus in
standard udev/systemd environments, as it includes the modules.alias
definition:
"visorbus:"+VISOR_VNIC_CHANNEL_GUID_STR
i.e.:
alias visorbus:8cd5994d-c58e-11da-95a9-00e08161165f visornic
2.4. visorinput
---------------
The visorinput driver registers with visorbus as the function driver to
handle human input devices, specified using the
VISOR_KEYBOARD_CHANNEL_GUID and VISOR_MOUSE_CHANNEL_GUID
types in the visorbus_register_visor_driver() call. visorinput uses
input_register_device() to expose devices of class input
(e.g., /sys/class/input/) for virtual keyboard and virtual mouse devices.
A s-Par virtual keyboard device maps 1-to-1 with a Linux input device
named "visor Keyboard", while a s-Par virtual mouse device has 2 Linux input
devices created for it: 1 named "visor Wheel", and 1 named "visor Mouse".
By registering as input class devices, modern versions of X will
automatically find and properly use s-Par virtual keyboard and mouse devices.
As the s-Par back-end reports keyboard and mouse activity via events on the
virtual device channel, the visorinput driver delivers the activity to the
Linux environment by calling input_report_key() and input_report_abs().
You can interact with the guest console using the usyscon Partition Desktop
(a.k.a., "pd") application, provided as part of s-Par. After installing the
usyscon Partition Desktop into a Linux environment via the
usyscon_partitiondesktop-*.rpm, or into a Windows environment via
PartitionDesktop.msi, you will be able to launch a console for your guest
Linux environment by clicking the console icon in the s-Par web UI.
When compiled as a module, visorinput can be autoloaded by visorbus in
standard udev/systemd environments, as it includes the modules.alias
definition:
"visorbus:"+VISOR_MOUSE_CHANNEL_GUID_STR
"visorbus:"+VISOR_KEYBOARD_CHANNEL_GUID_STR
i.e.:
alias visorbus:c73416d0-b0b8-44af-b304-9d2ae99f1b3d visorinput
alias visorbus:addf07d4-94a9-46e2-81c3-61abcdbdbd87 visorinput
3. Minimum Required Driver Set
------------------------------
visorbus is required for every Linux guest running under s-Par.
visorhba is typically required for a Linux guest running under s-Par, as it
is required if your guest boot disk is a virtual device provided by the s-Par
back-end, which is the default configuration. However, for advanced
configurations where the Linux guest boots via an SR-IOV-provided HBA or
SAN disk for example, visorhba is not technically required.
visornic is typically required for a Linux guest running under s-Par, as it
is required if your guest network interface is a virtual device provided by
the s-Par back-end, which is the default configuration. However, for
configurations where the Linux guest is provided with an SR-IOV NIC
for example, visornic is not technically required.
visorinput is only required for a Linux guest running under s-Par if you
require graphics-mode access to your guest console.
+15
View File
@@ -0,0 +1,15 @@
#
# Unisys SPAR driver configuration
#
menuconfig UNISYSSPAR
bool "Unisys SPAR driver support"
---help---
Support for the Unisys SPAR drivers
if UNISYSSPAR
source "drivers/staging/unisys/visornic/Kconfig"
source "drivers/staging/unisys/visorinput/Kconfig"
source "drivers/staging/unisys/visorhba/Kconfig"
endif # UNISYSSPAR
+5
View File
@@ -0,0 +1,5 @@
Unisys s-Par drivers
M: David Kershner <sparmaintainer@unisys.com>
S: Maintained
F: drivers/staging/unisys/Documentation/overview.txt
F: drivers/staging/unisys/
+6
View File
@@ -0,0 +1,6 @@
#
# Makefile for Unisys SPAR drivers
#
obj-$(CONFIG_UNISYS_VISORNIC) += visornic/
obj-$(CONFIG_UNISYS_VISORINPUT) += visorinput/
obj-$(CONFIG_UNISYS_VISORHBA) += visorhba/
+16
View File
@@ -0,0 +1,16 @@
TODO:
- enhance visornic to use channel_interrupt() hook instead of a
kernel thread
- enhance visorhba to use channel_interrupt() hook instead of a
kernel thread
- teach visorbus to handle virtual interrupts triggered by s-Par
back-end, and call function driver's channel_interrupt() function
when they occur
- enhance debugfs interfaces (e.g., per device, etc.)
- upgrade/remove deprecated workqueue operations
- move individual drivers into proper driver subsystems
Patches to:
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ken Cox <jkc@redhat.com>
Unisys s-Par maintainer mailing list <sparmaintainer@unisys.com>
+571
View File
@@ -0,0 +1,571 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2010 - 2016 UNISYS CORPORATION
* All rights reserved.
*/
#ifndef __IOCHANNEL_H__
#define __IOCHANNEL_H__
/*
* Everything needed for IOPart-GuestPart communication is define in
* this file. Note: Everything is OS-independent because this file is
* used by Windows, Linux and possible EFI drivers.
*
* Communication flow between the IOPart and GuestPart uses the channel headers
* channel state. The following states are currently being used:
* UNINIT(All Zeroes), CHANNEL_ATTACHING, CHANNEL_ATTACHED, CHANNEL_OPENED
*
* Additional states will be used later. No locking is needed to switch between
* states due to the following rules:
*
* 1. IOPart is only the only partition allowed to change from UNIT
* 2. IOPart is only the only partition allowed to change from
* CHANNEL_ATTACHING
* 3. GuestPart is only the only partition allowed to change from
* CHANNEL_ATTACHED
*
* The state changes are the following: IOPart sees the channel is in UNINIT,
* UNINIT -> CHANNEL_ATTACHING (performed only by IOPart)
* CHANNEL_ATTACHING -> CHANNEL_ATTACHED (performed only by IOPart)
* CHANNEL_ATTACHED -> CHANNEL_OPENED (performed only by GuestPart)
*/
#include <linux/uuid.h>
#include <linux/skbuff.h>
#include <linux/visorbus.h>
/*
* Must increment these whenever you insert or delete fields within this channel
* struct. Also increment whenever you change the meaning of fields within this
* channel struct so as to break pre-existing software. Note that you can
* usually add fields to the END of the channel struct without needing to
* increment this.
*/
#define VISOR_VHBA_CHANNEL_VERSIONID 2
#define VISOR_VNIC_CHANNEL_VERSIONID 2
/*
* Everything necessary to handle SCSI & NIC traffic between Guest Partition and
* IO Partition is defined below.
*/
/*
* Define the two queues per data channel between iopart and ioguestparts.
* IOCHAN_TO_IOPART -- used by guest to 'insert' signals to iopart.
* IOCHAN_FROM_IOPART -- used by guest to 'remove' signals from IO part.
*/
#define IOCHAN_TO_IOPART 0
#define IOCHAN_FROM_IOPART 1
/* Size of cdb - i.e., SCSI cmnd */
#define MAX_CMND_SIZE 16
/* Unisys-specific DMA direction values */
enum uis_dma_data_direction {
UIS_DMA_BIDIRECTIONAL = 0,
UIS_DMA_TO_DEVICE = 1,
UIS_DMA_FROM_DEVICE = 2,
UIS_DMA_NONE = 3
};
#define MAX_SENSE_SIZE 64
#define MAX_PHYS_INFO 64
/*
* enum net_types - Various types of network packets that can be sent in cmdrsp.
* @NET_RCV_POST: Submit buffer to hold receiving incoming packet.
* @NET_RCV: visornic -> uisnic. Incoming packet received.
* @NET_XMIT: uisnic -> visornic. For outgoing packet.
* @NET_XMIT_DONE: visornic -> uisnic. Outgoing packet xmitted.
* @NET_RCV_ENBDIS: uisnic -> visornic. Enable/Disable packet reception.
* @NET_RCV_ENBDIS_ACK: visornic -> uisnic. Acknowledge enable/disable packet.
* @NET_RCV_PROMISC: uisnic -> visornic. Enable/Disable promiscuous mode.
* @NET_CONNECT_STATUS: visornic -> uisnic. Indicate the loss or restoration of
* a network connection.
* @NET_MACADDR: uisnic -> visornic. Indicates the client has requested
* to update it's MAC address.
* @NET_MACADDR_ACK: MAC address acknowledge.
*/
enum net_types {
NET_RCV_POST = 0,
NET_RCV,
NET_XMIT,
NET_XMIT_DONE,
NET_RCV_ENBDIS,
NET_RCV_ENBDIS_ACK,
/* Reception */
NET_RCV_PROMISC,
NET_CONNECT_STATUS,
NET_MACADDR,
NET_MACADDR_ACK,
};
/* Minimum eth data size */
#define ETH_MIN_DATA_SIZE 46
#define ETH_MIN_PACKET_SIZE (ETH_HLEN + ETH_MIN_DATA_SIZE)
/* Maximum data size */
#define VISOR_ETH_MAX_MTU 16384
#ifndef MAX_MACADDR_LEN
/* Number of bytes in MAC address */
#define MAX_MACADDR_LEN 6
#endif
/* Various types of scsi task mgmt commands. */
enum task_mgmt_types {
TASK_MGMT_ABORT_TASK = 1,
TASK_MGMT_BUS_RESET,
TASK_MGMT_LUN_RESET,
TASK_MGMT_TARGET_RESET,
};
/* Various types of vdisk mgmt commands. */
enum vdisk_mgmt_types {
VDISK_MGMT_ACQUIRE = 1,
VDISK_MGMT_RELEASE,
};
struct phys_info {
u64 pi_pfn;
u16 pi_off;
u16 pi_len;
} __packed;
#define MIN_NUMSIGNALS 64
/* Structs with pragma pack. */
struct guest_phys_info {
u64 address;
u64 length;
} __packed;
/*
* struct uisscsi_dest
* @channel: Bus number.
* @id: Target number.
* @lun: Logical unit number.
*/
struct uisscsi_dest {
u32 channel;
u32 id;
u32 lun;
} __packed;
struct vhba_wwnn {
u32 wwnn1;
u32 wwnn2;
} __packed;
/*
* struct vhba_config_max
* @max_channel: Maximum channel for devices attached to this bus.
* @max_id: Maximum SCSI ID for devices attached to bus.
* @max_lun: Maximum SCSI LUN for devices attached to bus.
* @cmd_per_lun: Maximum number of outstanding commands per LUN.
* @max_io_size: Maximum io size for devices attached to this bus. Max io size
* is often determined by the resource of the hba.
* e.g Max scatter gather list length * page size / sector size.
*
* WARNING: Values stored in this structure must contain maximum counts (not
* maximum values).
*
* 20 bytes
*/
struct vhba_config_max {
u32 max_channel;
u32 max_id;
u32 max_lun;
u32 cmd_per_lun;
u32 max_io_size;
} __packed;
/*
* struct uiscmdrsp_scsi
*
* @handle: The handle to the cmd that was received. Send it back as
* is in the rsp packet.
* @cmnd: The cdb for the command.
* @bufflen: Length of data to be transferred out or in.
* @guest_phys_entries: Number of entries in scatter-gather list.
* @struct gpi_list: Physical address information for each fragment.
* @data_dir: Direction of the data, if any.
* @struct vdest: Identifies the virtual hba, id, channel, lun to which
* cmd was sent.
* @linuxstat: Original Linux status used by Linux vdisk.
* @scsistat: The scsi status.
* @addlstat: Non-scsi status.
* @sensebuf: Sense info in case cmd failed. sensebuf holds the
* sense_data struct. See sense_data struct for more
* details.
* @*vdisk: Pointer to the vdisk to clean up when IO completes.
* @no_disk_result: Used to return no disk inquiry result when
* no_disk_result is set to 1
* scsi.scsistat is SAM_STAT_GOOD
* scsi.addlstat is 0
* scsi.linuxstat is SAM_STAT_GOOD
* That is, there is NO error.
*/
struct uiscmdrsp_scsi {
u64 handle;
u8 cmnd[MAX_CMND_SIZE];
u32 bufflen;
u16 guest_phys_entries;
struct guest_phys_info gpi_list[MAX_PHYS_INFO];
u32 data_dir;
struct uisscsi_dest vdest;
/* Needed to queue the rsp back to cmd originator. */
int linuxstat;
u8 scsistat;
u8 addlstat;
#define ADDL_SEL_TIMEOUT 4
/* The following fields are need to determine the result of command. */
u8 sensebuf[MAX_SENSE_SIZE];
void *vdisk;
int no_disk_result;
} __packed;
/*
* Defines to support sending correct inquiry result when no disk is
* configured.
*
* From SCSI SPC2 -
*
* If the target is not capable of supporting a device on this logical unit, the
* device server shall set this field to 7Fh (PERIPHERAL QUALIFIER set to 011b
* and PERIPHERAL DEVICE TYPE set to 1Fh).
*
* The device server is capable of supporting the specified peripheral device
* type on this logical unit. However, the physical device is not currently
* connected to this logical unit.
*/
/*
* Peripheral qualifier of 0x3
* Peripheral type of 0x1f
* Specifies no device but target present
*/
#define DEV_NOT_CAPABLE 0x7f
/*
* Peripheral qualifier of 0x1
* Peripheral type of 0 - disk
* Specifies device capable, but not present
*/
#define DEV_DISK_CAPABLE_NOT_PRESENT 0x20
/* HiSup = 1; shows support for report luns must be returned for lun 0. */
#define DEV_HISUPPORT 0x10
/*
* Peripheral qualifier of 0x3
* Peripheral type of 0x1f
* Specifies no device but target present
*/
#define DEV_NOT_CAPABLE 0x7f
/*
* Peripheral qualifier of 0x1
* Peripheral type of 0 - disk
* Specifies device capable, but not present
*/
#define DEV_DISK_CAPABLE_NOT_PRESENT 0x20
/* HiSup = 1; shows support for report luns must be returned for lun 0. */
#define DEV_HISUPPORT 0x10
/*
* NOTE: Linux code assumes inquiry contains 36 bytes. Without checking length
* in buf[4] some Linux code accesses bytes beyond 5 to retrieve vendor, product
* and revision. Yikes! So let us always send back 36 bytes, the minimum for
* inquiry result.
*/
#define NO_DISK_INQUIRY_RESULT_LEN 36
/* 5 bytes minimum for inquiry result */
#define MIN_INQUIRY_RESULT_LEN 5
/* SCSI device version for no disk inquiry result */
/* indicates SCSI SPC2 (SPC3 is 5) */
#define SCSI_SPC2_VER 4
/* Struct and Defines to support sense information. */
/*
* The following struct is returned in sensebuf field in uiscmdrsp_scsi. It is
* initialized in exactly the manner that is recommended in Windows (hence the
* odd values).
* When set, these fields will have the following values:
* ErrorCode = 0x70 indicates current error
* Valid = 1 indicates sense info is valid
* SenseKey contains sense key as defined by SCSI specs.
* AdditionalSenseCode contains sense key as defined by SCSI specs.
* AdditionalSenseCodeQualifier contains qualifier to sense code as defined by
* scsi docs.
* AdditionalSenseLength contains will be sizeof(sense_data)-8=10.
*/
struct sense_data {
u8 errorcode:7;
u8 valid:1;
u8 segment_number;
u8 sense_key:4;
u8 reserved:1;
u8 incorrect_length:1;
u8 end_of_media:1;
u8 file_mark:1;
u8 information[4];
u8 additional_sense_length;
u8 command_specific_information[4];
u8 additional_sense_code;
u8 additional_sense_code_qualifier;
u8 fru_code;
u8 sense_key_specific[3];
} __packed;
/*
* struct net_pkt_xmt
* @len: Full length of data in the packet.
* @num_frags: Number of fragments in frags containing data.
* @struct phys_info frags: Physical page information.
* @ethhdr: The ethernet header.
* @struct lincsum: These are needed for csum at uisnic end.
* @valid: 1 = struct is valid - else ignore.
* @hrawoffv: 1 = hwrafoff is valid.
* @nhrawoffv: 1 = nhwrafoff is valid.
* @protocol: Specifies packet protocol.
* @csum: Value used to set skb->csum at IOPart.
* @hrawoff: Value used to set skb->h.raw at IOPart. hrawoff points to
* the start of the TRANSPORT LAYER HEADER.
* @nhrawoff: Value used to set skb->nh.raw at IOPart. nhrawoff points to
* the start of the NETWORK LAYER HEADER.
*
* NOTE:
* The full packet is described in frags but the ethernet header is separately
* kept in ethhdr so that uisnic doesn't have "MAP" the guest memory to get to
* the header. uisnic needs ethhdr to determine how to route the packet.
*/
struct net_pkt_xmt {
int len;
int num_frags;
struct phys_info frags[MAX_PHYS_INFO];
char ethhdr[ETH_HLEN];
struct {
u8 valid;
u8 hrawoffv;
u8 nhrawoffv;
__be16 protocol;
__wsum csum;
u32 hrawoff;
u32 nhrawoff;
} lincsum;
} __packed;
struct net_pkt_xmtdone {
/* Result of NET_XMIT */
u32 xmt_done_result;
} __packed;
/*
* RCVPOST_BUF_SIZE must be at most page_size(4096) - cache_line_size (64) The
* reason is because dev_skb_alloc which is used to generate RCV_POST skbs in
* visornic requires that there is "overhead" in the buffer, and pads 16 bytes.
* Use 1 full cache line size for "overhead" so that transfers are optimized.
* IOVM requires that a buffer be represented by 1 phys_info structure
* which can only cover page_size.
*/
#define RCVPOST_BUF_SIZE 4032
#define MAX_NET_RCV_CHAIN \
((VISOR_ETH_MAX_MTU + ETH_HLEN + RCVPOST_BUF_SIZE - 1) \
/ RCVPOST_BUF_SIZE)
/* rcv buf size must be large enough to include ethernet data len + ethernet
* header len - we are choosing 2K because it is guaranteed to be describable.
*/
struct net_pkt_rcvpost {
/* Physical page information for the single fragment 2K rcv buf */
struct phys_info frag;
/*
* Ensures that receive posts are returned to the adapter which we sent
* them from originally.
*/
u64 unique_num;
} __packed;
/*
* struct net_pkt_rcv
* @rcv_done_len: Length of the received data.
* @numrcvbufs: Contains the incoming data. Guest side MUST chain these
* together.
* @*rcvbuf: List of chained rcvbufa. Each entry is a receive buffer
* provided by NET_RCV_POST. NOTE: First rcvbuf in the
* chain will also be provided in net.buf.
* @unique_num:
* @rcvs_dropped_delta:
*
* The number of rcvbuf that can be chained is based on max mtu and size of each
* rcvbuf.
*/
struct net_pkt_rcv {
u32 rcv_done_len;
u8 numrcvbufs;
void *rcvbuf[MAX_NET_RCV_CHAIN];
u64 unique_num;
u32 rcvs_dropped_delta;
} __packed;
struct net_pkt_enbdis {
void *context;
/* 1 = enable, 0 = disable */
u16 enable;
} __packed;
struct net_pkt_macaddr {
void *context;
/* 6 bytes */
u8 macaddr[MAX_MACADDR_LEN];
} __packed;
/*
* struct uiscmdrsp_net - cmd rsp packet used for VNIC network traffic.
* @enum type:
* @*buf:
* @union:
* @struct xmt: Used for NET_XMIT.
* @struct xmtdone: Used for NET_XMIT_DONE.
* @struct rcvpost: Used for NET_RCV_POST.
* @struct rcv: Used for NET_RCV.
* @struct enbdis: Used for NET_RCV_ENBDIS, NET_RCV_ENBDIS_ACK,
* NET_RCV_PROMSIC, and NET_CONNECT_STATUS.
* @struct macaddr:
*/
struct uiscmdrsp_net {
enum net_types type;
void *buf;
union {
struct net_pkt_xmt xmt;
struct net_pkt_xmtdone xmtdone;
struct net_pkt_rcvpost rcvpost;
struct net_pkt_rcv rcv;
struct net_pkt_enbdis enbdis;
struct net_pkt_macaddr macaddr;
};
} __packed;
/*
* struct uiscmdrsp_scsitaskmgmt
* @enum tasktype: The type of task.
* @struct vdest: The vdisk for which this task mgmt is generated.
* @handle: This is a handle that the guest has saved off for its
* own use. The handle value is preserved by iopart and
* returned as in task mgmt rsp.
* @notify_handle: For Linux guests, this is a pointer to wait_queue_head
* that a thread is waiting on to see if the taskmgmt
* command has completed. When the rsp is received by
* guest, the thread receiving the response uses this to
* notify the thread waiting for taskmgmt command
* completion. It's value is preserved by iopart and
* returned as in the task mgmt rsp.
* @notifyresult_handle: This is a handle to the location in the guest where
* the result of the taskmgmt command (result field) is
* saved to when the response is handled. It's value is
* preserved by iopart and returned as is in the task mgmt
* rsp.
* @result: Result of taskmgmt command - set by IOPart.
*/
struct uiscmdrsp_scsitaskmgmt {
enum task_mgmt_types tasktype;
struct uisscsi_dest vdest;
u64 handle;
u64 notify_handle;
u64 notifyresult_handle;
char result;
#define TASK_MGMT_FAILED 0
} __packed;
/*
* struct uiscmdrsp_disknotify - Used by uissd to send disk add/remove
* notifications to Guest.
* @add: 0-remove, 1-add.
* @*v_hba: Channel info to route msg.
* @channel: SCSI Path of Disk to added or removed.
* @id: SCSI Path of Disk to added or removed.
* @lun: SCSI Path of Disk to added or removed.
*
* Note that the vHba pointer is not used by the Client/Guest side.
*/
struct uiscmdrsp_disknotify {
u8 add;
void *v_hba;
u32 channel, id, lun;
} __packed;
/* Keeping cmd and rsp info in one structure for now cmd rsp packet for SCSI */
struct uiscmdrsp {
char cmdtype;
/* Describes what type of information is in the struct */
#define CMD_SCSI_TYPE 1
#define CMD_NET_TYPE 2
#define CMD_SCSITASKMGMT_TYPE 3
#define CMD_NOTIFYGUEST_TYPE 4
union {
struct uiscmdrsp_scsi scsi;
struct uiscmdrsp_net net;
struct uiscmdrsp_scsitaskmgmt scsitaskmgmt;
struct uiscmdrsp_disknotify disknotify;
};
/* Send the response when the cmd is done (scsi and scsittaskmgmt). */
void *private_data;
/* General Purpose Queue Link */
struct uiscmdrsp *next;
/* Pointer to the nextactive commands */
struct uiscmdrsp *activeQ_next;
/* Pointer to the prevactive commands */
struct uiscmdrsp *activeQ_prev;
} __packed;
/* total = 28 bytes */
struct iochannel_vhba {
/* 8 bytes */
struct vhba_wwnn wwnn;
/* 20 bytes */
struct vhba_config_max max;
} __packed;
struct iochannel_vnic {
/* 6 bytes */
u8 macaddr[6];
/* 4 bytes */
u32 num_rcv_bufs;
/* 4 bytes */
u32 mtu;
/* 16 bytes */
guid_t zone_guid;
} __packed;
/*
* This is just the header of the IO channel. It is assumed that directly after
* this header there is a large region of memory which contains the command and
* response queues as specified in cmd_q and rsp_q SIGNAL_QUEUE_HEADERS.
*/
struct visor_io_channel {
struct channel_header channel_header;
struct signal_queue_header cmd_q;
struct signal_queue_header rsp_q;
union {
struct iochannel_vhba vhba;
struct iochannel_vnic vnic;
} __packed;
#define MAX_CLIENTSTRING_LEN 1024
/* client_string is NULL termimated so holds max-1 bytes */
u8 client_string[MAX_CLIENTSTRING_LEN];
} __packed;
/* INLINE functions for initializing and accessing I/O data channels. */
#define SIZEOF_CMDRSP (64 * DIV_ROUND_UP(sizeof(struct uiscmdrsp), 64))
/* Use 4K page sizes when passing page info between Guest and IOPartition. */
#define PI_PAGE_SIZE 0x1000
#define PI_PAGE_MASK 0x0FFF
/* __IOCHANNEL_H__ */
#endif
+14
View File
@@ -0,0 +1,14 @@
#
# Unisys visorhba configuration
#
config UNISYS_VISORHBA
tristate "Unisys visorhba driver"
depends on UNISYSSPAR && UNISYS_VISORBUS && SCSI
---help---
The Unisys visorhba driver provides support for s-Par HBA
devices exposed on the s-Par visorbus. When a message is sent
to visorbus to create a HBA device, the probe function of
visorhba is called to create the scsi device.
If you say Y here, you will enable the Unisys visorhba driver.
+10
View File
@@ -0,0 +1,10 @@
#
# Makefile for Unisys channel
#
obj-$(CONFIG_UNISYS_VISORHBA) += visorhba.o
visorhba-y := visorhba_main.o
ccflags-y += -Idrivers/staging/unisys/include
File diff suppressed because it is too large. Load diff
+15
View File
@@ -0,0 +1,15 @@
#
# Unisys visorinput configuration
#
config UNISYS_VISORINPUT
tristate "Unisys visorinput driver"
depends on UNISYSSPAR && UNISYS_VISORBUS && INPUT
---help---
The Unisys s-Par visorinput driver provides a virtualized system
console (keyboard and mouse) that is accessible through the
s-Par firmware's user interface. s-Par provides video using the EFI
GOP protocol, so If this driver is not present, the Linux guest should
still boot with visible output in the partition desktop, but keyboard
and mouse interaction will not be available.
@@ -0,0 +1,6 @@
#
# Makefile for Unisys visorinput
#
obj-$(CONFIG_UNISYS_VISORINPUT) += visorinput.o
@@ -0,0 +1,788 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2011 - 2015 UNISYS CORPORATION
* All rights reserved.
*/
/*
* This driver lives in a generic guest Linux partition, and registers to
* receive keyboard and mouse channels from the visorbus driver. It reads
* inputs from such channels, and delivers it to the Linux OS in the
* standard way the Linux expects for input drivers.
*/
#include <linux/fb.h>
#include <linux/input.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/uuid.h>
#include <linux/visorbus.h>
/* These defines identify mouse and keyboard activity which is specified by the
* firmware to the host using the cmsimpleinput protocol. @ingroup coretypes
*/
/* only motion; arg1=x, arg2=y */
#define INPUTACTION_XY_MOTION 1
/* arg1: 1=left,2=center,3=right */
#define INPUTACTION_MOUSE_BUTTON_DOWN 2
#define INPUTACTION_MOUSE_BUTTON_UP 3
#define INPUTACTION_MOUSE_BUTTON_CLICK 4
#define INPUTACTION_MOUSE_BUTTON_DCLICK 5
/* arg1: wheel rotation away from/toward user */
#define INPUTACTION_WHEEL_ROTATE_AWAY 6
#define INPUTACTION_WHEEL_ROTATE_TOWARD 7
/* arg1: scancode, as follows: If arg1 <= 0xff, it's a 1-byte scancode and arg1
* is that scancode. If arg1 > 0xff, it's a 2-byte scanecode, with the 1st
* byte in the low 8 bits, and the 2nd byte in the high 8 bits.
* E.g., the right ALT key would appear as x'38e0'.
*/
#define INPUTACTION_KEY_DOWN 64
#define INPUTACTION_KEY_UP 65
#define INPUTACTION_KEY_DOWN_UP 67
/* arg1: scancode (in same format as inputaction_keyDown); MUST refer to one of
* the locking keys, like capslock, numlock, or scrolllock.
* arg2: 1 iff locking key should be in the LOCKED position (e.g., light is ON)
*/
#define INPUTACTION_SET_LOCKING_KEY_STATE 66
/* Keyboard channel {c73416d0-b0b8-44af-b304-9d2ae99f1b3d} */
#define VISOR_KEYBOARD_CHANNEL_GUID \
GUID_INIT(0xc73416d0, 0xb0b8, 0x44af, \
0xb3, 0x4, 0x9d, 0x2a, 0xe9, 0x9f, 0x1b, 0x3d)
#define VISOR_KEYBOARD_CHANNEL_GUID_STR "c73416d0-b0b8-44af-b304-9d2ae99f1b3d"
/* Mouse channel {addf07d4-94a9-46e2-81c3-61abcdbdbd87} */
#define VISOR_MOUSE_CHANNEL_GUID \
GUID_INIT(0xaddf07d4, 0x94a9, 0x46e2, \
0x81, 0xc3, 0x61, 0xab, 0xcd, 0xbd, 0xbd, 0x87)
#define VISOR_MOUSE_CHANNEL_GUID_STR "addf07d4-94a9-46e2-81c3-61abcdbdbd87"
#define PIXELS_ACROSS_DEFAULT 1024
#define PIXELS_DOWN_DEFAULT 768
#define KEYCODE_TABLE_BYTES 256
struct visor_inputactivity {
u16 action;
u16 arg1;
u16 arg2;
u16 arg3;
} __packed;
struct visor_inputreport {
u64 seq_no;
struct visor_inputactivity activity;
} __packed;
/* header of keyboard/mouse channels */
struct visor_input_channel_data {
u32 n_input_reports;
union {
struct {
u16 x_res;
u16 y_res;
} mouse;
struct {
u32 flags;
} keyboard;
};
} __packed;
enum visorinput_dev_type {
visorinput_keyboard,
visorinput_mouse,
};
/*
* This is the private data that we store for each device. A pointer to this
* struct is maintained via dev_get_drvdata() / dev_set_drvdata() for each
* struct device.
*/
struct visorinput_devdata {
struct visor_device *dev;
/* lock for dev */
struct mutex lock_visor_dev;
struct input_dev *visorinput_dev;
bool paused;
bool interrupts_enabled;
/* size of following array */
unsigned int keycode_table_bytes;
/* for keyboard devices: visorkbd_keycode[] + visorkbd_ext_keycode[] */
unsigned char keycode_table[0];
};
static const guid_t visor_keyboard_channel_guid = VISOR_KEYBOARD_CHANNEL_GUID;
static const guid_t visor_mouse_channel_guid = VISOR_MOUSE_CHANNEL_GUID;
/*
* Borrowed from drivers/input/keyboard/atakbd.c
* This maps 1-byte scancodes to keycodes.
*/
static const unsigned char visorkbd_keycode[KEYCODE_TABLE_BYTES] = {
/* American layout */
[0] = KEY_GRAVE,
[1] = KEY_ESC,
[2] = KEY_1,
[3] = KEY_2,
[4] = KEY_3,
[5] = KEY_4,
[6] = KEY_5,
[7] = KEY_6,
[8] = KEY_7,
[9] = KEY_8,
[10] = KEY_9,
[11] = KEY_0,
[12] = KEY_MINUS,
[13] = KEY_EQUAL,
[14] = KEY_BACKSPACE,
[15] = KEY_TAB,
[16] = KEY_Q,
[17] = KEY_W,
[18] = KEY_E,
[19] = KEY_R,
[20] = KEY_T,
[21] = KEY_Y,
[22] = KEY_U,
[23] = KEY_I,
[24] = KEY_O,
[25] = KEY_P,
[26] = KEY_LEFTBRACE,
[27] = KEY_RIGHTBRACE,
[28] = KEY_ENTER,
[29] = KEY_LEFTCTRL,
[30] = KEY_A,
[31] = KEY_S,
[32] = KEY_D,
[33] = KEY_F,
[34] = KEY_G,
[35] = KEY_H,
[36] = KEY_J,
[37] = KEY_K,
[38] = KEY_L,
[39] = KEY_SEMICOLON,
[40] = KEY_APOSTROPHE,
[41] = KEY_GRAVE,
[42] = KEY_LEFTSHIFT,
[43] = KEY_BACKSLASH,
[44] = KEY_Z,
[45] = KEY_X,
[46] = KEY_C,
[47] = KEY_V,
[48] = KEY_B,
[49] = KEY_N,
[50] = KEY_M,
[51] = KEY_COMMA,
[52] = KEY_DOT,
[53] = KEY_SLASH,
[54] = KEY_RIGHTSHIFT,
[55] = KEY_KPASTERISK,
[56] = KEY_LEFTALT,
[57] = KEY_SPACE,
[58] = KEY_CAPSLOCK,
[59] = KEY_F1,
[60] = KEY_F2,
[61] = KEY_F3,
[62] = KEY_F4,
[63] = KEY_F5,
[64] = KEY_F6,
[65] = KEY_F7,
[66] = KEY_F8,
[67] = KEY_F9,
[68] = KEY_F10,
[69] = KEY_NUMLOCK,
[70] = KEY_SCROLLLOCK,
[71] = KEY_KP7,
[72] = KEY_KP8,
[73] = KEY_KP9,
[74] = KEY_KPMINUS,
[75] = KEY_KP4,
[76] = KEY_KP5,
[77] = KEY_KP6,
[78] = KEY_KPPLUS,
[79] = KEY_KP1,
[80] = KEY_KP2,
[81] = KEY_KP3,
[82] = KEY_KP0,
[83] = KEY_KPDOT,
/* enables UK backslash+pipe key and FR lessthan+greaterthan key */
[86] = KEY_102ND,
[87] = KEY_F11,
[88] = KEY_F12,
[90] = KEY_KPLEFTPAREN,
[91] = KEY_KPRIGHTPAREN,
[92] = KEY_KPASTERISK,
[93] = KEY_KPASTERISK,
[94] = KEY_KPPLUS,
[95] = KEY_HELP,
[96] = KEY_KPENTER,
[97] = KEY_RIGHTCTRL,
[98] = KEY_KPSLASH,
[99] = KEY_KPLEFTPAREN,
[100] = KEY_KPRIGHTPAREN,
[101] = KEY_KPSLASH,
[102] = KEY_HOME,
[103] = KEY_UP,
[104] = KEY_PAGEUP,
[105] = KEY_LEFT,
[106] = KEY_RIGHT,
[107] = KEY_END,
[108] = KEY_DOWN,
[109] = KEY_PAGEDOWN,
[110] = KEY_INSERT,
[111] = KEY_DELETE,
[112] = KEY_MACRO,
[113] = KEY_MUTE
};
/*
* This maps the <xx> in extended scancodes of the form "0xE0 <xx>" into
* keycodes.
*/
static const unsigned char visorkbd_ext_keycode[KEYCODE_TABLE_BYTES] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00 */
0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 */
0, 0, 0, 0, KEY_KPENTER, KEY_RIGHTCTRL, 0, 0, /* 0x18 */
0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 */
KEY_RIGHTALT, 0, 0, 0, 0, 0, 0, 0, /* 0x28 */
0, 0, 0, 0, 0, 0, 0, 0, /* 0x30 */
KEY_RIGHTALT /* AltGr */, 0, 0, 0, 0, 0, 0, 0, /* 0x38 */
0, 0, 0, 0, 0, 0, 0, KEY_HOME, /* 0x40 */
KEY_UP, KEY_PAGEUP, 0, KEY_LEFT, 0, KEY_RIGHT, 0, KEY_END, /* 0x48 */
KEY_DOWN, KEY_PAGEDOWN, KEY_INSERT, KEY_DELETE, 0, 0, 0, 0, /* 0x50 */
0, 0, 0, 0, 0, 0, 0, 0, /* 0x58 */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70 */
};
static int visorinput_open(struct input_dev *visorinput_dev)
{
struct visorinput_devdata *devdata = input_get_drvdata(visorinput_dev);
if (!devdata) {
dev_err(&visorinput_dev->dev,
"%s input_get_drvdata(%p) returned NULL\n",
__func__, visorinput_dev);
return -EINVAL;
}
dev_dbg(&visorinput_dev->dev, "%s opened\n", __func__);
/*
* If we're not paused, really enable interrupts. Regardless of whether
* we are paused, set a flag indicating interrupts should be enabled so
* when we resume, interrupts will really be enabled.
*/
mutex_lock(&devdata->lock_visor_dev);
devdata->interrupts_enabled = true;
if (devdata->paused)
goto out_unlock;
visorbus_enable_channel_interrupts(devdata->dev);
out_unlock:
mutex_unlock(&devdata->lock_visor_dev);
return 0;
}
static void visorinput_close(struct input_dev *visorinput_dev)
{
struct visorinput_devdata *devdata = input_get_drvdata(visorinput_dev);
if (!devdata) {
dev_err(&visorinput_dev->dev,
"%s input_get_drvdata(%p) returned NULL\n",
__func__, visorinput_dev);
return;
}
dev_dbg(&visorinput_dev->dev, "%s closed\n", __func__);
/*
* If we're not paused, really disable interrupts. Regardless of
* whether we are paused, set a flag indicating interrupts should be
* disabled so when we resume we will not re-enable them.
*/
mutex_lock(&devdata->lock_visor_dev);
devdata->interrupts_enabled = false;
if (devdata->paused)
goto out_unlock;
visorbus_disable_channel_interrupts(devdata->dev);
out_unlock:
mutex_unlock(&devdata->lock_visor_dev);
}
/*
* setup_client_keyboard() initializes and returns a Linux input node that we
* can use to deliver keyboard inputs to Linux. We of course do this when we
* see keyboard inputs coming in on a keyboard channel.
*/
static struct input_dev *setup_client_keyboard(void *devdata,
unsigned char *keycode_table)
{
int i;
struct input_dev *visorinput_dev = input_allocate_device();
if (!visorinput_dev)
return NULL;
visorinput_dev->name = "visor Keyboard";
visorinput_dev->phys = "visorkbd:input0";
visorinput_dev->id.bustype = BUS_VIRTUAL;
visorinput_dev->id.vendor = 0x0001;
visorinput_dev->id.product = 0x0001;
visorinput_dev->id.version = 0x0100;
visorinput_dev->evbit[0] = BIT_MASK(EV_KEY) |
BIT_MASK(EV_REP) |
BIT_MASK(EV_LED);
visorinput_dev->ledbit[0] = BIT_MASK(LED_CAPSL) |
BIT_MASK(LED_SCROLLL) |
BIT_MASK(LED_NUML);
visorinput_dev->keycode = keycode_table;
/* sizeof(unsigned char) */
visorinput_dev->keycodesize = 1;
visorinput_dev->keycodemax = KEYCODE_TABLE_BYTES;
for (i = 1; i < visorinput_dev->keycodemax; i++)
set_bit(keycode_table[i], visorinput_dev->keybit);
for (i = 1; i < visorinput_dev->keycodemax; i++)
set_bit(keycode_table[i + KEYCODE_TABLE_BYTES],
visorinput_dev->keybit);
visorinput_dev->open = visorinput_open;
visorinput_dev->close = visorinput_close;
/* pre input_register! */
input_set_drvdata(visorinput_dev, devdata);
return visorinput_dev;
}
static struct input_dev *setup_client_mouse(void *devdata, unsigned int xres,
unsigned int yres)
{
struct input_dev *visorinput_dev = input_allocate_device();
if (!visorinput_dev)
return NULL;
visorinput_dev->name = "visor Mouse";
visorinput_dev->phys = "visormou:input0";
visorinput_dev->id.bustype = BUS_VIRTUAL;
visorinput_dev->id.vendor = 0x0001;
visorinput_dev->id.product = 0x0002;
visorinput_dev->id.version = 0x0100;
visorinput_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
set_bit(BTN_LEFT, visorinput_dev->keybit);
set_bit(BTN_RIGHT, visorinput_dev->keybit);
set_bit(BTN_MIDDLE, visorinput_dev->keybit);
if (xres == 0)
xres = PIXELS_ACROSS_DEFAULT;
if (yres == 0)
yres = PIXELS_DOWN_DEFAULT;
input_set_abs_params(visorinput_dev, ABS_X, 0, xres, 0, 0);
input_set_abs_params(visorinput_dev, ABS_Y, 0, yres, 0, 0);
visorinput_dev->open = visorinput_open;
visorinput_dev->close = visorinput_close;
/* pre input_register! */
input_set_drvdata(visorinput_dev, devdata);
input_set_capability(visorinput_dev, EV_REL, REL_WHEEL);
return visorinput_dev;
}
static struct visorinput_devdata *devdata_create(struct visor_device *dev,
enum visorinput_dev_type dtype)
{
struct visorinput_devdata *devdata = NULL;
unsigned int extra_bytes = 0;
unsigned int size, xres, yres, err;
struct visor_input_channel_data data;
if (dtype == visorinput_keyboard)
/* allocate room for devdata->keycode_table, filled in below */
extra_bytes = KEYCODE_TABLE_BYTES * 2;
devdata = kzalloc(sizeof(*devdata) + extra_bytes, GFP_KERNEL);
if (!devdata)
return NULL;
mutex_init(&devdata->lock_visor_dev);
mutex_lock(&devdata->lock_visor_dev);
devdata->dev = dev;
/*
* visorinput_open() can be called as soon as input_register_device()
* happens, and that will enable channel interrupts. Setting paused
* prevents us from getting into visorinput_channel_interrupt() prior
* to the device structure being totally initialized.
*/
devdata->paused = true;
/*
* This is an input device in a client guest partition, so we need to
* create whatever input nodes are necessary to deliver our inputs to
* the guest OS.
*/
switch (dtype) {
case visorinput_keyboard:
devdata->keycode_table_bytes = extra_bytes;
memcpy(devdata->keycode_table, visorkbd_keycode,
KEYCODE_TABLE_BYTES);
memcpy(devdata->keycode_table + KEYCODE_TABLE_BYTES,
visorkbd_ext_keycode, KEYCODE_TABLE_BYTES);
devdata->visorinput_dev = setup_client_keyboard
(devdata, devdata->keycode_table);
if (!devdata->visorinput_dev)
goto cleanups_register;
break;
case visorinput_mouse:
size = sizeof(struct visor_input_channel_data);
err = visorbus_read_channel(dev, sizeof(struct channel_header),
&data, size);
if (err)
goto cleanups_register;
xres = data.mouse.x_res;
yres = data.mouse.y_res;
devdata->visorinput_dev = setup_client_mouse(devdata, xres,
yres);
if (!devdata->visorinput_dev)
goto cleanups_register;
break;
default:
/* No other input devices supported */
break;
}
dev_set_drvdata(&dev->device, devdata);
mutex_unlock(&devdata->lock_visor_dev);
/*
* Device struct is completely set up now, with the exception of
* visorinput_dev being registered. We need to unlock before we
* register the device, because this can cause an on-stack call of
* visorinput_open(), which would deadlock if we had the lock.
*/
if (input_register_device(devdata->visorinput_dev)) {
input_free_device(devdata->visorinput_dev);
goto err_kfree_devdata;
}
mutex_lock(&devdata->lock_visor_dev);
/*
* Establish calls to visorinput_channel_interrupt() if that is the
* desired state that we've kept track of in interrupts_enabled while
* the device was being created.
*/
devdata->paused = false;
if (devdata->interrupts_enabled)
visorbus_enable_channel_interrupts(dev);
mutex_unlock(&devdata->lock_visor_dev);
return devdata;
cleanups_register:
mutex_unlock(&devdata->lock_visor_dev);
err_kfree_devdata:
kfree(devdata);
return NULL;
}
static int visorinput_probe(struct visor_device *dev)
{
const guid_t *guid;
enum visorinput_dev_type dtype;
guid = visorchannel_get_guid(dev->visorchannel);
if (guid_equal(guid, &visor_mouse_channel_guid))
dtype = visorinput_mouse;
else if (guid_equal(guid, &visor_keyboard_channel_guid))
dtype = visorinput_keyboard;
else
return -ENODEV;
visorbus_disable_channel_interrupts(dev);
if (!devdata_create(dev, dtype))
return -ENOMEM;
return 0;
}
static void unregister_client_input(struct input_dev *visorinput_dev)
{
if (visorinput_dev)
input_unregister_device(visorinput_dev);
}
static void visorinput_remove(struct visor_device *dev)
{
struct visorinput_devdata *devdata = dev_get_drvdata(&dev->device);
if (!devdata)
return;
mutex_lock(&devdata->lock_visor_dev);
visorbus_disable_channel_interrupts(dev);
/*
* due to above, at this time no thread of execution will be in
* visorinput_channel_interrupt()
*/
dev_set_drvdata(&dev->device, NULL);
mutex_unlock(&devdata->lock_visor_dev);
unregister_client_input(devdata->visorinput_dev);
kfree(devdata);
}
/*
* Make it so the current locking state of the locking key indicated by
* <keycode> is as indicated by <desired_state> (1=locked, 0=unlocked).
*/
static void handle_locking_key(struct input_dev *visorinput_dev, int keycode,
int desired_state)
{
int led;
switch (keycode) {
case KEY_CAPSLOCK:
led = LED_CAPSL;
break;
case KEY_SCROLLLOCK:
led = LED_SCROLLL;
break;
case KEY_NUMLOCK:
led = LED_NUML;
break;
default:
led = -1;
return;
}
if (test_bit(led, visorinput_dev->led) != desired_state) {
input_report_key(visorinput_dev, keycode, 1);
input_sync(visorinput_dev);
input_report_key(visorinput_dev, keycode, 0);
input_sync(visorinput_dev);
__change_bit(led, visorinput_dev->led);
}
}
/*
* <scancode> is either a 1-byte scancode, or an extended 16-bit scancode with
* 0xE0 in the low byte and the extended scancode value in the next higher byte.
*/
static int scancode_to_keycode(int scancode)
{
if (scancode > 0xff)
return visorkbd_ext_keycode[(scancode >> 8) & 0xff];
return visorkbd_keycode[scancode];
}
static int calc_button(int x)
{
switch (x) {
case 1:
return BTN_LEFT;
case 2:
return BTN_MIDDLE;
case 3:
return BTN_RIGHT;
default:
return -EINVAL;
}
}
/*
* This is used only when this driver is active as an input driver in the
* client guest partition. It is called periodically so we can obtain inputs
* from the channel, and deliver them to the guest OS.
*/
static void visorinput_channel_interrupt(struct visor_device *dev)
{
struct visor_inputreport r;
int scancode, keycode;
struct input_dev *visorinput_dev;
int xmotion, ymotion, button;
int i;
struct visorinput_devdata *devdata = dev_get_drvdata(&dev->device);
if (!devdata)
return;
visorinput_dev = devdata->visorinput_dev;
while (!visorchannel_signalremove(dev->visorchannel, 0, &r)) {
scancode = r.activity.arg1;
keycode = scancode_to_keycode(scancode);
switch (r.activity.action) {
case INPUTACTION_KEY_DOWN:
input_report_key(visorinput_dev, keycode, 1);
input_sync(visorinput_dev);
break;
case INPUTACTION_KEY_UP:
input_report_key(visorinput_dev, keycode, 0);
input_sync(visorinput_dev);
break;
case INPUTACTION_KEY_DOWN_UP:
input_report_key(visorinput_dev, keycode, 1);
input_sync(visorinput_dev);
input_report_key(visorinput_dev, keycode, 0);
input_sync(visorinput_dev);
break;
case INPUTACTION_SET_LOCKING_KEY_STATE:
handle_locking_key(visorinput_dev, keycode,
r.activity.arg2);
break;
case INPUTACTION_XY_MOTION:
xmotion = r.activity.arg1;
ymotion = r.activity.arg2;
input_report_abs(visorinput_dev, ABS_X, xmotion);
input_report_abs(visorinput_dev, ABS_Y, ymotion);
input_sync(visorinput_dev);
break;
case INPUTACTION_MOUSE_BUTTON_DOWN:
button = calc_button(r.activity.arg1);
if (button < 0)
break;
input_report_key(visorinput_dev, button, 1);
input_sync(visorinput_dev);
break;
case INPUTACTION_MOUSE_BUTTON_UP:
button = calc_button(r.activity.arg1);
if (button < 0)
break;
input_report_key(visorinput_dev, button, 0);
input_sync(visorinput_dev);
break;
case INPUTACTION_MOUSE_BUTTON_CLICK:
button = calc_button(r.activity.arg1);
if (button < 0)
break;
input_report_key(visorinput_dev, button, 1);
input_sync(visorinput_dev);
input_report_key(visorinput_dev, button, 0);
input_sync(visorinput_dev);
break;
case INPUTACTION_MOUSE_BUTTON_DCLICK:
button = calc_button(r.activity.arg1);
if (button < 0)
break;
for (i = 0; i < 2; i++) {
input_report_key(visorinput_dev, button, 1);
input_sync(visorinput_dev);
input_report_key(visorinput_dev, button, 0);
input_sync(visorinput_dev);
}
break;
case INPUTACTION_WHEEL_ROTATE_AWAY:
input_report_rel(visorinput_dev, REL_WHEEL, 1);
input_sync(visorinput_dev);
break;
case INPUTACTION_WHEEL_ROTATE_TOWARD:
input_report_rel(visorinput_dev, REL_WHEEL, -1);
input_sync(visorinput_dev);
break;
default:
/* Unsupported input action */
break;
}
}
}
static int visorinput_pause(struct visor_device *dev,
visorbus_state_complete_func complete_func)
{
int rc;
struct visorinput_devdata *devdata = dev_get_drvdata(&dev->device);
if (!devdata) {
rc = -ENODEV;
goto out;
}
mutex_lock(&devdata->lock_visor_dev);
if (devdata->paused) {
rc = -EBUSY;
goto out_locked;
}
if (devdata->interrupts_enabled)
visorbus_disable_channel_interrupts(dev);
/*
* due to above, at this time no thread of execution will be in
* visorinput_channel_interrupt()
*/
devdata->paused = true;
complete_func(dev, 0);
rc = 0;
out_locked:
mutex_unlock(&devdata->lock_visor_dev);
out:
return rc;
}
static int visorinput_resume(struct visor_device *dev,
visorbus_state_complete_func complete_func)
{
int rc;
struct visorinput_devdata *devdata = dev_get_drvdata(&dev->device);
if (!devdata) {
rc = -ENODEV;
goto out;
}
mutex_lock(&devdata->lock_visor_dev);
if (!devdata->paused) {
rc = -EBUSY;
goto out_locked;
}
devdata->paused = false;
complete_func(dev, 0);
/*
* Re-establish calls to visorinput_channel_interrupt() if that is the
* desired state that we've kept track of in interrupts_enabled while
* the device was paused.
*/
if (devdata->interrupts_enabled)
visorbus_enable_channel_interrupts(dev);
rc = 0;
out_locked:
mutex_unlock(&devdata->lock_visor_dev);
out:
return rc;
}
/* GUIDS for all channel types supported by this driver. */
static struct visor_channeltype_descriptor visorinput_channel_types[] = {
{ VISOR_KEYBOARD_CHANNEL_GUID, "keyboard",
sizeof(struct channel_header), 0 },
{ VISOR_MOUSE_CHANNEL_GUID, "mouse", sizeof(struct channel_header), 0 },
{}
};
static struct visor_driver visorinput_driver = {
.name = "visorinput",
.owner = THIS_MODULE,
.channel_types = visorinput_channel_types,
.probe = visorinput_probe,
.remove = visorinput_remove,
.channel_interrupt = visorinput_channel_interrupt,
.pause = visorinput_pause,
.resume = visorinput_resume,
};
module_driver(visorinput_driver, visorbus_register_visor_driver,
visorbus_unregister_visor_driver);
MODULE_DEVICE_TABLE(visorbus, visorinput_channel_types);
MODULE_AUTHOR("Unisys");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("s-Par human input driver for virtual keyboard/mouse");
MODULE_ALIAS("visorbus:" VISOR_MOUSE_CHANNEL_GUID_STR);
MODULE_ALIAS("visorbus:" VISOR_KEYBOARD_CHANNEL_GUID_STR);
+15
View File
@@ -0,0 +1,15 @@
#
# Unisys visornic configuration
#
config UNISYS_VISORNIC
tristate "Unisys visornic driver"
depends on UNISYSSPAR && UNISYS_VISORBUS && NET
---help---
The Unisys Visornic driver provides support for s-Par network
devices exposed on the s-Par visorbus. When a message is sent
to visorbus to create a network device, the probe function of
visornic is called to create the netdev device. Networking on
s-Par switches will not work if this driver is not selected.
If you say Y here, you will enable the Unisys visornic driver.
+10
View File
@@ -0,0 +1,10 @@
#
# Makefile for Unisys channel
#
obj-$(CONFIG_UNISYS_VISORNIC) += visornic.o
visornic-y := visornic_main.o
ccflags-y += -Idrivers/staging/unisys/include
File diff suppressed because it is too large. Load diff