Ignore:
Timestamp:
Jul 31, 2017, 1:59:52 PM (7 years ago)
Author:
alain
Message:

Several modifs in the generic scheduler and in the hal_context to
fix the context switch mechanism.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/bootloader_tsar/boot.c

    r279 r296  
    105105// kernel segments layout variables
    106106
    107 uint32_t                        seg_kcode_base;  // kcode segment base address
    108 uint32_t                        seg_kcode_size;  // kcode segment size (bytes)
    109 uint32_t                        seg_kdata_base;  // kdata segment base address
    110 uint32_t                        seg_kdata_size;  // kdata segment size (bytes)
    111 uint32_t                        seg_kgiet_base;  // kcode segment base address
    112 uint32_t                        seg_kgiet_size;  // kcode segment size (bytes)
     107uint32_t                        seg_kcode_base;   // kcode segment base address
     108uint32_t                        seg_kcode_size;   // kcode segment size (bytes)
     109uint32_t                        seg_kdata_base;   // kdata segment base address
     110uint32_t                        seg_kdata_size;   // kdata segment size (bytes)
     111uint32_t                        seg_kentry_base;  // kcode segment base address
     112uint32_t                        seg_kentry_size;  // kcode segment size (bytes)
    113113
    114114uint32_t                        kernel_entry;    // kernel entry point
     
    175175/**************************************************************************************
    176176 * This function loads the 'kernel.elf' file into the boot cluster memory buffer,
    177  * analyzes it, and places the three kcode, kgiet, kdata segments at their final
     177 * analyzes it, and places the three kcode, kentry, kdata segments at their final
    178178 * physical adresses (defined the .elf file).       
    179179 * It set the global variables defining the kernel layout.
     
    192192    bool_t       kcode_found;     // kcode segment found.
    193193    bool_t       kdata_found;     // kdata segment found.
    194     bool_t       kgiet_found;     // kgiet segment found.
     194    bool_t       kentry_found;    // kentry segment found.
    195195    uint32_t     seg_id;          // iterator for segments loop.
    196196
     
    231231
    232232    // loop on segments
    233     kcode_found = false;
    234     kdata_found = false;
    235     kgiet_found = false;
     233    kcode_found  = false;
     234    kdata_found  = false;
     235    kentry_found = false;
    236236    for (seg_id = 0; seg_id < segments_nb; seg_id++)
    237237    {
     
    265265
    266266            // Note: we suppose that the 'kernel.elf' file contains exactly
    267             // three loadable segments ktext, kgiet, & kdata:
    268             // - the kcode segment is read-only and base < 0x80000000
    269             // - the kgiet segment is read-only and base >= 0x8000000
     267            // three loadable segments ktext, kentry, & kdata:
     268            // - the kcode segment is read-only and base == KCODE_BASE
     269            // - the kentry segment is read-only and base == KENTRY_BASE
    270270
    271271            if( ((program_header[seg_id].p_flags & PF_W) == 0) &&
    272                  (program_header[seg_id].p_paddr < 0x80000000) )     // kcode segment
     272                 (program_header[seg_id].p_paddr == KCODE_BASE) )     // kcode segment
    273273            {
    274274                if( kcode_found )
     
    284284                seg_kcode_size = seg_memsz;
    285285            }
    286             else if( program_header[seg_id].p_paddr >= 0x80000000 ) // kgiet segment
    287             {
    288                 if( kgiet_found )
     286            else if( program_header[seg_id].p_paddr == KENTRY_BASE ) // kentry segment
     287            {
     288                if( kentry_found )
    289289                {
    290290                    boot_printf("\n[BOOT_ERROR] in %s for file %s :\n"
    291                                 "   two kgiet segments found\n",
     291                                "   two kentry segments found\n",
    292292                                __FUNCTION__ , KERNEL_PATHNAME );
    293293                    boot_exit();
    294294                }
    295295
    296                 kgiet_found     = true;
    297                 seg_kgiet_base = seg_paddr;
    298                 seg_kgiet_size = seg_memsz;
     296                kentry_found     = true;
     297                seg_kentry_base = seg_paddr;
     298                seg_kentry_size = seg_memsz;
    299299            }
    300300            else                                                    // kdata segment
     
    322322        boot_exit();
    323323    }
    324     if( kgiet_found == false )
    325     {
    326         boot_printf("\n[BOOT_ERROR] in %s for file %s : seg_kgiet not found\n",
     324    if( kentry_found == false )
     325    {
     326        boot_printf("\n[BOOT_ERROR] in %s for file %s : seg_kentry not found\n",
    327327                    __FUNCTION__ , KERNEL_PATHNAME );
    328328        boot_exit();
     
    333333                    __FUNCTION__ , KERNEL_PATHNAME );
    334334        boot_exit();
     335    }
     336
     337    // check segments sizes
     338    if( seg_kentry_size > KENTRY_MAX_SIZE )
     339    {
     340        boot_printf("\n[BOOT_ERROR] in %s for file %s : seg_kentry too large\n",
     341                    __FUNCTION__ , KERNEL_PATHNAME );
     342        boot_exit();
     343    }
     344
     345    if( (seg_kcode_size + seg_kdata_size) > KCODE_MAX_SIZE )
     346    {
     347        boot_printf("\n[BOOT_ERROR] in %s for file %s : seg_kcode + seg_kdata too large\n",
     348                    __FUNCTION__ , KERNEL_PATHNAME );
    335349    }
    336350
     
    388402
    389403    // Initialize kernel segments from global variables
    390     boot_info->kernel_code_start = seg_kcode_base;
    391     boot_info->kernel_code_end   = seg_kcode_base + seg_kcode_size;
    392     boot_info->kernel_data_start = seg_kdata_base;
    393     boot_info->kernel_data_end   = seg_kdata_base + seg_kdata_size;
     404    boot_info->kcode_base  = seg_kcode_base;
     405    boot_info->kcode_size  = seg_kcode_size;
     406    boot_info->kdata_base  = seg_kdata_base;
     407    boot_info->kdata_size  = seg_kdata_size;
     408    boot_info->kentry_base = seg_kentry_base;
     409    boot_info->kentry_size = seg_kentry_size;
    394410
    395411    // loop on arch_info clusters to get relevant pointers
     
    604620
    605621   // Get the top address of the kernel segments
    606     end = (boot_info->kernel_code_end > boot_info->kernel_data_end ) ?
    607           boot_info->kernel_code_end : boot_info->kernel_data_end;
     622    end = boot_info->kdata_base + boot_info->kdata_size;
    608623
    609624    // compute number of physical pages occupied by the kernel code
     
    611626                 (end >> CONFIG_PPM_PAGE_SHIFT) : (end >> CONFIG_PPM_PAGE_SHIFT) + 1;
    612627
    613     // set one reserved zone for giet code
    614     uint32_t first_page = seg_kgiet_base >> CONFIG_PPM_PAGE_SHIFT;
    615     uint32_t last_page  = (seg_kgiet_base + seg_kgiet_size - 1) >> CONFIG_PPM_PAGE_SHIFT;
    616 
    617     boot_info->rsvd_nr = 1;
    618     boot_info->rsvd[0].first_page = first_page;
    619     boot_info->rsvd[0].npages     = last_page - first_page + 1;
     628    // no reserved sones for TSAR architecture
     629    boot_info->rsvd_nr = 0;
    620630
    621631    // set boot_info signature
     
    697707
    698708#if DEBUG_BOOT_WAKUP
    699 boot_printf("\n[BOOT] core[%x][0] activated at cycle %d\n",
     709boot_printf("\n[BOOT] core[%x,0] activated at cycle %d\n",
    700710            cluster->cxy , boot_get_proctime );
    701711#endif
     
    726736
    727737#if DEBUG_BOOT_WAKUP
    728 boot_printf("\n[BOOT] core[%x][%d] activated at cycle %d\n",
     738boot_printf("\n[BOOT] core[%x,%d] activated at cycle %d\n",
    729739             boot_info->cxy , core_id , boot_get_proctime() );
    730740#endif
     
    754764        if (cxy == BOOT_CORE_CXY)
    755765        {
    756             boot_printf("\n[BOOT] core[%x][%d] enters at cycle %d\n",
     766            boot_printf("\n[BOOT] core[%x,%d] enters at cycle %d\n",
    757767                        cxy , lid , boot_get_proctime() );
    758768
     
    775785            boot_kernel_load();
    776786
    777             boot_printf("\n[BOOT] core[%x][%d] loaded kernel at cycle %d\n",
     787            boot_printf("\n[BOOT] core[%x,%d] loaded kernel at cycle %d\n",
    778788                        cxy , lid , boot_get_proctime() );
    779789
     
    791801            if (boot_info->signature != BOOT_INFO_SIGNATURE)
    792802            {
    793                 boot_printf("\n[BOOT ERROR] in %s reported by core[%x][%d]\n"
     803                boot_printf("\n[BOOT ERROR] in %s reported by core[%x,%d]\n"
    794804                            "  illegal boot_info signature / should be %x\n",
    795805                            __FUNCTION__ , cxy , lid , BOOT_INFO_SIGNATURE );
     
    797807            }
    798808
    799             boot_printf("\n[BOOT] core[%x][%d] loaded boot_info at cycle %d\n",
     809            boot_printf("\n[BOOT] core[%x,%d] loaded boot_info at cycle %d\n",
    800810                        cxy , lid , boot_get_proctime() );
    801811
     
    812822            // activate other local cores
    813823            boot_wake_local_cores( boot_info );
     824
     825// display address extensions
     826uint32_t cp2_data_ext;
     827uint32_t cp2_ins_ext;
     828asm volatile( "mfc2   %0,  $24" : "=&r" (cp2_data_ext) );
     829asm volatile( "mfc2   %0,  $25" : "=&r" (cp2_ins_ext) );
     830boot_printf("\n[BOOT] core[%x,%d] CP2_DATA_EXT = %x / CP2_INS_EXT = %x\n",
     831            cxy , lid , cp2_data_ext , cp2_ins_ext );
    814832
    815833            // Wait until all local cores in cluster ready
     
    832850
    833851            // from now, it is safe to refer to the boot code global variables
    834             boot_printf("\n[BOOT] core[%x][%d] replicated boot code at cycle %d\n",
     852            boot_printf("\n[BOOT] core[%x,%d] replicated boot code at cycle %d\n",
    835853                        cxy , lid , boot_get_proctime() );
    836854
    837             // switch to the INSTRUCTION local memory space, to avoid contention.
     855                        // switch to the INSTRUCTION local memory space, to avoid contention.
    838856            asm volatile("mtc2  %0, $25" :: "r"(cxy));
    839857
     
    843861                               ARCHINFO_MAX_SIZE );
    844862
    845             boot_printf("\n[BOOT] core[%x][%d] replicated arch_info at cycle %d\n",
     863            boot_printf("\n[BOOT] core[%x,%d] replicated arch_info at cycle %d\n",
    846864                        cxy , lid , boot_get_proctime() );
    847865
     
    856874                                seg_kdata_size );
    857875
    858             boot_printf("\n[BOOT] core[%x][%d] replicated kernel code at cycle %d\n",
     876            boot_printf("\n[BOOT] core[%x,%d] replicated kernel code at cycle %d\n",
    859877                        cxy , lid , boot_get_proctime() );
    860878
     
    876894            // activate other local cores
    877895            boot_wake_local_cores( boot_info );
     896
     897// display address extensions
     898uint32_t cp2_data_ext;
     899uint32_t cp2_ins_ext;
     900asm volatile( "mfc2   %0,  $24" : "=&r" (cp2_data_ext) );
     901asm volatile( "mfc2   %0,  $25" : "=&r" (cp2_ins_ext) );
     902boot_printf("\n[BOOT] core[%x,%d] CP2_DATA_EXT = %x / CP2_INS_EXT = %x\n",
     903            cxy , lid , cp2_data_ext , cp2_ins_ext );
    878904
    879905            // Wait until all local cores in cluster ready
     
    897923        // Check core information
    898924        boot_check_core(boot_info, lid);
     925
     926// display address extensions
     927uint32_t cp2_data_ext;
     928uint32_t cp2_ins_ext;
     929asm volatile( "mfc2   %0,  $24" : "=&r" (cp2_data_ext) );
     930asm volatile( "mfc2   %0,  $25" : "=&r" (cp2_ins_ext) );
     931boot_printf("\n[BOOT] core[%x,%d] CP2_DATA_EXT = %x / CP2_INS_EXT = %x\n",
     932            cxy , lid , cp2_data_ext , cp2_ins_ext );
    899933
    900934        // Wait until all local cores in cluster ready
     
    911945    uint32_t pmask  = CONFIG_PPM_PAGE_MASK;
    912946    uint32_t psize  = CONFIG_PPM_PAGE_SIZE;
     947
    913948
    914949    // compute base address of idle thread descriptors array
     
    927962                  "ori   $26,  $26,  0xFFFF  \n"
    928963                  "and   $27,  $27,  $26     \n"
    929                   "mtc0  $27,  $12           \n" 
     964                  "mtc0  $27,  $12           \n"
    930965                  "move  $4,   %0            \n"
    931966                  "move  $29,  %1            \n"
Note: See TracChangeset for help on using the changeset viewer.