Commit | Line | Data |
---|---|---|
12e364b9 KC |
1 | /* visorchipset.h |
2 | * | |
f6d0c1e6 | 3 | * Copyright (C) 2010 - 2013 UNISYS CORPORATION |
12e364b9 KC |
4 | * All rights reserved. |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or (at | |
9 | * your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | |
14 | * NON INFRINGEMENT. See the GNU General Public License for more | |
15 | * details. | |
16 | */ | |
17 | ||
18 | #ifndef __VISORCHIPSET_H__ | |
19 | #define __VISORCHIPSET_H__ | |
20 | ||
90addb02 BR |
21 | #include <linux/uuid.h> |
22 | ||
12e364b9 KC |
23 | #include "channel.h" |
24 | #include "controlvmchannel.h" | |
12e364b9 KC |
25 | #include "procobjecttree.h" |
26 | #include "vbusdeviceinfo.h" | |
27 | #include "vbushelper.h" | |
28 | ||
46168810 | 29 | struct visorchannel; |
46168810 | 30 | |
37951dab | 31 | struct visorchipset_state { |
b3c55b13 BR |
32 | u32 created:1; |
33 | u32 attached:1; | |
34 | u32 configured:1; | |
35 | u32 running:1; | |
12e364b9 KC |
36 | /* Add new fields above. */ |
37 | /* Remaining bits in this 32-bit word are unused. */ | |
37951dab | 38 | }; |
12e364b9 | 39 | |
6fb23e18 | 40 | enum visorchipset_addresstype { |
12e364b9 KC |
41 | /** address is guest physical, but outside of the physical memory |
42 | * region that is controlled by the running OS (this is the normal | |
43 | * address type for Supervisor channels) | |
44 | */ | |
6fb23e18 | 45 | ADDRTYPE_LOCALPHYSICAL, |
12e364b9 KC |
46 | |
47 | /** address is guest physical, and withIN the confines of the | |
48 | * physical memory controlled by the running OS. | |
49 | */ | |
6fb23e18 BR |
50 | ADDRTYPE_LOCALTEST, |
51 | }; | |
12e364b9 | 52 | |
12e364b9 KC |
53 | /** Attributes for a particular Supervisor channel. |
54 | */ | |
9b1caee7 BR |
55 | struct visorchipset_channel_info { |
56 | enum visorchipset_addresstype addr_type; | |
57 | HOSTADDRESS channel_addr; | |
4eddbf13 | 58 | struct irq_info intr; |
9b1caee7 BR |
59 | u64 n_channel_bytes; |
60 | uuid_le channel_type_uuid; | |
61 | uuid_le channel_inst_uuid; | |
9b1caee7 | 62 | }; |
12e364b9 KC |
63 | |
64 | /** Attributes for a particular Supervisor device. | |
65 | * Any visorchipset client can query these attributes using | |
66 | * visorchipset_get_client_device_info() or | |
67 | * visorchipset_get_server_device_info(). | |
68 | */ | |
246e0cd0 | 69 | struct visorchipset_device_info { |
12e364b9 | 70 | struct list_head entry; |
246e0cd0 BR |
71 | u32 bus_no; |
72 | u32 dev_no; | |
73 | uuid_le dev_inst_uuid; | |
37951dab | 74 | struct visorchipset_state state; |
246e0cd0 BR |
75 | struct visorchipset_channel_info chan_info; |
76 | u32 reserved1; /* control_vm_id */ | |
77 | u64 reserved2; | |
78 | u32 switch_no; /* when devState.attached==1 */ | |
79 | u32 internal_port_no; /* when devState.attached==1 */ | |
80 | struct controlvm_message_header pending_msg_hdr;/* CONTROLVM_MESSAGE */ | |
12e364b9 KC |
81 | /** For private use by the bus driver */ |
82 | void *bus_driver_context; | |
246e0cd0 | 83 | }; |
12e364b9 | 84 | |
12e364b9 KC |
85 | /** Attributes for a particular Supervisor bus. |
86 | * (For a service partition acting as the server for buses/devices, there | |
87 | * is a 1-to-1 relationship between busses and guest partitions.) | |
88 | * Any visorchipset client can query these attributes using | |
89 | * visorchipset_get_client_bus_info() or visorchipset_get_bus_info(). | |
90 | */ | |
33192fa1 | 91 | struct visorchipset_bus_info { |
12e364b9 | 92 | struct list_head entry; |
33192fa1 | 93 | u32 bus_no; |
37951dab | 94 | struct visorchipset_state state; |
33192fa1 BR |
95 | struct visorchipset_channel_info chan_info; |
96 | uuid_le partition_uuid; | |
97 | u64 partition_handle; | |
c242233e BR |
98 | u8 *name; /* UTF8 */ |
99 | u8 *description; /* UTF8 */ | |
33192fa1 BR |
100 | u64 reserved1; |
101 | u32 reserved2; | |
12e364b9 | 102 | struct { |
b3c55b13 | 103 | u32 server:1; |
12e364b9 KC |
104 | /* Add new fields above. */ |
105 | /* Remaining bits in this 32-bit word are unused. */ | |
106 | } flags; | |
33192fa1 | 107 | struct controlvm_message_header pending_msg_hdr;/* CONTROLVM MsgHdr */ |
12e364b9 KC |
108 | /** For private use by the bus driver */ |
109 | void *bus_driver_context; | |
33192fa1 | 110 | }; |
12e364b9 | 111 | |
12e364b9 KC |
112 | /* These functions will be called from within visorchipset when certain |
113 | * events happen. (The implementation of these functions is outside of | |
114 | * visorchipset.) | |
115 | */ | |
fe90d892 | 116 | struct visorchipset_busdev_notifiers { |
52063eca JS |
117 | void (*bus_create)(u32 bus_no); |
118 | void (*bus_destroy)(u32 bus_no); | |
119 | void (*device_create)(u32 bus_no, u32 dev_no); | |
120 | void (*device_destroy)(u32 bus_no, u32 dev_no); | |
121 | void (*device_pause)(u32 bus_no, u32 dev_no); | |
122 | void (*device_resume)(u32 bus_no, u32 dev_no); | |
fe90d892 | 123 | }; |
12e364b9 KC |
124 | |
125 | /* These functions live inside visorchipset, and will be called to indicate | |
126 | * responses to specific events (by code outside of visorchipset). | |
127 | * For now, the value for each response is simply either: | |
128 | * 0 = it worked | |
129 | * -1 = it failed | |
130 | */ | |
929aa8ae | 131 | struct visorchipset_busdev_responders { |
52063eca JS |
132 | void (*bus_create)(u32 bus_no, int response); |
133 | void (*bus_destroy)(u32 bus_no, int response); | |
134 | void (*device_create)(u32 bus_no, u32 dev_no, int response); | |
135 | void (*device_destroy)(u32 bus_no, u32 dev_no, int response); | |
136 | void (*device_pause)(u32 bus_no, u32 dev_no, int response); | |
137 | void (*device_resume)(u32 bus_no, u32 dev_no, int response); | |
929aa8ae | 138 | }; |
12e364b9 | 139 | |
12e364b9 | 140 | /** Register functions (in the bus driver) to get called by visorchipset |
4da3336c DK |
141 | * whenever a bus or device appears for which this guest is to be the |
142 | * client for. visorchipset will fill in <responders>, to indicate | |
143 | * functions the bus driver should call to indicate message responses. | |
12e364b9 KC |
144 | */ |
145 | void | |
4da3336c | 146 | visorchipset_register_busdev( |
fe90d892 | 147 | struct visorchipset_busdev_notifiers *notifiers, |
929aa8ae | 148 | struct visorchipset_busdev_responders *responders, |
1e7a59c1 | 149 | struct ultra_vbus_deviceinfo *driver_info); |
12e364b9 | 150 | |
52063eca | 151 | bool visorchipset_get_bus_info(u32 bus_no, |
77db7127 | 152 | struct visorchipset_bus_info *bus_info); |
52063eca | 153 | bool visorchipset_get_device_info(u32 bus_no, u32 dev_no, |
b486df19 | 154 | struct visorchipset_device_info *dev_info); |
52063eca | 155 | bool visorchipset_set_bus_context(u32 bus_no, void *context); |
c79b28f7 PB |
156 | |
157 | /* visorbus init and exit functions */ | |
55c67dca | 158 | int visorbus_init(void); |
c79b28f7 | 159 | void visorbus_exit(void); |
12e364b9 | 160 | #endif |