Changeset 965dc18 in mainline for boot/arch/sparc64/loader/ofwarch.c
- Timestamp:
- 2008-12-05T19:59:03Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 49093a4
- Parents:
- 0258e67
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/arch/sparc64/loader/ofwarch.c
r0258e67 r965dc18 41 41 #include "asm.h" 42 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 43 47 void write(const char *str, const int len) 44 48 { … … 57 61 } 58 62 59 int ofw_cpu(void) 63 /** 64 * Starts all CPUs represented by following siblings of the given node, 65 * except for the current CPU. 66 * 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". 73 */ 74 static int wake_cpus_in_node(phandle child, uint64_t current_mid) 60 75 { 76 int cpus; 61 77 char type_name[BUF_SIZE]; 62 63 phandle node;64 node = ofw_get_child_node(ofw_root);65 if (node == 0 || node == -1) {66 printf("Could not find any child nodes of the root node.\n");67 return 0;68 }69 78 70 uint64_t current_mid; 71 72 asm volatile ("ldxa [%1] %2, %0\n" 73 : "=r" (current_mid) 74 : "r" (0), "i" (ASI_UPA_CONFIG)); 75 current_mid >>= UPA_CONFIG_MID_SHIFT; 76 current_mid &= UPA_CONFIG_MID_MASK; 77 78 int cpus; 79 80 for (cpus = 0; node != 0 && node != -1; node = ofw_get_peer_node(node), 81 cpus++) { 82 if (ofw_get_property(node, "device_type", type_name, 79 for (cpus = 0; child != 0 && child != -1; 80 child = ofw_get_peer_node(child), cpus++) { 81 if (ofw_get_property(child, "device_type", type_name, 83 82 sizeof(type_name)) > 0) { 84 83 if (strcmp(type_name, "cpu") == 0) { 85 84 uint32_t mid; 86 85 87 if (ofw_get_property(node, "upa-portid", &mid, 88 sizeof(mid)) <= 0) 86 /* 87 * "upa-portid" for US, "portid" for US-III, 88 * "cpuid" for US-IV 89 */ 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) 89 97 continue; 90 98 … … 94 102 */ 95 103 (void) ofw_call("SUNW,start-cpu", 3, 1, 96 NULL, node, KERNEL_VIRTUAL_ADDRESS,104 NULL, child, KERNEL_VIRTUAL_ADDRESS, 97 105 bootinfo.physmem_start | 98 106 AP_PROCESSOR); … … 105 113 } 106 114 115 /** 116 * Finds out the current CPU's MID and wakes up all AP processors. 117 */ 118 int ofw_cpu(void) 119 { 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 */ 128 uint64_t current_mid; 129 130 asm volatile ("ldxa [%1] %2, %0\n" 131 : "=r" (current_mid) 132 : "r" (0), "i" (ASI_ICBUS_CONFIG)); 133 current_mid >>= ICBUS_CONFIG_MID_SHIFT; 134 135 current_mid &= mid_mask; 136 137 /* wake up CPUs */ 138 139 cpus_parent = ofw_find_device("/ssm@0,0"); 140 if (cpus_parent == 0 || cpus_parent == -1) { 141 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) { 147 if (ofw_get_property(node, "name", name, 148 sizeof(name)) > 0) { 149 if (strcmp(name, "cmp") == 0) { 150 subnode = ofw_get_child_node(node); 151 cpus += wake_cpus_in_node(subnode, 152 current_mid); 153 } 154 } 155 node = ofw_get_peer_node(node); 156 } 157 158 return cpus; 159 160 } 161 107 162 /** Get physical memory starting address. 108 163 * 109 * @param start 110 * 164 * @param start Pointer to variable where the physical memory starting 165 * address will be stored. 111 166 * 112 * @return 167 * @return Non-zero on succes, zero on failure. 113 168 */ 114 169 int ofw_get_physmem_start(uintptr_t *start)
Note:
See TracChangeset
for help on using the changeset viewer.