Changeset e0565005 in mainline


Ignore:
Timestamp:
2009-08-24T14:41:42Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ed5ad30
Parents:
21d8020
Message:

initialize and setup all displays which can be detected in OFW tree (not only stdin)
reduce the number of newlines during boot (speedups especially in simulators)

Location:
boot
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • boot/arch/ppc32/loader/main.c

    r21d8020 re0565005  
    172172        pages += balloc_pages;
    173173       
     174        printf("Setting up screens...");
     175        ofw_setup_screens();
     176        printf("done.\n");
     177       
    174178        balloc_init(&bootinfo.ballocs, (uintptr_t) balloc_base, balloc_kernel_base);
    175179        printf("\nCanonizing OpenFirmware device tree...");
     
    177181        printf("done.\n");
    178182       
    179         ofw_setup_palette();
    180        
    181         printf("\nBooting the kernel...\n");
     183        printf("Booting the kernel...\n");
    182184        jump_to_kernel(bootinfo_pa, sizeof(bootinfo), trans_pa, pages << PAGE_WIDTH, real_mode_pa);
    183185}
  • boot/arch/sparc64/loader/main.c

    r21d8020 re0565005  
    189189        }
    190190       
     191        printf("\n");
     192       
    191193        /* Do not consider RAM disk */
    192194        j = bootinfo.taskmap.count - 1;
     
    205207                    silo_ramdisk_size;
    206208                bootinfo.taskmap.count++;
    207                 printf("\nCopying RAM disk...");
     209                printf("Copying RAM disk...");
    208210               
    209211                /*
     
    227229         * with base.
    228230         */
    229         printf("\nCopying tasks...");
     231        printf("Copying tasks...");
    230232        for (i = COMPONENTS - 1; i > 0; i--, j--) {
    231233                printf("%s ", components[i].name);
     
    252254        printf(".\n");
    253255       
    254         printf("\nCopying kernel...");
     256        printf("Copying kernel...");
    255257        (void) ofw_claim_phys(bootinfo.physmem_start + base,
    256258            ALIGN_UP(components[0].size, PAGE_SIZE));
     
    270272            (uintptr_t) balloc_base);
    271273       
    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...");
    273279        bootinfo.ofw_root = ofw_tree_build();
    274280        printf("done.\n");
    275281       
    276282#ifdef CONFIG_AP
    277         printf("\nChecking for secondary processors...");
     283        printf("Checking for secondary processors...");
    278284        if (!ofw_cpu(mid_mask, bootinfo.physmem_start))
    279285                printf("Error: unable to get CPU properties\n");
     
    281287#endif
    282288       
    283         ofw_setup_palette();
    284        
    285         printf("\nBooting the kernel...\n");
     289        printf("Booting the kernel...\n");
    286290        jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS,
    287291            bootinfo.physmem_start | BSP_PROCESSOR, &bootinfo,
  • boot/genarch/ofw.c

    r21d8020 re0565005  
    3232#include <asm.h>
    3333#include <types.h>
     34#include <string.h>
    3435
    3536#define RED(i)    (((i) >> 5) & ((1 << 3) - 1))
     
    4647ihandle ofw_memory_prop;
    4748phandle ofw_memory;
    48 phandle ofw_aliases;
    4949
    5050void ofw_init(void)
     
    7474                halt();
    7575        }
    76 
     76       
    7777        ofw_memory = ofw_find_device("/memory");
    7878        if (ofw_memory == -1) {
    7979                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");
    8680                halt();
    8781        }
     
    133127}
    134128
    135 int
    136 ofw_get_property(const phandle device, const char *name, void *buf,
     129int ofw_get_property(const phandle device, const char *name, void *buf,
    137130    const int buflen)
    138131{
     
    166159        return ret;
    167160}
    168 
    169161
    170162unsigned int ofw_get_size_cells(const phandle device)
     
    354346}
    355347
    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
     348static 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
     387static 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
    360427 * than 8).
    361428 *
    362  * @return true if the palette has been set, false otherwise
    363  *
    364429 */
    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;
     430void ofw_setup_screens(void)
     431{
     432        ofw_setup_screens_internal(ofw_root);
    395433}
    396434
  • boot/genarch/ofw.h

    r21d8020 re0565005  
    3333#include <stdarg.h>
    3434
    35 #define BUF_SIZE  1024
     35#define MEMMAP_MAX_RECORDS  32
     36#define MAX_OFW_ARGS        12
    3637
    37 #define MEMMAP_MAX_RECORDS  32
    38 
    39 #define MAX_OFW_ARGS  12
     38#define OFW_TREE_PATH_MAX_LEN           256
     39#define OFW_TREE_PROPERTY_MAX_NAMELEN   32
     40#define OFW_TREE_PROPERTY_MAX_VALUELEN  64
    4041
    4142typedef unative_t ofw_arg_t;
     
    8384extern ihandle ofw_mmu;
    8485extern phandle ofw_memory;
    85 extern phandle ofw_aliases;
    8686
    8787extern void ofw_init(void);
     
    110110extern int ofw_map(const void *phys, const void *virt, const unsigned int size, const int mode);
    111111extern int ofw_memmap(memmap_t *map);
    112 extern int ofw_setup_palette(void);
     112extern void ofw_setup_screens(void);
    113113extern void ofw_quiesce(void);
    114114
  • boot/genarch/ofw_tree.c

    r21d8020 re0565005  
    3535#include <asm.h>
    3636#include <memstr.h>
    37 
    38 #define MAX_PATH_LEN  256
    3937
    4038static ofw_tree_node_t *ofw_tree_node_alloc(void)
     
    10199                 * Get the disambigued name.
    102100                 */
    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);
    105103                if (len == -1)
    106104                        return;
     
    168166                        memcpy(name, name2, OFW_TREE_PROPERTY_MAX_NAMELEN);
    169167                        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';
    171169                       
    172170                        size_t size = ofw_get_proplen(current, name);
  • boot/genarch/ofw_tree.h

    r21d8020 re0565005  
    3333#include <ofw.h>
    3434
    35 #define OFW_TREE_PROPERTY_MAX_NAMELEN  32
    3635
    3736/** Memory representation of OpenFirmware device tree node property. */
Note: See TracChangeset for help on using the changeset viewer.