Linux-libre 4.7.10-gnu
[librecmc/linux-libre.git] / drivers / staging / unisys / visorbus / vbuschannel.h
1 /* Copyright (C) 2010 - 2015 UNISYS CORPORATION
2  * All rights reserved.
3  *
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.
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 __VBUSCHANNEL_H__
16 #define __VBUSCHANNEL_H__
17
18 /*  The vbus channel is the channel area provided via the BUS_CREATE controlvm
19  *  message for each virtual bus.  This channel area is provided to both server
20  *  and client ends of the bus.  The channel header area is initialized by
21  *  the server, and the remaining information is filled in by the client.
22  *  We currently use this for the client to provide various information about
23  *  the client devices and client drivers for the server end to see.
24  */
25 #include <linux/uuid.h>
26 #include "vbusdeviceinfo.h"
27 #include "channel.h"
28
29 /* {193b331b-c58f-11da-95a9-00e08161165f} */
30 #define SPAR_VBUS_CHANNEL_PROTOCOL_UUID \
31                 UUID_LE(0x193b331b, 0xc58f, 0x11da, \
32                                 0x95, 0xa9, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f)
33 static const uuid_le spar_vbus_channel_protocol_uuid =
34         SPAR_VBUS_CHANNEL_PROTOCOL_UUID;
35
36 #define SPAR_VBUS_CHANNEL_PROTOCOL_SIGNATURE ULTRA_CHANNEL_PROTOCOL_SIGNATURE
37
38 /* Must increment this whenever you insert or delete fields within this channel
39  * struct.  Also increment whenever you change the meaning of fields within this
40  * channel struct so as to break pre-existing software.  Note that you can
41  * usually add fields to the END of the channel struct withOUT needing to
42  * increment this.
43  */
44 #define SPAR_VBUS_CHANNEL_PROTOCOL_VERSIONID 1
45
46 #define SPAR_VBUS_CHANNEL_OK_CLIENT(ch)       \
47         spar_check_channel_client(ch,                           \
48                                    spar_vbus_channel_protocol_uuid,     \
49                                    "vbus",                              \
50                                    sizeof(struct spar_vbus_channel_protocol),\
51                                    SPAR_VBUS_CHANNEL_PROTOCOL_VERSIONID, \
52                                    SPAR_VBUS_CHANNEL_PROTOCOL_SIGNATURE)
53
54 #define SPAR_VBUS_CHANNEL_OK_SERVER(actual_bytes)    \
55         (spar_check_channel_server(spar_vbus_channel_protocol_uuid,     \
56                                    "vbus",                              \
57                                    sizeof(struct spar_vbus_channel_protocol),\
58                                    actual_bytes))
59
60 #pragma pack(push, 1)           /* both GCC and VC now allow this pragma */
61 struct spar_vbus_headerinfo {
62         u32 struct_bytes;       /* size of this struct in bytes */
63         u32 device_info_struct_bytes;   /* sizeof(ULTRA_VBUS_DEVICEINFO) */
64         u32 dev_info_count;     /* num of items in DevInfo member */
65         /* (this is the allocated size) */
66         u32 chp_info_offset;    /* byte offset from beginning of this struct */
67         /* to the ChpInfo struct (below) */
68         u32 bus_info_offset;    /* byte offset from beginning of this struct */
69         /* to the BusInfo struct (below) */
70         u32 dev_info_offset;    /* byte offset from beginning of this struct */
71         /* to the DevInfo array (below) */
72         u8 reserved[104];
73 };
74
75 struct spar_vbus_channel_protocol {
76         struct channel_header channel_header;   /* initialized by server */
77         struct spar_vbus_headerinfo hdr_info;   /* initialized by server */
78         /* the remainder of this channel is filled in by the client */
79         struct ultra_vbus_deviceinfo chp_info;
80         /* describes client chipset device and driver */
81         struct ultra_vbus_deviceinfo bus_info;
82         /* describes client bus device and driver */
83         struct ultra_vbus_deviceinfo dev_info[0];
84         /* describes client device and driver for each device on the bus */
85 };
86
87 #define VBUS_CH_SIZE_EXACT(MAXDEVICES) \
88         (sizeof(ULTRA_VBUS_CHANNEL_PROTOCOL) + ((MAXDEVICES) * \
89                                                 sizeof(ULTRA_VBUS_DEVICEINFO)))
90 #define VBUS_CH_SIZE(MAXDEVICES) COVER(VBUS_CH_SIZE_EXACT(MAXDEVICES), 4096)
91
92 #pragma pack(pop)
93
94 #endif