Changeset 199 for soft/giet_vm/boot/boot_init.c
- Timestamp:
- Aug 9, 2012, 2:38:06 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/boot/boot_init.c
r198 r199 23 23 // and the mapping: 24 24 // - physical segmentation of the physical address space, 25 // - number of virtual spaces(one multi-task application per vspace),26 // - static placement of tasks on the processors,27 // - staticplacement of virtual segments (vseg) in the physical segments (pseg).28 // - static placement of virtual objects (vobj) on virtual segments (vseg).25 // - virtual spaces definition (one multi-task application per vspace), 26 // - placement of virtual objects (vobj) in the virtual segments (vseg). 27 // - placement of virtual segments (vseg) in the physical segments (pseg). 28 // - placement of tasks on the processors, 29 29 // 30 // The page table are statically constructed in the boot phase, and they do not30 // The page table are statically build in the boot phase, and they do not 31 31 // change during execution. The GIET uses only 4 Kbytes pages. 32 32 // As most applications use only a limited number of segments, the number of PT2s 33 33 // actually used by a given virtual space is generally smaller than 2048, and is 34 // computed using the length of the vobj and stored in the boot_max_pt2 global variable, 35 // which is a table indexed by the vspace_id. 36 37 // defined by the (GIET_NB_PT2_MAX) configuration parameter. 34 // computed during the boot phase. 38 35 // The max number of virtual spaces (GIET_NB_VSPACE_MAX) is a configuration parameter. 39 36 // … … 794 791 mapping_periph_t* periph = boot_get_periph_base( header ); 795 792 796 unsigned int periph_id;797 unsigned int cluster_id;798 unsigned int channels;799 800 793 // checking mapping availability 801 794 if ( header->signature != IN_MAPPING_SIGNATURE ) … … 807 800 } 808 801 809 // checking NB_CLUSTERS802 // checking Rnumber of clusters 810 803 if ( header->clusters != NB_CLUSTERS ) 811 804 { … … 819 812 } 820 813 821 // checking NB_PROC_MAX 814 // checking number of virtual spaces 815 if ( header->vspaces > GIET_NB_VSPACE_MAX ) 816 { 817 boot_puts("\n[BOOT ERROR] : number of vspaces > GIET_NB_VSPACE_MAX\n"); 818 boot_puts("\n"); 819 boot_exit(); 820 } 821 822 // checking harware 823 unsigned int periph_id; 824 unsigned int cluster_id; 825 unsigned int channels; 826 unsigned int tty_found = 0; 827 unsigned int nic_found = 0; 822 828 for ( cluster_id = 0 ; cluster_id < NB_CLUSTERS ; cluster_id++ ) 823 829 { 830 // NB_PROCS_MAX 824 831 if ( cluster[cluster_id].procs > NB_PROCS_MAX ) 825 832 { 826 833 boot_puts("\n[BOOT ERROR] too much processors in cluster "); 827 834 boot_putw( cluster_id ); 828 boot_puts("\n - In giet_config, NB_PROCS_MAX = "); 829 boot_putw ( NB_PROCS_MAX ); 830 boot_puts("\n - In mapping_info, nprocs = "); 835 boot_puts(" : procs = "); 831 836 boot_putw ( cluster[cluster_id].procs ); 832 837 boot_puts("\n"); 833 838 boot_exit(); 834 839 } 835 } 836 837 // checking number of virtual spaces 838 if ( header->vspaces > GIET_NB_VSPACE_MAX ) 839 { 840 boot_puts("\n[BOOT ERROR] : number of vspaces > GIET_NB_VSPACE_MAX\n"); 841 boot_puts("\n"); 842 boot_exit(); 843 } 844 845 // checking TTY number 846 cluster_id = header->tty_clusterid; 847 for ( periph_id = cluster[cluster_id].periph_offset ; 848 periph_id < cluster[cluster_id].periph_offset + cluster[cluster_id].periphs ; 849 periph_id++ ) 850 { 851 if ( periph[periph_id].type == PERIPH_TYPE_TTY ) 852 { 853 channels = periph[periph_id].channels; 854 break; 855 } 856 857 } 858 if ( channels > NB_TTYS ) 859 { 860 boot_puts("\n[BOOT ERROR] Incoherent NB_TTYS"); 861 boot_puts("\n - In giet_config, value = "); 862 boot_putw ( NB_TTYS ); 863 boot_puts("\n - In mapping_info, value = "); 864 boot_putw ( channels ); 865 boot_puts("\n"); 866 boot_exit(); 867 } 868 869 // TODO same type of checking for TIMERS, DMAS, NIC channels 870 840 841 for ( periph_id = cluster[cluster_id].periph_offset ; 842 periph_id < cluster[cluster_id].periph_offset + cluster[cluster_id].periphs ; 843 periph_id++ ) 844 { 845 // NB_TTYS 846 if ( periph[periph_id].type == PERIPH_TYPE_TTY ) 847 { 848 if ( tty_found ) 849 { 850 boot_puts("\n[BOOT ERROR] TTY component should not be replicated\n"); 851 boot_exit(); 852 } 853 if ( periph[periph_id].channels > NB_TTYS ) 854 { 855 boot_puts("\n[BOOT ERROR] Too much TTY terminals in cluster "); 856 boot_putw( cluster_id ); 857 boot_puts(" : ttys = "); 858 boot_putw ( periph[periph_id].channels ); 859 boot_puts("\n"); 860 boot_exit(); 861 } 862 tty_found = 1; 863 } 864 // NB_NICS 865 if ( periph[periph_id].type == PERIPH_TYPE_NIC ) 866 { 867 if ( nic_found ) 868 { 869 boot_puts("\n[BOOT ERROR] NIC component should not be replicated\n"); 870 boot_exit(); 871 } 872 if ( periph[periph_id].channels > NB_NICS ) 873 { 874 boot_puts("\n[BOOT ERROR] Too much NIC channels in cluster "); 875 boot_putw( cluster_id ); 876 boot_puts(" : nics = "); 877 boot_putw ( periph[periph_id].channels ); 878 boot_puts("\n"); 879 boot_exit(); 880 } 881 nic_found = 1; 882 } 883 // NB_TIMERS 884 if ( periph[periph_id].type == PERIPH_TYPE_TIM ) 885 { 886 if ( periph[periph_id].channels > NB_TIMERS_MAX ) 887 { 888 boot_puts("\n[BOOT ERROR] Too much user timers in cluster "); 889 boot_putw( cluster_id ); 890 boot_puts(" : timers = "); 891 boot_putw ( periph[periph_id].channels ); 892 boot_puts("\n"); 893 boot_exit(); 894 } 895 } 896 // NB_DMAS 897 if ( periph[periph_id].type == PERIPH_TYPE_DMA ) 898 { 899 if ( periph[periph_id].channels > NB_DMAS_MAX ) 900 { 901 boot_puts("\n[BOOT ERROR] Too much DMA channels in cluster "); 902 boot_putw( cluster_id ); 903 boot_puts(" : channels = "); 904 boot_putw ( periph[periph_id].channels ); 905 boot_puts("\n"); 906 boot_exit(); 907 } 908 } 909 } // end for periphs 910 } // end for clusters 871 911 } // end boot_check_mapping() 872 912 … … 1419 1459 task_id++ ) 1420 1460 { 1421 // ra : the return address is &boot_eret()1422 unsigned int ra = (unsigned int)&boot_eret;1423 1424 // sr : value required before an eret instruction1425 unsigned int sr = 0x0000FF13;1426 1427 // ptpr : page table physical base address (shifted by 13 bit)1428 unsigned int ptpr = (unsigned int)boot_ptabs_paddr[vspace_id] >> 13;1429 1430 // ptab : page_table virtual base address (not a register)1431 unsigned int ptab = (unsigned int)boot_ptabs_vaddr[vspace_id];1432 1433 // tty : terminal global index provided by a global allocator1434 unsigned int tty = 0xFFFFFFFF;1461 // ctx_ra : the return address is &boot_eret() 1462 unsigned int ctx_ra = (unsigned int)&boot_eret; 1463 1464 // ctx_sr : value required before an eret instruction 1465 unsigned int ctx_sr = 0x0000FF13; 1466 1467 // ctx_ptpr : page table physical base address (shifted by 13 bit) 1468 unsigned int ctx_ptpr = (unsigned int)boot_ptabs_paddr[vspace_id] >> 13; 1469 1470 // ctx_ptab : page_table virtual base address 1471 unsigned int ctx_ptab = (unsigned int)boot_ptabs_vaddr[vspace_id]; 1472 1473 // ctx_tty : terminal global index provided by a global allocator 1474 unsigned int ctx_tty = 0xFFFFFFFF; 1435 1475 if ( task[task_id].use_tty ) 1436 1476 { … … 1444 1484 boot_exit(); 1445 1485 } 1446 tty = alloc_tty_channel;1486 ctx_tty = alloc_tty_channel; 1447 1487 alloc_tty_channel++; 1448 1488 } 1449 1489 1450 // nic : NIC channel global index provided by a global allocator1451 unsigned int nic = 0xFFFFFFFF;1490 // ctx_nic : NIC channel global index provided by a global allocator 1491 unsigned int ctx_nic = 0xFFFFFFFF; 1452 1492 if ( task[task_id].use_nic ) 1453 1493 { … … 1461 1501 boot_exit(); 1462 1502 } 1463 nic = alloc_nic_channel;1503 ctx_nic = alloc_nic_channel; 1464 1504 alloc_nic_channel++; 1465 1505 } 1466 1506 1467 // timer : user TIMER global index provided by a cluster allocator1468 unsigned int timer = 0xFFFFFFFF;1507 // ctx_timer : user TIMER global index provided by a cluster allocator 1508 unsigned int ctx_timer = 0xFFFFFFFF; 1469 1509 if ( task[task_id].use_timer ) 1470 1510 { … … 1479 1519 boot_exit(); 1480 1520 } 1481 timer = cluster_id*NB_TIMERS_MAX + alloc_timer_channel[cluster_id];1521 ctx_timer = cluster_id*NB_TIMERS_MAX + alloc_timer_channel[cluster_id]; 1482 1522 alloc_timer_channel[cluster_id]++; 1483 1523 } 1484 1524 1485 // fbdma : DMA global index provided by a cluster allocator1486 unsigned int fbdma = 0xFFFFFFFF;1525 // ctx_fbdma : DMA global index provided by a cluster allocator 1526 unsigned int ctx_fbdma = 0xFFFFFFFF; 1487 1527 if ( task[task_id].use_fbdma ) 1488 1528 { … … 1497 1537 boot_exit(); 1498 1538 } 1499 fbdma = cluster_id*NB_DMAS_MAX + alloc_fbdma_channel[cluster_id];1539 ctx_fbdma = cluster_id*NB_DMAS_MAX + alloc_fbdma_channel[cluster_id]; 1500 1540 alloc_fbdma_channel[cluster_id]++; 1501 1541 } 1502 1542 1503 // epc : Get the (virtual) base address of the start_vector containing 1504 // the start addresses for all tasks defined in the vspace. 1543 // ctx_epc : Get the virtual address of the start function 1505 1544 mapping_vobj_t* pvobj = &vobj[vspace[vspace_id].vobj_offset + 1506 1545 vspace[vspace_id].start_offset]; 1507 1546 unsigned int* start_vector_vbase = (unsigned int*)pvobj->vaddr; 1508 unsigned int epc = start_vector_vbase[task[task_id].startid];1509 1510 // sp : Get the vobj containing the stack1547 unsigned int ctx_epc = start_vector_vbase[task[task_id].startid]; 1548 1549 // ctx_sp : Get the vobj containing the stack 1511 1550 unsigned int vobj_id = task[task_id].vobjlocid + vspace[vspace_id].vobj_offset; 1512 unsigned int sp = vobj[vobj_id].vaddr + vobj[vobj_id].length;1551 unsigned int ctx_sp = vobj[vobj_id].vaddr + vobj[vobj_id].length; 1513 1552 1514 1553 // compute gpid = global processor index … … 1516 1555 task[task_id].proclocid; 1517 1556 1518 // sched : scheduler physical address1519 unsigned int sched = (unsigned int)boot_schedulers_paddr[gpid];1520 1521 1557 // In the code below, we access the scheduler with specific access 1522 1558 // functions, because we only have the physical address of the scheduler, … … 1526 1562 unsigned int ltid = boot_scheduler_get_tasks( gpid ); 1527 1563 1528 if ( ltid >= 15)1564 if ( ltid >= IDLE_TASK_INDEX ) 1529 1565 { 1530 1566 boot_puts("\n[BOOT ERROR] : "); … … 1543 1579 1544 1580 // initializes the task context in scheduler[gpid] 1545 boot_scheduler_set_context( gpid, ltid, CTX_SR_ID , sr ); 1546 boot_scheduler_set_context( gpid, ltid, CTX_SP_ID , sp ); 1547 boot_scheduler_set_context( gpid, ltid, CTX_RA_ID , ra ); 1548 boot_scheduler_set_context( gpid, ltid, CTX_EPC_ID , epc ); 1549 boot_scheduler_set_context( gpid, ltid, CTX_PTPR_ID , ptpr ); 1550 boot_scheduler_set_context( gpid, ltid, CTX_TTY_ID , tty ); 1551 boot_scheduler_set_context( gpid, ltid, CTX_TIMER_ID , timer ); 1552 boot_scheduler_set_context( gpid, ltid, CTX_FBDMA_ID , fbdma ); 1553 boot_scheduler_set_context( gpid, ltid, CTX_PTAB_ID , ptab ); 1554 boot_scheduler_set_context( gpid, ltid, CTX_SCHED_ID , sched ); 1581 boot_scheduler_set_context( gpid, ltid, CTX_SR_ID , ctx_sr ); 1582 boot_scheduler_set_context( gpid, ltid, CTX_SP_ID , ctx_sp ); 1583 boot_scheduler_set_context( gpid, ltid, CTX_RA_ID , ctx_ra ); 1584 boot_scheduler_set_context( gpid, ltid, CTX_EPC_ID , ctx_epc ); 1585 boot_scheduler_set_context( gpid, ltid, CTX_PTPR_ID , ctx_ptpr ); 1586 boot_scheduler_set_context( gpid, ltid, CTX_TTY_ID , ctx_tty ); 1587 boot_scheduler_set_context( gpid, ltid, CTX_FBDMA_ID , ctx_fbdma ); 1588 boot_scheduler_set_context( gpid, ltid, CTX_NIC_ID , ctx_nic ); 1589 boot_scheduler_set_context( gpid, ltid, CTX_TIMER_ID , ctx_timer ); 1590 boot_scheduler_set_context( gpid, ltid, CTX_PTAB_ID , ctx_ptab ); 1591 boot_scheduler_set_context( gpid, ltid, CTX_LTID_ID , ltid ); 1592 boot_scheduler_set_context( gpid, ltid, CTX_VSID_ID , vspace_id ); 1593 boot_scheduler_set_context( gpid, ltid, CTX_RUN_ID , 1 ); 1555 1594 1556 1595 #if BOOT_DEBUG_SCHED … … 1559 1598 boot_puts(" allocated to processor "); 1560 1599 boot_putw( gpid ); 1561 boot_puts(" / ltid= ");1600 boot_puts(" - ctx[LTID] = "); 1562 1601 boot_putw( ltid ); 1563 1602 boot_puts("\n"); 1564 1603 1565 boot_puts(" - SR = "); 1566 boot_putw( sr ); 1567 boot_puts("\n"); 1568 1569 boot_puts(" - SP = "); 1570 boot_putw( sp ); 1571 boot_puts("\n"); 1572 1573 boot_puts(" - RA = "); 1574 boot_putw( ra ); 1575 boot_puts("\n"); 1576 1577 boot_puts(" - EPC = "); 1578 boot_putw( epc ); 1579 boot_puts("\n"); 1580 1581 boot_puts(" - PTPR = "); 1582 boot_putw( ptpr<<13 ); 1583 boot_puts("\n"); 1584 1585 boot_puts(" - TTY = "); 1586 boot_putw( tty ); 1587 boot_puts("\n"); 1588 1589 boot_puts(" - TIMER = "); 1590 boot_putw( timer ); 1591 boot_puts("\n"); 1592 1593 boot_puts(" - FBDMA = "); 1594 boot_putw( fbdma ); 1595 boot_puts("\n"); 1596 1597 boot_puts(" - PTAB = "); 1598 boot_putw( ptab ); 1599 boot_puts("\n"); 1600 1601 boot_puts(" - SCHED = "); 1602 boot_putw( sched ); 1603 boot_puts("\n"); 1604 boot_puts(" - ctx[SR] = "); 1605 boot_putw( ctx_sr ); 1606 boot_puts("\n"); 1607 1608 boot_puts(" - ctx[SR] = "); 1609 boot_putw( ctx_sp ); 1610 boot_puts("\n"); 1611 1612 boot_puts(" - ctx[RA] = "); 1613 boot_putw( ctx_ra ); 1614 boot_puts("\n"); 1615 1616 boot_puts(" - ctx[EPC] = "); 1617 boot_putw( ctx_epc ); 1618 boot_puts("\n"); 1619 1620 boot_puts(" - ctx[PTPR] = "); 1621 boot_putw( ctx_ptpr ); 1622 boot_puts("\n"); 1623 1624 boot_puts(" - ctx[TTY] = "); 1625 boot_putw( ctx_tty ); 1626 boot_puts("\n"); 1627 1628 boot_puts(" - ctx[NIC] = "); 1629 boot_putw( ctx_nic ); 1630 boot_puts("\n"); 1631 1632 boot_puts(" - ctx[TIMER] = "); 1633 boot_putw( ctx_timer ); 1634 boot_puts("\n"); 1635 1636 boot_puts(" - ctx[FBDMA] = "); 1637 boot_putw( ctx_fbdma ); 1638 boot_puts("\n"); 1639 1640 boot_puts(" - ctx[PTAB] = "); 1641 boot_putw( ctx_ptab ); 1642 boot_puts("\n"); 1643 1644 boot_puts(" - ctx[VSID] = "); 1645 boot_putw( vspace_id ); 1646 boot_puts("\n"); 1647 1604 1648 #endif 1605 1649
Note: See TracChangeset
for help on using the changeset viewer.