# HG changeset patch # User Ron Minnich # Date 1319747474 25200 # Node ID 8a9762a01ea03157402a65091b6a107273ff41fa # Parent 62c28a02a0c5fcd690744bf4d3e17f6f79756441 Suppport for learning about the monitor/mwait instruction. sys/src/nix/k10/archk10.c: If monitor is enabled, use cpuid 5 to find region size sys/src/nix/k10/dat.h: Add monitorsize so we can check it later. sys/src/nix/k10/devarch.c: Add cpuidread function so we can see cpuid and monitorsize info R=nixiedev, nemo, quanstro CC=nix-dev http://codereview.appspot.com/5314062 diff -r 62c28a02a0c5 -r 8a9762a01ea0 sys/src/nix/k10/archk10.c --- a/sys/src/nix/k10/archk10.c Wed Oct 26 09:50:58 2011 -0700 +++ b/sys/src/nix/k10/archk10.c Thu Oct 27 13:31:14 2011 -0700 @@ -28,6 +28,12 @@ if((eax = cpuid(0x80000000, 0, info)) >= 0x80000000) m->ncpuinfoe = (eax & ~0x80000000) + 1; + /* is mnonitor supported? */ + if (m->cpuinfo[1][2] & 8) { + cpuid(5, 0, &m->monitorsize); + iprint("Monitor supported; size %d", m->monitorsize); + } + return 1; } diff -r 62c28a02a0c5 -r 8a9762a01ea0 sys/src/nix/k10/dat.h --- a/sys/src/nix/k10/dat.h Wed Oct 26 09:50:58 2011 -0700 +++ b/sys/src/nix/k10/dat.h Thu Oct 27 13:31:14 2011 -0700 @@ -135,6 +135,7 @@ int ncpuinfos; /* number of standard entries */ int ncpuinfoe; /* number of extended entries */ int isintelcpu; /* */ + u32int monitorsize; /* size of monitor area. If non-zero, monitor is supported */ }; /* diff -r 62c28a02a0c5 -r 8a9762a01ea0 sys/src/nix/k10/devarch.c --- a/sys/src/nix/k10/devarch.c Wed Oct 26 09:50:58 2011 -0700 +++ b/sys/src/nix/k10/devarch.c Thu Oct 27 13:31:14 2011 -0700 @@ -523,6 +523,20 @@ } static long +cpuidread(Chan*, void *a, long n, vlong off) +{ + char str[64]; + int nstr = sizeof(str), ns = 0; + int i; + + for(i = 0; i < 4; i++) + ns += snprint(str+ns, nstr-ns, "%08x ", m->cpuinfo[1][i]); + + ns += snprint(str+ns, nstr-ns, "%08x ", m->monitorsize); + return readstr(off, a, n, str); +} + +static long linuxread(Chan*, void* a, long n, vlong offset) { char str[32]; @@ -558,6 +572,7 @@ archinit(void) { addarchfile("cputype", 0444, cputyperead, nil); + addarchfile("cpuidread", 0444, cpuidread, nil); addarchfile("linux", 0644, linuxread, linuxwrite); }