Rev 788 | 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> |
||
705 | giacomo | 27 | #include <ll/i386/advtimer.h> |
28 | #include <ll/i386/apic.h> |
||
2 | pj | 29 | |
40 | pj | 30 | FILE(Cpu-C); |
2 | pj | 31 | |
40 | pj | 32 | INLINE_OP void cpuid(DWORD a, DWORD *outa, DWORD *outb, DWORD *outc, DWORD *outd) |
2 | pj | 33 | { |
34 | #ifdef __OLD_GNU__ |
||
40 | pj | 35 | __asm__ __volatile__ (".byte 0x0F,0xA2" |
2 | pj | 36 | #else |
40 | pj | 37 | __asm__ __volatile__ ("cpuid" |
2 | pj | 38 | #endif |
40 | pj | 39 | : "=a" (*outa), |
40 | "=b" (*outb), |
||
41 | "=c" (*outc), |
||
42 | "=d" (*outd) |
||
43 | : "a" (a)); |
||
2 | pj | 44 | } |
45 | |||
46 | void X86_get_CPU(struct ll_cpuInfo *p) |
||
47 | { |
||
40 | pj | 48 | DWORD tmp; |
2 | pj | 49 | |
40 | pj | 50 | memset(p, 0, sizeof(struct ll_cpuInfo)); |
51 | if (X86_is386()) { |
||
52 | p->X86_cpu = 3; |
||
53 | return; |
||
2 | pj | 54 | } |
788 | giacomo | 55 | |
56 | if (X86_isCyrix()) { |
||
57 | X86_enable_cyrix_cpuid(); |
||
58 | } |
||
59 | |||
40 | pj | 60 | if (X86_hasCPUID()) { |
61 | p->X86_cpuIdFlag = 1; |
||
62 | p->X86_cpu = 5; |
||
63 | cpuid(0, &tmp, &(p->X86_vendor_1), |
||
64 | &(p->X86_vendor_3), |
||
65 | &(p->X86_vendor_2)); |
||
66 | if (tmp >= 1) { |
||
705 | giacomo | 67 | |
40 | pj | 68 | cpuid(1, &(p->X86_signature), |
69 | &(p->X86_IntelFeature_1), |
||
70 | &(p->X86_IntelFeature_2), |
||
71 | &(p->X86_StandardFeature)); |
||
756 | giacomo | 72 | #ifdef __APIC__ |
705 | giacomo | 73 | if ((p->X86_StandardFeature >> 5) & 1) { |
74 | |||
75 | unsigned long msr_original_low, msr_original_high; |
||
76 | |||
77 | rdmsr(APIC_BASE_MSR, msr_original_low, msr_original_high); |
||
78 | wrmsr(APIC_BASE_MSR, msr_original_low|(1<<11), 0); |
||
79 | |||
80 | cpuid(1, &(p->X86_signature), |
||
81 | &(p->X86_IntelFeature_1), |
||
82 | &(p->X86_IntelFeature_2), |
||
83 | &(p->X86_StandardFeature)); |
||
84 | |||
85 | wrmsr(APIC_BASE_MSR, msr_original_low, msr_original_high); |
||
86 | |||
87 | } |
||
756 | giacomo | 88 | #endif |
40 | pj | 89 | } |
90 | } else { |
||
91 | p->X86_cpu = 4; |
||
92 | if (X86_isCyrix()) { |
||
93 | p->X86_cpu = 11; |
||
94 | } |
||
95 | /* Need tests for AMD and others... */ |
||
2 | pj | 96 | } |
97 | } |