Blame view

drivers/visorbus/controlvmchannel.h 22.4 KB
af8311451   Nishad Kamdar   drivers: visorbus...
1
  /* SPDX-License-Identifier: GPL-2.0 */
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
2
3
  /*
   * Copyright (C) 2010 - 2015 UNISYS CORPORATION
12e364b9f   Ken Cox   staging: visorchi...
4
   * All rights reserved.
12e364b9f   Ken Cox   staging: visorchi...
5
6
7
8
   */
  
  #ifndef __CONTROLVMCHANNEL_H__
  #define __CONTROLVMCHANNEL_H__
90addb021   Benjamin Romer   staging: unisys: ...
9
  #include <linux/uuid.h>
93d3ad90c   David Kershner   drivers: visorbus...
10
  #include <linux/visorbus.h>
af96e9c05   Benjamin Romer   staging: unisys: ...
11

12e364b9f   Ken Cox   staging: visorchi...
12
  /* {2B3C2D10-7EF5-4ad8-B966-3448B7386B3D} */
b32c5cb84   Andy Shevchenko   staging: unisys: ...
13
14
15
  #define VISOR_CONTROLVM_CHANNEL_GUID \
  	GUID_INIT(0x2b3c2d10, 0x7ef5, 0x4ad8, \
  		  0xb9, 0x66, 0x34, 0x48, 0xb7, 0x38, 0x6b, 0x3d)
12e364b9f   Ken Cox   staging: visorchi...
16

7e5a1a764   Erik Arfvidson   staging: unisys: ...
17
  #define CONTROLVM_MESSAGE_MAX 64
12e364b9f   Ken Cox   staging: visorchi...
18

fd3074867   Sameer Wadgaonkar   staging: unisys: ...
19
20
21
22
23
24
  /*
   * Must increment this 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.
7e5a1a764   Erik Arfvidson   staging: unisys: ...
25
   */
c5a28902b   Sameer Wadgaonkar   staging: unisys: ...
26
  #define VISOR_CONTROLVM_CHANNEL_VERSIONID 1
12e364b9f   Ken Cox   staging: visorchi...
27

7e5a1a764   Erik Arfvidson   staging: unisys: ...
28
  /* Defines for various channel queues */
b06f5d111   Erik Arfvidson   staging: unisys: ...
29
30
31
32
  #define CONTROLVM_QUEUE_REQUEST		0
  #define CONTROLVM_QUEUE_RESPONSE	1
  #define CONTROLVM_QUEUE_EVENT		2
  #define CONTROLVM_QUEUE_ACK		3
12e364b9f   Ken Cox   staging: visorchi...
33

7e5a1a764   Erik Arfvidson   staging: unisys: ...
34
  /* Max num of messages stored during IOVM creation to be reused after crash */
941affcbe   David Binder   staging: unisys: ...
35
  #define CONTROLVM_CRASHMSG_MAX 2
12e364b9f   Ken Cox   staging: visorchi...
36

fd3074867   Sameer Wadgaonkar   staging: unisys: ...
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  /*
   * struct visor_segment_state
   * @enabled:   May enter other states.
   * @active:    Assigned to active partition.
   * @alive:     Configure message sent to service/server.
   * @revoked:   Similar to partition state ShuttingDown.
   * @allocated: Memory (device/port number) has been selected by Command.
   * @known:     Has been introduced to the service/guest partition.
   * @ready:     Service/Guest partition has responded to introduction.
   * @operating: Resource is configured and operating.
   * @reserved:  Natural alignment.
   *
   * Note: Don't use high bit unless we need to switch to ushort which is
   * non-compliant.
   */
545f09138   Sameer Wadgaonkar   staging: unisys: ...
52
  struct visor_segment_state  {
1e3ab5219   Erik Arfvidson   staging: unisys: ...
53
  	u16 enabled:1;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
54
  	u16 active:1;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
55
  	u16 alive:1;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
56
  	u16 revoked:1;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
57
  	u16 allocated:1;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
58
  	u16 known:1;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
59
  	u16 ready:1;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
60
  	u16 operating:1;
2833399ed   Sameer Wadgaonkar   staging: unisys: ...
61
  	u16 reserved:8;
2833399ed   Sameer Wadgaonkar   staging: unisys: ...
62
  } __packed;
389f55920   David Kershner   staging: unisys: ...
63

545f09138   Sameer Wadgaonkar   staging: unisys: ...
64
  static const struct visor_segment_state segment_state_running = {
389f55920   David Kershner   staging: unisys: ...
65
66
  	1, 1, 1, 0, 1, 1, 1, 1
  };
545f09138   Sameer Wadgaonkar   staging: unisys: ...
67
  static const struct visor_segment_state segment_state_paused = {
389f55920   David Kershner   staging: unisys: ...
68
69
  	1, 1, 1, 0, 1, 1, 1, 0
  };
