File indexing completed on 2024-05-26 04:05:35

0001 /*
0002     SPDX-FileCopyrightText: 2021 Alexey Minnekhanov <alexeymin@postmarketos.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #ifndef SOLID_BACKENDS_UDEV_CPUINFO_ARM_H
0008 #define SOLID_BACKENDS_UDEV_CPUINFO_ARM_H
0009 
0010 /**
0011  * Detect if we are compiling for ARM 32-bit or 64-bit platforms.
0012  * This works at least for gcc and clang (they both have the same
0013  * default list of defined macros, which can be obtained by:
0014  * - for clang: clang -dM -E - < /dev/null
0015  * - for gcc:  gcc -march=native -dM -E - </dev/null
0016  */
0017 
0018 #if defined(__arm__) || defined(__aarch64__) || defined(__ARM_ARCH) || defined(__ARM_EABI__)
0019 #define BUILDING_FOR_ARM_TARGET
0020 #endif
0021 
0022 // don't even build the following code for non-ARM platforms
0023 #ifdef BUILDING_FOR_ARM_TARGET
0024 
0025 #include <QString>
0026 
0027 namespace Solid
0028 {
0029 namespace Backends
0030 {
0031 namespace UDev
0032 {
0033 /**
0034  * @brief The ArmIdPart struct
0035  * Describes specfic CPU Model. Is used to
0036  * convert numerical CPU ID to name string.
0037  */
0038 struct ArmIdPart {
0039     const int id; //! CPU model ID; -1 means end of list
0040     const char *name; //! CPU human-readable name
0041 };
0042 
0043 struct ArmCpuImplementer {
0044     const int id; //! CPU vendor ID
0045     const struct ArmIdPart *parts; //! pointer to an array of parts, last elemnt will have ID -1
0046     const char *name; //! CPU vendor name
0047 };
0048 
0049 const ArmCpuImplementer *findArmCpuImplementer(int vendorId);
0050 QString findArmCpuModel(int vendorId, int modelId);
0051 
0052 } // namespace UDev
0053 } // namespace Backends
0054 } // namespace Solid
0055 
0056 #endif // BUILDING_FOR_ARM_TARGET
0057 
0058 #endif // SOLID_BACKENDS_UDEV_CPUINFO_ARM_H