Benjamin Romer | 6f14cc1 | 2015-07-16 12:40:48 -0400 | [diff] [blame] | 1 | /* Copyright (C) 2010 - 2015 UNISYS CORPORATION |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 2 | * All rights reserved. |
| 3 | * |
Benjamin Romer | 6f14cc1 | 2015-07-16 12:40:48 -0400 | [diff] [blame] | 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms and conditions of the GNU General Public License, |
| 6 | * version 2, as published by the Free Software Foundation. |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, but |
| 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or |
| 11 | * NON INFRINGEMENT. See the GNU General Public License for more |
| 12 | * details. |
| 13 | */ |
| 14 | |
| 15 | #ifndef __CONTROLVMCHANNEL_H__ |
| 16 | #define __CONTROLVMCHANNEL_H__ |
| 17 | |
Benjamin Romer | 90addb0 | 2014-05-06 09:58:23 -0400 | [diff] [blame] | 18 | #include <linux/uuid.h> |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 19 | #include "channel.h" |
Benjamin Romer | af96e9c | 2014-08-02 22:03:40 -0400 | [diff] [blame] | 20 | |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 21 | /* {2B3C2D10-7EF5-4ad8-B966-3448B7386B3D} */ |
Benjamin Romer | 5fbaa4b | 2014-10-23 14:30:14 -0400 | [diff] [blame] | 22 | #define SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID \ |
Benjamin Romer | 90addb0 | 2014-05-06 09:58:23 -0400 | [diff] [blame] | 23 | UUID_LE(0x2b3c2d10, 0x7ef5, 0x4ad8, \ |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 24 | 0xb9, 0x66, 0x34, 0x48, 0xb7, 0x38, 0x6b, 0x3d) |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 25 | |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 26 | #define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE \ |
| 27 | ULTRA_CHANNEL_PROTOCOL_SIGNATURE |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 28 | #define CONTROLVM_MESSAGE_MAX 64 |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 29 | |
| 30 | /* Must increment this whenever you insert or delete fields within |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 31 | * this channel struct. Also increment whenever you change the meaning |
| 32 | * of fields within this channel struct so as to break pre-existing |
| 33 | * software. Note that you can usually add fields to the END of the |
| 34 | * channel struct withOUT needing to increment this. |
| 35 | */ |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 36 | #define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID 1 |
| 37 | |
Benjamin Romer | 600832f | 2014-10-23 14:30:16 -0400 | [diff] [blame] | 38 | #define SPAR_CONTROLVM_CHANNEL_OK_CLIENT(ch) \ |
| 39 | spar_check_channel_client(ch, \ |
Jes Sorensen | df94247 | 2015-05-05 18:37:10 -0400 | [diff] [blame] | 40 | SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID, \ |
Benjamin Romer | d19642f | 2014-10-23 14:30:34 -0400 | [diff] [blame] | 41 | "controlvm", \ |
| 42 | sizeof(struct spar_controlvm_channel_protocol), \ |
| 43 | ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \ |
| 44 | ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE) |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 45 | |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 46 | #define MAX_SERIAL_NUM 32 |
| 47 | |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 48 | /* Defines for various channel queues */ |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 49 | #define CONTROLVM_QUEUE_REQUEST 0 |
| 50 | #define CONTROLVM_QUEUE_RESPONSE 1 |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 51 | #define CONTROLVM_QUEUE_EVENT 2 |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 52 | #define CONTROLVM_QUEUE_ACK 3 |
| 53 | |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 54 | /* Max num of messages stored during IOVM creation to be reused after crash */ |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 55 | #define CONTROLVM_CRASHMSG_MAX 2 |
| 56 | |
David Kershner | 389f559 | 2015-05-13 13:22:03 -0400 | [diff] [blame] | 57 | struct spar_segment_state { |
Erik Arfvidson | 1e3ab52 | 2016-02-08 10:41:41 -0500 | [diff] [blame] | 58 | /* Bit 0: May enter other states */ |
| 59 | u16 enabled:1; |
| 60 | /* Bit 1: Assigned to active partition */ |
| 61 | u16 active:1; |
| 62 | /* Bit 2: Configure message sent to service/server */ |
| 63 | u16 alive:1; |
| 64 | /* Bit 3: similar to partition state ShuttingDown */ |
| 65 | u16 revoked:1; |
| 66 | /* Bit 4: memory (device/port number) has been selected by Command */ |
| 67 | u16 allocated:1; |
| 68 | /* Bit 5: has been introduced to the service/guest partition */ |
| 69 | u16 known:1; |
| 70 | /* Bit 6: service/Guest partition has responded to introduction */ |
| 71 | u16 ready:1; |
| 72 | /* Bit 7: resource is configured and operating */ |
| 73 | u16 operating:1; |
| 74 | /* Note: don't use high bit unless we need to switch to ushort |
| 75 | * which is non-compliant |
| 76 | */ |
David Kershner | 389f559 | 2015-05-13 13:22:03 -0400 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | static const struct spar_segment_state segment_state_running = { |
| 80 | 1, 1, 1, 0, 1, 1, 1, 1 |
| 81 | }; |
| 82 | |
| 83 | static const struct spar_segment_state segment_state_paused = { |
| 84 | 1, 1, 1, 0, 1, 1, 1, 0 |
| 85 | }; |
| 86 | |
| 87 | static const struct spar_segment_state segment_state_standby = { |
| 88 | 1, 1, 0, 0, 1, 1, 1, 0 |
| 89 | }; |
| 90 | |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 91 | /* Ids for commands that may appear in either queue of a ControlVm channel. |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 92 | * |
| 93 | * Commands that are initiated by the command partition (CP), by an IO or |
| 94 | * console service partition (SP), or by a guest partition (GP)are: |
| 95 | * - issued on the RequestQueue queue (q #0) in the ControlVm channel |
| 96 | * - responded to on the ResponseQueue queue (q #1) in the ControlVm channel |
| 97 | * |
| 98 | * Events that are initiated by an IO or console service partition (SP) or |
| 99 | * by a guest partition (GP) are: |
| 100 | * - issued on the EventQueue queue (q #2) in the ControlVm channel |
| 101 | * - responded to on the EventAckQueue queue (q #3) in the ControlVm channel |
| 102 | */ |
Benjamin Romer | 53bebb1 | 2014-10-23 14:30:17 -0400 | [diff] [blame] | 103 | enum controlvm_id { |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 104 | CONTROLVM_INVALID = 0, |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 105 | /* SWITCH commands required Parameter: SwitchNumber */ |
| 106 | /* BUS commands required Parameter: BusNumber */ |
| 107 | CONTROLVM_BUS_CREATE = 0x101, /* CP --> SP, GP */ |
| 108 | CONTROLVM_BUS_DESTROY = 0x102, /* CP --> SP, GP */ |
| 109 | CONTROLVM_BUS_CONFIGURE = 0x104, /* CP --> SP */ |
| 110 | CONTROLVM_BUS_CHANGESTATE = 0x105, /* CP --> SP, GP */ |
| 111 | CONTROLVM_BUS_CHANGESTATE_EVENT = 0x106, /* SP, GP --> CP */ |
| 112 | /* DEVICE commands required Parameter: BusNumber, DeviceNumber */ |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 113 | |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 114 | CONTROLVM_DEVICE_CREATE = 0x201, /* CP --> SP, GP */ |
| 115 | CONTROLVM_DEVICE_DESTROY = 0x202, /* CP --> SP, GP */ |
| 116 | CONTROLVM_DEVICE_CONFIGURE = 0x203, /* CP --> SP */ |
| 117 | CONTROLVM_DEVICE_CHANGESTATE = 0x204, /* CP --> SP, GP */ |
| 118 | CONTROLVM_DEVICE_CHANGESTATE_EVENT = 0x205, /* SP, GP --> CP */ |
| 119 | CONTROLVM_DEVICE_RECONFIGURE = 0x206, /* CP --> Boot */ |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 120 | /* CHIPSET commands */ |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 121 | CONTROLVM_CHIPSET_INIT = 0x301, /* CP --> SP, GP */ |
| 122 | CONTROLVM_CHIPSET_STOP = 0x302, /* CP --> SP, GP */ |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 123 | CONTROLVM_CHIPSET_READY = 0x304, /* CP --> SP */ |
| 124 | CONTROLVM_CHIPSET_SELFTEST = 0x305, /* CP --> SP */ |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 125 | |
Veronika Kabatova | d8ad8b0 | 2014-10-08 03:59:55 +0200 | [diff] [blame] | 126 | }; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 127 | |
Benjamin Romer | 4eddbf1 | 2014-10-03 14:09:10 -0400 | [diff] [blame] | 128 | struct irq_info { |
Erik Arfvidson | 22a0350 | 2015-05-05 18:36:41 -0400 | [diff] [blame] | 129 | u64 reserved1; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 130 | |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 131 | /* specifies interrupt handle. It is used to retrieve the |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 132 | * corresponding interrupt pin from Monitor; and the |
| 133 | * interrupt pin is used to connect to the corresponding |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 134 | * interrupt. Used by IOPart-GP only. |
| 135 | */ |
Benjamin Romer | af3286b | 2014-10-23 14:30:18 -0400 | [diff] [blame] | 136 | u64 recv_irq_handle; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 137 | |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 138 | /* specifies interrupt vector. It, interrupt pin, and shared are |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 139 | * used to connect to the corresponding interrupt. Used by |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 140 | * IOPart-GP only. |
| 141 | */ |
Benjamin Romer | af3286b | 2014-10-23 14:30:18 -0400 | [diff] [blame] | 142 | u32 recv_irq_vector; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 143 | |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 144 | /* specifies if the recvInterrupt is shared. It, interrupt pin |
| 145 | * and vector are used to connect to 0 = not shared; 1 = shared. |
| 146 | * the corresponding interrupt. Used by IOPart-GP only. |
| 147 | */ |
Benjamin Romer | af3286b | 2014-10-23 14:30:18 -0400 | [diff] [blame] | 148 | u8 recv_irq_shared; |
Benjamin Romer | c242233 | 2014-07-29 15:09:40 -0400 | [diff] [blame] | 149 | u8 reserved[3]; /* Natural alignment purposes */ |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 150 | }; |
| 151 | |
Benjamin Romer | c12ad83 | 2014-10-03 14:09:09 -0400 | [diff] [blame] | 152 | struct pci_id { |
Benjamin Romer | 6822f73 | 2014-10-23 14:30:19 -0400 | [diff] [blame] | 153 | u16 domain; |
| 154 | u8 bus; |
| 155 | u8 slot; |
| 156 | u8 func; |
| 157 | u8 reserved[3]; /* Natural alignment purposes */ |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 158 | }; |
| 159 | |
Benjamin Romer | 755e2ec | 2014-10-23 14:30:21 -0400 | [diff] [blame] | 160 | struct efi_spar_indication { |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 161 | u64 boot_to_fw_ui:1; /* Bit 0: Stop in uefi ui */ |
| 162 | u64 clear_nvram:1; /* Bit 1: Clear NVRAM */ |
| 163 | u64 clear_cmos:1; /* Bit 2: Clear CMOS */ |
| 164 | u64 boot_to_tool:1; /* Bit 3: Run install tool */ |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 165 | /* remaining bits are available */ |
Benjamin Romer | 755e2ec | 2014-10-23 14:30:21 -0400 | [diff] [blame] | 166 | }; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 167 | |
Benjamin Romer | b9b141e | 2014-10-23 14:30:24 -0400 | [diff] [blame] | 168 | enum ultra_chipset_feature { |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 169 | ULTRA_CHIPSET_FEATURE_REPLY = 0x00000001, |
| 170 | ULTRA_CHIPSET_FEATURE_PARA_HOTPLUG = 0x00000002, |
Benjamin Romer | b9b141e | 2014-10-23 14:30:24 -0400 | [diff] [blame] | 171 | }; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 172 | |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 173 | /* This is the common structure that is at the beginning of every |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 174 | * ControlVm message (both commands and responses) in any ControlVm |
| 175 | * queue. Commands are easily distinguished from responses by |
| 176 | * looking at the flags.response field. |
| 177 | */ |
Benjamin Romer | 98d7b59 | 2014-10-23 14:30:26 -0400 | [diff] [blame] | 178 | struct controlvm_message_header { |
| 179 | u32 id; /* See CONTROLVM_ID. */ |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 180 | /* For requests, indicates the message type. */ |
| 181 | /* For responses, indicates the type of message we are responding to. */ |
| 182 | |
Erik Arfvidson | 1e3ab52 | 2016-02-08 10:41:41 -0500 | [diff] [blame] | 183 | /* Includes size of this struct + size of message */ |
| 184 | u32 message_size; |
| 185 | /* Index of segment containing Vm message/information */ |
| 186 | u32 segment_index; |
| 187 | /* Error status code or result of message completion */ |
| 188 | u32 completion_status; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 189 | struct { |
Erik Arfvidson | 1e3ab52 | 2016-02-08 10:41:41 -0500 | [diff] [blame] | 190 | /* =1 in a response to signify failure */ |
| 191 | u32 failed:1; |
| 192 | /* =1 in all messages that expect a response */ |
| 193 | u32 response_expected:1; |
| 194 | /* =1 in all bus & device-related messages where the message |
| 195 | * receiver is to act as the bus or device server |
| 196 | */ |
| 197 | u32 server:1; |
| 198 | /* =1 for testing use only (Control and Command ignore this */ |
| 199 | u32 test_message:1; |
| 200 | /* =1 if there are forthcoming responses/acks associated |
| 201 | * with this message |
| 202 | */ |
| 203 | u32 partial_completion:1; |
| 204 | /* =1 this is to let us know to preserve channel contents */ |
| 205 | u32 preserve:1; |
| 206 | /* =1 the DiagWriter is active in the Diagnostic Partition */ |
| 207 | u32 writer_in_diag:1; |
Benjamin Romer | 98d7b59 | 2014-10-23 14:30:26 -0400 | [diff] [blame] | 208 | } flags; |
Erik Arfvidson | 1e3ab52 | 2016-02-08 10:41:41 -0500 | [diff] [blame] | 209 | /* Natural alignment */ |
| 210 | u32 reserved; |
| 211 | /* Identifies the particular message instance */ |
| 212 | u64 message_handle; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 213 | /* request instances with the corresponding response instance. */ |
Erik Arfvidson | 1e3ab52 | 2016-02-08 10:41:41 -0500 | [diff] [blame] | 214 | /* Offset of payload area from start of this instance */ |
| 215 | u64 payload_vm_offset; |
| 216 | /* Maximum bytes allocated in payload area of ControlVm segment */ |
| 217 | u32 payload_max_bytes; |
| 218 | /* Actual number of bytes of payload area to copy between IO/Command */ |
| 219 | u32 payload_bytes; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 220 | /* if non-zero, there is a payload to copy. */ |
Benjamin Romer | 98d7b59 | 2014-10-23 14:30:26 -0400 | [diff] [blame] | 221 | }; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 222 | |
Benjamin Romer | f91b926 | 2014-10-23 14:30:27 -0400 | [diff] [blame] | 223 | struct controlvm_packet_device_create { |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 224 | u32 bus_no; /* bus # (0..n-1) from the msg receiver's end */ |
| 225 | u32 dev_no; /* bus-relative (0..n-1) device number */ |
Erik Arfvidson | 1e3ab52 | 2016-02-08 10:41:41 -0500 | [diff] [blame] | 226 | /* Guest physical address of the channel, which can be dereferenced by |
| 227 | * the receiver of this ControlVm command |
| 228 | */ |
| 229 | u64 channel_addr; |
Benjamin Romer | f91b926 | 2014-10-23 14:30:27 -0400 | [diff] [blame] | 230 | u64 channel_bytes; /* specifies size of the channel in bytes */ |
| 231 | uuid_le data_type_uuid; /* specifies format of data in channel */ |
| 232 | uuid_le dev_inst_uuid; /* instance guid for the device */ |
| 233 | struct irq_info intr; /* specifies interrupt information */ |
| 234 | }; /* for CONTROLVM_DEVICE_CREATE */ |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 235 | |
Benjamin Romer | e6ad00b | 2014-10-23 14:30:28 -0400 | [diff] [blame] | 236 | struct controlvm_packet_device_configure { |
Erik Arfvidson | 1e3ab52 | 2016-02-08 10:41:41 -0500 | [diff] [blame] | 237 | /* bus # (0..n-1) from the msg receiver's perspective */ |
| 238 | u32 bus_no; |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 239 | /* Control uses header SegmentIndex field to access bus number... */ |
| 240 | u32 dev_no; /* bus-relative (0..n-1) device number */ |
Benjamin Romer | e6ad00b | 2014-10-23 14:30:28 -0400 | [diff] [blame] | 241 | } ; /* for CONTROLVM_DEVICE_CONFIGURE */ |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 242 | |
Benjamin Romer | c36acb5 | 2014-10-23 14:30:29 -0400 | [diff] [blame] | 243 | struct controlvm_message_device_create { |
| 244 | struct controlvm_message_header header; |
| 245 | struct controlvm_packet_device_create packet; |
| 246 | }; /* total 128 bytes */ |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 247 | |
Benjamin Romer | f676054 | 2014-10-23 14:30:30 -0400 | [diff] [blame] | 248 | struct controlvm_message_device_configure { |
| 249 | struct controlvm_message_header header; |
| 250 | struct controlvm_packet_device_configure packet; |
| 251 | }; /* total 56 bytes */ |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 252 | |
| 253 | /* This is the format for a message in any ControlVm queue. */ |
Benjamin Romer | 2ea5117 | 2014-10-23 14:30:25 -0400 | [diff] [blame] | 254 | struct controlvm_message_packet { |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 255 | union { |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 256 | struct { |
Erik Arfvidson | 1e3ab52 | 2016-02-08 10:41:41 -0500 | [diff] [blame] | 257 | /* bus # (0..n-1) from the msg receiver's perspective */ |
| 258 | u32 bus_no; |
| 259 | /* indicates the max number of devices on this bus */ |
| 260 | u32 dev_count; |
| 261 | /* Guest physical address of the channel, which can be |
| 262 | * dereferenced by the receiver of this ControlVm command |
| 263 | */ |
| 264 | u64 channel_addr; |
Benjamin Romer | 2ea5117 | 2014-10-23 14:30:25 -0400 | [diff] [blame] | 265 | u64 channel_bytes; /* size of the channel */ |
Erik Arfvidson | 1e3ab52 | 2016-02-08 10:41:41 -0500 | [diff] [blame] | 266 | /* indicates format of data in bus channel*/ |
| 267 | uuid_le bus_data_type_uuid; |
Benjamin Romer | 2ea5117 | 2014-10-23 14:30:25 -0400 | [diff] [blame] | 268 | uuid_le bus_inst_uuid; /* instance uuid for the bus */ |
| 269 | } create_bus; /* for CONTROLVM_BUS_CREATE */ |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 270 | struct { |
Erik Arfvidson | 1e3ab52 | 2016-02-08 10:41:41 -0500 | [diff] [blame] | 271 | /* bus # (0..n-1) from the msg receiver's perspective */ |
| 272 | u32 bus_no; |
Benjamin Romer | b3c55b1 | 2014-07-31 12:00:50 -0400 | [diff] [blame] | 273 | u32 reserved; /* Natural alignment purposes */ |
Benjamin Romer | 2ea5117 | 2014-10-23 14:30:25 -0400 | [diff] [blame] | 274 | } destroy_bus; /* for CONTROLVM_BUS_DESTROY */ |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 275 | struct { |
Erik Arfvidson | 1e3ab52 | 2016-02-08 10:41:41 -0500 | [diff] [blame] | 276 | /* bus # (0..n-1) from the receiver's perspective */ |
| 277 | u32 bus_no; |
Benjamin Romer | 2ea5117 | 2014-10-23 14:30:25 -0400 | [diff] [blame] | 278 | u32 reserved1; /* for alignment purposes */ |
Erik Arfvidson | 1e3ab52 | 2016-02-08 10:41:41 -0500 | [diff] [blame] | 279 | /* This is used to convert guest physical address to physical address */ |
| 280 | u64 guest_handle; |
Benjamin Romer | 2ea5117 | 2014-10-23 14:30:25 -0400 | [diff] [blame] | 281 | u64 recv_bus_irq_handle; |
| 282 | /* specifies interrupt info. It is used by SP |
| 283 | * to register to receive interrupts from the |
| 284 | * CP. This interrupt is used for bus level |
| 285 | * notifications. The corresponding |
Erik Arfvidson | 1e3ab52 | 2016-02-08 10:41:41 -0500 | [diff] [blame] | 286 | * sendBusInterruptHandle is kept in CP. |
| 287 | */ |
Benjamin Romer | 2ea5117 | 2014-10-23 14:30:25 -0400 | [diff] [blame] | 288 | } configure_bus; /* for CONTROLVM_BUS_CONFIGURE */ |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 289 | /* for CONTROLVM_DEVICE_CREATE */ |
Benjamin Romer | f91b926 | 2014-10-23 14:30:27 -0400 | [diff] [blame] | 290 | struct controlvm_packet_device_create create_device; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 291 | struct { |
Erik Arfvidson | 1e3ab52 | 2016-02-08 10:41:41 -0500 | [diff] [blame] | 292 | /* bus # (0..n-1) from the msg receiver's perspective */ |
| 293 | u32 bus_no; |
Benjamin Romer | 2ea5117 | 2014-10-23 14:30:25 -0400 | [diff] [blame] | 294 | u32 dev_no; /* bus-relative (0..n-1) device # */ |
| 295 | } destroy_device; /* for CONTROLVM_DEVICE_DESTROY */ |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 296 | /* for CONTROLVM_DEVICE_CONFIGURE */ |
Benjamin Romer | e6ad00b | 2014-10-23 14:30:28 -0400 | [diff] [blame] | 297 | struct controlvm_packet_device_configure configure_device; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 298 | struct { |
Erik Arfvidson | 1e3ab52 | 2016-02-08 10:41:41 -0500 | [diff] [blame] | 299 | /* bus # (0..n-1) from the msg receiver's perspective */ |
| 300 | u32 bus_no; |
Benjamin Romer | 2ea5117 | 2014-10-23 14:30:25 -0400 | [diff] [blame] | 301 | u32 dev_no; /* bus-relative (0..n-1) device # */ |
| 302 | } reconfigure_device; /* for CONTROLVM_DEVICE_RECONFIGURE */ |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 303 | struct { |
Benjamin Romer | 2ea5117 | 2014-10-23 14:30:25 -0400 | [diff] [blame] | 304 | u32 bus_no; |
Benjamin Romer | 3f833b5 | 2014-10-23 14:30:12 -0400 | [diff] [blame] | 305 | struct spar_segment_state state; |
Benjamin Romer | c242233 | 2014-07-29 15:09:40 -0400 | [diff] [blame] | 306 | u8 reserved[2]; /* Natural alignment purposes */ |
Benjamin Romer | 2ea5117 | 2014-10-23 14:30:25 -0400 | [diff] [blame] | 307 | } bus_change_state; /* for CONTROLVM_BUS_CHANGESTATE */ |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 308 | struct { |
Benjamin Romer | 2ea5117 | 2014-10-23 14:30:25 -0400 | [diff] [blame] | 309 | u32 bus_no; |
| 310 | u32 dev_no; |
Benjamin Romer | 3f833b5 | 2014-10-23 14:30:12 -0400 | [diff] [blame] | 311 | struct spar_segment_state state; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 312 | struct { |
Erik Arfvidson | 1e3ab52 | 2016-02-08 10:41:41 -0500 | [diff] [blame] | 313 | /* =1 if message is for a physical device */ |
| 314 | u32 phys_device:1; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 315 | } flags; |
Benjamin Romer | c242233 | 2014-07-29 15:09:40 -0400 | [diff] [blame] | 316 | u8 reserved[2]; /* Natural alignment purposes */ |
Benjamin Romer | 2ea5117 | 2014-10-23 14:30:25 -0400 | [diff] [blame] | 317 | } device_change_state; /* for CONTROLVM_DEVICE_CHANGESTATE */ |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 318 | struct { |
Benjamin Romer | 2ea5117 | 2014-10-23 14:30:25 -0400 | [diff] [blame] | 319 | u32 bus_no; |
| 320 | u32 dev_no; |
Benjamin Romer | 3f833b5 | 2014-10-23 14:30:12 -0400 | [diff] [blame] | 321 | struct spar_segment_state state; |
Benjamin Romer | c242233 | 2014-07-29 15:09:40 -0400 | [diff] [blame] | 322 | u8 reserved[6]; /* Natural alignment purposes */ |
Benjamin Romer | 2ea5117 | 2014-10-23 14:30:25 -0400 | [diff] [blame] | 323 | } device_change_state_event; |
| 324 | /* for CONTROLVM_DEVICE_CHANGESTATE_EVENT */ |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 325 | struct { |
Erik Arfvidson | 1e3ab52 | 2016-02-08 10:41:41 -0500 | [diff] [blame] | 326 | /* indicates the max number of busses */ |
| 327 | u32 bus_count; |
| 328 | /* indicates the max number of switches */ |
| 329 | u32 switch_count; |
Benjamin Romer | b9b141e | 2014-10-23 14:30:24 -0400 | [diff] [blame] | 330 | enum ultra_chipset_feature features; |
Benjamin Romer | 2ea5117 | 2014-10-23 14:30:25 -0400 | [diff] [blame] | 331 | u32 platform_number; /* Platform Number */ |
| 332 | } init_chipset; /* for CONTROLVM_CHIPSET_INIT */ |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 333 | struct { |
Benjamin Romer | 2ea5117 | 2014-10-23 14:30:25 -0400 | [diff] [blame] | 334 | u32 options; /* reserved */ |
| 335 | u32 test; /* bit 0 set to run embedded selftest */ |
| 336 | } chipset_selftest; /* for CONTROLVM_CHIPSET_SELFTEST */ |
Erik Arfvidson | 1e3ab52 | 2016-02-08 10:41:41 -0500 | [diff] [blame] | 337 | /* a physical address of something, that can be dereferenced |
| 338 | * by the receiver of this ControlVm command |
| 339 | */ |
| 340 | u64 addr; |
| 341 | /* a handle of something (depends on command id) */ |
| 342 | u64 handle; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 343 | }; |
Benjamin Romer | 2ea5117 | 2014-10-23 14:30:25 -0400 | [diff] [blame] | 344 | }; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 345 | |
| 346 | /* All messages in any ControlVm queue have this layout. */ |
Benjamin Romer | 3ab4770 | 2014-10-23 14:30:31 -0400 | [diff] [blame] | 347 | struct controlvm_message { |
Benjamin Romer | 98d7b59 | 2014-10-23 14:30:26 -0400 | [diff] [blame] | 348 | struct controlvm_message_header hdr; |
Benjamin Romer | 2ea5117 | 2014-10-23 14:30:25 -0400 | [diff] [blame] | 349 | struct controlvm_message_packet cmd; |
Benjamin Romer | 3ab4770 | 2014-10-23 14:30:31 -0400 | [diff] [blame] | 350 | }; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 351 | |
Benjamin Romer | d19642f | 2014-10-23 14:30:34 -0400 | [diff] [blame] | 352 | struct spar_controlvm_channel_protocol { |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 353 | struct channel_header header; |
| 354 | u64 gp_controlvm; /* guest phys addr of this channel */ |
| 355 | u64 gp_partition_tables;/* guest phys addr of partition tables */ |
| 356 | u64 gp_diag_guest; /* guest phys addr of diagnostic channel */ |
| 357 | u64 gp_boot_romdisk;/* guest phys addr of (read* only) Boot ROM disk */ |
| 358 | u64 gp_boot_ramdisk;/* guest phys addr of writable Boot RAM disk */ |
| 359 | u64 gp_acpi_table; /* guest phys addr of acpi table */ |
| 360 | u64 gp_control_channel;/* guest phys addr of control channel */ |
| 361 | u64 gp_diag_romdisk;/* guest phys addr of diagnostic ROM disk */ |
| 362 | u64 gp_nvram; /* guest phys addr of NVRAM channel */ |
| 363 | u64 request_payload_offset; /* Offset to request payload area */ |
| 364 | u64 event_payload_offset; /* Offset to event payload area */ |
Erik Arfvidson | 1e3ab52 | 2016-02-08 10:41:41 -0500 | [diff] [blame] | 365 | /* Bytes available in request payload area */ |
| 366 | u32 request_payload_bytes; |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 367 | u32 event_payload_bytes;/* Bytes available in event payload area */ |
| 368 | u32 control_channel_bytes; |
| 369 | u32 nvram_channel_bytes; /* Bytes in PartitionNvram segment */ |
| 370 | u32 message_bytes; /* sizeof(CONTROLVM_MESSAGE) */ |
| 371 | u32 message_count; /* CONTROLVM_MESSAGE_MAX */ |
| 372 | u64 gp_smbios_table; /* guest phys addr of SMBIOS tables */ |
| 373 | u64 gp_physical_smbios_table; /* guest phys addr of SMBIOS table */ |
| 374 | /* ULTRA_MAX_GUESTS_PER_SERVICE */ |
Erik Arfvidson | 680385e | 2015-05-05 18:36:43 -0400 | [diff] [blame] | 375 | char gp_reserved[2688]; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 376 | |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 377 | /* guest physical address of EFI firmware image base */ |
| 378 | u64 virtual_guest_firmware_image_base; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 379 | |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 380 | /* guest physical address of EFI firmware entry point */ |
| 381 | u64 virtual_guest_firmware_entry_point; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 382 | |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 383 | /* guest EFI firmware image size */ |
| 384 | u64 virtual_guest_firmware_image_size; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 385 | |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 386 | /* GPA = 1MB where EFI firmware image is copied to */ |
| 387 | u64 virtual_guest_firmware_boot_base; |
| 388 | u64 virtual_guest_image_base; |
| 389 | u64 virtual_guest_image_size; |
| 390 | u64 prototype_control_channel_offset; |
| 391 | u64 virtual_guest_partition_handle; |
Erik Arfvidson | 1e3ab52 | 2016-02-08 10:41:41 -0500 | [diff] [blame] | 392 | /* Restore Action field to restore the guest partition */ |
| 393 | u16 restore_action; |
| 394 | /* For Windows guests it shows if the visordisk is in dump mode */ |
| 395 | u16 dump_action; |
Benjamin Romer | d19642f | 2014-10-23 14:30:34 -0400 | [diff] [blame] | 396 | u16 nvram_fail_count; |
| 397 | u16 saved_crash_message_count; /* = CONTROLVM_CRASHMSG_MAX */ |
Erik Arfvidson | 1e3ab52 | 2016-02-08 10:41:41 -0500 | [diff] [blame] | 398 | /* Offset to request payload area needed for crash dump */ |
| 399 | u32 saved_crash_message_offset; |
| 400 | /* Type of error encountered during installation */ |
| 401 | u32 installation_error; |
Benjamin Romer | d19642f | 2014-10-23 14:30:34 -0400 | [diff] [blame] | 402 | u32 installation_text_id; /* Id of string to display */ |
Erik Arfvidson | 1e3ab52 | 2016-02-08 10:41:41 -0500 | [diff] [blame] | 403 | /* Number of remaining installation steps (for progress bars) */ |
| 404 | u16 installation_remaining_steps; |
| 405 | /* ULTRA_TOOL_ACTIONS Installation Action field */ |
| 406 | u8 tool_action; |
Benjamin Romer | d19642f | 2014-10-23 14:30:34 -0400 | [diff] [blame] | 407 | u8 reserved; /* alignment */ |
| 408 | struct efi_spar_indication efi_spar_ind; |
| 409 | struct efi_spar_indication efi_spar_ind_supported; |
| 410 | u32 sp_reserved; |
Erik Arfvidson | 1e3ab52 | 2016-02-08 10:41:41 -0500 | [diff] [blame] | 411 | /* Force signals to begin on 128-byte cache line */ |
| 412 | u8 reserved2[28]; |
| 413 | /* guest partition uses this queue to send requests to Control */ |
| 414 | struct signal_queue_header request_queue; |
| 415 | /* Control uses this queue to respond to service or guest |
| 416 | * partition requests |
| 417 | */ |
| 418 | struct signal_queue_header response_queue; |
| 419 | /* Control uses this queue to send events to guest partition */ |
| 420 | struct signal_queue_header event_queue; |
| 421 | /* Service or guest partition uses this queue to ack Control events */ |
| 422 | struct signal_queue_header event_ack_queue; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 423 | /* Request fixed-size message pool - does not include payload */ |
Benjamin Romer | d19642f | 2014-10-23 14:30:34 -0400 | [diff] [blame] | 424 | struct controlvm_message request_msg[CONTROLVM_MESSAGE_MAX]; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 425 | |
| 426 | /* Response fixed-size message pool - does not include payload */ |
Benjamin Romer | d19642f | 2014-10-23 14:30:34 -0400 | [diff] [blame] | 427 | struct controlvm_message response_msg[CONTROLVM_MESSAGE_MAX]; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 428 | |
| 429 | /* Event fixed-size message pool - does not include payload */ |
Benjamin Romer | d19642f | 2014-10-23 14:30:34 -0400 | [diff] [blame] | 430 | struct controlvm_message event_msg[CONTROLVM_MESSAGE_MAX]; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 431 | |
| 432 | /* Ack fixed-size message pool - does not include payload */ |
Benjamin Romer | d19642f | 2014-10-23 14:30:34 -0400 | [diff] [blame] | 433 | struct controlvm_message event_ack_msg[CONTROLVM_MESSAGE_MAX]; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 434 | |
| 435 | /* Message stored during IOVM creation to be reused after crash */ |
Benjamin Romer | d19642f | 2014-10-23 14:30:34 -0400 | [diff] [blame] | 436 | struct controlvm_message saved_crash_msg[CONTROLVM_CRASHMSG_MAX]; |
| 437 | }; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 438 | |
Erik Arfvidson | 7e5a1a7 | 2015-05-05 18:36:42 -0400 | [diff] [blame] | 439 | /* Offsets for VM channel attributes */ |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 440 | #define VM_CH_REQ_QUEUE_OFFSET \ |
Benjamin Romer | d19642f | 2014-10-23 14:30:34 -0400 | [diff] [blame] | 441 | offsetof(struct spar_controlvm_channel_protocol, request_queue) |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 442 | #define VM_CH_RESP_QUEUE_OFFSET \ |
Benjamin Romer | d19642f | 2014-10-23 14:30:34 -0400 | [diff] [blame] | 443 | offsetof(struct spar_controlvm_channel_protocol, response_queue) |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 444 | #define VM_CH_EVENT_QUEUE_OFFSET \ |
Benjamin Romer | d19642f | 2014-10-23 14:30:34 -0400 | [diff] [blame] | 445 | offsetof(struct spar_controlvm_channel_protocol, event_queue) |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 446 | #define VM_CH_ACK_QUEUE_OFFSET \ |
Benjamin Romer | d19642f | 2014-10-23 14:30:34 -0400 | [diff] [blame] | 447 | offsetof(struct spar_controlvm_channel_protocol, event_ack_queue) |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 448 | #define VM_CH_REQ_MSG_OFFSET \ |
Benjamin Romer | d19642f | 2014-10-23 14:30:34 -0400 | [diff] [blame] | 449 | offsetof(struct spar_controlvm_channel_protocol, request_msg) |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 450 | #define VM_CH_RESP_MSG_OFFSET \ |
Benjamin Romer | d19642f | 2014-10-23 14:30:34 -0400 | [diff] [blame] | 451 | offsetof(struct spar_controlvm_channel_protocol, response_msg) |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 452 | #define VM_CH_EVENT_MSG_OFFSET \ |
Benjamin Romer | d19642f | 2014-10-23 14:30:34 -0400 | [diff] [blame] | 453 | offsetof(struct spar_controlvm_channel_protocol, event_msg) |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 454 | #define VM_CH_ACK_MSG_OFFSET \ |
Benjamin Romer | d19642f | 2014-10-23 14:30:34 -0400 | [diff] [blame] | 455 | offsetof(struct spar_controlvm_channel_protocol, event_ack_msg) |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 456 | #define VM_CH_CRASH_MSG_OFFSET \ |
Benjamin Romer | d19642f | 2014-10-23 14:30:34 -0400 | [diff] [blame] | 457 | offsetof(struct spar_controlvm_channel_protocol, saved_crash_msg) |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 458 | |
| 459 | /* The following header will be located at the beginning of PayloadVmOffset for |
Benjamin Romer | 6242089 | 2014-10-23 14:30:35 -0400 | [diff] [blame] | 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. |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 466 | */ |
Benjamin Romer | 6242089 | 2014-10-23 14:30:35 -0400 | [diff] [blame] | 467 | struct spar_controlvm_parameters_header { |
| 468 | u32 total_length; |
| 469 | u32 header_length; |
| 470 | u32 connection_offset; |
| 471 | u32 connection_length; |
| 472 | u32 initiator_offset; |
| 473 | u32 initiator_length; |
| 474 | u32 target_offset; |
| 475 | u32 target_length; |
| 476 | u32 client_offset; |
| 477 | u32 client_length; |
| 478 | u32 name_offset; |
| 479 | u32 name_length; |
| 480 | uuid_le id; |
| 481 | u32 revision; |
| 482 | u32 reserved; /* Natural alignment */ |
| 483 | }; |
Ken Cox | 12e364b | 2014-03-04 07:58:07 -0600 | [diff] [blame] | 484 | |
| 485 | #endif /* __CONTROLVMCHANNEL_H__ */ |