File: dtb.h

package info (click to toggle)
virtualbox 7.2.6-dfsg-3
  • links: PTS, VCS
  • area: contrib
  • in suites: sid
  • size: 684,120 kB
  • sloc: ansic: 2,692,612; cpp: 2,685,536; asm: 402,532; python: 239,820; xml: 89,849; sh: 33,358; perl: 9,380; makefile: 8,889; java: 5,337; cs: 4,872; pascal: 1,785; javascript: 1,692; objc: 1,131; lex: 931; sed: 929; php: 906; yacc: 707
file content (158 lines) | stat: -rw-r--r-- 5,986 bytes parent folder | download
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/* $Id: dtb.h $ */
/** @file
 * IPRT, DTB (Flattened Devicetree) format.
 */

/*
 * Copyright (C) 2023-2025 Oracle and/or its affiliates.
 *
 * This file is part of VirtualBox base platform packages, as
 * available from https://www.virtualbox.org.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation, in version 3 of the
 * License.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <https://www.gnu.org/licenses>.
 *
 * The contents of this file may alternatively be used under the terms
 * of the Common Development and Distribution License Version 1.0
 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
 * in the VirtualBox distribution, in which case the provisions of the
 * CDDL are applicable instead of those of the GPL.
 *
 * You may elect to license modified versions of this file under the
 * terms and conditions of either the GPL or the CDDL or both.
 *
 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
 */

#ifndef IPRT_INCLUDED_formats_dtb_h
#define IPRT_INCLUDED_formats_dtb_h
#ifndef RT_WITHOUT_PRAGMA_ONCE
# pragma once
#endif

#include <iprt/types.h>
#include <iprt/cdefs.h>
#include <iprt/assertcompile.h>


/** @defgroup grp_rt_formats_dtb    Flattened Devicetree structures and definitions
 * @ingroup grp_rt_formats
 * @{
 */

/**
 * The Flattened Devicetree Header.
 *
 * @note All fields are in big endian format.
 */
typedef struct DTBFDTHDR
{
    /** 0x00 - Magic value to identify a Flattened Devicetree header. */
    uint32_t                u32Magic;
    /** 0x04 - Total size of the devicetree structure in bytes. */
    uint32_t                cbFdt;
    /** 0x08 - Offset in bytes of the structure block from the beginning of this header. */
    uint32_t                offDtStruct;
    /** 0x0c - Offset in bytes of the strings block from the beginning of this header. */
    uint32_t                offDtStrings;
    /** 0x10 - Offset in bytes of the memory reservation block from the beginning of this header. */
    uint32_t                offMemRsvMap;
    /** 0x14 - Version of the devicetree data structure. */
    uint32_t                u32Version;
    /** 0x18 - Lowest version of the devicetree data structure with which the version used is backwards compatible. */
    uint32_t                u32VersionLastCompatible;
    /** 0x1c - Physical ID of the system's boot CPU. */
    uint32_t                u32CpuIdPhysBoot;
    /** 0x20 - Length of the strings block section in bytes. */
    uint32_t                cbDtStrings;
    /** 0x24 - Length of the structure block section in bytes. */
    uint32_t                cbDtStruct;
} DTBFDTHDR;
AssertCompileSize(DTBFDTHDR, 40);
/** Pointer to a Flattened Devicetree header. */
typedef DTBFDTHDR *PDTBFDTHDR;
/** Pointer to a constant Flattened Devicetree header. */
typedef const DTBFDTHDR *PCDTBFDTHDR;

/** The magic value for identifying a DTB header. */
#define DTBFDTHDR_MAGIC             UINT32_C(0xd00dfeed)
/** The current DTB header version. */
#define DTBFDTHDR_VERSION           17
/** The last compatible DTB header version. */
#define DTBFDTHDR_VERSION_LAST_COMP 16


/**
 * Memory reservation block entry.
 */
typedef struct DTBFDTRSVENTRY
{
    /** 0x00 - Physical address of the start of the reserved area. */
    uint64_t                PhysAddrStart;
    /** 0x08 - Size of the reserved area in bytes. */
    uint64_t                cbArea;
} DTBFDTRSVENTRY;
AssertCompileSize(DTBFDTRSVENTRY, 16);
/** Pointer to a memory reservation block entry. */
typedef DTBFDTRSVENTRY *PDTBFDTRSVENTRY;
/** Pointer to a constant memory reservation block entry. */
typedef const DTBFDTRSVENTRY *PCDTBFDTRSVENTRY;


/** @name Structure block related definitions.
 * @{ */
/** A begin node token. */
#define DTB_FDT_TOKEN_BEGIN_NODE                UINT32_C(0x00000001)
/** Big endian version of the begin node token as read from a data stream. */
#define DTB_FDT_TOKEN_BEGIN_NODE_BE             RT_H2BE_U32(DTB_FDT_TOKEN_BEGIN_NODE)
/** A end node token. */
#define DTB_FDT_TOKEN_END_NODE                  UINT32_C(0x00000002)
/** Big endian version of the end node token as read from a data stream. */
#define DTB_FDT_TOKEN_END_NODE_BE               RT_H2BE_U32(DTB_FDT_TOKEN_END_NODE)
/** A property token. */
#define DTB_FDT_TOKEN_PROPERTY                  UINT32_C(0x00000003)
/** Big endian version of the property token as read from a data stream. */
#define DTB_FDT_TOKEN_PROPERTY_BE               RT_H2BE_U32(DTB_FDT_TOKEN_PROPERTY)
/** A no-op token. */
#define DTB_FDT_TOKEN_NOP                       UINT32_C(0x00000004)
/** Big endian version of the no-op token as read from a data stream. */
#define DTB_FDT_TOKEN_NOP_BE                    RT_H2BE_U32(DTB_FDT_TOKEN_NOP)
/** The end token. */
#define DTB_FDT_TOKEN_END                       UINT32_C(0x00000009)
/** Big endian version of the end token as read from a data stream. */
#define DTB_FDT_TOKEN_END_BE                    RT_H2BE_U32(DTB_FDT_TOKEN_END)


/**
 * DTB_FDT_TOKEN_PROPERTY data followed after the token.
 */
typedef struct DTBFDTPROP
{
    /** 0x00 - Length of the property data in bytes (or 0 if not data). */
    uint32_t                cbProperty;
    /** 0x04 - Offset of the property name in the strings block. */
    uint32_t                offPropertyName;
} DTBFDTPROP;
AssertCompileSize(DTBFDTPROP, 8);
/** Pointer to the FDT property data. */
typedef DTBFDTPROP *PDTBFDTPROP;
/** Pointer to constant FDT property data. */
typedef const DTBFDTPROP *PCDTBFDTPROP;


/** @} */

/** @} */

#endif /* !IPRT_INCLUDED_formats_dtb_h */