Subversion Repositories shark

Rev

Rev 3 | Details | Compare with Previous | 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
 
40 pj 28
FILE(Cpu-C);
2 pj 29
 
40 pj 30
INLINE_OP void cpuid(DWORD a, DWORD *outa, DWORD *outb, DWORD *outc, DWORD *outd)
2 pj 31
{
32
#ifdef __OLD_GNU__
40 pj 33
    __asm__ __volatile__ (".byte 0x0F,0xA2"
2 pj 34
#else
40 pj 35
    __asm__ __volatile__ ("cpuid"
2 pj 36
#endif
40 pj 37
    : "=a" (*outa),
38
      "=b" (*outb),
39
      "=c" (*outc),
40
      "=d" (*outd)
41
    : "a"  (a));
2 pj 42
}
43
 
44
void X86_get_CPU(struct ll_cpuInfo *p)
45
{
40 pj 46
        DWORD tmp;
2 pj 47
 
40 pj 48
        memset(p, 0, sizeof(struct ll_cpuInfo));
49
        if (X86_is386()) {
50
                p->X86_cpu = 3;
51
 
52
                return;
2 pj 53
        }
40 pj 54
        if (X86_hasCPUID()) {
55
                p->X86_cpuIdFlag = 1;
56
                p->X86_cpu = 5;
57
                cpuid(0, &tmp, &(p->X86_vendor_1),
58
                                &(p->X86_vendor_3),
59
                                &(p->X86_vendor_2));
60
                if (tmp >= 1) {
61
                        cpuid(1, &(p->X86_signature),
62
                                &(p->X86_IntelFeature_1),
63
                                &(p->X86_IntelFeature_2),
64
                                &(p->X86_StandardFeature));
65
                }
66
        } else {
67
                p->X86_cpu = 4;
68
                if (X86_isCyrix()) {
69
                        /* Err... Adjust IT!!!! */
70
                        p->X86_cpu = 11;
71
                }
72
                /* Need tests for AMD and others... */
2 pj 73
        }
74
}