staging: unisys: Convert device functions to pass dev_info pointer around
[firefly-linux-kernel-4.4.55.git] / drivers / staging / unisys / visorbus / visorbus_private.h
1 /* visorchipset.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 #ifndef __VISORCHIPSET_H__
19 #define __VISORCHIPSET_H__
20
21 #include <linux/uuid.h>
22
23 #include "channel.h"
24 #include "controlvmchannel.h"
25 #include "vbusdeviceinfo.h"
26 #include "vbushelper.h"
27
28 struct visorchannel;
29
30 enum visorchipset_addresstype {
31         /** address is guest physical, but outside of the physical memory
32          *  region that is controlled by the running OS (this is the normal
33          *  address type for Supervisor channels)
34          */
35         ADDRTYPE_LOCALPHYSICAL,
36
37         /** address is guest physical, and withIN the confines of the
38          *  physical memory controlled by the running OS.
39          */
40         ADDRTYPE_LOCALTEST,
41 };
42
43 /** Attributes for a particular Supervisor channel.
44  */
45 struct visorchipset_channel_info {
46         enum visorchipset_addresstype addr_type;
47         u64 channel_addr;
48         struct irq_info intr;
49         u64 n_channel_bytes;
50         uuid_le channel_type_uuid;
51         uuid_le channel_inst_uuid;
52 };
53
54 /** Attributes for a particular Supervisor device.
55  *  Any visorchipset client can query these attributes using
56  *  visorchipset_get_client_device_info() or
57  *  visorchipset_get_server_device_info().
58  */
59 struct visorchipset_device_info {
60         struct list_head entry;
61         u32 bus_no;
62         u32 dev_no;
63         uuid_le dev_inst_uuid;
64         struct visorchipset_state state;
65         struct visorchipset_channel_info chan_info;
66         u32 reserved1;          /* control_vm_id */
67         u64 reserved2;
68         u32 switch_no;          /* when devState.attached==1 */
69         u32 internal_port_no;   /* when devState.attached==1 */
70         struct controlvm_message_header pending_msg_hdr;/* CONTROLVM_MESSAGE */
71         /** For private use by the bus driver */
72         void *bus_driver_context;
73 };
74
75 /** Attributes for a particular Supervisor bus.
76  *  (For a service partition acting as the server for buses/devices, there
77  *  is a 1-to-1 relationship between busses and guest partitions.)
78  *  Any visorchipset client can query these attributes using
79  *  visorchipset_get_client_bus_info() or visorchipset_get_bus_info().
80  */
81 struct visorchipset_bus_info {
82         struct list_head entry;
83         u32 bus_no;
84         struct visorchipset_state state;
85         struct visorchipset_channel_info chan_info;
86         uuid_le partition_uuid;
87         u64 partition_handle;
88         u8 *name;               /* UTF8 */
89         u8 *description;        /* UTF8 */
90         u64 reserved1;
91         u32 reserved2;
92         struct {
93                 u32 server:1;
94                 /* Add new fields above. */
95                 /* Remaining bits in this 32-bit word are unused. */
96         } flags;
97         struct controlvm_message_header pending_msg_hdr;/* CONTROLVM MsgHdr */
98         /** For private use by the bus driver */
99         void *bus_driver_context;
100 };
101
102 /*  These functions will be called from within visorchipset when certain
103  *  events happen.  (The implementation of these functions is outside of
104  *  visorchipset.)
105  */
106 struct visorchipset_busdev_notifiers {
107         void (*bus_create)(struct visorchipset_bus_info *bus_info);
108         void (*bus_destroy)(struct visorchipset_bus_info *bus_info);
109         void (*device_create)(struct visorchipset_device_info *bus_info);
110         void (*device_destroy)(struct visorchipset_device_info *bus_info);
111         void (*device_pause)(struct visorchipset_device_info *bus_info);
112         void (*device_resume)(struct visorchipset_device_info *bus_info);
113 };
114
115 /*  These functions live inside visorchipset, and will be called to indicate
116  *  responses to specific events (by code outside of visorchipset).
117  *  For now, the value for each response is simply either:
118  *       0 = it worked
119  *      -1 = it failed
120  */
121 struct visorchipset_busdev_responders {
122         void (*bus_create)(struct visorchipset_bus_info *p, int response);
123         void (*bus_destroy)(struct visorchipset_bus_info *p, int response);
124         void (*device_create)(struct visorchipset_device_info *p, int response);
125         void (*device_destroy)(struct visorchipset_device_info *p,
126                                int response);
127         void (*device_pause)(struct visorchipset_device_info *p, int response);
128         void (*device_resume)(struct visorchipset_device_info *p, int response);
129 };
130
131 /** Register functions (in the bus driver) to get called by visorchipset
132  *  whenever a bus or device appears for which this guest is to be the
133  *  client for.  visorchipset will fill in <responders>, to indicate
134  *  functions the bus driver should call to indicate message responses.
135  */
136 void
137 visorchipset_register_busdev(
138                         struct visorchipset_busdev_notifiers *notifiers,
139                         struct visorchipset_busdev_responders *responders,
140                         struct ultra_vbus_deviceinfo *driver_info);
141
142 bool visorchipset_get_bus_info(u32 bus_no,
143                                struct visorchipset_bus_info *bus_info);
144 bool visorchipset_get_device_info(u32 bus_no, u32 dev_no,
145                                   struct visorchipset_device_info *dev_info);
146 bool visorchipset_set_bus_context(struct visorchipset_bus_info *bus_info,
147                                   void *context);
148
149 /* visorbus init and exit functions */
150 int visorbus_init(void);
151 void visorbus_exit(void);
152 #endif