1 /* Copyright (C) 2010 - 2013 UNISYS CORPORATION
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or (at
7 * your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
12 * NON INFRINGEMENT. See the GNU General Public License for more
16 #ifndef __CONTROLVMCHANNEL_H__
17 #define __CONTROLVMCHANNEL_H__
19 #include <linux/uuid.h>
21 #include "controlframework.h"
23 typedef u64 GUEST_PHYSICAL_ADDRESS;
25 enum { INVALID_GUEST_FIRMWARE, SAMPLE_GUEST_FIRMWARE,
26 TIANO32_GUEST_FIRMWARE, TIANO64_GUEST_FIRMWARE
29 /* {2B3C2D10-7EF5-4ad8-B966-3448B7386B3D} */
30 #define SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID \
31 UUID_LE(0x2b3c2d10, 0x7ef5, 0x4ad8, \
32 0xb9, 0x66, 0x34, 0x48, 0xb7, 0x38, 0x6b, 0x3d)
34 static const uuid_le spar_controlvm_channel_protocol_uuid =
35 SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID;
37 #define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE \
38 ULTRA_CHANNEL_PROTOCOL_SIGNATURE
39 #define CONTROLVM_MESSAGE_MAX 64
41 /* Must increment this whenever you insert or delete fields within
42 * this channel struct. Also increment whenever you change the meaning
43 * of fields within this channel struct so as to break pre-existing
44 * software. Note that you can usually add fields to the END of the
45 * channel struct withOUT needing to increment this. */
46 #define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID 1
48 #define SPAR_CONTROLVM_CHANNEL_OK_CLIENT(ch) \
49 spar_check_channel_client(ch, \
50 spar_controlvm_channel_protocol_uuid, \
52 sizeof(struct spar_controlvm_channel_protocol), \
53 ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \
54 ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE)
56 #define MY_DEVICE_INDEX 0
57 #define MAX_MACDATA_LEN 8 /* number of bytes for MAC address in config packet */
58 #define MAX_SERIAL_NUM 32
60 #define DISK_ZERO_PUN_NUMBER 1 /* Target ID on the SCSI bus for LUN 0 */
61 #define DISK_ZERO_LUN_NUMBER 3 /* Logical Unit Number */
63 /* Defines for various channel queues... */
64 #define CONTROLVM_QUEUE_REQUEST 0
65 #define CONTROLVM_QUEUE_RESPONSE 1
66 #define CONTROLVM_QUEUE_EVENT 2
67 #define CONTROLVM_QUEUE_ACK 3
69 /* Max number of messages stored during IOVM creation to be reused
71 #define CONTROLVM_CRASHMSG_MAX 2
73 /** Ids for commands that may appear in either queue of a ControlVm channel.
75 * Commands that are initiated by the command partition (CP), by an IO or
76 * console service partition (SP), or by a guest partition (GP)are:
77 * - issued on the RequestQueue queue (q #0) in the ControlVm channel
78 * - responded to on the ResponseQueue queue (q #1) in the ControlVm channel
80 * Events that are initiated by an IO or console service partition (SP) or
81 * by a guest partition (GP) are:
82 * - issued on the EventQueue queue (q #2) in the ControlVm channel
83 * - responded to on the EventAckQueue queue (q #3) in the ControlVm channel
86 CONTROLVM_INVALID = 0,
87 /* SWITCH commands required Parameter: SwitchNumber */
88 /* BUS commands required Parameter: BusNumber */
89 CONTROLVM_BUS_CREATE = 0x101, /* CP --> SP, GP */
90 CONTROLVM_BUS_DESTROY = 0x102, /* CP --> SP, GP */
91 CONTROLVM_BUS_CONFIGURE = 0x104, /* CP --> SP */
92 CONTROLVM_BUS_CHANGESTATE = 0x105, /* CP --> SP, GP */
93 CONTROLVM_BUS_CHANGESTATE_EVENT = 0x106, /* SP, GP --> CP */
94 /* DEVICE commands required Parameter: BusNumber, DeviceNumber */
96 CONTROLVM_DEVICE_CREATE = 0x201, /* CP --> SP, GP */
97 CONTROLVM_DEVICE_DESTROY = 0x202, /* CP --> SP, GP */
98 CONTROLVM_DEVICE_CONFIGURE = 0x203, /* CP --> SP */
99 CONTROLVM_DEVICE_CHANGESTATE = 0x204, /* CP --> SP, GP */
100 CONTROLVM_DEVICE_CHANGESTATE_EVENT = 0x205, /* SP, GP --> CP */
101 CONTROLVM_DEVICE_RECONFIGURE = 0x206, /* CP --> Boot */
102 /* DISK commands required Parameter: BusNumber, DeviceNumber */
103 CONTROLVM_DISK_CREATE = 0x221, /* CP --> SP */
104 CONTROLVM_DISK_DESTROY = 0x222, /* CP --> SP */
105 CONTROLVM_DISK_CONFIGURE = 0x223, /* CP --> SP */
106 CONTROLVM_DISK_CHANGESTATE = 0x224, /* CP --> SP */
107 /* CHIPSET commands */
108 CONTROLVM_CHIPSET_INIT = 0x301, /* CP --> SP, GP */
109 CONTROLVM_CHIPSET_STOP = 0x302, /* CP --> SP, GP */
110 CONTROLVM_CHIPSET_SHUTDOWN = 0x303, /* CP --> SP */
111 CONTROLVM_CHIPSET_READY = 0x304, /* CP --> SP */
112 CONTROLVM_CHIPSET_SELFTEST = 0x305, /* CP --> SP */
117 /**< specifies interrupt info. It is used to send interrupts
118 * for this channel. The peer at the end of this channel
119 * who has registered an interrupt (using recv fields
120 * above) will receive the interrupt. Passed as a parameter
121 * to Issue_VMCALL_IO_QUEUE_TRANSITION, which generates the
122 * interrupt. Currently this is used by IOPart-SP to wake
123 * up GP when Data Channel transitions from empty to
127 /**< specifies interrupt handle. It is used to retrieve the
128 * corresponding interrupt pin from Monitor; and the
129 * interrupt pin is used to connect to the corresponding
130 * interrupt. Used by IOPart-GP only. */
133 /**< specifies interrupt vector. It, interrupt pin, and shared are
134 * used to connect to the corresponding interrupt. Used by
138 /**< specifies if the recvInterrupt is shared. It, interrupt pin
139 * and vector are used to connect to 0 = not shared; 1 = shared.
140 * the corresponding interrupt. Used by IOPart-GP only. */
142 u8 reserved[3]; /* Natural alignment purposes */
150 u8 reserved[3]; /* Natural alignment purposes */
153 struct efi_spar_indication {
154 u64 boot_to_fw_ui:1; /* Bit 0: Stop in uefi ui */
155 u64 clear_nvram:1; /* Bit 1: Clear NVRAM */
156 u64 clear_cmos:1; /* Bit 2: Clear CMOS */
157 u64 boot_to_tool:1; /* Bit 3: Run install tool */
158 /* remaining bits are available */
161 enum ultra_chipset_feature {
162 ULTRA_CHIPSET_FEATURE_REPLY = 0x00000001,
163 ULTRA_CHIPSET_FEATURE_PARA_HOTPLUG = 0x00000002,
164 ULTRA_CHIPSET_FEATURE_PCIVBUS = 0x00000004
167 /** This is the common structure that is at the beginning of every
168 * ControlVm message (both commands and responses) in any ControlVm
169 * queue. Commands are easily distinguished from responses by
170 * looking at the flags.response field.
172 struct controlvm_message_header {
173 u32 id; /* See CONTROLVM_ID. */
174 /* For requests, indicates the message type. */
175 /* For responses, indicates the type of message we are responding to. */
177 u32 message_size; /* Includes size of this struct + size
179 u32 segment_index; /* Index of segment containing Vm
180 * message/information */
181 u32 completion_status; /* Error status code or result of
182 * message completion */
184 u32 failed:1; /**< =1 in a response to * signify
186 u32 response_expected:1; /**< =1 in all messages that expect a
187 * response (Control ignores this
189 u32 server:1; /**< =1 in all bus & device-related
190 * messages where the message
191 * receiver is to act as the bus or
193 u32 test_message:1; /**< =1 for testing use only
194 * (Control and Command ignore this
196 u32 partial_completion:1; /**< =1 if there are forthcoming
197 * responses/acks associated
198 * with this message */
199 u32 preserve:1; /**< =1 this is to let us know to
200 * preserve channel contents
201 * (for running guests)*/
202 u32 writer_in_diag:1; /**< =1 the DiagWriter is active in the
203 * Diagnostic Partition*/
205 u32 reserved; /* Natural alignment */
206 u64 message_handle; /* Identifies the particular message instance,
207 * and is used to match particular */
208 /* request instances with the corresponding response instance. */
209 u64 payload_vm_offset; /* Offset of payload area from start of this
210 * instance of ControlVm segment */
211 u32 payload_max_bytes; /* Maximum bytes allocated in payload
212 * area of ControlVm segment */
213 u32 payload_bytes; /* Actual number of bytes of payload
214 * area to copy between IO/Command; */
215 /* if non-zero, there is a payload to copy. */
218 struct controlvm_packet_device_create {
219 u32 bus_no; /* bus # (0..n-1) from the msg receiver's end */
220 u32 dev_no; /* bus-relative (0..n-1) device number */
221 u64 channel_addr; /* Guest physical address of the channel, which
222 * can be dereferenced by the receiver of this
223 * ControlVm command */
224 u64 channel_bytes; /* specifies size of the channel in bytes */
225 uuid_le data_type_uuid; /* specifies format of data in channel */
226 uuid_le dev_inst_uuid; /* instance guid for the device */
227 struct irq_info intr; /* specifies interrupt information */
228 }; /* for CONTROLVM_DEVICE_CREATE */
230 struct controlvm_packet_device_configure {
231 u32 bus_no; /**< bus # (0..n-1) from the msg
232 * receiver's perspective */
234 /* Control uses header SegmentIndex field to access bus number... */
235 u32 dev_no; /**< bus-relative (0..n-1) device number */
236 } ; /* for CONTROLVM_DEVICE_CONFIGURE */
238 struct controlvm_message_device_create {
239 struct controlvm_message_header header;
240 struct controlvm_packet_device_create packet;
241 }; /* total 128 bytes */
243 struct controlvm_message_device_configure {
244 struct controlvm_message_header header;
245 struct controlvm_packet_device_configure packet;
246 }; /* total 56 bytes */
248 /* This is the format for a message in any ControlVm queue. */
249 struct controlvm_message_packet {
252 u32 bus_no; /* bus # (0..n-1) from the msg
253 * receiver's perspective */
254 u32 dev_count; /* indicates the max number of
255 * devices on this bus */
256 u64 channel_addr; /* Guest physical address of
257 * the channel, which can be
258 * dereferenced by the receiver
259 * of this ControlVm command */
260 u64 channel_bytes; /* size of the channel */
261 uuid_le bus_data_type_uuid; /* indicates format of
262 * data in bus channel*/
263 uuid_le bus_inst_uuid; /* instance uuid for the bus */
264 } create_bus; /* for CONTROLVM_BUS_CREATE */
266 u32 bus_no; /* bus # (0..n-1) from the msg
267 * receiver's perspective */
268 u32 reserved; /* Natural alignment purposes */
269 } destroy_bus; /* for CONTROLVM_BUS_DESTROY */
271 u32 bus_no; /* bus # (0..n-1) from the receiver's
273 u32 reserved1; /* for alignment purposes */
274 u64 guest_handle; /* This is used to convert
275 * guest physical address to
276 * physical address */
277 u64 recv_bus_irq_handle;
278 /* specifies interrupt info. It is used by SP
279 * to register to receive interrupts from the
280 * CP. This interrupt is used for bus level
281 * notifications. The corresponding
282 * sendBusInterruptHandle is kept in CP. */
283 } configure_bus; /* for CONTROLVM_BUS_CONFIGURE */
284 /* for CONTROLVM_DEVICE_CREATE */
285 struct controlvm_packet_device_create create_device;
287 u32 bus_no; /* bus # (0..n-1) from the msg
288 * receiver's perspective */
289 u32 dev_no; /* bus-relative (0..n-1) device # */
290 } destroy_device; /* for CONTROLVM_DEVICE_DESTROY */
291 /* for CONTROLVM_DEVICE_CONFIGURE */
292 struct controlvm_packet_device_configure configure_device;
294 u32 bus_no; /* bus # (0..n-1) from the msg
295 * receiver's perspective */
296 u32 dev_no; /* bus-relative (0..n-1) device # */
297 } reconfigure_device; /* for CONTROLVM_DEVICE_RECONFIGURE */
300 struct spar_segment_state state;
301 u8 reserved[2]; /* Natural alignment purposes */
302 } bus_change_state; /* for CONTROLVM_BUS_CHANGESTATE */
306 struct spar_segment_state state;
308 u32 phys_device:1; /* =1 if message is for
309 * a physical device */
311 u8 reserved[2]; /* Natural alignment purposes */
312 } device_change_state; /* for CONTROLVM_DEVICE_CHANGESTATE */
316 struct spar_segment_state state;
317 u8 reserved[6]; /* Natural alignment purposes */
318 } device_change_state_event;
319 /* for CONTROLVM_DEVICE_CHANGESTATE_EVENT */
321 u32 bus_count; /* indicates the max number of busses */
322 u32 switch_count; /* indicates the max number of
323 * switches if a service partition */
324 enum ultra_chipset_feature features;
325 u32 platform_number; /* Platform Number */
326 } init_chipset; /* for CONTROLVM_CHIPSET_INIT */
328 u32 options; /* reserved */
329 u32 test; /* bit 0 set to run embedded selftest */
330 } chipset_selftest; /* for CONTROLVM_CHIPSET_SELFTEST */
331 u64 addr; /* a physical address of something, that can be
332 * dereferenced by the receiver of this
333 * ControlVm command (depends on command id) */
334 u64 handle; /* a handle of something (depends on command
339 /* All messages in any ControlVm queue have this layout. */
340 struct controlvm_message {
341 struct controlvm_message_header hdr;
342 struct controlvm_message_packet cmd;
346 GUEST_PHYSICAL_ADDRESS device_channel_address;
347 u64 device_channel_size;
349 u32 reserved; /* natural alignment */
350 u64 reserved2; /* Align structure on 32-byte boundary */
353 struct guest_devices {
354 struct device_map video_channel;
355 struct device_map keyboard_channel;
356 struct device_map network_channel;
357 struct device_map storage_channel;
358 struct device_map console_channel;
363 struct spar_controlvm_channel_protocol {
364 struct channel_header header;
365 GUEST_PHYSICAL_ADDRESS gp_controlvm; /* guest physical address of
367 GUEST_PHYSICAL_ADDRESS gp_partition_tables;/* guest physical address of
368 * partition tables */
369 GUEST_PHYSICAL_ADDRESS gp_diag_guest; /* guest physical address of
370 * diagnostic channel */
371 GUEST_PHYSICAL_ADDRESS gp_boot_romdisk;/* guest phys addr of (read
372 * only) Boot ROM disk */
373 GUEST_PHYSICAL_ADDRESS gp_boot_ramdisk;/* guest phys addr of writable
375 GUEST_PHYSICAL_ADDRESS gp_acpi_table; /* guest phys addr of acpi
377 GUEST_PHYSICAL_ADDRESS gp_control_channel;/* guest phys addr of control
379 GUEST_PHYSICAL_ADDRESS gp_diag_romdisk;/* guest phys addr of diagnostic
381 GUEST_PHYSICAL_ADDRESS gp_nvram; /* guest phys addr of NVRAM
383 u64 request_payload_offset; /* Offset to request payload area */
384 u64 event_payload_offset; /* Offset to event payload area */
385 u32 request_payload_bytes; /* Bytes available in request payload
387 u32 event_payload_bytes;/* Bytes available in event payload area */
388 u32 control_channel_bytes;
389 u32 nvram_channel_bytes; /* Bytes in PartitionNvram segment */
390 u32 message_bytes; /* sizeof(CONTROLVM_MESSAGE) */
391 u32 message_count; /* CONTROLVM_MESSAGE_MAX */
392 GUEST_PHYSICAL_ADDRESS gp_smbios_table;/* guest phys addr of SMBIOS
394 GUEST_PHYSICAL_ADDRESS gp_physical_smbios_table;/* guest phys addr of
396 /* ULTRA_MAX_GUESTS_PER_SERVICE */
397 struct guest_devices gp_obsolete_guest_devices[16];
399 /* guest physical address of EFI firmware image base */
400 GUEST_PHYSICAL_ADDRESS virtual_guest_firmware_image_base;
402 /* guest physical address of EFI firmware entry point */
403 GUEST_PHYSICAL_ADDRESS virtual_guest_firmware_entry_point;
405 /* guest EFI firmware image size */
406 u64 virtual_guest_firmware_image_size;
408 /* GPA = 1MB where EFI firmware image is copied to */
409 GUEST_PHYSICAL_ADDRESS virtual_guest_firmware_boot_base;
410 GUEST_PHYSICAL_ADDRESS virtual_guest_image_base;
411 GUEST_PHYSICAL_ADDRESS virtual_guest_image_size;
412 u64 prototype_control_channel_offset;
413 GUEST_PHYSICAL_ADDRESS virtual_guest_partition_handle;
415 u16 restore_action; /* Restore Action field to restore the guest
417 u16 dump_action; /* For Windows guests it shows if the visordisk
418 * is running in dump mode */
419 u16 nvram_fail_count;
420 u16 saved_crash_message_count; /* = CONTROLVM_CRASHMSG_MAX */
421 u32 saved_crash_message_offset; /* Offset to request payload area needed
423 u32 installation_error; /* Type of error encountered during
425 u32 installation_text_id; /* Id of string to display */
426 u16 installation_remaining_steps;/* Number of remaining installation
427 * steps (for progress bars) */
428 u8 tool_action; /* ULTRA_TOOL_ACTIONS Installation Action
430 u8 reserved; /* alignment */
431 struct efi_spar_indication efi_spar_ind;
432 struct efi_spar_indication efi_spar_ind_supported;
434 u8 reserved2[28]; /* Force signals to begin on 128-byte cache
436 struct signal_queue_header request_queue;/* Service or guest partition
437 * uses this queue to send
438 * requests to Control */
439 struct signal_queue_header response_queue;/* Control uses this queue to
440 * respond to service or guest
441 * partition requests */
442 struct signal_queue_header event_queue; /* Control uses this queue to
443 * send events to service or
445 struct signal_queue_header event_ack_queue;/* Service or guest partition
446 * uses this queue to ack
449 /* Request fixed-size message pool - does not include payload */
450 struct controlvm_message request_msg[CONTROLVM_MESSAGE_MAX];
452 /* Response fixed-size message pool - does not include payload */
453 struct controlvm_message response_msg[CONTROLVM_MESSAGE_MAX];
455 /* Event fixed-size message pool - does not include payload */
456 struct controlvm_message event_msg[CONTROLVM_MESSAGE_MAX];
458 /* Ack fixed-size message pool - does not include payload */
459 struct controlvm_message event_ack_msg[CONTROLVM_MESSAGE_MAX];
461 /* Message stored during IOVM creation to be reused after crash */
462 struct controlvm_message saved_crash_msg[CONTROLVM_CRASHMSG_MAX];
465 /* Offsets for VM channel attributes... */
466 #define VM_CH_REQ_QUEUE_OFFSET \
467 offsetof(struct spar_controlvm_channel_protocol, request_queue)
468 #define VM_CH_RESP_QUEUE_OFFSET \
469 offsetof(struct spar_controlvm_channel_protocol, response_queue)
470 #define VM_CH_EVENT_QUEUE_OFFSET \
471 offsetof(struct spar_controlvm_channel_protocol, event_queue)
472 #define VM_CH_ACK_QUEUE_OFFSET \
473 offsetof(struct spar_controlvm_channel_protocol, event_ack_queue)
474 #define VM_CH_REQ_MSG_OFFSET \
475 offsetof(struct spar_controlvm_channel_protocol, request_msg)
476 #define VM_CH_RESP_MSG_OFFSET \
477 offsetof(struct spar_controlvm_channel_protocol, response_msg)
478 #define VM_CH_EVENT_MSG_OFFSET \
479 offsetof(struct spar_controlvm_channel_protocol, event_msg)
480 #define VM_CH_ACK_MSG_OFFSET \
481 offsetof(struct spar_controlvm_channel_protocol, event_ack_msg)
482 #define VM_CH_CRASH_MSG_OFFSET \
483 offsetof(struct spar_controlvm_channel_protocol, saved_crash_msg)
485 /* The following header will be located at the beginning of PayloadVmOffset for
486 * various ControlVm commands. The receiver of a ControlVm command with a
487 * PayloadVmOffset will dereference this address and then use connection_offset,
488 * initiator_offset, and target_offset to get the location of UTF-8 formatted
489 * strings that can be parsed to obtain command-specific information. The value
490 * of total_length should equal PayloadBytes. The format of the strings at
491 * PayloadVmOffset will take different forms depending on the message.
493 struct spar_controlvm_parameters_header {
496 u32 connection_offset;
497 u32 connection_length;
498 u32 initiator_offset;
499 u32 initiator_length;
508 u32 reserved; /* Natural alignment */
511 #endif /* __CONTROLVMCHANNEL_H__ */