diff options
author | Jason Downs <downsj@cvs.openbsd.org> | 1998-05-27 02:26:08 +0000 |
---|---|---|
committer | Jason Downs <downsj@cvs.openbsd.org> | 1998-05-27 02:26:08 +0000 |
commit | f7a9ac5ec0eedfc718e8d5f94e5f1c8d0f621332 (patch) | |
tree | e5d71ee771bf95a6325304b70ecc0e83c43e6e46 /usr.bin/pctr | |
parent | 641ece5591f48c27f7f51b1be56c533ea70cf107 (diff) |
compile; needs lots of work.
Diffstat (limited to 'usr.bin/pctr')
-rw-r--r-- | usr.bin/pctr/pctr.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/usr.bin/pctr/pctr.c b/usr.bin/pctr/pctr.c index 874395c7011..b9d788156c2 100644 --- a/usr.bin/pctr/pctr.c +++ b/usr.bin/pctr/pctr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pctr.c,v 1.2 1996/08/16 00:02:35 dm Exp $ */ +/* $OpenBSD: pctr.c,v 1.3 1998/05/27 02:26:07 downsj Exp $ */ /* * Pentium performance counter control program for OpenBSD. @@ -226,6 +226,37 @@ struct ctrfn p6fn[] = { {0x0, 0, NULL, NULL}, }; +#define __cpuid() \ +({ \ + pctrval id; \ + __asm __volatile ("pushfl\n" \ + "\tpopl %%eax\n" \ + "\tmovl %%eax,%%ecx\n" \ + "\txorl %1,%%eax\n" \ + "\tpushl %%eax\n" \ + "\tpopfl\n" \ + "\tpushfl\n" \ + "\tpopl %%eax\n" \ + "\tpushl %%ecx\n" \ + "\tpopfl\n" \ + "\tcmpl %%eax,%%ecx\n" \ + "\tmovl $0,%%eax\n" \ + "\tje 1f\n" \ + "\tcpuid\n" \ + "\ttestl %%eax,%%eax\n" \ + "\tje 1f\n" \ + "\tmovl $1,%%eax\n" \ + "\tcpuid\n" \ + "\tjmp 2f\n" \ + "1:\t" \ + "\txorl %%eax,%%eax\n" \ + "\txorl %%edx,%%edx\n" \ + "2:\t" \ + : "=A" (id) : "i" (PSL_ID) \ + : "edx", "ecx", "ebx"); \ + id; \ +}) + static void printdesc (char *desc) { |