62 #define XENGRANT_TRY_VERSION 1 72 struct gnttab_set_version set_version;
73 struct gnttab_get_version get_version;
75 union grant_entry_v2 *
v2;
82 if ( ( xenrc = xengrant_query_size ( xen, &
size ) ) != 0 ) {
84 DBGC ( xen,
"XENGRANT could not get table size: %s\n",
92 if ( ( xenrc = xengrant_set_version ( xen, &set_version ) ) != 0 ) {
94 DBGC ( xen,
"XENGRANT could not set version %d: %s\n",
102 if ( ( xenrc = xengrant_get_version ( xen, &get_version ) ) == 0 ) {
118 sizeof ( *
v1 ) ) - 1 );
123 DBGC ( xen,
"XENGRANT detected unsupported version " 130 DBGC ( xen,
"XENGRANT could not get version (assuming v1): " 135 DBGC ( xen,
"XENGRANT using v%d table with %d entries\n",
136 version, xengrant_entries ( xen ) );
149 unsigned int count ) {
150 struct grant_entry_header *
hdr;
151 unsigned int entries = xengrant_entries ( xen );
152 unsigned int mask = ( entries - 1 );
153 unsigned int check = 0;
159 if ( avail <
count ) {
160 DBGC ( xen,
"XENGRANT cannot allocate %d references (only %d " 161 "of %d available)\n",
count, avail, entries );
164 DBGC ( xen,
"XENGRANT allocating %d references (from %d of %d " 165 "available)\n",
count, avail, entries );
174 assert ( check++ < entries );
181 hdr = xengrant_header ( xen,
ref );
195 DBGC2 ( xen,
"XENGRANT allocated ref %d\n",
ref );
215 unsigned int count ) {
216 struct grant_entry_header *
hdr;
221 for ( i = 0 ; i <
count ; i++ ) {
225 assert (
ref < xengrant_entries ( xen ) );
228 hdr = xengrant_header ( xen,
ref );
230 DBGC2 ( xen,
"XENGRANT freed ref %d\n",
ref );
int xengrant_init(struct xen_hypervisor *xen)
Initialise grant table.
struct arbelprm_rc_send_wqe rc
struct golan_inbox_hdr hdr
Message header.
uint16_t readw(volatile uint16_t *io_addr)
Read 16-bit word from memory-mapped device.
uint8_t size
Entry size (in 32-bit words)
#define GNTTAB_NR_RESERVED_ENTRIES
#define PAGE_SIZE
Page size.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
#define ENOTSUP
Operation not supported.
#define EXEN(xenrc)
Convert a Xen status code to an iPXE status code.
u32 version
Driver version.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
uint16_t count
Number of entries.
char * strerror(int errno)
Retrieve string representation of error number.
static const char grant_ref_t unsigned int struct io_buffer grant_ref_t * refs
void xengrant_free(struct xen_hypervisor *xen, grant_ref_t *refs, unsigned int count)
Free grant references.
unsigned int ref
Most recently used grant reference.
union grant_entry_v2 * v2
#define ENOBUFS
No buffer space available.
#define XENGRANT_TRY_VERSION
Grant table version to try setting.
unsigned int shift
Entry size shift (for later version tables)
struct xen_grant grant
Grant table.
size_t len
Total grant table length.
static const char grant_ref_t ref
static void xengrant_zero(struct xen_hypervisor *xen, struct grant_entry_header *hdr)
Zero grant table entry.
#define fls(x)
Find last (i.e.
int xengrant_alloc(struct xen_hypervisor *xen, grant_ref_t *refs, unsigned int count)
Allocate grant references.
unsigned int used
Number of grant table entries in use.
struct xen_hypervisor * xen
Xen hypervisor.