put something in cpuinfo
This commit is contained in:
parent
2ab344f847
commit
527661b03e
@ -219,8 +219,41 @@ static fs_node_t * procfs_procdir_create(process_t * process) {
|
||||
return fnode;
|
||||
}
|
||||
|
||||
#define cpuid(in,a,b,c,d) do { asm volatile ("cpuid" : "=a"(a),"=b"(b),"=c"(c),"=d"(d) : "a"(in)); } while(0)
|
||||
|
||||
static uint32_t cpuinfo_func(fs_node_t *node, uint32_t offset, uint32_t size, uint8_t *buffer) {
|
||||
return 0;
|
||||
char buf[1024];
|
||||
|
||||
unsigned long a, b, unused;;
|
||||
cpuid(0,unused,b,unused,unused);
|
||||
|
||||
char * _manu = "Unknown";
|
||||
int _model = 0, _family = 0;
|
||||
|
||||
if (b == 0x756e6547) {
|
||||
cpuid(1, a, b, unused, unused);
|
||||
_manu = "Intel";
|
||||
_model = (a >> 4) & 0x0F;
|
||||
_family = (a >> 8) & 0x0F;
|
||||
} else if (b == 0x68747541) {
|
||||
cpuid(1, a, unused, unused, unused);
|
||||
_manu = "AMD";
|
||||
_model = (a >> 4) & 0x0F;
|
||||
_family = (a >> 8) & 0x0F;
|
||||
}
|
||||
|
||||
sprintf(buf,
|
||||
"Manufacturer: %s\n"
|
||||
"Family: %d\n"
|
||||
"Model: %d\n"
|
||||
, _manu, _family, _model);
|
||||
|
||||
size_t _bsize = strlen(buf);
|
||||
if (offset > _bsize) return 0;
|
||||
if (size > _bsize - offset) size = _bsize - offset;
|
||||
|
||||
memcpy(buffer, buf + offset, size);
|
||||
return size;
|
||||
}
|
||||
|
||||
extern uintptr_t heap_end;
|
||||
|
Loading…
Reference in New Issue
Block a user