From 8fa03f6c419f658a5c5bf7595e531573ce7d5968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 30 Mar 2004 13:02:49 +0000 Subject: [PATCH] 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 --- src/kernel/libroot/os/arch/x86/systeminfo.c | 30 ++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/kernel/libroot/os/arch/x86/systeminfo.c b/src/kernel/libroot/os/arch/x86/systeminfo.c index 6b53bbf86d..65a7dcd7de 100644 --- a/src/kernel/libroot/os/arch/x86/systeminfo.c +++ b/src/kernel/libroot/os/arch/x86/systeminfo.c @@ -1,5 +1,5 @@ /* -** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Copyright 2003-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. ** 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 // 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 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 cpuid(eax_register, data); - + // fill the info struct with the return values info->regs.eax = data[0]; info->regs.ebx = data[1]; info->regs.ecx = data[2]; info->regs.edx = data[3]; - + if (eax_register == 0) { // fixups for this special case char *vendor = info->eax_0.vendorid; - + // the high-order word is non-zero on some Cyrix CPUs info->eax_0.max_eax = data[0] & 0xffff; - + // the vendor string bytes need a little re-ordering - *((unsigned int *) &vendor[0]) = data[1]; - *((unsigned int *) &vendor[4]) = data[3]; - *((unsigned int *) &vendor[8]) = data[2]; + *((uint32 *)&vendor[0]) = data[1]; + *((uint32 *)&vendor[4]) = data[3]; + *((uint32 *)&vendor[8]) = data[2]; } - + return B_OK; }