drivers/tty/serial/8250/8250_early.c
Source file repositories/reference/linux-study-clean/drivers/tty/serial/8250/8250_early.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tty/serial/8250/8250_early.c- Extension
.c- Size
- 5950 bytes
- Lines
- 212
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/tty.hlinux/init.hlinux/console.hlinux/of.hlinux/serial_reg.hlinux/serial.hlinux/serial_8250.hasm/io.hasm/serial.h
Detected Declarations
function serial8250_early_infunction serial8250_early_outfunction serial_putcfunction early_serial8250_writefunction early_serial8250_readfunction init_portfunction early_serial8250_setupfunction early_serial8250_rs2_setupfunction early_omap8250_setup
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Early serial console for 8250/16550 devices
*
* (c) Copyright 2004 Hewlett-Packard Development Company, L.P.
* Bjorn Helgaas <bjorn.helgaas@hp.com>
*
* Based on the 8250.c serial driver, Copyright (C) 2001 Russell King,
* and on early_printk.c by Andi Kleen.
*
* This is for use before the serial driver has initialized, in
* particular, before the UARTs have been discovered and named.
* Instead of specifying the console device as, e.g., "ttyS0",
* we locate the device directly by its MMIO or I/O port address.
*
* The user can specify the device directly, e.g.,
* earlycon=uart8250,io,0x3f8,9600n8
* earlycon=uart8250,mmio,0xff5e0000,115200n8
* earlycon=uart8250,mmio32,0xff5e0000,115200n8
* or
* console=uart8250,io,0x3f8,9600n8
* console=uart8250,mmio,0xff5e0000,115200n8
* console=uart8250,mmio32,0xff5e0000,115200n8
*/
#include <linux/tty.h>
#include <linux/init.h>
#include <linux/console.h>
#include <linux/of.h>
#include <linux/serial_reg.h>
#include <linux/serial.h>
#include <linux/serial_8250.h>
#include <asm/io.h>
#include <asm/serial.h>
static unsigned int serial8250_early_in(struct uart_port *port, int offset)
{
offset <<= port->regshift;
switch (port->iotype) {
case UPIO_MEM:
return readb(port->membase + offset);
case UPIO_MEM16:
return readw(port->membase + offset);
case UPIO_MEM32:
return readl(port->membase + offset);
case UPIO_MEM32BE:
return ioread32be(port->membase + offset);
#ifdef CONFIG_HAS_IOPORT
case UPIO_PORT:
return inb(port->iobase + offset);
#endif
default:
return 0;
}
}
static void serial8250_early_out(struct uart_port *port, int offset, int value)
{
offset <<= port->regshift;
switch (port->iotype) {
case UPIO_MEM:
writeb(value, port->membase + offset);
break;
case UPIO_MEM16:
writew(value, port->membase + offset);
break;
case UPIO_MEM32:
writel(value, port->membase + offset);
break;
case UPIO_MEM32BE:
iowrite32be(value, port->membase + offset);
break;
#ifdef CONFIG_HAS_IOPORT
case UPIO_PORT:
outb(value, port->iobase + offset);
break;
#endif
default:
break;
}
}
static void serial_putc(struct uart_port *port, unsigned char c)
{
unsigned int status;
serial8250_early_out(port, UART_TX, c);
Annotation
- Immediate include surface: `linux/tty.h`, `linux/init.h`, `linux/console.h`, `linux/of.h`, `linux/serial_reg.h`, `linux/serial.h`, `linux/serial_8250.h`, `asm/io.h`.
- Detected declarations: `function serial8250_early_in`, `function serial8250_early_out`, `function serial_putc`, `function early_serial8250_write`, `function early_serial8250_read`, `function init_port`, `function early_serial8250_setup`, `function early_serial8250_rs2_setup`, `function early_omap8250_setup`.
- Atlas domain: Driver Families / drivers/tty.
- Implementation status: source 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.