blob: 14e7736ce911e7f7ad69bf92f251762de9926cb8 [file] [log] [blame]
Andrew Scull18834872018-10-12 11:48:09 +01001/*
2 * Copyright 2018 Google LLC
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Andrew Scullfbc938a2018-08-20 14:09:28 +010017#pragma once
Wedson Almeida Filho987c0ff2018-06-20 16:34:38 +010018
19#include <stdbool.h>
Wedson Almeida Filhofed69022018-07-11 15:39:12 +010020#include <stddef.h>
Wedson Almeida Filho987c0ff2018-06-20 16:34:38 +010021#include <stdint.h>
22
23struct fdt_node {
Wedson Almeida Filho987c0ff2018-06-20 16:34:38 +010024 const struct fdt_header *hdr;
25 const char *begin;
26 const char *end;
27 const char *strs;
28};
29
Wedson Almeida Filhofed69022018-07-11 15:39:12 +010030size_t fdt_header_size(void);
31size_t fdt_total_size(struct fdt_header *hdr);
Wedson Almeida Filho987c0ff2018-06-20 16:34:38 +010032void fdt_dump(struct fdt_header *hdr);
Wedson Almeida Filhofdf4afc2018-07-19 15:45:21 +010033bool fdt_root_node(struct fdt_node *node, const struct fdt_header *hdr);
Wedson Almeida Filho987c0ff2018-06-20 16:34:38 +010034bool fdt_find_child(struct fdt_node *node, const char *child);
Wedson Almeida Filho87009642018-07-02 10:20:07 +010035bool fdt_first_child(struct fdt_node *node, const char **child_name);
36bool fdt_next_sibling(struct fdt_node *node, const char **sibling_name);
Wedson Almeida Filho987c0ff2018-06-20 16:34:38 +010037bool fdt_read_property(const struct fdt_node *node, const char *name,
38 const char **buf, uint32_t *size);
39
Andrew Scull4f170f52018-07-19 12:58:20 +010040void fdt_add_mem_reservation(struct fdt_header *hdr, uint64_t addr,
41 uint64_t len);