ia64/linux-2.6.18-xen.hg

diff arch/mips/sgi-ip27/ip27-klconfig.c @ 0:831230e53067

Import 2.6.18 from kernel.org tarball.
author Ian Campbell <ian.campbell@xensource.com>
date Wed Apr 11 14:15:44 2007 +0100 (2007-04-11)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/arch/mips/sgi-ip27/ip27-klconfig.c	Wed Apr 11 14:15:44 2007 +0100
     1.3 @@ -0,0 +1,135 @@
     1.4 +/*
     1.5 + * Copyright (C) 1999, 2000 Ralf Baechle (ralf@gnu.org)
     1.6 + * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
     1.7 + */
     1.8 +#include <linux/init.h>
     1.9 +#include <linux/kernel.h>
    1.10 +#include <linux/sched.h>
    1.11 +#include <linux/interrupt.h>
    1.12 +#include <linux/kernel_stat.h>
    1.13 +#include <linux/param.h>
    1.14 +#include <linux/timex.h>
    1.15 +#include <linux/mm.h>
    1.16 +
    1.17 +#include <asm/sn/klconfig.h>
    1.18 +#include <asm/sn/arch.h>
    1.19 +#include <asm/sn/gda.h>
    1.20 +
    1.21 +klinfo_t *find_component(lboard_t *brd, klinfo_t *kli, unsigned char struct_type)
    1.22 +{
    1.23 +	int index, j;
    1.24 +
    1.25 +	if (kli == (klinfo_t *)NULL) {
    1.26 +		index = 0;
    1.27 +	} else {
    1.28 +		for (j = 0; j < KLCF_NUM_COMPS(brd); j++)
    1.29 +			if (kli == KLCF_COMP(brd, j))
    1.30 +				break;
    1.31 +		index = j;
    1.32 +		if (index == KLCF_NUM_COMPS(brd)) {
    1.33 +			printk("find_component: Bad pointer: 0x%p\n", kli);
    1.34 +			return (klinfo_t *)NULL;
    1.35 +		}
    1.36 +		index++;		/* next component */
    1.37 +	}
    1.38 +
    1.39 +	for (; index < KLCF_NUM_COMPS(brd); index++) {
    1.40 +		kli = KLCF_COMP(brd, index);
    1.41 +		if (KLCF_COMP_TYPE(kli) == struct_type)
    1.42 +			return kli;
    1.43 +	}
    1.44 +
    1.45 +	/* Didn't find it. */
    1.46 +	return (klinfo_t *)NULL;
    1.47 +}
    1.48 +
    1.49 +klinfo_t *find_first_component(lboard_t *brd, unsigned char struct_type)
    1.50 +{
    1.51 +	return find_component(brd, (klinfo_t *)NULL, struct_type);
    1.52 +}
    1.53 +
    1.54 +lboard_t * find_lboard(lboard_t *start, unsigned char brd_type)
    1.55 +{
    1.56 +	/* Search all boards stored on this node. */
    1.57 +	while (start) {
    1.58 +		if (start->brd_type == brd_type)
    1.59 +			return start;
    1.60 +		start = KLCF_NEXT(start);
    1.61 +	}
    1.62 +	/* Didn't find it. */
    1.63 +	return (lboard_t *)NULL;
    1.64 +}
    1.65 +
    1.66 +lboard_t * find_lboard_class(lboard_t *start, unsigned char brd_type)
    1.67 +{
    1.68 +	/* Search all boards stored on this node. */
    1.69 +	while (start) {
    1.70 +		if (KLCLASS(start->brd_type) == KLCLASS(brd_type))
    1.71 +			return start;
    1.72 +		start = KLCF_NEXT(start);
    1.73 +	}
    1.74 +
    1.75 +	/* Didn't find it. */
    1.76 +	return (lboard_t *)NULL;
    1.77 +}
    1.78 +
    1.79 +cnodeid_t get_cpu_cnode(cpuid_t cpu)
    1.80 +{
    1.81 +	return CPUID_TO_COMPACT_NODEID(cpu);
    1.82 +}
    1.83 +
    1.84 +klcpu_t * nasid_slice_to_cpuinfo(nasid_t nasid, int slice)
    1.85 +{
    1.86 +	lboard_t *brd;
    1.87 +	klcpu_t *acpu;
    1.88 +
    1.89 +	if (!(brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_IP27)))
    1.90 +		return (klcpu_t *)NULL;
    1.91 +
    1.92 +	if (!(acpu = (klcpu_t *)find_first_component(brd, KLSTRUCT_CPU)))
    1.93 +		return (klcpu_t *)NULL;
    1.94 +
    1.95 +	do {
    1.96 +		if ((acpu->cpu_info.physid) == slice)
    1.97 +			return acpu;
    1.98 +	} while ((acpu = (klcpu_t *)find_component(brd, (klinfo_t *)acpu,
    1.99 +								KLSTRUCT_CPU)));
   1.100 +	return (klcpu_t *)NULL;
   1.101 +}
   1.102 +
   1.103 +klcpu_t * sn_get_cpuinfo(cpuid_t cpu)
   1.104 +{
   1.105 +	nasid_t nasid;
   1.106 +	int slice;
   1.107 +	klcpu_t *acpu;
   1.108 +	gda_t *gdap = GDA;
   1.109 +	cnodeid_t cnode;
   1.110 +
   1.111 +	if (!(cpu < MAXCPUS)) {
   1.112 +		printk("sn_get_cpuinfo: illegal cpuid 0x%lx\n", cpu);
   1.113 +		return NULL;
   1.114 +	}
   1.115 +
   1.116 +	cnode = get_cpu_cnode(cpu);
   1.117 +	if (cnode == INVALID_CNODEID)
   1.118 +		return NULL;
   1.119 +
   1.120 +	if ((nasid = gdap->g_nasidtable[cnode]) == INVALID_NASID)
   1.121 +		return NULL;
   1.122 +
   1.123 +	for (slice = 0; slice < CPUS_PER_NODE; slice++) {
   1.124 +		acpu = nasid_slice_to_cpuinfo(nasid, slice);
   1.125 +		if (acpu && acpu->cpu_info.virtid == cpu)
   1.126 +			return acpu;
   1.127 +	}
   1.128 +	return NULL;
   1.129 +}
   1.130 +
   1.131 +int get_cpu_slice(cpuid_t cpu)
   1.132 +{
   1.133 +	klcpu_t *acpu;
   1.134 +
   1.135 +	if ((acpu = sn_get_cpuinfo(cpu)) == NULL)
   1.136 +		return -1;
   1.137 +	return acpu->cpu_info.physid;
   1.138 +}