drivers/xen/evtchn.c
Source file repositories/reference/linux-study-clean/drivers/xen/evtchn.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/xen/evtchn.c- Extension
.c- Size
- 16910 bytes
- Lines
- 733
- Domain
- Driver Families
- Bucket
- drivers/xen
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/kernel.hlinux/sched.hlinux/slab.hlinux/string.hlinux/errno.hlinux/fs.hlinux/miscdevice.hlinux/major.hlinux/proc_fs.hlinux/stat.hlinux/poll.hlinux/irq.hlinux/init.hlinux/mutex.hlinux/cpu.hlinux/mm.hlinux/vmalloc.hxen/xen.hxen/events.hxen/evtchn.hxen/xen-ops.hasm/xen/hypervisor.h
Detected Declarations
struct per_user_datastruct user_evtchnfunction evtchn_free_ringfunction evtchn_ring_offsetfunction add_evtchnfunction del_evtchnfunction evtchn_interruptfunction evtchn_readfunction evtchn_writefunction evtchn_resize_ringfunction evtchn_bind_to_userfunction evtchn_unbind_from_userfunction evtchn_ioctlfunction evtchn_pollfunction evtchn_fasyncfunction evtchn_openfunction evtchn_releasefunction evtchn_initfunction evtchn_cleanupmodule init evtchn_init
Annotated Snippet
static const struct file_operations evtchn_fops = {
.owner = THIS_MODULE,
.read = evtchn_read,
.write = evtchn_write,
.unlocked_ioctl = evtchn_ioctl,
.poll = evtchn_poll,
.fasync = evtchn_fasync,
.open = evtchn_open,
.release = evtchn_release,
};
static struct miscdevice evtchn_miscdev = {
.minor = MISC_DYNAMIC_MINOR,
.name = "xen/evtchn",
.fops = &evtchn_fops,
};
static int __init evtchn_init(void)
{
int err;
if (!xen_domain())
return -ENODEV;
/* Create '/dev/xen/evtchn'. */
err = misc_register(&evtchn_miscdev);
if (err != 0) {
pr_err("Could not register /dev/xen/evtchn\n");
return err;
}
pr_info("Event-channel device installed\n");
return 0;
}
static void __exit evtchn_cleanup(void)
{
misc_deregister(&evtchn_miscdev);
}
module_init(evtchn_init);
module_exit(evtchn_cleanup);
MODULE_DESCRIPTION("Xen /dev/xen/evtchn device driver");
MODULE_LICENSE("GPL");
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/sched.h`, `linux/slab.h`, `linux/string.h`, `linux/errno.h`, `linux/fs.h`, `linux/miscdevice.h`.
- Detected declarations: `struct per_user_data`, `struct user_evtchn`, `function evtchn_free_ring`, `function evtchn_ring_offset`, `function add_evtchn`, `function del_evtchn`, `function evtchn_interrupt`, `function evtchn_read`, `function evtchn_write`, `function evtchn_resize_ring`.
- Atlas domain: Driver Families / drivers/xen.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.