arch/x86/kernel/early_printk.c
Source file repositories/reference/linux-study-clean/arch/x86/kernel/early_printk.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kernel/early_printk.c- Extension
.c- Size
- 11474 bytes
- Lines
- 450
- Domain
- Architecture Layer
- Bucket
- arch/x86
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/console.hlinux/kernel.hlinux/kexec.hlinux/init.hlinux/string.hlinux/screen_info.hlinux/usb/ch9.hlinux/pci_regs.hlinux/pci_ids.hlinux/errno.hlinux/pgtable.hasm/io.hasm/processor.hasm/fcntl.hasm/setup.hxen/hvc-console.hasm/pci-direct.hasm/fixmap.hlinux/usb/ehci_def.hlinux/usb/xhci-dbgp.hasm/pci_x86.hlinux/static_call.h
Detected Declarations
function early_vga_writefunction io_serial_infunction io_serial_outfunction early_serial_putcfunction early_serial_writefunction early_serial_hw_initfunction early_serial_initfunction mem32_serial_outfunction mem32_serial_infunction early_mmio_serial_initfunction early_pci_serial_initfunction early_console_registerfunction setup_early_printk
Annotated Snippet
if (current_ypos >= max_ypos) {
/* scroll 1 line up */
for (k = 1, j = 0; k < max_ypos; k++, j++) {
for (i = 0; i < max_xpos; i++) {
writew(readw(VGABASE+2*(max_xpos*k+i)),
VGABASE + 2*(max_xpos*j + i));
}
}
for (i = 0; i < max_xpos; i++)
writew(0x720, VGABASE + 2*(max_xpos*j + i));
current_ypos = max_ypos-1;
}
#ifdef CONFIG_KGDB_KDB
if (c == '\b') {
if (current_xpos > 0)
current_xpos--;
} else if (c == '\r') {
current_xpos = 0;
} else
#endif
if (c == '\n') {
current_xpos = 0;
current_ypos++;
} else if (c != '\r') {
writew(((0x7 << 8) | (unsigned short) c),
VGABASE + 2*(max_xpos*current_ypos +
current_xpos++));
if (current_xpos >= max_xpos) {
current_xpos = 0;
current_ypos++;
}
}
}
}
static struct console early_vga_console = {
.name = "earlyvga",
.write = early_vga_write,
.flags = CON_PRINTBUFFER,
.index = -1,
};
/* Serial functions loosely based on a similar package from Klaus P. Gerlicher */
static unsigned long early_serial_base = 0x3f8; /* ttyS0 */
#define XMTRDY 0x20
#define DLAB 0x80
#define TXR 0 /* Transmit register (WRITE) */
#define RXR 0 /* Receive register (READ) */
#define IER 1 /* Interrupt Enable */
#define IIR 2 /* Interrupt ID */
#define FCR 2 /* FIFO control */
#define LCR 3 /* Line control */
#define MCR 4 /* Modem control */
#define LSR 5 /* Line Status */
#define MSR 6 /* Modem Status */
#define DLL 0 /* Divisor Latch Low */
#define DLH 1 /* Divisor latch High */
static __noendbr unsigned int io_serial_in(unsigned long addr, int offset)
{
return inb(addr + offset);
}
ANNOTATE_NOENDBR_SYM(io_serial_in);
static __noendbr void io_serial_out(unsigned long addr, int offset, int value)
{
outb(value, addr + offset);
}
ANNOTATE_NOENDBR_SYM(io_serial_out);
DEFINE_STATIC_CALL(serial_in, io_serial_in);
DEFINE_STATIC_CALL(serial_out, io_serial_out);
static int early_serial_putc(unsigned char ch)
{
unsigned timeout = 0xffff;
while ((static_call(serial_in)(early_serial_base, LSR) & XMTRDY) == 0 && --timeout)
cpu_relax();
static_call(serial_out)(early_serial_base, TXR, ch);
return timeout ? 0 : -1;
}
static void early_serial_write(struct console *con, const char *s, unsigned n)
{
while (*s && n-- > 0) {
Annotation
- Immediate include surface: `linux/console.h`, `linux/kernel.h`, `linux/kexec.h`, `linux/init.h`, `linux/string.h`, `linux/screen_info.h`, `linux/usb/ch9.h`, `linux/pci_regs.h`.
- Detected declarations: `function early_vga_write`, `function io_serial_in`, `function io_serial_out`, `function early_serial_putc`, `function early_serial_write`, `function early_serial_hw_init`, `function early_serial_init`, `function mem32_serial_out`, `function mem32_serial_in`, `function early_mmio_serial_init`.
- Atlas domain: Architecture Layer / arch/x86.
- 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.