David Brazdil | 17e7665 | 2020-01-29 14:44:19 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
David Brazdil | b856be6 | 2020-03-25 10:14:55 +0000 | [diff] [blame] | 17 | #include "hf/check.h" |
| 18 | |
David Brazdil | 17e7665 | 2020-01-29 14:44:19 +0000 | [diff] [blame] | 19 | #include "test/hftest.h" |
| 20 | |
David Brazdil | b856be6 | 2020-03-25 10:14:55 +0000 | [diff] [blame] | 21 | bool hftest_ctrl_start(const struct fdt *fdt, struct memiter *cmd) |
David Brazdil | 17e7665 | 2020-01-29 14:44:19 +0000 | [diff] [blame] | 22 | { |
| 23 | struct fdt_node n; |
David Brazdil | b856be6 | 2020-03-25 10:14:55 +0000 | [diff] [blame] | 24 | struct memiter bootargs; |
David Brazdil | 17e7665 | 2020-01-29 14:44:19 +0000 | [diff] [blame] | 25 | |
David Brazdil | b856be6 | 2020-03-25 10:14:55 +0000 | [diff] [blame] | 26 | if (!fdt_find_node(fdt, "/chosen", &n)) { |
| 27 | HFTEST_LOG("Could not find '/chosen' node."); |
David Brazdil | 17e7665 | 2020-01-29 14:44:19 +0000 | [diff] [blame] | 28 | return false; |
| 29 | } |
| 30 | |
David Brazdil | b856be6 | 2020-03-25 10:14:55 +0000 | [diff] [blame] | 31 | if (!fdt_read_property(&n, "bootargs", &bootargs)) { |
David Brazdil | 17e7665 | 2020-01-29 14:44:19 +0000 | [diff] [blame] | 32 | HFTEST_LOG("Unable to read bootargs."); |
| 33 | return false; |
| 34 | } |
| 35 | |
| 36 | /* Remove null terminator. */ |
David Brazdil | b856be6 | 2020-03-25 10:14:55 +0000 | [diff] [blame] | 37 | CHECK(memiter_restrict(&bootargs, 1)); |
| 38 | *cmd = bootargs; |
David Brazdil | 17e7665 | 2020-01-29 14:44:19 +0000 | [diff] [blame] | 39 | return true; |
| 40 | } |
| 41 | |
| 42 | void hftest_ctrl_finish(void) |
| 43 | { |
| 44 | /* Nothing to do. */ |
| 45 | } |