545f09138   Sameer Wadgaonkar   staging: unisys: ...
70
  static const struct visor_segment_state segment_state_standby = {
389f55920   David Kershner   staging: unisys: ...
71
72
  	1, 1, 0, 0, 1, 1, 1, 0
  };
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
  /*
   * enum controlvm_id
   * @CONTROLVM_INVALID:
   * @CONTROLVM_BUS_CREATE:		CP --> SP, GP.
   * @CONTROLVM_BUS_DESTROY:		CP --> SP, GP.
   * @CONTROLVM_BUS_CONFIGURE:		CP --> SP.
   * @CONTROLVM_BUS_CHANGESTATE:		CP --> SP, GP.
   * @CONTROLVM_BUS_CHANGESTATE_EVENT:	SP, GP --> CP.
   * @CONTROLVM_DEVICE_CREATE:		CP --> SP, GP.
   * @CONTROLVM_DEVICE_DESTROY:		CP --> SP, GP.
   * @CONTROLVM_DEVICE_CONFIGURE:		CP --> SP.
   * @CONTROLVM_DEVICE_CHANGESTATE:	CP --> SP, GP.
   * @CONTROLVM_DEVICE_CHANGESTATE_EVENT:	SP, GP --> CP.
   * @CONTROLVM_DEVICE_RECONFIGURE:	CP --> Boot.
   * @CONTROLVM_CHIPSET_INIT:		CP --> SP, GP.
   * @CONTROLVM_CHIPSET_STOP:		CP --> SP, GP.
   * @CONTROLVM_CHIPSET_READY:		CP --> SP.
   * @CONTROLVM_CHIPSET_SELFTEST:		CP --> SP.
   *
   * Ids for commands that may appear in either queue of a ControlVm channel.
12e364b9f   Ken Cox   staging: visorchi...
93
   *
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
94
95
96
97
   * Commands that are initiated by the command partition (CP), by an IO or
   * console service partition (SP), or by a guest partition (GP) are:
   * - issued on the RequestQueue queue (q #0) in the ControlVm channel
   * - responded to on the ResponseQueue queue (q #1) in the ControlVm channel
12e364b9f   Ken Cox   staging: visorchi...
98
   *
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
99
100
101
102
   * Events that are initiated by an IO or console service partition (SP) or
   * by a guest partition (GP) are:
   * - issued on the EventQueue queue (q #2) in the ControlVm channel
   * - responded to on the EventAckQueue queue (q #3) in the ControlVm channel
12e364b9f   Ken Cox   staging: visorchi...
103
   */
53bebb13a   Benjamin Romer   staging: unisys: ...
104
  enum controlvm_id {
12e364b9f   Ken Cox   staging: visorchi...
105
  	CONTROLVM_INVALID = 0,
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
  	/*
  	 * SWITCH commands required Parameter: SwitchNumber.
  	 * BUS commands required Parameter: BusNumber
  	 */
  	CONTROLVM_BUS_CREATE = 0x101,
  	CONTROLVM_BUS_DESTROY = 0x102,
  	CONTROLVM_BUS_CONFIGURE = 0x104,
  	CONTROLVM_BUS_CHANGESTATE = 0x105,
  	CONTROLVM_BUS_CHANGESTATE_EVENT = 0x106,
  	/* DEVICE commands required Parameter: BusNumber, DeviceNumber */
  	CONTROLVM_DEVICE_CREATE = 0x201,
  	CONTROLVM_DEVICE_DESTROY = 0x202,
  	CONTROLVM_DEVICE_CONFIGURE = 0x203,
  	CONTROLVM_DEVICE_CHANGESTATE = 0x204,
  	CONTROLVM_DEVICE_CHANGESTATE_EVENT = 0x205,
  	CONTROLVM_DEVICE_RECONFIGURE = 0x206,
  	/* CHIPSET commands */
  	CONTROLVM_CHIPSET_INIT = 0x301,
  	CONTROLVM_CHIPSET_STOP = 0x302,
  	CONTROLVM_CHIPSET_READY = 0x304,
  	CONTROLVM_CHIPSET_SELFTEST = 0x305,
d8ad8b0ca   Veronika Kabatova   staging: unisys: ...
127
  };
12e364b9f   Ken Cox   staging: visorchi...
128

fd3074867   Sameer Wadgaonkar   staging: unisys: ...
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
  /*
   * struct irq_info
   * @reserved1:	     Natural alignment purposes
   * @recv_irq_handle: Specifies interrupt handle. It is used to retrieve the
   *		     corresponding interrupt pin from Monitor; and the interrupt
   *		     pin is used to connect to the corresponding interrupt.
   *		     Used by IOPart-GP only.
   * @recv_irq_vector: Specifies interrupt vector. It, interrupt pin, and shared
   *		     are used to connect to the corresponding interrupt.
   *		     Used by IOPart-GP only.
   * @recv_irq_shared: Specifies if the recvInterrupt is shared.  It, interrupt
   *		     pin and vector are used to connect to 0 = not shared;
   *		     1 = shared the corresponding interrupt.
   *		     Used by IOPart-GP only.
   * @reserved:	     Natural alignment purposes
   */
4eddbf139   Benjamin Romer   staging: unisys: ...
145
  struct irq_info {
22a0350b5   Erik Arfvidson   staging: unisys: ...
146
  	u64 reserved1;
af3286bdb   Benjamin Romer   staging: unisys: ...
147
  	u64 recv_irq_handle;
af3286bdb   Benjamin Romer   staging: unisys: ...
148
  	u32 recv_irq_vector;
af3286bdb   Benjamin Romer   staging: unisys: ...
149
  	u8 recv_irq_shared;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
150
  	u8 reserved[3];
2833399ed   Sameer Wadgaonkar   staging: unisys: ...
151
  } __packed;
