patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / arch / ia64 / sn / io / sn2 / ml_SN_init.c
1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License.  See the file "COPYING" in the main directory of this archive
4  * for more details.
5  *
6  * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
7  */
8
9 #include <linux/types.h>
10 #include <linux/slab.h>
11 #include <linux/bootmem.h>
12 #include <asm/sn/sgi.h>
13 #include <asm/sn/io.h>
14 #include <asm/sn/hcl.h>
15 #include <asm/sn/labelcl.h>
16 #include <asm/sn/sn_private.h>
17 #include <asm/sn/klconfig.h>
18 #include <asm/sn/sn_cpuid.h>
19 #include <asm/sn/simulator.h>
20
21 int             maxcpus;
22
23 extern xwidgetnum_t hub_widget_id(nasid_t);
24
25 /* XXX - Move the meat of this to intr.c ? */
26 /*
27  * Set up the platform-dependent fields in the nodepda.
28  */
29 void init_platform_nodepda(nodepda_t *npda, cnodeid_t node)
30 {
31         hubinfo_t hubinfo;
32         nasid_t nasid;
33
34         /* Allocate per-node platform-dependent data */
35         
36         nasid = cnodeid_to_nasid(node);
37         if (node >= numnodes) /* Headless/memless IO nodes */
38                 hubinfo = (hubinfo_t)alloc_bootmem_node(NODE_DATA(0), sizeof(struct hubinfo_s));
39         else
40                 hubinfo = (hubinfo_t)alloc_bootmem_node(NODE_DATA(node), sizeof(struct hubinfo_s));
41
42         npda->pdinfo = (void *)hubinfo;
43         hubinfo->h_nodepda = npda;
44         hubinfo->h_cnodeid = node;
45
46         spin_lock_init(&hubinfo->h_crblock);
47
48         npda->xbow_peer = INVALID_NASID;
49
50         /* 
51          * Initialize the linked list of
52          * router info pointers to the dependent routers
53          */
54         npda->npda_rip_first = NULL;
55
56         /*
57          * npda_rip_last always points to the place
58          * where the next element is to be inserted
59          * into the list 
60          */
61         npda->npda_rip_last = &npda->npda_rip_first;
62         npda->geoid.any.type = GEO_TYPE_INVALID;
63
64         init_MUTEX_LOCKED(&npda->xbow_sema); /* init it locked? */
65 }
66
67 void
68 init_platform_hubinfo(nodepda_t **nodepdaindr)
69 {
70         cnodeid_t       cnode;
71         hubinfo_t hubinfo;
72         nodepda_t *npda;
73         extern int numionodes;
74
75         if (IS_RUNNING_ON_SIMULATOR())
76                 return;
77         for (cnode = 0; cnode < numionodes; cnode++) {
78                 npda = nodepdaindr[cnode];
79                 hubinfo = (hubinfo_t)npda->pdinfo;
80                 hubinfo->h_nasid = cnodeid_to_nasid(cnode);
81                 hubinfo->h_widgetid = hub_widget_id(hubinfo->h_nasid);
82         }
83 }
84
85 void
86 update_node_information(cnodeid_t cnodeid)
87 {
88         nodepda_t *npda = NODEPDA(cnodeid);
89         nodepda_router_info_t *npda_rip;
90         
91         /* Go through the list of router info 
92          * structures and copy some frequently
93          * accessed info from the info hanging
94          * off the corresponding router vertices
95          */
96         npda_rip = npda->npda_rip_first;
97         while(npda_rip) {
98                 if (npda_rip->router_infop) {
99                         npda_rip->router_portmask = 
100                                 npda_rip->router_infop->ri_portmask;
101                         npda_rip->router_slot = 
102                                 npda_rip->router_infop->ri_slotnum;
103                 } else {
104                         /* No router, no ports. */
105                         npda_rip->router_portmask = 0;
106                 }
107                 npda_rip = npda_rip->router_next;
108         }
109 }