1 #include <lunaix/device.h>
2 #include <lunaix/syslog.h>
4 #include <asm/x86_pmio.h>
5 #include <asm/x86_isrm.h>
9 LOG_MODULE("16x50-isa");
11 static DEFINE_LLIST(com_ports);
14 com_irq_handler(irq_t irq, const struct hart_state* hstate)
16 uart_handle_irq_overlap(irq, &com_ports);
20 isa16x50_create_once(struct device_def* def)
22 int irq3 = 3, irq4 = 4;
23 u16_t ioports[] = { 0x3F8, 0x2F8, 0x3E8, 0x2E8 };
24 int* irqs[] = { &irq4, &irq3, &irq4, &irq3 };
26 struct uart16550* uart = NULL;
27 struct serial_dev* sdev;
31 for (size_t i = 0; i < 4; i++) {
34 uart = uart16x50_pmio_create(base);
36 WARN("port 0x%x not accessible", base);
40 sdev = uart_create_serial(uart, &def->class, &com_ports, "S");
45 * Since these irqs are overlapped, this particular setup is needed
46 * to avoid double-bind
48 uart->irq = irq_declare_line(com_irq_handler, irq, NULL);
49 irq_assign(irq_owning_domain(sdev->dev), uart->irq);
50 *((volatile int*)irqs[i]) = 0;
53 INFO("base: 0x%x, irq=%d", base, irq);