12e364b9f   Ken Cox   staging: visorchi...
152

fd3074867   Sameer Wadgaonkar   staging: unisys: ...
153
154
155
156
157
158
159
160
  /*
   * struct efi_visor_indication
   * @boot_to_fw_ui: Stop in UEFI UI
   * @clear_nvram:   Clear NVRAM
   * @clear_cmos:	   Clear CMOS
   * @boot_to_tool:  Run install tool
   * @reserved:	   Natural alignment
   */
545f09138   Sameer Wadgaonkar   staging: unisys: ...
161
  struct efi_visor_indication  {
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
162
163
164
165
166
167
  	u64 boot_to_fw_ui:1;
  	u64 clear_nvram:1;
  	u64 clear_cmos:1;
  	u64 boot_to_tool:1;
  	/* Remaining bits are available */
  	u64 reserved:60;
2833399ed   Sameer Wadgaonkar   staging: unisys: ...
168
  } __packed;
12e364b9f   Ken Cox   staging: visorchi...
169

d3ad6e69c   Sameer Wadgaonkar   staging: unisys: ...
170
171
172
  enum visor_chipset_feature {
  	VISOR_CHIPSET_FEATURE_REPLY = 0x00000001,
  	VISOR_CHIPSET_FEATURE_PARA_HOTPLUG = 0x00000002,
b9b141e85   Benjamin Romer   staging: unisys: ...
173
  };
12e364b9f   Ken Cox   staging: visorchi...
174

fd3074867   Sameer Wadgaonkar   staging: unisys: ...
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
  /*
   * struct controlvm_message_header
   * @id:		       See CONTROLVM_ID.
   * @message_size:      Includes size of this struct + size of message.
   * @segment_index:     Index of segment containing Vm message/information.
   * @completion_status: Error status code or result of  message completion.
   * @struct flags:
   *	@failed:	     =1 in a response to signify failure.
   *	@response_expected:  =1 in all messages that expect a response.
   *	@server:	     =1 in all bus & device-related messages where the
   *			     message receiver is to act as the bus or device
   *			     server.
   *	@test_message:	     =1 for testing use only (Control and Command
   *			     ignore this).
   *	@partial_completion: =1 if there are forthcoming responses/acks
   *                           associated with this message.
   *      @preserve:	     =1 this is to let us know to preserve channel
   *			     contents.
   *	@writer_in_diag:     =1 the DiagWriter is active in the Diagnostic
   *			     Partition.
   *	@reserve:	     Natural alignment.
   * @reserved:	       Natural alignment.
   * @message_handle:    Identifies the particular message instance.
   * @payload_vm_offset: Offset of payload area from start of this instance.
   * @payload_max_bytes: Maximum bytes allocated in payload area of ControlVm
   *		       segment.
   * @payload_bytes:     Actual number of bytes of payload area to copy between
   *		       IO/Command. If non-zero, there is a payload to copy.
   *
   * This is the common structure that is at the beginning of every
   * ControlVm message (both commands and responses) in any ControlVm
   * queue.  Commands are easily distinguished from responses by
   * looking at the flags.response field.
12e364b9f   Ken Cox   staging: visorchi...
208
   */
98d7b5947   Benjamin Romer   staging: unisys: ...
209
  struct controlvm_message_header  {
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
210
211
212
213
214
  	u32 id;
  	/*
  	 * For requests, indicates the message type. For responses, indicates
  	 * the type of message we are responding to.
  	 */
1e3ab5219   Erik Arfvidson   staging: unisys: ...
215
  	u32 message_size;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
216
  	u32 segment_index;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
217
  	u32 completion_status;
12e364b9f   Ken Cox   staging: visorchi...
218
  	struct  {
1e3ab5219   Erik Arfvidson   staging: unisys: ...
219
  		u32 failed:1;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
220
  		u32 response_expected:1;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
221
  		u32 server:1;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
222
  		u32 test_message:1;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
223
  		u32 partial_completion:1;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
224
  		u32 preserve:1;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
225
  		u32 writer_in_diag:1;
2833399ed   Sameer Wadgaonkar   staging: unisys: ...
226
227
  		u32 reserve:25;
  	} __packed flags;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
228
  	u32 reserved;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
229
  	u64 message_handle;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
230
  	u64 payload_vm_offset;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
231
  	u32 payload_max_bytes;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
232
  	u32 payload_bytes;
2833399ed   Sameer Wadgaonkar   staging: unisys: ...
233
  } __packed;
12e364b9f   Ken Cox   staging: visorchi...
234

fd3074867   Sameer Wadgaonkar   staging: unisys: ...
235
236
237
238
239
240
241
242
243
244
245
  /*
   * struct controlvm_packet_device_create - For CONTROLVM_DEVICE_CREATE
   * @bus_no:	    Bus # (0..n-1) from the msg receiver's end.
   * @dev_no:	    Bus-relative (0..n-1) device number.
   * @channel_addr:   Guest physical address of the channel, which can be
   *		    dereferenced by the receiver of this ControlVm command.
   * @channel_bytes:  Specifies size of the channel in bytes.
   * @data_type_uuid: Specifies format of data in channel.
   * @dev_inst_uuid:  Instance guid for the device.
   * @irq_info intr:  Specifies interrupt information.
   */
