18c2ecf20Sopenharmony_ci/******************************************************************************
28c2ecf20Sopenharmony_ci * displif.h
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Unified display device I/O interface for Xen guest OSes.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy
78c2ecf20Sopenharmony_ci * of this software and associated documentation files (the "Software"), to
88c2ecf20Sopenharmony_ci * deal in the Software without restriction, including without limitation the
98c2ecf20Sopenharmony_ci * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
108c2ecf20Sopenharmony_ci * sell copies of the Software, and to permit persons to whom the Software is
118c2ecf20Sopenharmony_ci * furnished to do so, subject to the following conditions:
128c2ecf20Sopenharmony_ci *
138c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
148c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software.
158c2ecf20Sopenharmony_ci *
168c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
178c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
188c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
198c2ecf20Sopenharmony_ci * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
208c2ecf20Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
218c2ecf20Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
228c2ecf20Sopenharmony_ci * DEALINGS IN THE SOFTWARE.
238c2ecf20Sopenharmony_ci *
248c2ecf20Sopenharmony_ci * Copyright (C) 2016-2017 EPAM Systems Inc.
258c2ecf20Sopenharmony_ci *
268c2ecf20Sopenharmony_ci * Authors: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
278c2ecf20Sopenharmony_ci *          Oleksandr Grytsov <oleksandr_grytsov@epam.com>
288c2ecf20Sopenharmony_ci */
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#ifndef __XEN_PUBLIC_IO_DISPLIF_H__
318c2ecf20Sopenharmony_ci#define __XEN_PUBLIC_IO_DISPLIF_H__
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#include "ring.h"
348c2ecf20Sopenharmony_ci#include "../grant_table.h"
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci/*
378c2ecf20Sopenharmony_ci ******************************************************************************
388c2ecf20Sopenharmony_ci *                           Protocol version
398c2ecf20Sopenharmony_ci ******************************************************************************
408c2ecf20Sopenharmony_ci */
418c2ecf20Sopenharmony_ci#define XENDISPL_PROTOCOL_VERSION	"2"
428c2ecf20Sopenharmony_ci#define XENDISPL_PROTOCOL_VERSION_INT	 2
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci/*
458c2ecf20Sopenharmony_ci ******************************************************************************
468c2ecf20Sopenharmony_ci *                  Main features provided by the protocol
478c2ecf20Sopenharmony_ci ******************************************************************************
488c2ecf20Sopenharmony_ci * This protocol aims to provide a unified protocol which fits more
498c2ecf20Sopenharmony_ci * sophisticated use-cases than a framebuffer device can handle. At the
508c2ecf20Sopenharmony_ci * moment basic functionality is supported with the intention to be extended:
518c2ecf20Sopenharmony_ci *  o multiple dynamically allocated/destroyed framebuffers
528c2ecf20Sopenharmony_ci *  o buffers of arbitrary sizes
538c2ecf20Sopenharmony_ci *  o buffer allocation at either back or front end
548c2ecf20Sopenharmony_ci *  o better configuration options including multiple display support
558c2ecf20Sopenharmony_ci *
568c2ecf20Sopenharmony_ci * Note: existing fbif can be used together with displif running at the
578c2ecf20Sopenharmony_ci * same time, e.g. on Linux one provides framebuffer and another DRM/KMS
588c2ecf20Sopenharmony_ci *
598c2ecf20Sopenharmony_ci * Note: display resolution (XenStore's "resolution" property) defines
608c2ecf20Sopenharmony_ci * visible area of the virtual display. At the same time resolution of
618c2ecf20Sopenharmony_ci * the display and frame buffers may differ: buffers can be smaller, equal
628c2ecf20Sopenharmony_ci * or bigger than the visible area. This is to enable use-cases, where backend
638c2ecf20Sopenharmony_ci * may do some post-processing of the display and frame buffers supplied,
648c2ecf20Sopenharmony_ci * e.g. those buffers can be just a part of the final composition.
658c2ecf20Sopenharmony_ci *
668c2ecf20Sopenharmony_ci ******************************************************************************
678c2ecf20Sopenharmony_ci *                        Direction of improvements
688c2ecf20Sopenharmony_ci ******************************************************************************
698c2ecf20Sopenharmony_ci * Future extensions to the existing protocol may include:
708c2ecf20Sopenharmony_ci *  o display/connector cloning
718c2ecf20Sopenharmony_ci *  o allocation of objects other than display buffers
728c2ecf20Sopenharmony_ci *  o plane/overlay support
738c2ecf20Sopenharmony_ci *  o scaling support
748c2ecf20Sopenharmony_ci *  o rotation support
758c2ecf20Sopenharmony_ci *
768c2ecf20Sopenharmony_ci ******************************************************************************
778c2ecf20Sopenharmony_ci *                  Feature and Parameter Negotiation
788c2ecf20Sopenharmony_ci ******************************************************************************
798c2ecf20Sopenharmony_ci *
808c2ecf20Sopenharmony_ci * Front->back notifications: when enqueuing a new request, sending a
818c2ecf20Sopenharmony_ci * notification can be made conditional on xendispl_req (i.e., the generic
828c2ecf20Sopenharmony_ci * hold-off mechanism provided by the ring macros). Backends must set
838c2ecf20Sopenharmony_ci * xendispl_req appropriately (e.g., using RING_FINAL_CHECK_FOR_REQUESTS()).
848c2ecf20Sopenharmony_ci *
858c2ecf20Sopenharmony_ci * Back->front notifications: when enqueuing a new response, sending a
868c2ecf20Sopenharmony_ci * notification can be made conditional on xendispl_resp (i.e., the generic
878c2ecf20Sopenharmony_ci * hold-off mechanism provided by the ring macros). Frontends must set
888c2ecf20Sopenharmony_ci * xendispl_resp appropriately (e.g., using RING_FINAL_CHECK_FOR_RESPONSES()).
898c2ecf20Sopenharmony_ci *
908c2ecf20Sopenharmony_ci * The two halves of a para-virtual display driver utilize nodes within
918c2ecf20Sopenharmony_ci * XenStore to communicate capabilities and to negotiate operating parameters.
928c2ecf20Sopenharmony_ci * This section enumerates these nodes which reside in the respective front and
938c2ecf20Sopenharmony_ci * backend portions of XenStore, following the XenBus convention.
948c2ecf20Sopenharmony_ci *
958c2ecf20Sopenharmony_ci * All data in XenStore is stored as strings. Nodes specifying numeric
968c2ecf20Sopenharmony_ci * values are encoded in decimal. Integer value ranges listed below are
978c2ecf20Sopenharmony_ci * expressed as fixed sized integer types capable of storing the conversion
988c2ecf20Sopenharmony_ci * of a properly formated node string, without loss of information.
998c2ecf20Sopenharmony_ci *
1008c2ecf20Sopenharmony_ci ******************************************************************************
1018c2ecf20Sopenharmony_ci *                        Example configuration
1028c2ecf20Sopenharmony_ci ******************************************************************************
1038c2ecf20Sopenharmony_ci *
1048c2ecf20Sopenharmony_ci * Note: depending on the use-case backend can expose more display connectors
1058c2ecf20Sopenharmony_ci * than the underlying HW physically has by employing SW graphics compositors
1068c2ecf20Sopenharmony_ci *
1078c2ecf20Sopenharmony_ci * This is an example of backend and frontend configuration:
1088c2ecf20Sopenharmony_ci *
1098c2ecf20Sopenharmony_ci *--------------------------------- Backend -----------------------------------
1108c2ecf20Sopenharmony_ci *
1118c2ecf20Sopenharmony_ci * /local/domain/0/backend/vdispl/1/0/frontend-id = "1"
1128c2ecf20Sopenharmony_ci * /local/domain/0/backend/vdispl/1/0/frontend = "/local/domain/1/device/vdispl/0"
1138c2ecf20Sopenharmony_ci * /local/domain/0/backend/vdispl/1/0/state = "4"
1148c2ecf20Sopenharmony_ci * /local/domain/0/backend/vdispl/1/0/versions = "1,2"
1158c2ecf20Sopenharmony_ci *
1168c2ecf20Sopenharmony_ci *--------------------------------- Frontend ----------------------------------
1178c2ecf20Sopenharmony_ci *
1188c2ecf20Sopenharmony_ci * /local/domain/1/device/vdispl/0/backend-id = "0"
1198c2ecf20Sopenharmony_ci * /local/domain/1/device/vdispl/0/backend = "/local/domain/0/backend/vdispl/1/0"
1208c2ecf20Sopenharmony_ci * /local/domain/1/device/vdispl/0/state = "4"
1218c2ecf20Sopenharmony_ci * /local/domain/1/device/vdispl/0/version = "1"
1228c2ecf20Sopenharmony_ci * /local/domain/1/device/vdispl/0/be-alloc = "1"
1238c2ecf20Sopenharmony_ci *
1248c2ecf20Sopenharmony_ci *-------------------------- Connector 0 configuration ------------------------
1258c2ecf20Sopenharmony_ci *
1268c2ecf20Sopenharmony_ci * /local/domain/1/device/vdispl/0/0/resolution = "1920x1080"
1278c2ecf20Sopenharmony_ci * /local/domain/1/device/vdispl/0/0/req-ring-ref = "2832"
1288c2ecf20Sopenharmony_ci * /local/domain/1/device/vdispl/0/0/req-event-channel = "15"
1298c2ecf20Sopenharmony_ci * /local/domain/1/device/vdispl/0/0/evt-ring-ref = "387"
1308c2ecf20Sopenharmony_ci * /local/domain/1/device/vdispl/0/0/evt-event-channel = "16"
1318c2ecf20Sopenharmony_ci *
1328c2ecf20Sopenharmony_ci *-------------------------- Connector 1 configuration ------------------------
1338c2ecf20Sopenharmony_ci *
1348c2ecf20Sopenharmony_ci * /local/domain/1/device/vdispl/0/1/resolution = "800x600"
1358c2ecf20Sopenharmony_ci * /local/domain/1/device/vdispl/0/1/req-ring-ref = "2833"
1368c2ecf20Sopenharmony_ci * /local/domain/1/device/vdispl/0/1/req-event-channel = "17"
1378c2ecf20Sopenharmony_ci * /local/domain/1/device/vdispl/0/1/evt-ring-ref = "388"
1388c2ecf20Sopenharmony_ci * /local/domain/1/device/vdispl/0/1/evt-event-channel = "18"
1398c2ecf20Sopenharmony_ci *
1408c2ecf20Sopenharmony_ci ******************************************************************************
1418c2ecf20Sopenharmony_ci *                            Backend XenBus Nodes
1428c2ecf20Sopenharmony_ci ******************************************************************************
1438c2ecf20Sopenharmony_ci *
1448c2ecf20Sopenharmony_ci *----------------------------- Protocol version ------------------------------
1458c2ecf20Sopenharmony_ci *
1468c2ecf20Sopenharmony_ci * versions
1478c2ecf20Sopenharmony_ci *      Values:         <string>
1488c2ecf20Sopenharmony_ci *
1498c2ecf20Sopenharmony_ci *      List of XENDISPL_LIST_SEPARATOR separated protocol versions supported
1508c2ecf20Sopenharmony_ci *      by the backend. For example "1,2,3".
1518c2ecf20Sopenharmony_ci *
1528c2ecf20Sopenharmony_ci ******************************************************************************
1538c2ecf20Sopenharmony_ci *                            Frontend XenBus Nodes
1548c2ecf20Sopenharmony_ci ******************************************************************************
1558c2ecf20Sopenharmony_ci *
1568c2ecf20Sopenharmony_ci *-------------------------------- Addressing ---------------------------------
1578c2ecf20Sopenharmony_ci *
1588c2ecf20Sopenharmony_ci * dom-id
1598c2ecf20Sopenharmony_ci *      Values:         <uint16_t>
1608c2ecf20Sopenharmony_ci *
1618c2ecf20Sopenharmony_ci *      Domain identifier.
1628c2ecf20Sopenharmony_ci *
1638c2ecf20Sopenharmony_ci * dev-id
1648c2ecf20Sopenharmony_ci *      Values:         <uint16_t>
1658c2ecf20Sopenharmony_ci *
1668c2ecf20Sopenharmony_ci *      Device identifier.
1678c2ecf20Sopenharmony_ci *
1688c2ecf20Sopenharmony_ci * conn-idx
1698c2ecf20Sopenharmony_ci *      Values:         <uint8_t>
1708c2ecf20Sopenharmony_ci *
1718c2ecf20Sopenharmony_ci *      Zero based contigous index of the connector.
1728c2ecf20Sopenharmony_ci *      /local/domain/<dom-id>/device/vdispl/<dev-id>/<conn-idx>/...
1738c2ecf20Sopenharmony_ci *
1748c2ecf20Sopenharmony_ci *----------------------------- Protocol version ------------------------------
1758c2ecf20Sopenharmony_ci *
1768c2ecf20Sopenharmony_ci * version
1778c2ecf20Sopenharmony_ci *      Values:         <string>
1788c2ecf20Sopenharmony_ci *
1798c2ecf20Sopenharmony_ci *      Protocol version, chosen among the ones supported by the backend.
1808c2ecf20Sopenharmony_ci *
1818c2ecf20Sopenharmony_ci *------------------------- Backend buffer allocation -------------------------
1828c2ecf20Sopenharmony_ci *
1838c2ecf20Sopenharmony_ci * be-alloc
1848c2ecf20Sopenharmony_ci *      Values:         "0", "1"
1858c2ecf20Sopenharmony_ci *
1868c2ecf20Sopenharmony_ci *      If value is set to "1", then backend can be a buffer provider/allocator
1878c2ecf20Sopenharmony_ci *      for this domain during XENDISPL_OP_DBUF_CREATE operation (see below
1888c2ecf20Sopenharmony_ci *      for negotiation).
1898c2ecf20Sopenharmony_ci *      If value is not "1" or omitted frontend must allocate buffers itself.
1908c2ecf20Sopenharmony_ci *
1918c2ecf20Sopenharmony_ci *----------------------------- Connector settings ----------------------------
1928c2ecf20Sopenharmony_ci *
1938c2ecf20Sopenharmony_ci * unique-id
1948c2ecf20Sopenharmony_ci *      Values:         <string>
1958c2ecf20Sopenharmony_ci *
1968c2ecf20Sopenharmony_ci *      After device instance initialization each connector is assigned a
1978c2ecf20Sopenharmony_ci *      unique ID, so it can be identified by the backend by this ID.
1988c2ecf20Sopenharmony_ci *      This can be UUID or such.
1998c2ecf20Sopenharmony_ci *
2008c2ecf20Sopenharmony_ci * resolution
2018c2ecf20Sopenharmony_ci *      Values:         <width, uint32_t>x<height, uint32_t>
2028c2ecf20Sopenharmony_ci *
2038c2ecf20Sopenharmony_ci *      Width and height of the connector in pixels separated by
2048c2ecf20Sopenharmony_ci *      XENDISPL_RESOLUTION_SEPARATOR. This defines visible area of the
2058c2ecf20Sopenharmony_ci *      display.
2068c2ecf20Sopenharmony_ci *      If backend provides extended display identification data (EDID) with
2078c2ecf20Sopenharmony_ci *      XENDISPL_OP_GET_EDID request then EDID values must take precedence
2088c2ecf20Sopenharmony_ci *      over the resolutions defined here.
2098c2ecf20Sopenharmony_ci *
2108c2ecf20Sopenharmony_ci *------------------ Connector Request Transport Parameters -------------------
2118c2ecf20Sopenharmony_ci *
2128c2ecf20Sopenharmony_ci * This communication path is used to deliver requests from frontend to backend
2138c2ecf20Sopenharmony_ci * and get the corresponding responses from backend to frontend,
2148c2ecf20Sopenharmony_ci * set up per connector.
2158c2ecf20Sopenharmony_ci *
2168c2ecf20Sopenharmony_ci * req-event-channel
2178c2ecf20Sopenharmony_ci *      Values:         <uint32_t>
2188c2ecf20Sopenharmony_ci *
2198c2ecf20Sopenharmony_ci *      The identifier of the Xen connector's control event channel
2208c2ecf20Sopenharmony_ci *      used to signal activity in the ring buffer.
2218c2ecf20Sopenharmony_ci *
2228c2ecf20Sopenharmony_ci * req-ring-ref
2238c2ecf20Sopenharmony_ci *      Values:         <uint32_t>
2248c2ecf20Sopenharmony_ci *
2258c2ecf20Sopenharmony_ci *      The Xen grant reference granting permission for the backend to map
2268c2ecf20Sopenharmony_ci *      a sole page of connector's control ring buffer.
2278c2ecf20Sopenharmony_ci *
2288c2ecf20Sopenharmony_ci *------------------- Connector Event Transport Parameters --------------------
2298c2ecf20Sopenharmony_ci *
2308c2ecf20Sopenharmony_ci * This communication path is used to deliver asynchronous events from backend
2318c2ecf20Sopenharmony_ci * to frontend, set up per connector.
2328c2ecf20Sopenharmony_ci *
2338c2ecf20Sopenharmony_ci * evt-event-channel
2348c2ecf20Sopenharmony_ci *      Values:         <uint32_t>
2358c2ecf20Sopenharmony_ci *
2368c2ecf20Sopenharmony_ci *      The identifier of the Xen connector's event channel
2378c2ecf20Sopenharmony_ci *      used to signal activity in the ring buffer.
2388c2ecf20Sopenharmony_ci *
2398c2ecf20Sopenharmony_ci * evt-ring-ref
2408c2ecf20Sopenharmony_ci *      Values:         <uint32_t>
2418c2ecf20Sopenharmony_ci *
2428c2ecf20Sopenharmony_ci *      The Xen grant reference granting permission for the backend to map
2438c2ecf20Sopenharmony_ci *      a sole page of connector's event ring buffer.
2448c2ecf20Sopenharmony_ci */
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_ci/*
2478c2ecf20Sopenharmony_ci ******************************************************************************
2488c2ecf20Sopenharmony_ci *                               STATE DIAGRAMS
2498c2ecf20Sopenharmony_ci ******************************************************************************
2508c2ecf20Sopenharmony_ci *
2518c2ecf20Sopenharmony_ci * Tool stack creates front and back state nodes with initial state
2528c2ecf20Sopenharmony_ci * XenbusStateInitialising.
2538c2ecf20Sopenharmony_ci * Tool stack creates and sets up frontend display configuration
2548c2ecf20Sopenharmony_ci * nodes per domain.
2558c2ecf20Sopenharmony_ci *
2568c2ecf20Sopenharmony_ci *-------------------------------- Normal flow --------------------------------
2578c2ecf20Sopenharmony_ci *
2588c2ecf20Sopenharmony_ci * Front                                Back
2598c2ecf20Sopenharmony_ci * =================================    =====================================
2608c2ecf20Sopenharmony_ci * XenbusStateInitialising              XenbusStateInitialising
2618c2ecf20Sopenharmony_ci *                                       o Query backend device identification
2628c2ecf20Sopenharmony_ci *                                         data.
2638c2ecf20Sopenharmony_ci *                                       o Open and validate backend device.
2648c2ecf20Sopenharmony_ci *                                                |
2658c2ecf20Sopenharmony_ci *                                                |
2668c2ecf20Sopenharmony_ci *                                                V
2678c2ecf20Sopenharmony_ci *                                      XenbusStateInitWait
2688c2ecf20Sopenharmony_ci *
2698c2ecf20Sopenharmony_ci * o Query frontend configuration
2708c2ecf20Sopenharmony_ci * o Allocate and initialize
2718c2ecf20Sopenharmony_ci *   event channels per configured
2728c2ecf20Sopenharmony_ci *   connector.
2738c2ecf20Sopenharmony_ci * o Publish transport parameters
2748c2ecf20Sopenharmony_ci *   that will be in effect during
2758c2ecf20Sopenharmony_ci *   this connection.
2768c2ecf20Sopenharmony_ci *              |
2778c2ecf20Sopenharmony_ci *              |
2788c2ecf20Sopenharmony_ci *              V
2798c2ecf20Sopenharmony_ci * XenbusStateInitialised
2808c2ecf20Sopenharmony_ci *
2818c2ecf20Sopenharmony_ci *                                       o Query frontend transport parameters.
2828c2ecf20Sopenharmony_ci *                                       o Connect to the event channels.
2838c2ecf20Sopenharmony_ci *                                                |
2848c2ecf20Sopenharmony_ci *                                                |
2858c2ecf20Sopenharmony_ci *                                                V
2868c2ecf20Sopenharmony_ci *                                      XenbusStateConnected
2878c2ecf20Sopenharmony_ci *
2888c2ecf20Sopenharmony_ci *  o Create and initialize OS
2898c2ecf20Sopenharmony_ci *    virtual display connectors
2908c2ecf20Sopenharmony_ci *    as per configuration.
2918c2ecf20Sopenharmony_ci *              |
2928c2ecf20Sopenharmony_ci *              |
2938c2ecf20Sopenharmony_ci *              V
2948c2ecf20Sopenharmony_ci * XenbusStateConnected
2958c2ecf20Sopenharmony_ci *
2968c2ecf20Sopenharmony_ci *                                      XenbusStateUnknown
2978c2ecf20Sopenharmony_ci *                                      XenbusStateClosed
2988c2ecf20Sopenharmony_ci *                                      XenbusStateClosing
2998c2ecf20Sopenharmony_ci * o Remove virtual display device
3008c2ecf20Sopenharmony_ci * o Remove event channels
3018c2ecf20Sopenharmony_ci *              |
3028c2ecf20Sopenharmony_ci *              |
3038c2ecf20Sopenharmony_ci *              V
3048c2ecf20Sopenharmony_ci * XenbusStateClosed
3058c2ecf20Sopenharmony_ci *
3068c2ecf20Sopenharmony_ci *------------------------------- Recovery flow -------------------------------
3078c2ecf20Sopenharmony_ci *
3088c2ecf20Sopenharmony_ci * In case of frontend unrecoverable errors backend handles that as
3098c2ecf20Sopenharmony_ci * if frontend goes into the XenbusStateClosed state.
3108c2ecf20Sopenharmony_ci *
3118c2ecf20Sopenharmony_ci * In case of backend unrecoverable errors frontend tries removing
3128c2ecf20Sopenharmony_ci * the virtualized device. If this is possible at the moment of error,
3138c2ecf20Sopenharmony_ci * then frontend goes into the XenbusStateInitialising state and is ready for
3148c2ecf20Sopenharmony_ci * new connection with backend. If the virtualized device is still in use and
3158c2ecf20Sopenharmony_ci * cannot be removed, then frontend goes into the XenbusStateReconfiguring state
3168c2ecf20Sopenharmony_ci * until either the virtualized device is removed or backend initiates a new
3178c2ecf20Sopenharmony_ci * connection. On the virtualized device removal frontend goes into the
3188c2ecf20Sopenharmony_ci * XenbusStateInitialising state.
3198c2ecf20Sopenharmony_ci *
3208c2ecf20Sopenharmony_ci * Note on XenbusStateReconfiguring state of the frontend: if backend has
3218c2ecf20Sopenharmony_ci * unrecoverable errors then frontend cannot send requests to the backend
3228c2ecf20Sopenharmony_ci * and thus cannot provide functionality of the virtualized device anymore.
3238c2ecf20Sopenharmony_ci * After backend is back to normal the virtualized device may still hold some
3248c2ecf20Sopenharmony_ci * state: configuration in use, allocated buffers, client application state etc.
3258c2ecf20Sopenharmony_ci * In most cases, this will require frontend to implement complex recovery
3268c2ecf20Sopenharmony_ci * reconnect logic. Instead, by going into XenbusStateReconfiguring state,
3278c2ecf20Sopenharmony_ci * frontend will make sure no new clients of the virtualized device are
3288c2ecf20Sopenharmony_ci * accepted, allow existing client(s) to exit gracefully by signaling error
3298c2ecf20Sopenharmony_ci * state etc.
3308c2ecf20Sopenharmony_ci * Once all the clients are gone frontend can reinitialize the virtualized
3318c2ecf20Sopenharmony_ci * device and get into XenbusStateInitialising state again signaling the
3328c2ecf20Sopenharmony_ci * backend that a new connection can be made.
3338c2ecf20Sopenharmony_ci *
3348c2ecf20Sopenharmony_ci * There are multiple conditions possible under which frontend will go from
3358c2ecf20Sopenharmony_ci * XenbusStateReconfiguring into XenbusStateInitialising, some of them are OS
3368c2ecf20Sopenharmony_ci * specific. For example:
3378c2ecf20Sopenharmony_ci * 1. The underlying OS framework may provide callbacks to signal that the last
3388c2ecf20Sopenharmony_ci *    client of the virtualized device has gone and the device can be removed
3398c2ecf20Sopenharmony_ci * 2. Frontend can schedule a deferred work (timer/tasklet/workqueue)
3408c2ecf20Sopenharmony_ci *    to periodically check if this is the right time to re-try removal of
3418c2ecf20Sopenharmony_ci *    the virtualized device.
3428c2ecf20Sopenharmony_ci * 3. By any other means.
3438c2ecf20Sopenharmony_ci *
3448c2ecf20Sopenharmony_ci ******************************************************************************
3458c2ecf20Sopenharmony_ci *                             REQUEST CODES
3468c2ecf20Sopenharmony_ci ******************************************************************************
3478c2ecf20Sopenharmony_ci * Request codes [0; 15] are reserved and must not be used
3488c2ecf20Sopenharmony_ci */
3498c2ecf20Sopenharmony_ci
3508c2ecf20Sopenharmony_ci#define XENDISPL_OP_DBUF_CREATE		0x10
3518c2ecf20Sopenharmony_ci#define XENDISPL_OP_DBUF_DESTROY	0x11
3528c2ecf20Sopenharmony_ci#define XENDISPL_OP_FB_ATTACH		0x12
3538c2ecf20Sopenharmony_ci#define XENDISPL_OP_FB_DETACH		0x13
3548c2ecf20Sopenharmony_ci#define XENDISPL_OP_SET_CONFIG		0x14
3558c2ecf20Sopenharmony_ci#define XENDISPL_OP_PG_FLIP		0x15
3568c2ecf20Sopenharmony_ci/* The below command is available in protocol version 2 and above. */
3578c2ecf20Sopenharmony_ci#define XENDISPL_OP_GET_EDID		0x16
3588c2ecf20Sopenharmony_ci
3598c2ecf20Sopenharmony_ci/*
3608c2ecf20Sopenharmony_ci ******************************************************************************
3618c2ecf20Sopenharmony_ci *                                 EVENT CODES
3628c2ecf20Sopenharmony_ci ******************************************************************************
3638c2ecf20Sopenharmony_ci */
3648c2ecf20Sopenharmony_ci#define XENDISPL_EVT_PG_FLIP		0x00
3658c2ecf20Sopenharmony_ci
3668c2ecf20Sopenharmony_ci/*
3678c2ecf20Sopenharmony_ci ******************************************************************************
3688c2ecf20Sopenharmony_ci *               XENSTORE FIELD AND PATH NAME STRINGS, HELPERS
3698c2ecf20Sopenharmony_ci ******************************************************************************
3708c2ecf20Sopenharmony_ci */
3718c2ecf20Sopenharmony_ci#define XENDISPL_DRIVER_NAME		"vdispl"
3728c2ecf20Sopenharmony_ci
3738c2ecf20Sopenharmony_ci#define XENDISPL_LIST_SEPARATOR		","
3748c2ecf20Sopenharmony_ci#define XENDISPL_RESOLUTION_SEPARATOR	"x"
3758c2ecf20Sopenharmony_ci
3768c2ecf20Sopenharmony_ci#define XENDISPL_FIELD_BE_VERSIONS	"versions"
3778c2ecf20Sopenharmony_ci#define XENDISPL_FIELD_FE_VERSION	"version"
3788c2ecf20Sopenharmony_ci#define XENDISPL_FIELD_REQ_RING_REF	"req-ring-ref"
3798c2ecf20Sopenharmony_ci#define XENDISPL_FIELD_REQ_CHANNEL	"req-event-channel"
3808c2ecf20Sopenharmony_ci#define XENDISPL_FIELD_EVT_RING_REF	"evt-ring-ref"
3818c2ecf20Sopenharmony_ci#define XENDISPL_FIELD_EVT_CHANNEL	"evt-event-channel"
3828c2ecf20Sopenharmony_ci#define XENDISPL_FIELD_RESOLUTION	"resolution"
3838c2ecf20Sopenharmony_ci#define XENDISPL_FIELD_BE_ALLOC		"be-alloc"
3848c2ecf20Sopenharmony_ci#define XENDISPL_FIELD_UNIQUE_ID	"unique-id"
3858c2ecf20Sopenharmony_ci
3868c2ecf20Sopenharmony_ci#define XENDISPL_EDID_BLOCK_SIZE	128
3878c2ecf20Sopenharmony_ci#define XENDISPL_EDID_BLOCK_COUNT	256
3888c2ecf20Sopenharmony_ci#define XENDISPL_EDID_MAX_SIZE		(XENDISPL_EDID_BLOCK_SIZE * XENDISPL_EDID_BLOCK_COUNT)
3898c2ecf20Sopenharmony_ci
3908c2ecf20Sopenharmony_ci/*
3918c2ecf20Sopenharmony_ci ******************************************************************************
3928c2ecf20Sopenharmony_ci *                          STATUS RETURN CODES
3938c2ecf20Sopenharmony_ci ******************************************************************************
3948c2ecf20Sopenharmony_ci *
3958c2ecf20Sopenharmony_ci * Status return code is zero on success and -XEN_EXX on failure.
3968c2ecf20Sopenharmony_ci *
3978c2ecf20Sopenharmony_ci ******************************************************************************
3988c2ecf20Sopenharmony_ci *                              Assumptions
3998c2ecf20Sopenharmony_ci ******************************************************************************
4008c2ecf20Sopenharmony_ci * o usage of grant reference 0 as invalid grant reference:
4018c2ecf20Sopenharmony_ci *   grant reference 0 is valid, but never exposed to a PV driver,
4028c2ecf20Sopenharmony_ci *   because of the fact it is already in use/reserved by the PV console.
4038c2ecf20Sopenharmony_ci * o all references in this document to page sizes must be treated
4048c2ecf20Sopenharmony_ci *   as pages of size XEN_PAGE_SIZE unless otherwise noted.
4058c2ecf20Sopenharmony_ci *
4068c2ecf20Sopenharmony_ci ******************************************************************************
4078c2ecf20Sopenharmony_ci *       Description of the protocol between frontend and backend driver
4088c2ecf20Sopenharmony_ci ******************************************************************************
4098c2ecf20Sopenharmony_ci *
4108c2ecf20Sopenharmony_ci * The two halves of a Para-virtual display driver communicate with
4118c2ecf20Sopenharmony_ci * each other using shared pages and event channels.
4128c2ecf20Sopenharmony_ci * Shared page contains a ring with request/response packets.
4138c2ecf20Sopenharmony_ci *
4148c2ecf20Sopenharmony_ci * All reserved fields in the structures below must be 0.
4158c2ecf20Sopenharmony_ci * Display buffers's cookie of value 0 is treated as invalid.
4168c2ecf20Sopenharmony_ci * Framebuffer's cookie of value 0 is treated as invalid.
4178c2ecf20Sopenharmony_ci *
4188c2ecf20Sopenharmony_ci * For all request/response/event packets that use cookies:
4198c2ecf20Sopenharmony_ci *   dbuf_cookie - uint64_t, unique to guest domain value used by the backend
4208c2ecf20Sopenharmony_ci *     to map remote display buffer to its local one
4218c2ecf20Sopenharmony_ci *   fb_cookie - uint64_t, unique to guest domain value used by the backend
4228c2ecf20Sopenharmony_ci *     to map remote framebuffer to its local one
4238c2ecf20Sopenharmony_ci *
4248c2ecf20Sopenharmony_ci *---------------------------------- Requests ---------------------------------
4258c2ecf20Sopenharmony_ci *
4268c2ecf20Sopenharmony_ci * All requests/responses, which are not connector specific, must be sent over
4278c2ecf20Sopenharmony_ci * control ring of the connector which has the index value of 0:
4288c2ecf20Sopenharmony_ci *   /local/domain/<dom-id>/device/vdispl/<dev-id>/0/req-ring-ref
4298c2ecf20Sopenharmony_ci *
4308c2ecf20Sopenharmony_ci * All request packets have the same length (64 octets)
4318c2ecf20Sopenharmony_ci * All request packets have common header:
4328c2ecf20Sopenharmony_ci *         0                1                 2               3        octet
4338c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
4348c2ecf20Sopenharmony_ci * |               id                |    operation   |   reserved     | 4
4358c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
4368c2ecf20Sopenharmony_ci * |                             reserved                              | 8
4378c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
4388c2ecf20Sopenharmony_ci *   id - uint16_t, private guest value, echoed in response
4398c2ecf20Sopenharmony_ci *   operation - uint8_t, operation code, XENDISPL_OP_???
4408c2ecf20Sopenharmony_ci *
4418c2ecf20Sopenharmony_ci * Request dbuf creation - request creation of a display buffer.
4428c2ecf20Sopenharmony_ci *         0                1                 2               3        octet
4438c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
4448c2ecf20Sopenharmony_ci * |               id                |_OP_DBUF_CREATE |   reserved     | 4
4458c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
4468c2ecf20Sopenharmony_ci * |                             reserved                              | 8
4478c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
4488c2ecf20Sopenharmony_ci * |                       dbuf_cookie low 32-bit                      | 12
4498c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
4508c2ecf20Sopenharmony_ci * |                       dbuf_cookie high 32-bit                     | 16
4518c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
4528c2ecf20Sopenharmony_ci * |                               width                               | 20
4538c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
4548c2ecf20Sopenharmony_ci * |                               height                              | 24
4558c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
4568c2ecf20Sopenharmony_ci * |                                bpp                                | 28
4578c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
4588c2ecf20Sopenharmony_ci * |                             buffer_sz                             | 32
4598c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
4608c2ecf20Sopenharmony_ci * |                               flags                               | 36
4618c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
4628c2ecf20Sopenharmony_ci * |                           gref_directory                          | 40
4638c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
4648c2ecf20Sopenharmony_ci * |                             data_ofs                              | 44
4658c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
4668c2ecf20Sopenharmony_ci * |                             reserved                              | 48
4678c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
4688c2ecf20Sopenharmony_ci * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
4698c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
4708c2ecf20Sopenharmony_ci * |                             reserved                              | 64
4718c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
4728c2ecf20Sopenharmony_ci *
4738c2ecf20Sopenharmony_ci * Must be sent over control ring of the connector which has the index
4748c2ecf20Sopenharmony_ci * value of 0:
4758c2ecf20Sopenharmony_ci *   /local/domain/<dom-id>/device/vdispl/<dev-id>/0/req-ring-ref
4768c2ecf20Sopenharmony_ci * All unused bits in flags field must be set to 0.
4778c2ecf20Sopenharmony_ci *
4788c2ecf20Sopenharmony_ci * An attempt to create multiple display buffers with the same dbuf_cookie is
4798c2ecf20Sopenharmony_ci * an error. dbuf_cookie can be re-used after destroying the corresponding
4808c2ecf20Sopenharmony_ci * display buffer.
4818c2ecf20Sopenharmony_ci *
4828c2ecf20Sopenharmony_ci * Width and height of the display buffers can be smaller, equal or bigger
4838c2ecf20Sopenharmony_ci * than the connector's resolution. Depth/pixel format of the individual
4848c2ecf20Sopenharmony_ci * buffers can differ as well.
4858c2ecf20Sopenharmony_ci *
4868c2ecf20Sopenharmony_ci * width - uint32_t, width in pixels
4878c2ecf20Sopenharmony_ci * height - uint32_t, height in pixels
4888c2ecf20Sopenharmony_ci * bpp - uint32_t, bits per pixel
4898c2ecf20Sopenharmony_ci * buffer_sz - uint32_t, buffer size to be allocated, octets
4908c2ecf20Sopenharmony_ci * flags - uint32_t, flags of the operation
4918c2ecf20Sopenharmony_ci *   o XENDISPL_DBUF_FLG_REQ_ALLOC - if set, then backend is requested
4928c2ecf20Sopenharmony_ci *     to allocate the buffer with the parameters provided in this request.
4938c2ecf20Sopenharmony_ci *     Page directory is handled as follows:
4948c2ecf20Sopenharmony_ci *       Frontend on request:
4958c2ecf20Sopenharmony_ci *         o allocates pages for the directory (gref_directory,
4968c2ecf20Sopenharmony_ci *           gref_dir_next_page(s)
4978c2ecf20Sopenharmony_ci *         o grants permissions for the pages of the directory to the backend
4988c2ecf20Sopenharmony_ci *         o sets gref_dir_next_page fields
4998c2ecf20Sopenharmony_ci *       Backend on response:
5008c2ecf20Sopenharmony_ci *         o grants permissions for the pages of the buffer allocated to
5018c2ecf20Sopenharmony_ci *           the frontend
5028c2ecf20Sopenharmony_ci *         o fills in page directory with grant references
5038c2ecf20Sopenharmony_ci *           (gref[] in struct xendispl_page_directory)
5048c2ecf20Sopenharmony_ci * gref_directory - grant_ref_t, a reference to the first shared page
5058c2ecf20Sopenharmony_ci *   describing shared buffer references. At least one page exists. If shared
5068c2ecf20Sopenharmony_ci *   buffer size (buffer_sz) exceeds what can be addressed by this single page,
5078c2ecf20Sopenharmony_ci *   then reference to the next page must be supplied (see gref_dir_next_page
5088c2ecf20Sopenharmony_ci *   below)
5098c2ecf20Sopenharmony_ci * data_ofs - uint32_t, offset of the data in the buffer, octets
5108c2ecf20Sopenharmony_ci */
5118c2ecf20Sopenharmony_ci
5128c2ecf20Sopenharmony_ci#define XENDISPL_DBUF_FLG_REQ_ALLOC	(1 << 0)
5138c2ecf20Sopenharmony_ci
5148c2ecf20Sopenharmony_cistruct xendispl_dbuf_create_req {
5158c2ecf20Sopenharmony_ci	uint64_t dbuf_cookie;
5168c2ecf20Sopenharmony_ci	uint32_t width;
5178c2ecf20Sopenharmony_ci	uint32_t height;
5188c2ecf20Sopenharmony_ci	uint32_t bpp;
5198c2ecf20Sopenharmony_ci	uint32_t buffer_sz;
5208c2ecf20Sopenharmony_ci	uint32_t flags;
5218c2ecf20Sopenharmony_ci	grant_ref_t gref_directory;
5228c2ecf20Sopenharmony_ci	uint32_t data_ofs;
5238c2ecf20Sopenharmony_ci};
5248c2ecf20Sopenharmony_ci
5258c2ecf20Sopenharmony_ci/*
5268c2ecf20Sopenharmony_ci * Shared page for XENDISPL_OP_DBUF_CREATE buffer descriptor (gref_directory in
5278c2ecf20Sopenharmony_ci * the request) employs a list of pages, describing all pages of the shared
5288c2ecf20Sopenharmony_ci * data buffer:
5298c2ecf20Sopenharmony_ci *         0                1                 2               3        octet
5308c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
5318c2ecf20Sopenharmony_ci * |                        gref_dir_next_page                         | 4
5328c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
5338c2ecf20Sopenharmony_ci * |                              gref[0]                              | 8
5348c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
5358c2ecf20Sopenharmony_ci * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
5368c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
5378c2ecf20Sopenharmony_ci * |                              gref[i]                              | i*4+8
5388c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
5398c2ecf20Sopenharmony_ci * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
5408c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
5418c2ecf20Sopenharmony_ci * |                             gref[N - 1]                           | N*4+8
5428c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
5438c2ecf20Sopenharmony_ci *
5448c2ecf20Sopenharmony_ci * gref_dir_next_page - grant_ref_t, reference to the next page describing
5458c2ecf20Sopenharmony_ci *   page directory. Must be 0 if there are no more pages in the list.
5468c2ecf20Sopenharmony_ci * gref[i] - grant_ref_t, reference to a shared page of the buffer
5478c2ecf20Sopenharmony_ci *   allocated at XENDISPL_OP_DBUF_CREATE
5488c2ecf20Sopenharmony_ci *
5498c2ecf20Sopenharmony_ci * Number of grant_ref_t entries in the whole page directory is not
5508c2ecf20Sopenharmony_ci * passed, but instead can be calculated as:
5518c2ecf20Sopenharmony_ci *   num_grefs_total = (XENDISPL_OP_DBUF_CREATE.buffer_sz + XEN_PAGE_SIZE - 1) /
5528c2ecf20Sopenharmony_ci *       XEN_PAGE_SIZE
5538c2ecf20Sopenharmony_ci */
5548c2ecf20Sopenharmony_ci
5558c2ecf20Sopenharmony_cistruct xendispl_page_directory {
5568c2ecf20Sopenharmony_ci	grant_ref_t gref_dir_next_page;
5578c2ecf20Sopenharmony_ci	grant_ref_t gref[1]; /* Variable length */
5588c2ecf20Sopenharmony_ci};
5598c2ecf20Sopenharmony_ci
5608c2ecf20Sopenharmony_ci/*
5618c2ecf20Sopenharmony_ci * Request dbuf destruction - destroy a previously allocated display buffer:
5628c2ecf20Sopenharmony_ci *         0                1                 2               3        octet
5638c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
5648c2ecf20Sopenharmony_ci * |               id                |_OP_DBUF_DESTROY|   reserved     | 4
5658c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
5668c2ecf20Sopenharmony_ci * |                             reserved                              | 8
5678c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
5688c2ecf20Sopenharmony_ci * |                       dbuf_cookie low 32-bit                      | 12
5698c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
5708c2ecf20Sopenharmony_ci * |                       dbuf_cookie high 32-bit                     | 16
5718c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
5728c2ecf20Sopenharmony_ci * |                             reserved                              | 20
5738c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
5748c2ecf20Sopenharmony_ci * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
5758c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
5768c2ecf20Sopenharmony_ci * |                             reserved                              | 64
5778c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
5788c2ecf20Sopenharmony_ci *
5798c2ecf20Sopenharmony_ci * Must be sent over control ring of the connector which has the index
5808c2ecf20Sopenharmony_ci * value of 0:
5818c2ecf20Sopenharmony_ci *   /local/domain/<dom-id>/device/vdispl/<dev-id>/0/req-ring-ref
5828c2ecf20Sopenharmony_ci */
5838c2ecf20Sopenharmony_ci
5848c2ecf20Sopenharmony_cistruct xendispl_dbuf_destroy_req {
5858c2ecf20Sopenharmony_ci	uint64_t dbuf_cookie;
5868c2ecf20Sopenharmony_ci};
5878c2ecf20Sopenharmony_ci
5888c2ecf20Sopenharmony_ci/*
5898c2ecf20Sopenharmony_ci * Request framebuffer attachment - request attachment of a framebuffer to
5908c2ecf20Sopenharmony_ci * previously created display buffer.
5918c2ecf20Sopenharmony_ci *         0                1                 2               3        octet
5928c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
5938c2ecf20Sopenharmony_ci * |               id                | _OP_FB_ATTACH  |   reserved     | 4
5948c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
5958c2ecf20Sopenharmony_ci * |                             reserved                              | 8
5968c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
5978c2ecf20Sopenharmony_ci * |                       dbuf_cookie low 32-bit                      | 12
5988c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
5998c2ecf20Sopenharmony_ci * |                       dbuf_cookie high 32-bit                     | 16
6008c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6018c2ecf20Sopenharmony_ci * |                        fb_cookie low 32-bit                       | 20
6028c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6038c2ecf20Sopenharmony_ci * |                        fb_cookie high 32-bit                      | 24
6048c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6058c2ecf20Sopenharmony_ci * |                               width                               | 28
6068c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6078c2ecf20Sopenharmony_ci * |                               height                              | 32
6088c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6098c2ecf20Sopenharmony_ci * |                            pixel_format                           | 36
6108c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6118c2ecf20Sopenharmony_ci * |                             reserved                              | 40
6128c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6138c2ecf20Sopenharmony_ci * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
6148c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6158c2ecf20Sopenharmony_ci * |                             reserved                              | 64
6168c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6178c2ecf20Sopenharmony_ci *
6188c2ecf20Sopenharmony_ci * Must be sent over control ring of the connector which has the index
6198c2ecf20Sopenharmony_ci * value of 0:
6208c2ecf20Sopenharmony_ci *   /local/domain/<dom-id>/device/vdispl/<dev-id>/0/req-ring-ref
6218c2ecf20Sopenharmony_ci * Width and height can be smaller, equal or bigger than the connector's
6228c2ecf20Sopenharmony_ci * resolution.
6238c2ecf20Sopenharmony_ci *
6248c2ecf20Sopenharmony_ci * An attempt to create multiple frame buffers with the same fb_cookie is
6258c2ecf20Sopenharmony_ci * an error. fb_cookie can be re-used after destroying the corresponding
6268c2ecf20Sopenharmony_ci * frame buffer.
6278c2ecf20Sopenharmony_ci *
6288c2ecf20Sopenharmony_ci * width - uint32_t, width in pixels
6298c2ecf20Sopenharmony_ci * height - uint32_t, height in pixels
6308c2ecf20Sopenharmony_ci * pixel_format - uint32_t, pixel format of the framebuffer, FOURCC code
6318c2ecf20Sopenharmony_ci */
6328c2ecf20Sopenharmony_ci
6338c2ecf20Sopenharmony_cistruct xendispl_fb_attach_req {
6348c2ecf20Sopenharmony_ci	uint64_t dbuf_cookie;
6358c2ecf20Sopenharmony_ci	uint64_t fb_cookie;
6368c2ecf20Sopenharmony_ci	uint32_t width;
6378c2ecf20Sopenharmony_ci	uint32_t height;
6388c2ecf20Sopenharmony_ci	uint32_t pixel_format;
6398c2ecf20Sopenharmony_ci};
6408c2ecf20Sopenharmony_ci
6418c2ecf20Sopenharmony_ci/*
6428c2ecf20Sopenharmony_ci * Request framebuffer detach - detach a previously
6438c2ecf20Sopenharmony_ci * attached framebuffer from the display buffer in request:
6448c2ecf20Sopenharmony_ci *         0                1                 2               3        octet
6458c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6468c2ecf20Sopenharmony_ci * |               id                |  _OP_FB_DETACH |   reserved     | 4
6478c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6488c2ecf20Sopenharmony_ci * |                             reserved                              | 8
6498c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6508c2ecf20Sopenharmony_ci * |                        fb_cookie low 32-bit                       | 12
6518c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6528c2ecf20Sopenharmony_ci * |                        fb_cookie high 32-bit                      | 16
6538c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6548c2ecf20Sopenharmony_ci * |                             reserved                              | 20
6558c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6568c2ecf20Sopenharmony_ci * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
6578c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6588c2ecf20Sopenharmony_ci * |                             reserved                              | 64
6598c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6608c2ecf20Sopenharmony_ci *
6618c2ecf20Sopenharmony_ci * Must be sent over control ring of the connector which has the index
6628c2ecf20Sopenharmony_ci * value of 0:
6638c2ecf20Sopenharmony_ci *   /local/domain/<dom-id>/device/vdispl/<dev-id>/0/req-ring-ref
6648c2ecf20Sopenharmony_ci */
6658c2ecf20Sopenharmony_ci
6668c2ecf20Sopenharmony_cistruct xendispl_fb_detach_req {
6678c2ecf20Sopenharmony_ci	uint64_t fb_cookie;
6688c2ecf20Sopenharmony_ci};
6698c2ecf20Sopenharmony_ci
6708c2ecf20Sopenharmony_ci/*
6718c2ecf20Sopenharmony_ci * Request configuration set/reset - request to set or reset
6728c2ecf20Sopenharmony_ci * the configuration/mode of the display:
6738c2ecf20Sopenharmony_ci *         0                1                 2               3        octet
6748c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6758c2ecf20Sopenharmony_ci * |               id                | _OP_SET_CONFIG |   reserved     | 4
6768c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6778c2ecf20Sopenharmony_ci * |                             reserved                              | 8
6788c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6798c2ecf20Sopenharmony_ci * |                        fb_cookie low 32-bit                       | 12
6808c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6818c2ecf20Sopenharmony_ci * |                        fb_cookie high 32-bit                      | 16
6828c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6838c2ecf20Sopenharmony_ci * |                                 x                                 | 20
6848c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6858c2ecf20Sopenharmony_ci * |                                 y                                 | 24
6868c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6878c2ecf20Sopenharmony_ci * |                               width                               | 28
6888c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6898c2ecf20Sopenharmony_ci * |                               height                              | 32
6908c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6918c2ecf20Sopenharmony_ci * |                                bpp                                | 40
6928c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6938c2ecf20Sopenharmony_ci * |                             reserved                              | 44
6948c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6958c2ecf20Sopenharmony_ci * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
6968c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6978c2ecf20Sopenharmony_ci * |                             reserved                              | 64
6988c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
6998c2ecf20Sopenharmony_ci *
7008c2ecf20Sopenharmony_ci * Pass all zeros to reset, otherwise command is treated as
7018c2ecf20Sopenharmony_ci * configuration set.
7028c2ecf20Sopenharmony_ci * Framebuffer's cookie defines which framebuffer/dbuf must be
7038c2ecf20Sopenharmony_ci * displayed while enabling display (applying configuration).
7048c2ecf20Sopenharmony_ci * x, y, width and height are bound by the connector's resolution and must not
7058c2ecf20Sopenharmony_ci * exceed it.
7068c2ecf20Sopenharmony_ci *
7078c2ecf20Sopenharmony_ci * x - uint32_t, starting position in pixels by X axis
7088c2ecf20Sopenharmony_ci * y - uint32_t, starting position in pixels by Y axis
7098c2ecf20Sopenharmony_ci * width - uint32_t, width in pixels
7108c2ecf20Sopenharmony_ci * height - uint32_t, height in pixels
7118c2ecf20Sopenharmony_ci * bpp - uint32_t, bits per pixel
7128c2ecf20Sopenharmony_ci */
7138c2ecf20Sopenharmony_ci
7148c2ecf20Sopenharmony_cistruct xendispl_set_config_req {
7158c2ecf20Sopenharmony_ci	uint64_t fb_cookie;
7168c2ecf20Sopenharmony_ci	uint32_t x;
7178c2ecf20Sopenharmony_ci	uint32_t y;
7188c2ecf20Sopenharmony_ci	uint32_t width;
7198c2ecf20Sopenharmony_ci	uint32_t height;
7208c2ecf20Sopenharmony_ci	uint32_t bpp;
7218c2ecf20Sopenharmony_ci};
7228c2ecf20Sopenharmony_ci
7238c2ecf20Sopenharmony_ci/*
7248c2ecf20Sopenharmony_ci * Request page flip - request to flip a page identified by the framebuffer
7258c2ecf20Sopenharmony_ci * cookie:
7268c2ecf20Sopenharmony_ci *         0                1                 2               3        octet
7278c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
7288c2ecf20Sopenharmony_ci * |               id                | _OP_PG_FLIP    |   reserved     | 4
7298c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
7308c2ecf20Sopenharmony_ci * |                             reserved                              | 8
7318c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
7328c2ecf20Sopenharmony_ci * |                        fb_cookie low 32-bit                       | 12
7338c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
7348c2ecf20Sopenharmony_ci * |                        fb_cookie high 32-bit                      | 16
7358c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
7368c2ecf20Sopenharmony_ci * |                             reserved                              | 20
7378c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
7388c2ecf20Sopenharmony_ci * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
7398c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
7408c2ecf20Sopenharmony_ci * |                             reserved                              | 64
7418c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
7428c2ecf20Sopenharmony_ci */
7438c2ecf20Sopenharmony_ci
7448c2ecf20Sopenharmony_cistruct xendispl_page_flip_req {
7458c2ecf20Sopenharmony_ci	uint64_t fb_cookie;
7468c2ecf20Sopenharmony_ci};
7478c2ecf20Sopenharmony_ci
7488c2ecf20Sopenharmony_ci/*
7498c2ecf20Sopenharmony_ci * Request EDID - request EDID describing current connector:
7508c2ecf20Sopenharmony_ci *         0                1                 2               3        octet
7518c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
7528c2ecf20Sopenharmony_ci * |               id                | _OP_GET_EDID   |   reserved     | 4
7538c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
7548c2ecf20Sopenharmony_ci * |                             buffer_sz                             | 8
7558c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
7568c2ecf20Sopenharmony_ci * |                          gref_directory                           | 12
7578c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
7588c2ecf20Sopenharmony_ci * |                             reserved                              | 16
7598c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
7608c2ecf20Sopenharmony_ci * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
7618c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
7628c2ecf20Sopenharmony_ci * |                             reserved                              | 64
7638c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
7648c2ecf20Sopenharmony_ci *
7658c2ecf20Sopenharmony_ci * Notes:
7668c2ecf20Sopenharmony_ci *   - This command is not available in protocol version 1 and should be
7678c2ecf20Sopenharmony_ci *     ignored.
7688c2ecf20Sopenharmony_ci *   - This request is optional and if not supported then visible area
7698c2ecf20Sopenharmony_ci *     is defined by the relevant XenStore's "resolution" property.
7708c2ecf20Sopenharmony_ci *   - Shared buffer, allocated for EDID storage, must not be less then
7718c2ecf20Sopenharmony_ci *     XENDISPL_EDID_MAX_SIZE octets.
7728c2ecf20Sopenharmony_ci *
7738c2ecf20Sopenharmony_ci * buffer_sz - uint32_t, buffer size to be allocated, octets
7748c2ecf20Sopenharmony_ci * gref_directory - grant_ref_t, a reference to the first shared page
7758c2ecf20Sopenharmony_ci *   describing EDID buffer references. See XENDISPL_OP_DBUF_CREATE for
7768c2ecf20Sopenharmony_ci *   grant page directory structure (struct xendispl_page_directory).
7778c2ecf20Sopenharmony_ci *
7788c2ecf20Sopenharmony_ci * See response format for this request.
7798c2ecf20Sopenharmony_ci */
7808c2ecf20Sopenharmony_ci
7818c2ecf20Sopenharmony_cistruct xendispl_get_edid_req {
7828c2ecf20Sopenharmony_ci	uint32_t buffer_sz;
7838c2ecf20Sopenharmony_ci	grant_ref_t gref_directory;
7848c2ecf20Sopenharmony_ci};
7858c2ecf20Sopenharmony_ci
7868c2ecf20Sopenharmony_ci/*
7878c2ecf20Sopenharmony_ci *---------------------------------- Responses --------------------------------
7888c2ecf20Sopenharmony_ci *
7898c2ecf20Sopenharmony_ci * All response packets have the same length (64 octets)
7908c2ecf20Sopenharmony_ci *
7918c2ecf20Sopenharmony_ci * All response packets have common header:
7928c2ecf20Sopenharmony_ci *         0                1                 2               3        octet
7938c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
7948c2ecf20Sopenharmony_ci * |               id                |            reserved             | 4
7958c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
7968c2ecf20Sopenharmony_ci * |                              status                               | 8
7978c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
7988c2ecf20Sopenharmony_ci * |                             reserved                              | 12
7998c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
8008c2ecf20Sopenharmony_ci * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
8018c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
8028c2ecf20Sopenharmony_ci * |                             reserved                              | 64
8038c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
8048c2ecf20Sopenharmony_ci *
8058c2ecf20Sopenharmony_ci * id - uint16_t, private guest value, echoed from request
8068c2ecf20Sopenharmony_ci * status - int32_t, response status, zero on success and -XEN_EXX on failure
8078c2ecf20Sopenharmony_ci *
8088c2ecf20Sopenharmony_ci *
8098c2ecf20Sopenharmony_ci * Get EDID response - response for XENDISPL_OP_GET_EDID:
8108c2ecf20Sopenharmony_ci *         0                1                 2               3        octet
8118c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
8128c2ecf20Sopenharmony_ci * |               id                |    operation   |    reserved    | 4
8138c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
8148c2ecf20Sopenharmony_ci * |                              status                               | 8
8158c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
8168c2ecf20Sopenharmony_ci * |                             edid_sz                               | 12
8178c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
8188c2ecf20Sopenharmony_ci * |                             reserved                              | 16
8198c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
8208c2ecf20Sopenharmony_ci * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
8218c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
8228c2ecf20Sopenharmony_ci * |                             reserved                              | 64
8238c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
8248c2ecf20Sopenharmony_ci *
8258c2ecf20Sopenharmony_ci * Notes:
8268c2ecf20Sopenharmony_ci *   - This response is not available in protocol version 1 and should be
8278c2ecf20Sopenharmony_ci *     ignored.
8288c2ecf20Sopenharmony_ci *
8298c2ecf20Sopenharmony_ci * edid_sz - uint32_t, size of the EDID, octets
8308c2ecf20Sopenharmony_ci */
8318c2ecf20Sopenharmony_ci
8328c2ecf20Sopenharmony_cistruct xendispl_get_edid_resp {
8338c2ecf20Sopenharmony_ci	uint32_t edid_sz;
8348c2ecf20Sopenharmony_ci};
8358c2ecf20Sopenharmony_ci
8368c2ecf20Sopenharmony_ci/*
8378c2ecf20Sopenharmony_ci *----------------------------------- Events ----------------------------------
8388c2ecf20Sopenharmony_ci *
8398c2ecf20Sopenharmony_ci * Events are sent via a shared page allocated by the front and propagated by
8408c2ecf20Sopenharmony_ci *   evt-event-channel/evt-ring-ref XenStore entries
8418c2ecf20Sopenharmony_ci * All event packets have the same length (64 octets)
8428c2ecf20Sopenharmony_ci * All event packets have common header:
8438c2ecf20Sopenharmony_ci *         0                1                 2               3        octet
8448c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
8458c2ecf20Sopenharmony_ci * |               id                |      type      |   reserved     | 4
8468c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
8478c2ecf20Sopenharmony_ci * |                             reserved                              | 8
8488c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
8498c2ecf20Sopenharmony_ci *
8508c2ecf20Sopenharmony_ci * id - uint16_t, event id, may be used by front
8518c2ecf20Sopenharmony_ci * type - uint8_t, type of the event
8528c2ecf20Sopenharmony_ci *
8538c2ecf20Sopenharmony_ci *
8548c2ecf20Sopenharmony_ci * Page flip complete event - event from back to front on page flip completed:
8558c2ecf20Sopenharmony_ci *         0                1                 2               3        octet
8568c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
8578c2ecf20Sopenharmony_ci * |               id                |   _EVT_PG_FLIP |   reserved     | 4
8588c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
8598c2ecf20Sopenharmony_ci * |                             reserved                              | 8
8608c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
8618c2ecf20Sopenharmony_ci * |                        fb_cookie low 32-bit                       | 12
8628c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
8638c2ecf20Sopenharmony_ci * |                        fb_cookie high 32-bit                      | 16
8648c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
8658c2ecf20Sopenharmony_ci * |                             reserved                              | 20
8668c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
8678c2ecf20Sopenharmony_ci * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
8688c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
8698c2ecf20Sopenharmony_ci * |                             reserved                              | 64
8708c2ecf20Sopenharmony_ci * +----------------+----------------+----------------+----------------+
8718c2ecf20Sopenharmony_ci */
8728c2ecf20Sopenharmony_ci
8738c2ecf20Sopenharmony_cistruct xendispl_pg_flip_evt {
8748c2ecf20Sopenharmony_ci	uint64_t fb_cookie;
8758c2ecf20Sopenharmony_ci};
8768c2ecf20Sopenharmony_ci
8778c2ecf20Sopenharmony_cistruct xendispl_req {
8788c2ecf20Sopenharmony_ci	uint16_t id;
8798c2ecf20Sopenharmony_ci	uint8_t operation;
8808c2ecf20Sopenharmony_ci	uint8_t reserved[5];
8818c2ecf20Sopenharmony_ci	union {
8828c2ecf20Sopenharmony_ci		struct xendispl_dbuf_create_req dbuf_create;
8838c2ecf20Sopenharmony_ci		struct xendispl_dbuf_destroy_req dbuf_destroy;
8848c2ecf20Sopenharmony_ci		struct xendispl_fb_attach_req fb_attach;
8858c2ecf20Sopenharmony_ci		struct xendispl_fb_detach_req fb_detach;
8868c2ecf20Sopenharmony_ci		struct xendispl_set_config_req set_config;
8878c2ecf20Sopenharmony_ci		struct xendispl_page_flip_req pg_flip;
8888c2ecf20Sopenharmony_ci		struct xendispl_get_edid_req get_edid;
8898c2ecf20Sopenharmony_ci		uint8_t reserved[56];
8908c2ecf20Sopenharmony_ci	} op;
8918c2ecf20Sopenharmony_ci};
8928c2ecf20Sopenharmony_ci
8938c2ecf20Sopenharmony_cistruct xendispl_resp {
8948c2ecf20Sopenharmony_ci	uint16_t id;
8958c2ecf20Sopenharmony_ci	uint8_t operation;
8968c2ecf20Sopenharmony_ci	uint8_t reserved;
8978c2ecf20Sopenharmony_ci	int32_t status;
8988c2ecf20Sopenharmony_ci	union {
8998c2ecf20Sopenharmony_ci		struct xendispl_get_edid_resp get_edid;
9008c2ecf20Sopenharmony_ci		uint8_t reserved1[56];
9018c2ecf20Sopenharmony_ci	} op;
9028c2ecf20Sopenharmony_ci};
9038c2ecf20Sopenharmony_ci
9048c2ecf20Sopenharmony_cistruct xendispl_evt {
9058c2ecf20Sopenharmony_ci	uint16_t id;
9068c2ecf20Sopenharmony_ci	uint8_t type;
9078c2ecf20Sopenharmony_ci	uint8_t reserved[5];
9088c2ecf20Sopenharmony_ci	union {
9098c2ecf20Sopenharmony_ci		struct xendispl_pg_flip_evt pg_flip;
9108c2ecf20Sopenharmony_ci		uint8_t reserved[56];
9118c2ecf20Sopenharmony_ci	} op;
9128c2ecf20Sopenharmony_ci};
9138c2ecf20Sopenharmony_ci
9148c2ecf20Sopenharmony_ciDEFINE_RING_TYPES(xen_displif, struct xendispl_req, struct xendispl_resp);
9158c2ecf20Sopenharmony_ci
9168c2ecf20Sopenharmony_ci/*
9178c2ecf20Sopenharmony_ci ******************************************************************************
9188c2ecf20Sopenharmony_ci *                        Back to front events delivery
9198c2ecf20Sopenharmony_ci ******************************************************************************
9208c2ecf20Sopenharmony_ci * In order to deliver asynchronous events from back to front a shared page is
9218c2ecf20Sopenharmony_ci * allocated by front and its granted reference propagated to back via
9228c2ecf20Sopenharmony_ci * XenStore entries (evt-ring-ref/evt-event-channel).
9238c2ecf20Sopenharmony_ci * This page has a common header used by both front and back to synchronize
9248c2ecf20Sopenharmony_ci * access and control event's ring buffer, while back being a producer of the
9258c2ecf20Sopenharmony_ci * events and front being a consumer. The rest of the page after the header
9268c2ecf20Sopenharmony_ci * is used for event packets.
9278c2ecf20Sopenharmony_ci *
9288c2ecf20Sopenharmony_ci * Upon reception of an event(s) front may confirm its reception
9298c2ecf20Sopenharmony_ci * for either each event, group of events or none.
9308c2ecf20Sopenharmony_ci */
9318c2ecf20Sopenharmony_ci
9328c2ecf20Sopenharmony_cistruct xendispl_event_page {
9338c2ecf20Sopenharmony_ci	uint32_t in_cons;
9348c2ecf20Sopenharmony_ci	uint32_t in_prod;
9358c2ecf20Sopenharmony_ci	uint8_t reserved[56];
9368c2ecf20Sopenharmony_ci};
9378c2ecf20Sopenharmony_ci
9388c2ecf20Sopenharmony_ci#define XENDISPL_EVENT_PAGE_SIZE XEN_PAGE_SIZE
9398c2ecf20Sopenharmony_ci#define XENDISPL_IN_RING_OFFS (sizeof(struct xendispl_event_page))
9408c2ecf20Sopenharmony_ci#define XENDISPL_IN_RING_SIZE (XENDISPL_EVENT_PAGE_SIZE - XENDISPL_IN_RING_OFFS)
9418c2ecf20Sopenharmony_ci#define XENDISPL_IN_RING_LEN (XENDISPL_IN_RING_SIZE / sizeof(struct xendispl_evt))
9428c2ecf20Sopenharmony_ci#define XENDISPL_IN_RING(page) \
9438c2ecf20Sopenharmony_ci	((struct xendispl_evt *)((char *)(page) + XENDISPL_IN_RING_OFFS))
9448c2ecf20Sopenharmony_ci#define XENDISPL_IN_RING_REF(page, idx) \
9458c2ecf20Sopenharmony_ci	(XENDISPL_IN_RING((page))[(idx) % XENDISPL_IN_RING_LEN])
9468c2ecf20Sopenharmony_ci
9478c2ecf20Sopenharmony_ci#endif /* __XEN_PUBLIC_IO_DISPLIF_H__ */
948