switch.c 732 B

123456789101112131415161718192021222324252627
  1. /* Copyright 2018 SiFive, Inc */
  2. /* SPDX-License-Identifier: Apache-2.0 */
  3. #include <metal/switch.h>
  4. #include <metal/machine.h>
  5. struct metal_switch* metal_switch_get (char *label)
  6. {
  7. int i;
  8. struct metal_switch *flip;
  9. if ((__METAL_DT_MAX_BUTTONS == 0) || (label == NULL)) {
  10. return NULL;
  11. }
  12. for (i = 0; i < __METAL_DT_MAX_BUTTONS; i++) {
  13. flip = (struct metal_switch*)__metal_switch_table[i];
  14. if (flip->vtable->switch_exist(flip, label)) {
  15. return flip;
  16. }
  17. }
  18. return NULL;
  19. }
  20. extern __inline__ struct metal_interrupt*
  21. metal_switch_interrupt_controller(struct metal_switch *flip);
  22. extern __inline__ int metal_switch_get_interrupt_id(struct metal_switch *flip);