blob: 85fe1cb7cb171b3eae796a23b238111a1891b174 [file] [log] [blame]
David Brazdil17e76652020-01-29 14:44:19 +00001/*
2 * Copyright 2020 The Hafnium Authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "test/hftest.h"
18
19bool hftest_ctrl_start(const struct fdt_header *fdt, struct memiter *cmd)
20{
21 struct fdt_node n;
22 const char *bootargs;
23 uint32_t bootargs_size;
24
25 if (!fdt_root_node(&n, fdt)) {
26 HFTEST_LOG("FDT failed validation.");
27 return false;
28 }
29
30 if (!fdt_find_child(&n, "")) {
31 HFTEST_LOG("Unable to find root node in FDT.");
32 return false;
33 }
34
35 if (!fdt_find_child(&n, "chosen")) {
36 HFTEST_LOG("Unable to find 'chosen' node in FDT.");
37 return false;
38 }
39
40 if (!fdt_read_property(&n, "bootargs", &bootargs, &bootargs_size)) {
41 HFTEST_LOG("Unable to read bootargs.");
42 return false;
43 }
44
45 /* Remove null terminator. */
46 memiter_init(cmd, bootargs, bootargs_size - 1);
47 return true;
48}
49
50void hftest_ctrl_finish(void)
51{
52 /* Nothing to do. */
53}