diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/mips/sgi-ip27/ip27-klnuma.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/mips/sgi-ip27/ip27-klnuma.c')
-rw-r--r-- | arch/mips/sgi-ip27/ip27-klnuma.c | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/arch/mips/sgi-ip27/ip27-klnuma.c b/arch/mips/sgi-ip27/ip27-klnuma.c new file mode 100644 index 000000000000..41c3f405e00c --- /dev/null +++ b/arch/mips/sgi-ip27/ip27-klnuma.c | |||
@@ -0,0 +1,135 @@ | |||
1 | /* | ||
2 | * Ported from IRIX to Linux by Kanoj Sarcar, 06/08/00. | ||
3 | * Copyright 2000 - 2001 Silicon Graphics, Inc. | ||
4 | * Copyright 2000 - 2001 Kanoj Sarcar (kanoj@sgi.com) | ||
5 | */ | ||
6 | #include <linux/config.h> | ||
7 | #include <linux/init.h> | ||
8 | #include <linux/mmzone.h> | ||
9 | #include <linux/kernel.h> | ||
10 | #include <linux/nodemask.h> | ||
11 | #include <linux/string.h> | ||
12 | |||
13 | #include <asm/page.h> | ||
14 | #include <asm/sections.h> | ||
15 | #include <asm/smp.h> | ||
16 | #include <asm/sn/types.h> | ||
17 | #include <asm/sn/arch.h> | ||
18 | #include <asm/sn/gda.h> | ||
19 | #include <asm/sn/hub.h> | ||
20 | #include <asm/sn/mapped_kernel.h> | ||
21 | #include <asm/sn/sn_private.h> | ||
22 | |||
23 | static cpumask_t ktext_repmask; | ||
24 | |||
25 | /* | ||
26 | * XXX - This needs to be much smarter about where it puts copies of the | ||
27 | * kernel. For example, we should never put a copy on a headless node, | ||
28 | * and we should respect the topology of the machine. | ||
29 | */ | ||
30 | void __init setup_replication_mask() | ||
31 | { | ||
32 | cnodeid_t cnode; | ||
33 | |||
34 | /* Set only the master cnode's bit. The master cnode is always 0. */ | ||
35 | cpus_clear(ktext_repmask); | ||
36 | cpu_set(0, ktext_repmask); | ||
37 | |||
38 | #ifdef CONFIG_REPLICATE_KTEXT | ||
39 | #ifndef CONFIG_MAPPED_KERNEL | ||
40 | #error Kernel replication works with mapped kernel support. No calias support. | ||
41 | #endif | ||
42 | for_each_online_node(cnode) { | ||
43 | if (cnode == 0) | ||
44 | continue; | ||
45 | /* Advertise that we have a copy of the kernel */ | ||
46 | cpu_set(cnode, ktext_repmask); | ||
47 | } | ||
48 | #endif | ||
49 | /* Set up a GDA pointer to the replication mask. */ | ||
50 | GDA->g_ktext_repmask = &ktext_repmask; | ||
51 | } | ||
52 | |||
53 | |||
54 | static __init void set_ktext_source(nasid_t client_nasid, nasid_t server_nasid) | ||
55 | { | ||
56 | cnodeid_t client_cnode; | ||
57 | kern_vars_t *kvp; | ||
58 | |||
59 | client_cnode = NASID_TO_COMPACT_NODEID(client_nasid); | ||
60 | |||
61 | kvp = &hub_data(client_nasid)->kern_vars; | ||
62 | |||
63 | KERN_VARS_ADDR(client_nasid) = (unsigned long)kvp; | ||
64 | |||
65 | kvp->kv_magic = KV_MAGIC; | ||
66 | kvp->kv_ro_nasid = server_nasid; | ||
67 | kvp->kv_rw_nasid = master_nasid; | ||
68 | kvp->kv_ro_baseaddr = NODE_CAC_BASE(server_nasid); | ||
69 | kvp->kv_rw_baseaddr = NODE_CAC_BASE(master_nasid); | ||
70 | printk("REPLICATION: ON nasid %d, ktext from nasid %d, kdata from nasid %d\n", client_nasid, server_nasid, master_nasid); | ||
71 | } | ||
72 | |||
73 | /* XXX - When the BTE works, we should use it instead of this. */ | ||
74 | static __init void copy_kernel(nasid_t dest_nasid) | ||
75 | { | ||
76 | unsigned long dest_kern_start, source_start, source_end, kern_size; | ||
77 | |||
78 | source_start = (unsigned long) _stext; | ||
79 | source_end = (unsigned long) _etext; | ||
80 | kern_size = source_end - source_start; | ||
81 | |||
82 | dest_kern_start = CHANGE_ADDR_NASID(MAPPED_KERN_RO_TO_K0(source_start), | ||
83 | dest_nasid); | ||
84 | memcpy((void *)dest_kern_start, (void *)source_start, kern_size); | ||
85 | } | ||
86 | |||
87 | void __init replicate_kernel_text() | ||
88 | { | ||
89 | cnodeid_t cnode; | ||
90 | nasid_t client_nasid; | ||
91 | nasid_t server_nasid; | ||
92 | |||
93 | server_nasid = master_nasid; | ||
94 | |||
95 | /* Record where the master node should get its kernel text */ | ||
96 | set_ktext_source(master_nasid, master_nasid); | ||
97 | |||
98 | for_each_online_node(cnode) { | ||
99 | if (cnode == 0) | ||
100 | continue; | ||
101 | client_nasid = COMPACT_TO_NASID_NODEID(cnode); | ||
102 | |||
103 | /* Check if this node should get a copy of the kernel */ | ||
104 | if (cpu_isset(cnode, ktext_repmask)) { | ||
105 | server_nasid = client_nasid; | ||
106 | copy_kernel(server_nasid); | ||
107 | } | ||
108 | |||
109 | /* Record where this node should get its kernel text */ | ||
110 | set_ktext_source(client_nasid, server_nasid); | ||
111 | } | ||
112 | } | ||
113 | |||
114 | /* | ||
115 | * Return pfn of first free page of memory on a node. PROM may allocate | ||
116 | * data structures on the first couple of pages of the first slot of each | ||
117 | * node. If this is the case, getfirstfree(node) > getslotstart(node, 0). | ||
118 | */ | ||
119 | pfn_t node_getfirstfree(cnodeid_t cnode) | ||
120 | { | ||
121 | unsigned long loadbase = REP_BASE; | ||
122 | nasid_t nasid = COMPACT_TO_NASID_NODEID(cnode); | ||
123 | unsigned long offset; | ||
124 | |||
125 | #ifdef CONFIG_MAPPED_KERNEL | ||
126 | loadbase += 16777216; | ||
127 | #endif | ||
128 | offset = PAGE_ALIGN((unsigned long)(&_end)) - loadbase; | ||
129 | if ((cnode == 0) || (cpu_isset(cnode, ktext_repmask))) | ||
130 | return (TO_NODE(nasid, offset) >> PAGE_SHIFT); | ||
131 | else | ||
132 | return (KDM_TO_PHYS(PAGE_ALIGN(SYMMON_STK_ADDR(nasid, 0))) >> | ||
133 | PAGE_SHIFT); | ||
134 | } | ||
135 | |||