Merge remote-tracking branch 'staging/staging-next'
[deliverable/linux.git] / drivers / staging / unisys / include / visorbus.h
CommitLineData
3703987c
EA
1/* visorbus.h
2 *
3 * Copyright (C) 2010 - 2013 UNISYS CORPORATION
4 * All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or (at
9 * your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
14 * NON INFRINGEMENT. See the GNU General Public License for more
15 * details.
16 */
17
18/*
19 * This header file is to be included by other kernel mode components that
20 * implement a particular kind of visor_device. Each of these other kernel
21 * mode components is called a visor device driver. Refer to visortemplate
22 * for a minimal sample visor device driver.
23 *
24 * There should be nothing in this file that is private to the visorbus
25 * bus implementation itself.
26 *
27 */
28
29#ifndef __VISORBUS_H__
30#define __VISORBUS_H__
31
32#include <linux/device.h>
33#include <linux/module.h>
c0a14641 34#include <linux/poll.h>
3703987c
EA
35#include <linux/kernel.h>
36#include <linux/uuid.h>
9ebab649
TS
37#include <linux/seq_file.h>
38#include <linux/slab.h>
3703987c 39
3703987c 40#include "channel.h"
f6439218 41
3703987c
EA
42struct visor_driver;
43struct visor_device;
1fb3016e 44extern struct bus_type visorbus_type;
3703987c
EA
45
46typedef void (*visorbus_state_complete_func) (struct visor_device *dev,
a298bc0b 47 int status);
1fb3016e
DZ
48struct visorchipset_state {
49 u32 created:1;
50 u32 attached:1;
51 u32 configured:1;
52 u32 running:1;
53 /* Add new fields above. */
54 /* Remaining bits in this 32-bit word are unused. */
55};
3703987c
EA
56
57/** This struct describes a specific Supervisor channel, by providing its
58 * GUID, name, and sizes.
59 */
60struct visor_channeltype_descriptor {
61 const uuid_le guid;
62 const char *name;
3703987c
EA
63};
64
b9edaf7c
AC
65/**
66 * struct visor_driver - Information provided by each visor driver when it
67 * registers with the visorbus driver.
68 * @name: Name of the visor driver.
69 * @version: The numbered version of the driver (x.x.xxx).
70 * @vertag: A human readable version string.
71 * @owner: The module owner.
72 * @channel_types: Types of channels handled by this driver, ending with
73 * a zero GUID. Our specialized BUS.match() method knows
74 * about this list, and uses it to determine whether this
75 * driver will in fact handle a new device that it has
76 * detected.
77 * @probe: Called when a new device comes online, by our probe()
78 * function specified by driver.probe() (triggered
79 * ultimately by some call to driver_register(),
80 * bus_add_driver(), or driver_attach()).
81 * @remove: Called when a new device is removed, by our remove()
82 * function specified by driver.remove() (triggered
83 * ultimately by some call to device_release_driver()).
84 * @channel_interrupt: Called periodically, whenever there is a possiblity
85 * that "something interesting" may have happened to the
86 * channel.
87 * @pause: Called to initiate a change of the device's state. If
88 * the return valu`e is < 0, there was an error and the
89 * state transition will NOT occur. If the return value
90 * is >= 0, then the state transition was INITIATED
91 * successfully, and complete_func() will be called (or
92 * was just called) with the final status when either the
93 * state transition fails or completes successfully.
94 * @resume: Behaves similar to pause.
95 * @driver: Private reference to the device driver. For use by bus
96 * driver only.
97 * @version_attr: Private version field. For use by bus driver only.
3703987c
EA
98 */
99struct visor_driver {
100 const char *name;
101 const char *version;
102 const char *vertag;
3703987c 103 struct module *owner;
3703987c 104 struct visor_channeltype_descriptor *channel_types;
3703987c 105 int (*probe)(struct visor_device *dev);
3703987c 106 void (*remove)(struct visor_device *dev);
3703987c 107 void (*channel_interrupt)(struct visor_device *dev);
3703987c 108 int (*pause)(struct visor_device *dev,
a298bc0b 109 visorbus_state_complete_func complete_func);
3703987c 110 int (*resume)(struct visor_device *dev,
a298bc0b 111 visorbus_state_complete_func complete_func);
3703987c 112
b9edaf7c 113 /* These fields are for private use by the bus driver only. */
3703987c
EA
114 struct device_driver driver;
115 struct driver_attribute version_attr;
116};
117
d15a65be
TS
118#define to_visor_driver(x) ((x) ? \
119 (container_of(x, struct visor_driver, driver)) : (NULL))
3703987c 120
39b92809
AC
121/**
122 * struct visor_device - A device type for things "plugged" into the visorbus
123 * bus
eafc6a94 124 * @visorchannel: Points to the channel that the device is
39b92809 125 * associated with.
eafc6a94
DB
126 * @channel_type_guid: Identifies the channel type to the bus driver.
127 * @device: Device struct meant for use by the bus driver
39b92809 128 * only.
eafc6a94
DB
129 * @list_all: Used by the bus driver to enumerate devices.
130 * @timer: Timer fired periodically to do interrupt-type
9ebab649 131 * activity.
eafc6a94 132 * @being_removed: Indicates that the device is being removed from
39b92809 133 * the bus. Private bus driver use only.
eafc6a94 134 * @visordriver_callback_lock: Used by the bus driver to lock when handling
39b92809 135 * channel events.
eafc6a94 136 * @pausing: Indicates that a change towards a paused state.
39b92809 137 * is in progress. Only modified by the bus driver.
eafc6a94 138 * @resuming: Indicates that a change towards a running state
39b92809 139 * is in progress. Only modified by the bus driver.
eafc6a94
DB
140 * @chipset_bus_no: Private field used by the bus driver.
141 * @chipset_dev_no: Private field used the bus driver.
142 * @state: Used to indicate the current state of the
39b92809 143 * device.
eafc6a94
DB
144 * @inst: Unique GUID for this instance of the device.
145 * @name: Name of the device.
146 * @pending_msg_hdr: For private use by bus driver to respond to
39b92809 147 * hypervisor requests.
eafc6a94 148 * @vbus_hdr_info: A pointer to header info. Private use by bus
39b92809 149 * driver.
eafc6a94 150 * @partition_uuid: Indicates client partion id. This should be the
39b92809
AC
151 * same across all visor_devices in the current
152 * guest. Private use by bus driver only.
153 */
3703987c
EA
154
155struct visor_device {
3703987c
EA
156 struct visorchannel *visorchannel;
157 uuid_le channel_type_guid;
39b92809 158 /* These fields are for private use by the bus driver only. */
3703987c
EA
159 struct device device;
160 struct list_head list_all;
9ebab649
TS
161 struct timer_list timer;
162 bool timer_active;
3703987c 163 bool being_removed;
d505855e 164 struct mutex visordriver_callback_lock;
3703987c
EA
165 bool pausing;
166 bool resuming;
65bd6e46
DZ
167 u32 chipset_bus_no;
168 u32 chipset_dev_no;
1fb3016e 169 struct visorchipset_state state;
1fb3016e
DZ
170 uuid_le inst;
171 u8 *name;
1fb3016e
DZ
172 struct controlvm_message_header *pending_msg_hdr;
173 void *vbus_hdr_info;
1fb3016e 174 uuid_le partition_uuid;
3703987c
EA
175};
176
177#define to_visor_device(x) container_of(x, struct visor_device, device)
178
3703987c
EA
179int visorbus_register_visor_driver(struct visor_driver *);
180void visorbus_unregister_visor_driver(struct visor_driver *);
181int visorbus_read_channel(struct visor_device *dev,
182 unsigned long offset, void *dest,
183 unsigned long nbytes);
184int visorbus_write_channel(struct visor_device *dev,
185 unsigned long offset, void *src,
186 unsigned long nbytes);
3703987c
EA
187void visorbus_enable_channel_interrupts(struct visor_device *dev);
188void visorbus_disable_channel_interrupts(struct visor_device *dev);
3703987c 189
e308d698
EA
190/* Levels of severity for diagnostic events, in order from lowest severity to
191 * highest (i.e. fatal errors are the most severe, and should always be logged,
192 * but info events rarely need to be logged except during debugging). The
193 * values DIAG_SEVERITY_ENUM_BEGIN and DIAG_SEVERITY_ENUM_END are not valid
194 * severity values. They exist merely to dilineate the list, so that future
195 * additions won't require changes to the driver (i.e. when checking for
196 * out-of-range severities in SetSeverity). The values DIAG_SEVERITY_OVERRIDE
197 * and DIAG_SEVERITY_SHUTOFF are not valid severity values for logging events
198 * but they are valid for controlling the amount of event data. Changes made
199 * to the enum, need to be reflected in s-Par.
200 */
201enum diag_severity {
202 DIAG_SEVERITY_VERBOSE = 0,
203 DIAG_SEVERITY_INFO = 1,
204 DIAG_SEVERITY_WARNING = 2,
205 DIAG_SEVERITY_ERR = 3,
206 DIAG_SEVERITY_PRINT = 4,
207};
208
779d0752 209bool visorchannel_signalremove(struct visorchannel *channel, u32 queue,
f6439218 210 void *msg);
779d0752 211bool visorchannel_signalinsert(struct visorchannel *channel, u32 queue,
f6439218 212 void *msg);
fdc792cd 213bool visorchannel_signalempty(struct visorchannel *channel, u32 queue);
f6439218 214uuid_le visorchannel_get_uuid(struct visorchannel *channel);
f6439218 215
d32517e3
DZ
216#define BUS_ROOT_DEVICE UINT_MAX
217struct visor_device *visorbus_get_device_by_id(u32 bus_no, u32 dev_no,
218 struct visor_device *from);
3703987c 219#endif
This page took 0.169716 seconds and 5 git commands to generate.