import of upstream 2.4.34.4 from kernel.org
[linux-2.4.git] / arch / ia64 / sn / io / sgi_io_sim.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/config.h>
11 #include <linux/types.h>
12 #include <asm/sn/sgi.h>
13 #include <asm/sn/sn_sal.h>
14 #include <asm/sn/io.h>
15 #include <asm/sn/sn_cpuid.h>
16 #include <asm/sn/klconfig.h>
17 #include <asm/sn/module.h>
18 #include <asm/sn/sn_private.h>
19
20 cpuid_t         master_procid;
21 char arg_maxnodes[4];
22
23 /*
24  * Return non-zero if the given variable was specified
25  */
26 int
27 is_specified(char *s)
28 {
29         return (strlen(s) != 0);
30 }
31
32 /*
33  * Routines provided by ml/SN/promif.c.
34  */
35 static __psunsigned_t master_bridge_base;
36 nasid_t console_nasid = (nasid_t)-1;
37 char master_baseio_wid;
38 static char console_wid;
39 static char console_pcislot;
40
41 void
42 set_master_bridge_base(void)
43 {
44         console_wid = WIDGETID_GET(KL_CONFIG_CH_CONS_INFO(master_nasid)->memory_base);
45         console_pcislot = KL_CONFIG_CH_CONS_INFO(master_nasid)->npci;
46         master_bridge_base = (__psunsigned_t)NODE_SWIN_BASE(console_nasid, console_wid);
47         // FIXME("WARNING: set_master_bridge_base: NON NASID 0 DOES NOT WORK\n");
48 }
49
50 int
51 check_nasid_equiv(nasid_t nasida, nasid_t nasidb)
52 {
53         if ((nasida == nasidb) || (nasida == NODEPDA(NASID_TO_COMPACT_NODEID(nasidb))->xbow_peer))
54                 return 1;
55         else
56                 return 0;
57 }
58
59 int
60 is_master_baseio_nasid_widget(nasid_t test_nasid, xwidgetnum_t test_wid)
61 {
62         extern nasid_t master_baseio_nasid;
63
64         /*
65          * If the widget numbers are different, we're not the master.
66          */
67         if (test_wid != (xwidgetnum_t)master_baseio_wid) {
68                 return 0;
69         }
70
71         /*
72          * If the NASIDs are the same or equivalent, we're the master.
73          */
74         if (check_nasid_equiv(test_nasid, master_baseio_nasid)) {
75                 return 1;
76         } else {
77                 return 0;
78         }
79 }