| @@ -1,85 +1,124 @@ | | | @@ -1,85 +1,124 @@ |
1 | $NetBSD: patch-ab,v 1.9 2014/10/01 01:17:33 jmcneill Exp $ | | 1 | $NetBSD: patch-ab,v 1.10 2015/01/04 18:42:50 jmcneill Exp $ |
2 | | | 2 | |
3 | --- estd.c.orig 2009-10-20 16:18:28.000000000 +0000 | | 3 | --- estd.c.orig 2009-10-20 16:18:28.000000000 +0000 |
4 | +++ estd.c 2014-09-30 11:10:54.000000000 +0000 | | 4 | +++ estd.c |
5 | @@ -55,7 +55,10 @@ | | 5 | @@ -55,7 +55,11 @@ |
6 | #define TECH_EST 1 | | 6 | #define TECH_EST 1 |
7 | #define TECH_POWERNOW 2 | | 7 | #define TECH_POWERNOW 2 |
8 | #define TECH_ACPI 3 | | 8 | #define TECH_ACPI 3 |
9 | -#define TECH_MAX 3 | | 9 | -#define TECH_MAX 3 |
10 | +#define TECH_INTREPID 4 | | 10 | +#define TECH_INTREPID 4 |
11 | +#define TECH_LOONGSON 5 | | 11 | +#define TECH_LOONGSON 5 |
12 | +#define TECH_GENERIC 6 | | 12 | +#define TECH_ROCKCHIP 6 |
13 | +#define TECH_MAX 6 | | 13 | +#define TECH_GENERIC 7 |
| | | 14 | +#define TECH_MAX 7 |
14 | | | 15 | |
15 | /* this is ugly, but... <shrug> */ | | 16 | /* this is ugly, but... <shrug> */ |
16 | #define MAX_FREQS 32 | | 17 | #define MAX_FREQS 32 |
17 | @@ -116,26 +119,35 @@ int ndomains; | | 18 | @@ -116,26 +120,38 @@ int ndomains; |
18 | static size_t cp_time_size = sizeof(cp_time[0]) * CPUSTATES; | | 19 | static size_t cp_time_size = sizeof(cp_time[0]) * CPUSTATES; |
19 | #endif | | 20 | #endif |
20 | | | 21 | |
21 | -static char *techdesc[4] = {"Unknown", | | 22 | -static char *techdesc[4] = {"Unknown", |
22 | +static char *techdesc[7] = {"Unknown", | | 23 | +static char *techdesc[8] = {"Unknown", |
23 | "Enhanced SpeedStep", | | 24 | "Enhanced SpeedStep", |
24 | "PowerNow", | | 25 | "PowerNow", |
25 | - "ACPI P-States" | | 26 | - "ACPI P-States" |
26 | + "ACPI P-States", | | 27 | + "ACPI P-States", |
27 | + "Intrepid", | | 28 | + "Intrepid", |
28 | + "Loongson", | | 29 | + "Loongson", |
| | | 30 | + "Rockchip", |
29 | + "Generic" | | 31 | + "Generic" |
30 | }; | | 32 | }; |
31 | -static char *freqctl[4] = { "", | | 33 | -static char *freqctl[4] = { "", |
32 | +static char *freqctl[7] = { "", | | 34 | +static char *freqctl[8] = { "", |
33 | "machdep.est.frequency.available", | | 35 | "machdep.est.frequency.available", |
34 | "machdep.powernow.frequency.available", | | 36 | "machdep.powernow.frequency.available", |
35 | - "hw.acpi.cpu.px_dom0.available" | | 37 | - "hw.acpi.cpu.px_dom0.available" |
36 | + "hw.acpi.cpu.px_dom0.available", | | 38 | + "hw.acpi.cpu.px_dom0.available", |
37 | + "machdep.intrepid.frequency.available", | | 39 | + "machdep.intrepid.frequency.available", |
38 | + "machdep.loongson.frequency.available", | | 40 | + "machdep.loongson.frequency.available", |
| | | 41 | + "machdep.cpu.frequency.available", |
39 | + "machdep.frequency.available" | | 42 | + "machdep.frequency.available" |
40 | }; | | 43 | }; |
41 | -static char *setctl[4] = { "", | | 44 | -static char *setctl[4] = { "", |
42 | +static char *setctl[7] = { "", | | 45 | +static char *setctl[8] = { "", |
43 | "machdep.est.frequency.target", | | 46 | "machdep.est.frequency.target", |
44 | "machdep.powernow.frequency.target", | | 47 | "machdep.powernow.frequency.target", |
45 | - "hw.acpi.cpu.px_dom0.select" | | 48 | - "hw.acpi.cpu.px_dom0.select" |
46 | + "hw.acpi.cpu.px_dom0.select", | | 49 | + "hw.acpi.cpu.px_dom0.select", |
47 | + "machdep.intrepid.frequency.target", | | 50 | + "machdep.intrepid.frequency.target", |
48 | + "machdep.loongson.frequency.target", | | 51 | + "machdep.loongson.frequency.target", |
| | | 52 | + "machdep.cpu.frequency.target", |
49 | + "machdep.frequency.current" | | 53 | + "machdep.frequency.current" |
50 | }; | | 54 | }; |
51 | | | 55 | |
52 | void | | 56 | void |
53 | usage() | | 57 | usage() |
54 | { | | 58 | { |
55 | - 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"); | | 59 | - 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"); |
56 | + 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"); | | 60 | + 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"); |
57 | printf(" estd -v\n"); | | 61 | printf(" estd -v\n"); |
58 | printf(" estd -f\n"); | | 62 | printf(" estd -f\n"); |
59 | exit(1); | | 63 | exit(1); |
60 | @@ -367,7 +379,7 @@ main(int argc, char *argv[]) | | 64 | @@ -367,7 +383,7 @@ main(int argc, char *argv[]) |
61 | FILE *fexists; | | 65 | FILE *fexists; |
62 | | | 66 | |
63 | /* get command-line options */ | | 67 | /* get command-line options */ |
64 | - while ((ch = getopt(argc, argv, "vfdonACEPasbp:h:l:g:m:M:")) != -1) | | 68 | - while ((ch = getopt(argc, argv, "vfdonACEPasbp:h:l:g:m:M:")) != -1) |
65 | + while ((ch = getopt(argc, argv, "vfdonACEPILGasbp:h:l:g:m:M:")) != -1) | | 69 | + while ((ch = getopt(argc, argv, "vfdonACEPILGasbp:h:l:g:m:M:")) != -1) |
66 | switch (ch) { | | 70 | switch (ch) { |
67 | case 'v': | | 71 | case 'v': |
68 | version(); | | 72 | version(); |
69 | @@ -400,6 +412,16 @@ main(int argc, char *argv[]) | | 73 | @@ -400,6 +416,19 @@ main(int argc, char *argv[]) |
70 | break; | | 74 | break; |
71 | case 'P': | | 75 | case 'P': |
72 | tech = TECH_POWERNOW; | | 76 | tech = TECH_POWERNOW; |
73 | + break; | | 77 | + break; |
74 | + case 'I': | | 78 | + case 'I': |
75 | + tech = TECH_INTREPID; | | 79 | + tech = TECH_INTREPID; |
76 | + break; | | 80 | + break; |
77 | + case 'L': | | 81 | + case 'L': |
78 | + tech = TECH_LOONGSON; | | 82 | + tech = TECH_LOONGSON; |
79 | + break; | | 83 | + break; |
| | | 84 | + case 'R': |
| | | 85 | + tech = TECH_ROCKCHIP; |
| | | 86 | + break; |
80 | + case 'G': | | 87 | + case 'G': |
81 | + tech = TECH_GENERIC; | | 88 | + tech = TECH_GENERIC; |
82 | + break; | | 89 | + break; |
83 | case 'a': | | 90 | case 'a': |
84 | strategy = AGGRESSIVE; | | 91 | strategy = AGGRESSIVE; |
85 | break; | | 92 | break; |
| | | 93 | @@ -434,8 +463,9 @@ main(int argc, char *argv[]) |
| | | 94 | |
| | | 95 | ndomains = 1; |
| | | 96 | domain = ecalloc(ndomains, sizeof(struct domain)); |
| | | 97 | - |
| | | 98 | - #if defined(__DragonFly__) |
| | | 99 | + |
| | | 100 | +#if defined(__NetBSD__) || defined(__DragonFly__) |
| | | 101 | +# if defined(__DragonFly__) |
| | | 102 | if (kinfo_get_cpus(&ncpus)) { |
| | | 103 | fprintf(stderr, "estd: Cannot get number of cpus\n"); |
| | | 104 | exit(1); |
| | | 105 | @@ -443,11 +473,18 @@ main(int argc, char *argv[]) |
| | | 106 | cp_time = ecalloc(ncpus, sizeof(struct kinfo_cputime)); |
| | | 107 | cp_old = ecalloc(ncpus, sizeof(struct kinfo_cputime)); |
| | | 108 | cp_time_len = ncpus * sizeof(struct kinfo_cputime); |
| | | 109 | +# elif defined(__NetBSD__) |
| | | 110 | + size_t ncpus_len = sizeof(ncpus); |
| | | 111 | + if (sysctlbyname("hw.ncpu", &ncpus, &ncpus_len, NULL, 0) != 0) { |
| | | 112 | + fprintf(stderr, "estd: Cannot get number of cpus\n"); |
| | | 113 | + exit(1); |
| | | 114 | + } |
| | | 115 | +# endif |
| | | 116 | domain[0].ncpus = ncpus; |
| | | 117 | domain[0].cpus = ecalloc(ncpus, sizeof(int)); |
| | | 118 | for (i = 0; i < domain[0].ncpus; i++) |
| | | 119 | domain[0].cpus[i] = i; |
| | | 120 | - #endif |
| | | 121 | +#endif |
| | | 122 | |
| | | 123 | /* try to guess cpu-scaling technology */ |
| | | 124 | if (tech == TECH_UNKNOWN) { |