1 | /* $Id: dtb.h 100006 2023-05-30 06:27:25Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT, DTB (Flattened Devicetree) format.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * The contents of this file may alternatively be used under the terms
|
---|
26 | * of the Common Development and Distribution License Version 1.0
|
---|
27 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
28 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
29 | * CDDL are applicable instead of those of the GPL.
|
---|
30 | *
|
---|
31 | * You may elect to license modified versions of this file under the
|
---|
32 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
33 | *
|
---|
34 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
35 | */
|
---|
36 |
|
---|
37 | #ifndef IPRT_INCLUDED_formats_dtb_h
|
---|
38 | #define IPRT_INCLUDED_formats_dtb_h
|
---|
39 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
40 | # pragma once
|
---|
41 | #endif
|
---|
42 |
|
---|
43 | #include <iprt/types.h>
|
---|
44 | #include <iprt/cdefs.h>
|
---|
45 | #include <iprt/assertcompile.h>
|
---|
46 |
|
---|
47 |
|
---|
48 | /** @defgroup grp_rt_formats_dtb Flattened Devicetree structures and definitions
|
---|
49 | * @ingroup grp_rt_formats
|
---|
50 | * @{
|
---|
51 | */
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * The Flattened Devicetree Header.
|
---|
55 | *
|
---|
56 | * @note All fields are in big endian format.
|
---|
57 | */
|
---|
58 | typedef struct DTBFDTHDR
|
---|
59 | {
|
---|
60 | /** 0x00 - Magic value to identify a Flattened Devicetree header. */
|
---|
61 | uint32_t u32Magic;
|
---|
62 | /** 0x04 - Total size of the devicetree structure in bytes. */
|
---|
63 | uint32_t cbFdt;
|
---|
64 | /** 0x08 - Offset in bytes of the structure block from the beginning of this header. */
|
---|
65 | uint32_t offDtStruct;
|
---|
66 | /** 0x0c - Offset in bytes of the strings block from the beginning of this header. */
|
---|
67 | uint32_t offDtStrings;
|
---|
68 | /** 0x10 - Offset in bytes of the memory reservation block from the beginning of this header. */
|
---|
69 | uint32_t offMemRsvMap;
|
---|
70 | /** 0x14 - Version of the devicetree data structure. */
|
---|
71 | uint32_t u32Version;
|
---|
72 | /** 0x18 - Lowest version of the devicetree data structure with which the version used is backwards compatible. */
|
---|
73 | uint32_t u32VersionLastCompatible;
|
---|
74 | /** 0x1c - Physical ID of the system's boot CPU. */
|
---|
75 | uint32_t u32CpuIdPhysBoot;
|
---|
76 | /** 0x20 - Length of the strings block section in bytes. */
|
---|
77 | uint32_t cbDtStrings;
|
---|
78 | /** 0x24 - Length of the structure block section in bytes. */
|
---|
79 | uint32_t cbDtStruct;
|
---|
80 | } DTBFDTHDR;
|
---|
81 | AssertCompileSize(DTBFDTHDR, 40);
|
---|
82 | /** Pointer to a Flattened Devicetree header. */
|
---|
83 | typedef DTBFDTHDR *PDTBFDTHDR;
|
---|
84 | /** Pointer to a constant Flattened Devicetree header. */
|
---|
85 | typedef const DTBFDTHDR *PCDTBFDTHDR;
|
---|
86 |
|
---|
87 | /** The magic value for identifying a DTB header. */
|
---|
88 | #define DTBFDTHDR_MAGIC UINT32_C(0xd00dfeed)
|
---|
89 | /** The current DTB header version. */
|
---|
90 | #define DTBFDTHDR_VERSION 17
|
---|
91 | /** The last compatible DTB header version. */
|
---|
92 | #define DTBFDTHDR_VERSION_LAST_COMP 16
|
---|
93 |
|
---|
94 |
|
---|
95 | /**
|
---|
96 | * Memory reservation block entry.
|
---|
97 | */
|
---|
98 | typedef struct DTBFDTRSVENTRY
|
---|
99 | {
|
---|
100 | /** 0x00 - Physical address of the start of the reserved area. */
|
---|
101 | uint64_t PhysAddrStart;
|
---|
102 | /** 0x08 - Size of the reserved area in bytes. */
|
---|
103 | uint64_t cbArea;
|
---|
104 | } DTBFDTRSVENTRY;
|
---|
105 | AssertCompileSize(DTBFDTRSVENTRY, 16);
|
---|
106 | /** Pointer to a memory reservation block entry. */
|
---|
107 | typedef DTBFDTRSVENTRY *PDTBFDTRSVENTRY;
|
---|
108 | /** Pointer to a constant memory reservation block entry. */
|
---|
109 | typedef const DTBFDTRSVENTRY *PCDTBFDTRSVENTRY;
|
---|
110 |
|
---|
111 |
|
---|
112 | /** @name Structure block related definitions.
|
---|
113 | * @{ */
|
---|
114 | /** A begin node token. */
|
---|
115 | #define DTB_FDT_TOKEN_BEGIN_NODE UINT32_C(0x00000001)
|
---|
116 | /** Big endian version of the begin node token as read from a data stream. */
|
---|
117 | #define DTB_FDT_TOKEN_BEGIN_NODE_BE RT_H2BE_U32(DTB_FDT_TOKEN_BEGIN_NODE)
|
---|
118 | /** A end node token. */
|
---|
119 | #define DTB_FDT_TOKEN_END_NODE UINT32_C(0x00000002)
|
---|
120 | /** Big endian version of the end node token as read from a data stream. */
|
---|
121 | #define DTB_FDT_TOKEN_END_NODE_BE RT_H2BE_U32(DTB_FDT_TOKEN_END_NODE)
|
---|
122 | /** A property token. */
|
---|
123 | #define DTB_FDT_TOKEN_PROPERTY UINT32_C(0x00000003)
|
---|
124 | /** Big endian version of the property token as read from a data stream. */
|
---|
125 | #define DTB_FDT_TOKEN_PROPERTY_BE RT_H2BE_U32(DTB_FDT_TOKEN_PROPERTY)
|
---|
126 | /** A no-op token. */
|
---|
127 | #define DTB_FDT_TOKEN_NOP UINT32_C(0x00000004)
|
---|
128 | /** Big endian version of the no-op token as read from a data stream. */
|
---|
129 | #define DTB_FDT_TOKEN_NOP_BE RT_H2BE_U32(DTB_FDT_TOKEN_NOP)
|
---|
130 | /** The end token. */
|
---|
131 | #define DTB_FDT_TOKEN_END UINT32_C(0x00000009)
|
---|
132 | /** Big endian version of the end token as read from a data stream. */
|
---|
133 | #define DTB_FDT_TOKEN_END_BE RT_H2BE_U32(DTB_FDT_TOKEN_END)
|
---|
134 |
|
---|
135 |
|
---|
136 | /**
|
---|
137 | * DTB_FDT_TOKEN_PROPERTY data followed after the token.
|
---|
138 | */
|
---|
139 | typedef struct DTBFDTPROP
|
---|
140 | {
|
---|
141 | /** 0x00 - Length of the property data in bytes (or 0 if not data). */
|
---|
142 | uint32_t cbProperty;
|
---|
143 | /** 0x04 - Offset of the property name in the strings block. */
|
---|
144 | uint32_t offPropertyName;
|
---|
145 | } DTBFDTPROP;
|
---|
146 | AssertCompileSize(DTBFDTPROP, 8);
|
---|
147 | /** Pointer to the FDT property data. */
|
---|
148 | typedef DTBFDTPROP *PDTBFDTPROP;
|
---|
149 | /** Pointer to constant FDT property data. */
|
---|
150 | typedef const DTBFDTPROP *PCDTBFDTPROP;
|
---|
151 |
|
---|
152 |
|
---|
153 | /** @} */
|
---|
154 |
|
---|
155 | /** @} */
|
---|
156 |
|
---|
157 | #endif /* !IPRT_INCLUDED_formats_dtb_h */
|
---|
158 |
|
---|