Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
0e528772
Commit
0e528772
authored
Nov 07, 2013
by
Ahmed Samy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cpuid: better parser for processor info
Signed-off-by:
Ahmed Samy
<
f.fallen45@gmail.com
>
parent
efd79fad
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
13 deletions
+22
-13
ccan/cpuid/cpuid.c
ccan/cpuid/cpuid.c
+10
-4
ccan/cpuid/cpuid.h
ccan/cpuid/cpuid.h
+7
-9
ccan/cpuid/test/run.c
ccan/cpuid/test/run.c
+5
-0
No files found.
ccan/cpuid/cpuid.c
View file @
0e528772
...
...
@@ -29,6 +29,7 @@
#include "cpuid.h"
#include <string.h>
#include <stdio.h>
enum
{
CPU_PROC_BRAND_STRING_INTERNAL0
=
0x80000003
,
...
...
@@ -309,10 +310,15 @@ void cpuid(cpuid_t info, uint32_t *buf)
buf
[
2
]
=
ecx
;
break
;
case
CPU_PROCINFO_AND_FEATUREBITS
:
buf
[
0
]
=
eax
;
/* The so called "signature" of the CPU. */
buf
[
1
]
=
edx
;
/* Feature flags #1. */
buf
[
2
]
=
ecx
;
/* Feature flags #2. */
buf
[
3
]
=
ebx
;
/* Additional feature information. */
buf
[
0
]
=
(
eax
&
0x0F
);
/* Stepping */
buf
[
1
]
=
(
eax
>>
4
)
&
0x0F
;
/* Model */
buf
[
2
]
=
(
eax
>>
8
)
&
0x0F
;
/* Family */
buf
[
3
]
=
(
eax
>>
16
)
&
0x0F
;
/* Extended Model. */
buf
[
4
]
=
(
eax
>>
24
)
&
0x0F
;
/* Extended Family. */
buf
[
5
]
=
edx
;
/* Feature flags #1. */
buf
[
6
]
=
ecx
;
/* Feature flags #2. */
buf
[
7
]
=
ebx
;
/* Additional feature information. */
break
;
case
CPU_CACHE_AND_TLBD_INFO
:
buf
[
0
]
=
eax
;
...
...
ccan/cpuid/cpuid.h
View file @
0e528772
...
...
@@ -173,16 +173,14 @@ uint32_t cpuid_highest_ext_func_supported(void);
* Returns a string into buf.
*
* For CPU_PROCINFO_AND_FEATUREBITS:
* buf[0]:
* - 3:0 - Stepping
* - 7:4 - Model
* - 11:8 - Family
* - 13:12 - Processor Type
* - 19:16 - Extended Model
* - 27:20 - Extended family
* buf[1] and buf[2]:
* buf[0]: Stepping
* buf[1]: Model
* buf[2]: Family
* buf[3]: Extended Model
* buf[4]: Extended Family
* buf[5] and buf[6]:
* Feature flags
* buf[
3
]:
* buf[
7
]:
* Additional feature information.
*
* For CPU_L1_CACHE_AND_TLB_IDS:
...
...
ccan/cpuid/test/run.c
View file @
0e528772
...
...
@@ -18,6 +18,11 @@ int main(void)
cpuid
(
CPU_PROC_BRAND_STRING
,
(
uint32_t
*
)
buf
);
printf
(
"Processor Brand: %s
\n
"
,
buf
);
uint32_t
procinfo
[
8
];
cpuid
(
CPU_PROCINFO_AND_FEATUREBITS
,
procinfo
);
printf
(
"Stepping: %d Model: 0x%X Family: %d extended model: %d extended family: %d
\n
"
,
procinfo
[
0
],
procinfo
[
1
],
procinfo
[
2
],
procinfo
[
3
],
procinfo
[
4
]);
printf
(
"Highest extended function supported: %#010x
\n
"
,
cpuid_highest_ext_func_supported
());
uint32_t
phys_virt
[
2
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment