1*b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds * Copyright (C) 1999, 2000 Ralf Baechle (ralf@gnu.org)
41da177e4SLinus Torvalds * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
51da177e4SLinus Torvalds */
61da177e4SLinus Torvalds #include <linux/kernel.h>
71da177e4SLinus Torvalds #include <linux/sched.h>
81da177e4SLinus Torvalds #include <linux/interrupt.h>
91da177e4SLinus Torvalds #include <linux/kernel_stat.h>
101da177e4SLinus Torvalds #include <linux/param.h>
111da177e4SLinus Torvalds #include <linux/timex.h>
121da177e4SLinus Torvalds #include <linux/mm.h>
131da177e4SLinus Torvalds
141da177e4SLinus Torvalds #include <asm/sn/klconfig.h>
151da177e4SLinus Torvalds #include <asm/sn/arch.h>
161da177e4SLinus Torvalds #include <asm/sn/gda.h>
171da177e4SLinus Torvalds
find_component(lboard_t * brd,klinfo_t * kli,unsigned char struct_type)181da177e4SLinus Torvalds klinfo_t *find_component(lboard_t *brd, klinfo_t *kli, unsigned char struct_type)
191da177e4SLinus Torvalds {
201da177e4SLinus Torvalds int index, j;
211da177e4SLinus Torvalds
221da177e4SLinus Torvalds if (kli == (klinfo_t *)NULL) {
231da177e4SLinus Torvalds index = 0;
241da177e4SLinus Torvalds } else {
251da177e4SLinus Torvalds for (j = 0; j < KLCF_NUM_COMPS(brd); j++)
261da177e4SLinus Torvalds if (kli == KLCF_COMP(brd, j))
271da177e4SLinus Torvalds break;
281da177e4SLinus Torvalds index = j;
291da177e4SLinus Torvalds if (index == KLCF_NUM_COMPS(brd)) {
301da177e4SLinus Torvalds printk("find_component: Bad pointer: 0x%p\n", kli);
311da177e4SLinus Torvalds return (klinfo_t *)NULL;
321da177e4SLinus Torvalds }
331da177e4SLinus Torvalds index++; /* next component */
341da177e4SLinus Torvalds }
351da177e4SLinus Torvalds
361da177e4SLinus Torvalds for (; index < KLCF_NUM_COMPS(brd); index++) {
371da177e4SLinus Torvalds kli = KLCF_COMP(brd, index);
381da177e4SLinus Torvalds if (KLCF_COMP_TYPE(kli) == struct_type)
391da177e4SLinus Torvalds return kli;
401da177e4SLinus Torvalds }
411da177e4SLinus Torvalds
421da177e4SLinus Torvalds /* Didn't find it. */
431da177e4SLinus Torvalds return (klinfo_t *)NULL;
441da177e4SLinus Torvalds }
451da177e4SLinus Torvalds
find_first_component(lboard_t * brd,unsigned char struct_type)461da177e4SLinus Torvalds klinfo_t *find_first_component(lboard_t *brd, unsigned char struct_type)
471da177e4SLinus Torvalds {
481da177e4SLinus Torvalds return find_component(brd, (klinfo_t *)NULL, struct_type);
491da177e4SLinus Torvalds }
501da177e4SLinus Torvalds
find_lboard(lboard_t * start,unsigned char brd_type)511da177e4SLinus Torvalds lboard_t *find_lboard(lboard_t *start, unsigned char brd_type)
521da177e4SLinus Torvalds {
531da177e4SLinus Torvalds /* Search all boards stored on this node. */
541da177e4SLinus Torvalds while (start) {
551da177e4SLinus Torvalds if (start->brd_type == brd_type)
561da177e4SLinus Torvalds return start;
571da177e4SLinus Torvalds start = KLCF_NEXT(start);
581da177e4SLinus Torvalds }
591da177e4SLinus Torvalds /* Didn't find it. */
601da177e4SLinus Torvalds return (lboard_t *)NULL;
611da177e4SLinus Torvalds }
621da177e4SLinus Torvalds
find_lboard_class(lboard_t * start,unsigned char brd_type)631da177e4SLinus Torvalds lboard_t *find_lboard_class(lboard_t *start, unsigned char brd_type)
641da177e4SLinus Torvalds {
651da177e4SLinus Torvalds /* Search all boards stored on this node. */
661da177e4SLinus Torvalds while (start) {
671da177e4SLinus Torvalds if (KLCLASS(start->brd_type) == KLCLASS(brd_type))
681da177e4SLinus Torvalds return start;
691da177e4SLinus Torvalds start = KLCF_NEXT(start);
701da177e4SLinus Torvalds }
711da177e4SLinus Torvalds
721da177e4SLinus Torvalds /* Didn't find it. */
731da177e4SLinus Torvalds return (lboard_t *)NULL;
741da177e4SLinus Torvalds }
75