| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2021 Alexey Minnekhanov <alexeymin@postmarketos.org> |
| 3 | |
| 4 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
| 5 | */ |
| 6 | |
| 7 | #ifndef SOLID_BACKENDS_UDEV_CPUINFO_ARM_H |
| 8 | #define SOLID_BACKENDS_UDEV_CPUINFO_ARM_H |
| 9 | |
| 10 | /*! |
| 11 | * Detect if we are compiling for ARM 32-bit or 64-bit platforms. |
| 12 | * This works at least for gcc and clang (they both have the same |
| 13 | * default list of defined macros, which can be obtained by: |
| 14 | * - for clang: clang -dM -E - < /dev/null |
| 15 | * - for gcc: gcc -march=native -dM -E - </dev/null |
| 16 | */ |
| 17 | |
| 18 | #if defined(__arm__) || defined(__aarch64__) || defined(__ARM_ARCH) || defined(__ARM_EABI__) |
| 19 | #define BUILDING_FOR_ARM_TARGET |
| 20 | #endif |
| 21 | |
| 22 | // don't even build the following code for non-ARM platforms |
| 23 | #ifdef BUILDING_FOR_ARM_TARGET |
| 24 | |
| 25 | #include <QString> |
| 26 | |
| 27 | namespace Solid |
| 28 | { |
| 29 | namespace Backends |
| 30 | { |
| 31 | namespace UDev |
| 32 | { |
| 33 | /*! |
| 34 | * @brief The ArmIdPart struct |
| 35 | * Describes specfic CPU Model. Is used to |
| 36 | * convert numerical CPU ID to name string. |
| 37 | */ |
| 38 | struct ArmIdPart { |
| 39 | const int id; //! CPU model ID; -1 means end of list |
| 40 | const char *name; //! CPU human-readable name |
| 41 | }; |
| 42 | |
| 43 | struct ArmCpuImplementer { |
| 44 | const int id; //! CPU vendor ID |
| 45 | const struct ArmIdPart *parts; //! pointer to an array of parts, last elemnt will have ID -1 |
| 46 | const char *name; //! CPU vendor name |
| 47 | }; |
| 48 | |
| 49 | const ArmCpuImplementer *findArmCpuImplementer(int vendorId); |
| 50 | QString findArmCpuModel(int vendorId, int modelId); |
| 51 | |
| 52 | } // namespace UDev |
| 53 | } // namespace Backends |
| 54 | } // namespace Solid |
| 55 | |
| 56 | #endif // BUILDING_FOR_ARM_TARGET |
| 57 | |
| 58 | #endif // SOLID_BACKENDS_UDEV_CPUINFO_ARM_H |
| 59 | |