arch/um/drivers/line.c
Source file repositories/reference/linux-study-clean/arch/um/drivers/line.c
File Facts
- System
- Linux kernel
- Corpus path
arch/um/drivers/line.c- Extension
.c- Size
- 16610 bytes
- Lines
- 772
- 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.
- 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/irqreturn.hlinux/kd.hlinux/sched/signal.hlinux/slab.hchan.hirq_kern.hirq_user.hkern_util.hos.h
Detected Declarations
struct winchfunction Copyrightfunction write_roomfunction line_write_roomfunction line_chars_in_bufferfunction buffer_datafunction flush_bufferfunction line_flush_bufferfunction line_flush_charsfunction line_writefunction line_throttlefunction line_unthrottlefunction line_write_interruptfunction line_setup_irqfunction line_activatefunction line_destructfunction line_openfunction line_installfunction line_closefunction line_hangupfunction close_linesfunction setup_one_linefunction line_setupfunction line_configfunction line_get_configfunction line_idfunction line_removefunction register_linesfunction __free_winchfunction free_winchfunction winch_interruptfunction register_winch_irqfunction unregister_winchfunction list_for_each_safefunction winch_cleanup
Annotated Snippet
struct winch {
struct list_head list;
int fd;
int tty_fd;
int pid;
struct tty_port *port;
unsigned long stack;
struct work_struct work;
};
static void __free_winch(struct work_struct *work)
{
struct winch *winch = container_of(work, struct winch, work);
um_free_irq(WINCH_IRQ, winch);
if (winch->pid != -1)
os_kill_process(winch->pid, 1);
if (winch->stack != 0)
free_stack(winch->stack, 0);
kfree(winch);
}
static void free_winch(struct winch *winch)
{
int fd = winch->fd;
winch->fd = -1;
if (fd != -1)
os_close_file(fd);
__free_winch(&winch->work);
}
static irqreturn_t winch_interrupt(int irq, void *data)
{
struct winch *winch = data;
struct tty_struct *tty;
struct line *line;
int fd = winch->fd;
int err;
char c;
struct pid *pgrp;
if (fd != -1) {
err = generic_read(fd, &c, NULL);
/* A read of 2 means the winch thread failed and has warned */
if (err < 0 || (err == 1 && c == 2)) {
if (err != -EAGAIN) {
winch->fd = -1;
list_del(&winch->list);
os_close_file(fd);
if (err < 0) {
printk(KERN_ERR "winch_interrupt : read failed, errno = %d\n",
-err);
printk(KERN_ERR "fd %d is losing SIGWINCH support\n",
winch->tty_fd);
}
INIT_WORK(&winch->work, __free_winch);
schedule_work(&winch->work);
return IRQ_HANDLED;
}
goto out;
}
}
tty = tty_port_tty_get(winch->port);
if (tty != NULL) {
line = tty->driver_data;
if (line != NULL) {
chan_window_size(line, &tty->winsize.ws_row,
&tty->winsize.ws_col);
pgrp = tty_get_pgrp(tty);
if (pgrp)
kill_pgrp(pgrp, SIGWINCH, 1);
put_pid(pgrp);
}
tty_kref_put(tty);
}
out:
return IRQ_HANDLED;
}
void register_winch_irq(int fd, int tty_fd, int pid, struct tty_port *port,
unsigned long stack)
{
struct winch *winch;
winch = kmalloc_obj(*winch);
if (winch == NULL) {
printk(KERN_ERR "register_winch_irq - kmalloc failed\n");
goto cleanup;
}
Annotation
- Immediate include surface: `linux/irqreturn.h`, `linux/kd.h`, `linux/sched/signal.h`, `linux/slab.h`, `chan.h`, `irq_kern.h`, `irq_user.h`, `kern_util.h`.
- Detected declarations: `struct winch`, `function Copyright`, `function write_room`, `function line_write_room`, `function line_chars_in_buffer`, `function buffer_data`, `function flush_buffer`, `function line_flush_buffer`, `function line_flush_chars`, `function line_write`.
- Atlas domain: Architecture Layer / arch/um.
- Implementation status: source implementation candidate.
- 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.