qemu/include/hw/remote-port.h
<<
>>
Prefs
   1/*
   2 * QEMU remote port.
   3 *
   4 * Copyright (c) 2013 Xilinx Inc
   5 * Written by Edgar E. Iglesias <edgar.iglesias@xilinx.com>
   6 *
   7 * This code is licensed under the GNU GPL.
   8 */
   9#ifndef REMOTE_PORT_H__
  10#define REMOTE_PORT_H__
  11
  12#include <stdbool.h>
  13#include "hw/remote-port-proto.h"
  14#include "hw/remote-port-device.h"
  15#include "sysemu/char.h"
  16#include "hw/ptimer.h"
  17
  18#define TYPE_REMOTE_PORT "remote-port"
  19#define REMOTE_PORT(obj) OBJECT_CHECK(RemotePort, (obj), TYPE_REMOTE_PORT)
  20
  21struct RemotePort {
  22    DeviceState parent;
  23
  24    QemuThread thread;
  25    union {
  26       int pipes[2];
  27       struct {
  28           int read;
  29           int write;
  30       } pipe;
  31    } event;
  32    CharBackend chr;
  33    bool do_sync;
  34    /* To serialize writes to fd.  */
  35    QemuMutex write_mutex;
  36
  37    char *chardesc;
  38    char *chrdev_id;
  39    struct rp_peer_state peer;
  40
  41    struct {
  42        QEMUBH *bh;
  43        QEMUBH *bh_resp;
  44        ptimer_state *ptimer;
  45        ptimer_state *ptimer_resp;
  46        bool resp_timer_enabled;
  47        bool need_sync;
  48        struct rp_pkt rsp;
  49        uint64_t quantum;
  50    } sync;
  51
  52    QemuMutex rsp_mutex;
  53    QemuCond progress_cond;
  54
  55    struct {
  56        /* This array must be sized minimum 2 and always a power of 2.  */
  57        RemotePortDynPkt pkt[16];
  58        QemuSemaphore sem;
  59        unsigned int wpos;
  60        unsigned int rpos;
  61    } rx_queue;
  62
  63    /*
  64     * rsp holds responses for the remote side.
  65     * Used by the slave.
  66     */
  67    RemotePortDynPkt rsp;
  68
  69    /*
  70     * rspqueue holds received responses from the remote side.
  71     * Only one for the moment but it might grow.
  72     * Used by the master.
  73     */
  74    RemotePortDynPkt rspqueue;
  75
  76    bool resets[32];
  77
  78    const char *prefix;
  79    const char *remote_prefix;
  80
  81    uint32_t current_id;
  82
  83#define REMOTE_PORT_MAX_DEVS 1024
  84    RemotePortDevice *devs[REMOTE_PORT_MAX_DEVS];
  85};
  86
  87/**
  88 * rp_device_attach:
  89 * @adaptor: The adaptor onto which to attach the device
  90 * @dev: The device to be attached to the adaptor
  91 * @rp_nr: The remote-port adaptor nr. A device may attach to multiple
  92 *         adaptors.
  93 * @dev_nr: The device/channel number to bind the device to.
  94 * @errp: returns an error if this function fails
  95 *
  96 * Attaches a device onto an adaptor and binds it to a device number.
  97 */
  98void rp_device_attach(Object *adaptor, Object *dev,
  99                      int rp_nr, int dev_nr,
 100                      Error **errp);
 101bool rp_time_warp_enable(bool en);
 102
 103/**
 104 * rp_device_add
 105 * @opts:  qdev opts created by the qdev subsystem
 106 * @dev: The device to be connected
 107 * @errp: Returns an error if the function fails
 108 *
 109 * Function used in qdev-monitor.c to connect remote port devices.
 110 */
 111void rp_device_add(QemuOpts *opts, DeviceState *dev, Error **errp);
 112
 113#endif
 114