Lines 1-6
Link Here
|
1 |
--- bsd/kernel.cc.orig Tue Oct 9 10:40:51 2001 |
1 |
--- bsd/kernel.cc.orig Tue Oct 14 03:53:17 2003 |
2 |
+++ bsd/kernel.cc Mon Oct 27 20:03:03 2003 |
2 |
+++ bsd/kernel.cc Thu Mar 17 23:26:49 2005 |
3 |
@@ -46,6 +46,7 @@ |
3 |
@@ -54,6 +54,7 @@ |
4 |
#endif |
4 |
#endif |
5 |
|
5 |
|
6 |
#ifdef HAVE_DEVSTAT |
6 |
#ifdef HAVE_DEVSTAT |
Lines 8-15
Link Here
|
8 |
#include <devstat.h> |
8 |
#include <devstat.h> |
9 |
#include <stdlib.h> /* For malloc(). */ |
9 |
#include <stdlib.h> /* For malloc(). */ |
10 |
void DevStat_Init(); |
10 |
void DevStat_Init(); |
11 |
@@ -297,7 +298,12 @@ |
11 |
@@ -211,19 +212,28 @@ |
12 |
while (nlp && nlp->n_name) { |
12 |
|
|
|
13 |
{ "_bufspace" }, |
14 |
#define BUFSPACE_SYM_INDEX 3 |
15 |
+#if __FreeBSD_version < 500000 |
16 |
{ "_intr_countp" }, |
17 |
#define INTRCOUNTP_SYM_INDEX 4 |
18 |
+{ DUMMY_SYM }, |
19 |
+#define DUMMY_5 5 |
20 |
+#else |
21 |
+{ "_intrnames" }, |
22 |
+#define INTRNAMES_SYM_INDEX 4 |
23 |
+{ "_eintrnames" }, |
24 |
+#define EINTRNAMES_SYM_INDEX 5 |
25 |
+#endif /* FreeBSD < 5.x */ |
26 |
{ "_intrcnt" }, |
27 |
-#define INTRCNT_SYM_INDEX 5 |
28 |
+#define INTRCNT_SYM_INDEX 6 |
29 |
{ "_eintrcnt" }, |
30 |
-#define EINTRCNT_SYM_INDEX 6 |
31 |
+#define EINTRCNT_SYM_INDEX 7 |
32 |
|
33 |
#ifndef HAVE_DEVSTAT |
34 |
|
35 |
{ "_dk_ndrive" }, |
36 |
-#define DK_NDRIVE_SYM_INDEX 7 |
37 |
+#define DK_NDRIVE_SYM_INDEX 8 |
38 |
{ "_dk_wds" }, |
39 |
-#define DK_WDS_SYM_INDEX 8 |
40 |
+#define DK_WDS_SYM_INDEX 9 |
41 |
|
42 |
#endif /*HAVE_DEVSTAT */ |
43 |
|
44 |
@@ -329,7 +339,12 @@ |
45 |
while (nlp && nlp->n_name && strncmp(nlp->n_name, DUMMY_SYM, strlen(DUMMY_SYM))) { |
13 |
if ((nlp->n_type == 0) || (nlp->n_value == 0)) |
46 |
if ((nlp->n_type == 0) || (nlp->n_value == 0)) |
14 |
/*errx (-1, "kvm_nlist() lookup failed for symbol '%s'.", nlp->n_name);*/ |
47 |
/*errx (-1, "kvm_nlist() lookup failed for symbol '%s'.", nlp->n_name);*/ |
15 |
+#if defined(XOSVIEW_FREEBSD) && defined(__alpha__) |
48 |
+#if defined(XOSVIEW_FREEBSD) && defined(__alpha__) |
Lines 21-36
Link Here
|
21 |
nlp++; |
54 |
nlp++; |
22 |
} |
55 |
} |
23 |
#ifdef HAVE_DEVSTAT |
56 |
#ifdef HAVE_DEVSTAT |
24 |
@@ -493,7 +499,7 @@ |
57 |
@@ -597,13 +612,21 @@ |
25 |
// |
|
|
26 |
|
27 |
void |
28 |
-BSDGetSwapCtlInfo(int *totalp, int *freep) { |
29 |
+BSDGetSwapCtlInfo(int64_t *totalp, int64_t *freep) { |
30 |
int totalinuse, totalsize; |
31 |
int rnswap, nswap = swapctl(SWAP_NSWAP, 0, 0); |
32 |
struct swapent *swapiter; |
33 |
@@ -557,13 +563,21 @@ |
34 |
* Make sure that the userland devstat version matches the kernel |
58 |
* Make sure that the userland devstat version matches the kernel |
35 |
* devstat version. |
59 |
* devstat version. |
36 |
*/ |
60 |
*/ |
Lines 52-58
Link Here
|
52 |
nodisk++; |
76 |
nodisk++; |
53 |
return; |
77 |
return; |
54 |
} |
78 |
} |
55 |
@@ -578,7 +592,11 @@ |
79 |
@@ -618,7 +641,11 @@ |
56 |
* changed here, since it almost certainly has. We only look for |
80 |
* changed here, since it almost certainly has. We only look for |
57 |
* errors. |
81 |
* errors. |
58 |
*/ |
82 |
*/ |
Lines 64-70
Link Here
|
64 |
nodisk++; |
88 |
nodisk++; |
65 |
return; |
89 |
return; |
66 |
} |
90 |
} |
67 |
@@ -590,7 +608,11 @@ |
91 |
@@ -630,7 +657,11 @@ |
68 |
|
92 |
|
69 |
/* only interested in disks */ |
93 |
/* only interested in disks */ |
70 |
matches = NULL; |
94 |
matches = NULL; |
Lines 76-82
Link Here
|
76 |
nodisk++; |
100 |
nodisk++; |
77 |
return; |
101 |
return; |
78 |
} |
102 |
} |
79 |
@@ -605,7 +627,11 @@ |
103 |
@@ -645,7 +676,11 @@ |
80 |
* device list has changed, so we don't look for return values of 0 |
104 |
* device list has changed, so we don't look for return values of 0 |
81 |
* or 1. If we get back -1, though, there is an error. |
105 |
* or 1. If we get back -1, though, there is an error. |
82 |
*/ |
106 |
*/ |
Lines 88-94
Link Here
|
88 |
&num_selections, &select_generation, |
112 |
&num_selections, &select_generation, |
89 |
generation, cur.dinfo->devices, num_devices, |
113 |
generation, cur.dinfo->devices, num_devices, |
90 |
matches, num_matches, |
114 |
matches, num_matches, |
91 |
@@ -632,7 +658,11 @@ |
115 |
@@ -672,7 +707,11 @@ |
92 |
* the selection process again, in case a device that we |
116 |
* the selection process again, in case a device that we |
93 |
* were previously displaying has gone away. |
117 |
* were previously displaying has gone away. |
94 |
*/ |
118 |
*/ |
Lines 100-106
Link Here
|
100 |
case -1: |
124 |
case -1: |
101 |
return (0); |
125 |
return (0); |
102 |
case 1: { |
126 |
case 1: { |
103 |
@@ -640,7 +670,11 @@ |
127 |
@@ -680,7 +719,11 @@ |
104 |
|
128 |
|
105 |
num_devices = cur.dinfo->numdevs; |
129 |
num_devices = cur.dinfo->numdevs; |
106 |
generation = cur.dinfo->generation; |
130 |
generation = cur.dinfo->generation; |
Lines 112-118
Link Here
|
112 |
&num_selections, &select_generation, |
136 |
&num_selections, &select_generation, |
113 |
generation, cur.dinfo->devices, |
137 |
generation, cur.dinfo->devices, |
114 |
num_devices, matches, num_matches, |
138 |
num_devices, matches, num_matches, |
115 |
@@ -664,14 +698,22 @@ |
139 |
@@ -704,14 +747,22 @@ |
116 |
* Calculate elapsed time up front, since it's the same for all |
140 |
* Calculate elapsed time up front, since it's the same for all |
117 |
* devices. |
141 |
* devices. |
118 |
*/ |
142 |
*/ |
Lines 135-141
Link Here
|
135 |
return (0); |
159 |
return (0); |
136 |
} |
160 |
} |
137 |
|
161 |
|
138 |
@@ -685,7 +727,11 @@ |
162 |
@@ -725,7 +776,11 @@ |
139 |
|
163 |
|
140 |
di = dev_select[dn].position; |
164 |
di = dev_select[dn].position; |
141 |
|
165 |
|
Lines 147-153
Link Here
|
147 |
&last.dinfo->devices[di], busy_seconds, |
171 |
&last.dinfo->devices[di], busy_seconds, |
148 |
&total_bytes, &total_transfers, |
172 |
&total_bytes, &total_transfers, |
149 |
NULL, NULL, |
173 |
NULL, NULL, |
150 |
@@ -700,7 +746,11 @@ |
174 |
@@ -740,7 +795,11 @@ |
151 |
last.dinfo = cur.dinfo; |
175 |
last.dinfo = cur.dinfo; |
152 |
cur.dinfo = tmp_dinfo; |
176 |
cur.dinfo = tmp_dinfo; |
153 |
|
177 |
|
Lines 159-165
Link Here
|
159 |
|
183 |
|
160 |
} else { |
184 |
} else { |
161 |
/* no disks found ? */ |
185 |
/* no disks found ? */ |
162 |
@@ -828,25 +878,25 @@ |
186 |
@@ -912,25 +971,26 @@ |
163 |
OpenKDIfNeeded(); |
187 |
OpenKDIfNeeded(); |
164 |
nintr = (nlst[EINTRCNT_SYM_INDEX].n_value - |
188 |
nintr = (nlst[EINTRCNT_SYM_INDEX].n_value - |
165 |
nlst[INTRCNT_SYM_INDEX].n_value) / sizeof(int); |
189 |
nlst[INTRCNT_SYM_INDEX].n_value) / sizeof(int); |
Lines 189-205
Link Here
|
189 |
BSDGetIntrStats (unsigned long intrCount[NUM_INTR]) { |
213 |
BSDGetIntrStats (unsigned long intrCount[NUM_INTR]) { |
190 |
-#ifdef XOSVIEW_FREEBSD |
214 |
-#ifdef XOSVIEW_FREEBSD |
191 |
+#if defined(XOSVIEW_FREEBSD) && defined(__i386__) |
215 |
+#if defined(XOSVIEW_FREEBSD) && defined(__i386__) |
|
|
216 |
+#if __FreeBSD_version < 500000 |
192 |
/* FreeBSD has an array of interrupt counts, indexed by device number. |
217 |
/* FreeBSD has an array of interrupt counts, indexed by device number. |
193 |
These are also indirected by IRQ num with intr_countp: */ |
218 |
These are also indirected by IRQ num with intr_countp: */ |
194 |
safe_kvm_read (nlst[INTRCOUNTP_SYM_INDEX].n_value, |
219 |
safe_kvm_read (nlst[INTRCOUNTP_SYM_INDEX].n_value, |
195 |
@@ -875,8 +925,8 @@ |
220 |
@@ -944,6 +1004,38 @@ |
196 |
intrCount[i] = kvm_intrptrs[i]; |
221 |
sizeof(unsigned long); |
197 |
#endif /* _BSDI_VERSION */ |
222 |
intrCount[i] = kvm_intrcnt[idx]; |
198 |
|
223 |
} |
199 |
-#else /* XOSVIEW_FREEBSD */ |
224 |
+#else /* FreeBSD 5.x and 6.x */ |
200 |
- // NetBSD/OpenBSD version, based on vmstat.c. Note that the pc532 |
225 |
+ /* This code is stolen from vmstat */ |
201 |
+#else /* XOSVIEW_FREEBSD & i386 */ |
226 |
+ unsigned long *kvm_intrcnt; |
202 |
+ // NetBSD/OpenBSD & FreeBSD/Alpha version, based on vmstat.c. Note that the pc532 |
227 |
+ char *kvm_intrname; |
203 |
// platform does support intrcnt and eintrcnt, but vmstat uses |
228 |
+ size_t inamlen, intrcntlen; |
204 |
// the more advanced event counters to provide software |
229 |
+ unsigned int i, nintr; |
205 |
// counts. We'll just use the intrcnt array here. If anyone |
230 |
+ int d; |
|
|
231 |
+ |
232 |
+ intrcntlen = (nlst[EINTRCNT_SYM_INDEX].n_value - nlst[INTRCNT_SYM_INDEX].n_value); |
233 |
+ inamlen = nlst[EINTRNAMES_SYM_INDEX].n_value - nlst[INTRNAMES_SYM_INDEX].n_value; |
234 |
+ nintr = intrcntlen / sizeof(unsigned long); |
235 |
+ |
236 |
+ if (((kvm_intrcnt = (unsigned long *)malloc(intrcntlen)) == NULL) || |
237 |
+ ((kvm_intrname = (char *)malloc(inamlen)) == NULL)) |
238 |
+ err(1, "malloc()"); |
239 |
+ |
240 |
+ safe_kvm_read (nlst[INTRCNT_SYM_INDEX].n_value, kvm_intrcnt, intrcntlen); |
241 |
+ safe_kvm_read (nlst[INTRNAMES_SYM_INDEX].n_value, kvm_intrname, inamlen); |
242 |
+ |
243 |
+ /* kvm_intrname has the ASCII names of the IRQs, every null-terminated |
244 |
+ * string corresponds to a value in the kvm_intrcnt array */ |
245 |
+ for (i=0; i < nintr; i++) { |
246 |
+ if (kvm_intrname[0] != '\0' && (*kvm_intrcnt != 0)) { |
247 |
+ /* Figure out which irq we have here */ |
248 |
+ if (1 == sscanf(kvm_intrname, "irq%d:", &d)) |
249 |
+ if (d < NUM_INTR) |
250 |
+ intrCount[d] = *kvm_intrcnt; |
251 |
+ } |
252 |
+ kvm_intrcnt++; |
253 |
+ kvm_intrname += strlen(kvm_intrname) + 1; |
254 |
+ } |
255 |
+#endif |
256 |
#elif defined (XOSVIEW_BSDI) |
257 |
int nintr = 16; |
258 |
#if _BSDI_VERSION >= 199802 /* BSD/OS 4.x */ |