1 // SPDX-License-Identifier: GPL-2.0 1 2 /* 3 * Ported from IRIX to Linux by Kanoj Sarcar, 4 * Copyright 2000 - 2001 Silicon Graphics, Inc 5 * Copyright 2000 - 2001 Kanoj Sarcar (kanoj@s 6 */ 7 #include <linux/init.h> 8 #include <linux/mm.h> 9 #include <linux/mmzone.h> 10 #include <linux/kernel.h> 11 #include <linux/nodemask.h> 12 #include <linux/string.h> 13 14 #include <asm/page.h> 15 #include <asm/sections.h> 16 #include <asm/sn/types.h> 17 #include <asm/sn/arch.h> 18 #include <asm/sn/gda.h> 19 #include <asm/sn/mapped_kernel.h> 20 21 #include "ip27-common.h" 22 23 static nodemask_t ktext_repmask; 24 25 /* 26 * XXX - This needs to be much smarter about w 27 * kernel. For example, we should never put a 28 * and we should respect the topology of the m 29 */ 30 void __init setup_replication_mask(void) 31 { 32 /* Set only the master cnode's bit. T 33 nodes_clear(ktext_repmask); 34 node_set(0, ktext_repmask); 35 36 #ifdef CONFIG_REPLICATE_KTEXT 37 #ifndef CONFIG_MAPPED_KERNEL 38 #error Kernel replication works with mapped ke 39 #endif 40 { 41 nasid_t nasid; 42 43 for_each_online_node(nasid) { 44 if (nasid == 0) 45 continue; 46 /* Advertise that we h 47 node_set(nasid, ktext_ 48 } 49 } 50 #endif 51 /* Set up a GDA pointer to the replica 52 GDA->g_ktext_repmask = &ktext_repmask; 53 } 54 55 56 static __init void set_ktext_source(nasid_t cl 57 { 58 kern_vars_t *kvp; 59 60 kvp = &hub_data(client_nasid)->kern_va 61 62 KERN_VARS_ADDR(client_nasid) = (unsign 63 64 kvp->kv_magic = KV_MAGIC; 65 kvp->kv_ro_nasid = server_nasid; 66 kvp->kv_rw_nasid = master_nasid; 67 kvp->kv_ro_baseaddr = NODE_CAC_BASE(se 68 kvp->kv_rw_baseaddr = NODE_CAC_BASE(ma 69 printk("REPLICATION: ON nasid %d, ktex 70 } 71 72 /* XXX - When the BTE works, we should use it 73 static __init void copy_kernel(nasid_t dest_na 74 { 75 unsigned long dest_kern_start, source_ 76 77 source_start = (unsigned long) _stext; 78 source_end = (unsigned long) _etext; 79 kern_size = source_end - source_start; 80 81 dest_kern_start = CHANGE_ADDR_NASID(MA 82 de 83 memcpy((void *)dest_kern_start, (void 84 } 85 86 void __init replicate_kernel_text(void) 87 { 88 nasid_t client_nasid; 89 nasid_t server_nasid; 90 91 server_nasid = master_nasid; 92 93 /* Record where the master node should 94 set_ktext_source(master_nasid, master_ 95 96 for_each_online_node(client_nasid) { 97 if (client_nasid == 0) 98 continue; 99 100 /* Check if this node should g 101 if (node_isset(client_nasid, k 102 server_nasid = client_ 103 copy_kernel(server_nas 104 } 105 106 /* Record where this node shou 107 set_ktext_source(client_nasid, 108 } 109 } 110 111 /* 112 * Return pfn of first free page of memory on 113 * data structures on the first couple of page 114 * node. If this is the case, getfirstfree(nod 115 */ 116 unsigned long node_getfirstfree(nasid_t nasid) 117 { 118 unsigned long loadbase = REP_BASE; 119 unsigned long offset; 120 121 #ifdef CONFIG_MAPPED_KERNEL 122 loadbase += 16777216; 123 #endif 124 offset = PAGE_ALIGN((unsigned long)(&_ 125 if ((nasid == 0) || (node_isset(nasid, 126 return TO_NODE(nasid, offset) 127 else 128 return KDM_TO_PHYS(PAGE_ALIGN( 129 } 130
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.