Bo Lv | 72d0e90 | 2023-01-02 14:27:34 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: (GPL-2.0+ OR MIT) |
| 2 | /* |
| 3 | * Copyright (c) 2019 Amlogic, Inc. All rights reserved. |
| 4 | */ |
| 5 | |
| 6 | #include <amlogic/blxx2bl33_param.h> |
| 7 | |
| 8 | #define param_end(x) ((x) > (BL2E2BL33_PARAM_END)) |
| 9 | |
| 10 | struct param_e *next_entry(struct param_e *param_pre) |
| 11 | { |
| 12 | struct param_e *param_next; |
| 13 | |
| 14 | param_next = (struct param_e *)((unsigned long)param_pre + param_pre->len); |
| 15 | if (param_end((unsigned long)param_next)) |
| 16 | return NULL; |
| 17 | |
| 18 | return param_next; |
| 19 | } |
| 20 | |
| 21 | struct param_e *param_of(int type) |
| 22 | { |
Bo Lv | 62e2d17 | 2024-04-18 10:46:59 +0800 | [diff] [blame] | 23 | #ifdef CONFIG_PXP_EMULATOR |
| 24 | return NULL; |
| 25 | #else |
Bo Lv | 72d0e90 | 2023-01-02 14:27:34 +0000 | [diff] [blame] | 26 | struct param_e *param; |
| 27 | |
| 28 | param = (struct param_e *)BL2E2BL33_PARAM_START; |
| 29 | |
| 30 | #if BLXX2BL33_PARAM_DEBUG |
| 31 | { |
| 32 | int i = 1; |
| 33 | unsigned char *data = (unsigned char *)BL2E2BL33_PARAM_START; |
| 34 | for (; i <= 512; i++) { |
| 35 | printf("%02x ", data[i-1]); |
| 36 | if (i%16 == 0) |
| 37 | printf("\n"); |
| 38 | } |
| 39 | } |
| 40 | #endif |
| 41 | |
| 42 | for (; param && param->type; param = next_entry(param)) { |
| 43 | if (param->type == STORAGE_PARAM_TYPE) |
| 44 | return param; |
| 45 | } |
| 46 | printf("ERROR %s(Type=%d) not found\n", __func__, type); |
| 47 | return NULL; |
Bo Lv | 62e2d17 | 2024-04-18 10:46:59 +0800 | [diff] [blame] | 48 | #endif |
Bo Lv | 72d0e90 | 2023-01-02 14:27:34 +0000 | [diff] [blame] | 49 | } |