1 /* The common simulator framework for GDB, the GNU Debugger.
3 Copyright 2002-2021 Free Software Foundation, Inc.
5 Contributed by Andrew Cagney and Red Hat.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 /* This must come before any other includes. */
34 #include "sim-assert.h"
36 /* manipulate/lookup device names */
38 typedef struct _name_specifier
41 /* components in the full length name */
65 /* Given a device specifier, break it up into its main components:
66 path (and if present) property name and property value. */
69 split_device_specifier (struct hw
*current
,
70 const char *device_specifier
,
75 /* expand any leading alias if present */
77 && *device_specifier
!= '\0'
78 && *device_specifier
!= '.'
79 && *device_specifier
!= '/')
81 struct hw
*aliases
= hw_tree_find_device (current
, "/aliases");
84 while (device_specifier
[len
] != '\0'
85 && device_specifier
[len
] != '/'
86 && device_specifier
[len
] != ':'
87 && !isspace (device_specifier
[len
]))
89 alias
[len
] = device_specifier
[len
];
91 if (len
>= sizeof (alias
))
92 hw_abort (NULL
, "split_device_specifier: buffer overflow");
96 && hw_find_property (aliases
, alias
))
98 strcpy (spec
->buf
, hw_find_string_property (aliases
, alias
));
99 strcat (spec
->buf
, device_specifier
+ len
);
103 strcpy (spec
->buf
, device_specifier
);
108 strcpy (spec
->buf
, device_specifier
);
111 /* check no overflow */
112 if (strlen (spec
->buf
) >= sizeof (spec
->buf
))
113 hw_abort (NULL
, "split_device_specifier: buffer overflow\n");
115 /* strip leading spaces */
117 while (*chp
!= '\0' && isspace (*chp
))
122 /* find the path and terminate it with null */
124 while (*chp
!= '\0' && !isspace (*chp
))
133 while (*chp
!= '\0' && isspace (*chp
))
137 /* now go back and chop the property off of the path */
138 if (spec
->value
[0] == '\0')
140 spec
->property
= NULL
; /*not a property*/
143 else if (spec
->value
[0] == '>'
144 || spec
->value
[0] == '<')
146 /* an interrupt spec */
147 spec
->property
= NULL
;
151 chp
= strrchr (spec
->path
, '/');
154 spec
->property
= spec
->path
;
155 spec
->path
= strchr (spec
->property
, '\0');
160 spec
->property
= chp
+1;
164 /* and mark the rest as invalid */
169 spec
->last_name
= NULL
;
170 spec
->last_family
= NULL
;
171 spec
->last_unit
= NULL
;
172 spec
->last_args
= NULL
;
178 /* given a device specifier break it up into its main components -
179 path and property name - assuming that the last `device' is a
183 split_property_specifier (struct hw
*current
,
184 const char *property_specifier
,
185 name_specifier
*spec
)
187 if (split_device_specifier (current
, property_specifier
, spec
))
189 if (spec
->property
== NULL
)
191 /* force the last name to be a property name */
192 char *chp
= strrchr (spec
->path
, '/');
195 spec
->property
= spec
->path
;
196 spec
->path
= strrchr (spec
->property
, '\0');;
201 spec
->property
= chp
+ 1;
211 /* device the next device name and split it up, return 0 when no more
212 names to struct hw */
215 split_device_name (name_specifier
*spec
)
218 /* remember what came before */
219 spec
->last_name
= spec
->name
;
220 spec
->last_family
= spec
->family
;
221 spec
->last_unit
= spec
->unit
;
222 spec
->last_args
= spec
->args
;
224 if (spec
->path
[0] == '\0')
232 /* break the current device spec from the path */
233 spec
->name
= spec
->path
;
234 chp
= strchr (spec
->name
, '/');
236 spec
->path
= strchr (spec
->name
, '\0');
242 /* break out the base */
243 if (spec
->name
[0] == '(')
245 chp
= strchr (spec
->name
, ')');
248 spec
->family
= spec
->name
;
253 spec
->family
= spec
->name
+ 1;
254 spec
->name
= chp
+ 1;
259 spec
->family
= spec
->name
;
261 /* now break out the unit */
262 chp
= strchr (spec
->name
, '@');
274 /* finally any args */
275 chp
= strchr (chp
, ':');
287 /* device the value, returning the next non-space token */
290 split_value (name_specifier
*spec
)
293 if (spec
->value
== NULL
)
295 /* skip leading white space */
296 while (isspace (spec
->value
[0]))
298 if (spec
->value
[0] == '\0')
304 /* find trailing space */
305 while (spec
->value
[0] != '\0' && !isspace (spec
->value
[0]))
307 /* chop this value out */
308 if (spec
->value
[0] != '\0')
310 spec
->value
[0] = '\0';
318 /* traverse the path specified by spec starting at current */
321 split_find_device (struct hw
*current
,
322 name_specifier
*spec
)
324 /* strip off (and process) any leading ., .., ./ and / */
327 if (strncmp (spec
->path
, "/", strlen ("/")) == 0)
330 while (current
!= NULL
&& hw_parent (current
) != NULL
)
331 current
= hw_parent (current
);
332 spec
->path
+= strlen ("/");
334 else if (strncmp (spec
->path
, "./", strlen ("./")) == 0)
338 spec
->path
+= strlen ("./");
340 else if (strncmp (spec
->path
, "../", strlen ("../")) == 0)
343 if (current
!= NULL
&& hw_parent (current
) != NULL
)
344 current
= hw_parent (current
);
345 spec
->path
+= strlen ("../");
347 else if (strcmp (spec
->path
, ".") == 0)
351 spec
->path
+= strlen (".");
353 else if (strcmp (spec
->path
, "..") == 0)
356 if (current
!= NULL
&& hw_parent (current
) != NULL
)
357 current
= hw_parent (current
);
358 spec
->path
+= strlen ("..");
364 /* now go through the path proper */
368 split_device_name (spec
);
372 while (split_device_name (spec
))
375 for (child
= hw_child (current
);
376 child
!= NULL
; child
= hw_sibling (child
))
378 if (strcmp (spec
->name
, hw_name (child
)) == 0)
380 if (spec
->unit
== NULL
)
385 hw_unit_decode (current
, spec
->unit
, &phys
);
386 if (memcmp (&phys
, hw_unit_address (child
),
387 sizeof (hw_unit
)) == 0)
393 return current
; /* search failed */
402 split_fill_path (struct hw
*current
,
403 const char *device_specifier
,
404 name_specifier
*spec
)
407 if (!split_device_specifier (current
, device_specifier
, spec
))
408 hw_abort (current
, "error parsing %s\n", device_specifier
);
410 /* fill our tree with its contents */
411 current
= split_find_device (current
, spec
);
413 /* add any additional devices as needed */
414 if (spec
->name
!= NULL
)
418 if (current
!= NULL
&& !hw_finished_p (current
))
420 current
= hw_create (NULL
,
427 while (split_device_name (spec
));
434 /* <non-white-space> */
437 skip_token (const char *chp
)
439 while (!isspace (*chp
) && *chp
!= '\0')
441 while (isspace (*chp
) && *chp
!= '\0')
447 /* count the number of entries */
450 count_entries (struct hw
*current
,
451 const char *property_name
,
452 const char *property_value
,
455 const char *chp
= property_value
;
460 chp
= skip_token (chp
);
462 if ((nr_entries
% modulo
) != 0)
464 hw_abort (current
, "incorrect number of entries for %s property %s, should be multiple of %d",
465 property_name
, property_value
, modulo
);
467 return nr_entries
/ modulo
;
472 /* parse: <address> ::= <token> ; device dependant */
475 parse_address (struct hw
*current
,
480 if (hw_unit_decode (bus
, chp
, address
) < 0)
481 hw_abort (current
, "invalid unit address in %s", chp
);
482 return skip_token (chp
);
486 /* parse: <size> ::= <number> { "," <number> } ; */
489 parse_size (struct hw
*current
,
496 const char *curr
= chp
;
497 memset (size
, 0, sizeof (*size
));
498 /* parse the numeric list */
499 size
->nr_cells
= hw_unit_nr_size_cells (bus
);
504 size
->cells
[nr
] = strtoul (curr
, &next
, 0);
506 hw_abort (current
, "Problem parsing <size> %s", chp
);
510 if (nr
== size
->nr_cells
)
511 hw_abort (current
, "Too many values in <size> %s", chp
);
514 ASSERT (nr
> 0 && nr
<= size
->nr_cells
);
515 /* right align the numbers */
516 for (i
= 1; i
<= size
->nr_cells
; i
++)
519 size
->cells
[size
->nr_cells
- i
] = size
->cells
[nr
- i
];
521 size
->cells
[size
->nr_cells
- i
] = 0;
523 return skip_token (chp
);
527 /* parse: <reg> ::= { <address> <size> } ; */
530 parse_reg_property (struct hw
*current
,
531 const char *property_name
,
532 const char *property_value
)
536 reg_property_spec
*regs
;
539 /* determine the number of reg entries by counting tokens */
540 nr_regs
= count_entries (current
, property_name
, property_value
, 2);
542 /* create working space */
543 regs
= zalloc (nr_regs
* sizeof (*regs
));
546 chp
= property_value
;
547 for (reg_nr
= 0; reg_nr
< nr_regs
; reg_nr
++)
549 chp
= parse_address (current
, hw_parent (current
),
550 chp
, ®s
[reg_nr
].address
);
551 chp
= parse_size (current
, hw_parent (current
),
552 chp
, ®s
[reg_nr
].size
);
556 hw_add_reg_array_property (current
, property_name
,
563 /* { <child-address> <parent-address> <child-size> }* */
566 parse_ranges_property (struct hw
*current
,
567 const char *property_name
,
568 const char *property_value
)
572 range_property_spec
*ranges
;
575 /* determine the number of ranges specified */
576 nr_ranges
= count_entries (current
, property_name
, property_value
, 3);
578 /* create a property of that size */
579 ranges
= zalloc (nr_ranges
* sizeof (*ranges
));
582 chp
= property_value
;
583 for (range_nr
= 0; range_nr
< nr_ranges
; range_nr
++)
585 chp
= parse_address (current
, current
,
586 chp
, &ranges
[range_nr
].child_address
);
587 chp
= parse_address (current
, hw_parent (current
),
588 chp
, &ranges
[range_nr
].parent_address
);
589 chp
= parse_size (current
, current
,
590 chp
, &ranges
[range_nr
].size
);
594 hw_add_range_array_property (current
, property_name
, ranges
, nr_ranges
);
603 parse_integer_property (struct hw
*current
,
604 const char *property_name
,
605 const char *property_value
)
608 unsigned_cell words
[1024];
609 /* integer or integer array? */
614 words
[nr_entries
] = strtoul (property_value
, &end
, 0);
615 if (property_value
== end
)
618 if (nr_entries
* sizeof (words
[0]) >= sizeof (words
))
619 hw_abort (current
, "buffer overflow");
620 property_value
= end
;
623 hw_abort (current
, "error parsing integer property %s (%s)",
624 property_name
, property_value
);
625 else if (nr_entries
== 1)
626 hw_add_integer_property (current
, property_name
, words
[0]);
630 for (i
= 0; i
< nr_entries
; i
++)
634 /* perhaps integer array property is better */
635 hw_add_array_property (current
, property_name
, words
,
636 sizeof (words
[0]) * nr_entries
);
644 parse_string_property (struct hw
*current
,
645 const char *property_name
,
646 const char *property_value
)
651 int approx_nr_strings
;
653 /* get an estimate as to the number of strings by counting double
655 approx_nr_strings
= 2;
656 for (chp
= property_value
; *chp
; chp
++)
661 approx_nr_strings
= (approx_nr_strings
) / 2;
663 /* create a string buffer for that many (plus a null) */
664 strings
= (char**) zalloc ((approx_nr_strings
+ 1) * sizeof (char*));
666 /* now find all the strings */
667 chp
= property_value
;
672 /* skip leading space */
673 while (*chp
!= '\0' && isspace (*chp
))
681 /* a quoted string - watch for '\' et al. */
682 /* estimate the size and allocate space for it */
686 while (chp
[pos
] != '\0' && chp
[pos
] != '"')
688 if (chp
[pos
] == '\\' && chp
[pos
+1] != '\0')
693 strings
[nr_strings
] = zalloc (pos
+ 1);
694 /* copy the string over */
696 while (*chp
!= '\0' && *chp
!= '"')
698 if (*chp
== '\\' && *(chp
+1) != '\0')
700 strings
[nr_strings
][pos
] = *(chp
+1);
706 strings
[nr_strings
][pos
] = *chp
;
713 strings
[nr_strings
][pos
] = '\0';
717 /* copy over a single unquoted token */
719 while (chp
[len
] != '\0' && !isspace (chp
[len
]))
721 strings
[nr_strings
] = zalloc (len
+ 1);
722 strncpy (strings
[nr_strings
], chp
, len
);
723 strings
[nr_strings
][len
] = '\0';
727 if (nr_strings
> approx_nr_strings
)
728 hw_abort (current
, "String property %s badly formatted",
731 ASSERT (strings
[nr_strings
] == NULL
); /* from zalloc */
735 hw_add_string_property (current
, property_name
, "");
736 else if (nr_strings
== 1)
737 hw_add_string_property (current
, property_name
, strings
[0]);
740 const char **specs
= (const char**) strings
; /* stop a bogus error */
741 hw_add_string_array_property (current
, property_name
,
745 /* flush the created string */
746 while (nr_strings
> 0)
749 free (strings
[nr_strings
]);
755 /* <path-to-ihandle-device> */
759 parse_ihandle_property (struct hw
*current
,
760 const char *property
,
763 ihandle_runtime_property_spec ihandle
;
765 /* pass the full path */
766 ihandle
.full_path
= value
;
768 /* save this ready for the ihandle create */
769 hw_add_ihandle_runtime_property (current
, property
,
776 hw_tree_create (SIM_DESC sd
,
779 return hw_create (sd
, NULL
, family
, family
, NULL
, NULL
);
783 hw_tree_delete (struct hw
*me
)
785 /* Need to allow devices to disapear under our feet */
786 while (hw_child (me
) != NULL
)
788 hw_tree_delete (hw_child (me
));
795 hw_tree_parse (struct hw
*current
,
801 current
= hw_tree_vparse (current
, fmt
, ap
);
807 hw_tree_vparse (struct hw
*current
,
811 char device_specifier
[1024];
814 /* format the path */
815 vsprintf (device_specifier
, fmt
, ap
);
816 if (strlen (device_specifier
) >= sizeof (device_specifier
))
817 hw_abort (NULL
, "device_tree_add_deviced: buffer overflow\n");
819 /* construct the tree down to the final struct hw */
820 current
= split_fill_path (current
, device_specifier
, &spec
);
822 /* is there an interrupt spec */
823 if (spec
.property
== NULL
824 && spec
.value
!= NULL
)
826 char *op
= split_value (&spec
);
831 char *my_port_name
= split_value (&spec
);
833 char *dest_port_name
= split_value (&spec
);
835 name_specifier dest_spec
;
836 char *dest_hw_name
= split_value (&spec
);
839 if (!hw_finished_p (current
))
841 my_port
= hw_port_decode (current
, my_port_name
, output_port
);
842 /* find the dest device and port */
843 dest
= split_fill_path (current
, dest_hw_name
, &dest_spec
);
844 if (!hw_finished_p (dest
))
846 dest_port
= hw_port_decode (dest
, dest_port_name
,
848 /* connect the two */
849 hw_port_attach (current
,
857 hw_abort (current
, "unreconised interrupt spec %s\n", spec
.value
);
862 /* is there a property */
863 if (spec
.property
!= NULL
)
865 if (strcmp (spec
.value
, "true") == 0)
866 hw_add_boolean_property (current
, spec
.property
, 1);
867 else if (strcmp (spec
.value
, "false") == 0)
868 hw_add_boolean_property (current
, spec
.property
, 0);
871 const struct hw_property
*property
;
872 switch (spec
.value
[0])
877 parse_ihandle_property (current
, spec
.property
, spec
.value
+ 1);
883 unsigned8 words
[1024];
884 char *curr
= spec
.value
+ 1;
889 words
[nr_words
] = H2BE_1 (strtoul (curr
, &next
, 0));
895 hw_add_array_property (current
, spec
.property
,
896 words
, sizeof (words
[0]) * nr_words
);
901 parse_string_property (current
, spec
.property
, spec
.value
);
907 property
= hw_tree_find_property (current
, spec
.value
);
908 if (property
== NULL
)
909 hw_abort (current
, "property %s not found\n", spec
.value
);
910 hw_add_duplicate_property (current
,
917 if (strcmp (spec
.property
, "reg") == 0
918 || strcmp (spec
.property
, "assigned-addresses") == 0
919 || strcmp (spec
.property
, "alternate-reg") == 0)
921 parse_reg_property (current
, spec
.property
, spec
.value
);
923 else if (strcmp (spec
.property
, "ranges") == 0)
925 parse_ranges_property (current
, spec
.property
, spec
.value
);
927 else if (isdigit (spec
.value
[0])
928 || (spec
.value
[0] == '-' && isdigit (spec
.value
[1]))
929 || (spec
.value
[0] == '+' && isdigit (spec
.value
[1])))
931 parse_integer_property (current
, spec
.property
, spec
.value
);
934 parse_string_property (current
, spec
.property
, spec
.value
);
945 finish_hw_tree (struct hw
*me
,
948 if (!hw_finished_p (me
))
953 hw_tree_finish (struct hw
*root
)
955 hw_tree_traverse (root
, finish_hw_tree
, NULL
, NULL
);
961 hw_tree_traverse (struct hw
*root
,
962 hw_tree_traverse_function
*prefix
,
963 hw_tree_traverse_function
*postfix
,
969 for (child
= hw_child (root
);
971 child
= hw_sibling (child
))
973 hw_tree_traverse (child
, prefix
, postfix
, data
);
976 postfix (root
, data
);
983 hw_tree_print_callback
*print
;
988 print_address (struct hw
*bus
,
993 hw_unit_encode (bus
, phys
, unit
, sizeof (unit
));
994 p
->print (p
->file
, " %s", unit
);
998 print_size (struct hw
*bus
,
1003 for (i
= 0; i
< size
->nr_cells
; i
++)
1004 if (size
->cells
[i
] != 0)
1006 if (i
< size
->nr_cells
)
1008 p
->print (p
->file
, " 0x%lx", (unsigned long) size
->cells
[i
]);
1010 for (; i
< size
->nr_cells
; i
++)
1011 p
->print (p
->file
, ",0x%lx", (unsigned long) size
->cells
[i
]);
1014 p
->print (p
->file
, " 0");
1018 print_reg_property (struct hw
*me
,
1019 const struct hw_property
*property
,
1023 reg_property_spec reg
;
1025 hw_find_reg_array_property (me
, property
->name
, reg_nr
, ®
);
1028 print_address (hw_parent (me
), ®
.address
, p
);
1029 print_size (me
, ®
.size
, p
);
1034 print_ranges_property (struct hw
*me
,
1035 const struct hw_property
*property
,
1039 range_property_spec range
;
1041 hw_find_range_array_property (me
, property
->name
, range_nr
, &range
);
1044 print_address (me
, &range
.child_address
, p
);
1045 print_address (hw_parent (me
), &range
.parent_address
, p
);
1046 print_size (me
, &range
.size
, p
);
1051 print_string (struct hw
*me
,
1055 p
->print (p
->file
, " \"");
1056 while (*string
!= '\0')
1061 p
->print (p
->file
, "\\\"");
1064 p
->print (p
->file
, "\\\\");
1067 p
->print (p
->file
, "%c", *string
);
1072 p
->print (p
->file
, "\"");
1076 print_string_array_property (struct hw
*me
,
1077 const struct hw_property
*property
,
1081 string_property_spec string
;
1083 hw_find_string_array_property (me
, property
->name
, nr
, &string
);
1086 print_string (me
, string
, p
);
1091 print_properties (struct hw
*me
,
1094 const struct hw_property
*property
;
1095 for (property
= hw_find_property (me
, NULL
);
1097 property
= hw_next_property (property
))
1099 if (hw_parent (me
) == NULL
)
1100 p
->print (p
->file
, "/%s", property
->name
);
1102 p
->print (p
->file
, "%s/%s", hw_path (me
), property
->name
);
1103 if (property
->original
!= NULL
)
1105 p
->print (p
->file
, " !");
1106 p
->print (p
->file
, "%s/%s",
1107 hw_path (property
->original
->owner
),
1108 property
->original
->name
);
1112 switch (property
->type
)
1114 case array_property
:
1116 if ((property
->sizeof_array
% sizeof (signed_cell
)) == 0)
1118 unsigned_cell
*w
= (unsigned_cell
*) property
->array
;
1121 cell_nr
< (property
->sizeof_array
/ sizeof (unsigned_cell
));
1124 p
->print (p
->file
, " 0x%lx", (unsigned long) BE2H_cell (w
[cell_nr
]));
1129 unsigned8
*w
= (unsigned8
*)property
->array
;
1130 p
->print (p
->file
, " [");
1131 while ((char*)w
- (char*)property
->array
< property
->sizeof_array
)
1133 p
->print (p
->file
, " 0x%2x", BE2H_1 (*w
));
1139 case boolean_property
:
1141 int b
= hw_find_boolean_property (me
, property
->name
);
1142 p
->print (p
->file
, " %s", b
? "true" : "false");
1146 case ihandle_property
:
1148 if (property
->array
!= NULL
)
1150 device_instance
*instance
= hw_find_ihandle_property (me
, property
->name
);
1151 p
->print (p
->file
, " *%s", device_instance_path (instance
));
1155 /* not yet initialized, ask the device for the path */
1156 ihandle_runtime_property_spec spec
;
1157 hw_find_ihandle_runtime_property (me
, property
->name
, &spec
);
1158 p
->print (p
->file
, " *%s", spec
.full_path
);
1163 case integer_property
:
1165 unsigned_word w
= hw_find_integer_property (me
, property
->name
);
1166 p
->print (p
->file
, " 0x%lx", (unsigned long)w
);
1169 case range_array_property
:
1171 print_ranges_property (me
, property
, p
);
1174 case reg_array_property
:
1176 print_reg_property (me
, property
, p
);
1179 case string_property
:
1181 const char *s
= hw_find_string_property (me
, property
->name
);
1182 print_string (me
, s
, p
);
1185 case string_array_property
:
1187 print_string_array_property (me
, property
, p
);
1192 p
->print (p
->file
, "\n");
1197 print_interrupts (struct hw
*me
,
1203 struct printer
*p
= data
;
1206 hw_port_encode (me
, my_port
, src
, sizeof (src
), output_port
);
1207 hw_port_encode (dest
, dest_port
, dst
, sizeof (dst
), input_port
);
1216 print_device (struct hw
*me
,
1219 struct printer
*p
= data
;
1220 p
->print (p
->file
, "%s\n", hw_path (me
));
1221 print_properties (me
, p
);
1222 hw_port_traverse (me
, print_interrupts
, data
);
1226 hw_tree_print (struct hw
*root
,
1227 hw_tree_print_callback
*print
,
1233 hw_tree_traverse (root
,
1242 tree_instance (struct hw
*root
,
1243 const char *device_specifier
)
1245 /* find the device node */
1247 name_specifier spec
;
1248 if (!split_device_specifier (root
, device_specifier
, &spec
))
1250 me
= split_find_device (root
, &spec
);
1251 if (spec
.name
!= NULL
)
1253 /* create the instance */
1254 return device_create_instance (me
, device_specifier
, spec
.last_args
);
1259 hw_tree_find_device (struct hw
*root
,
1260 const char *path_to_device
)
1263 name_specifier spec
;
1265 /* parse the path */
1266 split_device_specifier (root
, path_to_device
, &spec
);
1267 if (spec
.value
!= NULL
)
1268 return NULL
; /* something wierd */
1271 node
= split_find_device (root
, &spec
);
1272 if (spec
.name
!= NULL
)
1273 return NULL
; /* not a leaf */
1279 const struct hw_property
*
1280 hw_tree_find_property (struct hw
*root
,
1281 const char *path_to_property
)
1283 name_specifier spec
;
1284 if (!split_property_specifier (root
, path_to_property
, &spec
))
1285 hw_abort (root
, "Invalid property path %s", path_to_property
);
1286 root
= split_find_device (root
, &spec
);
1287 if (spec
.name
!= NULL
)
1288 return NULL
; /* not a leaf */
1289 return hw_find_property (root
, spec
.property
);
1293 hw_tree_find_boolean_property (struct hw
*root
,
1294 const char *path_to_property
)
1296 name_specifier spec
;
1297 if (!split_property_specifier (root
, path_to_property
, &spec
))
1298 hw_abort (root
, "Invalid property path %s", path_to_property
);
1299 root
= split_find_device (root
, &spec
);
1300 if (spec
.name
!= NULL
)
1301 hw_abort (root
, "device \"%s\" not found (property \"%s\")",
1302 spec
.name
, path_to_property
);
1303 return hw_find_boolean_property (root
, spec
.property
);
1307 hw_tree_find_integer_property (struct hw
*root
,
1308 const char *path_to_property
)
1310 name_specifier spec
;
1311 if (!split_property_specifier (root
, path_to_property
, &spec
))
1312 hw_abort (root
, "Invalid property path %s", path_to_property
);
1313 root
= split_find_device (root
, &spec
);
1314 if (spec
.name
!= NULL
)
1315 hw_abort (root
, "device \"%s\" not found (property \"%s\")",
1316 spec
.name
, path_to_property
);
1317 return hw_find_integer_property (root
, spec
.property
);
1322 hw_tree_find_ihandle_property (struct hw
*root
,
1323 const char *path_to_property
)
1326 name_specifier spec
;
1327 if (!split_property_specifier (root
, path_to_property
, &spec
))
1328 hw_abort (root
, "Invalid property path %s", path_to_property
);
1329 root
= split_find_device (root
, &spec
);
1330 if (spec
.name
!= NULL
)
1331 hw_abort (root
, "device \"%s\" not found (property \"%s\")",
1332 spec
.name
, path_to_property
);
1333 return hw_find_ihandle_property (root
, spec
.property
);
1338 hw_tree_find_string_property (struct hw
*root
,
1339 const char *path_to_property
)
1341 name_specifier spec
;
1342 if (!split_property_specifier (root
, path_to_property
, &spec
))
1343 hw_abort (root
, "Invalid property path %s", path_to_property
);
1344 root
= split_find_device (root
, &spec
);
1345 if (spec
.name
!= NULL
)
1346 hw_abort (root
, "device \"%s\" not found (property \"%s\")",
1347 spec
.name
, path_to_property
);
1348 return hw_find_string_property (root
, spec
.property
);