~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/mips/sgi-ip27/ip27-klconfig.c

Version: ~ [ linux-5.1-rc5 ] ~ [ linux-5.0.7 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.34 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.111 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.168 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.178 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.138 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.65 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /*
  3  * Copyright (C) 1999, 2000 Ralf Baechle (ralf@gnu.org)
  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 
 14 #include <asm/sn/klconfig.h>
 15 #include <asm/sn/arch.h>
 16 #include <asm/sn/gda.h>
 17 
 18 klinfo_t *find_component(lboard_t *brd, klinfo_t *kli, unsigned char struct_type)
 19 {
 20         int index, j;
 21 
 22         if (kli == (klinfo_t *)NULL) {
 23                 index = 0;
 24         } else {
 25                 for (j = 0; j < KLCF_NUM_COMPS(brd); j++)
 26                         if (kli == KLCF_COMP(brd, j))
 27                                 break;
 28                 index = j;
 29                 if (index == KLCF_NUM_COMPS(brd)) {
 30                         printk("find_component: Bad pointer: 0x%p\n", kli);
 31                         return (klinfo_t *)NULL;
 32                 }
 33                 index++;                /* next component */
 34         }
 35 
 36         for (; index < KLCF_NUM_COMPS(brd); index++) {
 37                 kli = KLCF_COMP(brd, index);
 38                 if (KLCF_COMP_TYPE(kli) == struct_type)
 39                         return kli;
 40         }
 41 
 42         /* Didn't find it. */
 43         return (klinfo_t *)NULL;
 44 }
 45 
 46 klinfo_t *find_first_component(lboard_t *brd, unsigned char struct_type)
 47 {
 48         return find_component(brd, (klinfo_t *)NULL, struct_type);
 49 }
 50 
 51 lboard_t *find_lboard(lboard_t *start, unsigned char brd_type)
 52 {
 53         /* Search all boards stored on this node. */
 54         while (start) {
 55                 if (start->brd_type == brd_type)
 56                         return start;
 57                 start = KLCF_NEXT(start);
 58         }
 59         /* Didn't find it. */
 60         return (lboard_t *)NULL;
 61 }
 62 
 63 lboard_t *find_lboard_class(lboard_t *start, unsigned char brd_type)
 64 {
 65         /* Search all boards stored on this node. */
 66         while (start) {
 67                 if (KLCLASS(start->brd_type) == KLCLASS(brd_type))
 68                         return start;
 69                 start = KLCF_NEXT(start);
 70         }
 71 
 72         /* Didn't find it. */
 73         return (lboard_t *)NULL;
 74 }
 75 
 76 cnodeid_t get_cpu_cnode(cpuid_t cpu)
 77 {
 78         return CPUID_TO_COMPACT_NODEID(cpu);
 79 }
 80 
 81 klcpu_t *nasid_slice_to_cpuinfo(nasid_t nasid, int slice)
 82 {
 83         lboard_t *brd;
 84         klcpu_t *acpu;
 85 
 86         if (!(brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_IP27)))
 87                 return (klcpu_t *)NULL;
 88 
 89         if (!(acpu = (klcpu_t *)find_first_component(brd, KLSTRUCT_CPU)))
 90                 return (klcpu_t *)NULL;
 91 
 92         do {
 93                 if ((acpu->cpu_info.physid) == slice)
 94                         return acpu;
 95         } while ((acpu = (klcpu_t *)find_component(brd, (klinfo_t *)acpu,
 96                                                                 KLSTRUCT_CPU)));
 97         return (klcpu_t *)NULL;
 98 }
 99 
100 klcpu_t *sn_get_cpuinfo(cpuid_t cpu)
101 {
102         nasid_t nasid;
103         int slice;
104         klcpu_t *acpu;
105         gda_t *gdap = GDA;
106         cnodeid_t cnode;
107 
108         if (!(cpu < MAXCPUS)) {
109                 printk("sn_get_cpuinfo: illegal cpuid 0x%lx\n", cpu);
110                 return NULL;
111         }
112 
113         cnode = get_cpu_cnode(cpu);
114         if (cnode == INVALID_CNODEID)
115                 return NULL;
116 
117         if ((nasid = gdap->g_nasidtable[cnode]) == INVALID_NASID)
118                 return NULL;
119 
120         for (slice = 0; slice < CPUS_PER_NODE; slice++) {
121                 acpu = nasid_slice_to_cpuinfo(nasid, slice);
122                 if (acpu && acpu->cpu_info.virtid == cpu)
123                         return acpu;
124         }
125         return NULL;
126 }
127 
128 int get_cpu_slice(cpuid_t cpu)
129 {
130         klcpu_t *acpu;
131 
132         if ((acpu = sn_get_cpuinfo(cpu)) == NULL)
133                 return -1;
134         return acpu->cpu_info.physid;
135 }
136 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp