Ignore:
File:
1 edited

Legend:

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

    re731b0d rf7734012  
    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 #include <memstr.h>
    42 
    43 static bootinfo_t bootinfo;
    44 static component_t components[COMPONENTS];
    45 static char *release = STRING(RELEASE);
     41
     42bootinfo_t bootinfo;
     43
     44component_t components[COMPONENTS];
     45
     46char *release = STRING(RELEASE);
    4647
    4748#ifdef REVISION
    48         static char *revision = ", revision " STRING(REVISION);
     49        char *revision = ", revision " STRING(REVISION);
    4950#else
    50         static char *revision = "";
     51        char *revision = "";
    5152#endif
    5253
    5354#ifdef TIMESTAMP
    54         static char *timestamp = "\nBuilt on " STRING(TIMESTAMP);
     55        char *timestamp = "\nBuilt on " STRING(TIMESTAMP);
    5556#else
    56         static char *timestamp = "";
     57        char *timestamp = "";
    5758#endif
    5859
    5960/** UltraSPARC subarchitecture - 1 for US, 3 for US3 */
    60 static uint8_t subarchitecture;
     61uint8_t subarchitecture;
    6162
    6263/**
     
    6465 * MID_SHIFT bits to the right
    6566 */
    66 static uint16_t mid_mask;
     67uint16_t mid_mask;
    6768
    6869/** Print version information. */
     
    7576
    7677/* the lowest ID (read from the VER register) of some US3 CPU model */
    77 #define FIRST_US3_CPU  0x14
     78#define FIRST_US3_CPU   0x14
    7879
    7980/* the greatest ID (read from the VER register) of some US3 CPU model */
    80 #define LAST_US3_CPU   0x19
     81#define LAST_US3_CPU    0x19
    8182
    8283/* UltraSPARC IIIi processor implementation code */
    83 #define US_IIIi_CODE   0x15
     84#define US_IIIi_CODE    0x15
    8485
    8586/**
     
    9091{
    9192        uint64_t v;
    92         asm volatile (
    93                 "rdpr %%ver, %0\n"
    94                 : "=r" (v)
    95         );
     93        asm volatile ("rdpr %%ver, %0\n" : "=r" (v));
    9694       
    9795        v = (v << 16) >> 48;
     
    105103                subarchitecture = SUBARCH_US;
    106104                mid_mask = (1 << 5) - 1;
    107         } else
     105        } else {
    108106                printf("\nThis CPU is not supported by HelenOS.");
     107        }
    109108}
    110109
     
    114113        void *balloc_base;
    115114        unsigned int top = 0;
    116         unsigned int i;
    117         unsigned int j;
    118        
     115        int i, j;
     116
    119117        version_print();
    120118       
    121119        detect_subarchitecture();
    122120        init_components(components);
    123        
     121
    124122        if (!ofw_get_physmem_start(&bootinfo.physmem_start)) {
    125123                printf("Error: unable to get start of physical memory.\n");
    126124                halt();
    127125        }
    128        
     126
    129127        if (!ofw_memmap(&bootinfo.memmap)) {
    130128                printf("Error: unable to get memory map, halting.\n");
    131129                halt();
    132130        }
    133        
     131
    134132        if (bootinfo.memmap.total == 0) {
    135133                printf("Error: no memory detected, halting.\n");
    136134                halt();
    137135        }
    138        
     136
    139137        /*
    140138         * SILO for some reason adds 0x400000 and subtracts
     
    145143                silo_ramdisk_image += bootinfo.physmem_start;
    146144                silo_ramdisk_image -= 0x400000;
    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),
     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),
    151148                    silo_ramdisk_size, -1) != 0) {
    152                         printf("Failed to map RAM disk.\n");
     149                        printf("Failed to map ramdisk.\n");
    153150                        halt();
    154151                }
    155152        }
    156153       
    157         printf("\nMemory statistics (total %d MB, starting at %P)\n",
     154        printf("\nSystem info\n");
     155        printf(" memory: %dM starting at %P\n",
    158156            bootinfo.memmap.total >> 20, bootinfo.physmem_start);
    159         printf(" %P: kernel entry point\n", KERNEL_VIRTUAL_ADDRESS);
     157
     158        printf("\nMemory statistics\n");
     159        printf(" kernel entry point at %P\n", KERNEL_VIRTUAL_ADDRESS);
    160160        printf(" %P: boot info structure\n", &bootinfo);
    161161       
     
    176176                                break;
    177177                        }
    178                        
    179178                        bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr =
    180179                            base + top;
     
    188187                top += components[i].size;
    189188        }
    190        
    191         /* Do not consider RAM disk */
    192         j = bootinfo.taskmap.count - 1;
    193        
     189
     190        j = bootinfo.taskmap.count - 1; /* do not consider ramdisk */
     191
    194192        if (silo_ramdisk_image) {
    195                 /* Treat the RAM disk as the last bootinfo task. */
     193                /* Treat the ramdisk as the last bootinfo task. */
    196194                if (bootinfo.taskmap.count == TASKMAP_MAX_RECORDS) {
    197                         printf("Skipping RAM disk.\n");
     195                        printf("Skipping ramdisk.\n");
    198196                        goto skip_ramdisk;
    199197                }
    200                
    201198                top = ALIGN_UP(top, PAGE_SIZE);
    202199                bootinfo.taskmap.tasks[bootinfo.taskmap.count].addr =
     
    205202                    silo_ramdisk_size;
    206203                bootinfo.taskmap.count++;
    207                 printf("\nCopying RAM disk...");
    208                
     204                printf("\nCopying ramdisk...");
    209205                /*
    210206                 * Claim and map the whole ramdisk as it may exceed the area
     
    214210                (void) ofw_map(bootinfo.physmem_start + base + top, base + top,
    215211                    silo_ramdisk_size, -1);
    216                 memmove(base + top, (void *) ((uintptr_t) silo_ramdisk_image),
     212                memmove(base + top, (void *)((uintptr_t)silo_ramdisk_image),
    217213                    silo_ramdisk_size);
    218                
    219214                printf("done.\n");
    220215                top += silo_ramdisk_size;
    221216        }
    222217skip_ramdisk:
    223        
     218
    224219        /*
    225220         * Now we can proceed to copy the components. We do it in reverse order
     
    227222         * with base.
    228223         */
    229         printf("\nCopying tasks...");
     224        printf("\nCopying bootinfo tasks\n");
    230225        for (i = COMPONENTS - 1; i > 0; i--, j--) {
    231                 printf("%s ", components[i].name);
    232                
     226                printf(" %s...", components[i].name);
     227
    233228                /*
    234229                 * At this point, we claim the physical memory that we are
     
    245240                    bootinfo.taskmap.tasks[j].addr,
    246241                    ALIGN_UP(components[i].size, PAGE_SIZE));
    247                
    248                 memcpy((void *) bootinfo.taskmap.tasks[j].addr,
     242                   
     243                memcpy((void *)bootinfo.taskmap.tasks[j].addr,
    249244                    components[i].start, components[i].size);
    250                
    251         }
    252         printf(".\n");
    253        
     245                printf("done.\n");
     246        }
     247
    254248        printf("\nCopying kernel...");
    255249        (void) ofw_claim_phys(bootinfo.physmem_start + base,
     
    257251        memcpy(base, components[0].start, components[0].size);
    258252        printf("done.\n");
    259        
     253
    260254        /*
    261255         * Claim and map the physical memory for the boot allocator.
     
    267261        (void) ofw_map(bootinfo.physmem_start + balloc_base, balloc_base,
    268262            BALLOC_MAX_SIZE, -1);
    269         balloc_init(&bootinfo.ballocs, (uintptr_t) balloc_base,
    270             (uintptr_t) balloc_base);
    271        
     263        balloc_init(&bootinfo.ballocs, (uintptr_t)balloc_base);
     264
    272265        printf("\nCanonizing OpenFirmware device tree...");
    273266        bootinfo.ofw_root = ofw_tree_build();
    274267        printf("done.\n");
    275        
     268
    276269#ifdef CONFIG_AP
    277270        printf("\nChecking for secondary processors...");
    278         if (!ofw_cpu(mid_mask, bootinfo.physmem_start))
     271        if (!ofw_cpu())
    279272                printf("Error: unable to get CPU properties\n");
    280273        printf("done.\n");
    281274#endif
    282        
     275
    283276        ofw_setup_palette();
    284        
     277
    285278        printf("\nBooting the kernel...\n");
    286279        jump_to_kernel((void *) KERNEL_VIRTUAL_ADDRESS,
    287280            bootinfo.physmem_start | BSP_PROCESSOR, &bootinfo,
    288             sizeof(bootinfo), subarchitecture);
     281            sizeof(bootinfo));
    289282}
Note: See TracChangeset for help on using the changeset viewer.