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
This commit is contained in:
Sebastian Sumpf 2024-10-15 15:33:15 +02:00 committed by Christian Helmuth
parent a148dc5cb4
commit 77d53f13ca
2 changed files with 31 additions and 4 deletions

View File

@ -142,6 +142,16 @@ class Lx_kit::Device : List<Device>::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<Device>::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>
Device_list(Entrypoint & ep,
Heap & heap,
Platform::Connection & platform);
void insert(Device const *device) { List<Device>::insert(device); }
};
#endif /* _LX_KIT__DEVICE_H_ */

View File

@ -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;