#include "kvm/early_printk.h" #include "kvm/ioport.h" #include static int early_serial_base = 0x3f8; /* ttyS0 */ #define XMTRDY 0x20 #define TXR 0 /* Transmit register (WRITE) */ #define LSR 5 /* Line Status */ #define MSR 6 /* Modem Status */ static bool early_serial_txr_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count) { char *p = data; int i; while (count--) { for (i = 0; i < size; i++) fprintf(stdout, "%c", *p++); } fflush(stdout); return true; } static bool early_serial_rxr_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count) { return true; } static struct ioport_operations early_serial_txr_rxr_ops = { .io_out = early_serial_txr_out, .io_in = early_serial_rxr_in, }; static bool early_serial_lsr_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count) { uint8_t *p = data; *p = XMTRDY; return true; } static struct ioport_operations early_serial_lsr_ops = { .io_in = early_serial_lsr_in, }; static bool early_serial_msr_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count) { return true; } static struct ioport_operations early_serial_msr_ops = { .io_in = early_serial_msr_in, }; void early_printk__init(void) { ioport__register(early_serial_base + TXR, &early_serial_txr_rxr_ops, 1); ioport__register(early_serial_base + LSR, &early_serial_lsr_ops, 1); ioport__register(early_serial_base + MSR, &early_serial_msr_ops, 1); }