import of upstream 2.4.34.4 from kernel.org
[linux-2.4.git] / arch / ia64 / sn / fakeprom / 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-2003 Silicon Graphics, Inc.  All rights reserved.
8  */
9
10
11
12 #include <linux/config.h>
13 #include <linux/types.h>
14 #include <asm/bitops.h>
15 #include <asm/sn/simulator.h>
16 #include "fpmem.h"
17
18 extern void klgraph_init(void);
19 void sys_fw_init (const char *args, int arglen);
20
21 int
22 fmain(int lid, int bsp) {
23         int     nasid, cpu, mynasid, mycpu, bootmaster;
24
25         /*
26          * * Pass the parameter base address to the build_efi_xxx routines.
27          */
28 #if defined(SGI_SN2)
29         build_init(0x3000000000UL | ((long)base_nasid<<38));
30 #endif
31
32         /*
33          * First lets figure out who we are. This is done from the
34          * LID passed to us.
35          */
36         mynasid = (lid>>16)&0xfff;
37         mycpu = (lid>>28)&3;
38
39         /*
40          * Determine if THIS cpu is the bootmaster. The <bsp> parameter
41          * is the logical cpu of the bootmaster. Cpus are numbered
42          * low-to-high nasid/lid.
43          */
44         GetLogicalCpu(bsp, &nasid, &cpu);
45         bootmaster = (mynasid == nasid) && (mycpu == cpu);
46         
47         /*
48          * Initialize SAL & EFI tables.
49          *   Note: non-bootmaster cpus will return to the slave loop 
50          *   in fpromasm.S. They spin there until they receive an
51          *   external interrupt from the master cpu.
52          */
53         if (bootmaster) {
54 #if 0
55                 /*
56                  * Undef if you need fprom to generate a 1 node klgraph
57                  * information .. only works for 1 node for nasid 0.
58                  */
59                 klgraph_init();
60 #endif
61                 sys_fw_init(0, 0);
62         }
63
64         return (bootmaster);
65 }
66
67
68
69 /* Why isnt there a bcopy/memcpy in lib64.a */
70
71 void* 
72 memcpy(void * dest, const void *src, size_t count)
73 {
74         char *s, *se, *d;
75
76         for(d=dest, s=(char*)src, se=s+count; s<se; s++, d++)
77                 *d = *s;
78         return dest;
79 }