aboutsummaryrefslogtreecommitdiff
path: root/include/libfdt_env.h
blob: 680939835015408c9f4834364be16b097a0fa180 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* SPDX-License-Identifier: copyleft-next-0.3.1 */
/* Copyright 2021 - 2022, Kim Kuparinen < kimi.h.kuparinen@gmail.com > */

#ifndef LIBFDT_ENV_H
/* take over libfdt */
#define LIBFDT_ENV_H

/**
 * @file libfdt_env.h
 * Set up kmi environment for libfdt.
 */

#include <kmi/types.h>
#include <kmi/string.h>
#include <kmi/bits.h>

/** 16bit integer. */
typedef int16_t fdt16_t;

/** 32bit integer. */
typedef int32_t fdt32_t;

/** 64bit integer. */
typedef int64_t fdt64_t;

/**
 * Convert FDT 32bit integer to cpu endianness.
 *
 * @param x Integer to convert.
 * @return Value of \c x in cpu endianness.
 */
#define fdt32_to_cpu(x) be32_to_cpu(x)

/**
 * Convert 32bit cpu endian integer to FDT endianness.
 *
 * @param x Integer to convert.
 * @return Value of \c x in FDT endianness.
 */
#define cpu_to_fdt32(x) cpu_to_be32(x)

/**
 * Convert FDT 64bit integer to cpu endianness.
 *
 * @param x Integer to convert.
 * @return Value of \c x in cpu endianness.
 */
#define fdt64_to_cpu(x) be64_to_cpu(x)

/**
 * Convert 64bit cpu endian integer to FDT endianness.
 *
 * @param x Integer to convert.
 * @return Value of \c x in FDT endianness.
 */
#define cpu_to_fdt64(x) cpu_to_be64(x)

#endif /* LIBFDT_ENV_H */