ls_interrupt_mgmt.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright 2020 NXP
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #include <bl31/interrupt_mgmt.h>
  8. #include <common/debug.h>
  9. #include <ls_interrupt_mgmt.h>
  10. #include <plat/common/platform.h>
  11. static interrupt_type_handler_t type_el3_interrupt_table[MAX_INTR_EL3];
  12. int request_intr_type_el3(uint32_t id, interrupt_type_handler_t handler)
  13. {
  14. /* Validate 'handler' and 'id' parameters */
  15. if (!handler || id >= MAX_INTR_EL3) {
  16. return -EINVAL;
  17. }
  18. /* Check if a handler has already been registered */
  19. if (type_el3_interrupt_table[id] != NULL) {
  20. return -EALREADY;
  21. }
  22. type_el3_interrupt_table[id] = handler;
  23. return 0;
  24. }
  25. static uint64_t ls_el3_interrupt_handler(uint32_t id, uint32_t flags,
  26. void *handle, void *cookie)
  27. {
  28. uint32_t intr_id;
  29. interrupt_type_handler_t handler;
  30. intr_id = plat_ic_get_pending_interrupt_id();
  31. INFO("Interrupt recvd is %d\n", intr_id);
  32. handler = type_el3_interrupt_table[intr_id];
  33. if (handler != NULL) {
  34. handler(intr_id, flags, handle, cookie);
  35. }
  36. /*
  37. * Mark this interrupt as complete to avoid a interrupt storm.
  38. */
  39. plat_ic_end_of_interrupt(intr_id);
  40. return 0U;
  41. }
  42. void ls_el3_interrupt_config(void)
  43. {
  44. uint64_t flags = 0U;
  45. uint64_t rc;
  46. set_interrupt_rm_flag(flags, NON_SECURE);
  47. rc = register_interrupt_type_handler(INTR_TYPE_EL3,
  48. ls_el3_interrupt_handler, flags);
  49. if (rc != 0U) {
  50. panic();
  51. }
  52. }