From 77d53f13ca1a6178b54870cb21888819089834a0 Mon Sep 17 00:00:00 2001 From: Sebastian Sumpf Date: Tue, 15 Oct 2024 15:33:15 +0200 Subject: [PATCH] lx_emul: handle pin controller irqs Register Global_irq_controller as Device so interrupts get forwarded to irqchip.c code. Otherwise, pin-controller interrupts will get lost. Fixed #5363 Related #5356 --- repos/dde_linux/src/include/lx_kit/device.h | 15 ++++++++++++++- repos/dde_linux/src/lib/lx_emul/pin.cc | 20 +++++++++++++++++--- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/repos/dde_linux/src/include/lx_kit/device.h b/repos/dde_linux/src/include/lx_kit/device.h index d54dcea977..affb640dd4 100644 --- a/repos/dde_linux/src/include/lx_kit/device.h +++ b/repos/dde_linux/src/include/lx_kit/device.h @@ -142,6 +142,16 @@ class Lx_kit::Device : List::Element void _for_each_clock(FN const & fn) { for (Clock * c = _clocks.first(); c; c = c->next()) fn(*c); } + protected: + + Device(Platform::Connection &plat, + Name name) + : + _platform(plat), _name(name), _type("") + { } + + virtual ~Device() { } + public: const char * compatible(); @@ -171,7 +181,8 @@ class Lx_kit::Device : List::Element bool irq_unmask(unsigned irq); void irq_mask(unsigned irq); void irq_ack(unsigned irq); - int pending_irq(); + + virtual int pending_irq(); bool read_config(unsigned reg, unsigned len, unsigned *val); bool write_config(unsigned reg, unsigned len, unsigned val); @@ -210,6 +221,8 @@ class Lx_kit::Device_list : List Device_list(Entrypoint & ep, Heap & heap, Platform::Connection & platform); + + void insert(Device const *device) { List::insert(device); } }; #endif /* _LX_KIT__DEVICE_H_ */ diff --git a/repos/dde_linux/src/lib/lx_emul/pin.cc b/repos/dde_linux/src/lib/lx_emul/pin.cc index 2b477d3b4a..0cb9796a2c 100644 --- a/repos/dde_linux/src/lib/lx_emul/pin.cc +++ b/repos/dde_linux/src/lib/lx_emul/pin.cc @@ -24,19 +24,25 @@ namespace { using namespace Genode; - class Global_irq_controller : Noncopyable + class Global_irq_controller : Lx_kit::Device, Noncopyable { private: Lx_kit::Env &_env; - unsigned _pending_irq = 0; + int _pending_irq { -1 }; public: struct Number { unsigned value; }; - Global_irq_controller(Lx_kit::Env &env) : _env(env) { } + Global_irq_controller(Lx_kit::Env &env) + : + Lx_kit::Device(env.platform, "pin_irq"), + _env(env) + { + _env.devices.insert(this); + } void trigger_irq(Number number) { @@ -45,6 +51,14 @@ namespace { _env.scheduler.unblock_irq_handler(); _env.scheduler.schedule(); } + + int pending_irq() override + { + int irq = _pending_irq; + _pending_irq = -1; + + return irq; + } }; using Pin_name = Session_label;