Changeset 4872160 in mainline for boot/arch/sparc64/src/ofw.c
- Timestamp:
- 2010-05-04T10:44:55Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 568db0f
- Parents:
- bb252ca
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
boot/arch/sparc64/src/ofw.c
rbb252ca r4872160 33 33 */ 34 34 35 #include <ofwarch.h> 36 #include <ofw.h> 35 #include <arch/arch.h> 36 #include <arch/ofw.h> 37 #include <genarch/ofw.h> 38 #include <typedefs.h> 37 39 #include <printf.h> 38 #include <string.h> 39 #include <register.h> 40 #include "main.h" 41 #include "asm.h" 40 #include <halt.h> 41 #include <putchar.h> 42 #include <str.h> 42 43 43 void write(const char *str, const int len)44 void putchar(const wchar_t ch) 44 45 { 45 int i; 46 if (ch == '\n') 47 ofw_putchar('\r'); 46 48 47 for (i = 0; i < len; i++) { 48 if (str[i] == '\n') 49 ofw_write("\r", 1); 50 ofw_write(&str[i], 1); 51 } 49 if (ascii_check(ch)) 50 ofw_putchar(ch); 51 else 52 ofw_putchar(U_SPECIAL); 52 53 } 53 54 54 int ofw_translate_failed(ofw_arg_t flag) 55 { 56 return flag != -1; 57 } 58 59 /** 60 * Starts all CPUs represented by following siblings of the given node, 61 * except for the current CPU. 55 /** Start all CPUs represented by following siblings of the given node. 56 * 57 * Except for the current CPU. 62 58 * 63 59 * @param child The first child of the OFW tree node whose children … … 71 67 * 72 68 */ 73 static int wake_cpus_in_node(phandle child, uint64_t current_mid,69 static size_t wake_cpus_in_node(phandle child, uint64_t current_mid, 74 70 uintptr_t physmem_start) 75 71 { 76 int cpus;72 size_t cpus; 77 73 78 for (cpus = 0; (child != 0) && (child != -1);74 for (cpus = 0; (child != 0) && (child != (phandle) -1); 79 75 child = ofw_get_peer_node(child), cpus++) { 80 76 char type_name[OFW_TREE_PROPERTY_MAX_VALUELEN]; … … 83 79 OFW_TREE_PROPERTY_MAX_VALUELEN) > 0) { 84 80 type_name[OFW_TREE_PROPERTY_MAX_VALUELEN - 1] = 0; 85 if (strcmp(type_name, "cpu") == 0) { 81 82 if (str_cmp(type_name, "cpu") == 0) { 86 83 uint32_t mid; 87 84 … … 100 97 */ 101 98 (void) ofw_call("SUNW,start-cpu", 3, 1, 102 NULL, child, KERNEL_ VIRTUAL_ADDRESS,99 NULL, child, KERNEL_ADDRESS, 103 100 physmem_start | AP_PROCESSOR); 104 101 } … … 110 107 } 111 108 112 /** 113 * Finds out the current CPU's MID and wakes up all AP processors.109 /** Find out the current CPU's MID and wake up all AP processors. 110 * 114 111 */ 115 intofw_cpu(uint16_t mid_mask, uintptr_t physmem_start)112 void ofw_cpu(uint16_t mid_mask, uintptr_t physmem_start) 116 113 { 117 114 /* Get the current CPU MID */ … … 119 116 120 117 asm volatile ( 121 "ldxa [%1] %2, %0\n" 122 : "=r" (current_mid) 123 : "r" (0), "i" (ASI_ICBUS_CONFIG) 118 "ldxa [%[zero]] %[asi], %[current_mid]\n" 119 : [current_mid] "=r" (current_mid) 120 : [zero] "r" (0), 121 [asi] "i" (ASI_ICBUS_CONFIG) 124 122 ); 125 123 … … 130 128 131 129 phandle cpus_parent = ofw_find_device("/ssm@0,0"); 132 if ((cpus_parent == 0) || (cpus_parent == -1))130 if ((cpus_parent == 0) || (cpus_parent == (phandle) -1)) 133 131 cpus_parent = ofw_find_device("/"); 134 132 135 133 phandle node = ofw_get_child_node(cpus_parent); 136 int cpus = wake_cpus_in_node(node, current_mid, physmem_start); 137 while ((node != 0) && (node != -1)) { 134 size_t cpus = wake_cpus_in_node(node, current_mid, physmem_start); 135 136 while ((node != 0) && (node != (phandle) -1)) { 138 137 char name[OFW_TREE_PROPERTY_MAX_VALUELEN]; 139 138 … … 141 140 OFW_TREE_PROPERTY_MAX_VALUELEN) > 0) { 142 141 name[OFW_TREE_PROPERTY_MAX_VALUELEN - 1] = 0; 143 if (strcmp(name, "cmp") == 0) { 142 143 if (str_cmp(name, "cmp") == 0) { 144 144 phandle subnode = ofw_get_child_node(node); 145 145 cpus += wake_cpus_in_node(subnode, 146 146 current_mid, physmem_start); 147 147 } 148 148 } 149 149 150 node = ofw_get_peer_node(node); 150 151 } 151 152 152 return cpus; 153 if (cpus == 0) 154 printf("Warning: Unable to get CPU properties.\n"); 153 155 } 154 156 155 157 /** Get physical memory starting address. 156 158 * 157 * @param start Pointer to variable where the physical memory starting 158 * address will be stored. 159 * 160 * @return Non-zero on succes, zero on failure. 159 * @return Physical memory starting address. 161 160 * 162 161 */ 163 int ofw_get_physmem_start(uintptr_t *start)162 uintptr_t ofw_get_physmem_start(void) 164 163 { 165 164 uint32_t memreg[4]; 166 if (ofw_get_property(ofw_memory, "reg", &memreg, sizeof(memreg)) <= 0) 167 return 0; 165 if ((ofw_ret_t) ofw_get_property(ofw_memory, "reg", &memreg, 166 sizeof(memreg)) <= 0) { 167 printf("Error: Unable to get physical memory starting address, halting.\n"); 168 halt(); 169 } 168 170 169 *start = (((uint64_t) memreg[0]) << 32) | memreg[1]; 170 return 1; 171 return ((((uintptr_t) memreg[0]) << 32) | memreg[1]); 171 172 }
Note:
See TracChangeset
for help on using the changeset viewer.