Changeset 296 for trunk/tools


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.

Location:
trunk/tools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/arch_info/boot_info.h

    r219 r296  
    135135    // kernel segments
    136136
    137     intptr_t      kernel_code_start;             /*! kernel code base paddr                 */
    138     intptr_t      kernel_code_end;               /*! kernel code last paddr (excluded)      */
    139     intptr_t      kernel_data_start;             /*! kernel data base paddr                 */
    140     intptr_t      kernel_data_end;               /*! kernel data last paddr (excluded)      */
     137    reg_t         kcode_base;                    /*! kernel code base paddr                 */
     138    reg_t         kcode_size;                    /*! kernel code size                       */
     139    reg_t         kdata_base;                    /*! kernel data base paddr                 */
     140    reg_t         kdata_size;                    /*! kernel data size                       */
     141    reg_t         kentry_base;                   /*! kernel entry base paddr                */
     142    reg_t         kentry_size;                   /*! kernel entry size                      */
    141143}
    142144boot_info_t;
  • 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"
  • trunk/tools/bootloader_tsar/boot_config.h

    r68 r296  
    2020
    2121// Preloader temporary segment
    22 #define PRELOADER_BASE      0x0             /* Preloader base address.      */
    23 #define PRELOADER_MAX_SIZE  0x4000          /* Preloader max size.          */
     22#define PRELOADER_BASE      0x00000000      // 'preloader' physical base address
     23#define PRELOADER_MAX_SIZE  0x00004000      // 'preloader' max size
    2424
    25 // boot code temporary segment
    26 #define BOOT_BASE           0x100000        /* 'boot.elf' base address.     */
    27 #define BOOT_MAX_SIZE       0x010000        /* 'boot.elf' max size.         */
     25// kentry segment
     26#define KENTRY_BASE         0x00004000      // 'kentry' segment physical base address       
     27#define KENTRY_MAX_SIZE     0X00004000      // 'kentry' segment max size
    2828
    29 // arch_info temporary segment
    30 #define ARCHINFO_BASE       0x200000        /* 'arch_info.bin' file base address */
    31 #define ARCHINFO_MAX_SIZE   0x010000        /* 'arch_info.bin' file max size.    */
     29// kcode segment
     30#define KCODE_BASE          0x00008000      // 'kcode' segment physical base address
     31#define KCODE_MAX_SIZE      0x000F8000      // 'kcode' + 'kdata' segments max size
    3232
    33 // kernel code temporary segment
    34 #define KERN_BASE           0x300000        /* 'kernel.elf' file base address    */
    35 #define KERN_MAX_SIZE       0x200000        /* 'kernel.elf' file max size.       */
     33// boot.elf file temporary buffer
     34#define BOOT_BASE           0x00100000      // 'boot.elf' file physical base address   
     35#define BOOT_MAX_SIZE       0x00010000      // 'boot.elf' file max size
     36
     37// arch_info file temporary buffer
     38#define ARCHINFO_BASE       0x00200000      // 'arch_info.bin' file physical base address
     39#define ARCHINFO_MAX_SIZE   0x00010000      // 'arch_info.bin' file max size
     40
     41// kernel.elf file temporary buffer
     42#define KERN_BASE           0x00300000      // 'kernel.elf' file base address
     43#define KERN_MAX_SIZE       0x00200000      // 'kernel.elf' file max size
    3644
    3745// Temporary stacks segments
    38 #define BOOT_STACK_BASE     0x504000        /* Boot stack base address.     */
    39 #define BOOT_STACK_SIZE     0x4000          /* Boot stack size (16Kb)       */
     46#define BOOT_STACK_BASE     0x00504000      // Boot stack base address
     47#define BOOT_STACK_SIZE     0x00004000      // Boot stack size (16Kb)
     48
     49
    4050
    4151#endif  // _BOOT_CONFIG_H
  • trunk/tools/bootloader_tsar/boot_entry.S

    r6 r296  
    2222 */
    2323
    24 /*************************************************************************************************
    25  * This file contains the entry point of the ALMOS-MK boot-loader for TSAR architecture.         *
    26  * It supports a generic multi-clusters / multi-processors architecture                          *
    27  *                                                                                               *
    28  * - The number of clusters is defined by the (X_SIZE, Y_SIZE) parameters in the                 *
    29  *   hard_config.h file (up to 256 clusters).                                                    *
    30  * - The number of processors per cluster is defined by the NB_PROCS_MAX parameter in the        *
    31  *   hard_config.h file (up to 4 processors per cluster).                                        *
    32  *                                                                                               *
    33  * This assembly code is executed by all cores. It has 2 versions (in order to see if the        *
    34  * contention created by the ARCHINFO core descriptor table scanning loops is acceptable):       *
    35  * with or without the assumption that the core hardware identifier gid has a fixed format:      *
    36  *                                                                                               *
    37  * - Version with fixed format: gid == (((x << Y_WIDTH) + y) << PADDR_WIDTH) + lid               *
    38  *   It does 3 things:                                                                           *
    39  *      + It initializes the stack pointer depending on the lid extracted from the gid,          *
    40  *        using the BOOT_STACK_BASE and BOOT_STACK_SIZE parameters defined in the                *
    41  *        'boot_config.h' file,                                                                  *
    42  *      + It changes the value of the address extension registers using the cxy extracted        *
    43  *        from the gid,                                                                          *
    44  *      + It jumps to the boot_loader() function defined in the 'boot.c' file and passes 2       *
    45  *        arguments which are the cxy and lid of each core to this function.                     *
    46  *                                                                                               *
    47  * - Version without fixed format                                                                *
    48  *   It has to perform an additional step in order to extract the (cxy,lid) values from the      *
    49  *   arch_info.bin structure that has been loaded in the cluster (0,0) memory by the bscpu.      *
    50  *      + Each core other than the bscpu scans the core descriptor table in the arch_info.bin    *
    51  *        structure to make an associative search on the (gid), and get the (cxy,lid).           *
    52  *      + It initializes the stack pointer depending on the lid, using the BOOT_STACK_BASE       *
    53  *        and BOOT_STACK_SIZE parameters defined in the 'boot_config.h' file,                    *
    54  *      + It changes the value of the address extension registers using cxy obtained             *
    55  *        previously,                                                                            *
    56  *      + It jumps to the boot_loader() function defined in the 'boot.c' file and passes 2       *
    57  *        arguments which are the cxy and lid of each core to this function.                     *
    58  *************************************************************************************************/
     24/**********************************************************************************************
     25 * This file contains the entry point of the ALMOS-MK boot-loader for TSAR architecture.      *
     26 * It supports a generic multi-clusters / multi-processors architecture                       *
     27 *                                                                                            *
     28 * - The number of clusters is defined by the (X_SIZE, Y_SIZE) parameters in the              *
     29 *   hard_config.h file (up to 256 clusters).                                                 *
     30 * - The number of processors per cluster is defined by the NB_PROCS_MAX parameter in the     *
     31 *   hard_config.h file (up to 4 processors per cluster).                                     *
     32 *                                                                                            *
     33 * This assembly code is executed by all cores. It has 2 versions (in order to see if the     *
     34 * contention created by the ARCHINFO core descriptor table scanning loops is acceptable):    *
     35 * with or without the assumption that the core hardware identifier gid has a fixed format:   *
     36 *                                                                                            *
     37 * - Version with fixed format: gid == (((x << Y_WIDTH) + y) << PADDR_WIDTH) + lid            *
     38 *   It does 3 things:                                                                        *
     39 *      + It initializes the stack pointer depending on the lid extracted from the gid,       *
     40 *        using the BOOT_STACK_BASE and BOOT_STACK_SIZE parameters defined in the             *
     41 *        'boot_config.h' file,                                                               *
     42 *      + It changes the value of the address extension registers using the cxy extracted     *
     43 *        from the gid,                                                                       *
     44 *      + It jumps to the boot_loader() function defined in the 'boot.c' file and passes 2    *
     45 *        arguments which are the cxy and lid of each core to this function.                  *
     46 *                                                                                            *
     47 * - Version without fixed format                                                             *
     48 *   It has to perform an additional step in order to extract the (cxy,lid) values from the   *
     49 *   arch_info.bin structure that has been loaded in the cluster (0,0) memory by the bscpu.   *
     50 *      + Each core other than the bscpu scans the core descriptor table in the arch_info.bin *
     51 *        structure to make an associative search on the (gid), and get the (cxy,lid).        *
     52 *      + It initializes the stack pointer depending on the lid, using the BOOT_STACK_BASE    *
     53 *        and BOOT_STACK_SIZE parameters defined in the 'boot_config.h' file,                 *
     54 *      + It changes the value of the address extension registers using cxy obtained          *
     55 *        previously,                                                                         *
     56 *      + It jumps to the boot_loader() function defined in the 'boot.c' file and passes 2    *
     57 *        arguments which are the cxy and lid of each core to this function.                  *
     58 *********************************************************************************************/
    5959
    6060#include "mips32_registers.h"
Note: See TracChangeset for help on using the changeset viewer.