arch/um/drivers/xterm_kern.c
Source file repositories/reference/linux-study-clean/arch/um/drivers/xterm_kern.c
File Facts
- System
- Linux kernel
- Corpus path
arch/um/drivers/xterm_kern.c- Extension
.c- Size
- 1712 bytes
- Lines
- 84
- Domain
- Architecture Layer
- Bucket
- arch/um
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- 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/slab.hlinux/completion.hlinux/irqreturn.hasm/irq.hirq_kern.hos.hxterm.h
Detected Declarations
struct xterm_waitfunction xterm_interruptfunction xterm_fd
Annotated Snippet
struct xterm_wait {
struct completion ready;
int fd;
int pid;
int new_fd;
};
static irqreturn_t xterm_interrupt(int irq, void *data)
{
struct xterm_wait *xterm = data;
int fd = -1, n_fds = 1;
ssize_t ret;
ret = os_rcv_fd_msg(xterm->fd, &fd, n_fds,
&xterm->pid, sizeof(xterm->pid));
if (ret == -EAGAIN)
return IRQ_NONE;
if (ret < 0)
fd = ret;
else if (ret != sizeof(xterm->pid))
fd = -EMSGSIZE;
xterm->new_fd = fd;
complete(&xterm->ready);
return IRQ_HANDLED;
}
int xterm_fd(int socket, int *pid_out)
{
struct xterm_wait *data;
int err, ret;
data = kmalloc_obj(*data);
if (data == NULL) {
printk(KERN_ERR "xterm_fd : failed to allocate xterm_wait\n");
return -ENOMEM;
}
/* This is a locked semaphore... */
*data = ((struct xterm_wait) { .fd = socket,
.pid = -1,
.new_fd = -1 });
init_completion(&data->ready);
err = um_request_irq(XTERM_IRQ, socket, IRQ_READ, xterm_interrupt,
IRQF_SHARED, "xterm", data);
if (err < 0) {
printk(KERN_ERR "xterm_fd : failed to get IRQ for xterm, "
"err = %d\n", err);
ret = err;
goto out;
}
/* ... so here we wait for an xterm interrupt.
*
* XXX Note, if the xterm doesn't work for some reason (eg. DISPLAY
* isn't set) this will hang... */
wait_for_completion(&data->ready);
um_free_irq(XTERM_IRQ, data);
ret = data->new_fd;
*pid_out = data->pid;
out:
kfree(data);
return ret;
}
Annotation
- Immediate include surface: `linux/slab.h`, `linux/completion.h`, `linux/irqreturn.h`, `asm/irq.h`, `irq_kern.h`, `os.h`, `xterm.h`.
- Detected declarations: `struct xterm_wait`, `function xterm_interrupt`, `function xterm_fd`.
- Atlas domain: Architecture Layer / arch/um.
- Implementation status: source implementation candidate.
- 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.