1# Copyright (C) 2020-2022 The opuntiaOS Project Authors.
2# + Contributed by Nikita Melekhin <nimelehin@gmail.com>
3#
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7from construct import *
8
9DEVTREE_HEADER_SIGNATURE = "odtr3"
10
11DEVTREE_HEADER = Struct(
12 "signature" / PaddedString(8, "ascii"),
13 "revision" / Int32ul,
14 "flags" / Int32ul,
15 "entries_count" / Int32ul,
16 "name_list_offset" / Int32ul
17)
18
19DEVTREE_ENTRY_FLAGS_MMIO = (1 << 0)
20DEVTREE_ENTRY_TYPE_IO = 0
21DEVTREE_ENTRY_TYPE_FB = 1
22DEVTREE_ENTRY_TYPE_UART = 2
23DEVTREE_ENTRY_TYPE_RAM = 3
24DEVTREE_ENTRY_TYPE_STORAGE = 4
25DEVTREE_ENTRY_TYPE_BUS_CONTROLLER = 5
26
27DEVTREE_ENTRY = Struct(
28 "type" / Int32ul,
29 "flags" / Int32ul,
30 "paddr" / Int32ul,
31 "rel_name_offset" / Int32ul,
32)