f91b92627   Benjamin Romer   staging: unisys: ...
246
  struct controlvm_packet_device_create  {
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
247
248
  	u32 bus_no;
  	u32 dev_no;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
249
  	u64 channel_addr;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
250
  	u64 channel_bytes;
b32c5cb84   Andy Shevchenko   staging: unisys: ...
251
252
  	guid_t data_type_guid;
  	guid_t dev_inst_guid;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
253
254
  	struct irq_info intr;
  } __packed;
12e364b9f   Ken Cox   staging: visorchi...
255

fd3074867   Sameer Wadgaonkar   staging: unisys: ...
256
257
258
259
260
  /*
   * struct controlvm_packet_device_configure - For CONTROLVM_DEVICE_CONFIGURE
   * @bus_no: Bus number (0..n-1) from the msg receiver's perspective.
   * @dev_no: Bus-relative (0..n-1) device number.
   */
e6ad00bbe   Benjamin Romer   staging: unisys: ...
261
  struct controlvm_packet_device_configure  {
1e3ab5219   Erik Arfvidson   staging: unisys: ...
262
  	u32 bus_no;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
263
264
  	u32 dev_no;
  } __packed;
12e364b9f   Ken Cox   staging: visorchi...
265

fd3074867   Sameer Wadgaonkar   staging: unisys: ...
266
  /* Total 128 bytes */
c36acb557   Benjamin Romer   staging: unisys: ...
267
268
269
  struct controlvm_message_device_create {
  	struct controlvm_message_header header;
  	struct controlvm_packet_device_create packet;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
270
  } __packed;
12e364b9f   Ken Cox   staging: visorchi...
271

fd3074867   Sameer Wadgaonkar   staging: unisys: ...
272
  /* Total 56 bytes */
f676054dd   Benjamin Romer   staging: unisys: ...
273
274
275
  struct controlvm_message_device_configure  {
  	struct controlvm_message_header header;
  	struct controlvm_packet_device_configure packet;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
276
  } __packed;
12e364b9f   Ken Cox   staging: visorchi...
277

fd3074867   Sameer Wadgaonkar   staging: unisys: ...
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
  /*
   * struct controlvm_message_packet - This is the format for a message in any
   *                                   ControlVm queue.
   * @struct create_bus:		For CONTROLVM_BUS_CREATE.
   *	@bus_no:	     Bus # (0..n-1) from the msg receiver's perspective.
   *	@dev_count:	     Indicates the max number of devices on this bus.
   *	@channel_addr:	     Guest physical address of the channel, which can be
   *			     dereferenced by the receiver of this ControlVM
   *			     command.
   *	@channel_bytes:	     Size of the channel.
   *	@bus_data_type_uuid: Indicates format of data in bus channel.
   *	@bus_inst_uuid:	     Instance uuid for the bus.
   *
   * @struct destroy_bus:		For CONTROLVM_BUS_DESTROY.
   *	@bus_no: Bus # (0..n-1) from the msg receiver's perspective.
   *	@reserved: Natural alignment purposes.
   *
   * @struct configure_bus:	For CONTROLVM_BUS_CONFIGURE.
   *	@bus_no:	      Bus # (0..n-1) from the receiver's perspective.
   *	@reserved1:	      For alignment purposes.
   *	@guest_handle:	      This is used to convert guest physical address to
   *			      physical address.
   *	@recv_bus_irq_handle: Specifies interrupt info. It is used by SP to
   *			      register to receive interrupts from the CP. This
   *			      interrupt is used for bus level notifications.
   *			      The corresponding sendBusInterruptHandle is kept
   *			      in CP.
   *
   * @struct create_device:	For CONTROLVM_DEVICE_CREATE.
   *
   * @struct destroy_device:	For CONTROLVM_DEVICE_DESTROY.
   *	@bus_no: Bus # (0..n-1) from the msg receiver's perspective.
   *	@dev_no: Bus-relative (0..n-1) device number.
   *
   * @struct configure_device:	For CONTROLVM_DEVICE_CONFIGURE.
   *
   * @struct reconfigure_device:	For CONTROLVM_DEVICE_RECONFIGURE.
   *	@bus_no: Bus # (0..n-1) from the msg receiver's perspective.
   *	@dev_no: Bus-relative (0..n-1) device number.
   *
   * @struct bus_change_state:	For CONTROLVM_BUS_CHANGESTATE.
   *	@bus_no:
   *	@struct state:
   *	@reserved: Natural alignment purposes.
   *
   * @struct device_change_state:	For CONTROLVM_DEVICE_CHANGESTATE.
   *	@bus_no:
   *	@dev_no:
   *	@struct state:
   *	@struct flags:
   *		@phys_device: =1 if message is for a physical device.
   *		@reserved:    Natural alignment.
   *		@reserved1:   Natural alignment.
   *	@reserved:    Natural alignment purposes.
   *
   * @struct device_change_state_event:	For CONTROLVM_DEVICE_CHANGESTATE_EVENT.
   *	@bus_no:
   *	@dev_no:
   *	@struct state:
   *	@reserved:     Natural alignment purposes.
   *
   * @struct init_chipset:	For CONTROLVM_CHIPSET_INIT.
   *	@bus_count:	  Indicates the max number of busses.
   *	@switch_count:    Indicates the max number of switches.
   *	@enum features:
   *	@platform_number:
   *
   * @struct chipset_selftest:	For CONTROLVM_CHIPSET_SELFTEST.
   *      @options: Reserved.
   *      @test:	  Bit 0 set to run embedded selftest.
   *
   * @addr:   A physical address of something, that can be dereferenced by the
   *	    receiver of this ControlVm command.
   *
   * @handle: A handle of something (depends on command id).
   */
