anc_loader.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (c) 1997-2015, Actions Semi Co., Inc.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include <stdint.h>
  7. #include <string.h>
  8. #include <errno.h>
  9. #include <zephyr.h>
  10. #include <drivers/anc.h>
  11. #include <soc_anc.h>
  12. #include "anc_inner.h"
  13. #include "anc_image.h"
  14. int anc_acts_request_image(struct device *dev, const struct anc_imageinfo *image)
  15. {
  16. uint32_t entry_point = UINT32_MAX;
  17. struct anc_acts_data *anc_data = dev->data;
  18. if (load_anc_image(image->ptr, image->size, &entry_point)) {
  19. printk("%s: cannot load anc image <%s>\n", __func__, image->name);
  20. return -EINVAL;
  21. }
  22. printk("%s: anc image <%s> loaded, entry_point=0x%x\n",
  23. __func__, image->name, entry_point);
  24. /* set ANC_VECTOR_ADDRESS */
  25. set_anc_vector_addr(entry_point);
  26. SYS_LOG_INF(" ANC_VCT_ADDR=0x%x 0x%x\n", sys_read32(ANC_VCT_ADDR), entry_point);
  27. memcpy(&anc_data->images, image, sizeof(*image));
  28. anc_data->images.entry_point = entry_point;
  29. return 0;
  30. }
  31. int anc_acts_release_image(struct device *dev)
  32. {
  33. struct anc_acts_data *anc_data = dev->data;
  34. printk("%s: anc image <%s> free\n",
  35. __func__, anc_data->images.name);
  36. memset(&anc_data->images, 0, sizeof(anc_data->images));
  37. return 0;
  38. }