Changes in boot/arch/sparc64/loader/main.c [f7734012:e731b0d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/arch/sparc64/loader/main.c
rf7734012 re731b0d 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 memmove(base + top, (void *) ((uintptr_t)silo_ramdisk_image),216 memmove(base + top, (void *) ((uintptr_t) silo_ramdisk_image), 213 217 silo_ramdisk_size); 218 214 219 printf("done.\n"); 215 220 top += silo_ramdisk_size; 216 221 } 217 222 skip_ramdisk: 218 223 219 224 /* 220 225 * Now we can proceed to copy the components. We do it in reverse order … … 222 227 * with base. 223 228 */ 224 printf("\nCopying bootinfo tasks\n");229 printf("\nCopying tasks..."); 225 230 for (i = COMPONENTS - 1; i > 0; i--, j--) { 226 printf(" %s...", components[i].name);227 231 printf("%s ", components[i].name); 232 228 233 /* 229 234 * At this point, we claim the physical memory that we are … … 240 245 bootinfo.taskmap.tasks[j].addr, 241 246 ALIGN_UP(components[i].size, PAGE_SIZE)); 242 243 memcpy((void *) bootinfo.taskmap.tasks[j].addr,247 248 memcpy((void *) bootinfo.taskmap.tasks[j].addr, 244 249 components[i].start, components[i].size); 245 printf("done.\n"); 246 } 247 250 251 } 252 printf(".\n"); 253 248 254 printf("\nCopying kernel..."); 249 255 (void) ofw_claim_phys(bootinfo.physmem_start + base, … … 251 257 memcpy(base, components[0].start, components[0].size); 252 258 printf("done.\n"); 253 259 254 260 /* 255 261 * Claim and map the physical memory for the boot allocator. … … 261 267 (void) ofw_map(bootinfo.physmem_start + balloc_base, balloc_base, 262 268 BALLOC_MAX_SIZE, -1); 263 balloc_init(&bootinfo.ballocs, (uintptr_t)balloc_base); 264 269 balloc_init(&bootinfo.ballocs, (uintptr_t) balloc_base, 270 (uintptr_t) balloc_base); 271 265 272 printf("\nCanonizing OpenFirmware device tree..."); 266 273 bootinfo.ofw_root = ofw_tree_build(); 267 274 printf("done.\n"); 268 275 269 276 #ifdef CONFIG_AP 270 277 printf("\nChecking for secondary processors..."); 271 if (!ofw_cpu( ))278 if (!ofw_cpu(mid_mask, bootinfo.physmem_start)) 272 279 printf("Error: unable to get CPU properties\n"); 273 280 printf("done.\n"); 274 281 #endif 275 282 276 283 ofw_setup_palette(); 277 284 278 285 printf("\nBooting the kernel...\n"); 279 286 jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, 280 287 bootinfo.physmem_start | BSP_PROCESSOR, &bootinfo, 281 sizeof(bootinfo) );288 sizeof(bootinfo), subarchitecture); 282 289 }
Note:
See TracChangeset
for help on using the changeset viewer.