Library call for cpu features; make kernel and vm use this to query cpu
features (specifically: 4MB pages and TLB global bit). Only enable these features in CR4 if available. 4MB pages to be used in the near future.
This commit is contained in:
@@ -6,6 +6,7 @@ LIBRARIES=libc
|
||||
|
||||
libc_FILES=" \
|
||||
_cpuid.s \
|
||||
_cpufeature.c \
|
||||
alloca.s \
|
||||
get_bp.s \
|
||||
getprocessor.s \
|
||||
|
||||
34
lib/i386/misc/_cpufeature.c
Normal file
34
lib/i386/misc/_cpufeature.c
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <minix/minlib.h>
|
||||
#include <minix/cpufeature.h>
|
||||
#include <sys/vm_i386.h>
|
||||
|
||||
int _cpufeature(int cpufeature)
|
||||
{
|
||||
u32_t cpuid_feature_edx = 0;
|
||||
int proc;
|
||||
|
||||
proc = getprocessor();
|
||||
|
||||
/* If processor supports CPUID and its CPUID supports enough
|
||||
* parameters, retrieve EDX feature flags to test against.
|
||||
*/
|
||||
if(proc >= 586) {
|
||||
u32_t params, a, b, c, d;
|
||||
_cpuid(0, ¶ms, &b, &c, &d);
|
||||
if(params > 0) {
|
||||
_cpuid(1, &a, &b, &c, &cpuid_feature_edx);
|
||||
}
|
||||
}
|
||||
|
||||
switch(cpufeature) {
|
||||
case _CPUF_I386_PSE:
|
||||
return cpuid_feature_edx & CPUID1_EDX_PSE;
|
||||
case _CPUF_I386_PGE:
|
||||
return cpuid_feature_edx & CPUID1_EDX_PGE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user