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