Changeset 180 for soft/giet_vm/boot/boot_handler.c
- Timestamp:
- Jul 25, 2012, 10:31:13 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/boot/boot_handler.c
r169 r180 31 31 // As most applications use only a limited number of segments, the number of PT2s 32 32 // actually used by a given virtual space is generally smaller than 2048, and is 33 // defined by the (GIET_NB_PT2_MAX) configuration parameter.34 // The max number of virtual spaces (GIET_NB_VSPACE_MAX) is a configuration parameter.33 // computed using the length of the vobj and stored in the _max_pte2 global variable, 34 // which is table indexed by the vspace_id. 35 35 // 36 36 // Each page table (one page table per virtual space) is monolithic, and 37 // contains one PT1 and (GIET_NB_PT2_MAX) PT2s. The PT1 is addressed using the ix1 field 38 // (11 bits) of the VPN, and the selected PT2 is addressed using the ix2 field (9 bits). 37 // contains one PT1 and ((vobj.length - PT1_SIZE) / PT2_SIZE ) PT2s. 38 // The PT1 is addressed using the ix1 field (11 bits) of the VPN, and 39 // the selected PT2 is addressed using the ix2 field (9 bits). 39 40 // - PT1[2048] : a first 8K aligned array of unsigned int, indexed by the (ix1) field of VPN. 40 41 // Each entry in the PT1 contains a 32 bits PTD. The MSB bit PTD[31] is … … 42 43 // address of the selected PT2. 43 44 // The PT1 contains 2048 PTD of 4 bytes => 8K bytes. 44 // - PT2[ 1024][GIET_NB_PT2_MAX]: an array of array of unsigned int.45 // - PT2[_max_pte2[vspace_id]][1024]: an array of array of unsigned int. 45 46 // Each PT2[1024] must be 4K aligned, and each entry in a PT2 contains two unsigned int: 46 47 // the first word contains the protection flags, and the second word contains the PPN. … … 61 62 #endif 62 63 63 #if !defined(GIET_NB_PT2_MAX)64 # error The GIET_NB_PT2_MAX value must be defined in the 'giet_config.h' file !65 #endif66 67 64 //////////////////////////////////////////////////////////////////////////// 68 65 // Page Tables global variables … … 71 68 // Next free PT2 index array 72 69 unsigned int _next_free_pt2[GIET_NB_VSPACE_MAX] = 70 { [0 ... GIET_NB_VSPACE_MAX-1] = 0 }; 71 72 // Max PT2 index 73 unsigned int _max_pte2[GIET_NB_VSPACE_MAX] = 73 74 { [0 ... GIET_NB_VSPACE_MAX-1] = 0 }; 74 75 … … 458 459 ix2 = vpn & 0x1FF; // 9 bits 459 460 461 // since the max_pte2 has to be > 1, we check that he have been set 462 // otherwise it means tha the ptabs has not been set 463 unsigned int max_pte2 = _max_pte2[vspace_id]; 464 if(max_pte2 == 0) 465 { 466 boot_puts("Unfound page table for vspace "); 467 boot_putw(vspace_id); 468 boot_puts("\n"); 469 boot_exit(); 470 } 471 460 472 page_table_t* pt = (page_table_t *)_ptabs[vspace_id]; 461 473 if ( (pt->pt1[ix1] & PTE_V) == 0 ) // set a new PTD in PT1 462 474 { 463 475 pt2_id = _next_free_pt2[vspace_id]; 464 if ( pt2_id == GIET_NB_PT2_MAX)476 if ( pt2_id == max_pte2 ) 465 477 { 466 478 boot_puts("\n[BOOT ERROR] in boot_add_pte() function\n"); … … 665 677 if ( vobj[vobj_id].type == VOBJ_TYPE_PTAB ) 666 678 { 667 if(vobj[vobj_id].length < (PT1_SIZE + PT2_SIZE*GIET_NB_PT2_MAX) ) 668 { 669 boot_puts( "\n[BOOT ERROR] in boot_vseg_map() function: " ); 670 boot_puts("PTAB vobj is too small in vspace "); 671 boot_putw(vspace_id); 672 boot_puts("\n"); 673 boot_exit(); 674 } 679 675 680 if(vspace_id == ((unsigned int) -1)) // global vseg 676 681 { … … 679 684 boot_exit(); 680 685 } 681 _ptabs[vspace_id] = (page_table_t*)vobj[vobj_id].paddr; 686 687 if(vobj[vobj_id].length < (PT1_SIZE + PT2_SIZE) ) //at least one pte2 => ( max_pte2 >= 1) 688 { 689 boot_puts( "\n[BOOT ERROR] in boot_vseg_map() function, " ); 690 boot_puts("PTAB too small, minumum size is: "); 691 boot_putw( PT1_SIZE + PT2_SIZE); 692 boot_exit(); 693 } 694 695 /* getting the physical address of the ptab */ 696 _ptabs[vspace_id] = (page_table_t*) vobj[vobj_id].paddr; 697 /* computing the number of second level page */ 698 _max_pte2[vspace_id] = (vobj[vobj_id].length - PT1_SIZE) / PT2_SIZE; 682 699 } 683 700 } // end for vobjs … … 849 866 boot_puts("\n>>> page table physical address = "); 850 867 boot_putw((unsigned int)_ptabs[vspace_id]); 868 boot_puts(", page table max_pte2 = "); 869 boot_putw((unsigned int)_max_pte2[vspace_id]); 851 870 boot_puts("\n"); 852 871 #endif
Note: See TracChangeset
for help on using the changeset viewer.