ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[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         extern void router_map_init(nodepda_t *);
35         extern void router_queue_init(nodepda_t *,cnodeid_t);
36         extern void intr_init_vecblk(nodepda_t *, cnodeid_t, int);
37
38         /* Allocate per-node platform-dependent data */
39         
40         nasid = COMPACT_TO_NASID_NODEID(node);
41         if (node >= numnodes) /* Headless/memless IO nodes */
42                 hubinfo = (hubinfo_t)alloc_bootmem_node(NODE_DATA(0), sizeof(struct hubinfo_s));
43         else
44                 hubinfo = (hubinfo_t)alloc_bootmem_node(NODE_DATA(node), sizeof(struct hubinfo_s));
45
46         npda->pdinfo = (void *)hubinfo;
47         hubinfo->h_nodepda = npda;
48         hubinfo->h_cnodeid = node;
49
50         spin_lock_init(&hubinfo->h_crblock);
51
52         npda->xbow_peer = INVALID_NASID;
53
54         /* 
55          * Initialize the linked list of
56          * router info pointers to the dependent routers
57          */
58         npda->npda_rip_first = NULL;
59
60         /*
61          * npda_rip_last always points to the place
62          * where the next element is to be inserted
63          * into the list 
64          */
65         npda->npda_rip_last = &npda->npda_rip_first;
66         npda->geoid.any.type = GEO_TYPE_INVALID;
67
68         init_MUTEX_LOCKED(&npda->xbow_sema); /* init it locked? */
69 }
70
71 void
72 init_platform_hubinfo(nodepda_t **nodepdaindr)
73 {
74         cnodeid_t       cnode;
75         hubinfo_t hubinfo;
76         nodepda_t *npda;
77         extern int numionodes;
78
79         if (IS_RUNNING_ON_SIMULATOR())
80                 return;
81         for (cnode = 0; cnode < numionodes; cnode++) {
82                 npda = nodepdaindr[cnode];
83                 hubinfo = (hubinfo_t)npda->pdinfo;
84                 hubinfo->h_nasid = COMPACT_TO_NASID_NODEID(cnode);
85                 hubinfo->h_widgetid = hub_widget_id(hubinfo->h_nasid);
86         }
87 }
88
89 void
90 update_node_information(cnodeid_t cnodeid)
91 {
92         nodepda_t *npda = NODEPDA(cnodeid);
93         nodepda_router_info_t *npda_rip;
94         
95         /* Go through the list of router info 
96          * structures and copy some frequently
97          * accessed info from the info hanging
98          * off the corresponding router vertices
99          */
100         npda_rip = npda->npda_rip_first;
101         while(npda_rip) {
102                 if (npda_rip->router_infop) {
103                         npda_rip->router_portmask = 
104                                 npda_rip->router_infop->ri_portmask;
105                         npda_rip->router_slot = 
106                                 npda_rip->router_infop->ri_slotnum;
107                 } else {
108                         /* No router, no ports. */
109                         npda_rip->router_portmask = 0;
110                 }
111                 npda_rip = npda_rip->router_next;
112         }
113 }