Changeset b50b5af2 in mainline for boot/arch/sparc64/loader/main.c


Ignore:
Timestamp:
2009-08-22T10:48:00Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
04803bf
Parents:
1ea99cc (diff), a71c158 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

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

    r1ea99cc rb50b5af2  
    11/*
    22 * Copyright (c) 2005 Martin Decky
    3  * Copyright (c) 2006 Jakub Jermar 
     3 * Copyright (c) 2006 Jakub Jermar
    44 * All rights reserved.
    55 *
     
    2828 */
    2929
    30 #include "main.h" 
     30#include "main.h"
    3131#include <printf.h>
    3232#include "asm.h"
     
    3939#include <macros.h>
    4040#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
     43static bootinfo_t bootinfo;
     44static component_t components[COMPONENTS];
     45static char *release = STRING(RELEASE);
    4746
    4847#ifdef REVISION
    49         char *revision = ", revision " STRING(REVISION);
     48        static char *revision = ", revision " STRING(REVISION);
    5049#else
    51         char *revision = "";
     50        static char *revision = "";
    5251#endif
    5352
    5453#ifdef TIMESTAMP
    55         char *timestamp = "\nBuilt on " STRING(TIMESTAMP);
     54        static char *timestamp = "\nBuilt on " STRING(TIMESTAMP);
    5655#else
    57         char *timestamp = "";
     56        static char *timestamp = "";
    5857#endif
    5958
    6059/** UltraSPARC subarchitecture - 1 for US, 3 for US3 */
    61 uint8_t subarchitecture;
     60static uint8_t subarchitecture;
    6261
    6362/**
     
    6564 * MID_SHIFT bits to the right
    6665 */
    67 uint16_t mid_mask;
     66static uint16_t mid_mask;
    6867
    6968/** Print version information. */
     
    7675
    7776/* the lowest ID (read from the VER register) of some US3 CPU model */
    78 #define FIRST_US3_CPU   0x14
     77#define FIRST_US3_CPU  0x14
    7978
    8079/* the greatest ID (read from the VER register) of some US3 CPU model */
    81 #define LAST_US3_CPU    0x19
     80#define LAST_US3_CPU   0x19
    8281
    8382/* UltraSPARC IIIi processor implementation code */
    84 #define US_IIIi_CODE    0x15
     83#define US_IIIi_CODE   0x15
    8584
    8685/**
     
    9190{
    9291        uint64_t v;
    93         asm volatile ("rdpr %%ver, %0\n" : "=r" (v));
     92        asm volatile (
     93                "rdpr %%ver, %0\n"
     94                : "=r" (v)
     95        );
    9496       
    9597        v = (v << 16) >> 48;
     
    103105                subarchitecture = SUBARCH_US;
    104106                mid_mask = (1 << 5) - 1;
    105         } else {
     107        } else
    106108                printf("\nThis CPU is not supported by HelenOS.");
    107         }
    108109}
    109110
     
    113114        void *balloc_base;
    114115        unsigned int top = 0;
    115         int i, j;
    116 
     116        unsigned int i;
     117        unsigned int j;
     118       
    117119        version_print();
    118120       
    119121        detect_subarchitecture();
    120122        init_components(components);
    121 
     123       
    122124        if (!ofw_get_physmem_start(&bootinfo.physmem_start)) {
    123125                printf("Error: unable to get start of physical memory.\n");
    124126                halt();
    125127        }
    126 
     128       
    127129        if (!ofw_memmap(&bootinfo.memmap)) {
    128130                printf("Error: unable to get memory map, halting.\n");
    129131                halt();
    130132        }
    131 
     133       
    132134        if (bootinfo.memmap.total == 0) {
    133135                printf("Error: no memory detected, halting.\n");
    134136                halt();
    135137        }
    136 
     138       
    137139        /*
    138140         * SILO for some reason adds 0x400000 and subtracts
     
    143145                silo_ramdisk_image += bootinfo.physmem_start;
    144146                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),
    148151                    silo_ramdisk_size, -1) != 0) {
    149                         printf("Failed to map ramdisk.\n");
     152                        printf("Failed to map RAM disk.\n");
    150153                        halt();
    151154                }
    152155        }
    153156       
    154         printf("\nSystem info\n");
    155         printf(" memory: %dM starting at %P\n",
     157        printf("\nMemory statistics (total %d MB, starting at %P)\n",
    156158            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);
    160160        printf(" %P: boot info structure\n", &bootinfo);
    161161       
     
    176176                                break;
    177177                        }
     178                       
    178179                        bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr =
    179180                            base + top;
     
    187188                top += components[i].size;
    188189        }
    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       
    192194        if (silo_ramdisk_image) {
    193                 /* Treat the ramdisk as the last bootinfo task. */
     195                /* Treat the RAM disk as the last bootinfo task. */
    194196                if (bootinfo.taskmap.count == TASKMAP_MAX_RECORDS) {
    195                         printf("Skipping ramdisk.\n");
     197                        printf("Skipping RAM disk.\n");
    196198                        goto skip_ramdisk;
    197199                }
     200               
    198201                top = ALIGN_UP(top, PAGE_SIZE);
    199202                bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr =
     
    202205                    silo_ramdisk_size;
    203206                bootinfo.taskmap.count++;
    204                 printf("\nCopying ramdisk...");
     207                printf("\nCopying RAM disk...");
     208               
    205209                /*
    206210                 * Claim and map the whole ramdisk as it may exceed the area
     
    210214                (void) ofw_map(bootinfo.physmem_start + base + top, base + top,
    211215                    silo_ramdisk_size, -1);
    212                 /*
    213                  * FIXME If the source and destination overlap, it may be
    214                  * desirable to copy in reverse order, depending on how the two
    215                  * regions overlap.
    216                  */
    217                 memcpy(base + top, (void *)((uintptr_t)silo_ramdisk_image),
     216                memmove(base + top, (void *) ((uintptr_t) silo_ramdisk_image),
    218217                    silo_ramdisk_size);
     218               
    219219                printf("done.\n");
    220220                top += silo_ramdisk_size;
    221221        }
    222222skip_ramdisk:
    223 
     223       
    224224        /*
    225225         * Now we can proceed to copy the components. We do it in reverse order
     
    227227         * with base.
    228228         */
    229         printf("\nCopying bootinfo tasks\n");
     229        printf("\nCopying tasks...");
    230230        for (i = COMPONENTS - 1; i > 0; i--, j--) {
    231                 printf(" %s...", components[i].name);
    232 
     231                printf("%s ", components[i].name);
     232               
    233233                /*
    234234                 * At this point, we claim the physical memory that we are
     
    245245                    bootinfo.taskmap.tasks[j].addr,
    246246                    ALIGN_UP(components[i].size, PAGE_SIZE));
    247                    
    248                 memcpy((void *)bootinfo.taskmap.tasks[j].addr,
     247               
     248                memcpy((void *) bootinfo.taskmap.tasks[j].addr,
    249249                    components[i].start, components[i].size);
    250                 printf("done.\n");
    251         }
    252 
     250               
     251        }
     252        printf(".\n");
     253       
    253254        printf("\nCopying kernel...");
    254255        (void) ofw_claim_phys(bootinfo.physmem_start + base,
     
    256257        memcpy(base, components[0].start, components[0].size);
    257258        printf("done.\n");
    258 
     259       
    259260        /*
    260261         * Claim and map the physical memory for the boot allocator.
     
    266267        (void) ofw_map(bootinfo.physmem_start + balloc_base, balloc_base,
    267268            BALLOC_MAX_SIZE, -1);
    268         balloc_init(&bootinfo.ballocs, (uintptr_t)balloc_base);
    269 
     269        balloc_init(&bootinfo.ballocs, (uintptr_t) balloc_base,
     270            (uintptr_t) balloc_base);
     271       
    270272        printf("\nCanonizing OpenFirmware device tree...");
    271273        bootinfo.ofw_root = ofw_tree_build();
    272274        printf("done.\n");
    273 
     275       
    274276#ifdef CONFIG_AP
    275277        printf("\nChecking for secondary processors...");
    276         if (!ofw_cpu())
     278        if (!ofw_cpu(mid_mask, bootinfo.physmem_start))
    277279                printf("Error: unable to get CPU properties\n");
    278280        printf("done.\n");
    279281#endif
    280 
     282       
    281283        ofw_setup_palette();
    282 
     284       
    283285        printf("\nBooting the kernel...\n");
    284286        jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS,
    285287            bootinfo.physmem_start | BSP_PROCESSOR, &bootinfo,
    286             sizeof(bootinfo));
     288            sizeof(bootinfo), subarchitecture);
    287289}
Note: See TracChangeset for help on using the changeset viewer.