diff --git a/cpukit/include/rtems/rtems-fdt.h b/cpukit/include/rtems/rtems-fdt.h index 245823dbb1..ff8dbcce29 100644 --- a/cpukit/include/rtems/rtems-fdt.h +++ b/cpukit/include/rtems/rtems-fdt.h @@ -42,7 +42,6 @@ #define _RTEMS_FDT_H_ #include -#include #ifdef __cplusplus extern "C" { diff --git a/cpukit/include/rtems/rtems-fdtimpl.h b/cpukit/include/rtems/rtems-fdtimpl.h new file mode 100644 index 0000000000..ffdf6b844f --- /dev/null +++ b/cpukit/include/rtems/rtems-fdtimpl.h @@ -0,0 +1,91 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/* + * Copyright (C) 2026 Gedare Bloom + * COPYRIGHT (c) 2013-2017 Chris Johns + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * + * @ingroup rtems_fdt + * + * @brief RTEMS Flattened Device Tree Implementation + * + * Internal implementation Support for loading, managing and accessing FDT blobs in RTEMS. + */ + +/** + * @defgroup rtems_fdt_InternalAPI RTEMS FDT API Internals + * + * @brief RTEMS FDT Internal Information + * + * This concerns implementation information about the RTEMS FDT. + */ + +#ifndef RTEMS_FDTIMPL_H +#define RTEMS_FDTIMPL_H + +#include + +/** + * An index for quick access to the FDT by name or offset. + */ + +typedef struct { + const char *name; /**< The full path of the FDT item. */ + int offset; /**< The offset of the item in the FDT blob. */ +} rtems_fdt_index_entry; + +typedef struct { + int num_entries; /**< The number of entries in this index. */ + rtems_fdt_index_entry *entries; /**< An ordered set of entries which we + * can binary search. */ + char *names; /**< Storage allocated for all the path names. */ +} rtems_fdt_index; + +/** + * A blob descriptor. + */ +struct rtems_fdt_blob { + rtems_chain_node node; /**< The node's link in the chain. */ + const void *blob; /**< The FDT blob. */ + const char *name; /**< The name of the blob. */ + int refs; /**< The number of active references of the blob. */ + rtems_fdt_index + index; /**< The index used for quick access to items in the blob. */ +}; + +/** + * The global FDT data. This structure is allocated on the heap when the first + * call to load a FDT blob is made and released when all blobs have been + * unloaded.. + */ +typedef struct { + rtems_mutex lock; /**< The FDT lock id */ + rtems_chain_control blobs; /**< List if loaded blobs. */ + const char *paths; /**< Search paths for blobs. */ +} rtems_fdt_data; + +#endif diff --git a/cpukit/libmisc/rtems-fdt/rtems-fdt.c b/cpukit/libmisc/rtems-fdt/rtems-fdt.c index e68d9861c3..6ffdd64c17 100644 --- a/cpukit/libmisc/rtems-fdt/rtems-fdt.c +++ b/cpukit/libmisc/rtems-fdt/rtems-fdt.c @@ -37,44 +37,7 @@ #include #include -/** - * An index for quick access to the FDT by name or offset. - */ - -typedef struct { - const char *name; /**< The full path of the FDT item. */ - int offset; /**< The offset of the item in the FDT blob. */ -} rtems_fdt_index_entry; - -typedef struct { - int num_entries; /**< The number of entries in this index. */ - rtems_fdt_index_entry *entries; /**< An ordered set of entries which we - * can binary search. */ - char *names; /**< Storage allocated for all the path names. */ -} rtems_fdt_index; - -/** - * A blob descriptor. - */ -struct rtems_fdt_blob { - rtems_chain_node node; /**< The node's link in the chain. */ - const void *blob; /**< The FDT blob. */ - const char *name; /**< The name of the blob. */ - int refs; /**< The number of active references of the blob. */ - rtems_fdt_index - index; /**< The index used for quick access to items in the blob. */ -}; - -/** - * The global FDT data. This structure is allocated on the heap when the first - * call to load a FDT blob is made and released when all blobs have been - * unloaded.. - */ -typedef struct { - rtems_mutex lock; /**< The FDT lock id */ - rtems_chain_control blobs; /**< List if loaded blobs. */ - const char *paths; /**< Search paths for blobs. */ -} rtems_fdt_data; +#include static void rtems_fdt_unlock( rtems_fdt_data *fdt ) { diff --git a/spec/build/cpukit/librtemscpu.yml b/spec/build/cpukit/librtemscpu.yml index 7c4caf1ce9..681bd5e706 100644 --- a/spec/build/cpukit/librtemscpu.yml +++ b/spec/build/cpukit/librtemscpu.yml @@ -177,6 +177,7 @@ install: - cpukit/include/rtems/rtems-debugger.h - cpukit/include/rtems/rtems-fdt-shell.h - cpukit/include/rtems/rtems-fdt.h + - cpukit/include/rtems/rtems-fdtimpl.h - cpukit/include/rtems/rtems-rfs-format.h - cpukit/include/rtems/rtems-rfs-shell.h - cpukit/include/rtems/rtems-rfs.h