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