2ea5117b5   Benjamin Romer   staging: unisys: ...
354
  struct controlvm_message_packet  {
12e364b9f   Ken Cox   staging: visorchi...
355
  	union  {
12e364b9f   Ken Cox   staging: visorchi...
356
  		struct  {
1e3ab5219   Erik Arfvidson   staging: unisys: ...
357
  			u32 bus_no;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
358
  			u32 dev_count;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
359
  			u64 channel_addr;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
360
  			u64 channel_bytes;
b32c5cb84   Andy Shevchenko   staging: unisys: ...
361
362
  			guid_t bus_data_type_guid;
  			guid_t bus_inst_guid;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
363
  		} __packed create_bus;
12e364b9f   Ken Cox   staging: visorchi...
364
  		struct  {
1e3ab5219   Erik Arfvidson   staging: unisys: ...
365
  			u32 bus_no;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
366
367
  			u32 reserved;
  		} __packed destroy_bus;
12e364b9f   Ken Cox   staging: visorchi...
368
  		struct  {
1e3ab5219   Erik Arfvidson   staging: unisys: ...
369
  			u32 bus_no;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
370
  			u32 reserved1;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
371
  			u64 guest_handle;
2ea5117b5   Benjamin Romer   staging: unisys: ...
372
  			u64 recv_bus_irq_handle;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
373
  		} __packed configure_bus;
f91b92627   Benjamin Romer   staging: unisys: ...
374
  		struct controlvm_packet_device_create create_device;
12e364b9f   Ken Cox   staging: visorchi...
375
  		struct  {
1e3ab5219   Erik Arfvidson   staging: unisys: ...
376
  			u32 bus_no;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
377
378
  			u32 dev_no;
  		} __packed destroy_device;
e6ad00bbe   Benjamin Romer   staging: unisys: ...
379
  		struct controlvm_packet_device_configure configure_device;
12e364b9f   Ken Cox   staging: visorchi...
380
  		struct  {
1e3ab5219   Erik Arfvidson   staging: unisys: ...
381
  			u32 bus_no;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
382
  			u32 dev_no;
2833399ed   Sameer Wadgaonkar   staging: unisys: ...
383
  		} __packed reconfigure_device;
12e364b9f   Ken Cox   staging: visorchi...
384
  		struct  {
2ea5117b5   Benjamin Romer   staging: unisys: ...
385
  			u32 bus_no;
545f09138   Sameer Wadgaonkar   staging: unisys: ...
386
  			struct visor_segment_state state;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
387
388
  			u8 reserved[2];
  		} __packed bus_change_state;
12e364b9f   Ken Cox   staging: visorchi...
389
  		struct  {
2ea5117b5   Benjamin Romer   staging: unisys: ...
390
391
  			u32 bus_no;
  			u32 dev_no;
545f09138   Sameer Wadgaonkar   staging: unisys: ...
392
  			struct visor_segment_state state;
12e364b9f   Ken Cox   staging: visorchi...
393
  			struct  {
1e3ab5219   Erik Arfvidson   staging: unisys: ...
394
  				u32 phys_device:1;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
395
396
  				u32 reserved:31;
  				u32 reserved1;
2833399ed   Sameer Wadgaonkar   staging: unisys: ...
397
  			} __packed flags;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
398
  			u8 reserved[2];
2833399ed   Sameer Wadgaonkar   staging: unisys: ...
399
  		} __packed device_change_state;
12e364b9f   Ken Cox   staging: visorchi...
400
  		struct  {
2ea5117b5   Benjamin Romer   staging: unisys: ...
401
402
  			u32 bus_no;
  			u32 dev_no;
545f09138   Sameer Wadgaonkar   staging: unisys: ...
403
  			struct visor_segment_state state;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
404
  			u8 reserved[6];
2833399ed   Sameer Wadgaonkar   staging: unisys: ...
405
  		} __packed device_change_state_event;
12e364b9f   Ken Cox   staging: visorchi...
406
  		struct  {
1e3ab5219   Erik Arfvidson   staging: unisys: ...
407
  			u32 bus_count;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
408
  			u32 switch_count;
d3ad6e69c   Sameer Wadgaonkar   staging: unisys: ...
409
  			enum visor_chipset_feature features;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
410
411
  			u32 platform_number;
  		} __packed init_chipset;
12e364b9f   Ken Cox   staging: visorchi...
412
  		struct  {
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
413
414
  			u32 options;
  			u32 test;
2833399ed   Sameer Wadgaonkar   staging: unisys: ...
415
  		} __packed chipset_selftest;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
416
  		u64 addr;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
417
  		u64 handle;
12e364b9f   Ken Cox   staging: visorchi...
418
  	};
2833399ed   Sameer Wadgaonkar   staging: unisys: ...
419
  } __packed;
