Hello, Genode Hackers!
I'm currently implementing an X86 PCI bus driver for L4Linux as a temporary solution for getting USB support in L4Linux.
Current genode-side code is presented below. The l4linux patch is not ready, but I've submitted the relevant part of the diff to pastebin (it's only makefile and kconfig anyway)
https://github.com/Ksys-labs/genode/blob/pci_wip/ports-foc/src/drivers/genod... https://github.com/Ksys-labs/genode/blob/pci_wip/ports-foc/src/lib/l4lx/geno... https://github.com/Ksys-labs/genode/blob/pci_wip/ports-foc/src/lib/l4lx/l4_i... http://pastebin.com/9c37tuJR
I have implemented the linux driver which calls the Genode pci service routines. I have also extended the l4lx io library to allow mapping pci memory space. With this patches, the ehci and ohci drivers probe in linux, but fail to work because interrupts are not triggered. I have implemented the fake irq thread which kicks the irq handler every millisecond and with that usb works. This indicates that the pci subsystem and memory mapping are
I've got some questions regarding interrupt handling in L4Linux and Genode in general.
1. Why are NR_IRQS_HW interrupts reserved on X86 in l4linux? The EHCI controller wants the interrupt number 11 which is lower than NR_IRQS_HW. Ok, I worked around that by editing the constant and removing the "BUG_ON(NR_REQUESTABLE < 1)" in arch/l4/kernel/irq.c init_array function 2. How are capabilities actually assigned? it would seem to me that l4x_register_irq allocates the capabilitiies in the first available slot, but l4x_have_irqcap looks it up by index. I've worked around it by explicitely allocating 12 capabilities via l4x_cap_alloc, but still got error -2004 on irq attach. Now, I've had success in attaching irq after I allocated the capability via the following code in l4lx:
Genode::Foc_cpu_session_client cpu(Genode::env()->cpu_session_cap()); p->irq_cap = cpu.alloc_irq().dst(); 3. what's the purpose of multiplying the irq number by four in l4_msgtag_t ret = l4_irq_attach(p->irq_cap, data->irq << 2, l4x_cpu_thread_get_cap(p->cpu));? As far as I can see, in the base-foc irq implementation, irq number is never multiplied 4. non-genode question, probably. Do EHCI/PCI interrupts need a special kick to work? I've tried using Genode::Irq_session for irq11, but wait_for_irq never returns. On the other hand, I've tried the regular linux iso on the same machine (which is actually qemu) and the ehci interrupt is indeed 11 and it works fine there.
So, the question is, why is interrupt handling broken and the only working interrupt in l4linux is timer which actually uses L4 timer ipc instead of irq and how this should be fixed. Also, what do you think of making a "genode" arch for linux and getting rid of l4linux which uses the Fiasco.OC API bypassing Genode interfaces?