- Timestamp:
- Jul 25, 2012, 10:31:13 AM (12 years ago)
- Location:
- soft/giet_vm
- Files:
-
- 4 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 -
soft/giet_vm/boot/boot_handler.h
r169 r180 54 54 { 55 55 unsigned int pt1[PT1_SIZE]; // PT1 (index is ix1) 56 unsigned int pt2[GIET_NB_PT2_MAX][PT2_SIZE]; // PT2s (index is 2*ix2) 56 unsigned int pt2[1][PT2_SIZE]; // PT2s (index is 2*ix2) 57 /* The number `1` is onmy here to indicate to the compiler that this is a table 58 ** of two dimension and the actual value is computed dynamically(see boot_handler.c)*/ 57 59 } page_table_t; 58 60 -
soft/giet_vm/giet_config.h
r175 r180 34 34 #define GIET_NB_TASKS_MAX 4 /* max number of tasks per processor */ 35 35 #define GIET_NB_VSPACE_MAX 4 /* max number of virtual spaces */ 36 #define GIET_NB_PT2_MAX 16 /* max number of level 2 page tables per vspace */37 36 #define GIET_TICK_VALUE 16384 /* context switch period (number of cycles) */ 38 37 #define GIET_IOMMU_ACTIVE 0 /* The IOMMU vspace is defined */ -
soft/giet_vm/sys/vm_handler.h
r167 r180 53 53 typedef struct PageTable 54 54 { 55 unsigned int pt1[PT1_SIZE/4]; // PT1 (index is ix1) 56 unsigned int pt2[GIET_NB_PT2_MAX][PT2_SIZE/4]; // PT2s (index is 2*ix2) 55 unsigned int pt1[PT1_SIZE/4]; // PT1 (index is ix1) 56 unsigned int pt2[1][PT2_SIZE/4]; // PT2s (index is 2*ix2) 57 /* The number `1` is onmy here to indicate to the compiler that this is a table 58 ** of two dimension and the actual value is computed dynamically(see boot_handler.c)*/ 57 59 } page_table_t; 58 60
Note: See TracChangeset
for help on using the changeset viewer.