Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
/* Project:     OSLib
2
 * Description: The OS Construction Kit
3
 * Date:                1.6.2000
4
 * Idea by:             Luca Abeni & Gerardo Lamastra
5
 *
6
 * OSLib is an SO project aimed at developing a common, easy-to-use
7
 * low-level infrastructure for developing OS kernels and Embedded
8
 * Applications; it partially derives from the HARTIK project but it
9
 * currently is independently developed.
10
 *
11
 * OSLib is distributed under GPL License, and some of its code has
12
 * been derived from the Linux kernel source; also some important
13
 * ideas come from studying the DJGPP go32 extender.
14
 *
15
 * We acknowledge the Linux Community, Free Software Foundation,
16
 * D.J. Delorie and all the other developers who believe in the
17
 * freedom of software and ideas.
18
 *
19
 * For legalese, check out the included GPL license.
20
 */
21
 
22
/*      CPU detection code      */
23
 
24
#include <ll/i386/hw-data.h>
25
#include <ll/i386/hw-arch.h>
26
#include <ll/i386/mem.h>
27
 
28
FILE(Cpu - C);
29
 
30
INLINE_OP void cpuid(DWORD a, DWORD * outa, DWORD * outb, DWORD * outc,
31
                     DWORD * outd)
32
{
33
#ifdef __OLD_GNU__
34
    __asm__ __volatile__(".byte 0x0F,0xA2"
35
#else
36
    __asm__ __volatile__("cpuid"
37
#endif
38
                         :"=a"(*outa),
39
                         "=b"(*outb), "=c"(*outc), "=d"(*outd):"a"(a));
40
}
41
 
42
void X86_get_CPU(struct ll_cpuInfo *p)
43
{
44
    DWORD tmp;
45
 
46
    memset(p, 0, sizeof(struct ll_cpuInfo));
47
    if (X86_is386()) {
48
        p->X86_cpu = 3;
49
 
50
        return;
51
    }
52
    if (X86_hasCPUID()) {
53
        p->X86_cpuIdFlag = 1;
54
        p->X86_cpu = 5;
55
        cpuid(0, &tmp, &(p->X86_vendor_1),
56
              &(p->X86_vendor_3), &(p->X86_vendor_2));
57
        if (tmp >= 1) {
58
            cpuid(1, &(p->X86_signature),
59
                  &(p->X86_IntelFeature_1),
60
                  &(p->X86_IntelFeature_2), &(p->X86_StandardFeature));
61
        }
62
    } else {
63
        p->X86_cpu = 4;
64
        if (X86_isCyrix()) {
65
            /* Err... Adjust IT!!!! */
66
            p->X86_cpu = 11;
67
        }
68
        /* Need tests for AMD and others... */
69
    }
70
}