RTEMS 6.1-rc5
Loading...
Searching...
No Matches
ofw.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
15/*
16 * Copyright (C) 2020 Niteesh Babu G S <niteesh.gs@gmail.com>
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 * 1. Redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in the
25 * documentation and/or other materials provided with the distribution.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40#ifndef _OFW_H
41#define _OFW_H
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47#include <rtems.h>
48#include <stdint.h>
49#include <sys/types.h>
50
56typedef uint32_t phandle_t;
60typedef uint32_t ihandle_t;
64typedef uint32_t pcell_t;
65
72typedef struct {
74 uint32_t start;
76 uint32_t size;
78
84typedef struct {
86 uint32_t child_bus;
88 uint32_t parent_bus;
90 uint32_t size;
92
102 phandle_t node
103);
104
114 phandle_t node
115);
116
126 phandle_t node
127);
128
139 phandle_t node,
140 const char *propname
141);
142
154ssize_t rtems_ofw_get_prop(
155 phandle_t node,
156 const char *propname,
157 void *buf,
158 size_t len
159);
160
177 phandle_t node,
178 const char *prop,
179 pcell_t *buf,
180 size_t len
181);
182
193 phandle_t node,
194 const char *propname
195);
196
212 phandle_t node,
213 const char *propname,
214 void *buf,
215 size_t len
216);
217
235 phandle_t node,
236 const char *propname,
237 pcell_t *buf,
238 size_t len
239);
240
256 phandle_t node,
257 const char *propname,
258 void **buf
259);
260
278 phandle_t node,
279 const char *propname,
280 int elsz,
281 void **buf
282);
283
299 phandle_t node,
300 const char *propname,
301 void **buf
302);
303
320 phandle_t node,
321 const char *propname,
322 int elsz,
323 void **buf
324);
325
331void rtems_ofw_free(
332 void *buf
333);
334
352 phandle_t node,
353 const char *previous,
354 char *buf,
355 size_t len
356);
357
370int rtems_ofw_set_prop(
371 phandle_t node,
372 const char *name,
373 const void *buf,
374 size_t len
375);
376
387 const char *dev,
388 char *buf,
389 size_t len
390);
391
401 const char *path
402);
403
413 phandle_t xref
414);
415
423 phandle_t node
424);
425
426/*
427 * instance handles(ihandle_t) as same as phandles in the FDT implementation
428 * of OF interface.
429 */
430
442 ihandle_t instance
443);
444
455 phandle_t node,
456 char *buf,
457 size_t len
458);
459
470 ihandle_t instance,
471 char *buf,
472 size_t len
473);
474
492 phandle_t node,
494 size_t size
495);
496
513 phandle_t node,
515 size_t size
516);
517
530
542phandle_t rtems_ofw_find_device_by_compat( const char *compat );
543
559bool rtems_ofw_is_node_compatible( phandle_t node, const char *compat );
560
561#ifdef __cplusplus
562}
563#endif
564
565#endif /* _OFW_H */
ISR_Vector_number rtems_vector_number
This integer type represents interrupt vector numbers.
Definition: intr.h:102
bool rtems_ofw_is_node_compatible(phandle_t node, const char *compat)
check a nodes compatible property.
Definition: ofw.c:704
ssize_t rtems_ofw_get_enc_prop(phandle_t node, const char *prop, pcell_t *buf, size_t len)
Gets the value of property mentioned in prop.
Definition: ofw.c:238
ssize_t rtems_ofw_get_prop_alloc(phandle_t node, const char *propname, void **buf)
Gets the value of property mentioned in propname.
Definition: ofw.c:308
phandle_t rtems_ofw_peer(phandle_t node)
Gets the node that is next to node.
Definition: ofw.c:98
bool rtems_ofw_node_status(phandle_t node)
Queries the node's status.
Definition: ofw.c:681
ssize_t rtems_ofw_instance_to_path(ihandle_t instance, char *buf, size_t len)
Find the node's path from ihandle.
Definition: ofw.c:584
phandle_t rtems_ofw_instance_to_package(ihandle_t instance)
Converts instance handle to phandle.
Definition: ofw.c:561
uint32_t phandle_t
Definition: ofw.h:56
ssize_t rtems_ofw_get_prop_alloc_multi(phandle_t node, const char *propname, int elsz, void **buf)
Gets multiple values of the property propname.
Definition: ofw.c:337
int rtems_ofw_next_prop(phandle_t node, const char *previous, char *buf, size_t len)
Finds the next property of node.
Definition: ofw.c:433
int rtems_ofw_get_reg(phandle_t node, rtems_ofw_memory_area *buf, size_t size)
Queries the node's reg value.
Definition: ofw.c:603
ssize_t rtems_ofw_get_enc_prop_alloc_multi(phandle_t node, const char *propname, int elsz, void **buf)
Gets multiple values of the property propname.
Definition: ofw.c:397
phandle_t rtems_ofw_find_device(const char *path)
Finds the node at the given path.
Definition: ofw.c:498
phandle_t rtems_ofw_find_device_by_compat(const char *compat)
Gets node phandle from compatible property.
Definition: ofw.c:696
uint32_t pcell_t
Definition: ofw.h:64
uint32_t ihandle_t
Definition: ofw.h:60
void rtems_ofw_free(void *buf)
Free's the buffers allocated by the rtems_ofw_*_alloc functions.
Definition: ofw.c:428
ssize_t rtems_ofw_search_prop(phandle_t node, const char *propname, void *buf, size_t len)
Searches for property propname in node.
Definition: ofw.c:272
ssize_t rtems_ofw_canon(const char *dev, char *buf, size_t len)
Converts a device specifier to a fully qualified path name.
phandle_t rtems_ofw_node_from_xref(phandle_t xref)
This routine converts effective phandle xref to node offset.
Definition: ofw.c:537
int rtems_ofw_has_prop(phandle_t node, const char *propname)
Checks if the property propname is present in node.
Definition: ofw.c:261
ssize_t rtems_ofw_get_prop_len(phandle_t node, const char *propname)
Gets the length of the property mentioned in propname.
Definition: ofw.c:144
ssize_t rtems_ofw_search_enc_prop(phandle_t node, const char *propname, pcell_t *buf, size_t len)
Searches for property propname in node.
Definition: ofw.c:290
int rtems_ofw_get_interrupts(phandle_t node, rtems_vector_number *buf, size_t size)
Queries the node's interrupt value.
Definition: ofw.c:664
phandle_t rtems_ofw_child(phandle_t node)
Gets the node that is the child of node.
Definition: ofw.c:116
ssize_t rtems_ofw_package_to_path(phandle_t node, char *buf, size_t len)
Find the node's path from phandle.
Definition: ofw.c:566
ssize_t rtems_ofw_get_prop(phandle_t node, const char *propname, void *buf, size_t len)
Gets the value of property mentioned in propname.
Definition: ofw.c:180
ssize_t rtems_ofw_get_enc_prop_alloc(phandle_t node, const char *propname, void **buf)
Gets the value of property mentioned in propname.
Definition: ofw.c:368
phandle_t rtems_ofw_parent(phandle_t node)
Gets the node that is the parent of node.
Definition: ofw.c:130
phandle_t rtems_ofw_xref_from_node(phandle_t node)
This routine converts node offset to effective phandle of node.
Definition: ofw.c:547
This header file defines the RTEMS Classic API.
Definition: ofw.h:72
uint32_t size
Definition: ofw.h:76
uint32_t start
Definition: ofw.h:74
Definition: ofw.h:84
uint32_t size
Definition: ofw.h:90
uint32_t parent_bus
Definition: ofw.h:88
uint32_t child_bus
Definition: ofw.h:86