12e364b9f   Ken Cox   staging: visorchi...
420
421
  
  /* All messages in any ControlVm queue have this layout. */
3ab477012   Benjamin Romer   staging: unisys: ...
422
  struct controlvm_message {
98d7b5947   Benjamin Romer   staging: unisys: ...
423
  	struct controlvm_message_header hdr;
2ea5117b5   Benjamin Romer   staging: unisys: ...
424
  	struct controlvm_message_packet cmd;
2833399ed   Sameer Wadgaonkar   staging: unisys: ...
425
  } __packed;
12e364b9f   Ken Cox   staging: visorchi...
426

fd3074867   Sameer Wadgaonkar   staging: unisys: ...
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
  /*
   * struct visor_controlvm_channel
   * @struct header:
   * @gp_controlvm:			Guest phys addr of this channel.
   * @gp_partition_tables:		Guest phys addr of partition tables.
   * @gp_diag_guest:			Guest phys addr of diagnostic channel.
   * @gp_boot_romdisk:			Guest phys addr of (read* only) Boot
   *					ROM disk.
   * @gp_boot_ramdisk:			Guest phys addr of writable Boot RAM
   *					disk.
   * @gp_acpi_table:			Guest phys addr of acpi table.
   * @gp_control_channel:			Guest phys addr of control channel.
   * @gp_diag_romdisk:			Guest phys addr of diagnostic ROM disk.
   * @gp_nvram:				Guest phys addr of NVRAM channel.
   * @request_payload_offset:		Offset to request payload area.
   * @event_payload_offset:		Offset to event payload area.
   * @request_payload_bytes:		Bytes available in request payload area.
   * @event_payload_bytes:		Bytes available in event payload area.
   * @control_channel_bytes:
   * @nvram_channel_bytes:		Bytes in PartitionNvram segment.
   * @message_bytes:			sizeof(CONTROLVM_MESSAGE).
   * @message_count:			CONTROLVM_MESSAGE_MAX.
   * @gp_smbios_table:			Guest phys addr of SMBIOS tables.
   * @gp_physical_smbios_table:		Guest phys addr of SMBIOS table.
   * @gp_reserved:			VISOR_MAX_GUESTS_PER_SERVICE.
   * @virtual_guest_firmware_image_base:	Guest physical address of EFI firmware
   *					image base.
   * @virtual_guest_firmware_entry_point:	Guest physical address of EFI firmware
   *					entry point.
   * @virtual_guest_firmware_image_size:	Guest EFI firmware image size.
   * @virtual_guest_firmware_boot_base:	GPA = 1MB where EFI firmware image is
   *					copied to.
   * @virtual_guest_image_base:
   * @virtual_guest_image_size:
   * @prototype_control_channel_offset:
   * @virtual_guest_partition_handle:
   * @restore_action:			Restore Action field to restore the
   *					guest partition.
   * @dump_action:			For Windows guests it shows if the
   *					visordisk is in dump mode.
   * @nvram_fail_count:
   * @saved_crash_message_count:		= CONTROLVM_CRASHMSG_MAX.
   * @saved_crash_message_offset:		Offset to request payload area needed
   *					for crash dump.
   * @installation_error:			Type of error encountered during
   *					installation.
   * @installation_text_id:		Id of string to display.
   * @installation_remaining_steps:	Number of remaining installation steps
   *					(for progress bars).
   * @tool_action:			VISOR_TOOL_ACTIONS Installation Action
   *					field.
   * @reserved: Alignment.
   * @struct efi_visor_ind:
   * @sp_reserved:
   * @reserved2:				Force signals to begin on 128-byte
   *					cache line.
   * @struct request_queue:		Guest partition uses this queue to send
   *					requests to Control.
   * @struct response_queue:		Control uses this queue to respond to
   *					service or guest partition request.
   * @struct event_queue:			Control uses this queue to send events
   *					to guest partition.
   * @struct event_ack_queue:		Service or guest partition uses this
   *					queue to ack Control events.
   * @struct request_msg:			Request fixed-size message pool -
   *					does not include payload.
   * @struct response_msg:		Response fixed-size message pool -
   *					does not include payload.
   * @struct event_msg:			Event fixed-size message pool -
   *					does not include payload.
   * @struct event_ack_msg:		Ack fixed-size message pool -
   *					does not include payload.
   * @struct saved_crash_msg:		Message stored during IOVM creation to
   *					be reused after crash.
   */
