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 test file                 */
23
 
24
#include <ll/i386/stdlib.h>
25
#include <ll/i386/error.h>
26
#include <ll/i386/mem.h>
27
#include <ll/i386/hw-arch.h>
28
#include <ll/sys/ll/ll-func.h>
29
 
30
#define T  1000
31
 
32
int main (int argc, char *argv[])
33
{
34
    DWORD sp1, sp2;
35
    struct ll_cpuInfo cpu;
36
    void *res;
37
    char vendorName[13];
38
 
39
    sp1 = get_SP();
40
    cli();
41
    res = ll_init();
42
 
43
    if (res == NULL) {
44
            message("Error in LowLevel initialization code...\n");
45
            sti();
46
            l1_exit(-1);
47
    }
48
    sti();
49
 
50
    message("LowLevel started...\n");
51
    message("CPU informations:\n");
52
    X86_get_CPU(&cpu);
53
 
54
    message("\tCPU type: %lu\n", cpu.X86_cpu);
55
 
56
    if (cpu.X86_cpuIdFlag) {
57
        message("CPUID instruction workin'...\n");
58
        message("\tCPU Vendor ID: ");
59
 
60
        memcpy(vendorName, &(cpu.X86_vendor_1), 12);
61
        vendorName[12] = 0;
62
        message("%s\n", vendorName);
63
 
64
        message("\tCPU Stepping ID: %lx", cpu.X86_cpu & 0x0F);
65
        message("\tCPU Model: %lx", (cpu.X86_cpu >> 4) & 0x0F);
66
        message("\tCPU Family: %lx", (cpu.X86_cpu >> 8) & 0x0F);
67
        message("\tCPU Type: %lx\n", (cpu.X86_cpu >> 12) & 0x0F);
68
 
69
        message("\tStandard Feature Flags %lx\n", cpu.X86_StandardFeature);
70
        if (cpu.X86_StandardFeature & 0x01) {
71
                message("Internal FPU present...\n");
72
        }
73
        if (cpu.X86_StandardFeature & 0x02) {
74
                message("V86 Mode present...\n");
75
        }
76
        if (cpu.X86_StandardFeature & 0x04) {
77
                message("Debug Extension present...\n");
78
        }
79
        if (cpu.X86_StandardFeature & 0x08) {
80
                message("4MB pages present...\n");
81
        }
82
        if (cpu.X86_StandardFeature & 0x10) {
83
                message("TimeStamp Counter present...\n");
84
        }
85
        if (cpu.X86_StandardFeature & 0x20) {
86
                message("RDMSR/WRMSR present...\n");
87
        }
88
        if (cpu.X86_StandardFeature & 0x40) {
89
                message("PAE present...\n");
90
        }
91
        if (cpu.X86_StandardFeature & 0x80) {
92
                message("MC Exception present...\n");
93
        }
94
        if (cpu.X86_StandardFeature & 0x0100) {
95
                message("CMPXCHG8B present...\n");
96
        }
97
        if (cpu.X86_StandardFeature & 0x0200) {
98
                message("APIC on chip...\n");
99
        }
100
        if (cpu.X86_StandardFeature & 0x1000) {
101
                message("MTRR present...\n");
102
        }
103
        if (cpu.X86_StandardFeature & 0x2000) {
104
                message("Global Bit present...\n");
105
        }
106
        if (cpu.X86_StandardFeature & 0x4000) {
107
                message("Machine Check present...\n");
108
        }
109
        if (cpu.X86_StandardFeature & 0x8000) {
110
                message("CMOV present...\n");
111
        }
112
        if (cpu.X86_StandardFeature & 0x800000) {
113
                message("MMX present...\n");
114
        }
115
    }
116
    cli();
117
    ll_end();
118
    sp2 = get_SP();
119
    message("End reached!\n");
120
    message("Actual stack : %lx - ", sp2);
121
    message("Begin stack : %lx\n", sp1);
122
    message("Check if same : %s\n",sp1 == sp2 ? "Ok :-)" : "No :-(");
123
 
124
    return 1;
125
}