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