2
* libfdt - Flat Device Tree manipulation
3
* Testcase for DT overlays()
4
* Copyright (C) 2016 Free Electrons
5
* Copyright (C) 2016 NextThing Co.
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public License
9
* as published by the Free Software Foundation; either version 2.1 of
10
* the License, or (at your option) any later version.
12
* This library is distributed in the hope that it will be useful, but
13
* WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this library; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28
#define CHECK(code, expected) \
31
if (err != expected) \
32
FAIL(#code ": %s", fdt_strerror(err)); \
35
/* 4k ought to be enough for anybody */
36
#define FDT_COPY_SIZE (4 * 1024)
38
static void *open_dt(char *path)
44
copy = xmalloc(FDT_COPY_SIZE);
47
* Resize our DTs to 4k so that we have room to operate on
49
CHECK(fdt_open_into(dt, copy, FDT_COPY_SIZE), 0);
54
int main(int argc, char *argv[])
56
void *fdt_base, *fdt_overlay;
59
test_init(argc, argv);
61
CONFIG("Usage: %s <base dtb> <overlay dtb>", argv[0]);
63
fdt_base = open_dt(argv[1]);
64
fdt_overlay = open_dt(argv[2]);
66
/* Apply the overlay */
67
CHECK(fdt_overlay_apply(fdt_base, fdt_overlay), -FDT_ERR_BADOVERLAY);