File: /usr/src/linux/arch/ia64/sn/fprom/main.c

1     /* 
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) 2000 Silicon Graphics, Inc.
8      * Copyright (C) 2000 by Jack Steiner (steiner@sgi.com)
9      */
10     
11     
12     
13     #include <linux/types.h>
14     #include <asm/bitops.h>
15     
16     void bedrock_init(int);
17     void synergy_init(int, int);
18     void sys_fw_init (const char *args, int arglen, int bsp);
19     
20     volatile int	bootmaster=0;		/* Used to pick bootmaster */
21     volatile int	nasidmaster[128]={0};	/* Used to pick node/synergy masters */
22     int		init_done=0;
23     extern int	bsp_lid;
24     
25     #define get_bit(b,p)	(((*p)>>(b))&1)
26     
27     int
28     fmain(int lid, int bsp) {
29     	int	syn, nasid, cpu;
30     
31     	/*
32     	 * First lets figure out who we are. This is done from the
33     	 * LID passed to us.
34     	 */
35     	nasid = (lid>>24);
36     	syn = (lid>>17)&1;
37     	cpu = (lid>>16)&1;
38     
39     	/*
40     	 * Now pick a synergy master to initialize synergy registers.
41     	 */
42     	if (test_and_set_bit(syn, &nasidmaster[nasid]) == 0) {
43     		synergy_init(nasid, syn);
44     		test_and_set_bit(syn+2, &nasidmaster[nasid]);
45     	} else
46     		while (get_bit(syn+2, &nasidmaster[nasid]) == 0);
47     	
48     	/*
49     	 * Now pick a nasid master to initialize Bedrock registers.
50     	 */
51     	if (test_and_set_bit(8, &nasidmaster[nasid]) == 0) {
52     		bedrock_init(nasid);
53     		test_and_set_bit(9, &nasidmaster[nasid]);
54     	} else
55     		while (get_bit(9, &nasidmaster[nasid]) == 0);
56     	
57     
58     	/*
59     	 * Now pick a BSP & finish init.
60     	 */
61     	if (test_and_set_bit(0, &bootmaster) == 0) {
62     		sys_fw_init(0, 0, bsp);
63     		test_and_set_bit(1, &bootmaster);
64     	} else
65     		while (get_bit(1, &bootmaster) == 0);
66     
67     	return (lid == bsp_lid);
68     }
69     
70     
71     void
72     bedrock_init(int nasid)
73     {
74     	nasid = nasid;		/* to quiet gcc */
75     }
76     
77     
78     void
79     synergy_init(int nasid, int syn)
80     {
81     	long	*base;
82     	long	off;
83     
84     	/*
85     	 * Enable all FSB flashed interrupts.
86     	 * ZZZ - I'd really like defines for this......
87     	 */
88     	base = (long*)0x80000e0000000000LL;		/* base of synergy regs */
89     	for (off = 0x2a0; off < 0x2e0; off+=8)		/* offset for VEC_MASK_{0-3}_A/B */
90     		*(base+off/8) = -1LL;
91     
92     	/*
93     	 * Set the NASID in the FSB_CONFIG register.
94     	 */
95     	base = (long*)0x80000e0000000450LL;
96     	*base = (long)((nasid<<16)|(syn<<9));
97     }
98     
99     
100     /* Why isnt there a bcopy/memcpy in lib64.a */
101     
102     void* 
103     memcpy(void * dest, const void *src, size_t count)
104     {
105     	char *s, *se, *d;
106     
107     	for(d=dest, s=(char*)src, se=s+count; s<se; s++, d++)
108     		*d = *s;
109     	return dest;
110     }
111