RTEMS 7.0-rc1
Loading...
Searching...
No Matches
cpuModel.h
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/*
4 * This file contains declaration for variables and code
5 * that may be used to get the Intel Cpu identification
6 * that has been performed by checkCPUtypeSetCr0 function.
7 */
8
9/*
10 * Copyright (c) 1998 Eric Valette <eric.valette@free.fr>
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#ifndef libcpu_cpuModel_h
35#define libcpu_cpuModel_h
36
37/*
38 * Tell us the machine setup..
39 */
40
41extern char hard_math; /* floating point coprocessor present indicator */
42extern char x86; /* type of cpu (3 = 386, 4 =486, ...) */
43extern char x86_model;
44extern char x86_mask;
45extern int x86_capability; /* cpuid:EDX */
46extern int x86_capability_x; /* cpuid:ECX */
47extern int x86_capability_ebx; /* cpuid:EBX */
48extern int x86_capability_cores; /* cpuid.(EAX=4, ECX=0) - physical cores */
49extern char x86_vendor_id[13];
50extern int have_cpuid;
51extern unsigned char Cx86_step; /* cyrix processor identification */
52
53/* Display this information on console in ascii form */
54extern void printCpuInfo(void);
55
56/* determine if the CPU has a TSC */
57#define x86_has_tsc() \
58 (x86_capability & (1 << 4))
59
60static inline unsigned long long
61rdtsc(void)
62{
63 /* Return the value of the on-chip cycle counter. */
64 unsigned long long result;
65 __asm__ volatile(".byte 0x0F, 0x31" : "=A" (result));
66 return result;
67} /* rdtsc */
68
69
70#endif
Definition: em86.c:54