ip27-klconfig.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (C) 1999, 2000 Ralf Baechle ([email protected])
  4. * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
  5. */
  6. #include <linux/kernel.h>
  7. #include <linux/sched.h>
  8. #include <linux/interrupt.h>
  9. #include <linux/kernel_stat.h>
  10. #include <linux/param.h>
  11. #include <linux/timex.h>
  12. #include <linux/mm.h>
  13. #include <asm/sn/klconfig.h>
  14. #include <asm/sn/arch.h>
  15. #include <asm/sn/gda.h>
  16. klinfo_t *find_component(lboard_t *brd, klinfo_t *kli, unsigned char struct_type)
  17. {
  18. int index, j;
  19. if (kli == (klinfo_t *)NULL) {
  20. index = 0;
  21. } else {
  22. for (j = 0; j < KLCF_NUM_COMPS(brd); j++)
  23. if (kli == KLCF_COMP(brd, j))
  24. break;
  25. index = j;
  26. if (index == KLCF_NUM_COMPS(brd)) {
  27. printk("find_component: Bad pointer: 0x%p\n", kli);
  28. return (klinfo_t *)NULL;
  29. }
  30. index++; /* next component */
  31. }
  32. for (; index < KLCF_NUM_COMPS(brd); index++) {
  33. kli = KLCF_COMP(brd, index);
  34. if (KLCF_COMP_TYPE(kli) == struct_type)
  35. return kli;
  36. }
  37. /* Didn't find it. */
  38. return (klinfo_t *)NULL;
  39. }
  40. klinfo_t *find_first_component(lboard_t *brd, unsigned char struct_type)
  41. {
  42. return find_component(brd, (klinfo_t *)NULL, struct_type);
  43. }
  44. lboard_t *find_lboard(lboard_t *start, unsigned char brd_type)
  45. {
  46. /* Search all boards stored on this node. */
  47. while (start) {
  48. if (start->brd_type == brd_type)
  49. return start;
  50. start = KLCF_NEXT(start);
  51. }
  52. /* Didn't find it. */
  53. return (lboard_t *)NULL;
  54. }
  55. lboard_t *find_lboard_class(lboard_t *start, unsigned char brd_type)
  56. {
  57. /* Search all boards stored on this node. */
  58. while (start) {
  59. if (KLCLASS(start->brd_type) == KLCLASS(brd_type))
  60. return start;
  61. start = KLCF_NEXT(start);
  62. }
  63. /* Didn't find it. */
  64. return (lboard_t *)NULL;
  65. }