Changeset 167
- Timestamp:
- Jul 16, 2012, 10:26:27 AM (12 years ago)
- Location:
- soft/giet_vm
- Files:
-
- 2 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/boot/boot.ld
r160 r167 12 12 seg_mapping_base = 0xBFC0C000; /* boot mapping_info */ 13 13 14 seg_kernel_init_base = 0x80030000; /* system init entry */ 14 seg_kernel_init_base = 0x80090000; /* system init entry */ 15 15 16 seg_tty_base = 0x90000000; /* TTY device: for debug purpose! */ 16 17 -
soft/giet_vm/boot/boot_handler.c
r165 r167 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 in the MAPPING_INFO_BINARY data structure (using the length field). 34 // The value is calculated and put in _max_pt2 indexed by the vspace_id. 35 // The physical alignment constraints, is ensured by the align flag in the MAPPING_INFO 36 // structure. 33 // defined by the (GIET_NB_PT2_MAX) configuration parameter. 37 34 // The max number of virtual spaces (GIET_NB_VSPACE_MAX) is a configuration parameter. 38 35 // 39 // Each page table (one page table per virtual space) is monolithic: 40 // - a first 8K aligned PT1[2148] array, indexed by the (ix1) field of VPN. 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). 39 // - PT1[2048] : a first 8K aligned array of unsigned int, indexed by the (ix1) field of VPN. 40 // Each entry in the PT1 contains a 32 bits PTD. The MSB bit PTD[31] is 41 // the PTD valid bit, and LSB bits PTD[19:0] are the 20 MSB bits of the physical base 42 // address of the selected PT2. 41 43 // The PT1 contains 2048 PTD of 4 bytes => 8K bytes. 42 // - an aray of array PT2[1024][_max_pt2[vspace_id]], indexed by 43 // the (ix2) field of the VPN, and by the PT2 index (pt2_id). 44 // Each PT2 contains 512 PTE2 of 8bytes => 4Kbytes * _max_pt2[vspace_id] 45 // The size of each page table is 8K + (_max_pt2[vspace_id])*4K bytes. 46 // All page tables must be stored in the seg_kernel_pt segment (at address 47 // seg_kernel_pt_base) 44 // - PT2[1024][GIET_NB_PT2_MAX] : an array of array of unsigned int. 45 // Each PT2[1024] must be 4K aligned, and each entry in a PT2 contains two unsigned int: 46 // the first word contains the protection flags, and the second word contains the PPN. 47 // Each PT2 contains 512 PTE2 of 8bytes => 4K bytes. 48 // The total size of a page table is finally = 8K + (GIET_NB_PT2_MAX)*4K bytes. 48 49 //////////////////////////////////////////////////////////////////////////////////// 49 50 … … 55 56 #include <stdarg.h> 56 57 57 58 58 #if !defined(GIET_NB_VSPACE_MAX) 59 59 # error The GIET_NB_VSPACE_MAX value must be defined in the 'giet_config.h' file ! 60 60 #endif 61 61 62 #if !defined(GIET_NB_PT2_MAX) 63 # error The GIET_NB_PT2_MAX value must be defined in the 'giet_config.h' file ! 64 #endif 65 62 66 //////////////////////////////////////////////////////////////////////////// 63 67 // Page Tables global variables … … 66 70 // Next free PT2 index array 67 71 unsigned int _next_free_pt2[GIET_NB_VSPACE_MAX] = 68 { [0 ... GIET_NB_VSPACE_MAX-1] = 0 };69 70 // Max number of PT2 array71 unsigned int _max_pt2[GIET_NB_VSPACE_MAX] =72 72 { [0 ... GIET_NB_VSPACE_MAX-1] = 0 }; 73 73 … … 439 439 // allocation), this function checks a possible overflow of the PT2 array. 440 440 // 441 // The parametre global is a boolean taht indicatewether a global vseg is441 // The global parameter is a boolean indicating wether a global vseg is 442 442 // being mapped. 443 443 ////////////////////////////////////////////////////////////////////////////// … … 445 445 unsigned int vpn, 446 446 unsigned int flags, 447 unsigned int ppn, 448 unsigned char global ) 447 unsigned int ppn ) 449 448 { 450 449 unsigned int ix1; … … 458 457 ix2 = vpn & 0x1FF; // 9 bits 459 458 460 461 unsigned int max_pt2 = _max_pt2[vspace_id]; 462 if(max_pt2 == 0) 463 { 464 boot_puts("Unfound page table for vspace "); 465 boot_putw(vspace_id); 466 boot_puts("\n"); 467 boot_exit(); 468 } 469 470 page_table_t* pt = (page_table_t *)_ptabs[vspace_id]; 459 page_table_t* pt = (page_table_t *)_ptabs[vspace_id]; 471 460 if ( (pt->pt1[ix1] & PTE_V) == 0 ) // set a new PTD in PT1 472 461 { 473 462 pt2_id = _next_free_pt2[vspace_id]; 474 if ( pt2_id == max_pt2)463 if ( pt2_id == GIET_NB_PT2_MAX ) 475 464 { 476 465 boot_puts("\n[BOOT ERROR] in boot_add_pte() function\n"); … … 557 546 vpn, 558 547 flags, 559 ppn, 560 0 ); 548 ppn ); 561 549 vpn++; 562 550 ppn++; … … 593 581 vpn, 594 582 flags, 595 ppn, 596 1 ); 583 ppn ); 597 584 vpn++; 598 585 ppn++; … … 616 603 // This function compute the physical base address for a vseg 617 604 // as specified in the mapping info data structure. 618 // It updates the pbase field of the vseg. 619 // It updates the page allocator (nextfreepage field of the pseg), 620 // and checks a possible pseg overflow. 605 // It updates the pbase and the length fields of the vseg. 606 // It updates the pbase and vbase fields of all vobjs in the vseg. 607 // It updates the next_base field of the pseg. 608 // It checks a possible pseg overflow. 621 609 // It is a global vseg if vspace_id = (-1) 622 610 /////////////////////////////////////////////////////////////////////////// … … 641 629 else // unconstrained mapping 642 630 { 643 vseg->pbase = pseg->base + (pseg->next_free_page<<12); 631 vseg->pbase = pseg->next_base; 632 633 // test alignment constraint 634 if ( vobj[vseg->vobj_offset].align ) 635 { 636 vseg->pbase = align_to( vseg->pbase, vobj[vseg->vobj_offset].align ); 637 } 644 638 } 645 639 646 // loop on vobjs to computes the length of the vseg, 647 // initialise the vaddr and paddr fields of all vobjs, 648 // and initialise the page table pointers array 640 // loop on vobjs to (1) computes the length of the vseg, 641 // (2) initialise the vaddr and paddr fields of all vobjs, 642 // (3) initialise the page table pointers array 643 649 644 cur_vaddr = vseg->vbase; 650 645 cur_paddr = vseg->pbase; … … 659 654 } 660 655 661 // set vaddr/paddr 656 // set vaddr/paddr for current vobj 662 657 vobj[vobj_id].vaddr = cur_vaddr; 663 658 vobj[vobj_id].paddr = cur_paddr; … … 667 662 cur_paddr += vobj[vobj_id].length; 668 663 669 // initialise _ptabs[] and _max_pt2[]664 // initialise _ptabs[] if current vobj is a PTAB 670 665 if ( vobj[vobj_id].type == VOBJ_TYPE_PTAB ) 671 666 { 672 if(vobj[vobj_id].length < (PT1_SIZE + PT2_SIZE ) ) // max_pt2 >= 1667 if(vobj[vobj_id].length < (PT1_SIZE + PT2_SIZE*GIET_NB_PT2_MAX) ) 673 668 { 674 669 boot_puts( "\n[BOOT ERROR] in boot_vseg_map() function: " ); … … 684 679 boot_exit(); 685 680 } 686 _ptabs[vspace_id] = (page_table_t*)vobj[vobj_id].paddr; 687 _max_pt2[vspace_id] = (vobj[vobj_id].length - PT1_SIZE) / PT2_SIZE; 688 } 689 } 681 _ptabs[vspace_id] = (page_table_t*)vobj[vobj_id].paddr; 682 } 683 } // end for vobjs 690 684 691 685 //set the vseg length 692 unsigned int plength = pseg->length; 693 unsigned int vlength = cur_paddr - vseg->pbase; 694 vseg->length = align_to(vlength, 12); 686 vseg->length = align_to( (cur_paddr - vseg->pbase), 12); 695 687 696 688 // checking pseg overflow 697 689 if ( (vseg->pbase < pseg->base) || 698 ((vseg->pbase + v length) > (pseg->base + plength)) )690 ((vseg->pbase + vseg->length) > (pseg->base + pseg->length)) ) 699 691 { 700 692 boot_puts("\n[BOOT ERROR] in boot_vseg_map() function\n"); 701 boot_puts("impossible identitymapping for virtual segment: ");693 boot_puts("impossible mapping for virtual segment: "); 702 694 boot_puts( vseg->name ); 703 695 boot_puts("\n"); … … 717 709 } 718 710 719 // computes number of pages 720 pages = vseg->length >> 12; 721 if ( (vseg->length & 0xFFF) != 0 ) pages++; 722 723 // set the next free physical address 724 if ( vseg->ident != 0 ) 725 ; // nothing to do 726 else 727 pseg->next_free_page = pseg->next_free_page + pages; 711 // set the next_base field in vseg 712 if ( vseg->ident == 0 ) 713 pseg->next_base = vseg->pbase + vseg->length; 728 714 729 715 #if BOOT_DEBUG_PT 730 boot_puts("- vseg ");731 716 boot_puts( vseg->name ); 732 boot_puts(" : vbase = "); 717 boot_puts(" : len = "); 718 boot_putw( vseg->length ); 719 boot_puts(" / vbase = "); 733 720 boot_putw( vseg->vbase ); 734 721 boot_puts(" / pbase = "); … … 816 803 for ( pseg_id = 0 ; pseg_id < header->psegs ; pseg_id++ ) 817 804 { 818 pseg[pseg_id].next_ free_page = 0;805 pseg[pseg_id].next_base = pseg[pseg_id].base; 819 806 } 820 807 … … 860 847 861 848 #if BOOT_DEBUG_PT 862 boot_puts(" >>> page table physical address = ");863 boot_putw((unsigned )_ptabs[vspace_id]);849 boot_puts("\n>>> page table physical address = "); 850 boot_putw((unsigned int)_ptabs[vspace_id]); 864 851 boot_puts("\n"); 865 852 #endif -
soft/giet_vm/boot/boot_handler.h
r160 r167 53 53 typedef struct PageTable 54 54 { 55 unsigned int pt1[ 2048]; // PT1 (index is ix1)56 unsigned int pt2[GIET_NB_PT2_MAX][ 1024]; // PT2s (index isix2)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) 57 57 } page_table_t; 58 58 -
soft/giet_vm/giet_config.h
r166 r167 14 14 #define BOOT_DEBUG_VIEW 0 /* display the mapping_info on system TTY */ 15 15 #define BOOT_DEBUG_PT 0 /* display the page tables after mapping */ 16 #define INIT_DEBUG 16 #define INIT_DEBUG_CTX 0 /* display the task contexts after mapping */ 17 17 #define GIET_DEBUG_SWITCH 0 /* Trace context switchs */ 18 18 … … 27 27 #define NB_TIMERS 4 /* number of timers per cluster */ 28 28 #define NB_DMAS 1 /* total number of DMA channels */ 29 #define NB_TTYS 7/* total number of TTY terminals */29 #define NB_TTYS 8 /* total number of TTY terminals */ 30 30 31 31 /* software parameters */ 32 32 33 33 #define GIET_NB_TASKS_MAX 4 /* max number of tasks per processor */ 34 #define GIET_NB_VSPACE_MAX 3/* max number of virtual spaces */34 #define GIET_NB_VSPACE_MAX 4 /* max number of virtual spaces */ 35 35 #define GIET_NB_PT2_MAX 16 /* max number of level 2 page tables per vspace */ 36 #define GIET_TICK_VALUE 65536/* context switch period (number of cycles) */36 #define GIET_TICK_VALUE 16384 /* context switch period (number of cycles) */ 37 37 #define GIET_IOMMU_ACTIVE 0 /* The IOMMU vspace is defined */ 38 #define GIET_IOMMU_CHANNELS 1 /* number of 2Mbytes segments in IOMMU vspace */ 38 39 39 #endif 40 40 -
soft/giet_vm/map.xml
r165 r167 5 5 clusters = "1" 6 6 psegs = "9" 7 ttys = " 7"7 ttys = "8" 8 8 fbs = "0" 9 vspaces = " 3"9 vspaces = "4" 10 10 globals = "13" > 11 11 … … 30 30 <pseg name = "PSEG_TTY" 31 31 base = "0x90000000" 32 length = "0x0000 0200" />32 length = "0x00001000" /> 33 33 34 34 <pseg name = "PSEG_TIM" 35 35 base = "0x91000000" 36 length = "0x0000 0080" />36 length = "0x00001000" /> 37 37 38 38 <pseg name = "PSEG_IOC" 39 39 base = "0x92000000" 40 length = "0x0000 0020" />40 length = "0x00001000" /> 41 41 42 42 <pseg name = "PSEG_DMA" 43 43 base = "0x93000000" 44 length = "0x0000 0100" />44 length = "0x00001000" /> 45 45 46 46 <pseg name = "PSEG_FBF" … … 50 50 <pseg name = "PSEG_ICU" 51 51 base = "0x9F000000" 52 length = "0x0000 0100" />52 length = "0x00001000" /> 53 53 </psegset> 54 54 … … 105 105 <vobj name = "seg_kernel_data" 106 106 type = "ELF" 107 length = "0x000 10000"107 length = "0x00040000" 108 108 binpath = "build/sys.elf" /> 109 109 </vseg> 110 110 111 111 <vseg name = "seg_kernel_uncdata" 112 vbase = "0x800 20000"112 vbase = "0x80080000" 113 113 mode = "__W_" 114 114 psegname = "PSEG_RAK" … … 121 121 122 122 <vseg name = "seg_kernel_init" 123 vbase = "0x800 30000"123 vbase = "0x80090000" 124 124 mode = "CX__" 125 125 psegname = "PSEG_RAK" … … 139 139 <vobj name = "tty" 140 140 type = "PERI" 141 length = "0x0000 0100" />141 length = "0x00001000" /> 142 142 </vseg> 143 143 … … 149 149 <vobj name = "timer" 150 150 type = "PERI" 151 length = "0x0000 0080" />151 length = "0x00001000" /> 152 152 </vseg> 153 153 … … 169 169 <vobj name = "dma" 170 170 type = "PERI" 171 length = "0x0000 0100" />171 length = "0x00001000" /> 172 172 </vseg> 173 173 … … 223 223 <vobj name = "ptab_router" 224 224 type = "PTAB" 225 length = "0x0001 0000"225 length = "0x00012000" 226 226 align = "13" /> 227 227 </vseg> … … 333 333 <vobj name = "ptab" 334 334 type = "PTAB" 335 length = "0x0001 0000"335 length = "0x00012000" 336 336 align = "13" /> 337 337 </vseg> … … 374 374 <vobj name = "ptab" 375 375 type = "PTAB" 376 length = "0x0001 0000"376 length = "0x00012000" 377 377 align = "13" /> 378 378 </vseg> … … 404 404 usetty = "1" /> 405 405 </vspace> 406 407 <vspace name = "display" 408 startname = "seg_data_display" > 409 410 <vseg name = "seg_data_display" 411 vbase = "0x00800000" 412 mode = "C_WU" 413 psegname = "PSEG_RAU" > 414 <vobj name = "seg_data_display" 415 type = "ELF" 416 length = "0x00010000" 417 binpath = "build/display.elf" /> 418 </vseg> 419 420 <vseg name = "seg_ptab_display" 421 vbase = "0x00300000" 422 mode = "C___" 423 psegname = "PSEG_RAU" > 424 <vobj name = "ptab" 425 type = "PTAB" 426 length = "0x00012000" 427 align = "13" /> 428 </vseg> 429 430 <vseg name = "seg_code_display" 431 vbase = "0x00400000" 432 mode = "CX_U" 433 psegname = "PSEG_RAU" > 434 <vobj name = "seg_code_display" 435 type = "ELF" 436 length = "0x00010000" 437 binpath = "build/display.elf" /> 438 </vseg> 439 440 <vseg name = "seg_stack_display" 441 vbase = "0x00000000" 442 mode = "C_WU" 443 psegname = "PSEG_RAU" > 444 <vobj name = "stack_display" 445 type = "BUFFER" 446 length = "0x00010000" /> 447 </vseg> 448 449 <task name = "main_display" 450 clusterid = "0" 451 proclocid = "3" 452 stackname = "stack_display" 453 startid = "0" 454 usetty = "1" /> 455 </vspace> 456 406 457 </vspaceset> 407 458 </mapping_info> -
soft/giet_vm/sys/ctx_handler.c
r165 r167 15 15 // It contains copies of processor registers, when the task is not running, 16 16 // and some general informations associated to the task. 17 // 17 18 // - It contains GPR[i], generally stored in slot (i). $0, *26 & $27 are not saved. 18 19 // - It contains HI & LO registers. 19 20 // - It contains CP0 registers: EPC, SR, CR. 20 21 // - It contains CP2 registers : PTPR and MODE. 21 // - It contains the TTY index for the terminal allocated to the task. 22 // ctx[0] <- SR ctx[8] <- $8 ctx[16]<- $16 ctx[24]<- $24 ctx[32]<- EPC 23 // ctx[1] <- $1 ctx[9] <- $9 ctx[17]<- $17 ctx[25]<- $25 ctx[33]<- CR 24 // ctx[2] <- $2 ctx[10]<- $10 ctx[18]<- $18 ctx[26]<- LO ctx[34]<- TTY 25 // ctx[3] <- $3 ctx[11]<- $11 ctx[19]<- $19 ctx[27]<- HI ctx[35]<- PTPR 26 // ctx[4] <- $4 ctx[12]<- $12 ctx[20]<- $20 ctx[28]<- $28 ctx[36]<- MODE 27 // ctx[5] <- $5 ctx[13]<- $13 ctx[21]<- $21 ctx[29]<- $29 ctx[37]<- FBDMA 28 // ctx[6] <- $6 ctx[14]<- $14 ctx[22]<- $22 ctx[30]<- $30 ctx[38]<- reserved 29 // ctx[7] <- $7 ctx[15]<- $15 ctx[23]<- $23 ctx[31]<- $31 ctx[39]<- reserved 22 // - It contains the TTY global index, the FBDMA global index, the virtual base 23 // address of the page table (PTAB), and the task global index (TASK). 24 // 25 // ctx[0]<- SR|ctx[8] <- $8 |ctx[16]<- $16|ctx[24]<- $24|ctx[32]<- EPC |ctx[40]<- TTY 26 // ctx[1]<- $1|ctx[9] <- $9 |ctx[17]<- $17|ctx[25]<- $25|ctx[33]<- CR |ctx[41]<- FBDMA 27 // ctx[2]<- $2|ctx[10]<- $10|ctx[18]<- $18|ctx[26]<- LO |ctx[34]<- *** |ctx[42]<- PTAB 28 // ctx[3]<- $3|ctx[11]<- $11|ctx[19]<- $19|ctx[27]<- HI |ctx[35]<- PTPR|ctx[43]<- TASK 29 // ctx[4]<- $4|ctx[12]<- $12|ctx[20]<- $20|ctx[28]<- $28|ctx[36]<- MODE|ctx[44]<- *** 30 // ctx[5]<- $5|ctx[13]<- $13|ctx[21]<- $21|ctx[29]<- SP |ctx[37]<- *** |ctx[45]<- *** 31 // ctx[6]<- $6|ctx[14]<- $14|ctx[22]<- $22|ctx[30]<- $30|ctx[38]<- *** |ctx[46]<- *** 32 // ctx[7]<- $7|ctx[15]<- $15|ctx[23]<- $23|ctx[31]<- RA |ctx[39]<- *** |ctx[47]<- *** 30 33 ///////////////////////////////////////////////////////////////////////////////////// 31 34 … … 40 43 41 44 ///////////////////////////////////////////////////////////////////////////////// 42 // Global variables 45 // Global variables : array of schedulers (one scheduler per processor) 43 46 ///////////////////////////////////////////////////////////////////////////////// 44 47 45 static_scheduler_t _scheduler[NB_CLUSTERS * NB_PROCS];48 __attribute__((section (".kdata"))) static_scheduler_t _scheduler[NB_CLUSTERS * NB_PROCS]; 46 49 47 50 ///////////////////////////////////////////////////////////////////////////////// … … 64 67 unsigned int *next_context; 65 68 66 unsigned int pid = _procid(); 67 unsigned int time = _proctime(); 68 unsigned int tasks = _scheduler[pid].tasks; 69 unsigned int proc_id = _procid(); 70 unsigned int tasks = _scheduler[proc_id].tasks; 69 71 70 72 // return if only one task */ … … 72 74 73 75 // compute the task context base address for the current task 74 curr_task_id = _scheduler[p id].current;75 curr_context = &(_scheduler[p id].context[curr_task_id][0]);76 curr_task_id = _scheduler[proc_id].current; 77 curr_context = &(_scheduler[proc_id].context[curr_task_id][0]); 76 78 77 79 // select the next task using a round-robin scheduling policy … … 79 81 80 82 // compute the task context base address for the next task 81 next_context = &(_scheduler[p id].context[next_task_id][0]);83 next_context = &(_scheduler[proc_id].context[next_task_id][0]); 82 84 83 85 #if GIET_DEBUG_SWITCH 84 86 _get_lock( &_tty_put_lock ); 85 87 _puts( "\n[GIET] Context switch for processor "); 86 _putw( p id );88 _putw( proc_id ); 87 89 _puts( " at cycle "); 88 _putw( time);90 _putw( _proctime() ); 89 91 _puts("\n"); 90 92 _puts( " - tasks = "); … … 101 103 102 104 // update the scheduler state, and makes the task switch 103 _scheduler[p id].current = next_task_id;105 _scheduler[proc_id].current = next_task_id; 104 106 _task_switch( curr_context, next_context ); 105 107 -
soft/giet_vm/sys/ctx_handler.h
r165 r167 15 15 } static_scheduler_t; 16 16 17 ///////////////////////////////////////////////////////////////////////////////// 18 // Definition of the task context slots indexes 19 ///////////////////////////////////////////////////////////////////////////////// 20 21 #define CTX_SR_ID 0 22 #define CTX_SP_ID 29 23 #define CTX_RA_ID 31 24 25 #define CTX_EPC_ID 32 26 #define CTX_CR_ID 33 27 #define CTX_PTPR_ID 35 28 #define CTX_MODE_ID 36 29 30 #define CTX_TTY_ID 40 31 #define CTX_FBDMA_ID 41 32 #define CTX_PTAB_ID 42 33 #define CTX_TASK_ID 43 34 35 17 36 ////////////////////////////////////////////////////////////////////////////////// 18 37 // Prototype of the context switch function -
soft/giet_vm/sys/drivers.c
r166 r167 491 491 unsigned int count ) 492 492 { 493 unsigned int user_vpn_min; 494 unsigned int user_vpn_max; 495 unsigned int vpn; // virtual page number in user space 496 unsigned int ppn; // physical page number 497 unsigned int flags; // page protection flags 498 unsigned int ix2; // Page index (for IOMMU page table) 499 unsigned int addr; // buffer address for IOC 500 page_table_t* user_ptp; // user page table pointer 501 unsigned int ko; // bool returned by _v2p_translate() 502 unsigned int ppn_first; // first physical page number for user buffer 493 unsigned int user_vpn_min; // first virtuel page index in user space 494 unsigned int user_vpn_max; // last virtual page index in user space 495 unsigned int vpn; // current virtual page index in user space 496 unsigned int ppn; // physical page number 497 unsigned int flags; // page protection flags 498 unsigned int ix2; // page index in IOMMU PT1 page table 499 unsigned int addr; // buffer address for IOC peripheral 500 unsigned int user_ptp; // page table pointer in user space 501 unsigned int ko; // bool returned by _v2p_translate() 502 unsigned int ppn_first; // first physical page number for user buffer 503 unsigned int ltid; // current task local index 504 static_scheduler_t* psched; // pointer on the current task scheduler 503 505 504 506 // check buffer alignment … … 509 511 unsigned int length = count*block_size; 510 512 511 // get user space page table base address 512 user_ptp = (page_table_t*)(_get_ptpr() << 13); 513 // get user space page table virtual address 514 psched = &_scheduler[_procid()]; 515 ltid = psched->current; 516 user_ptp = psched->context[ltid][CTX_PTAB_ID]; 513 517 514 518 user_vpn_min = user_vaddr >> 12; … … 520 524 { 521 525 // get ppn and flags for each vpn 522 ko = _v2p_translate( user_ptp, // user page table pointer523 vpn, // virtual page number524 &ppn, // physical page number525 &flags ); // protection flags526 ko = _v2p_translate( (page_table_t*)user_ptp, 527 vpn, 528 &ppn, 529 &flags ); 526 530 527 531 // check access rights … … 543 547 ppn, // Physical page number 544 548 flags ); // Protection flags 545 546 // buffer base address for IOC with IOMMU547 549 } 548 550 else // no IOMMU : check that physical pages are contiguous … … 563 565 // compute buffer base address for IOC depending on IOMMU activation 564 566 if ( GIET_IOMMU_ACTIVE ) addr = (_ioc_iommu_ix1) << 21 | (user_vaddr & 0xFFF); 565 else addr = ppn_first| (user_vaddr & 0xFFF);567 else addr = (ppn_first << 12) | (user_vaddr & 0xFFF); 566 568 567 569 // get the lock on ioc device -
soft/giet_vm/sys/irq_handler.c
r165 r167 23 23 /////////////////////////////////////////////////////////////////////////////////// 24 24 25 _isr_func_t _interrupt_vector[32] = { [0 ... 31] = &_isr_default }; 25 __attribute__((section (".kdata"))) _isr_func_t _interrupt_vector[32] = 26 { [0 ... 31] = &_isr_default }; 26 27 27 28 /////////////////////////////////////////////////////////////////////////////////// -
soft/giet_vm/sys/kernel_init.c
r166 r167 31 31 32 32 /////////////////////////////////////////////////////////////////////////////////// 33 // array of pointers on the page tables 34 // (both physical and virtual addresses) 35 /////////////////////////////////////////////////////////////////////////////////// 36 37 __attribute__((section (".kdata"))) unsigned int _kernel_ptabs_paddr[GIET_NB_VSPACE_MAX]; 38 __attribute__((section (".kdata"))) unsigned int _kernel_ptabs_vaddr[GIET_NB_VSPACE_MAX]; 39 40 /////////////////////////////////////////////////////////////////////////////////// 33 41 // declarations required to avoid forward references 34 42 /////////////////////////////////////////////////////////////////////////////////// 35 43 36 void _kernel_vobjs_init( unsigned int*);37 void _kernel_tasks_init( unsigned int*);44 void _kernel_vobjs_init(void); 45 void _kernel_tasks_init(void); 38 46 void _kernel_peripherals_init(void); 39 47 void _kernel_interrupt_vector_init(void); … … 45 53 in_kinit void _kernel_init() 46 54 { 47 // array of pointers on the page tables (used for task context initialisation)48 unsigned int kernel_ptabs[GIET_NB_VSPACE_MAX];49 50 55 // values to be written in registers 51 56 unsigned int sp_value; … … 59 64 if ( pid == 0 ) 60 65 { 61 _kernel_vobjs_init( kernel_ptabs);62 _kernel_tasks_init( kernel_ptabs);66 _kernel_vobjs_init(); 67 _kernel_tasks_init(); 63 68 _kernel_interrupt_vector_init(); 64 69 _kernel_peripherals_init(); … … 163 168 // - ptpr page table base address / 8K 164 169 // - mode mmu_mode = 0xF (TLBs and caches activated) 170 // - ptab page table virtual address 165 171 //////////////////////////////////////////////////////////////////////////////// 166 172 in_kinit void _task_map( unsigned int task_id, // global index 167 173 unsigned int vspace_id, // global index 168 174 unsigned int tty_id, // TTY index 169 unsigned int fb_id, // FB index 170 unsigned int pt_base ) // page table base adddress 175 unsigned int fbdma_id ) // FBDMA index 171 176 { 172 177 mapping_header_t* header = (mapping_header_t*)&seg_mapping_base; … … 176 181 mapping_vobj_t* vobj = _get_vobj_base( header ); 177 182 183 178 184 // values to be initialised in task context 179 unsigned int ra = (unsigned int)&_eret;185 unsigned int ra = (unsigned int)&_eret; 180 186 unsigned int sr = 0x0000FF13; 181 187 unsigned int tty = tty_id; 182 unsigned int fb = fb_id; 183 unsigned int ptpr = pt_base >> 13; 188 unsigned int fb = fbdma_id; 189 unsigned int ptpr = _kernel_ptabs_paddr[vspace_id] >> 13; 190 unsigned int ptab = _kernel_ptabs_vaddr[vspace_id]; 184 191 unsigned int mode = 0xF; 185 192 unsigned int sp; 186 193 unsigned int epc; 187 194 188 // compute epc value 189 // Get the (virtual) base address of the start_vector that 190 // contains the start addresses for all tasks defined in a vspace. 195 // EPC : Get the (virtual) base address of the start_vector containing 196 // the start addresses for all tasks defined in a vspace. 191 197 mapping_vobj_t* vobj_data = &vobj[vspace[vspace_id].vobj_offset + 192 198 vspace[vspace_id].start_offset]; … … 194 200 epc = start_vector[task[task_id].startid]; 195 201 196 // compute sp value 197 // Get the vobj containing the stack 202 // SP : Get the vobj containing the stack 198 203 unsigned int vobj_id = task[task_id].vobjlocid + vspace[vspace_id].vobj_offset; 199 204 sp = vobj[vobj_id].vaddr + vobj[vobj_id].length; … … 220 225 _scheduler[proc_id].context[ltid][CTX_RA_ID] = ra; 221 226 _scheduler[proc_id].context[ltid][CTX_EPC_ID] = epc; 227 _scheduler[proc_id].context[ltid][CTX_PTPR_ID] = ptpr; 228 _scheduler[proc_id].context[ltid][CTX_MODE_ID] = mode; 222 229 _scheduler[proc_id].context[ltid][CTX_TTY_ID] = tty; 223 230 _scheduler[proc_id].context[ltid][CTX_FBDMA_ID] = fb; 224 _scheduler[proc_id].context[ltid][CTX_PTPR_ID] = ptpr; 225 _scheduler[proc_id].context[ltid][CTX_MODE_ID] = mode; 231 _scheduler[proc_id].context[ltid][CTX_PTAB_ID] = ptab; 226 232 _scheduler[proc_id].context[ltid][CTX_TASK_ID] = task_id; 227 233 228 #if INIT_DEBUG 234 #if INIT_DEBUG_CTX 229 235 _puts("Task "); 230 236 _puts( task[task_id].name ); … … 259 265 _puts("\n"); 260 266 267 _puts(" - PTPR = "); 268 _putw( ptpr<<13 ); 269 _puts(" saved at "); 270 _putw( (unsigned int)&_scheduler[proc_id].context[ltid][CTX_PTPR_ID] ); 271 _puts("\n"); 272 261 273 _puts(" - TTY = "); 262 274 _putw( tty ); … … 271 283 _puts("\n"); 272 284 273 _puts(" - PT PR= ");274 _putw( pt pr<<13);275 _puts(" saved at "); 276 _putw( (unsigned int)&_scheduler[proc_id].context[ltid][CTX_PT PR_ID] );285 _puts(" - PTAB = "); 286 _putw( ptab ); 287 _puts(" saved at "); 288 _putw( (unsigned int)&_scheduler[proc_id].context[ltid][CTX_PTAB_ID] ); 277 289 _puts("\n"); 278 290 #endif … … 284 296 // such as mwmr channels, barriers and locks, depending on the vobj type. 285 297 // (Most of the vobjs are not known, and not initialised by the compiler). 286 // This function initialises the kernel_ptabs[] array indexed by the vspace_id,287 // and containin tthe base addresses of all page tables.288 // This kernel_ptabs[] array is used to initialise the task contexts.298 // This function initialises the _kernel_ptabs_paddr[] array indexed by the vspace_id, 299 // and containing the base addresses of all page tables. 300 // This _kernel_ptabs_paddr[] array is used to initialise the task contexts. 289 301 /////////////////////////////////////////////////////////////////////////////// 290 in_kinit void _kernel_vobjs_init( unsigned int* kernel_ptabs)302 in_kinit void _kernel_vobjs_init() 291 303 { 292 304 mapping_header_t* header = (mapping_header_t*)&seg_mapping_base; … … 302 314 char ptab_found = 0; 303 315 304 #if INIT_DEBUG 316 #if INIT_DEBUG_CTX 305 317 _puts("[INIT] --- vobjs initialisation in vspace "); 306 318 _puts(vspace[vspace_id].name); … … 317 329 { 318 330 ptab_found = 1; 319 kernel_ptabs[vspace_id] = vobj[vobj_id].paddr; 320 321 #if INIT_DEBUG 331 _kernel_ptabs_paddr[vspace_id] = vobj[vobj_id].paddr; 332 _kernel_ptabs_vaddr[vspace_id] = vobj[vobj_id].vaddr; 333 334 #if INIT_DEBUG_CTX 322 335 _puts("[INIT] PTAB address = "); 323 _putw( kernel_ptabs[vspace_id]);336 _putw(_kernel_ptabs_paddr[vspace_id]); 324 337 _puts("\n"); 325 338 #endif … … 334 347 mwmr->depth = (vobj[vobj_id].length>>2) - 5; 335 348 mwmr->lock = 0; 336 #if INIT_DEBUG 349 #if INIT_DEBUG_CTX 337 350 _puts("[INIT] MWMR channel "); 338 351 _puts( vobj->name); … … 346 359 { 347 360 348 #if INIT_DEBUG 361 #if INIT_DEBUG_CTX 349 362 _puts("[INIT] ELF section "); 350 363 _puts( vobj->name); … … 360 373 barrier->count = 0; 361 374 barrier->init = vobj[vobj_id].init; 362 #if INIT_DEBUG 375 #if INIT_DEBUG_CTX 363 376 _puts(" BARRIER "); 364 377 _puts( vobj->name); … … 373 386 unsigned int* lock = (unsigned int*)(vobj[vobj_id].vaddr); 374 387 *lock = 0; 375 #if INIT_DEBUG 388 #if INIT_DEBUG_CTX 376 389 _puts(" LOCK "); 377 390 _puts( vobj->name); … … 383 396 { 384 397 385 #if INIT_DEBUG 398 #if INIT_DEBUG_CTX 386 399 _puts(" BUFFER "); 387 400 _puts( vobj->name); … … 425 438 // TTY[0] is reserved for the kernel. 426 439 /////////////////////////////////////////////////////////////////////////////// 427 in_kinit void _kernel_tasks_init( unsigned int* ptabs)440 in_kinit void _kernel_tasks_init() 428 441 { 429 442 mapping_header_t* header = (mapping_header_t*)&seg_mapping_base; … … 461 474 { 462 475 463 #if INIT_DEBUG 476 #if INIT_DEBUG_CTX 464 477 _puts("\n[INIT] mapping tasks in vspace "); 465 478 _puts(vspace[vspace_id].name); … … 486 499 vspace_id, // vspace index 487 500 tty_id, // global tty index 488 fb_id, // global fbdma index 489 ptabs[vspace_id] ); // page table pointer 501 fb_id ); // global fbdma index 490 502 } // end loop on tasks 491 503 } // end oop on vspaces … … 495 507 _puts("\n"); 496 508 497 #if INIT_DEBUG 509 #if INIT_DEBUG_CTX 498 510 for ( cluster_id = 0 ; cluster_id < header->clusters ; cluster_id++ ) 499 511 { … … 540 552 { 541 553 unsigned int* iob_address = (unsigned int*)&seg_iob_base; 542 unsigned int icu_address = (unsigned int)&seg_icu_base;543 554 544 555 // define IPI address mapping the IOC interrupt ...TODO... -
soft/giet_vm/sys/mips32_registers.h
r165 r167 78 78 #define CP2_DCACHE_INVAL_PA $20 79 79 80 /* Context index */81 82 #define CTX_SR_ID 083 #define CTX_SP_ID 2984 #define CTX_RA_ID 3185 #define CTX_EPC_ID 3286 #define CTX_TTY_ID 3487 #define CTX_PTPR_ID 3588 #define CTX_MODE_ID 3689 #define CTX_FBDMA_ID 3790 #define CTX_TASK_ID 6391 92 93 80 #endif -
soft/giet_vm/sys/sys.ld
r166 r167 3 3 *****************************************************************************/ 4 4 5 /* The vsegs used by the system are replicated in all virtual spaces5 /* The vsegs used by the system are mapped in all virtual spaces 6 6 They can be identity mapping... or not */ 7 7 8 8 seg_kernel_code_base = 0x80000000; /* system code */ 9 9 seg_kernel_data_base = 0x80010000; /* system cacheable data */ 10 seg_kernel_uncdata_base = 0x800 20000; /* system uncacheable data */11 seg_kernel_init_base = 0x800 30000; /* system page table */10 seg_kernel_uncdata_base = 0x80080000; /* system uncacheable data */ 11 seg_kernel_init_base = 0x80090000; /* system page table */ 12 12 seg_mapping_base = 0xBFC0C000; /* boot mapping_info */ 13 13 … … 16 16 must be defined, even if the peripherals are not used in the architecture */ 17 17 18 seg_tty_base = 0x90000000; /* TTY device */19 seg_timer_base = 0x91000000; /* Timer device */20 seg_ioc_base = 0x92000000; /* Block device */21 seg_dma_base = 0x93000000; /* DMA device */22 seg_gcd_base = 0x95000000; /* GCD device */23 seg_fb_base = 0x96000000; /* FrameBuffer device */24 seg_i cu_base = 0x9F000000; /* ICU or XICUdevice */25 seg_i ob_base = 0x9E000000; /* IOBdevice */18 seg_tty_base = 0x90000000; /* TTY device */ 19 seg_timer_base = 0x91000000; /* Timer device */ 20 seg_ioc_base = 0x92000000; /* Block device */ 21 seg_dma_base = 0x93000000; /* DMA device */ 22 seg_gcd_base = 0x95000000; /* GCD device */ 23 seg_fb_base = 0x96000000; /* FrameBuffer device */ 24 seg_iob_base = 0x9E000000; /* IOB device */ 25 seg_icu_base = 0x9F000000; /* ICU or XICU device */ 26 26 27 27 /* … … 40 40 seg_kernel_data : 41 41 { 42 *(.iommu) 43 *(.kdata) 42 44 *(.rodata) 43 /* . = ALIGN(4); */44 45 *(.rodata.*) 45 /* . = ALIGN(4); */46 46 *(.data) 47 /* . = ALIGN(4); */48 47 *(.lit8) 49 48 *(.lit4) 50 49 *(.sdata) 51 /* . = ALIGN(4); */52 50 *(.bss) 53 51 *(COMMON) -
soft/giet_vm/sys/sys_handler.c
r165 r167 75 75 void _exit() 76 76 { 77 unsigned int date = _proctime(); 77 78 unsigned int proc_id = _procid(); 78 79 unsigned int task_id = _scheduler[proc_id].current; … … 83 84 _puts(" on processor "); 84 85 _putw( proc_id ); 86 _puts(" at cycle "); 87 _putw( date ); 85 88 _puts("\n\n"); 86 89 -
soft/giet_vm/xml/mapping_info.h
r165 r167 95 95 unsigned int base; // base address in physical space 96 96 unsigned int length; // size (bytes) 97 unsigned int next_ free_page; // physical page allocator97 unsigned int next_base; // first free page base address 98 98 } mapping_pseg_t; 99 99 -
soft/giet_vm/xml/xml_parser.c
r165 r167 802 802 } 803 803 804 pseg[pseg_index]->next_free_page = 0;805 804 pseg_index++; 806 805 } // end psegNode()
Note: See TracChangeset
for help on using the changeset viewer.