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>
22 /* {2B3C2D10-7EF5-4ad8-B966-3448B7386B3D} */
23 #define SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID \
24 UUID_LE(0x2b3c2d10, 0x7ef5, 0x4ad8, \
25 0xb9, 0x66, 0x34, 0x48, 0xb7, 0x38, 0x6b, 0x3d)
27 #define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE \
28 ULTRA_CHANNEL_PROTOCOL_SIGNATURE
29 #define CONTROLVM_MESSAGE_MAX 64
31 /* Must increment this whenever you insert or delete fields within
32 * this channel struct. Also increment whenever you change the meaning
33 * of fields within this channel struct so as to break pre-existing
34 * software. Note that you can usually add fields to the END of the
35 * channel struct withOUT needing to increment this.
37 #define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID 1
39 #define SPAR_CONTROLVM_CHANNEL_OK_CLIENT(ch) \
40 spar_check_channel_client(ch, \
41 SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID, \
43 sizeof(struct spar_controlvm_channel_protocol), \
44 ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \
45 ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE)
47 #define MAX_SERIAL_NUM 32
49 /* Defines for various channel queues */
50 #define CONTROLVM_QUEUE_REQUEST 0
51 #define CONTROLVM_QUEUE_RESPONSE 1
52 #define CONTROLVM_QUEUE_EVENT 2
53 #define CONTROLVM_QUEUE_ACK 3
55 /* Max num of messages stored during IOVM creation to be reused after crash */
56 #define CONTROLVM_CRASHMSG_MAX 2
58 struct spar_segment_state
{
59 u16 enabled
:1; /* Bit 0: May enter other states */
60 u16 active
:1; /* Bit 1: Assigned to active partition */
61 u16 alive
:1; /* Bit 2: Configure message sent to
63 u16 revoked
:1; /* Bit 3: similar to partition state
65 u16 allocated
:1; /* Bit 4: memory (device/port number)
66 * has been selected by Command */
67 u16 known
:1; /* Bit 5: has been introduced to the
68 * service/guest partition */
69 u16 ready
:1; /* Bit 6: service/Guest partition has
70 * responded to introduction */
71 u16 operating
:1; /* Bit 7: resource is configured and
73 /* Note: don't use high bit unless we need to switch to ushort
74 * which is non-compliant */
77 static const struct spar_segment_state segment_state_running
= {
78 1, 1, 1, 0, 1, 1, 1, 1
81 static const struct spar_segment_state segment_state_paused
= {
82 1, 1, 1, 0, 1, 1, 1, 0
85 static const struct spar_segment_state segment_state_standby
= {
86 1, 1, 0, 0, 1, 1, 1, 0
89 /* Ids for commands that may appear in either queue of a ControlVm channel.
91 * Commands that are initiated by the command partition (CP), by an IO or
92 * console service partition (SP), or by a guest partition (GP)are:
93 * - issued on the RequestQueue queue (q #0) in the ControlVm channel
94 * - responded to on the ResponseQueue queue (q #1) in the ControlVm channel
96 * Events that are initiated by an IO or console service partition (SP) or
97 * by a guest partition (GP) are:
98 * - issued on the EventQueue queue (q #2) in the ControlVm channel
99 * - responded to on the EventAckQueue queue (q #3) in the ControlVm channel
102 CONTROLVM_INVALID
= 0,
103 /* SWITCH commands required Parameter: SwitchNumber */
104 /* BUS commands required Parameter: BusNumber */
105 CONTROLVM_BUS_CREATE
= 0x101, /* CP --> SP, GP */
106 CONTROLVM_BUS_DESTROY
= 0x102, /* CP --> SP, GP */
107 CONTROLVM_BUS_CONFIGURE
= 0x104, /* CP --> SP */
108 CONTROLVM_BUS_CHANGESTATE
= 0x105, /* CP --> SP, GP */
109 CONTROLVM_BUS_CHANGESTATE_EVENT
= 0x106, /* SP, GP --> CP */
110 /* DEVICE commands required Parameter: BusNumber, DeviceNumber */
112 CONTROLVM_DEVICE_CREATE
= 0x201, /* CP --> SP, GP */
113 CONTROLVM_DEVICE_DESTROY
= 0x202, /* CP --> SP, GP */
114 CONTROLVM_DEVICE_CONFIGURE
= 0x203, /* CP --> SP */
115 CONTROLVM_DEVICE_CHANGESTATE
= 0x204, /* CP --> SP, GP */
116 CONTROLVM_DEVICE_CHANGESTATE_EVENT
= 0x205, /* SP, GP --> CP */
117 CONTROLVM_DEVICE_RECONFIGURE
= 0x206, /* CP --> Boot */
118 /* CHIPSET commands */
119 CONTROLVM_CHIPSET_INIT
= 0x301, /* CP --> SP, GP */
120 CONTROLVM_CHIPSET_STOP
= 0x302, /* CP --> SP, GP */
121 CONTROLVM_CHIPSET_READY
= 0x304, /* CP --> SP */
122 CONTROLVM_CHIPSET_SELFTEST
= 0x305, /* CP --> SP */
129 /* specifies interrupt handle. It is used to retrieve the
130 * corresponding interrupt pin from Monitor; and the
131 * interrupt pin is used to connect to the corresponding
132 * interrupt. Used by IOPart-GP only.
136 /* specifies interrupt vector. It, interrupt pin, and shared are
137 * used to connect to the corresponding interrupt. Used by
142 /* specifies if the recvInterrupt is shared. It, interrupt pin
143 * and vector are used to connect to 0 = not shared; 1 = shared.
144 * the corresponding interrupt. Used by IOPart-GP only.
147 u8 reserved
[3]; /* Natural alignment purposes */
155 u8 reserved
[3]; /* Natural alignment purposes */
158 struct efi_spar_indication
{
159 u64 boot_to_fw_ui
:1; /* Bit 0: Stop in uefi ui */
160 u64 clear_nvram
:1; /* Bit 1: Clear NVRAM */
161 u64 clear_cmos
:1; /* Bit 2: Clear CMOS */
162 u64 boot_to_tool
:1; /* Bit 3: Run install tool */
163 /* remaining bits are available */
166 enum ultra_chipset_feature
{
167 ULTRA_CHIPSET_FEATURE_REPLY
= 0x00000001,
168 ULTRA_CHIPSET_FEATURE_PARA_HOTPLUG
= 0x00000002,
171 /* This is the common structure that is at the beginning of every
172 * ControlVm message (both commands and responses) in any ControlVm
173 * queue. Commands are easily distinguished from responses by
174 * looking at the flags.response field.
176 struct controlvm_message_header
{
177 u32 id
; /* See CONTROLVM_ID. */
178 /* For requests, indicates the message type. */
179 /* For responses, indicates the type of message we are responding to. */
181 u32 message_size
; /* Includes size of this struct + size
183 u32 segment_index
; /* Index of segment containing Vm
184 * message/information */
185 u32 completion_status
; /* Error status code or result of
186 * message completion */
188 u32 failed
:1; /* =1 in a response to * signify
190 u32 response_expected
:1; /* =1 in all messages that expect a
191 * response (Control ignores this
193 u32 server
:1; /* =1 in all bus & device-related
194 * messages where the message
195 * receiver is to act as the bus or
197 u32 test_message
:1; /* =1 for testing use only
198 * (Control and Command ignore this
200 u32 partial_completion
:1; /* =1 if there are forthcoming
201 * responses/acks associated
202 * with this message */
203 u32 preserve
:1; /* =1 this is to let us know to
204 * preserve channel contents
205 * (for running guests)*/
206 u32 writer_in_diag
:1; /* =1 the DiagWriter is active in the
207 * Diagnostic Partition*/
209 u32 reserved
; /* Natural alignment */
210 u64 message_handle
; /* Identifies the particular message instance,
211 * and is used to match particular */
212 /* request instances with the corresponding response instance. */
213 u64 payload_vm_offset
; /* Offset of payload area from start of this
214 * instance of ControlVm segment */
215 u32 payload_max_bytes
; /* Maximum bytes allocated in payload
216 * area of ControlVm segment */
217 u32 payload_bytes
; /* Actual number of bytes of payload
218 * area to copy between IO/Command; */
219 /* if non-zero, there is a payload to copy. */
222 struct controlvm_packet_device_create
{
223 u32 bus_no
; /* bus # (0..n-1) from the msg receiver's end */
224 u32 dev_no
; /* bus-relative (0..n-1) device number */
225 u64 channel_addr
; /* Guest physical address of the channel, which
226 * can be dereferenced by the receiver of this
227 * ControlVm command */
228 u64 channel_bytes
; /* specifies size of the channel in bytes */
229 uuid_le data_type_uuid
; /* specifies format of data in channel */
230 uuid_le dev_inst_uuid
; /* instance guid for the device */
231 struct irq_info intr
; /* specifies interrupt information */
232 }; /* for CONTROLVM_DEVICE_CREATE */
234 struct controlvm_packet_device_configure
{
235 u32 bus_no
; /* bus # (0..n-1) from the msg
236 * receiver's perspective */
237 /* Control uses header SegmentIndex field to access bus number... */
238 u32 dev_no
; /* bus-relative (0..n-1) device number */
239 } ; /* for CONTROLVM_DEVICE_CONFIGURE */
241 struct controlvm_message_device_create
{
242 struct controlvm_message_header header
;
243 struct controlvm_packet_device_create packet
;
244 }; /* total 128 bytes */
246 struct controlvm_message_device_configure
{
247 struct controlvm_message_header header
;
248 struct controlvm_packet_device_configure packet
;
249 }; /* total 56 bytes */
251 /* This is the format for a message in any ControlVm queue. */
252 struct controlvm_message_packet
{
255 u32 bus_no
; /* bus # (0..n-1) from the msg
256 * receiver's perspective */
257 u32 dev_count
; /* indicates the max number of
258 * devices on this bus */
259 u64 channel_addr
; /* Guest physical address of
260 * the channel, which can be
261 * dereferenced by the receiver
262 * of this ControlVm command */
263 u64 channel_bytes
; /* size of the channel */
264 uuid_le bus_data_type_uuid
; /* indicates format of
265 * data in bus channel*/
266 uuid_le bus_inst_uuid
; /* instance uuid for the bus */
267 } create_bus
; /* for CONTROLVM_BUS_CREATE */
269 u32 bus_no
; /* bus # (0..n-1) from the msg
270 * receiver's perspective */
271 u32 reserved
; /* Natural alignment purposes */
272 } destroy_bus
; /* for CONTROLVM_BUS_DESTROY */
274 u32 bus_no
; /* bus # (0..n-1) from the receiver's
276 u32 reserved1
; /* for alignment purposes */
277 u64 guest_handle
; /* This is used to convert
278 * guest physical address to
279 * physical address */
280 u64 recv_bus_irq_handle
;
281 /* specifies interrupt info. It is used by SP
282 * to register to receive interrupts from the
283 * CP. This interrupt is used for bus level
284 * notifications. The corresponding
285 * sendBusInterruptHandle is kept in CP. */
286 } configure_bus
; /* for CONTROLVM_BUS_CONFIGURE */
287 /* for CONTROLVM_DEVICE_CREATE */
288 struct controlvm_packet_device_create create_device
;
290 u32 bus_no
; /* bus # (0..n-1) from the msg
291 * receiver's perspective */
292 u32 dev_no
; /* bus-relative (0..n-1) device # */
293 } destroy_device
; /* for CONTROLVM_DEVICE_DESTROY */
294 /* for CONTROLVM_DEVICE_CONFIGURE */
295 struct controlvm_packet_device_configure configure_device
;
297 u32 bus_no
; /* bus # (0..n-1) from the msg
298 * receiver's perspective */
299 u32 dev_no
; /* bus-relative (0..n-1) device # */
300 } reconfigure_device
; /* for CONTROLVM_DEVICE_RECONFIGURE */
303 struct spar_segment_state state
;
304 u8 reserved
[2]; /* Natural alignment purposes */
305 } bus_change_state
; /* for CONTROLVM_BUS_CHANGESTATE */
309 struct spar_segment_state state
;
311 u32 phys_device
:1; /* =1 if message is for
312 * a physical device */
314 u8 reserved
[2]; /* Natural alignment purposes */
315 } device_change_state
; /* for CONTROLVM_DEVICE_CHANGESTATE */
319 struct spar_segment_state state
;
320 u8 reserved
[6]; /* Natural alignment purposes */
321 } device_change_state_event
;
322 /* for CONTROLVM_DEVICE_CHANGESTATE_EVENT */
324 u32 bus_count
; /* indicates the max number of busses */
325 u32 switch_count
; /* indicates the max number of
326 * switches if a service partition */
327 enum ultra_chipset_feature features
;
328 u32 platform_number
; /* Platform Number */
329 } init_chipset
; /* for CONTROLVM_CHIPSET_INIT */
331 u32 options
; /* reserved */
332 u32 test
; /* bit 0 set to run embedded selftest */
333 } chipset_selftest
; /* for CONTROLVM_CHIPSET_SELFTEST */
334 u64 addr
; /* a physical address of something, that can be
335 * dereferenced by the receiver of this
336 * ControlVm command (depends on command id) */
337 u64 handle
; /* a handle of something (depends on command
342 /* All messages in any ControlVm queue have this layout. */
343 struct controlvm_message
{
344 struct controlvm_message_header hdr
;
345 struct controlvm_message_packet cmd
;
348 struct spar_controlvm_channel_protocol
{
349 struct channel_header header
;
350 u64 gp_controlvm
; /* guest phys addr of this channel */
351 u64 gp_partition_tables
;/* guest phys addr of partition tables */
352 u64 gp_diag_guest
; /* guest phys addr of diagnostic channel */
353 u64 gp_boot_romdisk
;/* guest phys addr of (read* only) Boot ROM disk */
354 u64 gp_boot_ramdisk
;/* guest phys addr of writable Boot RAM disk */
355 u64 gp_acpi_table
; /* guest phys addr of acpi table */
356 u64 gp_control_channel
;/* guest phys addr of control channel */
357 u64 gp_diag_romdisk
;/* guest phys addr of diagnostic ROM disk */
358 u64 gp_nvram
; /* guest phys addr of NVRAM channel */
359 u64 request_payload_offset
; /* Offset to request payload area */
360 u64 event_payload_offset
; /* Offset to event payload area */
361 u32 request_payload_bytes
; /* Bytes available in request payload
363 u32 event_payload_bytes
;/* Bytes available in event payload area */
364 u32 control_channel_bytes
;
365 u32 nvram_channel_bytes
; /* Bytes in PartitionNvram segment */
366 u32 message_bytes
; /* sizeof(CONTROLVM_MESSAGE) */
367 u32 message_count
; /* CONTROLVM_MESSAGE_MAX */
368 u64 gp_smbios_table
; /* guest phys addr of SMBIOS tables */
369 u64 gp_physical_smbios_table
; /* guest phys addr of SMBIOS table */
370 /* ULTRA_MAX_GUESTS_PER_SERVICE */
371 char gp_reserved
[2688];
373 /* guest physical address of EFI firmware image base */
374 u64 virtual_guest_firmware_image_base
;
376 /* guest physical address of EFI firmware entry point */
377 u64 virtual_guest_firmware_entry_point
;
379 /* guest EFI firmware image size */
380 u64 virtual_guest_firmware_image_size
;
382 /* GPA = 1MB where EFI firmware image is copied to */
383 u64 virtual_guest_firmware_boot_base
;
384 u64 virtual_guest_image_base
;
385 u64 virtual_guest_image_size
;
386 u64 prototype_control_channel_offset
;
387 u64 virtual_guest_partition_handle
;
389 u16 restore_action
; /* Restore Action field to restore the guest
391 u16 dump_action
; /* For Windows guests it shows if the visordisk
392 * is running in dump mode */
393 u16 nvram_fail_count
;
394 u16 saved_crash_message_count
; /* = CONTROLVM_CRASHMSG_MAX */
395 u32 saved_crash_message_offset
; /* Offset to request payload area needed
397 u32 installation_error
; /* Type of error encountered during
399 u32 installation_text_id
; /* Id of string to display */
400 u16 installation_remaining_steps
;/* Number of remaining installation
401 * steps (for progress bars) */
402 u8 tool_action
; /* ULTRA_TOOL_ACTIONS Installation Action
404 u8 reserved
; /* alignment */
405 struct efi_spar_indication efi_spar_ind
;
406 struct efi_spar_indication efi_spar_ind_supported
;
408 u8 reserved2
[28]; /* Force signals to begin on 128-byte cache
410 struct signal_queue_header request_queue
;/* Service or guest partition
411 * uses this queue to send
412 * requests to Control */
413 struct signal_queue_header response_queue
;/* Control uses this queue to
414 * respond to service or guest
415 * partition requests */
416 struct signal_queue_header event_queue
; /* Control uses this queue to
417 * send events to service or
419 struct signal_queue_header event_ack_queue
;/* Service or guest partition
420 * uses this queue to ack
423 /* Request fixed-size message pool - does not include payload */
424 struct controlvm_message request_msg
[CONTROLVM_MESSAGE_MAX
];
426 /* Response fixed-size message pool - does not include payload */
427 struct controlvm_message response_msg
[CONTROLVM_MESSAGE_MAX
];
429 /* Event fixed-size message pool - does not include payload */
430 struct controlvm_message event_msg
[CONTROLVM_MESSAGE_MAX
];
432 /* Ack fixed-size message pool - does not include payload */
433 struct controlvm_message event_ack_msg
[CONTROLVM_MESSAGE_MAX
];
435 /* Message stored during IOVM creation to be reused after crash */
436 struct controlvm_message saved_crash_msg
[CONTROLVM_CRASHMSG_MAX
];
439 /* Offsets for VM channel attributes */
440 #define VM_CH_REQ_QUEUE_OFFSET \
441 offsetof(struct spar_controlvm_channel_protocol, request_queue)
442 #define VM_CH_RESP_QUEUE_OFFSET \
443 offsetof(struct spar_controlvm_channel_protocol, response_queue)
444 #define VM_CH_EVENT_QUEUE_OFFSET \
445 offsetof(struct spar_controlvm_channel_protocol, event_queue)
446 #define VM_CH_ACK_QUEUE_OFFSET \
447 offsetof(struct spar_controlvm_channel_protocol, event_ack_queue)
448 #define VM_CH_REQ_MSG_OFFSET \
449 offsetof(struct spar_controlvm_channel_protocol, request_msg)
450 #define VM_CH_RESP_MSG_OFFSET \
451 offsetof(struct spar_controlvm_channel_protocol, response_msg)
452 #define VM_CH_EVENT_MSG_OFFSET \
453 offsetof(struct spar_controlvm_channel_protocol, event_msg)
454 #define VM_CH_ACK_MSG_OFFSET \
455 offsetof(struct spar_controlvm_channel_protocol, event_ack_msg)
456 #define VM_CH_CRASH_MSG_OFFSET \
457 offsetof(struct spar_controlvm_channel_protocol, saved_crash_msg)
459 /* The following header will be located at the beginning of PayloadVmOffset for
460 * various ControlVm commands. The receiver of a ControlVm command with a
461 * PayloadVmOffset will dereference this address and then use connection_offset,
462 * initiator_offset, and target_offset to get the location of UTF-8 formatted
463 * strings that can be parsed to obtain command-specific information. The value
464 * of total_length should equal PayloadBytes. The format of the strings at
465 * PayloadVmOffset will take different forms depending on the message.
467 struct spar_controlvm_parameters_header
{
470 u32 connection_offset
;
471 u32 connection_length
;
472 u32 initiator_offset
;
473 u32 initiator_length
;
482 u32 reserved
; /* Natural alignment */
485 #endif /* __CONTROLVMCHANNEL_H__ */