ofw_subr.c revision 1.29 1 1.29 jmcneill /* $NetBSD: ofw_subr.c,v 1.29 2017/06/30 09:17:05 jmcneill Exp $ */
2 1.1 cgd
3 1.1 cgd /*
4 1.1 cgd * Copyright 1998
5 1.1 cgd * Digital Equipment Corporation. All rights reserved.
6 1.1 cgd *
7 1.1 cgd * This software is furnished under license and may be used and
8 1.1 cgd * copied only in accordance with the following terms and conditions.
9 1.1 cgd * Subject to these conditions, you may download, copy, install,
10 1.1 cgd * use, modify and distribute this software in source and/or binary
11 1.1 cgd * form. No title or ownership is transferred hereby.
12 1.1 cgd *
13 1.1 cgd * 1) Any source code used, modified or distributed must reproduce
14 1.1 cgd * and retain this copyright notice and list of conditions as
15 1.1 cgd * they appear in the source file.
16 1.1 cgd *
17 1.1 cgd * 2) No right is granted to use any trade name, trademark, or logo of
18 1.1 cgd * Digital Equipment Corporation. Neither the "Digital Equipment
19 1.1 cgd * Corporation" name nor any trademark or logo of Digital Equipment
20 1.1 cgd * Corporation may be used to endorse or promote products derived
21 1.1 cgd * from this software without the prior written permission of
22 1.1 cgd * Digital Equipment Corporation.
23 1.1 cgd *
24 1.1 cgd * 3) This software is provided "AS-IS" and any express or implied
25 1.1 cgd * warranties, including but not limited to, any implied warranties
26 1.1 cgd * of merchantability, fitness for a particular purpose, or
27 1.1 cgd * non-infringement are disclaimed. In no event shall DIGITAL be
28 1.1 cgd * liable for any damages whatsoever, and in particular, DIGITAL
29 1.1 cgd * shall not be liable for special, indirect, consequential, or
30 1.1 cgd * incidental damages or damages for lost profits, loss of
31 1.1 cgd * revenue or loss of use, whether such damages arise in contract,
32 1.1 cgd * negligence, tort, under statute, in equity, at law or otherwise,
33 1.1 cgd * even if advised of the possibility of such damage.
34 1.1 cgd */
35 1.7 lukem
36 1.7 lukem #include <sys/cdefs.h>
37 1.29 jmcneill __KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.29 2017/06/30 09:17:05 jmcneill Exp $");
38 1.1 cgd
39 1.2 cgd #include <sys/param.h>
40 1.2 cgd #include <sys/systm.h>
41 1.2 cgd #include <sys/malloc.h>
42 1.2 cgd #include <dev/ofw/openfirm.h>
43 1.2 cgd
44 1.3 cgd #define OFW_MAX_STACK_BUF_SIZE 256
45 1.3 cgd #define OFW_PATH_BUF_SIZE 512
46 1.3 cgd
47 1.1 cgd /*
48 1.3 cgd * int of_decode_int(p)
49 1.3 cgd *
50 1.3 cgd * This routine converts OFW encoded-int datums
51 1.3 cgd * into the integer format of the host machine.
52 1.1 cgd *
53 1.3 cgd * It is primarily used to convert integer properties
54 1.3 cgd * returned by the OF_getprop routine.
55 1.2 cgd *
56 1.2 cgd * Arguments:
57 1.2 cgd * p pointer to unsigned char array which is an
58 1.2 cgd * OFW-encoded integer.
59 1.2 cgd *
60 1.2 cgd * Return Value:
61 1.2 cgd * Decoded integer value of argument p.
62 1.3 cgd *
63 1.3 cgd * Side Effects:
64 1.3 cgd * None.
65 1.1 cgd */
66 1.1 cgd int
67 1.14 dsl of_decode_int(const unsigned char *p)
68 1.1 cgd {
69 1.1 cgd unsigned int i = *p++ << 8;
70 1.1 cgd i = (i + *p++) << 8;
71 1.1 cgd i = (i + *p++) << 8;
72 1.1 cgd return (i + *p);
73 1.2 cgd }
74 1.2 cgd
75 1.2 cgd /*
76 1.3 cgd * int of_compatible(phandle, strings)
77 1.3 cgd *
78 1.2 cgd * This routine checks an OFW node's "compatible" entry to see if
79 1.2 cgd * it matches any of the provided strings.
80 1.2 cgd *
81 1.2 cgd * It should be used when determining whether a driver can drive
82 1.24 jmcneill * a particular device.
83 1.2 cgd *
84 1.2 cgd * Arguments:
85 1.2 cgd * phandle OFW phandle of device to be checked for
86 1.2 cgd * compatibility.
87 1.2 cgd * strings Array of containing expected "compatibility"
88 1.2 cgd * property values, presence of any of which
89 1.2 cgd * indicates compatibility.
90 1.2 cgd *
91 1.2 cgd * Return Value:
92 1.8 wiz * -1 if none of the strings are found in phandle's "compatibility"
93 1.24 jmcneill * property, or the reverse index of the matching string in the
94 1.24 jmcneill * phandle's "compatibility" property.
95 1.3 cgd *
96 1.3 cgd * Side Effects:
97 1.3 cgd * None.
98 1.2 cgd */
99 1.2 cgd int
100 1.12 garbled of_compatible(int phandle, const char * const *strings)
101 1.2 cgd {
102 1.24 jmcneill
103 1.24 jmcneill int len, olen, allocated, nstr, cstr, rv;
104 1.2 cgd char *buf;
105 1.2 cgd const char *sp, *nsp;
106 1.2 cgd
107 1.2 cgd len = OF_getproplen(phandle, "compatible");
108 1.2 cgd if (len <= 0)
109 1.2 cgd return (-1);
110 1.2 cgd
111 1.3 cgd if (len > OFW_MAX_STACK_BUF_SIZE) {
112 1.2 cgd buf = malloc(len, M_TEMP, M_WAITOK);
113 1.2 cgd allocated = 1;
114 1.2 cgd } else {
115 1.2 cgd buf = alloca(len);
116 1.2 cgd allocated = 0;
117 1.2 cgd }
118 1.2 cgd
119 1.2 cgd /* 'compatible' size should not change. */
120 1.2 cgd if (OF_getprop(phandle, "compatible", buf, len) != len) {
121 1.2 cgd rv = -1;
122 1.2 cgd goto out;
123 1.2 cgd }
124 1.2 cgd
125 1.24 jmcneill /* count 'compatible' strings */
126 1.24 jmcneill sp = buf;
127 1.24 jmcneill nstr = 0;
128 1.24 jmcneill olen = len;
129 1.24 jmcneill while (len && (nsp = memchr(sp, 0, len)) != NULL) {
130 1.24 jmcneill nsp++; /* skip over NUL char */
131 1.24 jmcneill len -= (nsp - sp);
132 1.24 jmcneill sp = nsp;
133 1.24 jmcneill nstr++;
134 1.24 jmcneill }
135 1.24 jmcneill len = olen;
136 1.24 jmcneill
137 1.2 cgd sp = buf;
138 1.24 jmcneill rv = nstr;
139 1.2 cgd while (len && (nsp = memchr(sp, 0, len)) != NULL) {
140 1.24 jmcneill rv--;
141 1.2 cgd /* look for a match among the strings provided */
142 1.24 jmcneill for (cstr = 0; strings[cstr] != NULL; cstr++)
143 1.24 jmcneill if (strcmp(sp, strings[cstr]) == 0)
144 1.2 cgd goto out;
145 1.2 cgd
146 1.2 cgd nsp++; /* skip over NUL char */
147 1.2 cgd len -= (nsp - sp);
148 1.2 cgd sp = nsp;
149 1.2 cgd }
150 1.2 cgd rv = -1;
151 1.2 cgd
152 1.2 cgd out:
153 1.2 cgd if (allocated)
154 1.2 cgd free(buf, M_TEMP);
155 1.2 cgd return (rv);
156 1.24 jmcneill }
157 1.10 perry
158 1.24 jmcneill /*
159 1.24 jmcneill * int of_match_compatible(phandle, strings)
160 1.24 jmcneill *
161 1.24 jmcneill * This routine checks an OFW node's "compatible" entry to see if
162 1.24 jmcneill * it matches any of the provided strings.
163 1.24 jmcneill *
164 1.24 jmcneill * It should be used when determining whether a driver can drive
165 1.24 jmcneill * a particular device.
166 1.24 jmcneill *
167 1.24 jmcneill * Arguments:
168 1.24 jmcneill * phandle OFW phandle of device to be checked for
169 1.24 jmcneill * compatibility.
170 1.24 jmcneill * strings Array of containing expected "compatibility"
171 1.24 jmcneill * property values, presence of any of which
172 1.24 jmcneill * indicates compatibility.
173 1.24 jmcneill *
174 1.24 jmcneill * Return Value:
175 1.24 jmcneill * 0 if none of the strings are found in phandle's "compatibility"
176 1.24 jmcneill * property, or a positive number based on the reverse index of the
177 1.24 jmcneill * matching string in the phandle's "compatibility" property, plus 1.
178 1.24 jmcneill *
179 1.24 jmcneill * Side Effects:
180 1.24 jmcneill * None.
181 1.24 jmcneill */
182 1.24 jmcneill int
183 1.24 jmcneill of_match_compatible(int phandle, const char * const *strings)
184 1.24 jmcneill {
185 1.24 jmcneill return of_compatible(phandle, strings) + 1;
186 1.3 cgd }
187 1.3 cgd
188 1.3 cgd /*
189 1.29 jmcneill * const struct of_compat_data *of_search_compatible(phandle, compat_data)
190 1.29 jmcneill *
191 1.29 jmcneill * This routine searches an array of compat_data structures for a
192 1.29 jmcneill * matching "compatible" entry matching the supplied OFW node.
193 1.29 jmcneill *
194 1.29 jmcneill * Arguments:
195 1.29 jmcneill * phandle OFW phandle of device to be checked for
196 1.29 jmcneill * compatibility.
197 1.29 jmcneill * compat_data Array of possible compat entry strings and
198 1.29 jmcneill * associated metadata. The last entry in the
199 1.29 jmcneill * list should have a "compat" of NULL to terminate
200 1.29 jmcneill * the list.
201 1.29 jmcneill *
202 1.29 jmcneill * Return Value:
203 1.29 jmcneill * The first matching compat_data entry in the array. If no matches
204 1.29 jmcneill * are found, the terminating ("compat" of NULL) record is returned.
205 1.29 jmcneill *
206 1.29 jmcneill * Side Effects:
207 1.29 jmcneill * None.
208 1.29 jmcneill */
209 1.29 jmcneill const struct of_compat_data *
210 1.29 jmcneill of_search_compatible(int phandle, const struct of_compat_data *compat_data)
211 1.29 jmcneill {
212 1.29 jmcneill for (; compat_data->compat != NULL; compat_data++) {
213 1.29 jmcneill const char *compat[] = { compat_data->compat, NULL };
214 1.29 jmcneill if (of_match_compatible(phandle, compat))
215 1.29 jmcneill break;
216 1.29 jmcneill }
217 1.29 jmcneill return compat_data;
218 1.29 jmcneill }
219 1.29 jmcneill
220 1.29 jmcneill /*
221 1.4 cgd * int of_packagename(phandle, buf, bufsize)
222 1.3 cgd *
223 1.3 cgd * This routine places the last component of an OFW node's name
224 1.3 cgd * into a user-provided buffer.
225 1.3 cgd *
226 1.3 cgd * It can be used during autoconfiguration to make printing of
227 1.3 cgd * device names more informative.
228 1.3 cgd *
229 1.3 cgd * Arguments:
230 1.3 cgd * phandle OFW phandle of device whose name name is
231 1.3 cgd * desired.
232 1.3 cgd * buf Buffer to contain device name, provided by
233 1.3 cgd * caller. (For now, must be at least 4
234 1.3 cgd * bytes long.)
235 1.3 cgd * bufsize Length of buffer referenced by 'buf', in
236 1.3 cgd * bytes.
237 1.3 cgd *
238 1.3 cgd * Return Value:
239 1.3 cgd * -1 if the device path name could not be obtained or would
240 1.3 cgd * not fit in the allocated temporary buffer, or zero otherwise
241 1.6 soren * (meaning that the leaf node name was successfully extracted).
242 1.3 cgd *
243 1.3 cgd * Side Effects:
244 1.3 cgd * If the leaf node name was successfully extracted, 'buf' is
245 1.3 cgd * filled in with at most 'bufsize' bytes of the leaf node
246 1.3 cgd * name. If the leaf node was not successfully extracted, a
247 1.3 cgd * somewhat meaningful string is placed in the buffer. In
248 1.3 cgd * either case, the contents of 'buf' will be NUL-terminated.
249 1.3 cgd */
250 1.3 cgd int
251 1.12 garbled of_packagename(int phandle, char *buf, int bufsize)
252 1.3 cgd {
253 1.3 cgd char *pbuf;
254 1.3 cgd const char *lastslash;
255 1.3 cgd int l, rv;
256 1.3 cgd
257 1.3 cgd pbuf = malloc(OFW_PATH_BUF_SIZE, M_TEMP, M_WAITOK);
258 1.3 cgd l = OF_package_to_path(phandle, pbuf, OFW_PATH_BUF_SIZE);
259 1.3 cgd
260 1.3 cgd /* check that we could get the name, and that it's not too long. */
261 1.3 cgd if (l < 0 ||
262 1.3 cgd (l == OFW_PATH_BUF_SIZE && pbuf[OFW_PATH_BUF_SIZE - 1] != '\0')) {
263 1.3 cgd if (bufsize >= 25)
264 1.9 itojun snprintf(buf, bufsize, "??? (phandle 0x%x)", phandle);
265 1.3 cgd else if (bufsize >= 4)
266 1.9 itojun strlcpy(buf, "???", bufsize);
267 1.3 cgd else
268 1.4 cgd panic("of_packagename: bufsize = %d is silly",
269 1.4 cgd bufsize);
270 1.3 cgd rv = -1;
271 1.3 cgd } else {
272 1.5 mycroft pbuf[l] = '\0';
273 1.3 cgd lastslash = strrchr(pbuf, '/');
274 1.9 itojun strlcpy(buf, (lastslash == NULL) ? pbuf : (lastslash + 1),
275 1.3 cgd bufsize);
276 1.3 cgd rv = 0;
277 1.3 cgd }
278 1.3 cgd
279 1.3 cgd free(pbuf, M_TEMP);
280 1.3 cgd return (rv);
281 1.1 cgd }
282 1.12 garbled
283 1.12 garbled /*
284 1.13 garbled * Find the first child of a given node that matches name. Does not recurse.
285 1.12 garbled */
286 1.12 garbled int
287 1.12 garbled of_find_firstchild_byname(int node, const char *name)
288 1.12 garbled {
289 1.12 garbled char namex[32];
290 1.12 garbled int nn;
291 1.12 garbled
292 1.12 garbled for (nn = OF_child(node); nn; nn = OF_peer(nn)) {
293 1.12 garbled memset(namex, 0, sizeof(namex));
294 1.12 garbled if (OF_getprop(nn, "name", namex, sizeof(namex)) == -1)
295 1.12 garbled continue;
296 1.12 garbled if (strcmp(name, namex) == 0)
297 1.12 garbled return nn;
298 1.12 garbled }
299 1.12 garbled return -1;
300 1.12 garbled }
301 1.13 garbled
302 1.13 garbled /*
303 1.13 garbled * Find a give node by name. Recurses, and seems to walk upwards too.
304 1.13 garbled */
305 1.13 garbled
306 1.13 garbled int
307 1.13 garbled of_getnode_byname(int start, const char *target)
308 1.13 garbled {
309 1.13 garbled int node, next;
310 1.13 garbled char name[64];
311 1.13 garbled
312 1.13 garbled if (start == 0)
313 1.13 garbled start = OF_peer(0);
314 1.13 garbled
315 1.13 garbled for (node = start; node; node = next) {
316 1.13 garbled memset(name, 0, sizeof name);
317 1.13 garbled OF_getprop(node, "name", name, sizeof name - 1);
318 1.13 garbled if (strcmp(name, target) == 0)
319 1.13 garbled break;
320 1.13 garbled
321 1.13 garbled if ((next = OF_child(node)) != 0)
322 1.13 garbled continue;
323 1.13 garbled
324 1.13 garbled while (node) {
325 1.13 garbled if ((next = OF_peer(node)) != 0)
326 1.13 garbled break;
327 1.13 garbled node = OF_parent(node);
328 1.13 garbled }
329 1.13 garbled }
330 1.13 garbled
331 1.13 garbled /* XXX is this correct? */
332 1.13 garbled return node;
333 1.13 garbled }
334 1.13 garbled
335 1.13 garbled /*
336 1.13 garbled * Create a uint32_t integer property from an OFW node property.
337 1.13 garbled */
338 1.13 garbled
339 1.13 garbled boolean_t
340 1.13 garbled of_to_uint32_prop(prop_dictionary_t dict, int node, const char *ofname,
341 1.13 garbled const char *propname)
342 1.13 garbled {
343 1.13 garbled uint32_t prop;
344 1.13 garbled
345 1.13 garbled if (OF_getprop(node, ofname, &prop, sizeof(prop)) != sizeof(prop))
346 1.13 garbled return FALSE;
347 1.13 garbled
348 1.13 garbled return(prop_dictionary_set_uint32(dict, propname, prop));
349 1.13 garbled }
350 1.13 garbled
351 1.13 garbled /*
352 1.13 garbled * Create a data property from an OFW node property. Max size of 256bytes.
353 1.13 garbled */
354 1.13 garbled
355 1.13 garbled boolean_t
356 1.13 garbled of_to_dataprop(prop_dictionary_t dict, int node, const char *ofname,
357 1.13 garbled const char *propname)
358 1.13 garbled {
359 1.13 garbled prop_data_t data;
360 1.13 garbled int len;
361 1.13 garbled uint8_t prop[256];
362 1.16 martin boolean_t res;
363 1.13 garbled
364 1.13 garbled len = OF_getprop(node, ofname, prop, 256);
365 1.13 garbled if (len < 1)
366 1.13 garbled return FALSE;
367 1.13 garbled
368 1.13 garbled data = prop_data_create_data(prop, len);
369 1.16 martin res = prop_dictionary_set(dict, propname, data);
370 1.16 martin prop_object_release(data);
371 1.16 martin return res;
372 1.13 garbled }
373 1.15 macallan
374 1.15 macallan /*
375 1.15 macallan * look at output-device, see if there's a Sun-typical video mode specifier as
376 1.15 macallan * in screen:r1024x768x60 attached. If found copy it into *buffer, otherwise
377 1.15 macallan * return NULL
378 1.15 macallan */
379 1.15 macallan
380 1.15 macallan char *
381 1.15 macallan of_get_mode_string(char *buffer, int len)
382 1.15 macallan {
383 1.15 macallan int options;
384 1.15 macallan char *pos, output_device[256];
385 1.15 macallan
386 1.15 macallan /*
387 1.15 macallan * finally, let's see if there's a video mode specified in
388 1.15 macallan * output-device and pass it on so there's at least some way
389 1.15 macallan * to program video modes
390 1.15 macallan */
391 1.15 macallan options = OF_finddevice("/options");
392 1.15 macallan if ((options == 0) || (options == -1))
393 1.15 macallan return NULL;
394 1.15 macallan if (OF_getprop(options, "output-device", output_device, 256) == 0)
395 1.15 macallan return NULL;
396 1.15 macallan
397 1.15 macallan /* find the mode string if there is one */
398 1.15 macallan pos = strstr(output_device, ":r");
399 1.15 macallan if (pos == NULL)
400 1.15 macallan return NULL;
401 1.15 macallan strncpy(buffer, pos + 2, len);
402 1.15 macallan return buffer;
403 1.15 macallan }
404 1.17 martin
405 1.17 martin /*
406 1.17 martin * Iterate over the subtree of a i2c controller node.
407 1.17 martin * Add all sub-devices into an array as part of the controller's
408 1.17 martin * device properties.
409 1.17 martin * This is used by the i2c bus attach code to do direct configuration.
410 1.17 martin */
411 1.17 martin void
412 1.26 jmcneill of_enter_i2c_devs(prop_dictionary_t props, int ofnode, size_t cell_size,
413 1.26 jmcneill int addr_shift)
414 1.17 martin {
415 1.17 martin int node, len;
416 1.21 jdc char name[32], compatible[32];
417 1.18 martin uint64_t reg64;
418 1.18 martin uint32_t reg32;
419 1.18 martin uint64_t addr;
420 1.19 jdc prop_array_t array = NULL;
421 1.17 martin prop_dictionary_t dev;
422 1.17 martin
423 1.17 martin for (node = OF_child(ofnode); node; node = OF_peer(node)) {
424 1.17 martin if (OF_getprop(node, "name", name, sizeof(name)) <= 0)
425 1.17 martin continue;
426 1.17 martin len = OF_getproplen(node, "reg");
427 1.18 martin addr = 0;
428 1.18 martin if (cell_size == 8 && len >= sizeof(reg64)) {
429 1.18 martin if (OF_getprop(node, "reg", ®64, sizeof(reg64))
430 1.18 martin < sizeof(reg64))
431 1.17 martin continue;
432 1.25 jmcneill addr = be64toh(reg64);
433 1.20 jdc /*
434 1.20 jdc * The i2c bus number (0 or 1) is encoded in bit 33
435 1.20 jdc * of the register, but we encode it in bit 8 of
436 1.20 jdc * i2c_addr_t.
437 1.20 jdc */
438 1.20 jdc if (addr & 0x100000000)
439 1.20 jdc addr = (addr & 0xff) | 0x100;
440 1.18 martin } else if (cell_size == 4 && len >= sizeof(reg32)) {
441 1.18 martin if (OF_getprop(node, "reg", ®32, sizeof(reg32))
442 1.18 martin < sizeof(reg32))
443 1.17 martin continue;
444 1.25 jmcneill addr = be32toh(reg32);
445 1.17 martin } else {
446 1.18 martin continue;
447 1.17 martin }
448 1.26 jmcneill addr >>= addr_shift;
449 1.18 martin if (addr == 0) continue;
450 1.17 martin
451 1.19 jdc if (array == NULL)
452 1.19 jdc array = prop_array_create();
453 1.19 jdc
454 1.17 martin dev = prop_dictionary_create();
455 1.17 martin prop_dictionary_set_cstring(dev, "name", name);
456 1.18 martin prop_dictionary_set_uint32(dev, "addr", addr);
457 1.17 martin prop_dictionary_set_uint64(dev, "cookie", node);
458 1.17 martin of_to_dataprop(dev, node, "compatible", "compatible");
459 1.21 jdc if (OF_getprop(node, "compatible", compatible,
460 1.21 jdc sizeof(compatible)) > 0) {
461 1.21 jdc /* Set size for EEPROM's that we know about */
462 1.21 jdc if (strcmp(compatible, "i2c-at24c64") == 0)
463 1.21 jdc prop_dictionary_set_uint32(dev, "size", 8192);
464 1.23 jdc if (strcmp(compatible, "i2c-at34c02") == 0)
465 1.23 jdc prop_dictionary_set_uint32(dev, "size", 256);
466 1.21 jdc }
467 1.17 martin prop_array_add(array, dev);
468 1.17 martin prop_object_release(dev);
469 1.17 martin }
470 1.17 martin
471 1.19 jdc if (array != NULL) {
472 1.19 jdc prop_dictionary_set(props, "i2c-child-devices", array);
473 1.19 jdc prop_object_release(array);
474 1.19 jdc }
475 1.22 jdc
476 1.22 jdc prop_dictionary_set_bool(props, "i2c-indirect-config", false);
477 1.17 martin }
478 1.27 jmcneill
479 1.27 jmcneill /*
480 1.28 jmcneill * Returns true if the specified property is present.
481 1.27 jmcneill */
482 1.27 jmcneill bool
483 1.28 jmcneill of_hasprop(int node, const char *prop)
484 1.27 jmcneill {
485 1.27 jmcneill return OF_getproplen(node, prop) >= 0;
486 1.27 jmcneill }
487 1.27 jmcneill
488 1.27 jmcneill /*
489 1.27 jmcneill * Get the value of a uint32 property, compensating for host byte order.
490 1.27 jmcneill * Returns 0 on success, non-zero on failure.
491 1.27 jmcneill */
492 1.27 jmcneill int
493 1.27 jmcneill of_getprop_uint32(int node, const char *prop, uint32_t *val)
494 1.27 jmcneill {
495 1.27 jmcneill uint32_t v;
496 1.27 jmcneill int len;
497 1.27 jmcneill
498 1.27 jmcneill len = OF_getprop(node, prop, &v, sizeof(v));
499 1.27 jmcneill if (len != sizeof(v))
500 1.27 jmcneill return -1;
501 1.27 jmcneill
502 1.27 jmcneill *val = be32toh(v);
503 1.27 jmcneill return 0;
504 1.27 jmcneill }
505