Changeset 295 for soft/giet_vm/giet_boot
- Timestamp:
- Mar 26, 2014, 6:44:44 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_boot/boot.c
r293 r295 68 68 /////////////////////////////////////////////////////////////////////////////////////// 69 69 70 // for vobjs initialisation71 70 #include <giet_config.h> 72 71 #include <mwmr_channel.h> … … 80 79 #include <nic_driver.h> 81 80 #include <ioc_driver.h> 81 #include <pic_driver.h> 82 82 #include <mwr_driver.h> 83 83 #include <ctx_handler.h> … … 874 874 _putx( curr->length ); 875 875 _puts(" / vbase "); 876 _put l( curr->vbase );876 _putx( curr->vbase ); 877 877 _puts(" / pbase "); 878 878 _putl( curr->pbase ); … … 894 894 boot_vspace_pt_build(vspace_id); 895 895 896 _puts("\n[BOOT] Page Table for vspace ");896 _puts("\n[BOOT] Page Table for vspace \""); 897 897 _puts( vspace[vspace_id].name ); 898 _puts(" completed at cycle ");898 _puts("\" completed at cycle "); 899 899 _putd( _get_proctime() ); 900 900 _puts("\n"); … … 1149 1149 mapping_task_t* task = _get_task_base(header); 1150 1150 mapping_vobj_t* vobj = _get_vobj_base(header); 1151 mapping_p roc_t* proc = _get_proc_base(header);1151 mapping_periph_t* periph = _get_periph_base(header); 1152 1152 mapping_irq_t* irq = _get_irq_base(header); 1153 1153 1154 1154 unsigned int cluster_id; // cluster index in mapping_info 1155 unsigned int p roc_id; // processor index in mapping_info1155 unsigned int periph_id; // peripheral index in mapping_info 1156 1156 unsigned int irq_id; // irq index in mapping_info 1157 1157 unsigned int vspace_id; // vspace index in mapping_info … … 1163 1163 // are reserved for the kernel (context switch) 1164 1164 1165 unsigned int alloc_tty_channel = 0; // TTY channel allocator 1166 unsigned int alloc_nic_channel = 0; // NIC channel allocator 1167 unsigned int alloc_cma_channel = 0; // CMA channel allocator 1168 unsigned int alloc_hba_channel = 0; // IOC channel allocator 1169 unsigned int alloc_tim_channel[X_SIZE*Y_SIZE]; // user TIMER allocators 1170 1171 if (NB_TTY_CHANNELS > 1) alloc_tty_channel++; 1165 unsigned int alloc_tty_channel = 1; // TTY channel allocator 1166 unsigned int alloc_nic_channel = 0; // NIC channel allocator 1167 unsigned int alloc_cma_channel = 0; // CMA channel allocator 1168 unsigned int alloc_hba_channel = 0; // HBA channel allocator 1169 unsigned int alloc_tim_channel[X_SIZE*Y_SIZE]; // user TIMER allocators 1172 1170 1173 1171 ///////////////////////////////////////////////////////////////////////// … … 1198 1196 alloc_tim_channel[cluster_id] = NB_PROCS_MAX; 1199 1197 1200 unsigned int lpid; // processor local index in cluster1201 unsigned int sched_vbase; // schedulers segment virtual base address1202 unsigned int sched_length; // schedulers segment length1203 unsigned int nprocs; // number of processors in cluster1204 1205 nprocs = cluster[cluster_id].procs;1206 1207 1198 // checking processors number 1208 if ( nprocs > NB_PROCS_MAX )1199 if ( cluster[cluster_id].procs > NB_PROCS_MAX ) 1209 1200 { 1210 1201 _puts("\n[BOOT ERROR] Too much processors in cluster["); … … 1216 1207 } 1217 1208 1218 // get scheduler array virtual base address and length 1219 boot_get_sched_vaddr( cluster_id, &sched_vbase, &sched_length ); 1220 1221 // each processor scheduler requires 4 Kbytes 1222 if ( sched_length < (nprocs<<12) ) 1223 { 1224 _puts("\n[BOOT ERROR] Schedulers segment too small in cluster["); 1225 _putd( x ); 1226 _puts(","); 1227 _putd( y ); 1228 _puts("]\n"); 1229 _exit(); 1230 } 1231 1232 // loop on processors 1233 for ( proc_id = cluster[cluster_id].proc_offset, lpid = 0 ; 1234 proc_id < cluster[cluster_id].proc_offset + cluster[cluster_id].procs; 1235 proc_id++, lpid++ ) 1236 { 1237 // current processor scheduler pointer : psched 1238 static_scheduler_t* psched = (static_scheduler_t*)(sched_vbase+(lpid<<12)); 1239 1240 // set the schedulers pointers array 1241 _schedulers[cluster_xy * NB_PROCS_MAX + lpid] = psched; 1209 static_scheduler_t* psched; // schedulers array base address in cluster 1210 1211 // no schedulers initialisation if nprocs == 0 1212 if ( cluster[cluster_id].procs > 0 ) 1213 { 1214 // get scheduler array virtual base address and length 1215 unsigned int sched_vbase; // schedulers segment virtual base address 1216 unsigned int sched_length; // schedulers segment length 1217 boot_get_sched_vaddr( cluster_id, &sched_vbase, &sched_length ); 1218 1219 if ( sched_length < (cluster[cluster_id].procs<<12) ) // 4 Kbytes per scheduler 1220 { 1221 _puts("\n[BOOT ERROR] Schedulers segment too small in cluster["); 1222 _putd( x ); 1223 _puts(","); 1224 _putd( y ); 1225 _puts("]\n"); 1226 _exit(); 1227 } 1228 1229 psched = (static_scheduler_t*)sched_vbase; 1230 1231 // scan cluster peripherals to find the ICU/XCU 1232 unsigned int found = 0; 1233 for ( periph_id = cluster[cluster_id].periph_offset ; 1234 periph_id < cluster[cluster_id].periph_offset + cluster[cluster_id].periphs; 1235 periph_id++ ) 1236 { 1237 if( (periph[periph_id].type == PERIPH_TYPE_XCU) || 1238 (periph[periph_id].type == PERIPH_TYPE_ICU) ) 1239 { 1240 found = 1; 1241 break; 1242 } 1243 } 1244 if ( found == 0 ) 1245 { 1246 _puts("\n[BOOT ERROR] No ICU / XCU component in cluster["); 1247 _putd( x ); 1248 _puts(","); 1249 _putd( y ); 1250 _puts("]\n"); 1251 _exit(); 1252 } 1253 1254 // loop on schedulers for default values initialisation 1255 unsigned int lpid; 1256 for ( lpid = 0 ; lpid < cluster[cluster_id].procs ; lpid++ ) 1257 { 1258 // set the schedulers pointers array 1259 _schedulers[cluster_xy * NB_PROCS_MAX + lpid] = 1260 (static_scheduler_t*)&psched[lpid]; 1242 1261 1243 1262 #if BOOT_DEBUG_SCHED 1244 _puts("\nProc _");1263 _puts("\nProc["); 1245 1264 _putd( x ); 1246 _puts(" _");1265 _puts(","); 1247 1266 _putd( y ); 1248 _puts(" _");1267 _puts(","); 1249 1268 _putd( lpid ); 1250 _puts(" : scheduler virtual base address = "); 1251 _putx( sched_vbase + (lpid<<12) ); 1252 _puts("\n"); 1253 #endif 1254 1255 // initialise the "tasks" variable : default value is 0 1256 psched->tasks = 0; 1257 1258 // initialise the "current" variable : default value is idle_task 1259 psched->current = IDLE_TASK_INDEX; 1260 1261 // initialise interrupt_vector with default value (valid bit = 0) 1262 unsigned int slot; 1263 for (slot = 0; slot < 32; slot++) psched->interrupt_vector[slot] = 0; 1264 1265 // initialise interrupt vector with the IRQs actually allocated 1266 for (irq_id = proc[proc_id].irq_offset; 1267 irq_id < proc[proc_id].irq_offset + proc[proc_id].irqs; 1268 irq_id++) 1269 _puts("] : scheduler virtual base address = "); 1270 _putx( (unsigned int)&psched[lpid] ); 1271 _puts("\n"); 1272 #endif 1273 // initialise the "tasks" and "current" variables default values 1274 psched[lpid].tasks = 0; 1275 psched[lpid].current = IDLE_TASK_INDEX; 1276 1277 // initialise HWI / PTI / SWI vectors (valid bit = 0) 1278 unsigned int slot; 1279 for (slot = 0; slot < 32; slot++) 1280 { 1281 psched[lpid].hwi_vector[slot] = 0; 1282 psched[lpid].pti_vector[slot] = 0; 1283 psched[lpid].wti_vector[slot] = 0; 1284 } 1285 1286 // initializes the idle_task context in scheduler: 1287 // - the SR slot is 0xFF03 because this task run in kernel mode. 1288 // - it uses the page table of vspace[0] 1289 // - it uses the kernel TTY terminal 1290 // - slots containing addresses (SP, RA, EPC, PTAB, PTPR) 1291 // must be re-initialised by kernel_parallel_init() 1292 1293 psched[lpid].context[IDLE_TASK_INDEX][CTX_CR_ID] = 0; 1294 psched[lpid].context[IDLE_TASK_INDEX][CTX_SR_ID] = 0xFF03; 1295 psched[lpid].context[IDLE_TASK_INDEX][CTX_PTPR_ID] = _ptabs_paddr[0]>>13; 1296 psched[lpid].context[IDLE_TASK_INDEX][CTX_PTAB_ID] = _ptabs_vaddr[0]; 1297 psched[lpid].context[IDLE_TASK_INDEX][CTX_TTY_ID] = 0; 1298 psched[lpid].context[IDLE_TASK_INDEX][CTX_LTID_ID] = IDLE_TASK_INDEX; 1299 psched[lpid].context[IDLE_TASK_INDEX][CTX_VSID_ID] = 0; 1300 psched[lpid].context[IDLE_TASK_INDEX][CTX_RUN_ID] = 1; 1301 } 1302 1303 1304 // loop on irqs for actual HWI / PTI / WTI vectors initialisation 1305 for ( irq_id = periph[periph_id].irq_offset ; 1306 irq_id < periph[periph_id].irq_offset + periph[periph_id].irqs ; 1307 irq_id++ ) 1269 1308 { 1270 unsigned int type = irq[irq_id].type; 1271 unsigned int icu_id = irq[irq_id].icuid; 1272 unsigned int isr_id = irq[irq_id].isr; 1309 unsigned int lpid = irq[irq_id].dstid; 1310 unsigned int dstx = irq[irq_id].dstx; 1311 unsigned int dsty = irq[irq_id].dsty; 1312 if ( (dstx != x) || (dsty != y) ) 1313 { 1314 _puts("\n[BOOT ERROR] Bad IRQ cluster coordinates in cluster["); 1315 _putd( x ); 1316 _puts(","); 1317 _putd( y ); 1318 _puts("]\n - dstx = "); 1319 _putd( dstx ); 1320 _puts("\n - dsty = "); 1321 _putd( dsty ); 1322 _puts("\n - x = "); 1323 _putd( x ); 1324 _puts("\n - y = "); 1325 _putd( y ); 1326 _puts("\n"); 1327 _exit(); 1328 } 1329 if ( lpid >= cluster[cluster_id].procs ) 1330 { 1331 _puts("\n[BOOT ERROR] Bad IRQ processor index in cluster["); 1332 _putd( x ); 1333 _puts(","); 1334 _putd( y ); 1335 _puts("]\n"); 1336 _exit(); 1337 } 1338 unsigned int type = irq[irq_id].srctype; 1339 unsigned int index = irq[irq_id].srcid; 1340 unsigned int isr = irq[irq_id].isr; 1273 1341 unsigned int channel = irq[irq_id].channel; 1274 1342 1275 unsigned int value = ((isr_id & 0xFF) ) | 1276 ((type & 0xFF) << 8) | 1343 unsigned int entry = ((isr & 0xFFFF) ) | 1277 1344 ((channel & 0x7FFF) << 16) | 1278 1345 0x80000000; // Valid entry 1279 1346 1280 psched->interrupt_vector[icu_id] = value; 1347 if (type == IRQ_TYPE_HWI) psched[lpid].hwi_vector[index] = entry; 1348 else if (type == IRQ_TYPE_PTI) psched[lpid].pti_vector[index] = entry; 1349 else if (type == IRQ_TYPE_WTI) psched[lpid].wti_vector[index] = entry; 1281 1350 1282 1351 #if BOOT_DEBUG_SCHED 1283 _puts("- IRQ : icu= ");1284 _putd( icu_id);1285 _puts(" / type= ");1286 _putd( type);1352 _puts("- IRQ : type = "); 1353 _putd( type ); 1354 _puts(" / index = "); 1355 _putd( index ); 1287 1356 _puts(" / isr = "); 1288 _putd( isr_id);1357 _putd( isr ); 1289 1358 _puts(" / channel = "); 1290 _putd(channel); 1291 _puts(" => vector_entry = "); 1292 _putx( value ); 1293 _puts("\n"); 1294 #endif 1295 } 1296 1297 // initializes the idle_task context in scheduler: 1298 // - the SR slot is 0xFF03 because this task run in kernel mode. 1299 // - it uses the page table of vspace[0] 1300 // - it uses the kernel TTY terminal 1301 // - slots containing addresses (SP, RA, EPC, PTAB, PTPR) 1302 // must be re-initialised by kernel_parallel_init() 1303 1304 psched->context[IDLE_TASK_INDEX][CTX_CR_ID] = 0; 1305 psched->context[IDLE_TASK_INDEX][CTX_SR_ID] = 0xFF03; 1306 psched->context[IDLE_TASK_INDEX][CTX_PTPR_ID] = _ptabs_paddr[0]>>13; 1307 psched->context[IDLE_TASK_INDEX][CTX_PTAB_ID] = _ptabs_vaddr[0]; 1308 psched->context[IDLE_TASK_INDEX][CTX_TTY_ID] = 0; 1309 psched->context[IDLE_TASK_INDEX][CTX_LTID_ID] = IDLE_TASK_INDEX; 1310 psched->context[IDLE_TASK_INDEX][CTX_VSID_ID] = 0; 1311 psched->context[IDLE_TASK_INDEX][CTX_RUN_ID] = 1; 1312 1313 } // end for procs 1359 _putd( channel ); 1360 _puts("\n"); 1361 #endif 1362 1363 } // end for irqs 1364 } // end if nprocs > 0 1314 1365 } // end for clusters 1315 1366 1316 1367 /////////////////////////////////////////////////////////////////// 1317 // Step 2 : loop on the vspaces and the tasks 1318 // t o initialise the schedulers and the task contexts.1368 // Step 2 : loop on the vspaces and the tasks to complete 1369 // the schedulers and task contexts initialisation. 1319 1370 1320 1371 for (vspace_id = 0; vspace_id < header->vspaces; vspace_id++) … … 1329 1380 task_id++) 1330 1381 { 1331 1332 // compute the cluster coordinates 1382 // compute the cluster coordinates & local processor index 1333 1383 unsigned int x = cluster[task[task_id].clusterid].x; 1334 1384 unsigned int y = cluster[task[task_id].clusterid].y; 1335 1385 unsigned int cluster_xy = (x<<Y_WIDTH) + y; 1386 unsigned int lpid = task[task_id].proclocid; 1336 1387 1337 1388 #if BOOT_DEBUG_SCHED … … 1347 1398 #endif 1348 1399 // compute gpid (global processor index) and scheduler base address 1349 unsigned int gpid = cluster_xy * NB_PROCS_MAX + task[task_id].proclocid;1400 unsigned int gpid = cluster_xy * NB_PROCS_MAX + lpid; 1350 1401 static_scheduler_t* psched = _schedulers[gpid]; 1351 1402 … … 1360 1411 1361 1412 // ctx_tty : TTY terminal global index provided by the global allocator 1413 // Each user terminal is a private ressource: the number of 1414 // requested terminal cannot be larger than NB_TTY_CHANNELS. 1362 1415 unsigned int ctx_tty = 0xFFFFFFFF; 1363 1416 if (task[task_id].use_tty) … … 1365 1418 if (alloc_tty_channel >= NB_TTY_CHANNELS) 1366 1419 { 1367 _puts("\n[BOOT ERROR] TTY index too large for task ");1420 _puts("\n[BOOT ERROR] TTY channel index too large for task "); 1368 1421 _puts(task[task_id].name); 1369 1422 _puts(" in vspace "); … … 1373 1426 } 1374 1427 ctx_tty = alloc_tty_channel; 1375 if (NB_TTY_CHANNELS > 1) alloc_tty_channel++; 1376 } 1428 alloc_tty_channel++; 1429 } 1430 1377 1431 // ctx_nic : NIC channel global index provided by the global allocator 1432 // Each channel is a private ressource: the number of 1433 // requested channels cannot be larger than NB_NIC_CHANNELS. 1378 1434 unsigned int ctx_nic = 0xFFFFFFFF; 1379 1435 if (task[task_id].use_nic) … … 1391 1447 alloc_nic_channel++; 1392 1448 } 1449 1393 1450 // ctx_cma : CMA channel global index provided by the global allocator 1451 // Each channel is a private ressource: the number of 1452 // requested channels cannot be larger than NB_NIC_CHANNELS. 1394 1453 unsigned int ctx_cma = 0xFFFFFFFF; 1395 1454 if (task[task_id].use_cma) … … 1407 1466 alloc_cma_channel++; 1408 1467 } 1468 1409 1469 // ctx_hba : HBA channel global index provided by the global allocator 1470 // Each channel is a private ressource: the number of 1471 // requested channels cannot be larger than NB_NIC_CHANNELS. 1410 1472 unsigned int ctx_hba = 0xFFFFFFFF; 1411 1473 if (task[task_id].use_hba) 1412 1474 { 1413 if (alloc_hba_channel >= NB_ HBA_CHANNELS)1475 if (alloc_hba_channel >= NB_IOC_CHANNELS) 1414 1476 { 1415 1477 _puts("\n[BOOT ERROR] IOC channel index too large for task "); … … 1423 1485 alloc_hba_channel++; 1424 1486 } 1425 // ctx_tim : TIM local channel index provided by the cluster allocator 1487 // ctx_tim : TIMER local channel index provided by the cluster allocator 1488 // Each timer is a private ressource 1426 1489 unsigned int ctx_tim = 0xFFFFFFFF; 1427 1490 if (task[task_id].use_tim) … … 1438 1501 _exit(); 1439 1502 } 1440 1441 // checking that there is an ISR_TIMER installed 1442 unsigned int found = 0; 1443 for ( irq_id = 0 ; irq_id < 32 ; irq_id++ ) 1444 { 1445 unsigned int entry = psched->interrupt_vector[irq_id]; 1446 unsigned int isr = entry & 0x000000FF; 1447 unsigned int channel = entry>>16; 1448 if ( (isr == ISR_TIMER) && (channel == alloc_tim_channel[cluster_id]) ) 1449 { 1450 found = 1; 1451 ctx_tim = alloc_tim_channel[cluster_id]; 1452 alloc_tim_channel[cluster_id]++; 1453 break; 1454 } 1455 } 1456 if (!found) 1457 { 1458 _puts("\n[BOOT ERROR] No ISR_TIMER installed for task "); 1459 _puts(task[task_id].name); 1460 _puts(" in vspace "); 1461 _puts(vspace[vspace_id].name); 1462 _puts("\n"); 1463 _exit(); 1464 } 1503 ctx_tim = alloc_tim_channel[cluster_id]; 1504 alloc_tim_channel[cluster_id]++; 1465 1505 } 1466 1506 // ctx_epc : Get the virtual address of the memory location containing … … 1520 1560 _puts("\nTask "); 1521 1561 _putd( task_id ); 1522 _puts(" allocated to processor "); 1523 _putd( gpid ); 1524 _puts("\n - ctx[LTID] = "); 1562 _puts(" allocated to processor["); 1563 _putd( x ) 1564 _puts(","); 1565 _putd( y ) 1566 _puts(","); 1567 _putd( lpid ) 1568 _puts("]\n - ctx[LTID] = "); 1525 1569 _putd( psched->context[ltid][CTX_LTID_ID] ); 1526 1570 _puts("\n - ctx[SR] = "); … … 1533 1577 _putx( psched->context[ltid][CTX_PTPR_ID] ); 1534 1578 _puts("\n - ctx[TTY] = "); 1535 _put d( psched->context[ltid][CTX_TTY_ID] );1579 _putx( psched->context[ltid][CTX_TTY_ID] ); 1536 1580 _puts("\n - ctx[NIC] = "); 1537 _put d( psched->context[ltid][CTX_NIC_ID] );1581 _putx( psched->context[ltid][CTX_NIC_ID] ); 1538 1582 _puts("\n - ctx[CMA] = "); 1539 _put d( psched->context[ltid][CTX_CMA_ID] );1583 _putx( psched->context[ltid][CTX_CMA_ID] ); 1540 1584 _puts("\n - ctx[IOC] = "); 1541 _put d( psched->context[ltid][CTX_HBA_ID] );1585 _putx( psched->context[ltid][CTX_HBA_ID] ); 1542 1586 _puts("\n - ctx[TIM] = "); 1543 _put d( psched->context[ltid][CTX_TIM_ID] );1587 _putx( psched->context[ltid][CTX_TIM_ID] ); 1544 1588 _puts("\n - ctx[PTAB] = "); 1545 1589 _putx( psched->context[ltid][CTX_PTAB_ID] ); 1546 1590 _puts("\n - ctx[GTID] = "); 1547 _put d( psched->context[ltid][CTX_GTID_ID] );1591 _putx( psched->context[ltid][CTX_GTID_ID] ); 1548 1592 _puts("\n - ctx[VSID] = "); 1549 _put d( psched->context[ltid][CTX_VSID_ID] );1593 _putx( psched->context[ltid][CTX_VSID_ID] ); 1550 1594 _puts("\n - ctx[TRDID] = "); 1551 _put d( psched->context[ltid][CTX_TRDID_ID] );1595 _putx( psched->context[ltid][CTX_TRDID_ID] ); 1552 1596 _puts("\n"); 1553 1597 #endif … … 1565 1609 _ioc_init( 0 ); 1566 1610 1567 int fd_id = _fat_open( IOC_BOOT_ PA_MODE,1611 int fd_id = _fat_open( IOC_BOOT_MODE, 1568 1612 "map.bin", 1569 1613 0 ); // no creation … … 1586 1630 if ( offset ) nblocks++; 1587 1631 1588 unsigned int ok = _fat_read( IOC_BOOT_ PA_MODE,1632 unsigned int ok = _fat_read( IOC_BOOT_MODE, 1589 1633 fd_id, 1590 1634 (unsigned int*)( &seg_boot_mapping_base), … … 1781 1825 // The "preloader.elf" file is not loaded, because it has been burned in the ROM. 1782 1826 // The "boot.elf" file is not loaded, because it has been loaded by the preloader. 1783 // Itscans all vobjs defined in the map.bin data structure to collect1827 // This function scans all vobjs defined in the map.bin data structure to collect 1784 1828 // all .elf files pathnames, and calls the load_one_elf_file() function to 1785 1829 // load all loadable segments at the virtual address found in the .elf file. … … 1813 1857 } 1814 1858 1815 load_one_elf_file( IOC_BOOT_ VA_MODE,1859 load_one_elf_file( IOC_BOOT_MODE, 1816 1860 vobj[vobj_id].binpath, 1817 1861 0 ); // vspace 0 1818 1862 1819 _puts("\n[BOOT] File ");1863 _puts("\n[BOOT] File \""); 1820 1864 _puts( vobj[vobj_id].binpath ); 1821 _puts(" loaded at cycle ");1865 _puts("\" loaded at cycle "); 1822 1866 _putd( _get_proctime() ); 1823 1867 _puts("\n"); … … 1852 1896 } 1853 1897 1854 load_one_elf_file( IOC_BOOT_ VA_MODE,1898 load_one_elf_file( IOC_BOOT_MODE, 1855 1899 vobj[vobj_id].binpath, 1856 1900 vspace_id ); 1857 1901 1858 _puts("\n[BOOT] File ");1902 _puts("\n[BOOT] File \""); 1859 1903 _puts( vobj[vobj_id].binpath ); 1860 _puts(" loaded at cycle ");1904 _puts("\" loaded at cycle "); 1861 1905 _putd( _get_proctime() ); 1862 1906 _puts("\n"); … … 1882 1926 mapping_coproc_t * coproc = _get_coproc_base(header); 1883 1927 mapping_cp_port_t * cp_port = _get_cp_port_base(header); 1928 mapping_irq_t * irq = _get_irq_base(header); 1884 1929 1885 1930 unsigned int cluster_id; … … 2001 2046 case PERIPH_TYPE_TTY: // vci_multi_tty component 2002 2047 { 2048 // nothing to do 2003 2049 #if BOOT_DEBUG_PERI 2004 2050 _puts("- TTY / channels = "); … … 2025 2071 _puts("\n"); 2026 2072 #endif 2073 break; 2074 } 2075 case PERIPH_TYPE_PIC: // vci_iopic component 2076 { 2077 2078 #if BOOT_DEBUG_PERI 2079 _puts("- PIC / channels = "); 2080 _putd(channels); 2081 _puts("\n"); 2082 #endif 2083 // scan all HWI IRQs defined in mapping for PIC component, 2084 // and initialises addresses for WTI IRQs 2085 for ( channel_id = periph[periph_id].irq_offset ; 2086 channel_id < periph[periph_id].irq_offset + periph[periph_id].irqs ; 2087 channel_id++ ) 2088 { 2089 unsigned int hwi_id = irq[channel_id].srcid; // HWI index in PIC 2090 unsigned int wti_id = irq[channel_id].dstid; // WTI index in XCU 2091 unsigned int x = irq[channel_id].dstx; // XCU X coordinate 2092 unsigned int y = irq[channel_id].dsty; // XCU Y coordinate 2093 unsigned int cluster = (x<<Y_WIDTH) + y; // XCU cluster 2094 unsigned int vaddr; 2095 2096 _xcu_get_wti_address( wti_id, &vaddr ); 2097 2098 _pic_init( hwi_id, vaddr, cluster ); 2099 #if BOOT_DEBUG_PERI 2100 _puts(" hwi_index = "); 2101 _putd( hwi_id ); 2102 _puts(" / wti_index = "); 2103 _putd( wti_id ); 2104 _puts(" / vaddr = "); 2105 _putx( vaddr ); 2106 _puts(" in cluster["); 2107 _putd( x ); 2108 _puts(","); 2109 _putd( y ); 2110 _puts("]\n"); 2111 #endif 2112 } 2027 2113 break; 2028 2114 } … … 2089 2175 void boot_init() 2090 2176 { 2091 mapping_header_t* header = (mapping_header_t *) & seg_boot_mapping_base; 2092 unsigned int gpid = _get_procid(); 2093 unsigned int cluster_xy = gpid / NB_PROCS_MAX; 2094 unsigned int lpid = gpid % NB_PROCS_MAX; 2177 mapping_header_t* header = (mapping_header_t *) & seg_boot_mapping_base; 2178 mapping_cluster_t* cluster = _get_cluster_base(header); 2179 unsigned int gpid = _get_procid(); 2095 2180 2096 2181 if ( gpid == 0 ) // only Processor 0 does it … … 2103 2188 boot_mapping_init(); 2104 2189 2105 _puts("\n[BOOT] Mapping ");2190 _puts("\n[BOOT] Mapping \""); 2106 2191 _puts( header->name ); 2107 _puts(" loaded at cycle ");2192 _puts("\" loaded at cycle "); 2108 2193 _putd(_get_proctime()); 2109 2194 _puts("\n"); … … 2111 2196 // Building all page tables 2112 2197 boot_pt_init(); 2113 2114 _puts("\n[BOOT] Page Tables initialisation completed at cycle ");2115 _putd(_get_proctime());2116 _puts("\n");2117 2198 2118 2199 // Activating proc 0 MMU … … 2134 2215 boot_schedulers_init(); 2135 2216 2136 _puts("\n[BOOT] All schedulers initialised at cycle ");2217 _puts("\n[BOOT] Schedulers initialised at cycle "); 2137 2218 _putd(_get_proctime()); 2138 2219 _puts("\n"); … … 2144 2225 boot_peripherals_init(); 2145 2226 2146 _puts("\n[BOOT] Allperipherals initialised at cycle ");2227 _puts("\n[BOOT] Non replicated peripherals initialised at cycle "); 2147 2228 _putd(_get_proctime()); 2148 2229 _puts("\n"); … … 2151 2232 boot_elf_load(); 2152 2233 2153 _puts("\n[BOOT] All ELF files loaded at cycle ");2154 _putd(_get_proctime());2155 _puts("\n");2156 2157 2234 // P0 starts all other processors 2158 unsigned int x,y,p; 2159 for (x = 0 ; x < X_SIZE ; x++) 2160 { 2161 for (y = 0 ; y < Y_SIZE ; y++) 2235 unsigned int clusterid, p; 2236 2237 for ( clusterid = 0 ; clusterid < X_SIZE*Y_SIZE ; clusterid++ ) 2238 { 2239 unsigned int nprocs = cluster[clusterid].procs; 2240 unsigned int xdest = cluster[clusterid].x; 2241 unsigned int ydest = cluster[clusterid].y; 2242 unsigned int cluster_xy = (xdest<<Y_WIDTH) + ydest; 2243 2244 for ( p = 0 ; p < nprocs; p++ ) 2162 2245 { 2163 for(p = 0; p < NB_PROCS_MAX; p++) 2164 { 2165 if ( (x != 0) || (y != 0) || (p != 0) ) 2166 { 2167 _xcu_send_ipi( (x<<Y_WIDTH) + y, 2168 p, 2169 (unsigned int)boot_init ); 2170 } 2246 if ( (nprocs > 0) && ((clusterid != 0) || (p != 0)) ) 2247 { 2248 _xcu_send_wti( cluster_xy, p, (unsigned int)boot_init ); 2171 2249 } 2172 2250 } 2173 2251 } 2252 2174 2253 } // end monoprocessor boot 2175 2254 … … 2186 2265 _set_mmu_ptpr( (unsigned int)(_ptabs_paddr[0]>>13) ); 2187 2266 _set_mmu_mode( 0xF ); 2188 2189 _tty_get_lock( 0 );2190 _puts("\n[BOOT] Processor[");2191 _putd( cluster_xy >> Y_WIDTH );2192 _puts(",");2193 _putd( cluster_xy & ((1<<Y_WIDTH)-1) );2194 _puts(",");2195 _putd( lpid );2196 _puts("] : MMU activation at cycle ");2197 _putd(_get_proctime());2198 _puts("\n");2199 _tty_release_lock( 0 );2200 2267 } 2201 2268 2202 2269 // all processors jump to kernel_init 2203 2270 unsigned int kernel_entry = (unsigned int)&seg_kernel_init_base; 2204 2205 #if GIET_DEBUG_INIT2206 _tty_get_lock( 0 );2207 _puts("\n[BOOT DEBUG] Processor[");2208 _putd( cluster_xy >> Y_WIDTH );2209 _puts(",");2210 _putd( cluster_xy & ((1<<Y_WIDTH)-1) );2211 _puts(",");2212 _putd( lpid );2213 _puts("] enters kernel at cycle ");2214 _putd( _get_proctime() );2215 _puts(" / kernel entry = ");2216 _putx( kernel_entry );2217 _puts("\n");2218 _tty_release_lock( 0 );2219 #endif2220 2221 2271 asm volatile( "jr %0" ::"r"(kernel_entry) ); 2222 2272
Note: See TracChangeset
for help on using the changeset viewer.