drivers/tty/amiserial.c
Source file repositories/reference/linux-study-clean/drivers/tty/amiserial.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tty/amiserial.c- Extension
.c- Size
- 41636 bytes
- Lines
- 1666
- Domain
- Driver Families
- Bucket
- drivers/tty
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitops.hlinux/circ_buf.hlinux/console.hlinux/delay.hlinux/errno.hlinux/fcntl.hlinux/init.hlinux/interrupt.hlinux/ioport.hlinux/kernel.hlinux/major.hlinux/mm.hlinux/module.hlinux/platform_device.hlinux/ptrace.hlinux/seq_file.hlinux/serial.hlinux/serial_reg.hlinux/serial_core.hlinux/sched.hlinux/signal.hlinux/slab.hlinux/string.hlinux/timer.hlinux/tty_flip.hlinux/tty.hlinux/types.hlinux/uaccess.hasm/amigahw.hasm/amigaints.hasm/irq.hasm/setup.h
Detected Declarations
struct serial_statefunction rtsdtr_ctrlfunction rs_stopfunction rs_startfunction receive_charsfunction transmit_charsfunction check_modem_statusfunction ser_vbl_intfunction ser_rx_intfunction ser_tx_intfunction rs_startupfunction rs_shutdownfunction change_speedfunction rs_put_charfunction rs_flush_charsfunction rs_writefunction rs_write_roomfunction rs_chars_in_bufferfunction rs_flush_bufferfunction rs_send_xcharfunction rs_throttlefunction rs_unthrottlefunction rs_ioctlfunction set_serial_infofunction get_lsr_infofunction rs_tiocmgetfunction rs_tiocmsetfunction rs_breakfunction interruptsfunction rs_ioctlfunction rs_set_termiosfunction rs_closefunction rs_wait_until_sentfunction rs_hangupfunction rs_openfunction line_infofunction rs_proc_showfunction amiga_carrier_raisedfunction amiga_dtr_rtsfunction amiga_serial_probefunction amiga_serial_removefunction amiga_serial_putcfunction serial_console_writefunction amiserial_console_init
Annotated Snippet
struct serial_state {
struct tty_port tport;
struct circ_buf xmit;
struct async_icount icount;
unsigned long port;
int baud_base;
int custom_divisor;
int read_status_mask;
int ignore_status_mask;
int timeout;
int quot;
int IER; /* Interrupt Enable Register */
int MCR; /* Modem control register */
u8 x_char; /* xon/xoff character */
};
static struct tty_driver *serial_driver;
/* number of characters left in xmit buffer before we ask for more */
#define WAKEUP_CHARS 256
#define XMIT_FIFO_SIZE 1
static unsigned char current_ctl_bits;
static void change_speed(struct tty_struct *tty, struct serial_state *info,
const struct ktermios *old);
static void rs_wait_until_sent(struct tty_struct *tty, int timeout);
static struct serial_state serial_state;
/* some serial hardware definitions */
#define SDR_OVRUN (1<<15)
#define SDR_RBF (1<<14)
#define SDR_TBE (1<<13)
#define SDR_TSRE (1<<12)
#define SERPER_PARENB (1<<15)
#define AC_SETCLR (1<<15)
#define AC_UARTBRK (1<<11)
#define SER_DTR (1<<7)
#define SER_RTS (1<<6)
#define SER_DCD (1<<5)
#define SER_CTS (1<<4)
#define SER_DSR (1<<3)
static __inline__ void rtsdtr_ctrl(int bits)
{
ciab.pra = ((bits & (SER_RTS | SER_DTR)) ^ (SER_RTS | SER_DTR)) | (ciab.pra & ~(SER_RTS | SER_DTR));
}
/*
* ------------------------------------------------------------
* rs_stop() and rs_start()
*
* This routines are called before setting or resetting tty->flow.stopped.
* They enable or disable transmitter interrupts, as necessary.
* ------------------------------------------------------------
*/
static void rs_stop(struct tty_struct *tty)
{
struct serial_state *info = tty->driver_data;
unsigned long flags;
local_irq_save(flags);
if (info->IER & UART_IER_THRI) {
info->IER &= ~UART_IER_THRI;
/* disable Tx interrupt and remove any pending interrupts */
amiga_custom.intena = IF_TBE;
mb();
amiga_custom.intreq = IF_TBE;
mb();
}
local_irq_restore(flags);
}
static void rs_start(struct tty_struct *tty)
{
struct serial_state *info = tty->driver_data;
unsigned long flags;
local_irq_save(flags);
if (info->xmit.head != info->xmit.tail
&& info->xmit.buf
&& !(info->IER & UART_IER_THRI)) {
info->IER |= UART_IER_THRI;
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/circ_buf.h`, `linux/console.h`, `linux/delay.h`, `linux/errno.h`, `linux/fcntl.h`, `linux/init.h`, `linux/interrupt.h`.
- Detected declarations: `struct serial_state`, `function rtsdtr_ctrl`, `function rs_stop`, `function rs_start`, `function receive_chars`, `function transmit_chars`, `function check_modem_status`, `function ser_vbl_int`, `function ser_rx_int`, `function ser_tx_int`.
- Atlas domain: Driver Families / drivers/tty.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.