diff options
author | Erwan Velu <erwanaliasr1@gmail.com> | 2011-03-21 21:23:56 +0100 |
---|---|---|
committer | Erwan Velu <erwanaliasr1@gmail.com> | 2011-03-21 21:23:56 +0100 |
commit | e35490fd9cfeace884bcea91a138f23cc11f934c (patch) | |
tree | 5122ac183fe8f056440eba42dc62aa6058d0829c /com32/gpllib | |
parent | 5b3160784fba34a69f4dcc3d433afc893fc552e5 (diff) | |
download | syslinux-e35490fd9cfeace884bcea91a138f23cc11f934c.tar.gz |
cpuid: Enable cpu flags members parsing
This patch allow a program to parse the list of the cpu flags and
retrieve its values, name & comments.
I'd like to thank Shao Miller for helping me doing this code. He was
really helpful and a good support. Thx Shao !
Diffstat (limited to 'com32/gpllib')
-rw-r--r-- | com32/gpllib/cpuid.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/com32/gpllib/cpuid.c b/com32/gpllib/cpuid.c index fb9323b6..3d62541a 100644 --- a/com32/gpllib/cpuid.c +++ b/com32/gpllib/cpuid.c @@ -20,8 +20,31 @@ #include <string.h> #include "cpuid.h" +const char *cpu_flags_names[] = { + CPU_FLAGS(STRUCT_MEMBER_NAMES) +}; + +size_t cpu_flags_offset[] = { + CPU_FLAGS(STRUCTURE_MEMBER_OFFSETS) +}; + +size_t cpu_flags_count = sizeof cpu_flags_names / sizeof *cpu_flags_names; + struct cpu_dev *cpu_devs[X86_VENDOR_NUM] = { }; +bool get_cpu_flag_value_from_name(s_cpu *cpu, const char * flag_name) { + size_t i;; + bool *flag=false; + + for (i = 0; i < cpu_flags_count; i++) { + if (strcmp(cpu_flags_names[i],flag_name) == 0) { + flag = (bool *)((char *)&cpu->flags + cpu_flags_offset[i]); + } + } + return *flag; +} + + /* * CPUID functions returning a single datum */ |