From 75ef20c5889005758ed8c30c3279954f16529a16 Mon Sep 17 00:00:00 2001 From: Alexey Gavrilov Date: Mon, 1 Dec 2025 21:40:49 +0700 Subject: Refactoring cpuid model interaction Patch for support CPU identification feature. Model smash on two pieces: platform-independent and dependent accordingly. The first obtains architecture details from CPU by special registers or execute instruction and filling proper structure. The second piece needs for more universality to use in independent code. Currently, platform-independent part supports only x86 cpuid(0h,01h) leafs. Signed-off-by: Alexey Gavrilov --- kernel/details/Platform.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 kernel/details/Platform.h (limited to 'kernel/details/Platform.h') diff --git a/kernel/details/Platform.h b/kernel/details/Platform.h new file mode 100644 index 0000000..12a8353 --- /dev/null +++ b/kernel/details/Platform.h @@ -0,0 +1,49 @@ +#ifndef PLATHFORMDETAILS_H +#define PLATHFORMDETAILS_H + + +namespace cpuid +{ + +/** + * Platform independent class to acquire processor details + */ +class Executor +{ + bool isCpuidAvailable; +public: + /** + * Standard constructor of Executor class + * + * @note Must be declare in platform depended part of code by path + * `arch/{architecture}/cpuid/`. + */ + Executor(); + + /** + * Perform cpuid command + * + * @tparam T the type posed processor details by one kind + * @param[out] instance to fill the details + */ + template + void cpuid(T &cmd) + { + if(isCpuidAvailable) + { + acquireInformation(cmd); + } + } + + /** + * Availability of cpuid command + * + * @return true if cpuid command would execute, + * false otherwise + */ + bool isCpuidWouldExecute() {return isCpuidAvailable;}; +}; + +}; + +#endif -- cgit v1.2.3