Changeset e0565005 in mainline
- Timestamp:
- 2009-08-24T14:41:42Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ed5ad30
- Parents:
- 21d8020
- Location:
- boot
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/arch/ppc32/loader/main.c
r21d8020 re0565005 172 172 pages += balloc_pages; 173 173 174 printf("Setting up screens..."); 175 ofw_setup_screens(); 176 printf("done.\n"); 177 174 178 balloc_init(&bootinfo.ballocs, (uintptr_t) balloc_base, balloc_kernel_base); 175 179 printf("\nCanonizing OpenFirmware device tree..."); … … 177 181 printf("done.\n"); 178 182 179 ofw_setup_palette(); 180 181 printf("\nBooting the kernel...\n"); 183 printf("Booting the kernel...\n"); 182 184 jump_to_kernel(bootinfo_pa, sizeof(bootinfo), trans_pa, pages << PAGE_WIDTH, real_mode_pa); 183 185 } -
boot/arch/sparc64/loader/main.c
r21d8020 re0565005 189 189 } 190 190 191 printf("\n"); 192 191 193 /* Do not consider RAM disk */ 192 194 j = bootinfo.taskmap.count - 1; … … 205 207 silo_ramdisk_size; 206 208 bootinfo.taskmap.count++; 207 printf(" \nCopying RAM disk...");209 printf("Copying RAM disk..."); 208 210 209 211 /* … … 227 229 * with base. 228 230 */ 229 printf(" \nCopying tasks...");231 printf("Copying tasks..."); 230 232 for (i = COMPONENTS - 1; i > 0; i--, j--) { 231 233 printf("%s ", components[i].name); … … 252 254 printf(".\n"); 253 255 254 printf(" \nCopying kernel...");256 printf("Copying kernel..."); 255 257 (void) ofw_claim_phys(bootinfo.physmem_start + base, 256 258 ALIGN_UP(components[0].size, PAGE_SIZE)); … … 270 272 (uintptr_t) balloc_base); 271 273 272 printf("\nCanonizing OpenFirmware device tree..."); 274 printf("Setting up screens..."); 275 ofw_setup_screens(); 276 printf("done.\n"); 277 278 printf("Canonizing OpenFirmware device tree..."); 273 279 bootinfo.ofw_root = ofw_tree_build(); 274 280 printf("done.\n"); 275 281 276 282 #ifdef CONFIG_AP 277 printf(" \nChecking for secondary processors...");283 printf("Checking for secondary processors..."); 278 284 if (!ofw_cpu(mid_mask, bootinfo.physmem_start)) 279 285 printf("Error: unable to get CPU properties\n"); … … 281 287 #endif 282 288 283 ofw_setup_palette(); 284 285 printf("\nBooting the kernel...\n"); 289 printf("Booting the kernel...\n"); 286 290 jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS, 287 291 bootinfo.physmem_start | BSP_PROCESSOR, &bootinfo, -
boot/genarch/ofw.c
r21d8020 re0565005 32 32 #include <asm.h> 33 33 #include <types.h> 34 #include <string.h> 34 35 35 36 #define RED(i) (((i) >> 5) & ((1 << 3) - 1)) … … 46 47 ihandle ofw_memory_prop; 47 48 phandle ofw_memory; 48 phandle ofw_aliases;49 49 50 50 void ofw_init(void) … … 74 74 halt(); 75 75 } 76 76 77 77 ofw_memory = ofw_find_device("/memory"); 78 78 if (ofw_memory == -1) { 79 79 puts("\r\nError: Unable to find /memory device, halted.\r\n"); 80 halt();81 }82 83 ofw_aliases = ofw_find_device("/aliases");84 if (ofw_aliases == -1) {85 puts("\r\nError: Unable to find /aliases device, halted.\r\n");86 80 halt(); 87 81 } … … 133 127 } 134 128 135 int 136 ofw_get_property(const phandle device, const char *name, void *buf, 129 int ofw_get_property(const phandle device, const char *name, void *buf, 137 130 const int buflen) 138 131 { … … 166 159 return ret; 167 160 } 168 169 161 170 162 unsigned int ofw_get_size_cells(const phandle device) … … 354 346 } 355 347 356 /** 357 * Sets up the palette for the 8-bit color depth configuration so that the 358 * 3:2:3 color scheme can be used. Checks that setting the palette makes sense 359 * (appropriate nodes exist in the OBP tree and the color depth is not greater 348 static void ofw_setup_screen(phandle handle) 349 { 350 /* Check for device type */ 351 char device_type[OFW_TREE_PROPERTY_MAX_VALUELEN]; 352 if (ofw_get_property(handle, "device_type", device_type, OFW_TREE_PROPERTY_MAX_VALUELEN) <= 0) 353 return; 354 355 device_type[OFW_TREE_PROPERTY_MAX_VALUELEN - 1] = '\0'; 356 if (strcmp(device_type, "display") != 0) 357 return; 358 359 /* Check for 8 bit depth */ 360 uint32_t depth; 361 if (ofw_get_property(handle, "depth", &depth, sizeof(uint32_t)) <= 0) 362 depth = 0; 363 364 /* Get device path */ 365 static char path[OFW_TREE_PATH_MAX_LEN + 1]; 366 size_t len = ofw_package_to_path(handle, path, OFW_TREE_PATH_MAX_LEN); 367 if (len == -1) 368 return; 369 370 path[len] = '\0'; 371 372 /* Open the display to initialize it */ 373 ihandle screen = ofw_open(path); 374 if (screen == -1) 375 return; 376 377 if (depth == 8) { 378 /* Setup the palette so that the (inverted) 3:2:3 scheme is usable */ 379 unsigned int i; 380 for (i = 0; i < 256; i++) { 381 ofw_call("call-method", 6, 1, NULL, "color!", screen, 382 255 - i, CLIP(BLUE(i) * 37), GREEN(i) * 85, CLIP(RED(i) * 37)); 383 } 384 } 385 } 386 387 static void ofw_setup_screens_internal(phandle current) 388 { 389 while ((current != 0) && (current != -1)) { 390 ofw_setup_screen(current); 391 392 /* 393 * Recursively process the potential child node. 394 */ 395 phandle child = ofw_get_child_node(current); 396 if ((child != 0) && (child != -1)) 397 ofw_setup_screens_internal(child); 398 399 /* 400 * Iteratively process the next peer node. 401 * Note that recursion is a bad idea here. 402 * Due to the topology of the OpenFirmware device tree, 403 * the nesting of peer nodes could be to wide and the 404 * risk of overflowing the stack is too real. 405 */ 406 phandle peer = ofw_get_peer_node(current); 407 if ((peer != 0) && (peer != -1)) { 408 current = peer; 409 /* 410 * Process the peer in next iteration. 411 */ 412 continue; 413 } 414 415 /* 416 * No more peers on this level. 417 */ 418 break; 419 } 420 } 421 422 /** Setup all screens which can be detected. 423 * 424 * Open all screens which can be detected and set up the palette for the 8-bit 425 * color depth configuration so that the 3:2:3 color scheme can be used. 426 * Check that setting the palette makes sense (the color depth is not greater 360 427 * than 8). 361 428 * 362 * @return true if the palette has been set, false otherwise363 *364 429 */ 365 int ofw_setup_palette(void) 366 { 367 char device_name[BUF_SIZE]; 368 369 /* Resolve alias */ 370 if (ofw_get_property(ofw_aliases, "screen", device_name, 371 sizeof(device_name)) <= 0) 372 return false; 373 374 /* For depth greater than 8 it makes no sense to set up the palette */ 375 uint32_t depth; 376 phandle device = ofw_find_device(device_name); 377 if (device == -1) 378 return false; 379 if (ofw_get_property(device, "depth", &depth, sizeof(uint32_t)) <= 0) 380 return false; 381 if (depth != 8) 382 return false; 383 384 /* Required in order to be able to make a method call */ 385 ihandle screen = ofw_open(device_name); 386 if (screen == -1) 387 return false; 388 389 /* Setup the palette so that the (inverted) 3:2:3 scheme is usable */ 390 unsigned int i; 391 for (i = 0; i < 256; i++) 392 ofw_call("call-method", 6, 1, NULL, "color!", screen, 393 255 - i, CLIP(BLUE(i) * 37), GREEN(i) * 85, CLIP(RED(i) * 37)); 394 return true; 430 void ofw_setup_screens(void) 431 { 432 ofw_setup_screens_internal(ofw_root); 395 433 } 396 434 -
boot/genarch/ofw.h
r21d8020 re0565005 33 33 #include <stdarg.h> 34 34 35 #define BUF_SIZE 1024 35 #define MEMMAP_MAX_RECORDS 32 36 #define MAX_OFW_ARGS 12 36 37 37 #define MEMMAP_MAX_RECORDS 3238 39 #define MAX_OFW_ARGS 1238 #define OFW_TREE_PATH_MAX_LEN 256 39 #define OFW_TREE_PROPERTY_MAX_NAMELEN 32 40 #define OFW_TREE_PROPERTY_MAX_VALUELEN 64 40 41 41 42 typedef unative_t ofw_arg_t; … … 83 84 extern ihandle ofw_mmu; 84 85 extern phandle ofw_memory; 85 extern phandle ofw_aliases;86 86 87 87 extern void ofw_init(void); … … 110 110 extern int ofw_map(const void *phys, const void *virt, const unsigned int size, const int mode); 111 111 extern int ofw_memmap(memmap_t *map); 112 extern int ofw_setup_palette(void);112 extern void ofw_setup_screens(void); 113 113 extern void ofw_quiesce(void); 114 114 -
boot/genarch/ofw_tree.c
r21d8020 re0565005 35 35 #include <asm.h> 36 36 #include <memstr.h> 37 38 #define MAX_PATH_LEN 25639 37 40 38 static ofw_tree_node_t *ofw_tree_node_alloc(void) … … 101 99 * Get the disambigued name. 102 100 */ 103 static char path[ MAX_PATH_LEN + 1];104 size_t len = ofw_package_to_path(current, path, MAX_PATH_LEN);101 static char path[OFW_TREE_PATH_MAX_LEN + 1]; 102 size_t len = ofw_package_to_path(current, path, OFW_TREE_PATH_MAX_LEN); 105 103 if (len == -1) 106 104 return; … … 168 166 memcpy(name, name2, OFW_TREE_PROPERTY_MAX_NAMELEN); 169 167 memcpy(property[i].name, name, OFW_TREE_PROPERTY_MAX_NAMELEN); 170 property[i].name[OFW_TREE_PROPERTY_MAX_NAMELEN ] = '\0';168 property[i].name[OFW_TREE_PROPERTY_MAX_NAMELEN - 1] = '\0'; 171 169 172 170 size_t size = ofw_get_proplen(current, name); -
boot/genarch/ofw_tree.h
r21d8020 re0565005 33 33 #include <ofw.h> 34 34 35 #define OFW_TREE_PROPERTY_MAX_NAMELEN 3236 35 37 36 /** Memory representation of OpenFirmware device tree node property. */
Note:
See TracChangeset
for help on using the changeset viewer.