ZXFoundation™ 26h2
Loading...
Searching...
No Matches
consts.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.consts;
6import zxfoundation.base.types;
7
8export {
9
10namespace zxfoundation::sys::irq {
11
12 constexpr u16 IRQ_NR_MAX = 0x0400; ///< Total vector slots (1024).
13 constexpr u16 IRQ_BASE_PGM = 0x0000; ///< Program-check vectors.
14 constexpr u16 IRQ_BASE_EXT = 0x0100; ///< External-interrupt vectors.
15 constexpr u16 IRQ_BASE_IO = 0x0200; ///< I/O interrupt vectors.
16 constexpr u16 IRQ_BASE_MCCK = 0x0300; ///< Machine-check vectors.
17
18 constexpr u32 IRQF_SHARED = 1U << 0; ///< Allow multiple registrations.
19 constexpr u32 IRQF_DISABLED = 1U << 1; ///< Handler runs with IRQs off.
20 constexpr u32 IRQF_NOAUTOEN = 1U << 2; ///< Don't auto-enable CR0 subclass.
21 constexpr u32 IRQF_FAST = 1U << 3; ///< Hot path -- bypass descriptor lock.
22
23 /// @brief External-interrupt sub-offsets within the @c IRQ_BASE_EXT range.
24 /// @note Offsets consume IRQ_BASE_EXT+(MAX)=0x010C and must remain
25 /// < 0x0100 to stay in the EXT span.
26 enum class ext_irq_slot : u16 {
27 EMERGENCY_SIGNAL = 0x01, ///< 0x1201 — IPI emergency signal.
28 EXTERNAL_CALL = 0x02, ///< 0x1202 — IPI external call (Linux reschedule / call_function).
29 SERVICE_SIGNAL = 0x03, ///< 0x2401 — SCLP service signal.
30 CP_SERVICE = 0x04, ///< 0x2603 — CP service (pfault) event.
31 CPU_TIMER = 0x05, ///< 0x1005 — CPU-timer quantum expiry.
32 CLOCK_COMPARATOR = 0x06, ///< 0x1004 — clock-comparator timer.
33 TIMING_ALERT = 0x07, ///< 0x1406 — STP timing alert.
34 MALFUNCTION_ALERT = 0x08, ///< 0x1200 — malfunction-alert IPI.
35 WARNING_TRACK = 0x09, ///< 0x1007 — warning-track STP/EAD.
36 MEASUREMENT_ALERT = 0x0A, ///< 0x1407 — CPU-MF measurement alert.
37 INTERRUPT_KEY = 0x0B, ///< 0x0040 — external-interrupt-key press.
38 };
39
40 /// @brief Constructor conveniences mirroring the @c ext_irq_slot enum.
41 /// @{
42 constexpr u16 EXT_IRQ_EMERGENCY_SIGNAL = static_cast<u16>(ext_irq_slot::EMERGENCY_SIGNAL);
43 constexpr u16 EXT_IRQ_EXTERNAL_CALL = static_cast<u16>(ext_irq_slot::EXTERNAL_CALL);
44 constexpr u16 EXT_IRQ_SERVICE_SIGNAL = static_cast<u16>(ext_irq_slot::SERVICE_SIGNAL);
45 constexpr u16 EXT_IRQ_CP_SERVICE = static_cast<u16>(ext_irq_slot::CP_SERVICE);
46 constexpr u16 EXT_IRQ_CPU_TIMER = static_cast<u16>(ext_irq_slot::CPU_TIMER);
47 constexpr u16 EXT_IRQ_CLOCK_COMPARATOR = static_cast<u16>(ext_irq_slot::CLOCK_COMPARATOR);
48 constexpr u16 EXT_IRQ_TIMING_ALERT = static_cast<u16>(ext_irq_slot::TIMING_ALERT);
49 constexpr u16 EXT_IRQ_MALFUNCTION_ALERT = static_cast<u16>(ext_irq_slot::MALFUNCTION_ALERT);
50 constexpr u16 EXT_IRQ_WARNING_TRACK = static_cast<u16>(ext_irq_slot::WARNING_TRACK);
51 constexpr u16 EXT_IRQ_MEASUREMENT_ALERT= static_cast<u16>(ext_irq_slot::MEASUREMENT_ALERT);
52 constexpr u16 EXT_IRQ_INTERRUPT_KEY = static_cast<u16>(ext_irq_slot::INTERRUPT_KEY);
53 /// @}
54
55 /// @brief Resolve a raw z/Architecture external-interruption code to its
56 /// IRQ table slot within the @c IRQ_BASE_EXT range.
57 [[nodiscard]] constexpr auto ext_code_to_irq(u16 ext_code) noexcept -> u16 {
58 switch (ext_code) {
59 case 0x1201: return IRQ_BASE_EXT + EXT_IRQ_EMERGENCY_SIGNAL;
60 case 0x1202: return IRQ_BASE_EXT + EXT_IRQ_EXTERNAL_CALL;
61 case 0x2401: return IRQ_BASE_EXT + EXT_IRQ_SERVICE_SIGNAL;
62 case 0x2603: return IRQ_BASE_EXT + EXT_IRQ_CP_SERVICE;
63 case 0x1005: return IRQ_BASE_EXT + EXT_IRQ_CPU_TIMER;
64 case 0x1004: return IRQ_BASE_EXT + EXT_IRQ_CLOCK_COMPARATOR;
65 case 0x1406: return IRQ_BASE_EXT + EXT_IRQ_TIMING_ALERT;
66 case 0x1200: return IRQ_BASE_EXT + EXT_IRQ_MALFUNCTION_ALERT;
67 case 0x1007: return IRQ_BASE_EXT + EXT_IRQ_WARNING_TRACK;
68 case 0x1407: return IRQ_BASE_EXT + EXT_IRQ_MEASUREMENT_ALERT;
69 case 0x0040: return IRQ_BASE_EXT + EXT_IRQ_INTERRUPT_KEY;
70 default: return IRQ_NR_MAX;
71 }
72 }
73
74 /// @brief Deferred-work bit indices held in the per-CPU
75 /// @c percpu::s390x_percpu_data::deferred_pending field.
76 /// @{
77 constexpr u32 DEFERRED_IRQ_WORK = 0; ///< Subsystem / RCU / timers scheduling.
78 constexpr u32 DEFERRED_CALL_FUNCTION = 1; ///< Cross-CPU function-call IPI.
79 constexpr u32 DEFERRED_MCCK_PENDING = 2; ///< Deferred (non-fatal) machine-check work.
80 constexpr u32 DEFERRED_RESCHED = 3; ///< Reschedule request (Linux "need_resched" IPI).
81 constexpr u32 DEFERRED_STOP_CPU = 4; ///< Cooperative CPU-offline request.
82
83 constexpr u32 DEFERRED_IRQ_WORK_BIT = 1U << DEFERRED_IRQ_WORK;
84 constexpr u32 DEFERRED_CALL_FUNCTION_BIT = 1U << DEFERRED_CALL_FUNCTION;
85 constexpr u32 DEFERRED_MCCK_PENDING_BIT = 1U << DEFERRED_MCCK_PENDING;
86 constexpr u32 DEFERRED_RESCHED_BIT = 1U << DEFERRED_RESCHED;
87 constexpr u32 DEFERRED_STOP_CPU_BIT = 1U << DEFERRED_STOP_CPU;
88 /// @}
89
90} // namespace zxfoundation::sys::irq
91
92} // end export