aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / native / kernel / core / cpufeat.h
| 1 | /* SPDX-License-Identifier: Apache-2.0 |
| 2 | * Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | /* cpufeat.h -- CPU feature decode from the Arm ID registers (pure function). |
| 18 | * |
| 19 | * Field positions (quoted from Linux arch/arm64/tools/sysreg, which |
| 20 | * transcribes the Arm ARM DDI0487 register pages; the Arm ARM PDF itself was |
| 21 | * not available offline here): |
| 22 | * ID_AA64ISAR0_EL1: RNDR [63:60], FHM [51:48], DP [47:44] |
| 23 | * ID_AA64ISAR1_EL1: I8MM [55:52], BF16 [47:44] |
| 24 | * ID_AA64PFR0_EL1: SVE [35:32] (unsigned), AdvSIMD [23:20] and FP [19:16] |
| 25 | * (signed; 0b1111 = not implemented, 0b0001 = with FP16) |
| 26 | * dotprod = DP >= 1. i8mm = I8MM >= 1. fp16 = FP >= 1 && AdvSIMD >= 1 (signed |
| 27 | * compare, so 0xf is "absent"). sve = SVE >= 1. rndr = RNDR >= 1. |
| 28 | * Reads only the boot core's registers; per-core comparison is not done. */ |
| 29 | #ifndef AIENOS_CK_CPUFEAT_H |
| 30 | #define AIENOS_CK_CPUFEAT_H |
| 31 | |
| 32 | #include <stddef.h> |
| 33 | #include <stdint.h> |
| 34 | |
| 35 | struct ck_cpu_features { |
| 36 | unsigned dotprod, i8mm, bf16, fhm, fp16, sve, rndr; |
| 37 | }; |
| 38 | |
| 39 | void ck_cpufeat_decode(uint64_t isar0, uint64_t isar1, uint64_t pfr0, struct ck_cpu_features *out); |
| 40 | /* "cpu_features: dotprod=1 i8mm=0 bf16=0 fhm=1 fp16=1 sve=0 rndr=0" (no newline). */ |
| 41 | int ck_cpufeat_format(const struct ck_cpu_features *f, char *buf, size_t n); |
| 42 | /* Record / read the boot core's decode (all zero until recorded). */ |
| 43 | void ck_cpufeat_set_boot(const struct ck_cpu_features *f); |
| 44 | const struct ck_cpu_features *ck_cpufeat_boot(void); |
| 45 | |
| 46 | #endif |