File: cpuid.c

package info (click to toggle)
haskell-cpu 0.1.2-13
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 92 kB
  • sloc: haskell: 171; ansic: 79; makefile: 2
file content (29 lines) | stat: -rw-r--r-- 495 bytes parent folder | download | duplicates (7)
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
#include <stdint.h>

void cpuid(uint32_t eax, uint32_t ecx, uint32_t regs[4])
{
	asm volatile (
#ifdef __i386__
		"push %%ebx\n\t"
		"push %%edx\n\t"
#else
		"push %%rbx\n\t"
		"push %%rdx\n\t"
#endif
		"cpuid\n\t"
		"mov %%eax,(%4)\n\t"
		"mov %%ebx,4(%4)\n\t"
		"mov %%ecx,8(%4)\n\t"
		"mov %%edx,12(%4)\n\t"
#ifdef __i386__
		"pop %%edx\n\t"
		"pop %%ebx\n\t"
#else
		"pop %%rdx\n\t"
		"pop %%rbx\n\t"
#endif
		: "=a" (eax), "=c" (ecx)
		: "0" (eax), "1" (ecx), "S" (regs)
		: "memory"
	);
}