Changeset 1787e527 in mainline for boot/arch/sparc64/loader/main.c
- Timestamp:
- 2009-11-16T21:22:54Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5ebdf94
- Parents:
- fcbd1be (diff), 9c70ed6 (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
rfcbd1be r1787e527 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 printf("\n"); 192 193 /* Do not consider RAM disk */ 194 j = bootinfo.taskmap.count - 1; 195 192 196 if (silo_ramdisk_image) { 193 /* Treat the ramdisk as the last bootinfo task. */197 /* Treat the RAM disk as the last bootinfo task. */ 194 198 if (bootinfo.taskmap.count == TASKMAP_MAX_RECORDS) { 195 printf("Skipping ramdisk.\n");199 printf("Skipping RAM disk.\n"); 196 200 goto skip_ramdisk; 197 201 } 202 198 203 top = ALIGN_UP(top, PAGE_SIZE); 199 204 bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr = … … 202 207 silo_ramdisk_size; 203 208 bootinfo.taskmap.count++; 204 printf("\nCopying ramdisk..."); 209 printf("Copying RAM disk..."); 210 205 211 /* 206 212 * Claim and map the whole ramdisk as it may exceed the area … … 210 216 (void) ofw_map(bootinfo.physmem_start + base + top, base + top, 211 217 silo_ramdisk_size, -1); 212 memmove(base + top, (void *) ((uintptr_t)silo_ramdisk_image),218 memmove(base + top, (void *) ((uintptr_t) silo_ramdisk_image), 213 219 silo_ramdisk_size); 220 214 221 printf("done.\n"); 215 222 top += silo_ramdisk_size; 216 223 } 217 224 skip_ramdisk: 218 225 219 226 /* 220 227 * Now we can proceed to copy the components. We do it in reverse order … … 222 229 * with base. 223 230 */ 224 printf(" \nCopying bootinfo tasks\n");231 printf("Copying tasks..."); 225 232 for (i = COMPONENTS - 1; i > 0; i--, j--) { 226 printf(" %s...", components[i].name);227 233 printf("%s ", components[i].name); 234 228 235 /* 229 236 * At this point, we claim the physical memory that we are … … 240 247 bootinfo.taskmap.tasks[j].addr, 241 248 ALIGN_UP(components[i].size, PAGE_SIZE)); 242 243 memcpy((void *) bootinfo.taskmap.tasks[j].addr,249 250 memcpy((void *) bootinfo.taskmap.tasks[j].addr, 244 251 components[i].start, components[i].size); 245 printf("done.\n"); 246 } 247 248 printf("\nCopying kernel..."); 252 253 } 254 printf(".\n"); 255 256 printf("Copying kernel..."); 249 257 (void) ofw_claim_phys(bootinfo.physmem_start + base, 250 258 ALIGN_UP(components[0].size, PAGE_SIZE)); 251 259 memcpy(base, components[0].start, components[0].size); 252 260 printf("done.\n"); 253 261 254 262 /* 255 263 * Claim and map the physical memory for the boot allocator. … … 261 269 (void) ofw_map(bootinfo.physmem_start + balloc_base, balloc_base, 262 270 BALLOC_MAX_SIZE, -1); 263 balloc_init(&bootinfo.ballocs, (uintptr_t)balloc_base); 264 265 printf("\nCanonizing OpenFirmware device tree..."); 271 balloc_init(&bootinfo.ballocs, (uintptr_t) balloc_base, 272 (uintptr_t) balloc_base); 273 274 printf("Setting up screens..."); 275 ofw_setup_screens(); 276 printf("done.\n"); 277 278 printf("Canonizing OpenFirmware device tree..."); 266 279 bootinfo.ofw_root = ofw_tree_build(); 267 280 printf("done.\n"); 268 281 269 282 #ifdef CONFIG_AP 270 printf(" \nChecking for secondary processors...");271 if (!ofw_cpu( ))283 printf("Checking for secondary processors..."); 284 if (!ofw_cpu(mid_mask, bootinfo.physmem_start)) 272 285 printf("Error: unable to get CPU properties\n"); 273 286 printf("done.\n"); 274 287 #endif 275 276 ofw_setup_palette(); 277 278 printf("\nBooting the kernel...\n"); 288 289 printf("Booting the kernel...\n"); 279 290 jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, 280 291 bootinfo.physmem_start | BSP_PROCESSOR, &bootinfo, 281 sizeof(bootinfo) );292 sizeof(bootinfo), subarchitecture); 282 293 }
Note:
See TracChangeset
for help on using the changeset viewer.