/* This file is part of the program psim.
|
/* This file is part of the program psim.
|
|
|
Copyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>
|
Copyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>
|
|
|
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
the Free Software Foundation; either version 2 of the License, or
|
the Free Software Foundation; either version 2 of the License, or
|
(at your option) any later version.
|
(at your option) any later version.
|
|
|
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
GNU General Public License for more details.
|
GNU General Public License for more details.
|
|
|
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
*/
|
*/
|
|
|
|
|
#ifndef _TREE_H_
|
#ifndef _TREE_H_
|
#define _TREE_H_
|
#define _TREE_H_
|
|
|
#ifndef INLINE_TREE
|
#ifndef INLINE_TREE
|
#define INLINE_TREE
|
#define INLINE_TREE
|
#endif
|
#endif
|
|
|
/* Constructing the device tree:
|
/* Constructing the device tree:
|
|
|
The initial device tree populated with devices and basic properties
|
The initial device tree populated with devices and basic properties
|
is created using the function <<device_tree_add_parsed()>>. This
|
is created using the function <<device_tree_add_parsed()>>. This
|
function parses a PSIM device specification and uses it to populate
|
function parses a PSIM device specification and uses it to populate
|
the tree accordingly.
|
the tree accordingly.
|
|
|
This function accepts a printf style formatted string as the
|
This function accepts a printf style formatted string as the
|
argument that describes the entry. Any properties or interrupt
|
argument that describes the entry. Any properties or interrupt
|
connections added to a device tree using this function are marked
|
connections added to a device tree using this function are marked
|
as having a permenant disposition. When the tree is (re)
|
as having a permenant disposition. When the tree is (re)
|
initialized they will be restored to their initial value.
|
initialized they will be restored to their initial value.
|
|
|
*/
|
*/
|
|
|
EXTERN_TREE\
|
EXTERN_TREE\
|
(char*) tree_quote_property
|
(char*) tree_quote_property
|
(const char *property_value);
|
(const char *property_value);
|
|
|
EXTERN_TREE\
|
EXTERN_TREE\
|
(device *) tree_parse
|
(device *) tree_parse
|
(device *root,
|
(device *root,
|
const char *fmt,
|
const char *fmt,
|
...) __attribute__ ((format (printf, 2, 3)));
|
...) __attribute__ ((format (printf, 2, 3)));
|
|
|
|
|
INLINE_TREE\
|
INLINE_TREE\
|
(void) tree_usage
|
(void) tree_usage
|
(int verbose);
|
(int verbose);
|
|
|
INLINE_TREE\
|
INLINE_TREE\
|
(void) tree_print
|
(void) tree_print
|
(device *root);
|
(device *root);
|
|
|
INLINE_TREE\
|
INLINE_TREE\
|
(device_instance*) tree_instance
|
(device_instance*) tree_instance
|
(device *root,
|
(device *root,
|
const char *device_specifier);
|
const char *device_specifier);
|
|
|
|
|
/* Tree traversal::
|
/* Tree traversal::
|
|
|
The entire device tree can be traversed using the
|
The entire device tree can be traversed using the
|
<<device_tree_traverse()>> function. The traversal can be in
|
<<device_tree_traverse()>> function. The traversal can be in
|
either pre- or postfix order.
|
either pre- or postfix order.
|
|
|
*/
|
*/
|
|
|
typedef void (tree_traverse_function)
|
typedef void (tree_traverse_function)
|
(device *device,
|
(device *device,
|
void *data);
|
void *data);
|
|
|
INLINE_DEVICE\
|
INLINE_DEVICE\
|
(void) tree_traverse
|
(void) tree_traverse
|
(device *root,
|
(device *root,
|
tree_traverse_function *prefix,
|
tree_traverse_function *prefix,
|
tree_traverse_function *postfix,
|
tree_traverse_function *postfix,
|
void *data);
|
void *data);
|
|
|
|
|
/* Tree lookup::
|
/* Tree lookup::
|
|
|
The function <<tree_find_device()>> will attempt to locate
|
The function <<tree_find_device()>> will attempt to locate
|
the specified device within the tree. If the device is not found a
|
the specified device within the tree. If the device is not found a
|
NULL device is returned.
|
NULL device is returned.
|
|
|
*/
|
*/
|
|
|
INLINE_TREE\
|
INLINE_TREE\
|
(device *) tree_find_device
|
(device *) tree_find_device
|
(device *root,
|
(device *root,
|
const char *path);
|
const char *path);
|
|
|
|
|
INLINE_TREE\
|
INLINE_TREE\
|
(const device_property *) tree_find_property
|
(const device_property *) tree_find_property
|
(device *root,
|
(device *root,
|
const char *path_to_property);
|
const char *path_to_property);
|
|
|
INLINE_TREE\
|
INLINE_TREE\
|
(int) tree_find_boolean_property
|
(int) tree_find_boolean_property
|
(device *root,
|
(device *root,
|
const char *path_to_property);
|
const char *path_to_property);
|
|
|
INLINE_TREE\
|
INLINE_TREE\
|
(signed_cell) tree_find_integer_property
|
(signed_cell) tree_find_integer_property
|
(device *root,
|
(device *root,
|
const char *path_to_property);
|
const char *path_to_property);
|
|
|
INLINE_TREE\
|
INLINE_TREE\
|
(device_instance *) tree_find_ihandle_property
|
(device_instance *) tree_find_ihandle_property
|
(device *root,
|
(device *root,
|
const char *path_to_property);
|
const char *path_to_property);
|
|
|
INLINE_TREE\
|
INLINE_TREE\
|
(const char *) tree_find_string_property
|
(const char *) tree_find_string_property
|
(device *root,
|
(device *root,
|
const char *path_to_property);
|
const char *path_to_property);
|
|
|
|
|
/* Initializing the created tree:
|
/* Initializing the created tree:
|
|
|
Once a device tree has been created the <<device_tree_init()>>
|
Once a device tree has been created the <<device_tree_init()>>
|
function is used to initialize it. The exact sequence of events
|
function is used to initialize it. The exact sequence of events
|
that occure during initialization are described separatly.
|
that occure during initialization are described separatly.
|
|
|
*/
|
*/
|
|
|
INLINE_TREE\
|
INLINE_TREE\
|
(void) tree_init
|
(void) tree_init
|
(device *root,
|
(device *root,
|
psim *system);
|
psim *system);
|
|
|
|
|
#endif /* _TREE_H_ */
|
#endif /* _TREE_H_ */
|
|
|