1 #include "kvm/early_printk.h" 2 3 #include "kvm/ioport.h" 4 5 #include <stdio.h> 6 7 static bool early_serial_txr_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count) 8 { 9 char *p = data; 10 11 printf("%c", *p); 12 13 return true; 14 } 15 16 static struct ioport_operations early_serial_txr_ops = { 17 .io_out = early_serial_txr_out, 18 }; 19 20 static bool early_serial_lsr_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count) 21 { 22 uint8_t *p = data; 23 24 *p = 0x20; /* xmtrdy */ 25 26 return true; 27 } 28 29 static struct ioport_operations early_serial_lsr_ops = { 30 .io_in = early_serial_lsr_in, 31 }; 32 33 void early_printk__init(void) 34 { 35 ioport__register(0x03F8, &early_serial_txr_ops); 36 ioport__register(0x03FD, &early_serial_lsr_ops); 37 } 38