drivers/xen/xen-front-pgdir-shbuf.c

Source file repositories/reference/linux-study-clean/drivers/xen/xen-front-pgdir-shbuf.c

File Facts

System
Linux kernel
Corpus path
drivers/xen/xen-front-pgdir-shbuf.c
Extension
.c
Size
14465 bytes
Lines
550
Domain
Driver Families
Bucket
drivers/xen
Inferred role
Driver Families: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct xen_page_directory {
	grant_ref_t gref_dir_next_page;
#define XEN_GREF_LIST_END	0
	grant_ref_t gref[]; /* Variable length */
};

/*
 * Shared buffer ops which are differently implemented
 * depending on the allocation mode, e.g. if the buffer
 * is allocated by the corresponding backend or frontend.
 * Some of the operations.
 */
struct xen_front_pgdir_shbuf_ops {
	/*
	 * Calculate number of grefs required to handle this buffer,
	 * e.g. if grefs are required for page directory only or the buffer
	 * pages as well.
	 */
	void (*calc_num_grefs)(struct xen_front_pgdir_shbuf *buf);

	/* Fill page directory according to para-virtual display protocol. */
	void (*fill_page_dir)(struct xen_front_pgdir_shbuf *buf);

	/* Claim grant references for the pages of the buffer. */
	int (*grant_refs_for_buffer)(struct xen_front_pgdir_shbuf *buf,
				     grant_ref_t *priv_gref_head, int gref_idx);

	/* Map grant references of the buffer. */
	int (*map)(struct xen_front_pgdir_shbuf *buf);

	/* Unmap grant references of the buffer. */
	int (*unmap)(struct xen_front_pgdir_shbuf *buf);
};

/*
 * Get granted reference to the very first page of the
 * page directory. Usually this is passed to the backend,
 * so it can find/fill the grant references to the buffer's
 * pages.
 *
 * \param buf shared buffer which page directory is of interest.
 * \return granted reference to the very first page of the
 * page directory.
 */
grant_ref_t
xen_front_pgdir_shbuf_get_dir_start(struct xen_front_pgdir_shbuf *buf)
{
	if (!buf->grefs)
		return INVALID_GRANT_REF;

	return buf->grefs[0];
}
EXPORT_SYMBOL_GPL(xen_front_pgdir_shbuf_get_dir_start);

/*
 * Map granted references of the shared buffer.
 *
 * Depending on the shared buffer mode of allocation
 * (be_alloc flag) this can either do nothing (for buffers
 * shared by the frontend itself) or map the provided granted
 * references onto the backing storage (buf->pages).
 *
 * \param buf shared buffer which grants to be mapped.
 * \return zero on success or a negative number on failure.
 */
int xen_front_pgdir_shbuf_map(struct xen_front_pgdir_shbuf *buf)
{
	if (buf->ops && buf->ops->map)
		return buf->ops->map(buf);

	/* No need to map own grant references. */
	return 0;
}
EXPORT_SYMBOL_GPL(xen_front_pgdir_shbuf_map);

/*
 * Unmap granted references of the shared buffer.
 *
 * Depending on the shared buffer mode of allocation
 * (be_alloc flag) this can either do nothing (for buffers
 * shared by the frontend itself) or unmap the provided granted
 * references.
 *
 * \param buf shared buffer which grants to be unmapped.
 * \return zero on success or a negative number on failure.
 */
int xen_front_pgdir_shbuf_unmap(struct xen_front_pgdir_shbuf *buf)
{
	if (buf->ops && buf->ops->unmap)
		return buf->ops->unmap(buf);

Annotation

Implementation Notes