summaryrefslogtreecommitdiff
path: root/com32/modules/cpuidtest.c
blob: cf07f2073fc074006f8067f75e5ff236481b13c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* ----------------------------------------------------------------------- *
 *
 *   Copyright 2006 Erwan Velu - All Rights Reserved
 *
 *   Permission is hereby granted, free of charge, to any person
 *   obtaining a copy of this software and associated documentation
 *   files (the "Software"), to deal in the Software without
 *   restriction, including without limitation the rights to use,
 *   copy, modify, merge, publish, distribute, sublicense, and/or
 *   sell copies of the Software, and to permit persons to whom
 *   the Software is furnished to do so, subject to the following
 *   conditions:
 *
 *   The above copyright notice and this permission notice shall
 *   be included in all copies or substantial portions of the Software.
 *
 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 *   OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 *   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 *   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 *   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 *   OTHER DEALINGS IN THE SOFTWARE.
 *
 * -----------------------------------------------------------------------
*/

/*
 * cpuidtest.c
 *
 * A CPUID demo program using libcom32
 */

#include <string.h>
#include <stdio.h>
#include <console.h>
#include "cpuid.h"

char display_line;

int main(void)
{
  s_cpu cpu;
  openconsole(&dev_stdcon_r, &dev_stdcon_w);

  for (;;) {
	detect_cpu(&cpu);
	printf("Vendor      = %s\n",cpu.vendor);
	printf("Model       = %s\n",cpu.model);
	printf("Vendor ID   = %d\n",cpu.vendor_id);
	printf("Family      = %d\n",cpu.family);
	printf("Model ID    = %d\n",cpu.model_id);
	printf("Stepping    = %d\n",cpu.stepping);
	printf("Flags       = ");
	if (cpu.flags.fpu)    printf("fpu ");
	if (cpu.flags.vme)    printf("vme ");
	if (cpu.flags.de)     printf("de ");
	if (cpu.flags.pse)    printf("pse ");
	if (cpu.flags.tsc)    printf("tsc ");
	if (cpu.flags.msr)    printf("msr ");
	if (cpu.flags.pae)    printf("pae ");
	if (cpu.flags.mce)    printf("mce ");
	if (cpu.flags.cx8)    printf("cx8 ");
	if (cpu.flags.apic)   printf("apic ");
	if (cpu.flags.sep)    printf("sep ");
	if (cpu.flags.mtrr)   printf("mtrr ");
	if (cpu.flags.pge)    printf("pge ");
	if (cpu.flags.mca)    printf("mca ");
	if (cpu.flags.cmov)   printf("cmov ");
	if (cpu.flags.pat)    printf("pat ");
	if (cpu.flags.pse_36) printf("pse_36 ");
	if (cpu.flags.psn)    printf("psn ");
	if (cpu.flags.clflsh) printf("clflsh ");
	if (cpu.flags.dts)    printf("dts ");
	if (cpu.flags.acpi)   printf("acpi ");
	if (cpu.flags.mmx)    printf("mmx ");
	if (cpu.flags.sse)    printf("sse ");
	if (cpu.flags.sse2)   printf("sse2 ");
	if (cpu.flags.ss)     printf("ss ");
	if (cpu.flags.htt)    printf("ht ");
	if (cpu.flags.acc)    printf("acc ");
	if (cpu.flags.syscall) printf("syscall ");
	if (cpu.flags.mp)     printf("mp ");
	if (cpu.flags.nx)     printf("nx ");
	if (cpu.flags.mmxext) printf("mmxext ");
	if (cpu.flags.lm)     printf("lm ");
	if (cpu.flags.nowext) printf("3dnowext ");
	if (cpu.flags.now)    printf("3dnow! ");
	printf("\n");
	printf("SMP         = ");
	if (cpu.flags.smp)    printf("yes\n");
	else		      printf("no\n");
	break;
  }

  return 0;
}