Changeset b50b5af2 in mainline for boot/arch/sparc64/loader/ofwarch.c
- Timestamp:
- 2009-08-22T10:48:00Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 04803bf
- Parents:
- 1ea99cc (diff), a71c158 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/arch/sparc64/loader/ofwarch.c
r1ea99cc rb50b5af2 30 30 /** 31 31 * @file 32 * @brief 32 * @brief Architecture dependent parts of OpenFirmware interface. 33 33 */ 34 34 … … 40 40 #include "main.h" 41 41 #include "asm.h" 42 43 /* these tho variables will be set by the detect_subarchitecture function */44 extern uint8_t subarchitecture;45 extern uint16_t mid_mask;46 42 47 43 void write(const char *str, const int len) … … 65 61 * except for the current CPU. 66 62 * 67 * @param child The first child of the OFW tree node whose children 68 * represent CPUs to be woken up. 69 * @param current_mid MID of the current CPU, the current CPU will 70 * (of course) not be woken up. 71 * @return Number of CPUs which have the same parent node as 72 * "child". 63 * @param child The first child of the OFW tree node whose children 64 * represent CPUs to be woken up. 65 * @param current_mid MID of the current CPU, the current CPU will 66 * (of course) not be woken up. 67 * @param physmem_start Starting address of the physical memory. 68 * 69 * @return Number of CPUs which have the same parent node as 70 * "child". 71 * 73 72 */ 74 static int wake_cpus_in_node(phandle child, uint64_t current_mid) 73 static int wake_cpus_in_node(phandle child, uint64_t current_mid, 74 uintptr_t physmem_start) 75 75 { 76 76 int cpus; 77 char type_name[BUF_SIZE];78 77 79 for (cpus = 0; child != 0 && child != -1;78 for (cpus = 0; (child != 0) && (child != -1); 80 79 child = ofw_get_peer_node(child), cpus++) { 80 char type_name[BUF_SIZE]; 81 81 82 if (ofw_get_property(child, "device_type", type_name, 82 83 sizeof(type_name)) > 0) { … … 88 89 * "cpuid" for US-IV 89 90 */ 90 if (ofw_get_property( 91 child, "upa-portid", 92 &mid, sizeof(mid)) <= 0 93 && ofw_get_property(child, "portid", 94 &mid, sizeof(mid)) <= 0 95 && ofw_get_property(child, "cpuid", 96 &mid, sizeof(mid)) <= 0) 91 if ((ofw_get_property(child, "upa-portid", &mid, sizeof(mid)) <= 0) 92 && (ofw_get_property(child, "portid", &mid, sizeof(mid)) <= 0) 93 && (ofw_get_property(child, "cpuid", &mid, sizeof(mid)) <= 0)) 97 94 continue; 98 95 99 96 if (current_mid != mid) { 100 97 /* … … 103 100 (void) ofw_call("SUNW,start-cpu", 3, 1, 104 101 NULL, child, KERNEL_VIRTUAL_ADDRESS, 105 bootinfo.physmem_start | 106 AP_PROCESSOR); 102 physmem_start | AP_PROCESSOR); 107 103 } 108 104 } 109 105 } 110 106 } 111 107 112 108 return cpus; 113 109 } … … 116 112 * Finds out the current CPU's MID and wakes up all AP processors. 117 113 */ 118 int ofw_cpu( void)114 int ofw_cpu(uint16_t mid_mask, uintptr_t physmem_start) 119 115 { 120 int cpus; 121 phandle node; 122 phandle subnode; 123 phandle cpus_parent; 124 phandle cmp; 125 char name[BUF_SIZE]; 126 127 /* get the current CPU MID */ 116 /* Get the current CPU MID */ 128 117 uint64_t current_mid; 129 118 130 asm volatile ("ldxa [%1] %2, %0\n" 131 : "=r" (current_mid) 132 : "r" (0), "i" (ASI_ICBUS_CONFIG)); 119 asm volatile ( 120 "ldxa [%1] %2, %0\n" 121 : "=r" (current_mid) 122 : "r" (0), "i" (ASI_ICBUS_CONFIG) 123 ); 124 133 125 current_mid >>= ICBUS_CONFIG_MID_SHIFT; 134 135 126 current_mid &= mid_mask; 136 137 /* wake up CPUs */138 127 139 cpus_parent = ofw_find_device("/ssm@0,0"); 140 if (cpus_parent == 0 || cpus_parent == -1) { 128 /* Wake up the CPUs */ 129 130 phandle cpus_parent = ofw_find_device("/ssm@0,0"); 131 if ((cpus_parent == 0) || (cpus_parent == -1)) 141 132 cpus_parent = ofw_find_device("/"); 142 } 143 144 node = ofw_get_child_node(cpus_parent); 145 cpus = wake_cpus_in_node(node, current_mid); 146 while (node != 0 && node != -1) { 133 134 phandle node = ofw_get_child_node(cpus_parent); 135 int cpus = wake_cpus_in_node(node, current_mid, physmem_start); 136 while ((node != 0) && (node != -1)) { 137 char name[BUF_SIZE]; 138 147 139 if (ofw_get_property(node, "name", name, 148 140 sizeof(name)) > 0) { 149 141 if (strcmp(name, "cmp") == 0) { 150 subnode = ofw_get_child_node(node);142 phandle subnode = ofw_get_child_node(node); 151 143 cpus += wake_cpus_in_node(subnode, 152 current_mid );144 current_mid, physmem_start); 153 145 } 154 146 } … … 157 149 158 150 return cpus; 159 160 151 } 161 152 162 153 /** Get physical memory starting address. 163 154 * 164 * @param start 165 * 155 * @param start Pointer to variable where the physical memory starting 156 * address will be stored. 166 157 * 167 * @return Non-zero on succes, zero on failure. 158 * @return Non-zero on succes, zero on failure. 159 * 168 160 */ 169 161 int ofw_get_physmem_start(uintptr_t *start) 170 162 { 171 163 uint32_t memreg[4]; 172 173 164 if (ofw_get_property(ofw_memory, "reg", &memreg, sizeof(memreg)) <= 0) 174 165 return 0; 175 166 176 167 *start = (((uint64_t) memreg[0]) << 32) | memreg[1]; 177 168 return 1; 178 169 } 179
Note:
See TracChangeset
for help on using the changeset viewer.