L4Re Operating System Framework
Interface and Usage Documentation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cpu.h
Go to the documentation of this file.
1
7/*
8 * (c) 2004-2009 Author(s)
9 * economic rights: Technische Universität Dresden (Germany)
10 * License: see LICENSE.spdx (in this directory or the directories above)
11 */
12
13#ifndef __L4_UTIL_CPU_H
14#define __L4_UTIL_CPU_H
15
16#include <l4/sys/compiler.h>
17
19
32
39L4_INLINE unsigned int l4util_cpu_capabilities(void);
40
47
51L4_INLINE void
52l4util_cpu_cpuid(unsigned long mode,
53 unsigned long *eax, unsigned long *ebx,
54 unsigned long *ecx, unsigned long *edx);
55
57static inline void
58l4util_cpu_pause(void)
59{
60 __asm__ __volatile__ ("rep; nop");
61}
62
63L4_INLINE int
65{
66 return 1;
67}
68
69L4_INLINE void
70l4util_cpu_cpuid(unsigned long mode,
71 unsigned long *eax, unsigned long *ebx,
72 unsigned long *ecx, unsigned long *edx)
73{
74 asm volatile("cpuid"
75 : "=a" (*eax),
76 "=b" (*ebx),
77 "=c" (*ecx),
78 "=d" (*edx)
79 : "a" (mode)
80 );
81}
82
83L4_INLINE unsigned int
85{
86 unsigned long dummy, capability;
87
88 /* get CPU capabilities */
89 l4util_cpu_cpuid(1, &dummy, &dummy, &dummy, &capability);
90
91 return capability;
92}
93
94L4_INLINE unsigned int
96{
98 return 0; /* CPU has not cpuid instruction */
99
101}
102
104
105#endif
106
L4 compiler related defines.
#define __END_DECLS
End section with C types and functions.
Definition compiler.h:167
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:51
#define __BEGIN_DECLS
Start section with C types and functions.
Definition compiler.h:164
void l4util_cpu_cpuid(unsigned long mode, unsigned long *eax, unsigned long *ebx, unsigned long *ecx, unsigned long *edx)
Generic CPUID access function.
Definition cpu.h:70
unsigned int l4util_cpu_capabilities_nocheck(void)
Returns the CPU capabilities.
Definition cpu.h:84
unsigned int l4util_cpu_capabilities(void)
Returns the CPU capabilities if the "cpuid" instruction is available.
Definition cpu.h:95
int l4util_cpu_has_cpuid(void)
Check whether the CPU supports the "cpuid" instruction.
Definition cpu.h:64