diff options
| author | Alexey Gavrilov <alexey.gavrilov@mail.com> | 2025-12-01 21:40:49 +0700 |
|---|---|---|
| committer | Alexey Gavrilov <alexey.gavrilov@mail.com> | 2025-12-01 21:40:49 +0700 |
| commit | 75ef20c5889005758ed8c30c3279954f16529a16 (patch) | |
| tree | 16c5b061163d48e9752db022544592ff1c2337e2 /kernel | |
| parent | 5d3179d0e2c3915af65dedef0952672220ac4714 (diff) | |
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 <alexey.gavrilov@mail.com>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/details/Platform.h | 49 |
1 files changed, 49 insertions, 0 deletions
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<typename T> + 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 |
