blob: fa96cdb01532ab3f144f4070abe3128b20639042 [file] [log] [blame]
Bo Lv72d0e902023-01-02 14:27:34 +00001// 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
10struct 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
21struct param_e *param_of(int type)
22{
Bo Lv62e2d172024-04-18 10:46:59 +080023#ifdef CONFIG_PXP_EMULATOR
24 return NULL;
25#else
Bo Lv72d0e902023-01-02 14:27:34 +000026 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 Lv62e2d172024-04-18 10:46:59 +080048#endif
Bo Lv72d0e902023-01-02 14:27:34 +000049}