libopenbios: introduce BIND_NODE_METHODS() macro
This macro is designed to bind C functions into Forth words during creation of the device tree, but only into an existing node and without attempting to create any missing parent nodes. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
This commit is contained in:
parent
da2e55182a
commit
ca13d318ef
|
@ -127,6 +127,11 @@ typedef struct {
|
|||
paths, 1, name##_m, sizeof(name##_m)/sizeof(method_t)); \
|
||||
} while(0)
|
||||
|
||||
#define BIND_NODE_METHODS(ph, name) do { \
|
||||
bind_node_methods(ph, name##_flags_, name##_size_, \
|
||||
name##_m, sizeof(name##_m)/sizeof(method_t)); \
|
||||
} while(0)
|
||||
|
||||
#define DECLARE_UNNAMED_NODE( name, flags, size ) \
|
||||
static const int name##_flags_ = flags; \
|
||||
static const int name##_size_ = size;
|
||||
|
@ -144,6 +149,9 @@ static const method_t name##_m[]
|
|||
name##_m, sizeof(name##_m)/sizeof(method_t) ); \
|
||||
} while(0)
|
||||
|
||||
extern void
|
||||
bind_node_methods(phandle_t ph, int flags, int size, const method_t *methods, int nmet);
|
||||
|
||||
extern void bind_node( int flags, int size, const char * const *paths, int npaths,
|
||||
const method_t *methods, int nmethods );
|
||||
|
||||
|
|
|
@ -484,6 +484,16 @@ add_methods( int flags, int size, const method_t *methods, int nmet )
|
|||
make_openable(0);
|
||||
}
|
||||
|
||||
void
|
||||
bind_node_methods(phandle_t ph, int flags, int size, const method_t *methods, int nmet)
|
||||
{
|
||||
phandle_t save_ph = get_cur_dev();
|
||||
|
||||
activate_dev(ph);
|
||||
add_methods(flags, size, methods, nmet);
|
||||
activate_dev( save_ph );
|
||||
}
|
||||
|
||||
void
|
||||
bind_node( int flags, int size, const char * const *paths, int npaths,
|
||||
const method_t *methods, int nmet )
|
||||
|
|
Loading…
Reference in New Issue