implemented the get_cpuid() function in libroot and added a new kernel app 'cpuinfo'
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1582 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
SubDir OBOS_TOP src kernel libroot os arch x86 ;
|
||||
|
||||
KernelObjects atomic.S ;
|
||||
KernelObjects
|
||||
<$(SOURCE_GRIST)>atomic.S
|
||||
<$(SOURCE_GRIST)>cpuid.S
|
||||
:
|
||||
-fPIC -DPIC
|
||||
;
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
|
||||
** Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
|
||||
#define FUNCTION(x) .global x; .type x,@function; x
|
||||
|
||||
.text
|
||||
|
||||
/* void cpuid(unsigned int eax_value, unsigned int *return_data) */
|
||||
FUNCTION(cpuid):
|
||||
pushl %ebx
|
||||
pushl %edi
|
||||
movl 12(%esp),%eax /* first arg sets up eax */
|
||||
movl 16(%esp),%edi /* second arg points to the return area */
|
||||
cpuid
|
||||
movl %eax,0(%edi) /* copy the regs into the return area */
|
||||
movl %ebx,4(%edi) /* ... */
|
||||
movl %ecx,8(%edi) /* ... */
|
||||
movl %edx,12(%edi) /* ... */
|
||||
popl %edi
|
||||
popl %ebx
|
||||
ret
|
||||
|
||||
|
||||
/* unsigned int get_eflags(void) */
|
||||
FUNCTION(get_eflags):
|
||||
pushfl
|
||||
popl %eax
|
||||
ret
|
||||
|
||||
|
||||
/* void set_eflags(unsigned int val) */
|
||||
FUNCTION(set_eflags):
|
||||
pushl 4(%esp)
|
||||
popfl
|
||||
ret
|
||||
@@ -8,13 +8,61 @@
|
||||
#include "syscalls.h"
|
||||
|
||||
|
||||
#ifdef __INTEL__
|
||||
|
||||
// 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);
|
||||
|
||||
|
||||
/*
|
||||
* get_cpuid() -- uses the 'cpuid' instruction to retrieve information
|
||||
* about the computer make & model and the capabilities of the cpu(s)
|
||||
* ...this means the function is strictly INTEL PLATFORM ONLY!!!
|
||||
*
|
||||
* parameters:
|
||||
* info: out - the structure to hold the cpuid information
|
||||
* eax_register: in - the value to place in eax before invoking 'cpuid'
|
||||
* cpu_num: in - the number of the cpu to gather information about
|
||||
* (currently not used)
|
||||
*
|
||||
* Note: the stage2 bootloader already verifies at startup time that the
|
||||
* 'cpuid' instruction can be called by the host computer, so no checking
|
||||
* for this is done here.
|
||||
*/
|
||||
|
||||
status_t
|
||||
get_cpuid(cpuid_info *info, uint32 eax_register, uint32 cpu_num)
|
||||
{
|
||||
// ToDo: get_cpuid()
|
||||
return B_ERROR;
|
||||
unsigned int data[4];
|
||||
|
||||
// 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];
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
status_t
|
||||
_get_system_info(system_info *returned_info, size_t size)
|
||||
|
||||
Reference in New Issue
Block a user