/* SPDX-License-Identifier: GPL-2.0-only */ #include #include #include #include #include #include static int num_serial_ports = 0; void init_serial_port(int port) { outb(port | 1, 0x00); outb(port | 3, 0x80); outb(port | 0, 0x01); outb(port | 1, 0x00); outb(port | 3, 0x03); outb(port | 2, 0xC7); outb(port | 4, 0x0B); outb(port | 4, 0x1E); outb(port | 0, 0xAE); /* Enable loopback mode */ if (inb(port | 0) != 0xAE) { /* Loopback test */ kwarn("Serial port 0x%04x loopback test failed\n", port); return; } outb(port | 1, 0x01); /* Enable interrupts */ outb(port | 4, 0x0F); /* Enter normal operation */ char name[256]; } void *arch_serial_init() { return (void *)COM1; } void arch_serial_write(struct tty *tty, char c) { /* Wait for line to be clear */ size_t port = (size_t)tty->priv; while ((inb(port + 5) & 0x20) == 0) ; outb(port, c); } char arch_serial_read(struct tty *tty) { size_t port = (size_t)tty->priv; while ((inb(port + 5) & 1) == 0) ; return inb(port); }