Ignore:
File:
1 edited

Legend:

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

    rf7734012 re0565005  
    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        printf("\n");
     192       
     193        /* Do not consider RAM disk */
     194        j = bootinfo.taskmap.count - 1;
     195       
    192196        if (silo_ramdisk_image) {
    193                 /* Treat the ramdisk as the last bootinfo task. */
     197                /* Treat the RAM disk as the last bootinfo task. */
    194198                if (bootinfo.taskmap.count == TASKMAP_MAX_RECORDS) {
    195                         printf("Skipping ramdisk.\n");
     199                        printf("Skipping RAM disk.\n");
    196200                        goto skip_ramdisk;
    197201                }
     202               
    198203                top = ALIGN_UP(top, PAGE_SIZE);
    199204                bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr =
     
    202207                    silo_ramdisk_size;
    203208                bootinfo.taskmap.count++;
    204                 printf("\nCopying ramdisk...");
     209                printf("Copying RAM disk...");
     210               
    205211                /*
    206212                 * Claim and map the whole ramdisk as it may exceed the area
     
    210216                (void) ofw_map(bootinfo.physmem_start + base + top, base + top,
    211217                    silo_ramdisk_size, -1);
    212                 memmove(base + top, (void *)((uintptr_t)silo_ramdisk_image),
     218                memmove(base + top, (void *) ((uintptr_t) silo_ramdisk_image),
    213219                    silo_ramdisk_size);
     220               
    214221                printf("done.\n");
    215222                top += silo_ramdisk_size;
    216223        }
    217224skip_ramdisk:
    218 
     225       
    219226        /*
    220227         * Now we can proceed to copy the components. We do it in reverse order
     
    222229         * with base.
    223230         */
    224         printf("\nCopying bootinfo tasks\n");
     231        printf("Copying tasks...");
    225232        for (i = COMPONENTS - 1; i > 0; i--, j--) {
    226                 printf(" %s...", components[i].name);
    227 
     233                printf("%s ", components[i].name);
     234               
    228235                /*
    229236                 * At this point, we claim the physical memory that we are
     
    240247                    bootinfo.taskmap.tasks[j].addr,
    241248                    ALIGN_UP(components[i].size, PAGE_SIZE));
    242                    
    243                 memcpy((void *)bootinfo.taskmap.tasks[j].addr,
     249               
     250                memcpy((void *) bootinfo.taskmap.tasks[j].addr,
    244251                    components[i].start, components[i].size);
    245                 printf("done.\n");
    246         }
    247 
    248         printf("\nCopying kernel...");
     252               
     253        }
     254        printf(".\n");
     255       
     256        printf("Copying kernel...");
    249257        (void) ofw_claim_phys(bootinfo.physmem_start + base,
    250258            ALIGN_UP(components[0].size, PAGE_SIZE));
    251259        memcpy(base, components[0].start, components[0].size);
    252260        printf("done.\n");
    253 
     261       
    254262        /*
    255263         * Claim and map the physical memory for the boot allocator.
     
    261269        (void) ofw_map(bootinfo.physmem_start + balloc_base, balloc_base,
    262270            BALLOC_MAX_SIZE, -1);
    263         balloc_init(&bootinfo.ballocs, (uintptr_t)balloc_base);
    264 
    265         printf("\nCanonizing OpenFirmware device tree...");
     271        balloc_init(&bootinfo.ballocs, (uintptr_t) balloc_base,
     272            (uintptr_t) balloc_base);
     273       
     274        printf("Setting up screens...");
     275        ofw_setup_screens();
     276        printf("done.\n");
     277       
     278        printf("Canonizing OpenFirmware device tree...");
    266279        bootinfo.ofw_root = ofw_tree_build();
    267280        printf("done.\n");
    268 
     281       
    269282#ifdef CONFIG_AP
    270         printf("\nChecking for secondary processors...");
    271         if (!ofw_cpu())
     283        printf("Checking for secondary processors...");
     284        if (!ofw_cpu(mid_mask, bootinfo.physmem_start))
    272285                printf("Error: unable to get CPU properties\n");
    273286        printf("done.\n");
    274287#endif
    275 
    276         ofw_setup_palette();
    277 
    278         printf("\nBooting the kernel...\n");
     288       
     289        printf("Booting the kernel...\n");
    279290        jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS,
    280291            bootinfo.physmem_start | BSP_PROCESSOR, &bootinfo,
    281             sizeof(bootinfo));
     292            sizeof(bootinfo), subarchitecture);
    282293}
Note: See TracChangeset for help on using the changeset viewer.