imx_common.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (c) 2024, Pengutronix, Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <errno.h>
  7. #include <stdint.h>
  8. #include <common/bl_common.h>
  9. #include <common/desc_image_load.h>
  10. #include <plat_common.h>
  11. /*
  12. * This function checks if @arg0 can safely be accessed as a pointer
  13. * and if it does, it fills in @bl32_info and @bl33_info with data
  14. * found in @arg0.
  15. *
  16. * Returns 0 when @arg0 can be used as entry point info and a negative
  17. * error code otherwise.
  18. */
  19. int imx_bl31_params_parse(uintptr_t arg0, uintptr_t ocram_base,
  20. uintptr_t ocram_size,
  21. entry_point_info_t *bl32_info,
  22. entry_point_info_t *bl33_info)
  23. {
  24. bl_params_t *v2 = (void *)(uintptr_t)arg0;
  25. if (arg0 & 0x3) {
  26. return -EINVAL;
  27. }
  28. if (arg0 < ocram_base || arg0 >= ocram_base + ocram_size) {
  29. return -EINVAL;
  30. }
  31. if (v2->h.version != PARAM_VERSION_2) {
  32. return -EINVAL;
  33. }
  34. if (v2->h.type != PARAM_BL_PARAMS) {
  35. return -EINVAL;
  36. }
  37. bl31_params_parse_helper(arg0, bl32_info, bl33_info);
  38. return 0;
  39. }