Added a ToDo comment about how to correctly implement get_cpuid().

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7121 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2004-03-30 13:02:49 +00:00
parent 0f197ce81a
commit 8fa03f6c41
+18 -12
View File
@@ -1,5 +1,5 @@
/* /*
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved. ** Copyright 2003-2004, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the OpenBeOS License. ** Distributed under the terms of the OpenBeOS License.
*/ */
@@ -9,7 +9,7 @@
// this declaration could be placed in a header file somewhere, but it doesn't // this declaration could be placed in a header file somewhere, but it doesn't
// appear likely that any user functions besides 'get_cpuid()' would need it... // appear likely that any user functions besides 'get_cpuid()' would need it...
void cpuid(unsigned int selector, unsigned int *data); void cpuid(uint32 selector, uint32 *data);
/* /*
@@ -31,30 +31,36 @@ void cpuid(unsigned int selector, unsigned int *data);
status_t status_t
get_cpuid(cpuid_info *info, uint32 eax_register, uint32 cpu_num) get_cpuid(cpuid_info *info, uint32 eax_register, uint32 cpu_num)
{ {
unsigned int data[4]; uint32 data[4];
// ToDo: cpu_num is ignored, it's probably best fixed by introducing
// a syscall for this function and use the call_all_cpus() function
// inside the kernel.
// ToDo: the cpuid() and set_eflags()/get_eflags() shouldn't clobber
// the global namespace.
// call the instruction // call the instruction
cpuid(eax_register, data); cpuid(eax_register, data);
// fill the info struct with the return values // fill the info struct with the return values
info->regs.eax = data[0]; info->regs.eax = data[0];
info->regs.ebx = data[1]; info->regs.ebx = data[1];
info->regs.ecx = data[2]; info->regs.ecx = data[2];
info->regs.edx = data[3]; info->regs.edx = data[3];
if (eax_register == 0) { if (eax_register == 0) {
// fixups for this special case // fixups for this special case
char *vendor = info->eax_0.vendorid; char *vendor = info->eax_0.vendorid;
// the high-order word is non-zero on some Cyrix CPUs // the high-order word is non-zero on some Cyrix CPUs
info->eax_0.max_eax = data[0] & 0xffff; info->eax_0.max_eax = data[0] & 0xffff;
// the vendor string bytes need a little re-ordering // the vendor string bytes need a little re-ordering
*((unsigned int *) &vendor[0]) = data[1]; *((uint32 *)&vendor[0]) = data[1];
*((unsigned int *) &vendor[4]) = data[3]; *((uint32 *)&vendor[4]) = data[3];
*((unsigned int *) &vendor[8]) = data[2]; *((uint32 *)&vendor[8]) = data[2];
} }
return B_OK; return B_OK;
} }