X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/34f6af4f61e0eec9c96113e07f140b609b4113c8..f89517343bf062d299d54408eea2f9387bfefb6d:/lunaix-os/hal/char/uart/16x50_isa.c?ds=sidebyside diff --git a/lunaix-os/hal/char/uart/16x50_isa.c b/lunaix-os/hal/char/uart/16x50_isa.c index 128803e..152317a 100644 --- a/lunaix-os/hal/char/uart/16x50_isa.c +++ b/lunaix-os/hal/char/uart/16x50_isa.c @@ -1,5 +1,4 @@ #include -#include #include #include @@ -11,20 +10,20 @@ LOG_MODULE("16x50-isa"); static DEFINE_LLIST(com_ports); static void -com_irq_handler(const struct hart_state* hstate) +com_irq_handler(irq_t irq, const struct hart_state* hstate) { - int vector = hart_vector_stamp(hstate); - uart_handle_irq_overlap(vector, &com_ports); + uart_handle_irq_overlap(irq, &com_ports); } -static int -upiom_init(struct device_def* def) +int +isa16x50_create_once(struct device_def* def) { int irq3 = 3, irq4 = 4; u16_t ioports[] = { 0x3F8, 0x2F8, 0x3E8, 0x2E8 }; int* irqs[] = { &irq4, &irq3, &irq4, &irq3 }; struct uart16550* uart = NULL; + struct serial_dev* sdev; ptr_t base; // COM 1...4 @@ -37,28 +36,21 @@ upiom_init(struct device_def* def) continue; } + sdev = uart_create_serial(uart, &def->class, &com_ports, "S"); + int irq = *irqs[i]; if (irq) { /* * Since these irqs are overlapped, this particular setup is needed * to avoid double-bind */ - uart->iv = isrm_bindirq(irq, com_irq_handler); + uart->irq = irq_declare_line(com_irq_handler, irq); + irq_assign(irq_owning_domain(sdev->dev), uart->irq, NULL); *((volatile int*)irqs[i]) = 0; } - - INFO("base: 0x%x, irq=%d", - base, irq, uart->iv); - - uart_create_serial(uart, &def->class, &com_ports, "S"); + + INFO("base: 0x%x, irq=%d", base, irq); } return 0; -} - -static struct device_def uart_pmio_def = { - .class = DEVCLASS(DEVIF_SOC, DEVFN_CHAR, DEV_UART16550), - .name = "16550 UART (PIO)", - .init = upiom_init -}; -EXPORT_DEVICE(uart16550_pmio, &uart_pmio_def, load_onboot); \ No newline at end of file +} \ No newline at end of file