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.
- 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/errno.hlinux/mm.hasm/xen/hypervisor.hxen/balloon.hxen/xen.hxen/xenbus.hxen/interface/io/ring.hxen/xen-front-pgdir-shbuf.h
Detected Declarations
struct xen_page_directorystruct xen_front_pgdir_shbuf_opsfunction xen_front_pgdir_shbuf_get_dir_startfunction storagefunction xen_front_pgdir_shbuf_unmapfunction xen_front_pgdir_shbuf_freefunction offsetoffunction backend_calc_num_grefsfunction guest_calc_num_grefsfunction backend_unmapfunction backend_mapfunction backend_fill_page_dirfunction guest_fill_page_dirfunction guest_grant_refs_for_bufferfunction grant_referencesfunction alloc_storagefunction xen_front_pgdir_shbuf_allocexport xen_front_pgdir_shbuf_get_dir_startexport xen_front_pgdir_shbuf_mapexport xen_front_pgdir_shbuf_unmapexport xen_front_pgdir_shbuf_freeexport xen_front_pgdir_shbuf_alloc
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
- Immediate include surface: `linux/module.h`, `linux/errno.h`, `linux/mm.h`, `asm/xen/hypervisor.h`, `xen/balloon.h`, `xen/xen.h`, `xen/xenbus.h`, `xen/interface/io/ring.h`.
- Detected declarations: `struct xen_page_directory`, `struct xen_front_pgdir_shbuf_ops`, `function xen_front_pgdir_shbuf_get_dir_start`, `function storage`, `function xen_front_pgdir_shbuf_unmap`, `function xen_front_pgdir_shbuf_free`, `function offsetof`, `function backend_calc_num_grefs`, `function guest_calc_num_grefs`, `function backend_unmap`.
- Atlas domain: Driver Families / drivers/xen.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.