blob: 22f1b2ad19dde542171907924c30fcba1cc55f2b [file] [log] [blame]
David Gibson2f1ccc32007-11-01 16:49:26 +11001/*
2 * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2007.
3 *
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18 * USA
19 */
20
21#include "dtc.h"
22
David Gibsonb16a2bd2007-11-22 14:38:07 +110023#ifdef TRACE_CHECKS
24#define TRACE(c, ...) \
25 do { \
26 fprintf(stderr, "=== %s: ", (c)->name); \
27 fprintf(stderr, __VA_ARGS__); \
28 fprintf(stderr, "\n"); \
29 } while (0)
30#else
31#define TRACE(c, fmt, ...) do { } while (0)
32#endif
33
34enum checklevel {
35 IGNORE = 0,
36 WARN = 1,
37 ERROR = 2,
38};
39
40enum checkstatus {
41 UNCHECKED = 0,
42 PREREQ,
43 PASSED,
44 FAILED,
45};
46
47struct check;
48
49typedef void (*tree_check_fn)(struct check *c, struct node *dt);
50typedef void (*node_check_fn)(struct check *c, struct node *dt, struct node *node);
51typedef void (*prop_check_fn)(struct check *c, struct node *dt,
52 struct node *node, struct property *prop);
53
54struct check {
55 const char *name;
56 tree_check_fn tree_fn;
57 node_check_fn node_fn;
58 prop_check_fn prop_fn;
59 void *data;
60 enum checklevel level;
61 enum checkstatus status;
62 int inprogress;
63 int num_prereqs;
64 struct check **prereq;
65};
66
67#define CHECK(nm, tfn, nfn, pfn, d, lvl, ...) \
68 static struct check *nm##_prereqs[] = { __VA_ARGS__ }; \
69 static struct check nm = { \
70 .name = #nm, \
71 .tree_fn = (tfn), \
72 .node_fn = (nfn), \
73 .prop_fn = (pfn), \
74 .data = (d), \
75 .level = (lvl), \
76 .status = UNCHECKED, \
77 .num_prereqs = ARRAY_SIZE(nm##_prereqs), \
78 .prereq = nm##_prereqs, \
79 };
80
81#define TREE_CHECK(nm, d, lvl, ...) \
82 CHECK(nm, check_##nm, NULL, NULL, d, lvl, __VA_ARGS__)
83#define NODE_CHECK(nm, d, lvl, ...) \
84 CHECK(nm, NULL, check_##nm, NULL, d, lvl, __VA_ARGS__)
85#define PROP_CHECK(nm, d, lvl, ...) \
86 CHECK(nm, NULL, NULL, check_##nm, d, lvl, __VA_ARGS__)
87#define BATCH_CHECK(nm, lvl, ...) \
88 CHECK(nm, NULL, NULL, NULL, NULL, lvl, __VA_ARGS__)
89
90static inline void check_msg(struct check *c, const char *fmt, ...)
91{
92 va_list ap;
93 va_start(ap, fmt);
94
95 if ((c->level < WARN) || (c->level <= quiet))
96 return; /* Suppress message */
97
98 fprintf(stderr, "%s (%s): ",
99 (c->level == ERROR) ? "ERROR" : "Warning", c->name);
100 vfprintf(stderr, fmt, ap);
101 fprintf(stderr, "\n");
102}
103
David Gibsond06cda32007-12-05 09:34:53 +1100104#define FAIL(c, ...) \
David Gibsonb16a2bd2007-11-22 14:38:07 +1100105 do { \
106 TRACE((c), "\t\tFAILED at %s:%d", __FILE__, __LINE__); \
107 (c)->status = FAILED; \
David Gibsond06cda32007-12-05 09:34:53 +1100108 check_msg((c), __VA_ARGS__); \
David Gibsonb16a2bd2007-11-22 14:38:07 +1100109 } while (0)
110
111static void check_nodes_props(struct check *c, struct node *dt, struct node *node)
112{
113 struct node *child;
114 struct property *prop;
115
116 TRACE(c, "%s", node->fullpath);
117 if (c->node_fn)
118 c->node_fn(c, dt, node);
119
120 if (c->prop_fn)
121 for_each_property(node, prop) {
122 TRACE(c, "%s\t'%s'", node->fullpath, prop->name);
123 c->prop_fn(c, dt, node, prop);
124 }
125
126 for_each_child(node, child)
127 check_nodes_props(c, dt, child);
128}
129
130static int run_check(struct check *c, struct node *dt)
131{
132 int error = 0;
133 int i;
134
135 assert(!c->inprogress);
136
137 if (c->status != UNCHECKED)
138 goto out;
139
140 c->inprogress = 1;
141
142 for (i = 0; i < c->num_prereqs; i++) {
143 struct check *prq = c->prereq[i];
144 error |= run_check(prq, dt);
145 if (prq->status != PASSED) {
146 c->status = PREREQ;
147 check_msg(c, "Failed prerequisite '%s'",
148 c->prereq[i]->name);
149 }
150 }
151
152 if (c->status != UNCHECKED)
153 goto out;
154
155 if (c->node_fn || c->prop_fn)
156 check_nodes_props(c, dt, dt);
157
158 if (c->tree_fn)
159 c->tree_fn(c, dt);
160 if (c->status == UNCHECKED)
161 c->status = PASSED;
162
163 TRACE(c, "\tCompleted, status %d", c->status);
164
165out:
166 c->inprogress = 0;
167 if ((c->status != PASSED) && (c->level == ERROR))
168 error = 1;
169 return error;
170}
171
David Gibson2f1ccc32007-11-01 16:49:26 +1100172/*
David Gibson459c9552007-12-05 09:40:23 +1100173 * Utility check functions
174 */
175
176static void check_is_string(struct check *c, struct node *root,
177 struct node *node)
178{
179 struct property *prop;
180 char *propname = c->data;
181
182 prop = get_property(node, propname);
183 if (!prop)
184 return; /* Not present, assumed ok */
185
186 if (!data_is_one_string(prop->val))
187 FAIL(c, "\"%s\" property in %s is not a string",
188 propname, node->fullpath);
189}
190#define CHECK_IS_STRING(nm, propname, lvl) \
191 CHECK(nm, NULL, check_is_string, NULL, (propname), (lvl))
192
193/*
David Gibson2f1ccc32007-11-01 16:49:26 +1100194 * Structural check functions
195 */
196
David Gibsonb16a2bd2007-11-22 14:38:07 +1100197static void check_duplicate_node_names(struct check *c, struct node *dt,
198 struct node *node)
199{
200 struct node *child, *child2;
201
202 for_each_child(node, child)
203 for (child2 = child->next_sibling;
204 child2;
205 child2 = child2->next_sibling)
206 if (streq(child->name, child2->name))
207 FAIL(c, "Duplicate node name %s",
208 child->fullpath);
209}
210NODE_CHECK(duplicate_node_names, NULL, ERROR);
211
212static void check_duplicate_property_names(struct check *c, struct node *dt,
213 struct node *node)
214{
215 struct property *prop, *prop2;
216
217 for_each_property(node, prop)
218 for (prop2 = prop->next; prop2; prop2 = prop2->next)
219 if (streq(prop->name, prop2->name))
220 FAIL(c, "Duplicate property name %s in %s",
221 prop->name, node->fullpath);
222}
223NODE_CHECK(duplicate_property_names, NULL, ERROR);
224
225static void check_explicit_phandles(struct check *c, struct node *root,
226 struct node *node)
227{
228 struct property *prop;
229 struct node *other;
230 cell_t phandle;
231
232 prop = get_property(node, "linux,phandle");
233 if (! prop)
234 return; /* No phandle, that's fine */
235
236 if (prop->val.len != sizeof(cell_t)) {
237 FAIL(c, "%s has bad length (%d) linux,phandle property",
238 node->fullpath, prop->val.len);
239 return;
240 }
241
242 phandle = propval_cell(prop);
243 if ((phandle == 0) || (phandle == -1)) {
244 FAIL(c, "%s has invalid linux,phandle value 0x%x",
245 node->fullpath, phandle);
246 return;
247 }
248
249 other = get_node_by_phandle(root, phandle);
250 if (other) {
251 FAIL(c, "%s has duplicated phandle 0x%x (seen before at %s)",
252 node->fullpath, phandle, other->fullpath);
253 return;
254 }
255
256 node->phandle = phandle;
257}
258NODE_CHECK(explicit_phandles, NULL, ERROR);
259
David Gibson459c9552007-12-05 09:40:23 +1100260static void check_name_properties(struct check *c, struct node *root,
261 struct node *node)
262{
263 struct property *prop;
264
265 prop = get_property(node, "name");
266 if (!prop)
267 return; /* No name property, that's fine */
268
269 if ((prop->val.len != node->basenamelen+1)
270 || (memcmp(prop->val.val, node->name, node->basenamelen) != 0))
271 FAIL(c, "\"name\" property in %s is incorrect (\"%s\" instead"
272 " of base node name)", node->fullpath, prop->val.val);
273}
274CHECK_IS_STRING(name_is_string, "name", ERROR);
275NODE_CHECK(name_properties, NULL, ERROR, &name_is_string);
276
David Gibsonb16a2bd2007-11-22 14:38:07 +1100277/*
278 * Reference fixup functions
279 */
280
281static void fixup_phandle_references(struct check *c, struct node *dt,
282 struct node *node, struct property *prop)
283{
David Gibsondc941772007-11-22 14:39:23 +1100284 struct marker *m = prop->val.markers;
David Gibsonb16a2bd2007-11-22 14:38:07 +1100285 struct node *refnode;
286 cell_t phandle;
287
David Gibsondc941772007-11-22 14:39:23 +1100288 for_each_marker_of_type(m, REF_PHANDLE) {
289 assert(m->offset + sizeof(cell_t) <= prop->val.len);
David Gibsonb16a2bd2007-11-22 14:38:07 +1100290
David Gibsondc941772007-11-22 14:39:23 +1100291 refnode = get_node_by_ref(dt, m->ref);
David Gibsonb16a2bd2007-11-22 14:38:07 +1100292 if (! refnode) {
293 FAIL(c, "Reference to non-existent node or label \"%s\"\n",
David Gibsondc941772007-11-22 14:39:23 +1100294 m->ref);
295 continue;
David Gibsonb16a2bd2007-11-22 14:38:07 +1100296 }
297
David Gibsondc941772007-11-22 14:39:23 +1100298 phandle = get_node_phandle(dt, refnode);
299 *((cell_t *)(prop->val.val + m->offset)) = cpu_to_be32(phandle);
David Gibsonb16a2bd2007-11-22 14:38:07 +1100300 }
301}
302CHECK(phandle_references, NULL, NULL, fixup_phandle_references, NULL, ERROR,
303 &duplicate_node_names, &explicit_phandles);
304
305static struct check *check_table[] = {
306 &duplicate_node_names, &duplicate_property_names,
David Gibson459c9552007-12-05 09:40:23 +1100307 &name_is_string, &name_properties,
David Gibsonb16a2bd2007-11-22 14:38:07 +1100308 &explicit_phandles,
309 &phandle_references,
310};
311
David Gibson2d728162007-12-04 11:49:43 +1100312int check_semantics(struct node *dt, int outversion, int boot_cpuid_phys);
313
314void process_checks(int force, struct boot_info *bi,
315 int checkflag, int outversion, int boot_cpuid_phys)
David Gibsonb16a2bd2007-11-22 14:38:07 +1100316{
David Gibson2d728162007-12-04 11:49:43 +1100317 struct node *dt = bi->dt;
David Gibsonb16a2bd2007-11-22 14:38:07 +1100318 int i;
319 int error = 0;
320
321 for (i = 0; i < ARRAY_SIZE(check_table); i++) {
322 struct check *c = check_table[i];
323
324 if (c->level != IGNORE)
325 error = error || run_check(c, dt);
326 }
327
328 if (error) {
329 if (!force) {
330 fprintf(stderr, "ERROR: Input tree has errors, aborting "
331 "(use -f to force output)\n");
332 exit(2);
333 } else if (quiet < 3) {
334 fprintf(stderr, "Warning: Input tree has errors, "
335 "output forced\n");
336 }
337 }
David Gibson2d728162007-12-04 11:49:43 +1100338
339 if (checkflag) {
340 if (error) {
341 fprintf(stderr, "Warning: Skipping semantic checks due to structural errors\n");
342 } else {
343 if (!check_semantics(bi->dt, outversion,
344 boot_cpuid_phys))
345 fprintf(stderr, "Warning: Input tree has semantic errors\n");
346 }
347 }
David Gibsonb16a2bd2007-11-22 14:38:07 +1100348}
349
350/*
351 * Semantic check functions
352 */
353
David Gibson2f1ccc32007-11-01 16:49:26 +1100354#define ERRMSG(...) if (quiet < 2) fprintf(stderr, "ERROR: " __VA_ARGS__)
355#define WARNMSG(...) if (quiet < 1) fprintf(stderr, "Warning: " __VA_ARGS__)
356
357#define DO_ERR(...) do {ERRMSG(__VA_ARGS__); ok = 0; } while (0)
358
David Gibson2f1ccc32007-11-01 16:49:26 +1100359static int must_be_one_cell(struct property *prop, struct node *node)
360{
361 if (prop->val.len != sizeof(cell_t)) {
362 ERRMSG("\"%s\" property in %s has the wrong length (should be 1 cell)\n",
363 prop->name, node->fullpath);
364 return 0;
365 }
366
367 return 1;
368}
369
370static int must_be_cells(struct property *prop, struct node *node)
371{
372 if ((prop->val.len % sizeof(cell_t)) != 0) {
373 ERRMSG("\"%s\" property in %s is not a multiple of cell size\n",
374 prop->name, node->fullpath);
375 return 0;
376 }
377
378 return 1;
379}
380
381static int must_be_string(struct property *prop, struct node *node)
382{
383 if (! data_is_one_string(prop->val)) {
384 ERRMSG("\"%s\" property in %s is not a string\n",
385 prop->name, node->fullpath);
386 return 0;
387 }
388
389 return 1;
390}
391
David Gibson2f1ccc32007-11-01 16:49:26 +1100392static struct {
393 char *propname;
394 int (*check_fn)(struct property *prop, struct node *node);
395} prop_checker_table[] = {
David Gibson2f1ccc32007-11-01 16:49:26 +1100396 {"linux,phandle", must_be_one_cell},
397 {"#address-cells", must_be_one_cell},
398 {"#size-cells", must_be_one_cell},
399 {"reg", must_be_cells},
400 {"model", must_be_string},
401 {"device_type", must_be_string},
402};
403
404static int check_properties(struct node *node)
405{
406 struct property *prop;
407 struct node *child;
408 int i;
409 int ok = 1;
410
411 for_each_property(node, prop)
412 for (i = 0; i < ARRAY_SIZE(prop_checker_table); i++)
413 if (streq(prop->name, prop_checker_table[i].propname))
414 if (! prop_checker_table[i].check_fn(prop, node)) {
415 ok = 0;
416 break;
417 }
418
419 for_each_child(node, child)
420 if (! check_properties(child))
421 ok = 0;
422
423 return ok;
424}
425
426#define CHECK_HAVE(node, propname) \
427 do { \
428 if (! (prop = get_property((node), (propname)))) \
429 DO_ERR("Missing \"%s\" property in %s\n", (propname), \
430 (node)->fullpath); \
431 } while (0);
432
433#define CHECK_HAVE_WARN(node, propname) \
434 do { \
435 if (! (prop = get_property((node), (propname)))) \
436 WARNMSG("%s has no \"%s\" property\n", \
437 (node)->fullpath, (propname)); \
438 } while (0)
439
440#define CHECK_HAVE_STRING(node, propname) \
441 do { \
442 CHECK_HAVE((node), (propname)); \
443 if (prop && !data_is_one_string(prop->val)) \
444 DO_ERR("\"%s\" property in %s is not a string\n", \
445 (propname), (node)->fullpath); \
446 } while (0)
447
448#define CHECK_HAVE_STREQ(node, propname, value) \
449 do { \
450 CHECK_HAVE_STRING((node), (propname)); \
451 if (prop && !streq(prop->val.val, (value))) \
452 DO_ERR("%s has wrong %s, %s (should be %s\n", \
453 (node)->fullpath, (propname), \
454 prop->val.val, (value)); \
455 } while (0)
456
457#define CHECK_HAVE_ONECELL(node, propname) \
458 do { \
459 CHECK_HAVE((node), (propname)); \
460 if (prop && (prop->val.len != sizeof(cell_t))) \
461 DO_ERR("\"%s\" property in %s has wrong size %d (should be 1 cell)\n", (propname), (node)->fullpath, prop->val.len); \
462 } while (0)
463
464#define CHECK_HAVE_WARN_ONECELL(node, propname) \
465 do { \
466 CHECK_HAVE_WARN((node), (propname)); \
467 if (prop && (prop->val.len != sizeof(cell_t))) \
468 DO_ERR("\"%s\" property in %s has wrong size %d (should be 1 cell)\n", (propname), (node)->fullpath, prop->val.len); \
469 } while (0)
470
471#define CHECK_HAVE_WARN_PHANDLE(xnode, propname, root) \
472 do { \
473 struct node *ref; \
474 CHECK_HAVE_WARN_ONECELL((xnode), (propname)); \
475 if (prop) {\
476 cell_t phandle = propval_cell(prop); \
477 if ((phandle == 0) || (phandle == -1)) { \
478 DO_ERR("\"%s\" property in %s contains an invalid phandle %x\n", (propname), (xnode)->fullpath, phandle); \
479 } else { \
480 ref = get_node_by_phandle((root), propval_cell(prop)); \
481 if (! ref) \
482 DO_ERR("\"%s\" property in %s refers to non-existant phandle %x\n", (propname), (xnode)->fullpath, propval_cell(prop)); \
483 } \
484 } \
485 } while (0)
486
487#define CHECK_HAVE_WARN_STRING(node, propname) \
488 do { \
489 CHECK_HAVE_WARN((node), (propname)); \
490 if (prop && !data_is_one_string(prop->val)) \
491 DO_ERR("\"%s\" property in %s is not a string\n", \
492 (propname), (node)->fullpath); \
493 } while (0)
494
495static int check_root(struct node *root)
496{
497 struct property *prop;
498 int ok = 1;
499
500 CHECK_HAVE_STRING(root, "model");
501
502 CHECK_HAVE(root, "#address-cells");
503 CHECK_HAVE(root, "#size-cells");
504
505 CHECK_HAVE_WARN(root, "compatible");
506
507 return ok;
508}
509
510static int check_cpus(struct node *root, int outversion, int boot_cpuid_phys)
511{
512 struct node *cpus, *cpu;
513 struct property *prop;
514 struct node *bootcpu = NULL;
515 int ok = 1;
516
517 cpus = get_subnode(root, "cpus");
518 if (! cpus) {
519 ERRMSG("Missing /cpus node\n");
520 return 0;
521 }
522
523 CHECK_HAVE_WARN(cpus, "#address-cells");
524 CHECK_HAVE_WARN(cpus, "#size-cells");
525
526 for_each_child(cpus, cpu) {
527 CHECK_HAVE_STREQ(cpu, "device_type", "cpu");
528
529 if (cpu->addr_cells != 1)
530 DO_ERR("%s has bad #address-cells value %d (should be 1)\n",
531 cpu->fullpath, cpu->addr_cells);
532 if (cpu->size_cells != 0)
533 DO_ERR("%s has bad #size-cells value %d (should be 0)\n",
534 cpu->fullpath, cpu->size_cells);
535
536 CHECK_HAVE_ONECELL(cpu, "reg");
537 if (prop) {
538 cell_t unitnum;
539 char *eptr;
540
541 unitnum = strtol(get_unitname(cpu), &eptr, 16);
542 if (*eptr) {
543 WARNMSG("%s has bad format unit name %s (should be CPU number\n",
544 cpu->fullpath, get_unitname(cpu));
545 } else if (unitnum != propval_cell(prop)) {
546 WARNMSG("%s unit name \"%s\" does not match \"reg\" property <%x>\n",
547 cpu->fullpath, get_unitname(cpu),
548 propval_cell(prop));
549 }
550 }
551
552/* CHECK_HAVE_ONECELL(cpu, "d-cache-line-size"); */
553/* CHECK_HAVE_ONECELL(cpu, "i-cache-line-size"); */
554 CHECK_HAVE_ONECELL(cpu, "d-cache-size");
555 CHECK_HAVE_ONECELL(cpu, "i-cache-size");
556
557 CHECK_HAVE_WARN_ONECELL(cpu, "clock-frequency");
558 CHECK_HAVE_WARN_ONECELL(cpu, "timebase-frequency");
559
560 prop = get_property(cpu, "linux,boot-cpu");
561 if (prop) {
562 if (prop->val.len)
563 WARNMSG("\"linux,boot-cpu\" property in %s is non-empty\n",
564 cpu->fullpath);
565 if (bootcpu)
566 DO_ERR("Multiple boot cpus (%s and %s)\n",
567 bootcpu->fullpath, cpu->fullpath);
568 else
569 bootcpu = cpu;
570 }
571 }
572
573 if (outversion < 2) {
574 if (! bootcpu)
575 WARNMSG("No cpu has \"linux,boot-cpu\" property\n");
576 } else {
577 if (bootcpu)
578 WARNMSG("\"linux,boot-cpu\" property is deprecated in blob version 2 or higher\n");
579 if (boot_cpuid_phys == 0xfeedbeef)
580 WARNMSG("physical boot CPU not set. Use -b option to set\n");
581 }
582
583 return ok;
584}
585
586static int check_memory(struct node *root)
587{
588 struct node *mem;
589 struct property *prop;
590 int nnodes = 0;
591 int ok = 1;
592
593 for_each_child(root, mem) {
594 if (! strneq(mem->name, "memory", mem->basenamelen))
595 continue;
596
597 nnodes++;
598
599 CHECK_HAVE_STREQ(mem, "device_type", "memory");
600 CHECK_HAVE(mem, "reg");
601 }
602
603 if (nnodes == 0) {
604 ERRMSG("No memory nodes\n");
605 return 0;
606 }
607
608 return ok;
609}
610
611static int check_chosen(struct node *root)
612{
613 struct node *chosen;
614 struct property *prop;
615 int ok = 1;
616
617 chosen = get_subnode(root, "chosen");
618 if (!chosen)
619 return ok;
620
621 /* give warning for obsolete interrupt-controller property */
622 do {
623 if ((prop = get_property(chosen, "interrupt-controller")) != NULL) {
624 WARNMSG("%s has obsolete \"%s\" property\n",
625 chosen->fullpath, "interrupt-controller");
626 }
627 } while (0);
628
629 return ok;
630}
631
632static int check_addr_size_reg(struct node *node,
633 int p_addr_cells, int p_size_cells)
634{
635 int addr_cells = p_addr_cells;
636 int size_cells = p_size_cells;
637 struct property *prop;
638 struct node *child;
639 int ok = 1;
640
641 node->addr_cells = addr_cells;
642 node->size_cells = size_cells;
643
644 prop = get_property(node, "reg");
645 if (prop) {
646 int len = prop->val.len / 4;
647
648 if ((len % (addr_cells+size_cells)) != 0)
649 DO_ERR("\"reg\" property in %s has invalid length (%d) for given #address-cells (%d) and #size-cells (%d)\n",
650 node->fullpath, prop->val.len,
651 addr_cells, size_cells);
652 }
653
654 prop = get_property(node, "#address-cells");
655 if (prop)
656 addr_cells = propval_cell(prop);
657
658 prop = get_property(node, "#size-cells");
659 if (prop)
660 size_cells = propval_cell(prop);
661
662 for_each_child(node, child) {
663 ok = ok && check_addr_size_reg(child, addr_cells, size_cells);
664 }
665
666 return ok;
667}
668
669int check_semantics(struct node *dt, int outversion, int boot_cpuid_phys)
670{
671 int ok = 1;
672
673 ok = ok && check_properties(dt);
674 ok = ok && check_addr_size_reg(dt, -1, -1);
675 ok = ok && check_root(dt);
676 ok = ok && check_cpus(dt, outversion, boot_cpuid_phys);
677 ok = ok && check_memory(dt);
678 ok = ok && check_chosen(dt);
679 if (! ok)
680 return 0;
681
682 return 1;
683}