Changeset 513
- Timestamp:
- Feb 14, 2015, 5:10:32 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_boot/boot.c
r493 r513 34 34 // - The structure of the various multi-threaded software applications: 35 35 // number of tasks, communication channels. 36 // - The mapping: grouping of virtual objects (vobj) in the virtual segments (vseg), 37 // placement of virtual segments (vseg) in the physical segments (pseg), placement 38 // of software tasks on the processors, 36 // - The mapping: placement of virtual segments (vseg) in the physical 37 // segments (pseg), placement of software tasks on the processors, 39 38 // 40 39 // 3) The GIET-VM uses the paged virtual memory to provides two services: … … 52 51 // Each page table (one page table per virtual space) is monolithic, and contains 53 52 // one PT1 (8 Kbytes) and a variable number of PT2s (4 Kbytes each). For each vspace, 54 // the number of PT2s is defined by the size of the PTAB vobjin the mapping.53 // the number of PT2s is defined by the size of the PTAB vseg in the mapping. 55 54 // The PT1 is indexed by the ix1 field (11 bits) of the VPN. Each entry is 32 bits. 56 55 // A PT2 is indexed the ix2 field (9 bits) of the VPN. Each entry is a double word. … … 334 333 // vseg can cover several contiguous big physical pages. 335 334 // 336 // 1) First step: it computes the vseg length, and register it in vseg->length field. 337 // It computes - for each vobj - the actual vbase address, taking into 338 // account the alignment constraints and register it in vobj->vbase field. 335 // 1) First step: it computes various vseg attributes and checks 336 // alignment constraints. 339 337 // 340 338 // 2) Second step: it allocates the required number of contiguous physical pages, … … 345 343 // is reserved for the boot vsegs. 346 344 // 347 // 3) Third step (only for vseg that have the V OBJ_TYPE_PTAB): the M page tables345 // 3) Third step (only for vseg that have the VSEG_TYPE_PTAB): the M page tables 348 346 // associated to the M vspaces must be packed in the same vseg. 349 347 // We divide this vseg in M sub-segments, and compute the vbase and pbase … … 356 354 { 357 355 mapping_header_t* header = (mapping_header_t *)SEG_BOOT_MAPPING_BASE; 358 mapping_vobj_t* vobj = _get_vobj_base(header);359 356 mapping_cluster_t* cluster = _get_cluster_base(header); 360 357 mapping_pseg_t* pseg = _get_pseg_base(header); 358 359 //////////// First step : compute vseg attributes 361 360 362 361 // compute destination cluster pointer & coordinates … … 366 365 unsigned int y_dest = cluster->y; 367 366 368 // compute the first vobj global index369 unsigned int vobj_id = vseg->vobj_offset;370 371 367 // compute the "big" vseg attribute 372 368 unsigned int big = vseg->big; 369 370 // all vsegs must be aligned on 4Kbytes 371 if ( vseg->vbase & 0x00000FFF ) 372 { 373 _printf("\n[BOOT ERROR] vseg %s not aligned : vbase = %x\n", 374 vseg->name, vseg->vbase ); 375 _exit(); 376 } 373 377 374 378 // compute the "is_ram" vseg attribute … … 379 383 // compute the "is_ptab" attribute 380 384 unsigned int is_ptab; 381 if ( v obj[vobj_id].type == VOBJ_TYPE_PTAB ) is_ptab = 1;382 else 385 if ( vseg->type == VSEG_TYPE_PTAB ) is_ptab = 1; 386 else is_ptab = 0; 383 387 384 388 // compute actual vspace index … … 387 391 else vsid = vspace_id; 388 392 389 //////////// First step : compute vseg length and vobj(s) vbase390 391 unsigned int vobj_vbase = vseg->vbase; // min vbase for first vobj392 393 for ( vobj_id = vseg->vobj_offset ;394 vobj_id < (vseg->vobj_offset + vseg->vobjs) ;395 vobj_id++ )396 {397 // compute and register vobj vbase398 vobj[vobj_id].vbase = vaddr_align_to( vobj_vbase, vobj[vobj_id].align );399 400 // compute min vbase for next vobj401 vobj_vbase = vobj[vobj_id].vbase + vobj[vobj_id].length;402 }403 404 // compute and register vseg length (multiple of 4 Kbytes)405 vseg->length = vaddr_align_to( vobj_vbase - vseg->vbase, 12 );406 407 393 //////////// Second step : compute ppn and npages 408 394 //////////// - if identity mapping : ppn <= vpn … … 490 476 vseg->pbase = ((paddr_t)ppn) << 12; 491 477 vseg->mapped = 1; 492 vseg->next_vseg = pseg->next_vseg;493 pseg->next_vseg = (unsigned int)vseg;494 478 495 479 … … 782 766 mapping_vspace_t* vspace = _get_vspace_base(header); 783 767 mapping_vseg_t* vseg = _get_vseg_base(header); 784 mapping_vobj_t* vobj = _get_vobj_base(header);785 768 mapping_cluster_t* cluster ; 786 769 mapping_pseg_t* pseg ; … … 808 791 ///////// Phase 1 : global vseg containing the PTAB (two barriers required) 809 792 810 // get local PTAB vseg793 // get PTAB global vseg in cluster(cx,cy) 811 794 unsigned int found = 0; 812 795 for (vseg_id = 0; vseg_id < header->globals; vseg_id++) 813 796 { 814 unsigned int vobj_id = vseg[vseg_id].vobj_offset;815 797 pseg = _get_pseg_base(header) + vseg[vseg_id].psegid; 816 798 cluster = _get_cluster_base(header) + pseg->clusterid; 817 if ( (v obj[vobj_id].type == VOBJ_TYPE_PTAB) &&799 if ( (vseg[vseg_id].type == VSEG_TYPE_PTAB) && 818 800 (cluster->x == cx) && (cluster->y == cy) ) 819 801 { … … 845 827 for (vseg_id = 0; vseg_id < header->globals; vseg_id++) 846 828 { 847 unsigned int vobj_id = vseg[vseg_id].vobj_offset;848 829 pseg = _get_pseg_base(header) + vseg[vseg_id].psegid; 849 830 cluster = _get_cluster_base(header) + pseg->clusterid; 850 if ( (v obj[vobj_id].length > 0x200000) &&831 if ( (vseg[vseg_id].length > 0x200000) && 851 832 (vseg[vseg_id].mapped == 0) && 852 833 (cluster->x == cx) && (cluster->y == cy) ) … … 930 911 { 931 912 mapping_header_t* header = (mapping_header_t *)SEG_BOOT_MAPPING_BASE; 932 mapping_vobj_t* vobj = _get_vobj_base(header);933 913 mapping_vseg_t* vseg = _get_vseg_base(header); 934 914 mapping_pseg_t* pseg = _get_pseg_base(header); … … 939 919 for ( vseg_id = 0 ; (vseg_id < header->vsegs) && (found == 0) ; vseg_id++ ) 940 920 { 941 if ( (v obj[vseg[vseg_id].vobj_offset].type == VOBJ_TYPE_SCHED) &&921 if ( (vseg[vseg_id].type == VSEG_TYPE_SCHED) && 942 922 (pseg[vseg[vseg_id].psegid].clusterid == cluster_id ) ) 943 923 { 944 924 *vbase = vseg[vseg_id].vbase; 945 *length = v obj[vseg[vseg_id].vobj_offset].length;925 *length = vseg[vseg_id].length; 946 926 found = 1; 947 927 } … … 950 930 { 951 931 mapping_cluster_t* cluster = _get_cluster_base(header); 952 _printf("\n[BOOT ERROR] No v objof type SCHED in cluster [%d,%d]\n",932 _printf("\n[BOOT ERROR] No vseg of type SCHED in cluster [%d,%d]\n", 953 933 cluster[cluster_id].x, cluster[cluster_id].y ); 954 934 _exit(); … … 972 952 mapping_cluster_t* cluster = _get_cluster_base(header); 973 953 mapping_vspace_t* vspace = _get_vspace_base(header); 954 mapping_vseg_t* vseg = _get_vseg_base(header); 974 955 mapping_task_t* task = _get_task_base(header); 975 mapping_vobj_t* vobj = _get_vobj_base(header);976 956 mapping_periph_t* periph = _get_periph_base(header); 977 957 mapping_irq_t* irq = _get_irq_base(header); … … 980 960 unsigned int irq_id; 981 961 unsigned int vspace_id; 962 unsigned int vseg_id; 982 963 unsigned int task_id; 983 unsigned int vobj_id;984 964 985 965 unsigned int sched_vbase; // schedulers array vbase address … … 1133 1113 // the task entry point : the start_vector is stored by GCC in the seg_data 1134 1114 // segment and we must wait the .elf loading to get the entry point value... 1135 v obj_id = vspace[vspace_id].start_vobj_id;1136 unsigned int ctx_epc = v obj[vobj_id].vbase + (task[task_id].startid)*4;1137 1138 // ctx_sp : Get the v objcontaining the stack1139 v obj_id = task[task_id].stack_vobj_id;1140 unsigned int ctx_sp = v obj[vobj_id].vbase + vobj[vobj_id].length;1115 vseg_id = vspace[vspace_id].start_vseg_id; 1116 unsigned int ctx_epc = vseg[vseg_id].vbase + (task[task_id].startid)*4; 1117 1118 // ctx_sp : Get the vseg containing the stack 1119 vseg_id = task[task_id].stack_vseg_id; 1120 unsigned int ctx_sp = vseg[vseg_id].vbase + vseg[vseg_id].length; 1141 1121 1142 1122 // get vspace thread index … … 1332 1312 1333 1313 while ( (lpid >= cluster[cluster_id].procs) || 1334 (_wti_channel_alloc[cx][cy] >= 16) )1314 (_wti_channel_alloc[cx][cy] >= 32) ) 1335 1315 { 1336 1316 cluster_id = (cluster_id + 1) % (X_SIZE*Y_SIZE); … … 1501 1481 mapping_vspace_t * vspace = _get_vspace_base(header); 1502 1482 mapping_vseg_t * vseg = _get_vseg_base(header); 1503 mapping_vobj_t * vobj = _get_vobj_base(header);1504 1483 1505 1484 unsigned int seg_id; … … 1629 1608 // get destination buffer physical address and size 1630 1609 paddr_t seg_paddr = vseg[vseg_id].pbase; 1631 unsigned int vobj_id = vseg[vseg_id].vobj_offset; 1632 unsigned int seg_size = vobj[vobj_id].length; 1610 unsigned int seg_size = vseg[vseg_id].length; 1633 1611 1634 1612 #if BOOT_DEBUG_ELF … … 1690 1668 // - The "preloader.elf" file is not loaded, because it has been burned in the ROM. 1691 1669 // - The "boot.elf" file is not loaded, because it has been loaded by the preloader. 1692 // This function scans all v objs defined in the map.bin data structure to collect1670 // This function scans all vsegs defined in the map.bin data structure to collect 1693 1671 // all .elf files pathnames, and calls the load_one_elf_file() for each .elf file. 1694 1672 // As the code can be replicated in several vsegs, the same code can be copied … … 1699 1677 mapping_header_t* header = (mapping_header_t *)SEG_BOOT_MAPPING_BASE; 1700 1678 mapping_vspace_t* vspace = _get_vspace_base( header ); 1701 mapping_vobj_t* vobj = _get_vobj_base( header ); 1679 mapping_vseg_t* vseg = _get_vseg_base( header ); 1680 1702 1681 unsigned int vspace_id; 1703 unsigned int v obj_id;1682 unsigned int vseg_id; 1704 1683 unsigned int found; 1705 1684 1706 // Scan all vobjs corresponding to global vsegs, 1707 // to find the pathname to the kernel.elf file 1685 // Scan all global vsegs to find the pathname to the kernel.elf file 1708 1686 found = 0; 1709 for( v obj_id = 0 ; vobj_id < header->globals ; vobj_id++ )1710 { 1711 if(v obj[vobj_id].type == VOBJ_TYPE_ELF)1687 for( vseg_id = 0 ; vseg_id < header->globals ; vseg_id++ ) 1688 { 1689 if(vseg[vseg_id].type == VSEG_TYPE_ELF) 1712 1690 { 1713 1691 found = 1; … … 1725 1703 // Load the kernel 1726 1704 load_one_elf_file( 1, // kernel file 1727 v obj[vobj_id].binpath, // file pathname1705 vseg[vseg_id].binpath, // file pathname 1728 1706 0 ); // vspace 0 1729 1707 1730 // loop on the vspaces, scanning all v objs in the vspace,1708 // loop on the vspaces, scanning all vsegs in the vspace, 1731 1709 // to find the pathname of the .elf file associated to the vspace. 1732 1710 for( vspace_id = 0 ; vspace_id < header->vspaces ; vspace_id++ ) 1733 1711 { 1734 // loop on the vobjs in vspace (vobj_id is the global index)1712 // loop on the private vsegs 1735 1713 unsigned int found = 0; 1736 for (v obj_id = vspace[vspace_id].vobj_offset;1737 v obj_id < (vspace[vspace_id].vobj_offset + vspace[vspace_id].vobjs);1738 v obj_id++)1739 { 1740 if(v obj[vobj_id].type == VOBJ_TYPE_ELF)1714 for (vseg_id = vspace[vspace_id].vseg_offset; 1715 vseg_id < (vspace[vspace_id].vseg_offset + vspace[vspace_id].vsegs); 1716 vseg_id++) 1717 { 1718 if(vseg[vseg_id].type == VSEG_TYPE_ELF) 1741 1719 { 1742 1720 found = 1; … … 1754 1732 1755 1733 load_one_elf_file( 0, // not a kernel file 1756 v obj[vobj_id].binpath, // file pathname1734 vseg[vseg_id].binpath, // file pathname 1757 1735 vspace_id ); // vspace index 1758 1736 … … 1770 1748 mapping_cluster_t * cluster = _get_cluster_base(header); 1771 1749 mapping_periph_t * periph = _get_periph_base(header); 1772 mapping_v obj_t * vobj = _get_vobj_base(header);1750 mapping_vseg_t * vseg = _get_vseg_base(header); 1773 1751 mapping_coproc_t * coproc = _get_coproc_base(header); 1774 1752 mapping_cp_port_t * cp_port = _get_cp_port_base(header); … … 1890 1868 cp_port_id++ ) 1891 1869 { 1892 // get global index of associted v obj1893 unsigned int v obj_id = cp_port[cp_port_id].mwmr_vobj_id;1870 // get global index of associted vseg 1871 unsigned int vseg_id = cp_port[cp_port_id].mwmr_vseg_id; 1894 1872 1895 1873 // get MWMR channel base address 1896 1874 page_table_t* ptab = (page_table_t*)_ptabs_vaddr[0][x][y]; 1897 unsigned int vbase = v obj[vobj_id].vbase;1875 unsigned int vbase = vseg[vseg_id].vbase; 1898 1876 unsigned int ppn; 1899 1877 unsigned int flags;
Note: See TracChangeset
for help on using the changeset viewer.