ml_SN_init.c 2.68 KB
Newer Older
Andrew Morton's avatar
Andrew Morton committed
1
/*
Jesse Barnes's avatar
Jesse Barnes committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 *
 * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
 */

#include <linux/types.h>
#include <linux/slab.h>
#include <linux/bootmem.h>
#include <asm/sn/sgi.h>
#include <asm/sn/io.h>
#include <asm/sn/hcl.h>
#include <asm/sn/labelcl.h>
#include <asm/sn/sn_private.h>
#include <asm/sn/klconfig.h>
#include <asm/sn/sn_cpuid.h>
19
#include <asm/sn/simulator.h>
Jesse Barnes's avatar
Jesse Barnes committed
20 21 22 23 24 25 26 27 28 29 30 31

int		maxcpus;

extern xwidgetnum_t hub_widget_id(nasid_t);

/* XXX - Move the meat of this to intr.c ? */
/*
 * Set up the platform-dependent fields in the nodepda.
 */
void init_platform_nodepda(nodepda_t *npda, cnodeid_t node)
{
	hubinfo_t hubinfo;
32
	nasid_t nasid;
Jesse Barnes's avatar
Jesse Barnes committed
33 34

	/* Allocate per-node platform-dependent data */
35
	
36
	nasid = cnodeid_to_nasid(node);
37 38 39 40
	if (node >= numnodes) /* Headless/memless IO nodes */
		hubinfo = (hubinfo_t)alloc_bootmem_node(NODE_DATA(0), sizeof(struct hubinfo_s));
	else
		hubinfo = (hubinfo_t)alloc_bootmem_node(NODE_DATA(node), sizeof(struct hubinfo_s));
Jesse Barnes's avatar
Jesse Barnes committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63

	npda->pdinfo = (void *)hubinfo;
	hubinfo->h_nodepda = npda;
	hubinfo->h_cnodeid = node;

	spin_lock_init(&hubinfo->h_crblock);

	npda->xbow_peer = INVALID_NASID;

	/* 
	 * Initialize the linked list of
	 * router info pointers to the dependent routers
	 */
	npda->npda_rip_first = NULL;

	/*
	 * npda_rip_last always points to the place
	 * where the next element is to be inserted
	 * into the list 
	 */
	npda->npda_rip_last = &npda->npda_rip_first;
	npda->geoid.any.type = GEO_TYPE_INVALID;

64
	init_MUTEX_LOCKED(&npda->xbow_sema); /* init it locked? */
Jesse Barnes's avatar
Jesse Barnes committed
65 66
}

67
void
68 69
init_platform_hubinfo(nodepda_t **nodepdaindr)
{
70 71 72 73 74
	cnodeid_t       cnode;
	hubinfo_t hubinfo;
	nodepda_t *npda;
	extern int numionodes;

75 76
	if (IS_RUNNING_ON_SIMULATOR())
		return;
77 78 79
	for (cnode = 0; cnode < numionodes; cnode++) {
		npda = nodepdaindr[cnode];
		hubinfo = (hubinfo_t)npda->pdinfo;
80
		hubinfo->h_nasid = cnodeid_to_nasid(cnode);
81 82 83 84
		hubinfo->h_widgetid = hub_widget_id(hubinfo->h_nasid);
	}
}

Jesse Barnes's avatar
Jesse Barnes committed
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
void
update_node_information(cnodeid_t cnodeid)
{
	nodepda_t *npda = NODEPDA(cnodeid);
	nodepda_router_info_t *npda_rip;
	
	/* Go through the list of router info 
	 * structures and copy some frequently
	 * accessed info from the info hanging
	 * off the corresponding router vertices
	 */
	npda_rip = npda->npda_rip_first;
	while(npda_rip) {
		if (npda_rip->router_infop) {
			npda_rip->router_portmask = 
				npda_rip->router_infop->ri_portmask;
			npda_rip->router_slot = 
				npda_rip->router_infop->ri_slotnum;
		} else {
			/* No router, no ports. */
			npda_rip->router_portmask = 0;
		}
		npda_rip = npda_rip->router_next;
	}
}