diff options
Diffstat (limited to 'sys/xen/interface')
-rw-r--r-- | sys/xen/interface/grant_table.h | 2 | ||||
-rw-r--r-- | sys/xen/interface/hvm/params.h | 26 | ||||
-rw-r--r-- | sys/xen/interface/io/blkif.h | 31 | ||||
-rw-r--r-- | sys/xen/interface/io/protocols.h | 3 | ||||
-rw-r--r-- | sys/xen/interface/io/ring.h | 18 | ||||
-rw-r--r-- | sys/xen/interface/io/xenbus.h | 9 |
6 files changed, 83 insertions, 6 deletions
diff --git a/sys/xen/interface/grant_table.h b/sys/xen/interface/grant_table.h index 26f2c35..e76ca67 100644 --- a/sys/xen/interface/grant_table.h +++ b/sys/xen/interface/grant_table.h @@ -159,6 +159,8 @@ typedef struct grant_entry grant_entry_t; */ typedef uint32_t grant_ref_t; +#define GRANT_REF_INVALID 0xffffffff + /* * Handle to track a mapping created via a grant reference. */ diff --git a/sys/xen/interface/hvm/params.h b/sys/xen/interface/hvm/params.h index 6befa78..d846731 100644 --- a/sys/xen/interface/hvm/params.h +++ b/sys/xen/interface/hvm/params.h @@ -95,4 +95,30 @@ #define HVM_NR_PARAMS 15 +#ifdef XENHVM +/** + * Retrieve an HVM setting from the hypervisor. + * + * \param index The index of the HVM parameter to retrieve. + * + * \return On error, 0. Otherwise the value of the requested parameter. + */ +static inline unsigned long +hvm_get_parameter(int index) +{ + struct xen_hvm_param xhv; + int error; + + xhv.domid = DOMID_SELF; + xhv.index = index; + error = HYPERVISOR_hvm_op(HVMOP_get_param, &xhv); + if (error) { + printf("hvm_get_parameter: failed to get %d, error %d\n", + index, error); + return (0); + } + return (xhv.value); +} +#endif + #endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */ diff --git a/sys/xen/interface/io/blkif.h b/sys/xen/interface/io/blkif.h index 9e2d3d0..020936b 100644 --- a/sys/xen/interface/io/blkif.h +++ b/sys/xen/interface/io/blkif.h @@ -78,11 +78,19 @@ #define BLKIF_OP_FLUSH_DISKCACHE 3 /* - * Maximum scatter/gather segments per request. - * This is carefully chosen so that sizeof(blkif_ring_t) <= PAGE_SIZE. - * NB. This could be 12 if the ring indexes weren't stored in the same page. + * Maximum scatter/gather segments associated with a request header block. */ -#define BLKIF_MAX_SEGMENTS_PER_REQUEST 11 +#define BLKIF_MAX_SEGMENTS_PER_HEADER_BLOCK 11 + +/* + * Maximum scatter/gather segments associated with a segment block. + */ +#define BLKIF_MAX_SEGMENTS_PER_SEGMENT_BLOCK 14 + +/* + * Maximum scatter/gather segments per request (header + segment blocks). + */ +#define BLKIF_MAX_SEGMENTS_PER_REQUEST 255 struct blkif_request_segment { grant_ref_t gref; /* reference to I/O buffer frame */ @@ -90,6 +98,7 @@ struct blkif_request_segment { /* @last_sect: last sector in frame to transfer (inclusive). */ uint8_t first_sect, last_sect; }; +typedef struct blkif_request_segment blkif_request_segment_t; struct blkif_request { uint8_t operation; /* BLKIF_OP_??? */ @@ -97,7 +106,7 @@ struct blkif_request { blkif_vdev_t handle; /* only for read/write requests */ uint64_t id; /* private guest value, echoed in resp */ blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ - struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST]; + struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_HEADER_BLOCK]; }; typedef struct blkif_request blkif_request_t; @@ -124,10 +133,22 @@ typedef struct blkif_response blkif_response_t; DEFINE_RING_TYPES(blkif, struct blkif_request, struct blkif_response); +#define BLKRING_GET_SG_REQUEST(_r, _idx) \ + ((struct blkif_request_segment *)RING_GET_REQUEST(_r, _idx)) + #define VDISK_CDROM 0x1 #define VDISK_REMOVABLE 0x2 #define VDISK_READONLY 0x4 +/* + * The number of ring request blocks required to handle an I/O + * request containing _segs segments. + */ +#define BLKIF_SEGS_TO_BLOCKS(_segs) \ + ((((_segs - BLKIF_MAX_SEGMENTS_PER_HEADER_BLOCK) \ + + (BLKIF_MAX_SEGMENTS_PER_SEGMENT_BLOCK - 1)) \ + / BLKIF_MAX_SEGMENTS_PER_SEGMENT_BLOCK) + /*header_block*/1) + #endif /* __XEN_PUBLIC_IO_BLKIF_H__ */ /* diff --git a/sys/xen/interface/io/protocols.h b/sys/xen/interface/io/protocols.h index 77bd1bd..fd52934 100644 --- a/sys/xen/interface/io/protocols.h +++ b/sys/xen/interface/io/protocols.h @@ -26,6 +26,7 @@ #define XEN_IO_PROTO_ABI_X86_32 "x86_32-abi" #define XEN_IO_PROTO_ABI_X86_64 "x86_64-abi" #define XEN_IO_PROTO_ABI_IA64 "ia64-abi" +#define XEN_IO_PROTO_ABI_POWERPC64 "powerpc64-abi" #if defined(__i386__) # define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_32 @@ -33,6 +34,8 @@ # define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_64 #elif defined(__ia64__) # define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_IA64 +#elif defined(__powerpc64__) +# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_POWERPC64 #else # error arch fixup needed here #endif diff --git a/sys/xen/interface/io/ring.h b/sys/xen/interface/io/ring.h index 6ce1d0d..6b7fd74 100644 --- a/sys/xen/interface/io/ring.h +++ b/sys/xen/interface/io/ring.h @@ -45,13 +45,29 @@ typedef unsigned int RING_IDX; #define __RD32(_x) (((_x) & 0xffff0000) ? __RD16((_x)>>16)<<16 : __RD16(_x)) /* + * The amount of space reserved in the shared ring for accounting information. + */ +#define __RING_HEADER_SIZE(_s) \ + ((intptr_t)(_s)->ring - (intptr_t)(_s)) + +/* * Calculate size of a shared ring, given the total available space for the * ring and indexes (_sz), and the name tag of the request/response structure. * A ring contains as many entries as will fit, rounded down to the nearest * power of two (so we can mask with (size-1) to loop around). */ #define __RING_SIZE(_s, _sz) \ - (__RD32(((_sz) - (long)(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0]))) + (__RD32(((_sz) - __RING_HEADER_SIZE(_s)) / sizeof((_s)->ring[0]))) + +/* + * The number of pages needed to support a given number of request/reponse + * entries. The entry count is rounded down to the nearest power of two + * as required by the ring macros. + */ +#define __RING_PAGES(_s, _entries) \ + ((__RING_HEADER_SIZE(_s) \ + + (__RD32(_entries) * sizeof((_s)->ring[0])) \ + + PAGE_SIZE - 1) / PAGE_SIZE) /* * Macros to make the correct C datatypes for a new kind of ring. diff --git a/sys/xen/interface/io/xenbus.h b/sys/xen/interface/io/xenbus.h index 4a053df..5e24f31 100644 --- a/sys/xen/interface/io/xenbus.h +++ b/sys/xen/interface/io/xenbus.h @@ -36,6 +36,9 @@ enum xenbus_state { XenbusStateUnknown = 0, + /* + * Initializing: Back-end is initializing. + */ XenbusStateInitialising = 1, /* @@ -49,6 +52,9 @@ enum xenbus_state { */ XenbusStateInitialised = 3, + /* + * Connected: The normal state for a front to backend connection. + */ XenbusStateConnected = 4, /* @@ -56,6 +62,9 @@ enum xenbus_state { */ XenbusStateClosing = 5, + /* + * Closed: No connection exists between front and back end. + */ XenbusStateClosed = 6, /* |