Home | History | Annotate | Line # | Download | only in io
      1  1.1  cherry /******************************************************************************
      2  1.1  cherry  * displif.h
      3  1.1  cherry  *
      4  1.1  cherry  * Unified display device I/O interface for Xen guest OSes.
      5  1.1  cherry  *
      6  1.1  cherry  * Permission is hereby granted, free of charge, to any person obtaining a copy
      7  1.1  cherry  * of this software and associated documentation files (the "Software"), to
      8  1.1  cherry  * deal in the Software without restriction, including without limitation the
      9  1.1  cherry  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
     10  1.1  cherry  * sell copies of the Software, and to permit persons to whom the Software is
     11  1.1  cherry  * furnished to do so, subject to the following conditions:
     12  1.1  cherry  *
     13  1.1  cherry  * The above copyright notice and this permission notice shall be included in
     14  1.1  cherry  * all copies or substantial portions of the Software.
     15  1.1  cherry  *
     16  1.1  cherry  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     17  1.1  cherry  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     18  1.1  cherry  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     19  1.1  cherry  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     20  1.1  cherry  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     21  1.1  cherry  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
     22  1.1  cherry  * DEALINGS IN THE SOFTWARE.
     23  1.1  cherry  *
     24  1.1  cherry  * Copyright (C) 2016-2017 EPAM Systems Inc.
     25  1.1  cherry  *
     26  1.1  cherry  * Authors: Oleksandr Andrushchenko <oleksandr_andrushchenko (at) epam.com>
     27  1.1  cherry  *          Oleksandr Grytsov <oleksandr_grytsov (at) epam.com>
     28  1.1  cherry  */
     29  1.1  cherry 
     30  1.1  cherry #ifndef __XEN_PUBLIC_IO_DISPLIF_H__
     31  1.1  cherry #define __XEN_PUBLIC_IO_DISPLIF_H__
     32  1.1  cherry 
     33  1.1  cherry #include "ring.h"
     34  1.1  cherry #include "../grant_table.h"
     35  1.1  cherry 
     36  1.1  cherry /*
     37  1.1  cherry  ******************************************************************************
     38  1.1  cherry  *                           Protocol version
     39  1.1  cherry  ******************************************************************************
     40  1.1  cherry  */
     41  1.1  cherry #define XENDISPL_PROTOCOL_VERSION     "1"
     42  1.1  cherry 
     43  1.1  cherry /*
     44  1.1  cherry  ******************************************************************************
     45  1.1  cherry  *                  Main features provided by the protocol
     46  1.1  cherry  ******************************************************************************
     47  1.1  cherry  * This protocol aims to provide a unified protocol which fits more
     48  1.1  cherry  * sophisticated use-cases than a framebuffer device can handle. At the
     49  1.1  cherry  * moment basic functionality is supported with the intention to be extended:
     50  1.1  cherry  *  o multiple dynamically allocated/destroyed framebuffers
     51  1.1  cherry  *  o buffers of arbitrary sizes
     52  1.1  cherry  *  o buffer allocation at either back or front end
     53  1.1  cherry  *  o better configuration options including multiple display support
     54  1.1  cherry  *
     55  1.1  cherry  * Note: existing fbif can be used together with displif running at the
     56  1.1  cherry  * same time, e.g. on Linux one provides framebuffer and another DRM/KMS
     57  1.1  cherry  *
     58  1.1  cherry  * Note: display resolution (XenStore's "resolution" property) defines
     59  1.1  cherry  * visible area of the virtual display. At the same time resolution of
     60  1.1  cherry  * the display and frame buffers may differ: buffers can be smaller, equal
     61  1.1  cherry  * or bigger than the visible area. This is to enable use-cases, where backend
     62  1.1  cherry  * may do some post-processing of the display and frame buffers supplied,
     63  1.1  cherry  * e.g. those buffers can be just a part of the final composition.
     64  1.1  cherry  *
     65  1.1  cherry  ******************************************************************************
     66  1.1  cherry  *                        Direction of improvements
     67  1.1  cherry  ******************************************************************************
     68  1.1  cherry  * Future extensions to the existing protocol may include:
     69  1.1  cherry  *  o display/connector cloning
     70  1.1  cherry  *  o allocation of objects other than display buffers
     71  1.1  cherry  *  o plane/overlay support
     72  1.1  cherry  *  o scaling support
     73  1.1  cherry  *  o rotation support
     74  1.1  cherry  *
     75  1.1  cherry  ******************************************************************************
     76  1.1  cherry  *                  Feature and Parameter Negotiation
     77  1.1  cherry  ******************************************************************************
     78  1.1  cherry  *
     79  1.1  cherry  * Front->back notifications: when enqueuing a new request, sending a
     80  1.1  cherry  * notification can be made conditional on xendispl_req (i.e., the generic
     81  1.1  cherry  * hold-off mechanism provided by the ring macros). Backends must set
     82  1.1  cherry  * xendispl_req appropriately (e.g., using RING_FINAL_CHECK_FOR_REQUESTS()).
     83  1.1  cherry  *
     84  1.1  cherry  * Back->front notifications: when enqueuing a new response, sending a
     85  1.1  cherry  * notification can be made conditional on xendispl_resp (i.e., the generic
     86  1.1  cherry  * hold-off mechanism provided by the ring macros). Frontends must set
     87  1.1  cherry  * xendispl_resp appropriately (e.g., using RING_FINAL_CHECK_FOR_RESPONSES()).
     88  1.1  cherry  *
     89  1.1  cherry  * The two halves of a para-virtual display driver utilize nodes within
     90  1.1  cherry  * XenStore to communicate capabilities and to negotiate operating parameters.
     91  1.1  cherry  * This section enumerates these nodes which reside in the respective front and
     92  1.1  cherry  * backend portions of XenStore, following the XenBus convention.
     93  1.1  cherry  *
     94  1.1  cherry  * All data in XenStore is stored as strings. Nodes specifying numeric
     95  1.1  cherry  * values are encoded in decimal. Integer value ranges listed below are
     96  1.1  cherry  * expressed as fixed sized integer types capable of storing the conversion
     97  1.1  cherry  * of a properly formated node string, without loss of information.
     98  1.1  cherry  *
     99  1.1  cherry  ******************************************************************************
    100  1.1  cherry  *                        Example configuration
    101  1.1  cherry  ******************************************************************************
    102  1.1  cherry  *
    103  1.1  cherry  * Note: depending on the use-case backend can expose more display connectors
    104  1.1  cherry  * than the underlying HW physically has by employing SW graphics compositors
    105  1.1  cherry  *
    106  1.1  cherry  * This is an example of backend and frontend configuration:
    107  1.1  cherry  *
    108  1.1  cherry  *--------------------------------- Backend -----------------------------------
    109  1.1  cherry  *
    110  1.1  cherry  * /local/domain/0/backend/vdispl/1/0/frontend-id = "1"
    111  1.1  cherry  * /local/domain/0/backend/vdispl/1/0/frontend = "/local/domain/1/device/vdispl/0"
    112  1.1  cherry  * /local/domain/0/backend/vdispl/1/0/state = "4"
    113  1.1  cherry  * /local/domain/0/backend/vdispl/1/0/versions = "1,2"
    114  1.1  cherry  *
    115  1.1  cherry  *--------------------------------- Frontend ----------------------------------
    116  1.1  cherry  *
    117  1.1  cherry  * /local/domain/1/device/vdispl/0/backend-id = "0"
    118  1.1  cherry  * /local/domain/1/device/vdispl/0/backend = "/local/domain/0/backend/vdispl/1/0"
    119  1.1  cherry  * /local/domain/1/device/vdispl/0/state = "4"
    120  1.1  cherry  * /local/domain/1/device/vdispl/0/version = "1"
    121  1.1  cherry  * /local/domain/1/device/vdispl/0/be-alloc = "1"
    122  1.1  cherry  *
    123  1.1  cherry  *-------------------------- Connector 0 configuration ------------------------
    124  1.1  cherry  *
    125  1.1  cherry  * /local/domain/1/device/vdispl/0/0/resolution = "1920x1080"
    126  1.1  cherry  * /local/domain/1/device/vdispl/0/0/req-ring-ref = "2832"
    127  1.1  cherry  * /local/domain/1/device/vdispl/0/0/req-event-channel = "15"
    128  1.1  cherry  * /local/domain/1/device/vdispl/0/0/evt-ring-ref = "387"
    129  1.1  cherry  * /local/domain/1/device/vdispl/0/0/evt-event-channel = "16"
    130  1.1  cherry  *
    131  1.1  cherry  *-------------------------- Connector 1 configuration ------------------------
    132  1.1  cherry  *
    133  1.1  cherry  * /local/domain/1/device/vdispl/0/1/resolution = "800x600"
    134  1.1  cherry  * /local/domain/1/device/vdispl/0/1/req-ring-ref = "2833"
    135  1.1  cherry  * /local/domain/1/device/vdispl/0/1/req-event-channel = "17"
    136  1.1  cherry  * /local/domain/1/device/vdispl/0/1/evt-ring-ref = "388"
    137  1.1  cherry  * /local/domain/1/device/vdispl/0/1/evt-event-channel = "18"
    138  1.1  cherry  *
    139  1.1  cherry  ******************************************************************************
    140  1.1  cherry  *                            Backend XenBus Nodes
    141  1.1  cherry  ******************************************************************************
    142  1.1  cherry  *
    143  1.1  cherry  *----------------------------- Protocol version ------------------------------
    144  1.1  cherry  *
    145  1.1  cherry  * versions
    146  1.1  cherry  *      Values:         <string>
    147  1.1  cherry  *
    148  1.1  cherry  *      List of XENDISPL_LIST_SEPARATOR separated protocol versions supported
    149  1.1  cherry  *      by the backend. For example "1,2,3".
    150  1.1  cherry  *
    151  1.1  cherry  ******************************************************************************
    152  1.1  cherry  *                            Frontend XenBus Nodes
    153  1.1  cherry  ******************************************************************************
    154  1.1  cherry  *
    155  1.1  cherry  *-------------------------------- Addressing ---------------------------------
    156  1.1  cherry  *
    157  1.1  cherry  * dom-id
    158  1.1  cherry  *      Values:         <uint16_t>
    159  1.1  cherry  *
    160  1.1  cherry  *      Domain identifier.
    161  1.1  cherry  *
    162  1.1  cherry  * dev-id
    163  1.1  cherry  *      Values:         <uint16_t>
    164  1.1  cherry  *
    165  1.1  cherry  *      Device identifier.
    166  1.1  cherry  *
    167  1.1  cherry  * conn-idx
    168  1.1  cherry  *      Values:         <uint8_t>
    169  1.1  cherry  *
    170  1.1  cherry  *      Zero based contigous index of the connector.
    171  1.1  cherry  *      /local/domain/<dom-id>/device/vdispl/<dev-id>/<conn-idx>/...
    172  1.1  cherry  *
    173  1.1  cherry  *----------------------------- Protocol version ------------------------------
    174  1.1  cherry  *
    175  1.1  cherry  * version
    176  1.1  cherry  *      Values:         <string>
    177  1.1  cherry  *
    178  1.1  cherry  *      Protocol version, chosen among the ones supported by the backend.
    179  1.1  cherry  *
    180  1.1  cherry  *------------------------- Backend buffer allocation -------------------------
    181  1.1  cherry  *
    182  1.1  cherry  * be-alloc
    183  1.1  cherry  *      Values:         "0", "1"
    184  1.1  cherry  *
    185  1.1  cherry  *      If value is set to "1", then backend can be a buffer provider/allocator
    186  1.1  cherry  *      for this domain during XENDISPL_OP_DBUF_CREATE operation (see below
    187  1.1  cherry  *      for negotiation).
    188  1.1  cherry  *      If value is not "1" or omitted frontend must allocate buffers itself.
    189  1.1  cherry  *
    190  1.1  cherry  *----------------------------- Connector settings ----------------------------
    191  1.1  cherry  *
    192  1.1  cherry  * unique-id
    193  1.1  cherry  *      Values:         <string>
    194  1.1  cherry  *
    195  1.1  cherry  *      After device instance initialization each connector is assigned a
    196  1.1  cherry  *      unique ID, so it can be identified by the backend by this ID.
    197  1.1  cherry  *      This can be UUID or such.
    198  1.1  cherry  *
    199  1.1  cherry  * resolution
    200  1.1  cherry  *      Values:         <width, uint32_t>x<height, uint32_t>
    201  1.1  cherry  *
    202  1.1  cherry  *      Width and height of the connector in pixels separated by
    203  1.1  cherry  *      XENDISPL_RESOLUTION_SEPARATOR. This defines visible area of the
    204  1.1  cherry  *      display.
    205  1.1  cherry  *
    206  1.1  cherry  *------------------ Connector Request Transport Parameters -------------------
    207  1.1  cherry  *
    208  1.1  cherry  * This communication path is used to deliver requests from frontend to backend
    209  1.1  cherry  * and get the corresponding responses from backend to frontend,
    210  1.1  cherry  * set up per connector.
    211  1.1  cherry  *
    212  1.1  cherry  * req-event-channel
    213  1.1  cherry  *      Values:         <uint32_t>
    214  1.1  cherry  *
    215  1.1  cherry  *      The identifier of the Xen connector's control event channel
    216  1.1  cherry  *      used to signal activity in the ring buffer.
    217  1.1  cherry  *
    218  1.1  cherry  * req-ring-ref
    219  1.1  cherry  *      Values:         <uint32_t>
    220  1.1  cherry  *
    221  1.1  cherry  *      The Xen grant reference granting permission for the backend to map
    222  1.1  cherry  *      a sole page of connector's control ring buffer.
    223  1.1  cherry  *
    224  1.1  cherry  *------------------- Connector Event Transport Parameters --------------------
    225  1.1  cherry  *
    226  1.1  cherry  * This communication path is used to deliver asynchronous events from backend
    227  1.1  cherry  * to frontend, set up per connector.
    228  1.1  cherry  *
    229  1.1  cherry  * evt-event-channel
    230  1.1  cherry  *      Values:         <uint32_t>
    231  1.1  cherry  *
    232  1.1  cherry  *      The identifier of the Xen connector's event channel
    233  1.1  cherry  *      used to signal activity in the ring buffer.
    234  1.1  cherry  *
    235  1.1  cherry  * evt-ring-ref
    236  1.1  cherry  *      Values:         <uint32_t>
    237  1.1  cherry  *
    238  1.1  cherry  *      The Xen grant reference granting permission for the backend to map
    239  1.1  cherry  *      a sole page of connector's event ring buffer.
    240  1.1  cherry  */
    241  1.1  cherry 
    242  1.1  cherry /*
    243  1.1  cherry  ******************************************************************************
    244  1.1  cherry  *                               STATE DIAGRAMS
    245  1.1  cherry  ******************************************************************************
    246  1.1  cherry  *
    247  1.1  cherry  * Tool stack creates front and back state nodes with initial state
    248  1.1  cherry  * XenbusStateInitialising.
    249  1.1  cherry  * Tool stack creates and sets up frontend display configuration
    250  1.1  cherry  * nodes per domain.
    251  1.1  cherry  *
    252  1.1  cherry  *-------------------------------- Normal flow --------------------------------
    253  1.1  cherry  *
    254  1.1  cherry  * Front                                Back
    255  1.1  cherry  * =================================    =====================================
    256  1.1  cherry  * XenbusStateInitialising              XenbusStateInitialising
    257  1.1  cherry  *                                       o Query backend device identification
    258  1.1  cherry  *                                         data.
    259  1.1  cherry  *                                       o Open and validate backend device.
    260  1.1  cherry  *                                                |
    261  1.1  cherry  *                                                |
    262  1.1  cherry  *                                                V
    263  1.1  cherry  *                                      XenbusStateInitWait
    264  1.1  cherry  *
    265  1.1  cherry  * o Query frontend configuration
    266  1.1  cherry  * o Allocate and initialize
    267  1.1  cherry  *   event channels per configured
    268  1.1  cherry  *   connector.
    269  1.1  cherry  * o Publish transport parameters
    270  1.1  cherry  *   that will be in effect during
    271  1.1  cherry  *   this connection.
    272  1.1  cherry  *              |
    273  1.1  cherry  *              |
    274  1.1  cherry  *              V
    275  1.1  cherry  * XenbusStateInitialised
    276  1.1  cherry  *
    277  1.1  cherry  *                                       o Query frontend transport parameters.
    278  1.1  cherry  *                                       o Connect to the event channels.
    279  1.1  cherry  *                                                |
    280  1.1  cherry  *                                                |
    281  1.1  cherry  *                                                V
    282  1.1  cherry  *                                      XenbusStateConnected
    283  1.1  cherry  *
    284  1.1  cherry  *  o Create and initialize OS
    285  1.1  cherry  *    virtual display connectors
    286  1.1  cherry  *    as per configuration.
    287  1.1  cherry  *              |
    288  1.1  cherry  *              |
    289  1.1  cherry  *              V
    290  1.1  cherry  * XenbusStateConnected
    291  1.1  cherry  *
    292  1.1  cherry  *                                      XenbusStateUnknown
    293  1.1  cherry  *                                      XenbusStateClosed
    294  1.1  cherry  *                                      XenbusStateClosing
    295  1.1  cherry  * o Remove virtual display device
    296  1.1  cherry  * o Remove event channels
    297  1.1  cherry  *              |
    298  1.1  cherry  *              |
    299  1.1  cherry  *              V
    300  1.1  cherry  * XenbusStateClosed
    301  1.1  cherry  *
    302  1.1  cherry  *------------------------------- Recovery flow -------------------------------
    303  1.1  cherry  *
    304  1.1  cherry  * In case of frontend unrecoverable errors backend handles that as
    305  1.1  cherry  * if frontend goes into the XenbusStateClosed state.
    306  1.1  cherry  *
    307  1.1  cherry  * In case of backend unrecoverable errors frontend tries removing
    308  1.1  cherry  * the virtualized device. If this is possible at the moment of error,
    309  1.1  cherry  * then frontend goes into the XenbusStateInitialising state and is ready for
    310  1.1  cherry  * new connection with backend. If the virtualized device is still in use and
    311  1.1  cherry  * cannot be removed, then frontend goes into the XenbusStateReconfiguring state
    312  1.1  cherry  * until either the virtualized device is removed or backend initiates a new
    313  1.1  cherry  * connection. On the virtualized device removal frontend goes into the
    314  1.1  cherry  * XenbusStateInitialising state.
    315  1.1  cherry  *
    316  1.1  cherry  * Note on XenbusStateReconfiguring state of the frontend: if backend has
    317  1.1  cherry  * unrecoverable errors then frontend cannot send requests to the backend
    318  1.1  cherry  * and thus cannot provide functionality of the virtualized device anymore.
    319  1.1  cherry  * After backend is back to normal the virtualized device may still hold some
    320  1.1  cherry  * state: configuration in use, allocated buffers, client application state etc.
    321  1.1  cherry  * In most cases, this will require frontend to implement complex recovery
    322  1.1  cherry  * reconnect logic. Instead, by going into XenbusStateReconfiguring state,
    323  1.1  cherry  * frontend will make sure no new clients of the virtualized device are
    324  1.1  cherry  * accepted, allow existing client(s) to exit gracefully by signaling error
    325  1.1  cherry  * state etc.
    326  1.1  cherry  * Once all the clients are gone frontend can reinitialize the virtualized
    327  1.1  cherry  * device and get into XenbusStateInitialising state again signaling the
    328  1.1  cherry  * backend that a new connection can be made.
    329  1.1  cherry  *
    330  1.1  cherry  * There are multiple conditions possible under which frontend will go from
    331  1.1  cherry  * XenbusStateReconfiguring into XenbusStateInitialising, some of them are OS
    332  1.1  cherry  * specific. For example:
    333  1.1  cherry  * 1. The underlying OS framework may provide callbacks to signal that the last
    334  1.1  cherry  *    client of the virtualized device has gone and the device can be removed
    335  1.1  cherry  * 2. Frontend can schedule a deferred work (timer/tasklet/workqueue)
    336  1.1  cherry  *    to periodically check if this is the right time to re-try removal of
    337  1.1  cherry  *    the virtualized device.
    338  1.1  cherry  * 3. By any other means.
    339  1.1  cherry  *
    340  1.1  cherry  ******************************************************************************
    341  1.1  cherry  *                             REQUEST CODES
    342  1.1  cherry  ******************************************************************************
    343  1.1  cherry  * Request codes [0; 15] are reserved and must not be used
    344  1.1  cherry  */
    345  1.1  cherry 
    346  1.1  cherry #define XENDISPL_OP_DBUF_CREATE       0x10
    347  1.1  cherry #define XENDISPL_OP_DBUF_DESTROY      0x11
    348  1.1  cherry #define XENDISPL_OP_FB_ATTACH         0x12
    349  1.1  cherry #define XENDISPL_OP_FB_DETACH         0x13
    350  1.1  cherry #define XENDISPL_OP_SET_CONFIG        0x14
    351  1.1  cherry #define XENDISPL_OP_PG_FLIP           0x15
    352  1.1  cherry 
    353  1.1  cherry /*
    354  1.1  cherry  ******************************************************************************
    355  1.1  cherry  *                                 EVENT CODES
    356  1.1  cherry  ******************************************************************************
    357  1.1  cherry  */
    358  1.1  cherry #define XENDISPL_EVT_PG_FLIP          0x00
    359  1.1  cherry 
    360  1.1  cherry /*
    361  1.1  cherry  ******************************************************************************
    362  1.1  cherry  *               XENSTORE FIELD AND PATH NAME STRINGS, HELPERS
    363  1.1  cherry  ******************************************************************************
    364  1.1  cherry  */
    365  1.1  cherry #define XENDISPL_DRIVER_NAME          "vdispl"
    366  1.1  cherry 
    367  1.1  cherry #define XENDISPL_LIST_SEPARATOR       ","
    368  1.1  cherry #define XENDISPL_RESOLUTION_SEPARATOR "x"
    369  1.1  cherry 
    370  1.1  cherry #define XENDISPL_FIELD_BE_VERSIONS    "versions"
    371  1.1  cherry #define XENDISPL_FIELD_FE_VERSION     "version"
    372  1.1  cherry #define XENDISPL_FIELD_REQ_RING_REF   "req-ring-ref"
    373  1.1  cherry #define XENDISPL_FIELD_REQ_CHANNEL    "req-event-channel"
    374  1.1  cherry #define XENDISPL_FIELD_EVT_RING_REF   "evt-ring-ref"
    375  1.1  cherry #define XENDISPL_FIELD_EVT_CHANNEL    "evt-event-channel"
    376  1.1  cherry #define XENDISPL_FIELD_RESOLUTION     "resolution"
    377  1.1  cherry #define XENDISPL_FIELD_BE_ALLOC       "be-alloc"
    378  1.1  cherry #define XENDISPL_FIELD_UNIQUE_ID      "unique-id"
    379  1.1  cherry 
    380  1.1  cherry /*
    381  1.1  cherry  ******************************************************************************
    382  1.1  cherry  *                          STATUS RETURN CODES
    383  1.1  cherry  ******************************************************************************
    384  1.1  cherry  *
    385  1.1  cherry  * Status return code is zero on success and -XEN_EXX on failure.
    386  1.1  cherry  *
    387  1.1  cherry  ******************************************************************************
    388  1.1  cherry  *                              Assumptions
    389  1.1  cherry  ******************************************************************************
    390  1.1  cherry  * o usage of grant reference 0 as invalid grant reference:
    391  1.1  cherry  *   grant reference 0 is valid, but never exposed to a PV driver,
    392  1.1  cherry  *   because of the fact it is already in use/reserved by the PV console.
    393  1.1  cherry  * o all references in this document to page sizes must be treated
    394  1.1  cherry  *   as pages of size XEN_PAGE_SIZE unless otherwise noted.
    395  1.1  cherry  *
    396  1.1  cherry  ******************************************************************************
    397  1.1  cherry  *       Description of the protocol between frontend and backend driver
    398  1.1  cherry  ******************************************************************************
    399  1.1  cherry  *
    400  1.1  cherry  * The two halves of a Para-virtual display driver communicate with
    401  1.1  cherry  * each other using shared pages and event channels.
    402  1.1  cherry  * Shared page contains a ring with request/response packets.
    403  1.1  cherry  *
    404  1.1  cherry  * All reserved fields in the structures below must be 0.
    405  1.1  cherry  * Display buffers's cookie of value 0 is treated as invalid.
    406  1.1  cherry  * Framebuffer's cookie of value 0 is treated as invalid.
    407  1.1  cherry  *
    408  1.1  cherry  * For all request/response/event packets that use cookies:
    409  1.1  cherry  *   dbuf_cookie - uint64_t, unique to guest domain value used by the backend
    410  1.1  cherry  *     to map remote display buffer to its local one
    411  1.1  cherry  *   fb_cookie - uint64_t, unique to guest domain value used by the backend
    412  1.1  cherry  *     to map remote framebuffer to its local one
    413  1.1  cherry  *
    414  1.1  cherry  *---------------------------------- Requests ---------------------------------
    415  1.1  cherry  *
    416  1.1  cherry  * All requests/responses, which are not connector specific, must be sent over
    417  1.1  cherry  * control ring of the connector which has the index value of 0:
    418  1.1  cherry  *   /local/domain/<dom-id>/device/vdispl/<dev-id>/0/req-ring-ref
    419  1.1  cherry  *
    420  1.1  cherry  * All request packets have the same length (64 octets)
    421  1.1  cherry  * All request packets have common header:
    422  1.1  cherry  *         0                1                 2               3        octet
    423  1.1  cherry  * +----------------+----------------+----------------+----------------+
    424  1.1  cherry  * |               id                |    operation   |   reserved     | 4
    425  1.1  cherry  * +----------------+----------------+----------------+----------------+
    426  1.1  cherry  * |                             reserved                              | 8
    427  1.1  cherry  * +----------------+----------------+----------------+----------------+
    428  1.1  cherry  *   id - uint16_t, private guest value, echoed in response
    429  1.1  cherry  *   operation - uint8_t, operation code, XENDISPL_OP_???
    430  1.1  cherry  *
    431  1.1  cherry  * Request dbuf creation - request creation of a display buffer.
    432  1.1  cherry  *         0                1                 2               3        octet
    433  1.1  cherry  * +----------------+----------------+----------------+----------------+
    434  1.1  cherry  * |               id                |_OP_DBUF_CREATE |   reserved     | 4
    435  1.1  cherry  * +----------------+----------------+----------------+----------------+
    436  1.1  cherry  * |                             reserved                              | 8
    437  1.1  cherry  * +----------------+----------------+----------------+----------------+
    438  1.1  cherry  * |                       dbuf_cookie low 32-bit                      | 12
    439  1.1  cherry  * +----------------+----------------+----------------+----------------+
    440  1.1  cherry  * |                       dbuf_cookie high 32-bit                     | 16
    441  1.1  cherry  * +----------------+----------------+----------------+----------------+
    442  1.1  cherry  * |                               width                               | 20
    443  1.1  cherry  * +----------------+----------------+----------------+----------------+
    444  1.1  cherry  * |                               height                              | 24
    445  1.1  cherry  * +----------------+----------------+----------------+----------------+
    446  1.1  cherry  * |                                bpp                                | 28
    447  1.1  cherry  * +----------------+----------------+----------------+----------------+
    448  1.1  cherry  * |                             buffer_sz                             | 32
    449  1.1  cherry  * +----------------+----------------+----------------+----------------+
    450  1.1  cherry  * |                               flags                               | 36
    451  1.1  cherry  * +----------------+----------------+----------------+----------------+
    452  1.1  cherry  * |                           gref_directory                          | 40
    453  1.1  cherry  * +----------------+----------------+----------------+----------------+
    454  1.1  cherry  * |                             reserved                              | 44
    455  1.1  cherry  * +----------------+----------------+----------------+----------------+
    456  1.1  cherry  * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
    457  1.1  cherry  * +----------------+----------------+----------------+----------------+
    458  1.1  cherry  * |                             reserved                              | 64
    459  1.1  cherry  * +----------------+----------------+----------------+----------------+
    460  1.1  cherry  *
    461  1.1  cherry  * Must be sent over control ring of the connector which has the index
    462  1.1  cherry  * value of 0:
    463  1.1  cherry  *   /local/domain/<dom-id>/device/vdispl/<dev-id>/0/req-ring-ref
    464  1.1  cherry  * All unused bits in flags field must be set to 0.
    465  1.1  cherry  *
    466  1.1  cherry  * An attempt to create multiple display buffers with the same dbuf_cookie is
    467  1.1  cherry  * an error. dbuf_cookie can be re-used after destroying the corresponding
    468  1.1  cherry  * display buffer.
    469  1.1  cherry  *
    470  1.1  cherry  * Width and height of the display buffers can be smaller, equal or bigger
    471  1.1  cherry  * than the connector's resolution. Depth/pixel format of the individual
    472  1.1  cherry  * buffers can differ as well.
    473  1.1  cherry  *
    474  1.1  cherry  * width - uint32_t, width in pixels
    475  1.1  cherry  * height - uint32_t, height in pixels
    476  1.1  cherry  * bpp - uint32_t, bits per pixel
    477  1.1  cherry  * buffer_sz - uint32_t, buffer size to be allocated, octets
    478  1.1  cherry  * flags - uint32_t, flags of the operation
    479  1.1  cherry  *   o XENDISPL_DBUF_FLG_REQ_ALLOC - if set, then backend is requested
    480  1.1  cherry  *     to allocate the buffer with the parameters provided in this request.
    481  1.1  cherry  *     Page directory is handled as follows:
    482  1.1  cherry  *       Frontend on request:
    483  1.1  cherry  *         o allocates pages for the directory (gref_directory,
    484  1.1  cherry  *           gref_dir_next_page(s)
    485  1.1  cherry  *         o grants permissions for the pages of the directory to the backend
    486  1.1  cherry  *         o sets gref_dir_next_page fields
    487  1.1  cherry  *       Backend on response:
    488  1.1  cherry  *         o grants permissions for the pages of the buffer allocated to
    489  1.1  cherry  *           the frontend
    490  1.1  cherry  *         o fills in page directory with grant references
    491  1.1  cherry  *           (gref[] in struct xendispl_page_directory)
    492  1.1  cherry  * gref_directory - grant_ref_t, a reference to the first shared page
    493  1.1  cherry  *   describing shared buffer references. At least one page exists. If shared
    494  1.1  cherry  *   buffer size (buffer_sz) exceeds what can be addressed by this single page,
    495  1.1  cherry  *   then reference to the next page must be supplied (see gref_dir_next_page
    496  1.1  cherry  *   below)
    497  1.1  cherry  */
    498  1.1  cherry 
    499  1.1  cherry #define XENDISPL_DBUF_FLG_REQ_ALLOC       (1 << 0)
    500  1.1  cherry 
    501  1.1  cherry struct xendispl_dbuf_create_req {
    502  1.1  cherry     uint64_t dbuf_cookie;
    503  1.1  cherry     uint32_t width;
    504  1.1  cherry     uint32_t height;
    505  1.1  cherry     uint32_t bpp;
    506  1.1  cherry     uint32_t buffer_sz;
    507  1.1  cherry     uint32_t flags;
    508  1.1  cherry     grant_ref_t gref_directory;
    509  1.1  cherry };
    510  1.1  cherry 
    511  1.1  cherry /*
    512  1.1  cherry  * Shared page for XENDISPL_OP_DBUF_CREATE buffer descriptor (gref_directory in
    513  1.1  cherry  * the request) employs a list of pages, describing all pages of the shared
    514  1.1  cherry  * data buffer:
    515  1.1  cherry  *         0                1                 2               3        octet
    516  1.1  cherry  * +----------------+----------------+----------------+----------------+
    517  1.1  cherry  * |                        gref_dir_next_page                         | 4
    518  1.1  cherry  * +----------------+----------------+----------------+----------------+
    519  1.1  cherry  * |                              gref[0]                              | 8
    520  1.1  cherry  * +----------------+----------------+----------------+----------------+
    521  1.1  cherry  * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
    522  1.1  cherry  * +----------------+----------------+----------------+----------------+
    523  1.1  cherry  * |                              gref[i]                              | i*4+8
    524  1.1  cherry  * +----------------+----------------+----------------+----------------+
    525  1.1  cherry  * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
    526  1.1  cherry  * +----------------+----------------+----------------+----------------+
    527  1.1  cherry  * |                             gref[N - 1]                           | N*4+8
    528  1.1  cherry  * +----------------+----------------+----------------+----------------+
    529  1.1  cherry  *
    530  1.1  cherry  * gref_dir_next_page - grant_ref_t, reference to the next page describing
    531  1.1  cherry  *   page directory. Must be 0 if there are no more pages in the list.
    532  1.1  cherry  * gref[i] - grant_ref_t, reference to a shared page of the buffer
    533  1.1  cherry  *   allocated at XENDISPL_OP_DBUF_CREATE
    534  1.1  cherry  *
    535  1.1  cherry  * Number of grant_ref_t entries in the whole page directory is not
    536  1.1  cherry  * passed, but instead can be calculated as:
    537  1.1  cherry  *   num_grefs_total = (XENDISPL_OP_DBUF_CREATE.buffer_sz + XEN_PAGE_SIZE - 1) /
    538  1.1  cherry  *       XEN_PAGE_SIZE
    539  1.1  cherry  */
    540  1.1  cherry 
    541  1.1  cherry struct xendispl_page_directory {
    542  1.1  cherry     grant_ref_t gref_dir_next_page;
    543  1.1  cherry     grant_ref_t gref[1]; /* Variable length */
    544  1.1  cherry };
    545  1.1  cherry 
    546  1.1  cherry /*
    547  1.1  cherry  * Request dbuf destruction - destroy a previously allocated display buffer:
    548  1.1  cherry  *         0                1                 2               3        octet
    549  1.1  cherry  * +----------------+----------------+----------------+----------------+
    550  1.1  cherry  * |               id                |_OP_DBUF_DESTROY|   reserved     | 4
    551  1.1  cherry  * +----------------+----------------+----------------+----------------+
    552  1.1  cherry  * |                             reserved                              | 8
    553  1.1  cherry  * +----------------+----------------+----------------+----------------+
    554  1.1  cherry  * |                       dbuf_cookie low 32-bit                      | 12
    555  1.1  cherry  * +----------------+----------------+----------------+----------------+
    556  1.1  cherry  * |                       dbuf_cookie high 32-bit                     | 16
    557  1.1  cherry  * +----------------+----------------+----------------+----------------+
    558  1.1  cherry  * |                             reserved                              | 20
    559  1.1  cherry  * +----------------+----------------+----------------+----------------+
    560  1.1  cherry  * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
    561  1.1  cherry  * +----------------+----------------+----------------+----------------+
    562  1.1  cherry  * |                             reserved                              | 64
    563  1.1  cherry  * +----------------+----------------+----------------+----------------+
    564  1.1  cherry  *
    565  1.1  cherry  * Must be sent over control ring of the connector which has the index
    566  1.1  cherry  * value of 0:
    567  1.1  cherry  *   /local/domain/<dom-id>/device/vdispl/<dev-id>/0/req-ring-ref
    568  1.1  cherry  */
    569  1.1  cherry 
    570  1.1  cherry struct xendispl_dbuf_destroy_req {
    571  1.1  cherry     uint64_t dbuf_cookie;
    572  1.1  cherry };
    573  1.1  cherry 
    574  1.1  cherry /*
    575  1.1  cherry  * Request framebuffer attachment - request attachment of a framebuffer to
    576  1.1  cherry  * previously created display buffer.
    577  1.1  cherry  *         0                1                 2               3        octet
    578  1.1  cherry  * +----------------+----------------+----------------+----------------+
    579  1.1  cherry  * |               id                | _OP_FB_ATTACH  |   reserved     | 4
    580  1.1  cherry  * +----------------+----------------+----------------+----------------+
    581  1.1  cherry  * |                             reserved                              | 8
    582  1.1  cherry  * +----------------+----------------+----------------+----------------+
    583  1.1  cherry  * |                       dbuf_cookie low 32-bit                      | 12
    584  1.1  cherry  * +----------------+----------------+----------------+----------------+
    585  1.1  cherry  * |                       dbuf_cookie high 32-bit                     | 16
    586  1.1  cherry  * +----------------+----------------+----------------+----------------+
    587  1.1  cherry  * |                        fb_cookie low 32-bit                       | 20
    588  1.1  cherry  * +----------------+----------------+----------------+----------------+
    589  1.1  cherry  * |                        fb_cookie high 32-bit                      | 24
    590  1.1  cherry  * +----------------+----------------+----------------+----------------+
    591  1.1  cherry  * |                               width                               | 28
    592  1.1  cherry  * +----------------+----------------+----------------+----------------+
    593  1.1  cherry  * |                               height                              | 32
    594  1.1  cherry  * +----------------+----------------+----------------+----------------+
    595  1.1  cherry  * |                            pixel_format                           | 36
    596  1.1  cherry  * +----------------+----------------+----------------+----------------+
    597  1.1  cherry  * |                             reserved                              | 40
    598  1.1  cherry  * +----------------+----------------+----------------+----------------+
    599  1.1  cherry  * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
    600  1.1  cherry  * +----------------+----------------+----------------+----------------+
    601  1.1  cherry  * |                             reserved                              | 64
    602  1.1  cherry  * +----------------+----------------+----------------+----------------+
    603  1.1  cherry  *
    604  1.1  cherry  * Must be sent over control ring of the connector which has the index
    605  1.1  cherry  * value of 0:
    606  1.1  cherry  *   /local/domain/<dom-id>/device/vdispl/<dev-id>/0/req-ring-ref
    607  1.1  cherry  * Width and height can be smaller, equal or bigger than the connector's
    608  1.1  cherry  * resolution.
    609  1.1  cherry  *
    610  1.1  cherry  * An attempt to create multiple frame buffers with the same fb_cookie is
    611  1.1  cherry  * an error. fb_cookie can be re-used after destroying the corresponding
    612  1.1  cherry  * frame buffer.
    613  1.1  cherry  *
    614  1.1  cherry  * width - uint32_t, width in pixels
    615  1.1  cherry  * height - uint32_t, height in pixels
    616  1.1  cherry  * pixel_format - uint32_t, pixel format of the framebuffer, FOURCC code
    617  1.1  cherry  */
    618  1.1  cherry 
    619  1.1  cherry struct xendispl_fb_attach_req {
    620  1.1  cherry     uint64_t dbuf_cookie;
    621  1.1  cherry     uint64_t fb_cookie;
    622  1.1  cherry     uint32_t width;
    623  1.1  cherry     uint32_t height;
    624  1.1  cherry     uint32_t pixel_format;
    625  1.1  cherry };
    626  1.1  cherry 
    627  1.1  cherry /*
    628  1.1  cherry  * Request framebuffer detach - detach a previously
    629  1.1  cherry  * attached framebuffer from the display buffer in request:
    630  1.1  cherry  *         0                1                 2               3        octet
    631  1.1  cherry  * +----------------+----------------+----------------+----------------+
    632  1.1  cherry  * |               id                |  _OP_FB_DETACH |   reserved     | 4
    633  1.1  cherry  * +----------------+----------------+----------------+----------------+
    634  1.1  cherry  * |                             reserved                              | 8
    635  1.1  cherry  * +----------------+----------------+----------------+----------------+
    636  1.1  cherry  * |                        fb_cookie low 32-bit                       | 12
    637  1.1  cherry  * +----------------+----------------+----------------+----------------+
    638  1.1  cherry  * |                        fb_cookie high 32-bit                      | 16
    639  1.1  cherry  * +----------------+----------------+----------------+----------------+
    640  1.1  cherry  * |                             reserved                              | 20
    641  1.1  cherry  * +----------------+----------------+----------------+----------------+
    642  1.1  cherry  * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
    643  1.1  cherry  * +----------------+----------------+----------------+----------------+
    644  1.1  cherry  * |                             reserved                              | 64
    645  1.1  cherry  * +----------------+----------------+----------------+----------------+
    646  1.1  cherry  *
    647  1.1  cherry  * Must be sent over control ring of the connector which has the index
    648  1.1  cherry  * value of 0:
    649  1.1  cherry  *   /local/domain/<dom-id>/device/vdispl/<dev-id>/0/req-ring-ref
    650  1.1  cherry  */
    651  1.1  cherry 
    652  1.1  cherry struct xendispl_fb_detach_req {
    653  1.1  cherry     uint64_t fb_cookie;
    654  1.1  cherry };
    655  1.1  cherry 
    656  1.1  cherry /*
    657  1.1  cherry  * Request configuration set/reset - request to set or reset
    658  1.1  cherry  * the configuration/mode of the display:
    659  1.1  cherry  *         0                1                 2               3        octet
    660  1.1  cherry  * +----------------+----------------+----------------+----------------+
    661  1.1  cherry  * |               id                | _OP_SET_CONFIG |   reserved     | 4
    662  1.1  cherry  * +----------------+----------------+----------------+----------------+
    663  1.1  cherry  * |                             reserved                              | 8
    664  1.1  cherry  * +----------------+----------------+----------------+----------------+
    665  1.1  cherry  * |                        fb_cookie low 32-bit                       | 12
    666  1.1  cherry  * +----------------+----------------+----------------+----------------+
    667  1.1  cherry  * |                        fb_cookie high 32-bit                      | 16
    668  1.1  cherry  * +----------------+----------------+----------------+----------------+
    669  1.1  cherry  * |                                 x                                 | 20
    670  1.1  cherry  * +----------------+----------------+----------------+----------------+
    671  1.1  cherry  * |                                 y                                 | 24
    672  1.1  cherry  * +----------------+----------------+----------------+----------------+
    673  1.1  cherry  * |                               width                               | 28
    674  1.1  cherry  * +----------------+----------------+----------------+----------------+
    675  1.1  cherry  * |                               height                              | 32
    676  1.1  cherry  * +----------------+----------------+----------------+----------------+
    677  1.1  cherry  * |                                bpp                                | 40
    678  1.1  cherry  * +----------------+----------------+----------------+----------------+
    679  1.1  cherry  * |                             reserved                              | 44
    680  1.1  cherry  * +----------------+----------------+----------------+----------------+
    681  1.1  cherry  * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
    682  1.1  cherry  * +----------------+----------------+----------------+----------------+
    683  1.1  cherry  * |                             reserved                              | 64
    684  1.1  cherry  * +----------------+----------------+----------------+----------------+
    685  1.1  cherry  *
    686  1.1  cherry  * Pass all zeros to reset, otherwise command is treated as
    687  1.1  cherry  * configuration set.
    688  1.1  cherry  * Framebuffer's cookie defines which framebuffer/dbuf must be
    689  1.1  cherry  * displayed while enabling display (applying configuration).
    690  1.1  cherry  * x, y, width and height are bound by the connector's resolution and must not
    691  1.1  cherry  * exceed it.
    692  1.1  cherry  *
    693  1.1  cherry  * x - uint32_t, starting position in pixels by X axis
    694  1.1  cherry  * y - uint32_t, starting position in pixels by Y axis
    695  1.1  cherry  * width - uint32_t, width in pixels
    696  1.1  cherry  * height - uint32_t, height in pixels
    697  1.1  cherry  * bpp - uint32_t, bits per pixel
    698  1.1  cherry  */
    699  1.1  cherry 
    700  1.1  cherry struct xendispl_set_config_req {
    701  1.1  cherry     uint64_t fb_cookie;
    702  1.1  cherry     uint32_t x;
    703  1.1  cherry     uint32_t y;
    704  1.1  cherry     uint32_t width;
    705  1.1  cherry     uint32_t height;
    706  1.1  cherry     uint32_t bpp;
    707  1.1  cherry };
    708  1.1  cherry 
    709  1.1  cherry /*
    710  1.1  cherry  * Request page flip - request to flip a page identified by the framebuffer
    711  1.1  cherry  * cookie:
    712  1.1  cherry  *         0                1                 2               3        octet
    713  1.1  cherry  * +----------------+----------------+----------------+----------------+
    714  1.1  cherry  * |               id                | _OP_PG_FLIP    |   reserved     | 4
    715  1.1  cherry  * +----------------+----------------+----------------+----------------+
    716  1.1  cherry  * |                             reserved                              | 8
    717  1.1  cherry  * +----------------+----------------+----------------+----------------+
    718  1.1  cherry  * |                        fb_cookie low 32-bit                       | 12
    719  1.1  cherry  * +----------------+----------------+----------------+----------------+
    720  1.1  cherry  * |                        fb_cookie high 32-bit                      | 16
    721  1.1  cherry  * +----------------+----------------+----------------+----------------+
    722  1.1  cherry  * |                             reserved                              | 20
    723  1.1  cherry  * +----------------+----------------+----------------+----------------+
    724  1.1  cherry  * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
    725  1.1  cherry  * +----------------+----------------+----------------+----------------+
    726  1.1  cherry  * |                             reserved                              | 64
    727  1.1  cherry  * +----------------+----------------+----------------+----------------+
    728  1.1  cherry  */
    729  1.1  cherry 
    730  1.1  cherry struct xendispl_page_flip_req {
    731  1.1  cherry     uint64_t fb_cookie;
    732  1.1  cherry };
    733  1.1  cherry 
    734  1.1  cherry /*
    735  1.1  cherry  *---------------------------------- Responses --------------------------------
    736  1.1  cherry  *
    737  1.1  cherry  * All response packets have the same length (64 octets)
    738  1.1  cherry  *
    739  1.1  cherry  * All response packets have common header:
    740  1.1  cherry  *         0                1                 2               3        octet
    741  1.1  cherry  * +----------------+----------------+----------------+----------------+
    742  1.1  cherry  * |               id                |            reserved             | 4
    743  1.1  cherry  * +----------------+----------------+----------------+----------------+
    744  1.1  cherry  * |                              status                               | 8
    745  1.1  cherry  * +----------------+----------------+----------------+----------------+
    746  1.1  cherry  * |                             reserved                              | 12
    747  1.1  cherry  * +----------------+----------------+----------------+----------------+
    748  1.1  cherry  * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
    749  1.1  cherry  * +----------------+----------------+----------------+----------------+
    750  1.1  cherry  * |                             reserved                              | 64
    751  1.1  cherry  * +----------------+----------------+----------------+----------------+
    752  1.1  cherry  *
    753  1.1  cherry  * id - uint16_t, private guest value, echoed from request
    754  1.1  cherry  * status - int32_t, response status, zero on success and -XEN_EXX on failure
    755  1.1  cherry  *
    756  1.1  cherry  *----------------------------------- Events ----------------------------------
    757  1.1  cherry  *
    758  1.1  cherry  * Events are sent via a shared page allocated by the front and propagated by
    759  1.1  cherry  *   evt-event-channel/evt-ring-ref XenStore entries
    760  1.1  cherry  * All event packets have the same length (64 octets)
    761  1.1  cherry  * All event packets have common header:
    762  1.1  cherry  *         0                1                 2               3        octet
    763  1.1  cherry  * +----------------+----------------+----------------+----------------+
    764  1.1  cherry  * |               id                |      type      |   reserved     | 4
    765  1.1  cherry  * +----------------+----------------+----------------+----------------+
    766  1.1  cherry  * |                             reserved                              | 8
    767  1.1  cherry  * +----------------+----------------+----------------+----------------+
    768  1.1  cherry  *
    769  1.1  cherry  * id - uint16_t, event id, may be used by front
    770  1.1  cherry  * type - uint8_t, type of the event
    771  1.1  cherry  *
    772  1.1  cherry  *
    773  1.1  cherry  * Page flip complete event - event from back to front on page flip completed:
    774  1.1  cherry  *         0                1                 2               3        octet
    775  1.1  cherry  * +----------------+----------------+----------------+----------------+
    776  1.1  cherry  * |               id                |   _EVT_PG_FLIP |   reserved     | 4
    777  1.1  cherry  * +----------------+----------------+----------------+----------------+
    778  1.1  cherry  * |                             reserved                              | 8
    779  1.1  cherry  * +----------------+----------------+----------------+----------------+
    780  1.1  cherry  * |                        fb_cookie low 32-bit                       | 12
    781  1.1  cherry  * +----------------+----------------+----------------+----------------+
    782  1.1  cherry  * |                        fb_cookie high 32-bit                      | 16
    783  1.1  cherry  * +----------------+----------------+----------------+----------------+
    784  1.1  cherry  * |                             reserved                              | 20
    785  1.1  cherry  * +----------------+----------------+----------------+----------------+
    786  1.1  cherry  * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
    787  1.1  cherry  * +----------------+----------------+----------------+----------------+
    788  1.1  cherry  * |                             reserved                              | 64
    789  1.1  cherry  * +----------------+----------------+----------------+----------------+
    790  1.1  cherry  */
    791  1.1  cherry 
    792  1.1  cherry struct xendispl_pg_flip_evt {
    793  1.1  cherry     uint64_t fb_cookie;
    794  1.1  cherry };
    795  1.1  cherry 
    796  1.1  cherry struct xendispl_req {
    797  1.1  cherry     uint16_t id;
    798  1.1  cherry     uint8_t operation;
    799  1.1  cherry     uint8_t reserved[5];
    800  1.1  cherry     union {
    801  1.1  cherry         struct xendispl_dbuf_create_req dbuf_create;
    802  1.1  cherry         struct xendispl_dbuf_destroy_req dbuf_destroy;
    803  1.1  cherry         struct xendispl_fb_attach_req fb_attach;
    804  1.1  cherry         struct xendispl_fb_detach_req fb_detach;
    805  1.1  cherry         struct xendispl_set_config_req set_config;
    806  1.1  cherry         struct xendispl_page_flip_req pg_flip;
    807  1.1  cherry         uint8_t reserved[56];
    808  1.1  cherry     } op;
    809  1.1  cherry };
    810  1.1  cherry 
    811  1.1  cherry struct xendispl_resp {
    812  1.1  cherry     uint16_t id;
    813  1.1  cherry     uint8_t operation;
    814  1.1  cherry     uint8_t reserved;
    815  1.1  cherry     int32_t status;
    816  1.1  cherry     uint8_t reserved1[56];
    817  1.1  cherry };
    818  1.1  cherry 
    819  1.1  cherry struct xendispl_evt {
    820  1.1  cherry     uint16_t id;
    821  1.1  cherry     uint8_t type;
    822  1.1  cherry     uint8_t reserved[5];
    823  1.1  cherry     union {
    824  1.1  cherry         struct xendispl_pg_flip_evt pg_flip;
    825  1.1  cherry         uint8_t reserved[56];
    826  1.1  cherry     } op;
    827  1.1  cherry };
    828  1.1  cherry 
    829  1.1  cherry DEFINE_RING_TYPES(xen_displif, struct xendispl_req, struct xendispl_resp);
    830  1.1  cherry 
    831  1.1  cherry /*
    832  1.1  cherry  ******************************************************************************
    833  1.1  cherry  *                        Back to front events delivery
    834  1.1  cherry  ******************************************************************************
    835  1.1  cherry  * In order to deliver asynchronous events from back to front a shared page is
    836  1.1  cherry  * allocated by front and its granted reference propagated to back via
    837  1.1  cherry  * XenStore entries (evt-ring-ref/evt-event-channel).
    838  1.1  cherry  * This page has a common header used by both front and back to synchronize
    839  1.1  cherry  * access and control event's ring buffer, while back being a producer of the
    840  1.1  cherry  * events and front being a consumer. The rest of the page after the header
    841  1.1  cherry  * is used for event packets.
    842  1.1  cherry  *
    843  1.1  cherry  * Upon reception of an event(s) front may confirm its reception
    844  1.1  cherry  * for either each event, group of events or none.
    845  1.1  cherry  */
    846  1.1  cherry 
    847  1.1  cherry struct xendispl_event_page {
    848  1.1  cherry     uint32_t in_cons;
    849  1.1  cherry     uint32_t in_prod;
    850  1.1  cherry     uint8_t reserved[56];
    851  1.1  cherry };
    852  1.1  cherry 
    853  1.1  cherry #define XENDISPL_EVENT_PAGE_SIZE 4096
    854  1.1  cherry #define XENDISPL_IN_RING_OFFS (sizeof(struct xendispl_event_page))
    855  1.1  cherry #define XENDISPL_IN_RING_SIZE (XENDISPL_EVENT_PAGE_SIZE - XENDISPL_IN_RING_OFFS)
    856  1.1  cherry #define XENDISPL_IN_RING_LEN (XENDISPL_IN_RING_SIZE / sizeof(struct xendispl_evt))
    857  1.1  cherry #define XENDISPL_IN_RING(page) \
    858  1.1  cherry 	((struct xendispl_evt *)((char *)(page) + XENDISPL_IN_RING_OFFS))
    859  1.1  cherry #define XENDISPL_IN_RING_REF(page, idx) \
    860  1.1  cherry 	(XENDISPL_IN_RING((page))[(idx) % XENDISPL_IN_RING_LEN])
    861  1.1  cherry 
    862  1.1  cherry #endif /* __XEN_PUBLIC_IO_DISPLIF_H__ */
    863  1.1  cherry 
    864  1.1  cherry /*
    865  1.1  cherry  * Local variables:
    866  1.1  cherry  * mode: C
    867  1.1  cherry  * c-file-style: "BSD"
    868  1.1  cherry  * c-basic-offset: 4
    869  1.1  cherry  * tab-width: 4
    870  1.1  cherry  * indent-tabs-mode: nil
    871  1.1  cherry  * End:
    872  1.1  cherry  */
    873