blob: 8f728561f67a7d7a1214b4c9a7abe0d1b2d910bf [file] [log] [blame]
Andrew Scull18834872018-10-12 11:48:09 +01001/*
Andrew Walbran692b3252019-03-07 15:51:31 +00002 * Copyright 2018 The Hafnium Authors.
Andrew Scull18834872018-10-12 11:48:09 +01003 *
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);
Andrew Scull37402872018-10-24 14:23:06 +010031uint32_t fdt_total_size(struct fdt_header *hdr);
David Brazdil7a462ec2019-08-15 12:27:47 +010032void fdt_dump(const 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);
David Brazdil7a462ec2019-08-15 12:27:47 +010039bool fdt_parse_number(const char *data, uint32_t size, uint64_t *value);
Wedson Almeida Filho987c0ff2018-06-20 16:34:38 +010040
Andrew Scull4f170f52018-07-19 12:58:20 +010041void fdt_add_mem_reservation(struct fdt_header *hdr, uint64_t addr,
42 uint64_t len);