/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_XENDEV_H
#define _SYS_XENDEV_H
#include <sys/hypervisor.h>
#ifndef __xpv
#include <public/event_channel.h>
#include <public/grant_table.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* Xenbus property interfaces, initialized by framework
*/
/*
* Xenbus property interfaces, initialized by backend disk driver
*/
/*
* Xenbus property interfaces, initialized by frontend disk driver
*/
/*
* Xenbus CDROM property interfaces, used by backend and frontend
*
* XBP_MEDIA_REQ_SUP
* - Backend xenbus property located at:
* - Set by the backend, consumed by the frontend.
* - Cosumed by the frontend.
* - A boolean integer property indicating backend support
* for the XBP_MEDIA_REQ property.
*
* XBP_MEDIA_REQ
* - Frontend xenbus property located at:
* - Set and consumed by both the frontend and backend.
* - Possible values:
* XBV_MEDIA_REQ_NONE, XBV_MEDIA_REQ_LOCK, and XBV_MEDIA_REQ_EJECT
* - Only applies to CDROM devices.
*
* XBV_MEDIA_REQ_NONE
* - XBP_MEDIA_REQ property valud
* - Set and consumed by both the frontend and backend.
* - Indicates that there are no currently outstanding media requet
* operations.
*
* XBV_MEDIA_REQ_LOCK
* - XBP_MEDIA_REQ property valud
* - Set by the frontend, consumed by the backend.
* - Indicates to the backend that the currenct media is locked
* and changes to the media (via xm block-configure for example)
* should not be allowed.
*
* XBV_MEDIA_REQ_EJECT
* - XBP_MEDIA_REQ property valud
* - Set by the frontend, consumed by the backend.
* - Indicates to the backend that the currenct media should be ejected.
* This means that the backend should close it's connection to
* and then set the media-req property to XBV_MEDIA_REQ_NONE. (to
* indicate that the eject operation is complete.)
*/
/*
* Xen device class codes
*/
typedef enum {
XEN_CONSOLE = 0,
/*
* Hotplug request sent to userland event handler.
*/
typedef enum {
/*
* Hotplug status.
*
* In fact, the Xen tools can write any arbitrary string into the
* hotplug-status node. We represent the known values here - anything
* else will be 'Unrecognized'.
*/
typedef enum {
struct xendev_ppd {
int xd_evtchn;
int xd_vdevnum;
};
/*
* A device with xd_vdevnum == VDEV_NOXS does not participate in
* xenstore.
*/
void xvdi_suspend(dev_info_t *);
int xvdi_resume(dev_info_t *);
int xvdi_alloc_evtchn(dev_info_t *);
void xvdi_free_evtchn(dev_info_t *);
int xvdi_add_event_handler(dev_info_t *, char *,
void (*)(dev_info_t *, ddi_eventcookie_t, void *, void *),
void *arg);
void xvdi_remove_event_handler(dev_info_t *, char *);
int xvdi_get_evtchn(dev_info_t *);
int xvdi_get_vdevnum(dev_info_t *);
char *xvdi_get_xsname(dev_info_t *);
char *xvdi_get_oename(dev_info_t *);
void xvdi_dev_error(dev_info_t *, int, char *);
void xvdi_fatal_error(dev_info_t *, int, char *);
void xvdi_notify_oe(dev_info_t *);
domid_t, int);
int xvdi_init_dev(dev_info_t *);
void xvdi_uninit_dev(dev_info_t *);
extern int xvdi_add_xb_watch_handler(dev_info_t *, const char *,
const char *, xvdi_xb_watch_cb_t cb, void *);
extern void xvdi_remove_xb_watch_handlers(dev_info_t *);
/*
* common ring interfaces
*/
/*
* we need the pad between ring index
* so that we can map comif_sring_t structure to
* any xxxif_sring_t structure defined via macros in ring.h
*/
typedef struct comif_sring {
/*
* variable length
* entry size is fixed per ring
*/
typedef struct comif_ring_fe {
/*
* keep the member names as defined in ring.h
* in order to make use of the pre-defined macros
*/
unsigned int nr_ents;
typedef struct comif_ring_be {
/*
* keep the member names as defined in ring.h
* in order to make use of the pre-defined macros
*/
unsigned int nr_ents;
typedef union comif_ring {
} comif_ring_t;
typedef struct xendev_req {
unsigned long next;
void *req;
} xendev_req_t;
typedef struct xendev_ring {
int xr_entry_size;
int xr_frontend;
xendev_ring_t **);
void xvdi_free_ring(xendev_ring_t *);
xendev_ring_t **);
void xvdi_unmap_ring(xendev_ring_t *);
void* xvdi_ring_get_request(xendev_ring_t *);
int xvdi_ring_push_request(xendev_ring_t *);
void* xvdi_ring_get_response(xendev_ring_t *);
int xvdi_ring_push_response(xendev_ring_t *);
#ifdef __cplusplus
}
#endif
#endif /* _SYS_XENDEV_H */