Changeset 95b47c82 in mainline
- Timestamp:
- 2007-04-15T20:51:04Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9a7a970
- Parents:
- ddee708
- Location:
- boot
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/arch/sparc64/loader/main.c
rddee708 r95b47c82 93 93 for (i = 0; i < COMPONENTS; i++) 94 94 printf(" %P: %s image (size %d bytes)\n", components[i].start, 95 95 components[i].name, components[i].size); 96 96 97 97 void * base = (void *) KERNEL_VIRTUAL_ADDRESS; … … 103 103 printf(" %s...", components[i].name); 104 104 top = ALIGN_UP(top, PAGE_SIZE); 105 106 /* 107 * At this point, we claim the physical memory that we are 108 * going to use. We should be safe in case of the virtual 109 * address space because the OpenFirmware, according to its 110 * SPARC binding, should restrict its use of virtual memory 111 * to addresses from [0xffd00000; 0xffefffff] and 112 * [0xfe000000; 0xfeffffff]. 113 */ 114 (void) ofw_claim_phys(bootinfo.physmem_start + base + top, 115 ALIGN_UP(components[i].size, PAGE_SIZE)); 116 105 117 memcpy(base + top, components[i].start, components[i].size); 106 118 if (i > 0) { 107 bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr = base + top; 108 bootinfo.taskmap.tasks[bootinfo.taskmap.count].size = components[i].size; 119 bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr = 120 base + top; 121 bootinfo.taskmap.tasks[bootinfo.taskmap.count].size = 122 components[i].size; 109 123 bootinfo.taskmap.count++; 110 124 } … … 113 127 } 114 128 115 balloc_init(&bootinfo.ballocs, ALIGN_UP(((uintptr_t) base) + top, PAGE_SIZE)); 129 /* 130 * Claim the physical memory for the boot allocator. 131 * Initialize the boot allocator. 132 */ 133 (void) ofw_claim_phys(bootinfo.physmem_start + 134 base + ALIGN_UP(top, PAGE_SIZE), BALLOC_MAX_SIZE); 135 balloc_init(&bootinfo.ballocs, ALIGN_UP(((uintptr_t) base) + top, 136 PAGE_SIZE)); 116 137 117 138 printf("\nCanonizing OpenFirmware device tree..."); … … 128 149 printf("\nBooting the kernel...\n"); 129 150 jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, 130 bootinfo.physmem_start | BSP_PROCESSOR, &bootinfo, sizeof(bootinfo)); 151 bootinfo.physmem_start | BSP_PROCESSOR, &bootinfo, 152 sizeof(bootinfo)); 131 153 } 154 -
boot/genarch/balloc.c
rddee708 r95b47c82 48 48 49 49 addr = ballocs->base + ALIGN_UP(ballocs->size, alignment); 50 50 51 if (ALIGN_UP(ballocs->size, alignment) + size > BALLOC_MAX_SIZE) 52 return NULL; 53 51 54 ballocs->size = ALIGN_UP(ballocs->size, alignment) + size; 52 55 -
boot/genarch/balloc.h
rddee708 r95b47c82 32 32 #include <types.h> 33 33 34 #define BALLOC_MAX_SIZE (1024 * 1024) 35 34 36 typedef struct { 35 37 uintptr_t base; -
boot/genarch/ofw.c
rddee708 r95b47c82 39 39 phandle ofw_root; 40 40 ihandle ofw_mmu; 41 ihandle ofw_memory_prop; 41 42 phandle ofw_memory; 42 43 phandle ofw_aliases; … … 48 49 halt(); 49 50 50 if (ofw_get_property(ofw_chosen, "stdout", 51 if (ofw_get_property(ofw_chosen, "stdout", &ofw_stdout, sizeof(ofw_stdout)) <= 0) 51 52 ofw_stdout = 0; 52 53 … … 57 58 } 58 59 59 if (ofw_get_property(ofw_chosen, "mmu", 60 if (ofw_get_property(ofw_chosen, "mmu", &ofw_mmu, sizeof(ofw_mmu)) <= 0) { 60 61 puts("\r\nError: Unable to get mmu property, halted.\r\n"); 62 halt(); 63 } 64 if (ofw_get_property(ofw_chosen, "memory", &ofw_memory_prop, sizeof(ofw_memory_prop)) <= 0) { 65 puts("\r\nError: Unable to get memory property, halted.\r\n"); 61 66 halt(); 62 67 } … … 201 206 shift = 0; 202 207 203 return (void *) ((result[2] <<shift)|result[3]);204 } 205 206 void *ofw_claim (const void *virt, const int len)208 return (void *) ((result[2] << shift) | result[3]); 209 } 210 211 void *ofw_claim_virt(const void *virt, const int len) 207 212 { 208 213 ofw_arg_t retaddr; 209 int shift;210 214 211 215 if (ofw_call("call-method", 5, 2, &retaddr, "claim", ofw_mmu, 0, len, virt) != 0) { … … 215 219 216 220 return (void *) retaddr; 221 } 222 223 void *ofw_claim_phys(const void *phys, const int len) 224 { 225 ofw_arg_t retaddr[2]; 226 int shift; 227 228 if (sizeof(unative_t) == 8) { 229 shift = 32; 230 if (ofw_call("call-method", 6, 3, retaddr, "claim", 231 ofw_memory_prop, 0, len, ((uintptr_t) phys) >> shift, 232 ((uintptr_t) phys) & ((uint32_t) -1)) != 0) { 233 /* 234 * Note that this will help us to discover 235 * conflicts between OpenFirmware allocations 236 * and our use of physical memory. 237 * It is better to detect collisions here 238 * than to cope with weird errors later. 239 * 240 * So this is really not to make the loader 241 * more generic; it is here for debugging 242 * purposes. 243 */ 244 puts("Error: memory method claim() failed, halting.\n"); 245 halt(); 246 } 247 } else { 248 shift = 0; 249 /* 250 * FIXME: the number of arguments is probably different... 251 */ 252 puts("Error: 32-bit ofw_claim_phys not implemented.\n"); 253 halt(); 254 } 255 256 return (void *) ((retaddr[0] << shift) | retaddr[1]); 217 257 } 218 258 … … 231 271 232 272 return ofw_call("call-method", 7, 1, NULL, "map", ofw_mmu, mode, size, virt, 233 273 phys_hi, phys_lo); 234 274 } 235 275 … … 253 293 map->total = 0; 254 294 map->count = 0; 255 for (pos = 0; (pos < ret / sizeof(uint32_t)) && (map->count <256 295 for (pos = 0; (pos < ret / sizeof(uint32_t)) && 296 (map->count < MEMMAP_MAX_RECORDS); pos += ac + sc) { 257 297 void * start = (void *) ((uintptr_t) buf[pos + ac - 1]); 258 298 unsigned int size = buf[pos + ac + sc - 1]; -
boot/genarch/ofw.h
rddee708 r95b47c82 118 118 extern void *ofw_translate(const void *virt); 119 119 extern int ofw_translate_failed(ofw_arg_t flag); 120 extern void *ofw_claim(const void *virt, const int len); 120 extern void *ofw_claim_virt(const void *virt, const int len); 121 extern void *ofw_claim_phys(const void *virt, const int len); 121 122 extern int ofw_map(const void *phys, const void *virt, const int size, const int mode); 122 123 extern int ofw_memmap(memmap_t *map);
Note:
See TracChangeset
for help on using the changeset viewer.