545f09138   Sameer Wadgaonkar   staging: unisys: ...
502
  struct visor_controlvm_channel {
7e5a1a764   Erik Arfvidson   staging: unisys: ...
503
  	struct channel_header header;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
504
505
506
507
508
509
510
511
512
513
514
  	u64 gp_controlvm;
  	u64 gp_partition_tables;
  	u64 gp_diag_guest;
  	u64 gp_boot_romdisk;
  	u64 gp_boot_ramdisk;
  	u64 gp_acpi_table;
  	u64 gp_control_channel;
  	u64 gp_diag_romdisk;
  	u64 gp_nvram;
  	u64 request_payload_offset;
  	u64 event_payload_offset;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
515
  	u32 request_payload_bytes;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
516
  	u32 event_payload_bytes;
7e5a1a764   Erik Arfvidson   staging: unisys: ...
517
  	u32 control_channel_bytes;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
518
519
520
521
522
  	u32 nvram_channel_bytes;
  	u32 message_bytes;
  	u32 message_count;
  	u64 gp_smbios_table;
  	u64 gp_physical_smbios_table;
680385e38   Erik Arfvidson   staging: unisys: ...
523
  	char gp_reserved[2688];
7e5a1a764   Erik Arfvidson   staging: unisys: ...
524
  	u64 virtual_guest_firmware_image_base;
7e5a1a764   Erik Arfvidson   staging: unisys: ...
525
  	u64 virtual_guest_firmware_entry_point;
7e5a1a764   Erik Arfvidson   staging: unisys: ...
526
  	u64 virtual_guest_firmware_image_size;
7e5a1a764   Erik Arfvidson   staging: unisys: ...
527
528
529
530
531
  	u64 virtual_guest_firmware_boot_base;
  	u64 virtual_guest_image_base;
  	u64 virtual_guest_image_size;
  	u64 prototype_control_channel_offset;
  	u64 virtual_guest_partition_handle;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
532
  	u16 restore_action;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
533
  	u16 dump_action;
d19642f65   Benjamin Romer   staging: unisys: ...
534
  	u16 nvram_fail_count;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
535
  	u16 saved_crash_message_count;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
536
  	u32 saved_crash_message_offset;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
537
  	u32 installation_error;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
538
  	u32 installation_text_id;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
539
  	u16 installation_remaining_steps;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
540
  	u8 tool_action;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
541
  	u8 reserved;
545f09138   Sameer Wadgaonkar   staging: unisys: ...
542
  	struct efi_visor_indication efi_visor_ind;
d19642f65   Benjamin Romer   staging: unisys: ...
543
  	u32 sp_reserved;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
544
  	u8 reserved2[28];
1e3ab5219   Erik Arfvidson   staging: unisys: ...
545
  	struct signal_queue_header request_queue;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
546
  	struct signal_queue_header response_queue;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
547
  	struct signal_queue_header event_queue;
1e3ab5219   Erik Arfvidson   staging: unisys: ...
548
  	struct signal_queue_header event_ack_queue;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
549
550
551
552
553
  	struct controlvm_message request_msg[CONTROLVM_MESSAGE_MAX];
  	struct controlvm_message response_msg[CONTROLVM_MESSAGE_MAX];
  	struct controlvm_message event_msg[CONTROLVM_MESSAGE_MAX];
  	struct controlvm_message event_ack_msg[CONTROLVM_MESSAGE_MAX];
  	struct controlvm_message saved_crash_msg[CONTROLVM_CRASHMSG_MAX];
2833399ed   Sameer Wadgaonkar   staging: unisys: ...
554
  } __packed;
12e364b9f   Ken Cox   staging: visorchi...
555

fd3074867   Sameer Wadgaonkar   staging: unisys: ...
556
557
558
559
  /*
   * struct visor_controlvm_parameters_header
   *
   * The following header will be located at the beginning of PayloadVmOffset for
624208933   Benjamin Romer   staging: unisys: ...
560
561
562
563
564
565
   * various ControlVm commands. The receiver of a ControlVm command with a
   * PayloadVmOffset will dereference this address and then use connection_offset,
   * initiator_offset, and target_offset to get the location of UTF-8 formatted
   * strings that can be parsed to obtain command-specific information. The value
   * of total_length should equal PayloadBytes. The format of the strings at
   * PayloadVmOffset will take different forms depending on the message.
12e364b9f   Ken Cox   staging: visorchi...
566
   */
545f09138   Sameer Wadgaonkar   staging: unisys: ...
567
  struct visor_controlvm_parameters_header {
624208933   Benjamin Romer   staging: unisys: ...
568
569
570
571
572
573
574
575
576
577
578
579
  	u32 total_length;
  	u32 header_length;
  	u32 connection_offset;
  	u32 connection_length;
  	u32 initiator_offset;
  	u32 initiator_length;
  	u32 target_offset;
  	u32 target_length;
  	u32 client_offset;
  	u32 client_length;
  	u32 name_offset;
  	u32 name_length;
b32c5cb84   Andy Shevchenko   staging: unisys: ...
580
  	guid_t id;
624208933   Benjamin Romer   staging: unisys: ...
581
  	u32 revision;
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
582
583
  	/* Natural alignment */
  	u32 reserved;
2833399ed   Sameer Wadgaonkar   staging: unisys: ...
584
  } __packed;
12e364b9f   Ken Cox   staging: visorchi...
585

8a7a2fde4   David Kershner   staging: unisys: ...
586
  /* General Errors------------------------------------------------------[0-99] */
941affcbe   David Binder   staging: unisys: ...
587
588
589
590
591
592
  #define CONTROLVM_RESP_SUCCESS			   0
  #define CONTROLVM_RESP_ALREADY_DONE		   1
  #define CONTROLVM_RESP_IOREMAP_FAILED		   2
  #define CONTROLVM_RESP_KMALLOC_FAILED		   3
  #define CONTROLVM_RESP_ID_UNKNOWN		   4
  #define CONTROLVM_RESP_ID_INVALID_FOR_CLIENT	   5
