Changeset b50b5af2 in mainline for boot/arch/sparc64/loader/main.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/main.c
r1ea99cc rb50b5af2 1 1 /* 2 2 * Copyright (c) 2005 Martin Decky 3 * Copyright (c) 2006 Jakub Jermar 3 * Copyright (c) 2006 Jakub Jermar 4 4 * All rights reserved. 5 5 * … … 28 28 */ 29 29 30 #include "main.h" 30 #include "main.h" 31 31 #include <printf.h> 32 32 #include "asm.h" … … 39 39 #include <macros.h> 40 40 #include <string.h> 41 42 bootinfo_t bootinfo; 43 44 component_t components[COMPONENTS]; 45 46 char *release = STRING(RELEASE); 41 #include <memstr.h> 42 43 static bootinfo_t bootinfo; 44 static component_t components[COMPONENTS]; 45 static char *release = STRING(RELEASE); 47 46 48 47 #ifdef REVISION 49 char *revision = ", revision " STRING(REVISION);48 static char *revision = ", revision " STRING(REVISION); 50 49 #else 51 char *revision = "";50 static char *revision = ""; 52 51 #endif 53 52 54 53 #ifdef TIMESTAMP 55 char *timestamp = "\nBuilt on " STRING(TIMESTAMP);54 static char *timestamp = "\nBuilt on " STRING(TIMESTAMP); 56 55 #else 57 char *timestamp = "";56 static char *timestamp = ""; 58 57 #endif 59 58 60 59 /** UltraSPARC subarchitecture - 1 for US, 3 for US3 */ 61 uint8_t subarchitecture;60 static uint8_t subarchitecture; 62 61 63 62 /** … … 65 64 * MID_SHIFT bits to the right 66 65 */ 67 uint16_t mid_mask;66 static uint16_t mid_mask; 68 67 69 68 /** Print version information. */ … … 76 75 77 76 /* the lowest ID (read from the VER register) of some US3 CPU model */ 78 #define FIRST_US3_CPU 77 #define FIRST_US3_CPU 0x14 79 78 80 79 /* the greatest ID (read from the VER register) of some US3 CPU model */ 81 #define LAST_US3_CPU 80 #define LAST_US3_CPU 0x19 82 81 83 82 /* UltraSPARC IIIi processor implementation code */ 84 #define US_IIIi_CODE 83 #define US_IIIi_CODE 0x15 85 84 86 85 /** … … 91 90 { 92 91 uint64_t v; 93 asm volatile ("rdpr %%ver, %0\n" : "=r" (v)); 92 asm volatile ( 93 "rdpr %%ver, %0\n" 94 : "=r" (v) 95 ); 94 96 95 97 v = (v << 16) >> 48; … … 103 105 subarchitecture = SUBARCH_US; 104 106 mid_mask = (1 << 5) - 1; 105 } else {107 } else 106 108 printf("\nThis CPU is not supported by HelenOS."); 107 }108 109 } 109 110 … … 113 114 void *balloc_base; 114 115 unsigned int top = 0; 115 int i, j; 116 116 unsigned int i; 117 unsigned int j; 118 117 119 version_print(); 118 120 119 121 detect_subarchitecture(); 120 122 init_components(components); 121 123 122 124 if (!ofw_get_physmem_start(&bootinfo.physmem_start)) { 123 125 printf("Error: unable to get start of physical memory.\n"); 124 126 halt(); 125 127 } 126 128 127 129 if (!ofw_memmap(&bootinfo.memmap)) { 128 130 printf("Error: unable to get memory map, halting.\n"); 129 131 halt(); 130 132 } 131 133 132 134 if (bootinfo.memmap.total == 0) { 133 135 printf("Error: no memory detected, halting.\n"); 134 136 halt(); 135 137 } 136 138 137 139 /* 138 140 * SILO for some reason adds 0x400000 and subtracts … … 143 145 silo_ramdisk_image += bootinfo.physmem_start; 144 146 silo_ramdisk_image -= 0x400000; 145 /* Install 1:1 mapping for the ramdisk. */ 146 if (ofw_map((void *)((uintptr_t) silo_ramdisk_image), 147 (void *)((uintptr_t) silo_ramdisk_image), 147 148 /* Install 1:1 mapping for the RAM disk. */ 149 if (ofw_map((void *) ((uintptr_t) silo_ramdisk_image), 150 (void *) ((uintptr_t) silo_ramdisk_image), 148 151 silo_ramdisk_size, -1) != 0) { 149 printf("Failed to map ramdisk.\n");152 printf("Failed to map RAM disk.\n"); 150 153 halt(); 151 154 } 152 155 } 153 156 154 printf("\nSystem info\n"); 155 printf(" memory: %dM starting at %P\n", 157 printf("\nMemory statistics (total %d MB, starting at %P)\n", 156 158 bootinfo.memmap.total >> 20, bootinfo.physmem_start); 157 158 printf("\nMemory statistics\n"); 159 printf(" kernel entry point at %P\n", KERNEL_VIRTUAL_ADDRESS); 159 printf(" %P: kernel entry point\n", KERNEL_VIRTUAL_ADDRESS); 160 160 printf(" %P: boot info structure\n", &bootinfo); 161 161 … … 176 176 break; 177 177 } 178 178 179 bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr = 179 180 base + top; … … 187 188 top += components[i].size; 188 189 } 189 190 j = bootinfo.taskmap.count - 1; /* do not consider ramdisk */ 191 190 191 /* Do not consider RAM disk */ 192 j = bootinfo.taskmap.count - 1; 193 192 194 if (silo_ramdisk_image) { 193 /* Treat the ramdisk as the last bootinfo task. */195 /* Treat the RAM disk as the last bootinfo task. */ 194 196 if (bootinfo.taskmap.count == TASKMAP_MAX_RECORDS) { 195 printf("Skipping ramdisk.\n");197 printf("Skipping RAM disk.\n"); 196 198 goto skip_ramdisk; 197 199 } 200 198 201 top = ALIGN_UP(top, PAGE_SIZE); 199 202 bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr = … … 202 205 silo_ramdisk_size; 203 206 bootinfo.taskmap.count++; 204 printf("\nCopying ramdisk..."); 207 printf("\nCopying RAM disk..."); 208 205 209 /* 206 210 * Claim and map the whole ramdisk as it may exceed the area … … 210 214 (void) ofw_map(bootinfo.physmem_start + base + top, base + top, 211 215 silo_ramdisk_size, -1); 212 /* 213 * FIXME If the source and destination overlap, it may be 214 * desirable to copy in reverse order, depending on how the two 215 * regions overlap. 216 */ 217 memcpy(base + top, (void *)((uintptr_t)silo_ramdisk_image), 216 memmove(base + top, (void *) ((uintptr_t) silo_ramdisk_image), 218 217 silo_ramdisk_size); 218 219 219 printf("done.\n"); 220 220 top += silo_ramdisk_size; 221 221 } 222 222 skip_ramdisk: 223 223 224 224 /* 225 225 * Now we can proceed to copy the components. We do it in reverse order … … 227 227 * with base. 228 228 */ 229 printf("\nCopying bootinfo tasks\n");229 printf("\nCopying tasks..."); 230 230 for (i = COMPONENTS - 1; i > 0; i--, j--) { 231 printf(" %s...", components[i].name);232 231 printf("%s ", components[i].name); 232 233 233 /* 234 234 * At this point, we claim the physical memory that we are … … 245 245 bootinfo.taskmap.tasks[j].addr, 246 246 ALIGN_UP(components[i].size, PAGE_SIZE)); 247 248 memcpy((void *) bootinfo.taskmap.tasks[j].addr,247 248 memcpy((void *) bootinfo.taskmap.tasks[j].addr, 249 249 components[i].start, components[i].size); 250 printf("done.\n"); 251 } 252 250 251 } 252 printf(".\n"); 253 253 254 printf("\nCopying kernel..."); 254 255 (void) ofw_claim_phys(bootinfo.physmem_start + base, … … 256 257 memcpy(base, components[0].start, components[0].size); 257 258 printf("done.\n"); 258 259 259 260 /* 260 261 * Claim and map the physical memory for the boot allocator. … … 266 267 (void) ofw_map(bootinfo.physmem_start + balloc_base, balloc_base, 267 268 BALLOC_MAX_SIZE, -1); 268 balloc_init(&bootinfo.ballocs, (uintptr_t)balloc_base); 269 269 balloc_init(&bootinfo.ballocs, (uintptr_t) balloc_base, 270 (uintptr_t) balloc_base); 271 270 272 printf("\nCanonizing OpenFirmware device tree..."); 271 273 bootinfo.ofw_root = ofw_tree_build(); 272 274 printf("done.\n"); 273 275 274 276 #ifdef CONFIG_AP 275 277 printf("\nChecking for secondary processors..."); 276 if (!ofw_cpu( ))278 if (!ofw_cpu(mid_mask, bootinfo.physmem_start)) 277 279 printf("Error: unable to get CPU properties\n"); 278 280 printf("done.\n"); 279 281 #endif 280 282 281 283 ofw_setup_palette(); 282 284 283 285 printf("\nBooting the kernel...\n"); 284 286 jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, 285 287 bootinfo.physmem_start | BSP_PROCESSOR, &bootinfo, 286 sizeof(bootinfo) );288 sizeof(bootinfo), subarchitecture); 287 289 }
Note:
See TracChangeset
for help on using the changeset viewer.