- 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
- Location:
- boot
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/arch/ppc64/Makefile.inc
r0258e67 r965dc18 27 27 # 28 28 29 DEFS += -DOPEN_BOOT 30 29 31 build: $(BASE)/image.boot 30 32 … … 36 38 37 39 arch/$(ARCH)/loader/image.boot: 38 make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR) 40 make -C arch/$(ARCH)/loader COMPILER=$(COMPILER) KERNELDIR=../../../$(KERNELDIR) USPACEDIR=../../../$(USPACEDIR) "DEFS=$(DEFS)" 39 41 40 42 clean: generic_clean -
boot/arch/sparc64/Makefile.inc
r0258e67 r965dc18 29 29 TMP = distroot 30 30 31 ifeq ($(CONFIG_AOUT_ISOFS_B),n) 32 SILO_PACKAGE=silo.patched.tar.gz 33 endif 34 35 ifeq ($(CONFIG_AOUT_ISOFS_B),y) 36 SILO_PACKAGE=silo.tar.gz 37 endif 38 31 39 build: $(BASE)/image.iso 32 40 … … 40 48 mkdir -p $(TMP)/boot 41 49 mkdir -p $(TMP)/HelenOS 42 cat arch/$(ARCH)/silo/ silo.tar.gz| (cd $(TMP)/boot; tar xvfz -)50 cat arch/$(ARCH)/silo/$(SILO_PACKAGE) | (cd $(TMP)/boot; tar xvfz -) 43 51 cp arch/$(ARCH)/silo/README arch/$(ARCH)/silo/COPYING $(TMP)/boot 44 52 cat arch/$(ARCH)/silo/silo.conf | $(SILO_CONF_FILTER) >$(TMP)/boot/silo.conf -
boot/arch/sparc64/loader/asm.S
r0258e67 r965dc18 106 106 * 2. Invalidate I-cache. 107 107 * 3. Flush instruction pipeline. 108 */ 109 call icache_flush 110 membar #StoreStore 108 */ 109 110 /* 111 * US3 processors have a write-invalidate cache, so explicitly 112 * invalidating it is not required. Whether to invalidate I-cache 113 * or not is decided according to the value of the global 114 * "subarchitecture" variable (set in the bootstrap). 115 */ 116 set subarchitecture, %g2 117 ldub [%g2], %g2 118 cmp %g2, 3 119 be 1f 120 nop 121 0: 122 call icache_flush 123 nop 124 1: 125 membar #StoreStore 126 127 /* 128 * Flush the instruction pipeline. 129 */ 111 130 flush %i7 112 131 … … 135 154 ! SF Erratum #51 136 155 nop 137 138 156 .global ofw 139 157 ofw: -
boot/arch/sparc64/loader/main.c
r0258e67 r965dc18 40 40 41 41 bootinfo_t bootinfo; 42 42 43 component_t components[COMPONENTS]; 43 44 … … 55 56 char *timestamp = ""; 56 57 #endif 58 59 /** UltraSPARC subarchitecture - 1 for US, 3 for US3 */ 60 uint8_t subarchitecture; 61 62 /** 63 * mask of the MID field inside the ICBUS_CONFIG register shifted by 64 * MID_SHIFT bits to the right 65 */ 66 uint16_t mid_mask; 57 67 58 68 /** Print version information. */ … … 64 74 } 65 75 76 /* the lowest ID (read from the VER register) of some US3 CPU model */ 77 #define FIRST_US3_CPU 0x14 78 79 /* the greatest ID (read from the VER register) of some US3 CPU model */ 80 #define LAST_US3_CPU 0x19 81 82 /* UltraSPARC IIIi processor implementation code */ 83 #define US_IIIi_CODE 0x15 84 85 /** 86 * Sets the global variables "subarchitecture" and "mid_mask" to 87 * correct values. 88 */ 89 static void detect_subarchitecture(void) 90 { 91 uint64_t v; 92 asm volatile ("rdpr %%ver, %0\n" : "=r" (v)); 93 94 v = (v << 16) >> 48; 95 if ((v >= FIRST_US3_CPU) && (v <= LAST_US3_CPU)) { 96 subarchitecture = SUBARCH_US3; 97 if (v == US_IIIi_CODE) 98 mid_mask = (1 << 5) - 1; 99 else 100 mid_mask = (1 << 10) - 1; 101 } else if (v < FIRST_US3_CPU) { 102 subarchitecture = SUBARCH_US; 103 mid_mask = (1 << 5) - 1; 104 } else { 105 printf("\nThis CPU is not supported by HelenOS."); 106 } 107 } 108 66 109 void bootstrap(void) 67 110 { … … 73 116 version_print(); 74 117 118 detect_subarchitecture(); 75 119 init_components(components); 76 120 … … 84 128 halt(); 85 129 } 86 130 87 131 if (bootinfo.memmap.total == 0) { 88 132 printf("Error: no memory detected, halting.\n"); -
boot/arch/sparc64/loader/main.h
r0258e67 r965dc18 42 42 #define AP_PROCESSOR 0 43 43 44 #define SUBARCH_US 1 45 #define SUBARCH_US3 3 46 44 47 typedef struct { 45 48 void *addr; -
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) -
boot/arch/sparc64/loader/register.h
r0258e67 r965dc18 34 34 #define PSTATE_AM_BIT 8 35 35 36 #define ASI_UPA_CONFIG 0x4a 37 #define UPA_CONFIG_MID_SHIFT 17 38 #define UPA_CONFIG_MID_MASK 0x1f 36 #define ASI_ICBUS_CONFIG 0x4a 37 #define ICBUS_CONFIG_MID_SHIFT 17 39 38 40 39 #endif -
boot/boot.config
r0258e67 r965dc18 84 84 ! RDFMT (choice) 85 85 86 # Preserve A.OUT header in isofs.b 87 ! [ARCH=sparc64] CONFIG_AOUT_ISOFS_B (y/n) 88 86 89 # External ramdisk 87 90 ! [ARCH=sparc64] CONFIG_RD_EXTERNAL (y/n) -
boot/genarch/balloc.h
r0258e67 r965dc18 32 32 #include <types.h> 33 33 34 #define BALLOC_MAX_SIZE (1 024* 1024)34 #define BALLOC_MAX_SIZE (128 * 1024) 35 35 36 36 typedef struct { -
boot/genarch/ofw.c
r0258e67 r965dc18 49 49 halt(); 50 50 51 if (ofw_get_property(ofw_chosen, "stdout", &ofw_stdout, sizeof(ofw_stdout)) <= 0) 51 if (ofw_get_property(ofw_chosen, "stdout", &ofw_stdout, 52 sizeof(ofw_stdout)) <= 0) 52 53 ofw_stdout = 0; 53 54 … … 58 59 } 59 60 60 if (ofw_get_property(ofw_chosen, "mmu", &ofw_mmu, sizeof(ofw_mmu)) <= 0) { 61 if (ofw_get_property(ofw_chosen, "mmu", &ofw_mmu, 62 sizeof(ofw_mmu)) <= 0) { 61 63 puts("\r\nError: Unable to get mmu property, halted.\r\n"); 62 64 halt(); 63 65 } 64 if (ofw_get_property(ofw_chosen, "memory", &ofw_memory_prop, sizeof(ofw_memory_prop)) <= 0) { 66 if (ofw_get_property(ofw_chosen, "memory", &ofw_memory_prop, 67 sizeof(ofw_memory_prop)) <= 0) { 65 68 puts("\r\nError: Unable to get memory property, halted.\r\n"); 66 69 halt(); … … 82 85 /** Perform a call to OpenFirmware client interface. 83 86 * 84 * @param service String identifying the service requested. 85 * @param nargs Number of input arguments. 86 * @param nret Number of output arguments. This includes the return value. 87 * @param rets Buffer for output arguments or NULL. The buffer must accommodate nret - 1 items. 88 * 89 * @return Return value returned by the client interface. 87 * @param service String identifying the service requested. 88 * @param nargs Number of input arguments. 89 * @param nret Number of output arguments. This includes the return 90 * value. 91 * @param rets Buffer for output arguments or NULL. The buffer must 92 * accommodate nret - 1 items. 93 * 94 * @return Return value returned by the client interface. 90 95 */ 91 unsigned long ofw_call(const char *service, const int nargs, const int nret, ofw_arg_t *rets, ...) 96 unsigned long 97 ofw_call(const char *service, const int nargs, const int nret, ofw_arg_t *rets, 98 ...) 92 99 { 93 100 va_list list; … … 120 127 } 121 128 122 int ofw_get_property(const phandle device, const char *name, void *buf, const int buflen) 129 int 130 ofw_get_property(const phandle device, const char *name, void *buf, 131 const int buflen) 123 132 { 124 133 return ofw_call("getprop", 4, 1, NULL, device, name, buf, buflen); … … 145 154 146 155 if (ofw_get_property(device, "#address-cells", &ret, sizeof(ret)) <= 0) 147 if (ofw_get_property(ofw_root, "#address-cells", &ret, sizeof(ret)) <= 0) 156 if (ofw_get_property(ofw_root, "#address-cells", &ret, 157 sizeof(ret)) <= 0) 148 158 ret = OFW_ADDRESS_CELLS; 149 159 … … 157 167 158 168 if (ofw_get_property(device, "#size-cells", &ret, sizeof(ret)) <= 0) 159 if (ofw_get_property(ofw_root, "#size-cells", &ret, sizeof(ret)) <= 0) 169 if (ofw_get_property(ofw_root, "#size-cells", &ret, 170 sizeof(ret)) <= 0) 160 171 ret = OFW_SIZE_CELLS; 161 172 … … 193 204 int shift; 194 205 195 if (ofw_call("call-method", 3, 5, result, "translate", ofw_mmu, virt) != 0) { 206 if (ofw_call("call-method", 3, 5, result, "translate", ofw_mmu, 207 virt) != 0) { 196 208 puts("Error: MMU method translate() failed, halting.\n"); 197 209 halt(); … … 213 225 ofw_arg_t retaddr; 214 226 215 if (ofw_call("call-method", 5, 2, &retaddr, "claim", ofw_mmu, 0, len, virt) != 0) { 227 if (ofw_call("call-method", 5, 2, &retaddr, "claim", ofw_mmu, 0, len, 228 virt) != 0) { 216 229 puts("Error: MMU method claim() failed, halting.\n"); 217 230 halt(); … … 270 283 } 271 284 272 return ofw_call("call-method", 7, 1, NULL, "map", ofw_mmu, mode, size, virt,273 phys_hi, phys_lo);285 return ofw_call("call-method", 7, 1, NULL, "map", ofw_mmu, mode, size, 286 virt, phys_hi, phys_lo); 274 287 } 275 288 … … 282 295 int ofw_memmap(memmap_t *map) 283 296 { 284 unsigned int ac = ofw_get_address_cells(ofw_memory); 285 unsigned int sc = ofw_get_size_cells(ofw_memory); 286 287 uint32_t buf[((ac + sc) * MEMMAP_MAX_RECORDS)]; 297 unsigned int ac = ofw_get_address_cells(ofw_memory) / 298 (sizeof(uintptr_t) / sizeof(uint32_t)); 299 unsigned int sc = ofw_get_size_cells(ofw_memory) / 300 (sizeof(uintptr_t) / sizeof(uint32_t)); 301 printf("address cells: %d, size cells: %d. ", ac, sc); 302 303 uintptr_t buf[((ac + sc) * MEMMAP_MAX_RECORDS)]; 288 304 int ret = ofw_get_property(ofw_memory, "reg", buf, sizeof(buf)); 289 305 if (ret <= 0) /* ret is the number of written bytes */ … … 293 309 map->total = 0; 294 310 map->count = 0; 295 for (pos = 0; (pos < ret / sizeof(uint 32_t)) &&311 for (pos = 0; (pos < ret / sizeof(uintptr_t)) && 296 312 (map->count < MEMMAP_MAX_RECORDS); pos += ac + sc) { 297 void * start = (void *) ((uintptr_t)buf[pos + ac - 1]);313 void *start = (void *) (buf[pos + ac - 1]); 298 314 unsigned int size = buf[pos + ac + sc - 1]; 299 315 316 /* 317 * This is a hot fix of the issue which occurs on machines 318 * where there are holes in the physical memory (such as 319 * SunBlade 1500). Should we detect a hole in the physical 320 * memory, we will ignore any memory detected behind 321 * the hole and pretend the hole does not exist. 322 */ 323 if ((map->count > 0) && (map->zones[map->count - 1].start + 324 map->zones[map->count - 1].size < start)) 325 break; 326 300 327 if (size > 0) { 301 328 map->zones[map->count].start = start; … … 309 336 } 310 337 311 312 338 int ofw_screen(screen_t *screen) 313 339 { … … 315 341 uint32_t virtaddr; 316 342 317 if (ofw_get_property(ofw_aliases, "screen", device_name, sizeof(device_name)) <= 0) 343 if (ofw_get_property(ofw_aliases, "screen", device_name, 344 sizeof(device_name)) <= 0) 318 345 return false; 319 346 … … 322 349 return false; 323 350 324 if (ofw_get_property(device, "address", &virtaddr, sizeof(virtaddr)) <= 0) 351 if (ofw_get_property(device, "address", &virtaddr, 352 sizeof(virtaddr)) <= 0) 325 353 return false; 326 354 327 355 screen->addr = (void *) ((uintptr_t) virtaddr); 328 356 329 if (ofw_get_property(device, "width", &screen->width, sizeof(screen->width)) <= 0) 330 return false; 331 332 if (ofw_get_property(device, "height", &screen->height, sizeof(screen->height)) <= 0) 333 return false; 334 335 if (ofw_get_property(device, "depth", &screen->bpp, sizeof(screen->bpp)) <= 0) 336 return false; 337 338 if (ofw_get_property(device, "linebytes", &screen->scanline, sizeof(screen->scanline)) <= 0) 357 if (ofw_get_property(device, "width", &screen->width, 358 sizeof(screen->width)) <= 0) 359 return false; 360 361 if (ofw_get_property(device, "height", &screen->height, 362 sizeof(screen->height)) <= 0) 363 return false; 364 365 if (ofw_get_property(device, "depth", &screen->bpp, 366 sizeof(screen->bpp)) <= 0) 367 return false; 368 369 if (ofw_get_property(device, "linebytes", &screen->scanline, 370 sizeof(screen->scanline)) <= 0) 339 371 return false; 340 372 -
boot/genarch/ofw_tree.c
r0258e67 r965dc18 121 121 memcpy(current_node->da_name, &path[i], len); 122 122 current_node->da_name[len] = '\0'; 123 124 123 125 124 /* … … 220 219 { 221 220 ofw_tree_node_t *root; 221 phandle ssm_node; 222 ofw_tree_node_t *ssm; 222 223 223 224 root = ofw_tree_node_alloc(); 224 225 if (root) 225 226 ofw_tree_node_process(root, NULL, ofw_root); 227 228 /* 229 * The firmware client interface does not automatically include the 230 * "ssm" node in the list of children of "/". A nasty yet working 231 * solution is to explicitly stick "ssm" to the OFW tree. 232 */ 233 ssm_node = ofw_find_device("/ssm@0,0"); 234 if (ssm_node != -1) { 235 ssm = ofw_tree_node_alloc(); 236 if (ssm) { 237 ofw_tree_node_process( 238 ssm, root, ofw_find_device("/ssm@0,0")); 239 ssm->peer = root->child; 240 root->child = ssm; 241 } 242 } 226 243 227 244 return root;
Note:
See TracChangeset
for help on using the changeset viewer.