6export module arch.s390x.cpu.features;
7import zxfoundation.base.types;
13namespace arch::s390x::cpu::features {
17 enum class facility : u32 {
22 idte_segment_clear = 4,
23 idte_region_clear = 5,
29 configuration_topology = 11,
32 nonquiescing_key_setting = 14,
33 ap_facility_test = 15,
34 extended_translation_2 = 16,
36 long_displacement = 18,
37 long_displacement_hi_perf = 19,
40 extended_translation_3 = 22,
42 etf2_enhancement = 24,
43 store_clock_fast = 25,
44 parsing_enhancement = 26,
46 tod_clock_steering = 28,
47 etf3_enhancement = 30,
48 extract_cpu_time = 31,
49 cmp_swap_and_store = 32,
50 cmp_swap_and_store_2 = 33,
53 enhanced_monitor = 36,
55 order_preserving_compression= 38,
56 load_program_params = 40,
59 dfp_high_performance = 43,
61 distinct_operands = 45,
62 cmpsc_enhancement = 47,
63 decimal_fp_zoned_conversion = 48,
66 local_tlb_clearing = 51,
67 interlocked_access_2 = 52,
68 load_store_on_cond_2 = 53,
69 entropy_encoding_compression= 54,
73 reset_ref_bits_multiple = 66,
74 cpu_meas_counter = 67,
75 cpu_meas_sampling = 68,
76 transactional_exec = 73,
77 store_hypervisor_info = 74,
78 access_exc_fetch_store_ind = 75,
82 dfp_packed_conversion = 80,
85 sequential_inst_fetching = 85,
89 instruction_exec_protection = 130,
90 side_effect_access = 131,
91 guarded_storage = 133,
92 vector_packed_decimal = 134,
94 config_zarch_arch_mode = 138,
96 store_cpu_counter_multiple = 142,
97 test_pending_ext_int = 144,
98 insert_ref_bits_multiple = 145,
101 move_page_and_set_key = 149,
103 deflate_conversion = 151,
104 vector_packed_decimal_enh = 152,
106 ultravisor_call = 158,
107 secure_execution_unpack = 161,
109 esa390_compat_mode = 168,
111 ineff_nonconstrained_transaction = 170,
112 vector_packed_decimal_2 = 192,
114 reset_dat_protection = 194,
115 proc_activity_inst = 196,
116 proc_activity_inst_ext1 = 197,
117 vector_enhancements_3 = 198,
118 vector_packed_decimal_3 = 199,
119 concurrent_funcs = 201,
122 constexpr auto STFLE_MAX_DWORDS = 32;
127 template <usize Extent = STFLE_MAX_DWORDS>
128 requires (Extent > 0 && Extent <= STFLE_MAX_DWORDS)
129 auto detect(std::span<u64, Extent> fac_list)
noexcept -> std::expected<u32, lib::kernel_error> {
131 std::fill(fac_list.begin(), fac_list.end(), 0ULL);
133 register u64 r0
__asm__(
"0") = fac_list.size() - 1U;
134 register u64 r1
__asm__(
"1") =
reinterpret_cast<u64>(fac_list.data());
138 " .insn s,0xb2b00000,0(%[addr])\n"
141 : [cc]
"=d" (cc),
"+d" (r0)
146 if (cc == 3) [[unlikely]] {
147 return std::unexpected(lib::kernel_error::from_arch(lib::arch_error::code::stfle_failed));
150 return static_cast<u32>(r0 + 1U);
155 auto init(std::optional<
const u64*> stfle_fac)
noexcept ->
void;
158 [[nodiscard]]
auto has(facility f)
noexcept ->
bool;
161 [[nodiscard]]
auto has_raw(u32 bit)
noexcept ->
bool;
164 auto enable_hardware_facilities()
noexcept ->
void;