Home | History | Annotate | Line # | Download | only in ppc
tree.h revision 1.1.1.1
      1 /*  This file is part of the program psim.
      2 
      3     Copyright (C) 1994-1996, Andrew Cagney <cagney (at) highland.com.au>
      4 
      5     This program is free software; you can redistribute it and/or modify
      6     it under the terms of the GNU General Public License as published by
      7     the Free Software Foundation; either version 2 of the License, or
      8     (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
     13     GNU 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, USA.
     18 
     19     */
     20 
     21 
     22 #ifndef _TREE_H_
     23 #define _TREE_H_
     24 
     25 #ifndef INLINE_TREE
     26 #define INLINE_TREE
     27 #endif
     28 
     29 /* Constructing the device tree:
     30 
     31    The initial device tree populated with devices and basic properties
     32    is created using the function <<device_tree_add_parsed()>>.  This
     33    function parses a PSIM device specification and uses it to populate
     34    the tree accordingly.
     35 
     36    This function accepts a printf style formatted string as the
     37    argument that describes the entry.  Any properties or interrupt
     38    connections added to a device tree using this function are marked
     39    as having a permenant disposition.  When the tree is (re)
     40    initialized they will be restored to their initial value.
     41 
     42    */
     43 
     44 EXTERN_TREE\
     45 (char*) tree_quote_property
     46 (const char *property_value);
     47 
     48 EXTERN_TREE\
     49 (device *) tree_parse
     50 (device *root,
     51  const char *fmt,
     52  ...) __attribute__ ((format (printf, 2, 3)));
     53 
     54 
     55 INLINE_TREE\
     56 (void) tree_usage
     57 (int verbose);
     58 
     59 INLINE_TREE\
     60 (void) tree_print
     61 (device *root);
     62 
     63 INLINE_TREE\
     64 (device_instance*) tree_instance
     65 (device *root,
     66  const char *device_specifier);
     67 
     68 
     69 /* Tree traversal::
     70 
     71    The entire device tree can be traversed using the
     72    <<device_tree_traverse()>> function.  The traversal can be in
     73    either pre- or postfix order.
     74 
     75    */
     76 
     77 typedef void (tree_traverse_function)
     78      (device *device,
     79       void *data);
     80 
     81 INLINE_DEVICE\
     82 (void) tree_traverse
     83 (device *root,
     84  tree_traverse_function *prefix,
     85  tree_traverse_function *postfix,
     86  void *data);
     87 
     88 
     89 /* Tree lookup::
     90 
     91    The function <<tree_find_device()>> will attempt to locate
     92    the specified device within the tree.  If the device is not found a
     93    NULL device is returned.
     94 
     95    */
     96 
     97 INLINE_TREE\
     98 (device *) tree_find_device
     99 (device *root,
    100  const char *path);
    101 
    102 
    103 INLINE_TREE\
    104 (const device_property *) tree_find_property
    105 (device *root,
    106  const char *path_to_property);
    107 
    108 INLINE_TREE\
    109 (int) tree_find_boolean_property
    110 (device *root,
    111  const char *path_to_property);
    112 
    113 INLINE_TREE\
    114 (signed_cell) tree_find_integer_property
    115 (device *root,
    116  const char *path_to_property);
    117 
    118 INLINE_TREE\
    119 (device_instance *) tree_find_ihandle_property
    120 (device *root,
    121  const char *path_to_property);
    122 
    123 INLINE_TREE\
    124 (const char *) tree_find_string_property
    125 (device *root,
    126  const char *path_to_property);
    127 
    128 
    129 /* Initializing the created tree:
    130 
    131    Once a device tree has been created the <<device_tree_init()>>
    132    function is used to initialize it.  The exact sequence of events
    133    that occure during initialization are described separatly.
    134 
    135    */
    136 
    137 INLINE_TREE\
    138 (void) tree_init
    139 (device *root,
    140  psim *system);
    141 
    142 
    143 #endif /* _TREE_H_ */
    144