8a7a2fde4   David Kershner   staging: unisys: ...
593
  /* CONTROLVM_INIT_CHIPSET-------------------------------------------[100-199] */
941affcbe   David Binder   staging: unisys: ...
594
595
  #define CONTROLVM_RESP_CLIENT_SWITCHCOUNT_NONZERO  100
  #define CONTROLVM_RESP_EXPECTED_CHIPSET_INIT	   101
8a7a2fde4   David Kershner   staging: unisys: ...
596
  /* Maximum Limit----------------------------------------------------[200-299] */
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
597
598
599
600
  /* BUS_CREATE */
  #define CONTROLVM_RESP_ERROR_MAX_BUSES		   201
  /* DEVICE_CREATE */
  #define CONTROLVM_RESP_ERROR_MAX_DEVICES	   202
8a7a2fde4   David Kershner   staging: unisys: ...
601
  /* Payload and Parameter Related------------------------------------[400-499] */
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
602
603
604
605
606
607
608
609
  /* SWITCH_ATTACHEXTPORT, DEVICE_CONFIGURE */
  #define CONTROLVM_RESP_PAYLOAD_INVALID		   400
  /* Multiple */
  #define CONTROLVM_RESP_INITIATOR_PARAMETER_INVALID 401
  /* DEVICE_CONFIGURE */
  #define CONTROLVM_RESP_TARGET_PARAMETER_INVALID	   402
  /* DEVICE_CONFIGURE */
  #define CONTROLVM_RESP_CLIENT_PARAMETER_INVALID	   403
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
  /* Specified[Packet Structure] Value--------------------------------[500-599] */
  /* SWITCH_ATTACHINTPORT */
  /* BUS_CONFIGURE, DEVICE_CREATE, DEVICE_CONFIG, DEVICE_DESTROY */
  #define CONTROLVM_RESP_BUS_INVALID		   500
  /* SWITCH_ATTACHINTPORT*/
  /* DEVICE_CREATE, DEVICE_CONFIGURE, DEVICE_DESTROY */
  #define CONTROLVM_RESP_DEVICE_INVALID		   501
  /* DEVICE_CREATE, DEVICE_CONFIGURE */
  #define CONTROLVM_RESP_CHANNEL_INVALID		   502
  /* Partition Driver Callback Interface------------------------------[600-699] */
  /* BUS_CREATE, BUS_DESTROY, DEVICE_CREATE, DEVICE_DESTROY */
  #define CONTROLVM_RESP_VIRTPCI_DRIVER_FAILURE	   604
  /* Unable to invoke VIRTPCI callback. VIRTPCI Callback returned error. */
  /* BUS_CREATE, BUS_DESTROY, DEVICE_CREATE, DEVICE_DESTROY */
  #define CONTROLVM_RESP_VIRTPCI_DRIVER_CALLBACK_ERROR   605
  /* Generic device callback returned error. */
  /* SWITCH_ATTACHEXTPORT, SWITCH_DETACHEXTPORT, DEVICE_CONFIGURE */
941affcbe   David Binder   staging: unisys: ...
627
  #define CONTROLVM_RESP_GENERIC_DRIVER_CALLBACK_ERROR   606
8a7a2fde4   David Kershner   staging: unisys: ...
628
  /* Bus Related------------------------------------------------------[700-799] */
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
629
630
  /* BUS_DESTROY */
  #define CONTROLVM_RESP_ERROR_BUS_DEVICE_ATTACHED       700
8a7a2fde4   David Kershner   staging: unisys: ...
631
  /* Channel Related--------------------------------------------------[800-899] */
fd3074867   Sameer Wadgaonkar   staging: unisys: ...
632
633
634
635
  /* GET_CHANNELINFO, DEVICE_DESTROY */
  #define CONTROLVM_RESP_CHANNEL_TYPE_UNKNOWN	       800
  /* DEVICE_CREATE */
  #define CONTROLVM_RESP_CHANNEL_SIZE_TOO_SMALL	       801
8a7a2fde4   David Kershner   staging: unisys: ...
636
  /* Chipset Shutdown Related---------------------------------------[1000-1099] */
941affcbe   David Binder   staging: unisys: ...
637
638
  #define CONTROLVM_RESP_CHIPSET_SHUTDOWN_FAILED	       1000
  #define CONTROLVM_RESP_CHIPSET_SHUTDOWN_ALREADY_ACTIVE 1001
8a7a2fde4   David Kershner   staging: unisys: ...
639
  /* Chipset Stop Related-------------------------------------------[1100-1199] */
941affcbe   David Binder   staging: unisys: ...
640
641
  #define CONTROLVM_RESP_CHIPSET_STOP_FAILED_BUS	       1100
  #define CONTROLVM_RESP_CHIPSET_STOP_FAILED_SWITCH      1101
8a7a2fde4   David Kershner   staging: unisys: ...
642
  /* Device Related-------------------------------------------------[1400-1499] */
941affcbe   David Binder   staging: unisys: ...
643
  #define CONTROLVM_RESP_DEVICE_UDEV_TIMEOUT	       1400
8a7a2fde4   David Kershner   staging: unisys: ...
644

fd3074867   Sameer Wadgaonkar   staging: unisys: ...
645
646
  /* __CONTROLVMCHANNEL_H__ */
  #endif