head 1.14; access; symbols pkgsrc-2014Q4:1.9.0.2 pkgsrc-2014Q4-base:1.9 pkgsrc-2014Q3:1.8.0.24 pkgsrc-2014Q3-base:1.8 pkgsrc-2014Q2:1.8.0.22 pkgsrc-2014Q2-base:1.8 pkgsrc-2014Q1:1.8.0.20 pkgsrc-2014Q1-base:1.8 pkgsrc-2013Q4:1.8.0.18 pkgsrc-2013Q4-base:1.8 pkgsrc-2013Q3:1.8.0.16 pkgsrc-2013Q3-base:1.8 pkgsrc-2013Q2:1.8.0.14 pkgsrc-2013Q2-base:1.8 pkgsrc-2013Q1:1.8.0.12 pkgsrc-2013Q1-base:1.8 pkgsrc-2012Q4:1.8.0.10 pkgsrc-2012Q4-base:1.8 pkgsrc-2012Q3:1.8.0.8 pkgsrc-2012Q3-base:1.8 pkgsrc-2012Q2:1.8.0.6 pkgsrc-2012Q2-base:1.8 pkgsrc-2012Q1:1.8.0.4 pkgsrc-2012Q1-base:1.8 pkgsrc-2011Q4:1.8.0.2 pkgsrc-2011Q4-base:1.8 pkgsrc-2011Q3:1.7.0.6 pkgsrc-2011Q3-base:1.7 pkgsrc-2011Q2:1.7.0.4 pkgsrc-2011Q2-base:1.7 pkgsrc-2011Q1:1.7.0.2 pkgsrc-2011Q1-base:1.7 pkgsrc-2009Q4:1.6.0.8 pkgsrc-2009Q4-base:1.6 pkgsrc-2008Q4:1.6.0.6 pkgsrc-2008Q4-base:1.6 pkgsrc-2008Q3:1.6.0.4 pkgsrc-2008Q3-base:1.6 cube-native-xorg:1.6.0.2 cube-native-xorg-base:1.6 pkgsrc-2008Q2:1.5.0.18 pkgsrc-2008Q2-base:1.5 cwrapper:1.5.0.16 pkgsrc-2008Q1:1.5.0.14 pkgsrc-2008Q1-base:1.5 pkgsrc-2007Q4:1.5.0.12 pkgsrc-2007Q4-base:1.5 pkgsrc-2007Q3:1.5.0.10 pkgsrc-2007Q3-base:1.5 pkgsrc-2007Q2:1.5.0.8 pkgsrc-2007Q2-base:1.5 pkgsrc-2007Q1:1.5.0.6 pkgsrc-2007Q1-base:1.5 pkgsrc-2006Q4:1.5.0.4 pkgsrc-2006Q4-base:1.5 pkgsrc-2006Q3:1.5.0.2 pkgsrc-2006Q3-base:1.5 pkgsrc-2006Q2:1.3.0.4 pkgsrc-2006Q2-base:1.3 pkgsrc-2006Q1:1.3.0.2 pkgsrc-2006Q1-base:1.3 pkgsrc-2005Q4:1.2.0.2 pkgsrc-2005Q4-base:1.2 pkgsrc-2005Q3:1.1.0.6 pkgsrc-2005Q3-base:1.1 pkgsrc-2005Q2:1.1.0.4 pkgsrc-2005Q2-base:1.1 pkgsrc-2005Q1:1.1.0.2 pkgsrc-2005Q1-base:1.1; locks; strict; comment @# @; 1.14 date 2015.02.19.00.08.15; author wiz; state dead; branches; next 1.13; commitid DeEWahlrRYxL9yay; 1.13 date 2015.02.18.10.34.57; author wiz; state Exp; branches; next 1.12; commitid ecvvpJDDEg2MEtay; 1.12 date 2015.02.17.09.59.30; author abs; state Exp; branches; next 1.11; commitid o6O8r1zdXkwuulay; 1.11 date 2015.02.01.18.59.05; author wiz; state Exp; branches; next 1.10; commitid hqva5AT5tWMDZk8y; 1.10 date 2015.01.04.18.42.50; author jmcneill; state Exp; branches; next 1.9; commitid FJZBohuhT5vGNJ4y; 1.9 date 2014.10.01.01.17.33; author jmcneill; state Exp; branches; next 1.8; commitid VDYpV0NSjpDE4rSx; 1.8 date 2011.12.14.21.44.32; author macallan; state Exp; branches; next 1.7; 1.7 date 2011.03.16.05.09.16; author macallan; state Exp; branches; next 1.6; 1.6 date 2008.09.11.09.51.54; author adam; state dead; branches; next 1.5; 1.5 date 2006.08.08.22.07.48; author xtraeme; state Exp; branches; next 1.4; 1.4 date 2006.07.24.08.11.38; author adam; state Exp; branches; next 1.3; 1.3 date 2005.12.27.09.58.56; author dillo; state Exp; branches; next 1.2; 1.2 date 2005.10.07.08.52.14; author adam; state dead; branches; next 1.1; 1.1 date 2005.01.24.10.56.03; author agc; state Exp; branches; next ; desc @@ 1.14 log @Update to r11. From Leonardo Taccari in PR 49679. Changes: * fix incorrect static array initialization @ text @$NetBSD: patch-ab,v 1.13 2015/02/18 10:34:57 wiz Exp $ Add a missing comma that resulted in a smaller freqctl[] and setctl[] (and so with a potential off-by-one error). Explicitly use TECH_MAX in sizes of freqlist and related arrays. --- estd.c.orig 2015-02-15 21:12:10.000000000 +0000 +++ estd.c @@@@ -121,7 +121,7 @@@@ int ndomains; static const size_t cp_time_max_size = sizeof(cp_time[0]) * MAX_CPUS; #endif -static char *techdesc[8] = {"Unknown", +static char *techdesc[TECH_MAX + 1] = {"Unknown", "Enhanced SpeedStep", "PowerNow", "ACPI P-States", @@@@ -130,20 +130,20 @@@@ static char *techdesc[8] = {"Unknown", "Rockchip", "Generic" }; -static char *freqctl[8] = { "", +static char *freqctl[TECH_MAX + 1] = { "", "machdep.est.frequency.available", "machdep.powernow.frequency.available", "hw.acpi.cpu.px_dom0.available", - "machdep.intrepid.frequency.available" + "machdep.intrepid.frequency.available", "machdep.loongson.frequency.available", "machdep.cpu.frequency.available", "machdep.frequency.available" }; -static char *setctl[8] = { "", +static char *setctl[TECH_MAX + 1] = { "", "machdep.est.frequency.target", "machdep.powernow.frequency.target", "hw.acpi.cpu.px_dom0.select", - "machdep.intrepid.frequency.target" + "machdep.intrepid.frequency.target", "machdep.loongson.frequency.target", "machdep.cpu.frequency.target", "machdep.frequency.current" @ 1.13 log @Update to r10 from Leonardo Taccari in PR 49675: Changes: * Fix build on DragonFly due to pidfile changes. * Add support for TECH_LOONGSON, TECH_ROCKCHIP, and TECH_GENERIC. Taken from pkgsrc, submitted-by: Leonardo Taccari, original patches by Jared D. McNeill. @ text @d1 1 a1 1 $NetBSD$ @ 1.12 log @Fix off by one error which caused SEGV when no valid scaling option found Add comments to patch-ab Bump PKGREVISION @ text @d1 1 a1 1 $NetBSD: patch-ab,v 1.11 2015/02/01 18:59:05 wiz Exp $ d3 3 a5 2 Fix off by one error in use of TECH_MAX against freqlist which would cause a null pointer to be passed to sysctl d7 1 a7 9 Explicitly use TECH_MAX in sizes of freqlist and related arrays Add mre frequency mechanisms Add -G, -L and -R options Add NetBSD support --- estd.c.orig 2013-03-24 19:14:06.000000000 +0000 d9 1 a9 15 @@@@ -56,8 +56,11 @@@@ #define TECH_POWERNOW 2 #define TECH_ACPI 3 #define TECH_INTREPID 4 -#define TECH_MAX 4 - +#define TECH_LOONGSON 5 +#define TECH_ROCKCHIP 6 +#define TECH_GENERIC 7 +#define TECH_MAX 7 + /* this is ugly, but... */ #define MAX_FREQS 32 #define SYSCTLBUF 255 @@@@ -118,29 +121,41 @@@@ int ndomains; d13 2 a14 3 -static char *techdesc[5] = {"Unknown", +static char *techdesc[TECH_MAX + 1] = { + "Unknown", d18 3 a20 5 - "Intrepid" + "Intrepid", + "Loongson", + "Rockchip", + "Generic" d22 2 a23 3 -static char *freqctl[5] = { "", +static char *freqctl[TECH_MAX + 1] = { + "", d27 5 a31 4 "machdep.intrepid.frequency.available" + "machdep.loongson.frequency.available", + "machdep.cpu.frequency.available", + "machdep.frequency.available" d33 2 a34 3 -static char *setctl[5] = { "", +static char *setctl[TECH_MAX + 1] = { + "", d38 5 a42 86 "machdep.intrepid.frequency.target" + "machdep.loongson.frequency.target", + "machdep.cpu.frequency.target", + "machdep.frequency.current" }; void usage() { - printf("usage: estd [-d] [-o] [-n] [-A] [-C] [-E] [-I] [-P] [-a] [-s] [-b] [-p poll interval in us] [-g grace period] [-l low watermark percentage] [-h high watermark percentage] [-m minimum MHz] [-M maximum MHz]\n"); + printf("usage: estd [-d] [-o] [-n] [-A] [-C] [-E] [-I] [-L] [-R] [-P] [-G] [-a] [-s] [-b] [-p poll interval in us] [-g grace period] [-l low watermark percentage] [-h high watermark percentage] [-m minimum MHz] [-M maximum MHz]\n"); printf(" estd -v\n"); printf(" estd -f\n"); exit(1); @@@@ -395,7 +410,7 @@@@ main(int argc, char *argv[]) FILE *fexists; /* get command-line options */ - while ((ch = getopt(argc, argv, "vfdonACEIPasbp:h:l:g:m:M:")) != -1) + while ((ch = getopt(argc, argv, "vfdonACEGILPasbp:h:l:g:m:M:")) != -1) switch (ch) { case 'v': version(); @@@@ -426,12 +441,21 @@@@ main(int argc, char *argv[]) case 'E': tech = TECH_EST; break; + case 'G': + tech = TECH_GENERIC; + break; case 'I': tech = TECH_INTREPID; break; + case 'L': + tech = TECH_LOONGSON; + break; case 'P': tech = TECH_POWERNOW; break; + case 'R': + tech = TECH_ROCKCHIP; + break; case 'a': strategy = AGGRESSIVE; break; @@@@ -466,8 +490,9 @@@@ main(int argc, char *argv[]) ndomains = 1; domain = ecalloc(ndomains, sizeof(struct domain)); - - #if defined(__DragonFly__) + +#if defined(__NetBSD__) || defined(__DragonFly__) +# if defined(__DragonFly__) if (kinfo_get_cpus(&ncpus)) { fprintf(stderr, "estd: Cannot get number of cpus\n"); exit(1); @@@@ -475,18 +500,25 @@@@ main(int argc, char *argv[]) cp_time = ecalloc(ncpus, sizeof(struct kinfo_cputime)); cp_old = ecalloc(ncpus, sizeof(struct kinfo_cputime)); cp_time_len = ncpus * sizeof(struct kinfo_cputime); +# elif defined(__NetBSD__) + size_t ncpus_len = sizeof(ncpus); + if (sysctlbyname("hw.ncpu", &ncpus, &ncpus_len, NULL, 0) != 0) { + fprintf(stderr, "estd: Cannot get number of cpus\n"); + exit(1); + } +# endif domain[0].ncpus = ncpus; domain[0].cpus = ecalloc(ncpus, sizeof(int)); for (i = 0; i < domain[0].ncpus; i++) domain[0].cpus[i] = i; - #endif +#endif /* try to guess cpu-scaling technology */ if (tech == TECH_UNKNOWN) { - for (tech = 1; tech <= TECH_MAX; tech++) { + for (tech = 1; tech < TECH_MAX; tech++) { if (sysctlbyname(freqctl[tech], &frequencies, &freqsize, NULL, 0) >= 0) break; } - if (tech > TECH_MAX) { + if (tech >= TECH_MAX) { fprintf(stderr, "estd: Cannot guess CPU-scaling technology. (maybe you are missing some kernel-option?)\n"); exit(1); } @ 1.11 log @Update to 0.9, from Leonardo Taccari in PR 49624: Changes: estd-r9 * Improve SMP support on NetBSD. Submitted by: vincent@@labri.fr estd-r8 * Add Intrepid support. Submitted by: Michael @ text @d1 12 a12 1 $NetBSD: patch-ab,v 1.10 2015/01/04 18:42:50 jmcneill Exp $ d30 1 a30 1 @@@@ -118,29 +121,38 @@@@ int ndomains; d35 2 a36 1 +static char *techdesc[8] = {"Unknown", d47 2 a48 1 +static char *freqctl[8] = { "", d58 2 a59 1 +static char *setctl[8] = { "", d77 1 a77 1 @@@@ -395,7 +407,7 @@@@ main(int argc, char *argv[]) d86 1 a86 1 @@@@ -426,12 +438,21 @@@@ main(int argc, char *argv[]) d108 1 a108 1 @@@@ -466,8 +487,9 @@@@ main(int argc, char *argv[]) d120 1 a120 1 @@@@ -475,11 +497,18 @@@@ main(int argc, char *argv[]) d140 9 @ 1.10 log @Add support for Rockchip 'machdep.cpu.frequency' interface. Use hw.ncpu to detect number of CPUs on non-ACPI NetBSD systems. @ text @d1 1 a1 1 $NetBSD$ d3 1 a3 1 --- estd.c.orig 2009-10-20 16:18:28.000000000 +0000 d5 1 a5 2 @@@@ -55,7 +55,11 @@@@ #define TECH_EST 1 d8 3 a10 2 -#define TECH_MAX 3 +#define TECH_INTREPID 4 d15 1 a15 1 d18 3 a20 2 @@@@ -116,26 +120,38 @@@@ int ndomains; static size_t cp_time_size = sizeof(cp_time[0]) * CPUSTATES; d23 1 a23 1 -static char *techdesc[4] = {"Unknown", d27 2 a28 2 - "ACPI P-States" + "ACPI P-States", d34 1 a34 1 -static char *freqctl[4] = { "", d38 2 a39 3 - "hw.acpi.cpu.px_dom0.available" + "hw.acpi.cpu.px_dom0.available", + "machdep.intrepid.frequency.available", d44 1 a44 1 -static char *setctl[4] = { "", d48 2 a49 3 - "hw.acpi.cpu.px_dom0.select" + "hw.acpi.cpu.px_dom0.select", + "machdep.intrepid.frequency.target", d58 2 a59 2 - printf("usage: estd [-d] [-o] [-n] [-A] [-C] [-E] [-P] [-a] [-s] [-b] [-p poll interval in us] [-g grace period] [-l low watermark percentage] [-h high watermark percentage] [-m minimum MHz] [-M maximum MHz]\n"); + printf("usage: estd [-d] [-o] [-n] [-A] [-C] [-E] [-P] [-I] [-L] [-R] [-G] [-a] [-s] [-b] [-p poll interval in us] [-g grace period] [-l low watermark percentage] [-h high watermark percentage] [-m minimum MHz] [-M maximum MHz]\n"); d63 1 a63 1 @@@@ -367,7 +383,7 @@@@ main(int argc, char *argv[]) d67 2 a68 2 - while ((ch = getopt(argc, argv, "vfdonACEPasbp:h:l:g:m:M:")) != -1) + while ((ch = getopt(argc, argv, "vfdonACEPILGasbp:h:l:g:m:M:")) != -1) d72 3 a74 1 @@@@ -400,6 +416,19 @@@@ main(int argc, char *argv[]) d76 2 a77 5 case 'P': tech = TECH_POWERNOW; + break; + case 'I': + tech = TECH_INTREPID; d79 3 d85 3 a90 3 + case 'G': + tech = TECH_GENERIC; + break; d94 1 a94 1 @@@@ -434,8 +463,9 @@@@ main(int argc, char *argv[]) d106 1 a106 1 @@@@ -443,11 +473,18 @@@@ main(int argc, char *argv[]) @ 1.9 log @add NetBSD/arm (am335x) support, bump pkgrevision @ text @d4 2 a5 2 +++ estd.c 2014-09-30 11:10:54.000000000 +0000 @@@@ -55,7 +55,10 @@@@ d12 3 a14 2 +#define TECH_GENERIC 6 +#define TECH_MAX 6 d18 1 a18 1 @@@@ -116,26 +119,35 @@@@ int ndomains; d23 1 a23 1 +static char *techdesc[7] = {"Unknown", d30 1 d34 1 a34 1 +static char *freqctl[7] = { "", d41 1 d45 1 a45 1 +static char *setctl[7] = { "", d52 1 d60 1 a60 1 + printf("usage: estd [-d] [-o] [-n] [-A] [-C] [-E] [-P] [-I] [-L] [-G] [-a] [-s] [-b] [-p poll interval in us] [-g grace period] [-l low watermark percentage] [-h high watermark percentage] [-m minimum MHz] [-M maximum MHz]\n"); d64 1 a64 1 @@@@ -367,7 +379,7 @@@@ main(int argc, char *argv[]) d73 1 a73 1 @@@@ -400,6 +412,16 @@@@ main(int argc, char *argv[]) d84 3 d93 32 @ 1.8 log @add Loongson support, allow build on mips64el @ text @d1 1 a1 1 $NetBSD: patch-ab,v 1.7 2011/03/16 05:09:16 macallan Exp $ d4 2 a5 2 +++ estd.c @@@@ -55,7 +55,9 @@@@ d12 2 a13 1 +#define TECH_MAX 5 d17 1 a17 1 @@@@ -116,20 +118,26 @@@@ int ndomains; d22 1 a22 1 +static char *techdesc[6] = {"Unknown", d28 2 a29 1 + "Loongson" d32 1 a32 1 +static char *freqctl[6] = { "", d38 2 a39 1 + "machdep.loongson.frequency.available" d42 1 a42 1 +static char *setctl[6] = { "", d48 2 a49 1 + "machdep.loongson.frequency.target" d53 17 a69 1 @@@@ -400,6 +408,13 @@@@ main(int argc, char *argv[]) d80 3 @ 1.7 log @add support for macppc. @ text @d1 1 a1 1 $NetBSD$ d3 1 a3 1 --- estd.c.orig 2011-03-16 04:50:26.000000000 +0000 d5 1 a5 1 @@@@ -55,7 +55,8 @@@@ d11 2 a12 1 +#define TECH_MAX 4 d16 1 a16 1 @@@@ -116,20 +117,23 @@@@ int ndomains; d21 1 a21 1 +static char *techdesc[5] = {"Unknown", d26 2 a27 1 + "Intrepid" d30 1 a30 1 +static char *freqctl[5] = { "", d35 2 a36 1 + "machdep.intrepid.frequency.available" d39 1 a39 1 +static char *setctl[5] = { "", d44 2 a45 1 + "machdep.intrepid.frequency.target" d49 1 a49 1 @@@@ -400,6 +404,10 @@@@ main(int argc, char *argv[]) d57 3 @ 1.6 log @Changes 0.6: * added support for ultra-low frequency idle-mode on CPUs that support On Demand Clock Modulation * added an option to delay lowering the frequency * added an option to count time spent on nice processes as idle @ text @d1 1 a1 1 $NetBSD: patch-ab,v 1.5 2006/08/08 22:07:48 xtraeme Exp $ d3 9 a11 3 --- estd.c.orig 2006-07-02 20:12:31.000000000 +0200 +++ estd.c 2006-08-09 00:03:55.000000000 +0200 @@@@ -27,6 +27,7 @@@@ d13 43 a55 15 #include #include +#include #include #include #include @@@@ -220,7 +221,7 @@@@ int i; char frequencies[SYSCTLBUF]; /* XXX Ugly */ char *fp; - int freqsize = SYSCTLBUF; + size_t freqsize = SYSCTLBUF; int freqtab[MAX_FREQS]; int nfreqs = 0; int minidx = 0; @ 1.5 log @Fix -f on NetBSD/amd64 4.0 and powernow. Patch from Robert Swindells. Quoting Robert: With this change I get: # estd -f Supported frequencies (PowerNow Mode): 800 MHz 1600 MHz Bump PKGREVISION. @ text @d1 1 a1 1 $NetBSD$ @ 1.4 log @Changes 0.5: * Added support for DragonFly BSD * Daemon can now be controlled via signals * Bugfixes @ text @d3 2 a4 2 --- estd.c.orig 2006-07-24 10:04:46.000000000 +0200 +++ estd.c d13 9 @ 1.3 log @Fix bug in comparison function used to sort frequencies. Install rc.d script. Bump PKGREVISION. Take maintainership. @ text @d3 1 a3 1 --- estd.c.orig 2005-01-30 23:15:13.000000000 +0100 d5 1 a5 7 @@@@ -141,7 +141,7 @@@@ set_freq(int freq) int freqcmp(const void *x, const void *y) { - return *((int *) x) > *((int *) y); + return *((int *) x) - *((int *) y); } d7 6 a12 1 /* clean up the pidfile on exit */ @ 1.2 log @Changes 0.4: * Support for PowerNow @ text @d1 1 a1 1 $NetBSD: patch-ab,v 1.1 2005/01/24 10:56:03 agc Exp $ d3 5 a7 3 --- estd.c.orig 2004-07-22 16:03:58.000000000 +0200 +++ estd.c 2005-01-16 15:07:56.000000000 +0100 @@@@ -110,7 +110,9 @@@@ d9 3 a11 11 if ((!daemonize) && (verbose)) printf("%i MHz\n", freq); - if (sysctlbyname("machdep.est.frequency.target", NULL, NULL, &freq, sizeof(freq)) < 0) { + if ((sysctlbyname("machdep.est.frequency.target", NULL, NULL, &freq, sizeof(freq)) < 0) + && (sysctlbyname("machdep.powernow.frequency.target", NULL, NULL, &freq, sizeof(freq)) < 0)) + { printf("estd: Cannot set CPU frequency (maybe you aren't root?)\n"); exit(1); } @@@@ -191,7 +193,9 @@@@ } d13 1 a13 8 /* get supported frequencies... */ - if (sysctlbyname("machdep.est.frequency.available", &frequencies, &freqsize, NULL, 0) < 0) { + if ((sysctlbyname("machdep.est.frequency.available", &frequencies, &freqsize, NULL, 0) < 0) + && (sysctlbyname("machdep.powernow.frequency.available", &frequencies, &freqsize, NULL, 0) < 0)) + { printf("estd: Cannot get supported frequencies (maybe SpeedStep is not included in your kernel-config?)\n"); exit(1); } @ 1.1 log @Add rudimentary support for PowerNow processors from Rumi Szabolcs. @ text @d1 1 a1 1 $NetBSD$ @