Changeset 819 for soft


Ignore:
Timestamp:
Apr 28, 2016, 1:12:26 PM (8 years ago)
Author:
cfuguet
Message:

Add a preprocessor flag which allows to inhibit the use of the
GLOBAL bit in page table entries.

Location:
soft/giet_vm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_boot/boot.c

    r791 r819  
    405405    // The three flags (Local, Remote and Dirty) are set to 1
    406406    // to avoid hardware update for these flags, because GIET_VM
    407     // does use these flags.
     407    // does not use these flags.
    408408    unsigned int flags = 0;
    409409    if (vseg->mode & C_MODE_MASK) flags |= PTE_C;
     
    411411    if (vseg->mode & W_MODE_MASK) flags |= PTE_W;
    412412    if (vseg->mode & U_MODE_MASK) flags |= PTE_U;
    413     if ( global )                 flags |= PTE_G;
    414413                                  flags |= PTE_L;
    415414                                  flags |= PTE_R;
    416415                                  flags |= PTE_D;
     416
     417#if GIET_USE_MMU_GLOBAL_FLAG
     418    if ( global ) flags |= PTE_G;
     419#endif
    417420
    418421    // compute VPN, PPN and number of pages (big or small)
     
    849852//              idle_thread context, the  HWI / PTI / WTI interrupt vectors,
    850853//              and the XCU HWI / PTI / WTI masks.
    851 // - In Step 2, it scan all threads in all vspaces to complete the threads contexts, 
     854// - In Step 2, it scan all threads in all vspaces to complete the threads contexts,
    852855//              initialisation as specified in the mapping_info data structure,
    853 //              and set the CP0_SCHED register. 
     856//              and set the CP0_SCHED register.
    854857////////////////////////////////////////////////////////////////////////////////////
    855 void boot_scheduler_init( unsigned int x, 
     858void boot_scheduler_init( unsigned int x,
    856859                          unsigned int y )
    857860{
     
    864867    mapping_irq_t*       irq     = _get_irq_base(header);
    865868
    866     unsigned int         periph_id; 
     869    unsigned int         periph_id;
    867870    unsigned int         irq_id;
    868871    unsigned int         vspace_id;
    869872    unsigned int         vseg_id;
    870     unsigned int         thread_id; 
    871 
    872     unsigned int         sched_vbase;          // schedulers array vbase address 
     873    unsigned int         thread_id;
     874
     875    unsigned int         sched_vbase;          // schedulers array vbase address
    873876    unsigned int         sched_length;         // schedulers array length
    874877    static_scheduler_t*  psched;               // pointer on processor scheduler
    875878
    876879    unsigned int cluster_id = (x * Y_SIZE) + y;
    877     unsigned int cluster_xy = (x << Y_WIDTH) + y; 
     880    unsigned int cluster_xy = (x << Y_WIDTH) + y;
    878881    unsigned int nprocs = cluster[cluster_id].procs;
    879     unsigned int lpid;                       
    880    
     882    unsigned int lpid;
     883
    881884    if ( nprocs > 8 )
    882885    {
     
    886889
    887890    ////////////////////////////////////////////////////////////////////////////////
    888     // Step 1 : - initialize the schedulers[] array of pointers, 
    889     //          - initialize the "threads" and "current variables. 
     891    // Step 1 : - initialize the schedulers[] array of pointers,
     892    //          - initialize the "threads" and "current variables.
    890893    //          - initialise the idle_thread context.
    891894    //          - initialize the HWI, PTI and WTI interrupt vectors.
    892895    //          - initialize the XCU masks for HWI / WTI / PTI interrupts.
    893896    //
    894     // The general policy for interrupts routing is the following:         
     897    // The general policy for interrupts routing is the following:
    895898    //          - the local HWI are statically allocatedted to local processors.
    896899    //          - the nprocs first PTI are allocated for TICK (one per processor).
     
    955958    unsigned int wti_mask[8] = {0,0,0,0,0,0,0,0};
    956959
    957     // scan local peripherals to get and check local XCU 
     960    // scan local peripherals to get and check local XCU
    958961    mapping_periph_t*  xcu = NULL;
    959962    unsigned int       min = cluster[cluster_id].periph_offset ;
     
    962965    for ( periph_id = min ; periph_id < max ; periph_id++ )
    963966    {
    964         if( periph[periph_id].type == PERIPH_TYPE_XCU ) 
     967        if( periph[periph_id].type == PERIPH_TYPE_XCU )
    965968        {
    966969            xcu = &periph[periph_id];
     
    996999            }
    9971000        }
    998     } 
     1001    }
    9991002
    10001003    if ( xcu == NULL )
    1001     {         
     1004    {
    10021005        _printf("\n[BOOT ERROR] missing XCU in cluster[%d,%d]\n", x , y );
    10031006        _exit();
     
    10051008
    10061009    // HWI interrupt vector definition
    1007     // scan HWI connected to local XCU 
     1010    // scan HWI connected to local XCU
    10081011    // for round-robin allocation to local processors
    10091012    lpid = 0;
     
    10291032        hwi_mask[lpid] = hwi_mask[lpid] | (1<<srcid);
    10301033
    1031         lpid = (lpid + 1) % nprocs; 
     1034        lpid = (lpid + 1) % nprocs;
    10321035    } // end for irqs
    10331036
     
    10571060    }
    10581061
    1059     // set the XCU masks for HWI / WTI / PTI interrupts 
     1062    // set the XCU masks for HWI / WTI / PTI interrupts
    10601063    for ( lpid = 0 ; lpid < nprocs ; lpid++ )
    10611064    {
    1062         unsigned int channel = lpid * IRQ_PER_PROCESSOR; 
    1063 
    1064         _xcu_set_mask( cluster_xy, channel, hwi_mask[lpid], IRQ_TYPE_HWI ); 
     1065        unsigned int channel = lpid * IRQ_PER_PROCESSOR;
     1066
     1067        _xcu_set_mask( cluster_xy, channel, hwi_mask[lpid], IRQ_TYPE_HWI );
    10651068        _xcu_set_mask( cluster_xy, channel, wti_mask[lpid], IRQ_TYPE_WTI );
    10661069        _xcu_set_mask( cluster_xy, channel, pti_mask[lpid], IRQ_TYPE_PTI );
     
    10791082    // Step 2 : Initialise the threads context. The context of a thread placed
    10801083    //          on  processor P must be stored in the scheduler of P.
    1081     //          For each vspace, this require two nested loops: loop on the threads, 
    1082     //          and loop on the local processors in cluster[x,y]. 
     1084    //          For each vspace, this require two nested loops: loop on the threads,
     1085    //          and loop on the local processors in cluster[x,y].
    10831086    //          We complete the scheduler when the required placement matches
    10841087    //          the local processor.
    10851088    ///////////////////////////////////////////////////////////////////////////////
    10861089
    1087     for (vspace_id = 0; vspace_id < header->vspaces; vspace_id++) 
    1088     {
    1089         // We must set the PTPR depending on the vspace, because the start_vector 
     1090    for (vspace_id = 0; vspace_id < header->vspaces; vspace_id++)
     1091    {
     1092        // We must set the PTPR depending on the vspace, because the start_vector
    10901093        // and the stack address are defined in virtual space.
    10911094        _set_mmu_ptpr( (unsigned int)(_ptabs_paddr[vspace_id][x][y] >> 13) );
     
    10941097        for (thread_id = vspace[vspace_id].thread_offset;
    10951098             thread_id < (vspace[vspace_id].thread_offset + vspace[vspace_id].threads);
    1096              thread_id++) 
     1099             thread_id++)
    10971100        {
    10981101            // get the required thread placement coordinates [x,y,p]
    10991102            unsigned int req_x      = cluster[thread[thread_id].clusterid].x;
    11001103            unsigned int req_y      = cluster[thread[thread_id].clusterid].y;
    1101             unsigned int req_p      = thread[thread_id].proclocid;                 
     1104            unsigned int req_p      = thread[thread_id].proclocid;
     1105
     1106            // skip this thread if it is allocated to another cluster
     1107            if ( ( req_x != x ) || ( req_y != y ) ) continue;
     1108
     1109            if ( req_p >= NB_PROCS_MAX )
     1110            {
     1111                _printf("\n[BOOT ERROR] Bad allocation of thread %s from vspace %s\n",
     1112                        thread[thread_id].name,
     1113                        vspace[vspace_id].name);
     1114                _exit();
     1115            }
    11021116
    11031117            // ctx_norun : two conditions to activate a thread
     
    11171131
    11181132            // ctx_entry : Get the virtual address of the memory location containing
    1119             // the thread entry point : the start_vector is stored by GCC in the 
    1120             // seg_data segment, and we must wait the application.elf loading to get 
     1133            // the thread entry point : the start_vector is stored by GCC in the
     1134            // seg_data segment, and we must wait the application.elf loading to get
    11211135            // the entry point value...
    1122             vseg_id = vspace[vspace_id].start_vseg_id;     
     1136            vseg_id = vspace[vspace_id].start_vseg_id;
    11231137            unsigned int ctx_entry = vseg[vseg_id].vbase + (thread[thread_id].startid)*4;
    11241138
    1125             // ctx_sp :  Get the vseg containing the stack 
     1139            // ctx_sp :  Get the vseg containing the stack
    11261140            // allocate 16 slots (64 bytes) for possible arguments.
    11271141            vseg_id = thread[thread_id].stack_vseg_id;
    11281142            unsigned int ctx_sp = vseg[vseg_id].vbase + vseg[vseg_id].length - 64;
    11291143
    1130             // loop on the local processors
    1131             for ( lpid = 0 ; lpid < nprocs ; lpid++ )
    1132             {
    1133                 if ( (x == req_x) && (y == req_y) && (req_p == lpid) )   // fit
    1134                 {
    1135                     // pointer on selected scheduler
    1136                     psched = _schedulers[x][y][lpid];
    1137 
    1138                     // ltid : compute local thread index in scheduler
    1139                     unsigned int ltid = psched->threads;
    1140 
    1141                     // update the threads field in scheduler:
    1142                     psched->threads   = ltid + 1;
    1143 
    1144                     // ctx_trdid : compute pthread global identifier
    1145                     unsigned int ctx_trdid = x << 24 | y<<16 | lpid<<8 | ltid;
    1146 
    1147                     // initializes the thread context
    1148                     psched->context[ltid].slot[CTX_CR_ID]     = 0;
    1149                     psched->context[ltid].slot[CTX_SR_ID]     = GIET_SR_INIT_VALUE;
    1150                     psched->context[ltid].slot[CTX_SP_ID]     = ctx_sp;
    1151                     psched->context[ltid].slot[CTX_EPC_ID]    = ctx_entry;
    1152                     psched->context[ltid].slot[CTX_ENTRY_ID]  = ctx_entry;
    1153                     psched->context[ltid].slot[CTX_PTPR_ID]   = ctx_ptpr;
    1154                     psched->context[ltid].slot[CTX_PTAB_ID]   = ctx_ptab;
    1155                     psched->context[ltid].slot[CTX_NPT2_ID]   = ctx_npt2;
    1156                     psched->context[ltid].slot[CTX_LTID_ID]   = ltid;
    1157                     psched->context[ltid].slot[CTX_TRDID_ID]  = ctx_trdid;
    1158                     psched->context[ltid].slot[CTX_VSID_ID]   = vspace_id;
    1159                     psched->context[ltid].slot[CTX_NORUN_ID]  = ctx_norun;
    1160                     psched->context[ltid].slot[CTX_SIGS_ID]   = 0;
    1161                     psched->context[ltid].slot[CTX_LOCKS_ID]  = 0;
    1162 
    1163                     psched->context[ltid].slot[CTX_TTY_ID]    = 0xFFFFFFFF;
    1164                     psched->context[ltid].slot[CTX_CMA_FB_ID] = 0xFFFFFFFF;
    1165                     psched->context[ltid].slot[CTX_CMA_RX_ID] = 0xFFFFFFFF;
    1166                     psched->context[ltid].slot[CTX_CMA_TX_ID] = 0xFFFFFFFF;
    1167                     psched->context[ltid].slot[CTX_NIC_RX_ID] = 0xFFFFFFFF;
    1168                     psched->context[ltid].slot[CTX_NIC_TX_ID] = 0xFFFFFFFF;
    1169                     psched->context[ltid].slot[CTX_TIM_ID]    = 0xFFFFFFFF;
    1170                     psched->context[ltid].slot[CTX_HBA_ID]    = 0xFFFFFFFF;
    1171 
    1172                     // update thread ltid field in the mapping
    1173                     thread[thread_id].ltid = ltid;
     1144            // pointer on selected scheduler
     1145            psched = _schedulers[x][y][req_p];
     1146
     1147            // ltid : compute local thread index in scheduler
     1148            unsigned int ltid = psched->threads;
     1149
     1150            // update the threads field in scheduler:
     1151            psched->threads = ltid + 1;
     1152
     1153            // ctx_trdid : compute pthread global identifier
     1154            unsigned int ctx_trdid = (x<<24) | (y<<16) | (req_p<<8) | ltid;
     1155
     1156            // initializes the thread context
     1157            psched->context[ltid].slot[CTX_CR_ID]     = 0;
     1158            psched->context[ltid].slot[CTX_SR_ID]     = GIET_SR_INIT_VALUE;
     1159            psched->context[ltid].slot[CTX_SP_ID]     = ctx_sp;
     1160            psched->context[ltid].slot[CTX_EPC_ID]    = ctx_entry;
     1161            psched->context[ltid].slot[CTX_ENTRY_ID]  = ctx_entry;
     1162            psched->context[ltid].slot[CTX_PTPR_ID]   = ctx_ptpr;
     1163            psched->context[ltid].slot[CTX_PTAB_ID]   = ctx_ptab;
     1164            psched->context[ltid].slot[CTX_NPT2_ID]   = ctx_npt2;
     1165            psched->context[ltid].slot[CTX_LTID_ID]   = ltid;
     1166            psched->context[ltid].slot[CTX_TRDID_ID]  = ctx_trdid;
     1167            psched->context[ltid].slot[CTX_VSID_ID]   = vspace_id;
     1168            psched->context[ltid].slot[CTX_NORUN_ID]  = ctx_norun;
     1169            psched->context[ltid].slot[CTX_SIGS_ID]   = 0;
     1170            psched->context[ltid].slot[CTX_LOCKS_ID]  = 0;
     1171
     1172            psched->context[ltid].slot[CTX_TTY_ID]    = 0xFFFFFFFF;
     1173            psched->context[ltid].slot[CTX_CMA_FB_ID] = 0xFFFFFFFF;
     1174            psched->context[ltid].slot[CTX_CMA_RX_ID] = 0xFFFFFFFF;
     1175            psched->context[ltid].slot[CTX_CMA_TX_ID] = 0xFFFFFFFF;
     1176            psched->context[ltid].slot[CTX_NIC_RX_ID] = 0xFFFFFFFF;
     1177            psched->context[ltid].slot[CTX_NIC_TX_ID] = 0xFFFFFFFF;
     1178            psched->context[ltid].slot[CTX_TIM_ID]    = 0xFFFFFFFF;
     1179            psched->context[ltid].slot[CTX_HBA_ID]    = 0xFFFFFFFF;
     1180
     1181            // update thread ltid field in the mapping
     1182            thread[thread_id].ltid = ltid;
    11741183
    11751184#if BOOT_DEBUG_SCHED
     
    11881197        thread[thread_id].name,
    11891198        vspace[vspace_id].name,
    1190         x, y, lpid,
     1199        x, y, req_p,
    11911200        psched->context[ltid].slot[CTX_LTID_ID],
    11921201        psched->context[ltid].slot[CTX_TRDID_ID],
     
    12011210        psched->context[ltid].slot[CTX_SIGS_ID] );
    12021211#endif
    1203                 } // end if FIT
    1204             } // end for loop on local procs
    12051212        } // end loop on threads
    12061213    } // end loop on vspaces
  • soft/giet_vm/giet_config.h

    r816 r819  
    6262#define GIET_SR_INIT_VALUE        0x2000FF13   /* SR initial value (before eret) */
    6363#define GIET_USE_HARD_FLOAT       0            /* hard float supported */
     64#define GIET_USE_MMU_GLOBAL_FLAG  0            /* enable the use of the PTE_G flag */
    6465
    6566#endif
Note: See TracChangeset for help on using the changeset viewer.