ZXFoundation™ 26h2
Loading...
Searching...
No Matches
desc.cxxm
1/// SPDX-License-Identifier: Apache-2.0
2/// @file zxfoundation/sys/irq.zcomponent/irqdesc.cxxm
3/// @brief Generic IRQ descriptor table
4
5export module zxfoundation.sys.irq.desc;
6import zxfoundation.sys.irq.core;
7import zxfoundation.base.types;
8import zxfoundation.scoms.kobject.base;
9import zxfoundation.sync.qspinlock.core;
10import arch.s390x.cpu.irq;
11import lib.error;
12import std;
13
14export {
15
16namespace zxfoundation::sys::irq {
17
18 /// @brief IRQ descriptor — SCOMS-managed kobject, one per active vector.
19 struct irq_desc {
20 scoms::kobject::bobject ko{}; ///< SCOMS identity (offset 0).
21
22 handler_fn handler{nullptr}; ///< Dispatch target.
23 void* data{nullptr}; ///< Handler-private context.
24 u32 flags{0}; ///< IRQF_* bitmask.
25 u16 irq_nr{0}; ///< Vector number.
26
27 std::atomic<u32> count{0}; ///< Dispatch count (relaxed).
28 sync::qspinlock::qspinlock lock{};
29
30 irq_desc() noexcept = default;
31
32 explicit irq_desc(u16 irq) noexcept
33 : irq_nr(irq) {}
34
35 [[nodiscard]] auto registered() const noexcept -> bool {
36 return handler != nullptr;
37 }
38
39 irq_desc(const irq_desc&) = delete;
40 auto operator=(const irq_desc&) = delete;
41 irq_desc(irq_desc&&) = delete;
42 auto operator=(irq_desc&&) = delete;
43 };
44
45 static_assert(__builtin_offsetof(irq_desc, ko) == 0,
46 "irq_desc::ko must be at offset 0 for SCOMS scoms_table");
47
48 [[nodiscard]] auto irq_get_desc(u16 irq) noexcept -> irq_desc*;
49
50} // namespace zxfoundation::sys::irq
51
52} // end export