Ignore:
Timestamp:
Oct 5, 2018, 12:20:34 AM (3 years ago)
Author:
alain
Message:

Introduce the cluster_info[x][y] in the boot_info.h structure for the TSAR architecture.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/boot/tsar_mips32/boot.c

    r562 r572  
    22 * boot.c - TSAR bootloader implementation.
    33 *
    4  * Authors :   Alain Greiner / Vu Son  (2016)
     4 * Authors :   Vu Son  (2016)
     5 *             Alain Greiner (2016, 2017,2018)
    56 *
    67 * Copyright (c) UPMC Sorbonne Universites
     
    5556 *      - activate all other cores in the same cluster (CPi).               *
    5657 *      - wait local CPi completion reports on a local barrier.             *
    57  *      - report completion to bscpu on the global barrier.                 *
     58 *      - report completion  on the global barrier.                         *
    5859 *                                                                          *
    5960 * 3) The boot-loader third phase is executed in parallel by all cores.     *
    60  *    After passing the global barrier the bscpu:                           *
    61  *      - activates the CPi of cluster(0),                                  *
     61 *    In each cluster (i) the CP0                                           *
     62 *      - activates the other cores of cluster(i),                          *
    6263 *      - blocks on the local barrier waiting for all local CPi to report   *
    6364 *        completion on the local barrier,                                  *
     
    6566 *        address 0x0, (erasing the preloader code).                        *
    6667 *                                                                          *
    67  * 4) All cores have finished the boot phase, they jump to the kern_init()  *
    68  *    function (maybe not at the same time).                                *
     68 * 4) All cores jump to kern_init() (maybe not at the same time).           *
    6969 ****************************************************************************/
    7070
     
    7777#include <arch_info.h>
    7878#include <boot_info.h>
    79 
    80 #include <cluster_info.h>
    8179
    8280#include <boot_utils.h>
     
    8482#include <boot_bdv_driver.h>
    8583#include <boot_hba_driver.h>
    86 #include <boot_spi_driver.h>
    8784#include <boot_tty_driver.h>
    8885
     
    117114uint32_t                        kernel_entry;    // kernel entry point
    118115
    119 // address used by the WTI to activate remote CP0s
    120 
    121 // Functions called by boot_entry.S must be externs.
     116// Functions called by boot_entry.S
     117
    122118extern void boot_entry( void );    // boot_loader entry point
    123119extern void boot_loader( lid_t lid, cxy_t cxy );
    124120
     121
     122#if DEBUG_BOOT_INFO
    125123/*********************************************************************************
    126  * This function returns the printable string for each device type
     124 * This debug function returns the printable string for each device type.
    127125 ********************************************************************************/
    128 static const char * device_type_str( boot_device_types_t dev_type ) {
    129     switch (dev_type) {
     126static char * device_type_str( enum device_types_e dev_type )
     127{
     128    switch ( dev_type )
     129    {
    130130        case DEV_TYPE_RAM_SCL: return "RAM_SCL";
    131131        case DEV_TYPE_ROM_SCL: return "ROM_SCL";
     
    148148    }
    149149}
     150#endif
    150151
    151152/************************************************************************************
     
    160161    {
    161162        boot_printf("\n[BOOT ERROR]: boot_archinfo_load(): "
    162                     "<%s> file not found\n",
    163                     ARCHINFO_PATHNAME);
     163        "<%s> file not found\n",
     164        ARCHINFO_PATHNAME);
    164165        boot_exit();
    165166    }
     
    168169    {
    169170        boot_printf("\n[BOOT_ERROR]: boot_archinfo_load(): "
    170                     "<%s> file signature should be %x\n",
    171                     ARCHINFO_PATHNAME, ARCHINFO_SIGNATURE);
     171        "<%s> file signature should be %x\n",
     172        ARCHINFO_PATHNAME, ARCHINFO_SIGNATURE);
    172173        boot_exit();
    173174    }
     
    175176#if DEBUG_BOOT_INFO
    176177boot_printf("\n[BOOT INFO] in %s : file %s loaded at address = %x\n",
    177             __FUNCTION__ , ARCHINFO_PATHNAME , ARCHINFO_BASE );
     178__FUNCTION__ , ARCHINFO_PATHNAME , ARCHINFO_BASE );
    178179#endif
    179180
     
    204205#if DEBUG_BOOT_ELF
    205206boot_printf("\n[BOOT INFO] %s enters for file %s at cycle %d\n",
    206             __FUNCTION__ , KERNEL_PATHNAME , boot_get_proctime() );
     207__FUNCTION__ , KERNEL_PATHNAME , boot_get_proctime() );
    207208#endif
    208209
     
    261262#if DEBUG_BOOT_ELF
    262263boot_printf("\n[BOOT INFO] in %s for file %s : found loadable segment\n"
    263             "   base = %x / size = %x\n",
    264             __FUNCTION__ , KERNEL_PATHNAME , seg_paddr , seg_memsz );
     264"   base = %x / size = %x\n",
     265__FUNCTION__ , KERNEL_PATHNAME , seg_paddr , seg_memsz );
    265266#endif
    266267
     
    282283                {
    283284                    boot_printf("\n[BOOT_ERROR] in %s for file %s :\n"
    284                                 "   two kcode segments found\n",
    285                                 __FUNCTION__ , KERNEL_PATHNAME );
     285                    "   two kcode segments found\n",
     286                    __FUNCTION__ , KERNEL_PATHNAME );
    286287                    boot_exit();
    287288                }
     
    296297                {
    297298                    boot_printf("\n[BOOT_ERROR] in %s for file %s :\n"
    298                                 "   two kentry segments found\n",
    299                                 __FUNCTION__ , KERNEL_PATHNAME );
     299                    "   two kentry segments found\n",
     300                    __FUNCTION__ , KERNEL_PATHNAME );
    300301                    boot_exit();
    301302                }
     
    310311                {
    311312                    boot_printf("\n[BOOT_ERROR] in %s for file %s :\n"
    312                                 "   two loadable kdata segments found\n",
    313                                 __FUNCTION__ , KERNEL_PATHNAME );
     313                    "   two kdata segments found\n",
     314                    __FUNCTION__ , KERNEL_PATHNAME );
    314315                    boot_exit();
    315316                }
     
    326327    {
    327328        boot_printf("\n[BOOT_ERROR] in %s for file %s : seg_kcode not found\n",
    328                     __FUNCTION__ , KERNEL_PATHNAME );
     329        __FUNCTION__ , KERNEL_PATHNAME );
    329330        boot_exit();
    330331    }
     
    332333    {
    333334        boot_printf("\n[BOOT_ERROR] in %s for file %s : seg_kentry not found\n",
    334                     __FUNCTION__ , KERNEL_PATHNAME );
     335        __FUNCTION__ , KERNEL_PATHNAME );
    335336        boot_exit();
    336337    }
     
    338339    {
    339340        boot_printf("\n[BOOT_ERROR] in %s for file %s : seg_kdata not found\n",
    340                     __FUNCTION__ , KERNEL_PATHNAME );
     341        __FUNCTION__ , KERNEL_PATHNAME );
    341342        boot_exit();
    342343    }
     
    346347    {
    347348        boot_printf("\n[BOOT_ERROR] in %s for file %s : seg_kentry too large\n",
    348                     __FUNCTION__ , KERNEL_PATHNAME );
     349        __FUNCTION__ , KERNEL_PATHNAME );
    349350        boot_exit();
    350351    }
     
    353354    {
    354355        boot_printf("\n[BOOT_ERROR] in %s for file %s : seg_kcode + seg_kdata too large\n",
    355                     __FUNCTION__ , KERNEL_PATHNAME );
     356        __FUNCTION__ , KERNEL_PATHNAME );
    356357    }
    357358
     
    361362#if DEBUG_BOOT_ELF
    362363boot_printf("\n[BOOT INFO] %s completed for file %s at cycle %d\n",
    363             __FUNCTION__ , KERNEL_PATHNAME , boot_get_proctime() );
     364__FUNCTION__ , KERNEL_PATHNAME , boot_get_proctime() );
    364365#endif
    365366
     
    382383    archinfo_cluster_t * cluster;
    383384    archinfo_cluster_t * my_cluster = NULL;   // target cluster
    384     archinfo_cluster_t * io_cluster = NULL;   // cluster containing ext. peripherals
     385    archinfo_cluster_t * io_cluster = NULL;   // external peripherals cluster
    385386
    386387    archinfo_core_t    * core;
     
    416417    boot_info->kentry_size = seg_kentry_size;
    417418
    418     /* Initialize all clusters as empty for now */
    419     int x, y;
    420     for ( x = 0; x < CONFIG_MAX_CLUSTERS_X; x++)
    421     {
    422         for ( x = 0; x < CONFIG_MAX_CLUSTERS_X; x++)
    423         {
    424             boot_info->cluster_info[x][y] = 0x0;
    425         }
    426     }
    427 
    428     // loop on arch_info clusters to get relevant pointers
     419    // loop on arch_info clusters to build cluster_info[][] array
     420    // and get io_cluster and my_cluster pointers
    429421    for (cluster =  cluster_base;
    430422         cluster < &cluster_base[header->x_size * header->y_size];
     
    433425        int x = cluster->cxy >> Y_WIDTH;
    434426        int y = cluster->cxy & ((1 << Y_WIDTH) - 1);
    435 
    436         if( cluster->cxy  == cxy )            my_cluster = cluster;
    437         if( cluster->cxy  == header->io_cxy ) {
    438             io_cluster = cluster;
    439             boot_info->cluster_info[x][y] |= CINFO_IS_IO;
    440         }
    441         if ( cluster->cores > 0 ) {
    442             boot_info->cluster_info[x][y] |= CINFO_ACTIVE;
    443         }
     427        boot_info->cluster_info[x][y] = (uint8_t)cluster->cores;
     428
     429        if( cluster->cxy == cxy )            my_cluster = cluster;
     430        if( cluster->cxy == header->io_cxy ) io_cluster = cluster;
    444431    }
    445432
     
    447434    {
    448435        boot_printf("\n[ERROR] in %s : cannot found cluster %x in arch_info\n",
    449                     __FUNCTION__ , cxy );
     436        __FUNCTION__ , cxy );
    450437        boot_exit();
    451438    }
     
    454441    {
    455442        boot_printf("\n[ERROR] in %s : cannot found io_cluster %x in arch_info\n",
    456                     __FUNCTION__ , header->io_cxy );
     443        __FUNCTION__ , cxy );
    457444        boot_exit();
    458445    }
     
    463450#if DEBUG_BOOT_INFO
    464451boot_printf("\n[BOOT INFO] %s : external peripherals at cycle %d\n",
    465             __FUNCTION__ , boot_get_proctime() );
     452__FUNCTION__ , boot_get_proctime() );
    466453#endif
    467454
     
    474461        {
    475462            boot_printf("\n[ERROR] in %s : too much external devices in arch_info\n",
    476                         __FUNCTION__ );
     463            __FUNCTION__ );
    477464            boot_exit();
    478465        }
     
    501488#if DEBUG_BOOT_INFO
    502489boot_printf("  - %s : base = %l / size = %l / channels = %d / irqs = %d\n",
    503             device_type_str( device->type ) , device->base , device->size ,
    504             device->channels , device->irqs );   
     490device_type_str(device->type), device->base, device->size, device->channels, device->irqs );
    505491#endif
    506492        }
     
    525511#if DEBUG_BOOT_INFO
    526512boot_printf("    . irq_port = %d / source = %s / channel = %d / is_rx = %d\n",
    527             irq->port , device_type_str( irq->dev_type ) , irq->channel , irq->is_rx );
     513irq->port , device_type_str( irq->dev_type ) , irq->channel , irq->is_rx );
    528514#endif
    529515            }
     
    554540#if DEBUG_BOOT_INFO
    555541boot_printf("  - core_gid = %x : cxy = %x / lid = %d\n",
    556             core->gid , core->cxy , core->lid );
     542core->gid , core->cxy , core->lid );
    557543#endif
    558544        core_id++;
     
    566552
    567553#if DEBUG_BOOT_INFO
    568 boot_printf("\n[BOOT INFO] %s : internal peripherals in cluster %x\n", __FUNCTION__ , cxy );
     554boot_printf("\n[BOOT INFO] %s : internal peripherals in cluster %x\n",
     555__FUNCTION__ , cxy );
    569556#endif
    570557
     
    615602#if DEBUG_BOOT_INFO
    616603boot_printf("  - %s : base = %l / size = %l / channels = %d / irqs = %d\n",
    617             device_type_str( device->type ) , device->base , device->size ,
    618             device->channels , device->irqs );   
     604device_type_str( device->type ) , device->base , device->size ,
     605device->channels , device->irqs );   
    619606#endif
    620607
     
    637624#if DEBUG_BOOT_INFO
    638625boot_printf("    . irq_port = %d / source = %s / channel = %d / is_rx = %d\n",
    639             irq->port , device_type_str( irq->dev_type ) , irq->channel , irq->is_rx );
     626irq->port , device_type_str( irq->dev_type ) , irq->channel , irq->is_rx );
    640627#endif
    641628
     
    656643                 (end >> CONFIG_PPM_PAGE_SHIFT) : (end >> CONFIG_PPM_PAGE_SHIFT) + 1;
    657644
    658     // no reserved sones for TSAR architecture
     645    // no reserved zones for TSAR architecture
    659646    boot_info->rsvd_nr = 0;
    660647
     
    738725#if DEBUG_BOOT_WAKUP
    739726boot_printf("\n[BOOT] core[%x,0] activated at cycle %d\n",
    740             cluster->cxy , boot_get_proctime );
     727cluster->cxy , boot_get_proctime );
    741728#endif
    742729
     
    767754#if DEBUG_BOOT_WAKUP
    768755boot_printf("\n[BOOT] core[%x,%d] activated at cycle %d\n",
    769              boot_info->cxy , core_id , boot_get_proctime() );
     756boot_info->cxy , core_id , boot_get_proctime() );
    770757#endif
    771758        // send an IPI
     
    801788            else if (USE_IOC_HBA) boot_hba_init();
    802789            // else if (USE_IOC_SDC) boot_sdc_init();
    803             else if (USE_IOC_SPI) boot_spi_init();
     790            // else if (USE_IOC_SPI) boot_spi_init();
    804791            else if (!USE_IOC_RDK)
    805792            {
     
    816803
    817804            boot_printf("\n[BOOT] core[%x,%d] loaded kernel at cycle %d\n",
    818                         cxy , lid , boot_get_proctime() );
     805            cxy , lid , boot_get_proctime() );
    819806
    820807            // Load the arch_info.bin file into memory.
    821808            boot_archinfo_load();
     809
     810            boot_printf("\n[BOOT] core[%x,%d] loaded arch_info at cycle %d\n",
     811            cxy , lid , boot_get_proctime() );
    822812
    823813            // Get local boot_info_t structure base address.
     
    827817            // Initialize local boot_info_t structure.
    828818            boot_info_init( boot_info , cxy );
     819
     820            boot_printf("\n[BOOT] core[%x,%d] initialised boot_info at cycle %d\n",
     821            cxy , lid , boot_get_proctime() );
    829822
    830823            // check boot_info signature
     
    832825            {
    833826                boot_printf("\n[BOOT ERROR] in %s reported by core[%x,%d]\n"
    834                             "  illegal boot_info signature / should be %x\n",
    835                             __FUNCTION__ , cxy , lid , BOOT_INFO_SIGNATURE );
     827                "  illegal boot_info signature / should be %x\n",
     828                __FUNCTION__ , cxy , lid , BOOT_INFO_SIGNATURE );
    836829                boot_exit();
    837830            }
    838 
    839             boot_printf("\n[BOOT] core[%x,%d] loaded arch_info at cycle %d\n",
    840                         cxy , lid , boot_get_proctime() );
    841831
    842832            // Check core information.
     
    881871            // from now, it is safe to refer to the boot code global variables
    882872            boot_printf("\n[BOOT] core[%x,%d] replicated boot code at cycle %d\n",
    883                         cxy , lid , boot_get_proctime() );
     873            cxy , lid , boot_get_proctime() );
    884874
    885875                        // switch to the INSTRUCTION local memory space, to avoid contention.
     
    892882
    893883            boot_printf("\n[BOOT] core[%x,%d] replicated arch_info at cycle %d\n",
    894                         cxy , lid , boot_get_proctime() );
     884            cxy , lid , boot_get_proctime() );
    895885
    896886            // Copy the kcode segment into local memory
     
    910900
    911901            boot_printf("\n[BOOT] core[%x,%d] replicated kernel code at cycle %d\n",
    912                         cxy , lid , boot_get_proctime() );
     902            cxy , lid , boot_get_proctime() );
    913903
    914904            // Get local boot_info_t structure base address.
     
    917907            // Initialize local boot_info_t structure.
    918908            boot_info_init( boot_info , cxy );
     909
     910            boot_printf("\n[BOOT] core[%x,%d] initialised boot_info at cycle %d\n",
     911            cxy , lid , boot_get_proctime() );
    919912
    920913            // Check core information.
Note: See TracChangeset for help on using the changeset viewer.