Changeset 218
- Timestamp:
- Sep 19, 2012, 10:52:43 AM (12 years ago)
- Location:
- soft/giet_vm
- Files:
-
- 1 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/Makefile
r215 r218 64 64 65 65 ### system compilation 66 build/sys/sys.elf: $(SYS_OBJS) sys/sys.ld 66 build/sys/sys.elf: $(SYS_OBJS) sys/sys.ld 67 67 $(LD) -o $@ -T sys/sys.ld $(SYS_OBJS) 68 68 $(DU) -D $@ > $@.txt 69 69 70 build/sys/%.o: sys/%.c giet_config.h 70 build/sys/%.o: sys/%.c giet_config.h $(MAP_XML) 71 71 $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< 72 72 73 build/sys/%.o: sys/%.s giet_config.h 73 build/sys/%.o: sys/%.s giet_config.h $(MAP_XML) 74 74 $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< 75 75 … … 79 79 $(DU) -D $@ > $@.txt 80 80 81 build/boot/%.o: boot/%.c giet_config.h 81 build/boot/%.o: boot/%.c giet_config.h $(MAP_XML) 82 82 $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< 83 83 84 build/boot/%.o: boot/%.S giet_config.h 84 build/boot/%.o: boot/%.S giet_config.h $(MAP_XML) 85 85 $(CC) $(INCLUDE) $(CFLAGS) -c -o $@ $< 86 86 -
soft/giet_vm/boot/boot_init.c
r215 r218 912 912 boot_exit(); 913 913 } 914 if ( periph[periph_id].channels !=NB_TTYS )914 if ( periph[periph_id].channels > NB_TTYS ) 915 915 { 916 916 boot_puts("\n[BOOT ERROR] Wrong NB_TTYS in cluster "); … … 1296 1296 unsigned int* pseg_base = (unsigned int*)pseg[pseg_id].base; 1297 1297 1298 //////// vci_block_device component 1299 if ( type == PERIPH_TYPE_IOC ) 1298 #if BOOT_DEBUG_PERI 1299 boot_puts("- peripheral type : "); 1300 boot_putd( type ); 1301 boot_puts(" / address = "); 1302 boot_putx( (unsigned int)pseg_base ); 1303 boot_puts(" / channels = "); 1304 boot_putd( channels ); 1305 boot_puts("\n"); 1306 #endif 1307 1308 switch ( type ) 1300 1309 { 1301 1302 // activate interrupts 1303 pseg_base[BLOCK_DEVICE_IRQ_ENABLE] = 1; 1304 1310 case PERIPH_TYPE_IOC: // vci_block_device component 1311 pseg_base[BLOCK_DEVICE_IRQ_ENABLE] = 1; 1305 1312 #if BOOT_DEBUG_PERI 1306 boot_puts("- IOC initialised : "); 1307 boot_putd( channels ); 1308 boot_puts(" channels\n"); 1309 #endif 1310 } 1311 1312 //////// vci_multi_dma component 1313 else if ( type == PERIPH_TYPE_DMA ) 1314 { 1315 for ( channel_id = 0 ; channel_id < channels ; channel_id++ ) 1316 { 1317 // activate interrupts 1318 pseg_base[DMA_IRQ_DISABLE + channel_id*DMA_SPAN] = 0; 1319 } 1320 1313 boot_puts("- IOC initialised\n"); 1314 #endif 1315 break; 1316 case PERIPH_TYPE_DMA: // vci_multi_dma component 1317 for ( channel_id = 0 ; channel_id < channels ; channel_id++ ) 1318 { 1319 pseg_base[DMA_IRQ_DISABLE + channel_id*DMA_SPAN] = 0; 1320 } 1321 1321 #if BOOT_DEBUG_PERI 1322 boot_puts("- DMA initialised : "); 1323 boot_putd( channels ); 1324 boot_puts(" channels\n"); 1325 #endif 1326 } 1327 1328 //////// vci_multi_nic component 1329 else if ( type == PERIPH_TYPE_NIC ) 1330 { 1331 for ( channel_id = 0 ; channel_id < channels ; channel_id++ ) 1332 { 1333 // TODO 1334 } 1335 1322 boot_puts("- DMA initialised\n"); 1323 #endif 1324 break; 1325 case PERIPH_TYPE_NIC: // vci_multi_nic component 1326 for ( channel_id = 0 ; channel_id < channels ; channel_id++ ) 1327 { 1328 // TODO 1329 } 1336 1330 #if BOOT_DEBUG_PERI 1337 boot_puts("- NIC initialised : "); 1338 boot_putd( channels ); 1339 boot_puts(" channels\n"); 1340 #endif 1341 } 1342 1343 //////// vci_io_bridge component 1344 else if ( (type == PERIPH_TYPE_IOB) && IOMMU_ACTIVE ) 1345 { 1346 // get the iommu page table physical address 1347 // TODO 1348 1349 // define IPI address mapping the IOC interrupt 1350 // TODO 1351 1352 // set IOMMU page table address 1353 // pseg_base[IOB_IOMMU_PTPR] = ptab_pbase; 1354 1355 // activate IOMMU 1356 // pseg_base[IOB_IOMMU_ACTIVE] = 1; 1357 1331 boot_puts("- NIC initialised\n"); 1332 #endif 1333 break; 1334 case PERIPH_TYPE_TTY: // vci_multi_tty component 1358 1335 #if BOOT_DEBUG_PERI 1359 boot_puts("- IOB initialised : "); 1360 boot_putd( channels ); 1361 boot_puts(" channels\n"); 1362 #endif 1363 } 1364 1336 boot_puts("- TTY initialised\n"); 1337 #endif 1338 break; 1339 case PERIPH_TYPE_IOB: // vci_io_bridge component 1340 if ( IOMMU_ACTIVE ) 1341 { 1342 // TODO 1343 // get the iommu page table physical address 1344 // define IPI address mapping the IOC interrupt 1345 // set IOMMU page table address 1346 // pseg_base[IOB_IOMMU_PTPR] = ptab_pbase; 1347 // activate IOMMU 1348 // pseg_base[IOB_IOMMU_ACTIVE] = 1; 1349 } 1350 #if BOOT_DEBUG_PERI 1351 boot_puts("- IOB initialised\n"); 1352 #endif 1353 break; 1354 } // end switch periph type 1365 1355 } // end for periphs 1356 1357 #if BOOT_DEBUG_PERI 1358 boot_puts("\n[BOOT DEBUG] ****** coprocessors initialisation in cluster "); 1359 boot_putd( cluster_id ); 1360 boot_puts(" ******\n"); 1361 #endif 1366 1362 1367 1363 for ( coproc_id = cluster[cluster_id].coproc_offset ; … … 1374 1370 1375 1371 #if BOOT_DEBUG_PERI 1376 boot_puts(" [BOOT] mwmr coproc initialisation of");1377 boot_puts( (unsigned int) coproc[coproc_id].name);1378 boot_puts(" , nb ports");1372 boot_puts("- coprocessor name : "); 1373 boot_puts( coproc[coproc_id].name ); 1374 boot_puts(" / nb ports = "); 1379 1375 boot_putd((unsigned int)coproc[coproc_id].ports); 1380 1376 boot_puts("\n"); … … 1443 1439 unsigned int alloc_tty_channel; // TTY channel allocator 1444 1440 unsigned int alloc_nic_channel; // NIC channel allocator 1445 unsigned int alloc_ fbdma_channel[NB_CLUSTERS]; // FBDMA channel allocators1441 unsigned int alloc_dma_channel[NB_CLUSTERS]; // DMA channel allocators 1446 1442 unsigned int alloc_timer_channel[NB_CLUSTERS]; // user TIMER allocators 1447 1443 … … 1464 1460 for ( cluster_id = 0 ; cluster_id < header->clusters ; cluster_id++ ) 1465 1461 { 1466 alloc_ fbdma_channel[cluster_id]= 0;1462 alloc_dma_channel[cluster_id] = 0; 1467 1463 alloc_timer_channel[cluster_id] = 0; 1468 1464 } … … 1678 1674 } 1679 1675 1680 // ctx_ fbdma : DMA global index provided by a cluster allocator1681 unsigned int ctx_ fbdma = 0xFFFFFFFF;1682 if ( task[task_id].use_fbdma )1676 // ctx_dma : DMA global index provided by a cluster allocator 1677 unsigned int ctx_dma = 0xFFFFFFFF; 1678 if ( task[task_id].use_fbdma || task[task_id].use_nic ) 1683 1679 { 1684 1680 unsigned int cluster_id = task[task_id].clusterid; 1685 if ( alloc_ fbdma_channel[cluster_id] >= NB_DMAS_MAX )1686 { 1687 boot_puts("\n[BOOT ERROR] local FBDMA index too large for task ");1681 if ( alloc_dma_channel[cluster_id] >= NB_DMAS_MAX ) 1682 { 1683 boot_puts("\n[BOOT ERROR] local DMA index too large for task "); 1688 1684 boot_puts( task[task_id].name ); 1689 1685 boot_puts(" in vspace "); … … 1692 1688 boot_exit(); 1693 1689 } 1694 ctx_ fbdma = cluster_id*NB_DMAS_MAX + alloc_fbdma_channel[cluster_id];1695 alloc_ fbdma_channel[cluster_id]++;1690 ctx_dma = cluster_id*NB_DMAS_MAX + alloc_dma_channel[cluster_id]; 1691 alloc_dma_channel[cluster_id]++; 1696 1692 } 1697 1693 … … 1730 1726 1731 1727 // initializes the task context in scheduler[gpid] 1732 boot_scheduler_set_context( gpid, ltid, CTX_SR_ID , ctx_sr 1733 boot_scheduler_set_context( gpid, ltid, CTX_SP_ID , ctx_sp 1734 boot_scheduler_set_context( gpid, ltid, CTX_RA_ID , ctx_ra 1735 boot_scheduler_set_context( gpid, ltid, CTX_EPC_ID , ctx_epc 1736 boot_scheduler_set_context( gpid, ltid, CTX_PTPR_ID , ctx_ptpr 1737 boot_scheduler_set_context( gpid, ltid, CTX_TTY_ID , ctx_tty 1738 boot_scheduler_set_context( gpid, ltid, CTX_ FBDMA_ID , ctx_fbdma);1739 boot_scheduler_set_context( gpid, ltid, CTX_NIC_ID , ctx_nic 1740 boot_scheduler_set_context( gpid, ltid, CTX_TIMER_ID , ctx_timer 1741 boot_scheduler_set_context( gpid, ltid, CTX_PTAB_ID , ctx_ptab 1742 boot_scheduler_set_context( gpid, ltid, CTX_LTID_ID , ltid 1743 boot_scheduler_set_context( gpid, ltid, CTX_VSID_ID , vspace_id 1744 boot_scheduler_set_context( gpid, ltid, CTX_RUN_ID , 1 1728 boot_scheduler_set_context( gpid, ltid, CTX_SR_ID , ctx_sr ); 1729 boot_scheduler_set_context( gpid, ltid, CTX_SP_ID , ctx_sp ); 1730 boot_scheduler_set_context( gpid, ltid, CTX_RA_ID , ctx_ra ); 1731 boot_scheduler_set_context( gpid, ltid, CTX_EPC_ID , ctx_epc ); 1732 boot_scheduler_set_context( gpid, ltid, CTX_PTPR_ID , ctx_ptpr ); 1733 boot_scheduler_set_context( gpid, ltid, CTX_TTY_ID , ctx_tty ); 1734 boot_scheduler_set_context( gpid, ltid, CTX_DMA_ID , ctx_dma ); 1735 boot_scheduler_set_context( gpid, ltid, CTX_NIC_ID , ctx_nic ); 1736 boot_scheduler_set_context( gpid, ltid, CTX_TIMER_ID , ctx_timer ); 1737 boot_scheduler_set_context( gpid, ltid, CTX_PTAB_ID , ctx_ptab ); 1738 boot_scheduler_set_context( gpid, ltid, CTX_LTID_ID , ltid ); 1739 boot_scheduler_set_context( gpid, ltid, CTX_VSID_ID , vspace_id ); 1740 boot_scheduler_set_context( gpid, ltid, CTX_RUN_ID , 1 ); 1745 1741 1746 1742 #if BOOT_DEBUG_SCHED … … 1785 1781 boot_puts("\n"); 1786 1782 1787 boot_puts(" - ctx[ FBDMA]= ");1788 boot_putd( ctx_ fbdma );1783 boot_puts(" - ctx[DMA] = "); 1784 boot_putd( ctx_dma ); 1789 1785 boot_puts("\n"); 1790 1786 -
soft/giet_vm/display/main.c
r207 r218 2 2 3 3 #define NBLOCS 32 4 #define THRESHOLD 2005 4 6 5 __attribute__((constructor)) int main(void) 7 6 { 8 unsigned char buf_in[128*128]; 9 unsigned char buf_out[128*128]; 7 unsigned char buf[128*128]; 8 unsigned int x; 9 unsigned int base = 0; 10 10 11 unsigned int i; 12 unsigned int x; 13 unsigned int base = 0; 14 15 while (base < 5 * NBLOCS) 11 while (base < 10 * NBLOCS) 16 12 { 17 13 giet_tty_printf("\n *** image %d *** at date = %d \n", 18 14 base / NBLOCS, giet_proctime()); 19 15 20 /* Phase 1 : lecture image sur le disque et transfert vers buf _in*/21 x = giet_ioc_read(base, buf _in, NBLOCS);16 /* Phase 1 : lecture image sur le disque et transfert vers buf */ 17 x = giet_ioc_read(base, buf, NBLOCS); 22 18 if ( x ) 23 19 { … … 31 27 giet_exit(); 32 28 } 33 giet_tty_printf("io _read completed at date = %d \n", giet_proctime());29 giet_tty_printf("ioc_read completed at date = %d \n", giet_proctime()); 34 30 35 /* Phase 2 : transfert de buf_in vers buf_out avec seuillage */ 36 for (i = 0; i < 128 * 128; i++) 37 { 38 if (buf_in[i] > THRESHOLD) 39 buf_out[i] = 255; 40 else 41 buf_out[i] = buf_in[i]; 42 } 43 giet_tty_printf("image processing completed at date = %d \n", giet_proctime()); 44 45 /* Phase 3 : transfert de buf_out vers le frame buffer par dma */ 46 x = giet_fb_write(0, buf_out, 128 * 128); 31 // Phase 2 : transfert de buf vers le frame buffer par dma 32 x = giet_fb_write(0, buf, 128 * 128); 47 33 if ( x ) 48 34 { … … 50 36 giet_exit(); 51 37 } 38 39 giet_tty_printf("fb_write ok at date : %d\n", giet_proctime() ); 52 40 53 41 x = giet_fb_completed(); … … 57 45 giet_exit(); 58 46 } 59 giet_tty_printf(" transfercompleted at date = %d \n", giet_proctime());47 giet_tty_printf("display completed at date = %d \n", giet_proctime()); 60 48 61 49 base = base + NBLOCS; -
soft/giet_vm/giet_config.h
r216 r218 16 16 /* Debug parameters */ 17 17 18 #define BOOT_DEBUG_PERI 0 /* trace peripherals initialisation on TTY0*/19 #define BOOT_DEBUG_PT 0 /* trace page tables initialisation on TTY0*/20 #define BOOT_DEBUG_VOBJS 0 /* trace vobjs initialisation on TTY0*/21 #define BOOT_DEBUG_SCHED 0 /* trace schedulers initialisation on TTY0*/18 #define BOOT_DEBUG_PERI 0 /* trace peripherals initialisation */ 19 #define BOOT_DEBUG_PT 0 /* trace page tables initialisation */ 20 #define BOOT_DEBUG_VOBJS 0 /* trace vobjs initialisation */ 21 #define BOOT_DEBUG_SCHED 0 /* trace schedulers initialisation */ 22 22 23 #define GIET_DEBUG_INIT 0 /* trace parallel kernel initialisation on TTY0*/24 #define GIET_DEBUG_SWITCH 0 /* trace context switchs on TTY0*/23 #define GIET_DEBUG_INIT 0 /* trace parallel kernel initialisation */ 24 #define GIET_DEBUG_SWITCH 0 /* trace context switchs */ 25 25 26 26 #define CONFIG_SRL_VERBOSITY TRACE -
soft/giet_vm/libs/stdio.c
r204 r218 33 33 #define SYSCALL_IOC_COMPLETED 0x17 34 34 #define SYSCALL_VOBJ_GET_VBASE 0x1A 35 #define SYSCALL_NIC_WRITE 0x1B 36 #define SYSCALL_NIC_READ 0x1C 37 #define SYSCALL_NIC_COMPLETED 0x1D 35 38 36 39 ////////////////////////////////////////////////////////////////////////////////// … … 645 648 ////////////////////////////////////////////////////////////////////////////////// 646 649 unsigned int giet_fb_write( unsigned int offset, 647 void* 650 void* buffer, 648 651 unsigned int length ) 649 652 { … … 667 670 ////////////////////////////////////////////////////////////////////////////////// 668 671 unsigned int giet_fb_read( unsigned int offset, 669 void* 672 void* buffer, 670 673 unsigned int length ) 671 674 { … … 685 688 { 686 689 return sys_call(SYSCALL_FB_COMPLETED, 690 0, 0, 0, 0); 691 } 692 693 ////////////////////////////////////////////////////////////////////////////////// 694 // giet_nic_write() 695 ////////////////////////////////////////////////////////////////////////////////// 696 // This non-blocking function use the DMA coprocessor to transfer data from the 697 // NIC device to an user buffer. 698 // - offset : offset (in bytes) in the NIC 699 // - buffer : base address of the memory buffer 700 // - length : number of bytes to be transfered 701 // The transfer completion is signaled by an IRQ, and must be tested by the 702 // nic_completed() function. 703 // - Returns 0 if success, > 0 if error (e.g. memory buffer not in user space). 704 ////////////////////////////////////////////////////////////////////////////////// 705 706 unsigned int giet_nic_write( unsigned int offset, 707 void* buffer, 708 unsigned int length ) 709 { 710 return sys_call(SYSCALL_NIC_WRITE, 711 offset, 712 (unsigned int)buffer, 713 length, 714 0); 715 } 716 717 ////////////////////////////////////////////////////////////////////////////////// 718 // giet_nic_read() 719 ////////////////////////////////////////////////////////////////////////////////// 720 // This non-blocking function use the DMA coprocessor to transfer data from the 721 // NIC device to an user buffer. 722 // - offset : offset (in bytes) in the NIC 723 // - buffer : base address of the memory buffer 724 // - length : number of bytes to be transfered 725 // The transfer completion is signaled by an IRQ, and must be tested by the 726 // nic_completed() function. 727 // - Returns 0 if success, > 0 if error (e.g. memory buffer not in user space). 728 ////////////////////////////////////////////////////////////////////////////////// 729 730 unsigned int giet_nic_read( unsigned int offset, 731 void* buffer, 732 unsigned int length ) 733 { 734 return sys_call(SYSCALL_NIC_READ, 735 offset, 736 (unsigned int)buffer, 737 length, 738 0); 739 } 740 741 ////////////////////////////////////////////////////////////////////////////////// 742 // giet_nic_completed() 743 ////////////////////////////////////////////////////////////////////////////////// 744 // This blocking function returns when the transfer is completed. 745 // - Returns 0 if success, > 0 if error. 746 ////////////////////////////////////////////////////////////////////////////////// 747 unsigned int giet_nic_completed() 748 { 749 return sys_call(SYSCALL_NIC_COMPLETED, 687 750 0, 0, 0, 0); 688 751 } -
soft/giet_vm/libs/stdio.h
r189 r218 52 52 void* buffer, 53 53 unsigned int length ); 54 unsigned int giet_nic_write( unsigned int offset, 55 void* buffer, 56 unsigned int length ); 57 unsigned int giet_nic_read( unsigned int offset, 58 void* buffer, 59 unsigned int length ); 54 60 unsigned int giet_fb_completed(); 61 unsigned int giet_nic_completed(); 55 62 56 63 /* Misc */ -
soft/giet_vm/mappings/4c_1p_four.xml
r215 r218 43 43 *** Boot ROM and non replicated peripherals 44 44 45 <pseg name = "PSEG_FBF" type = "PERI" base = "0x 80D00000" length = "0x00200000" />46 <pseg name = "PSEG_TTY" type = "PERI" base = "0x 80F20000" length = "0x00001000" />47 <pseg name = "PSEG_IOC" type = "PERI" base = "0x 80F10000" length = "0x00001000" />48 <pseg name = "PSEG_NIC" type = "PERI" base = "0x 80F80000" length = "0x00021000" />45 <pseg name = "PSEG_FBF" type = "PERI" base = "0xBFD00000" length = "0x00200000" /> 46 <pseg name = "PSEG_TTY" type = "PERI" base = "0xBFF20000" length = "0x00001000" /> 47 <pseg name = "PSEG_IOC" type = "PERI" base = "0xBFF10000" length = "0x00001000" /> 48 <pseg name = "PSEG_NIC" type = "PERI" base = "0xBFF80000" length = "0x00021000" /> 49 49 <pseg name = "PSEG_ROM" type = "ROM" base = "0xBFC00000" length = "0x00100000" /> 50 50 … … 95 95 96 96 <globalset> 97 <vseg name = "seg_boot_code" vbase = "0x bfc00000" mode = "CXW_" clusterid = "2" psegname = "PSEG_ROM" ident = "1" >97 <vseg name = "seg_boot_code" vbase = "0xBFC00000" mode = "CXW_" clusterid = "2" psegname = "PSEG_ROM" ident = "1" > 98 98 <vobj name = "boot_code" type = "ELF" length = "0x00008000" binpath = "build/boot/boot.elf" /> 99 99 </vseg> 100 <vseg name = "seg_boot_stack" vbase = "0x bfc08000" mode = "C_W_" clusterid = "2" psegname = "PSEG_ROM" ident = "1" >100 <vseg name = "seg_boot_stack" vbase = "0xBFC08000" mode = "C_W_" clusterid = "2" psegname = "PSEG_ROM" ident = "1" > 101 101 <vobj name = "boot_stack" type = "BUFFER" length = "0x00004000" /> 102 102 </vseg> 103 <vseg name = "seg_boot_mapping" vbase = "0x bfc0c000" mode = "C_W_" clusterid = "2" psegname = "PSEG_ROM" ident = "1" >103 <vseg name = "seg_boot_mapping" vbase = "0xBFC0c000" mode = "C_W_" clusterid = "2" psegname = "PSEG_ROM" ident = "1" > 104 104 <vobj name = "boot_mapping" type = "BLOB" length = "0x00004000" binpath = "map.bin" /> 105 105 </vseg> … … 122 122 *** Non replicated peripherals 123 123 124 <vseg name = "seg_ioc" vbase = "0x 80F10000" mode = "__W_" clusterid = "2" psegname = "PSEG_IOC" ident = "1" >124 <vseg name = "seg_ioc" vbase = "0xBFF10000" mode = "__W_" clusterid = "2" psegname = "PSEG_IOC" ident = "1" > 125 125 <vobj name = "ioc" type = "PERI" length = "0x00001000" /> 126 126 </vseg> 127 <vseg name = "seg_tty" vbase = "0x 80F20000" mode = "__W_" clusterid = "2" psegname = "PSEG_TTY" ident = "1" >127 <vseg name = "seg_tty" vbase = "0xBFF20000" mode = "__W_" clusterid = "2" psegname = "PSEG_TTY" ident = "1" > 128 128 <vobj name = "tty" type = "PERI" length = "0x00001000" /> 129 129 </vseg> 130 <vseg name = "seg_fbf" vbase = "0x 80D00000" mode = "__W_" clusterid = "2" psegname = "PSEG_FBF" ident = "1" >130 <vseg name = "seg_fbf" vbase = "0xBFD00000" mode = "__W_" clusterid = "2" psegname = "PSEG_FBF" ident = "1" > 131 131 <vobj name = "fbf" type = "PERI" length = "0x00200000" /> 132 132 </vseg> 133 <vseg name = "seg_nic" vbase = "0x 80f80000" mode = "__W_" clusterid = "2" psegname = "PSEG_NIC" ident = "1" >133 <vseg name = "seg_nic" vbase = "0xBFF80000" mode = "__W_" clusterid = "2" psegname = "PSEG_NIC" ident = "1" > 134 134 <vobj name = "nic" type = "PERI" length = "0x00021000" /> 135 135 </vseg> -
soft/giet_vm/sys/common.h
r207 r218 18 18 19 19 extern _ld_symbol_t seg_iob_base; 20 extern _ld_symbol_t seg_nic_base; 20 21 extern _ld_symbol_t seg_icu_base; 21 22 extern _ld_symbol_t seg_tim_base; -
soft/giet_vm/sys/ctx_handler.c
r199 r218 40 40 // 41 41 // ctx[0]<- ***|ctx[8] <- $8 |ctx[16]<- $16|ctx[24]<- $24|ctx[32]<- EPC |ctx[40]<- TTY 42 // ctx[1]<- $1 |ctx[9] <- $9 |ctx[17]<- $17|ctx[25]<- $25|ctx[33]<- CR |ctx[41]<- FBDMA42 // ctx[1]<- $1 |ctx[9] <- $9 |ctx[17]<- $17|ctx[25]<- $25|ctx[33]<- CR |ctx[41]<- DMA 43 43 // ctx[2]<- $2 |ctx[10]<- $10|ctx[18]<- $18|ctx[26]<- LO |ctx[34]<- SR |ctx[42]<- NIC 44 44 // ctx[3]<- $3 |ctx[11]<- $11|ctx[19]<- $19|ctx[27]<- HI |ctx[35]<- BVAR |ctx[43]<- TIMER -
soft/giet_vm/sys/ctx_handler.h
r199 r218 38 38 39 39 #define CTX_TTY_ID 40 40 #define CTX_ FBDMA_ID4141 #define CTX_NIC_ID 40 #define CTX_DMA_ID 41 41 #define CTX_NIC_ID 42 42 42 #define CTX_TIMER_ID 43 43 43 #define CTX_PTAB_ID 44 -
soft/giet_vm/sys/drivers.c
r216 r218 24 24 // - NB_TTYS 25 25 // 26 // The following virtual base addresses must be defined in the giet .ld file:26 // The following virtual base addresses must be defined in the giet_vsegs.ld file: 27 27 // - seg_icu_base 28 28 // - seg_tim_base … … 32 32 // - seg_fbf_base 33 33 // - seg_ioc_base 34 // - seg_nic_base 34 35 // As some peripherals can be replicated in the clusters (ICU, TIMER, DMA) 35 36 // These addresses must be completed by an offset depending on the cluster index … … 713 714 ////////////////////////////////////////////////////////////////////////////////// 714 715 715 //+1: for the case where the NB_DMAS_MAX == 0716 716 #if NB_DMAS_MAX > 0 717 717 in_unckdata unsigned int _dma_lock[NB_DMAS_MAX * NB_CLUSTERS] 718 = { [0 ... ( (NB_DMAS_MAX)* NB_CLUSTERS)-1] = 0 };718 = { [0 ... (NB_DMAS_MAX * NB_CLUSTERS)-1] = 0 }; 719 719 720 720 in_unckdata volatile unsigned int _dma_done[NB_DMAS_MAX * NB_CLUSTERS] … … 749 749 #endif 750 750 } 751 751 752 ////////////////////////////////////////////////////////////////////////////////// 752 753 // _dma_get_status() … … 773 774 774 775 ////////////////////////////////////////////////////////////////////////////////// 775 // VciFrameBuffer driver 776 ////////////////////////////////////////////////////////////////////////////////// 777 // The vci_frame_buffer device can be accessed directly by software with memcpy(), 778 // or it can be accessed through a multi-channels DMA component: 779 // 780 // The '_fb_sync_write' and '_fb_sync_read' functions use a memcpy strategy to 781 // implement the transfer between a data buffer (user space) and the frame 782 // buffer (kernel space). They are blocking until completion of the transfer. 783 // 784 // The '_fb_write()', '_fb_read()' and '_fb_completed()' functions use the DMA 785 // controlers (distributed in the clusters) to transfer data 786 // between the user buffer and the frame buffer. A DMA channel is 787 // allocated to each task requesting it in the mapping_info data structure. 788 ////////////////////////////////////////////////////////////////////////////////// 789 790 ////////////////////////////////////////////////////////////////////////////////// 791 // _fb_sync_write() 792 // Transfer data from an memory buffer to the frame_buffer device using 793 // a memcpy. The source memory buffer must be in user address space. 794 // - offset : offset (in bytes) in the frame buffer. 795 // - buffer : base address of the memory buffer. 796 // - length : number of bytes to be transfered. 797 // Returns 0 if success, > 0 if error. 798 ////////////////////////////////////////////////////////////////////////////////// 799 unsigned int _fb_sync_write( unsigned int offset, 800 const void* buffer, 801 unsigned int length ) 802 { 803 804 // buffer must be mapped in user space 805 if ( ((unsigned int)buffer + length ) >= 0x80000000 ) 806 { 807 return 1; 808 } 809 else 810 { 811 unsigned char *fb_address = (unsigned char*)&seg_fbf_base + offset; 812 memcpy((void*)fb_address, (void*)buffer, length); 813 return 0; 814 } 815 } 816 817 ////////////////////////////////////////////////////////////////////////////////// 818 // _fb_sync_read() 819 // Transfer data from the frame_buffer device to a memory buffer using 820 // a memcpy. The destination memory buffer must be in user address space. 821 // - offset : offset (in bytes) in the frame buffer. 822 // - buffer : base address of the memory buffer. 823 // - length : number of bytes to be transfered. 824 // Returns 0 if success, > 0 if error. 825 ////////////////////////////////////////////////////////////////////////////////// 826 unsigned int _fb_sync_read( unsigned int offset, 827 const void* buffer, 828 unsigned int length ) 829 { 830 // buffer must be mapped in user space 831 if ( ((unsigned int)buffer + length ) >= 0x80000000 ) 832 { 833 return 1; 834 } 835 else 836 { 837 unsigned char *fb_address = (unsigned char*)&seg_fbf_base + offset; 838 memcpy((void*)buffer, (void*)fb_address, length); 839 return 0; 840 } 841 } 842 843 ////////////////////////////////////////////////////////////////////////////////// 844 // _fb_dma_access() 845 // Transfer data between a user buffer and the frame_buffer using DMA. 846 // - to_user : from frame buffer to user buffer when true. 847 // - offset : offset (in bytes) in the frame buffer. 848 // - user_vaddr : virtual base address of the memory buffer. 849 // - length : number of bytes to be transfered. 776 // _dma_transfer() 777 // Transfer data between a user buffer and a device buffer using DMA. 778 // Two devices types are supported: Frame Buffer if dev_type == 0 779 // Multi-Nic if dev_type != 0 780 // Arguments are: 781 // - dev_type : device type. 782 // - to_user : from device buffer to user buffer when true. 783 // - offset : offset (in bytes) in the device buffer. 784 // - user_vaddr : virtual base address of the user buffer. 785 // - length : number of bytes to be transfered. 786 // 787 // The DMA channel is obtained from task context (CTX_FBDMA_ID / CTX_NIDMA_ID. 850 788 // The user buffer must be mapped in user address space and word-aligned. 851 789 // The user buffer length must be multiple of 4 bytes. 852 // Me must compute the physical base addresses for both the frame buffer790 // Me must compute the physical base addresses for both the device buffer 853 791 // and the user buffer before programming the DMA transfer. 854 792 // The GIET being fully static, we don't need to split the transfer in 4 Kbytes … … 856 794 // Returns 0 if success, > 0 if error. 857 795 ////////////////////////////////////////////////////////////////////////////////// 858 unsigned int _fb_dma_access( unsigned int to_user, 796 unsigned int _dma_transfer( unsigned int dev_type, 797 unsigned int to_user, 859 798 unsigned int offset, 860 799 unsigned int user_vaddr, … … 862 801 { 863 802 #if NB_DMAS_MAX > 0 864 unsigned int ko; // unsuccessfull V2P translation 865 unsigned int flags; // protection flags 866 unsigned int ppn; // physical page number 867 unsigned int user_pbase; // user buffer pbase address 868 unsigned int fb_pbase; // frame buffer pbase address 803 unsigned int ko; // unsuccessfull V2P translation 804 unsigned int flags; // protection flags 805 unsigned int ppn; // physical page number 806 unsigned int user_pbase; // user buffer pbase address 807 unsigned int device_pbase; // frame buffer pbase address 808 unsigned int device_vaddr; // device buffer vbase address 809 810 // check user buffer address and length alignment 811 if ( (user_vaddr & 0x3) || (length & 0x3) ) 812 { 813 _get_lock(&_tty_put_lock); 814 _puts("\n[GIET ERROR] in _dma_transfer : user buffer not word aligned\n"); 815 _release_lock(&_tty_put_lock); 816 return 1; 817 } 869 818 870 819 // get DMA channel and compute DMA vbase address 871 820 unsigned int task_id = _get_current_task_id(); 872 unsigned int dma_id = _get_context_slot( task_id, CTX_FBDMA_ID );821 unsigned int dma_id = _get_context_slot( task_id, CTX_DMA_ID ); 873 822 unsigned int cluster_id = dma_id / NB_DMAS_MAX; 874 823 unsigned int loc_id = dma_id % NB_DMAS_MAX; 875 876 unsigned int* dma_base = (unsigned int*)( (char*)&seg_dma_base + 877 (cluster_id * (unsigned)CLUSTER_SIZE) ); 878 879 // check user buffer address and length alignment 880 if ( (user_vaddr & 0x3) || (length & 0x3) ) 881 { 882 _get_lock(&_tty_put_lock); 883 _puts("\n[GIET ERROR] in _fbdma_access() : user buffer not word aligned\n"); 884 _release_lock(&_tty_put_lock); 885 return 1; 886 } 887 888 // get user space page table virtual address 824 unsigned int* dma_base = (unsigned int*)( (char*)&seg_dma_base + 825 (cluster_id * (unsigned)CLUSTER_SIZE) ); 826 827 // get page table address 889 828 unsigned int user_ptab = _get_context_slot( task_id, CTX_PTAB_ID ); 890 829 891 // compute frame buffer pbase address 892 unsigned int fb_vaddr = (unsigned int)&seg_fbf_base + offset; 893 830 // get peripheral buffer virtual address 831 if ( dev_type) device_vaddr = (unsigned int)&seg_nic_base + offset; 832 else device_vaddr = (unsigned int)&seg_fbf_base + offset; 833 834 // get device buffer physical address 894 835 ko = _v2p_translate( (page_table_t*)user_ptab, 895 ( fb_vaddr >> 12),836 (device_vaddr >> 12), 896 837 &ppn, 897 838 &flags ); 898 fb_pbase = (ppn << 12) | (fb_vaddr & 0x00000FFF);899 900 839 if ( ko ) 901 840 { 902 841 _get_lock(&_tty_put_lock); 903 _puts("\n[GIET ERROR] in _ fbdma_access() : frame buffer unmapped\n");842 _puts("\n[GIET ERROR] in _dma_transfer : device buffer unmapped\n"); 904 843 _release_lock(&_tty_put_lock); 905 844 return 2; 906 845 } 907 908 // Compute user buffer pbase address 846 device_pbase = (ppn << 12) | (device_vaddr & 0x00000FFF); 847 848 // Compute user buffer physical address 909 849 ko = _v2p_translate( (page_table_t*)user_ptab, 910 850 (user_vaddr >> 12), 911 851 &ppn, 912 852 &flags ); 913 user_pbase = (ppn << 12) | (user_vaddr & 0x00000FFF);914 915 853 if ( ko ) 916 854 { 917 855 _get_lock(&_tty_put_lock); 918 _puts("\n[GIET ERROR] in _ fbdma_access() : user buffer unmapped\n");856 _puts("\n[GIET ERROR] in _dma_transfer() : user buffer unmapped\n"); 919 857 _release_lock(&_tty_put_lock); 920 858 return 3; … … 923 861 { 924 862 _get_lock(&_tty_put_lock); 925 _puts("[GIET ERROR] in _ fbdma_access() : user buffer not in user space\n");863 _puts("[GIET ERROR] in _dma_transfer() : user buffer not in user space\n"); 926 864 _release_lock(&_tty_put_lock); 927 865 return 4; … … 930 868 { 931 869 _get_lock(&_tty_put_lock); 932 _puts("\n[GIET ERROR] in _ fbdma_access() : user buffer not writable\n");870 _puts("\n[GIET ERROR] in _dma_transfer() : user buffer not writable\n"); 933 871 _release_lock(&_tty_put_lock); 934 872 return 5; 935 873 } 936 937 938 939 /* 874 user_pbase = (ppn << 12) | (user_vaddr & 0x00000FFF); 875 876 /* This is a draft for IOMMU support 877 940 878 // loop on all virtual pages covering the user buffer 941 879 unsigned int user_vpn_min = user_vaddr >> 12; … … 987 925 // invalidate data cache in case of memory write 988 926 if ( to_user ) _dcache_buf_invalidate( (void*)user_vaddr, length ); 989 927 990 928 // get the lock 991 929 _get_lock( &_dma_lock[dma_id] ); … … 994 932 if ( to_user ) 995 933 { 996 dma_base[loc_id*DMA_SPAN + DMA_SRC] = (unsigned int) fb_pbase;934 dma_base[loc_id*DMA_SPAN + DMA_SRC] = (unsigned int)device_pbase; 997 935 dma_base[loc_id*DMA_SPAN + DMA_DST] = (unsigned int)user_pbase; 998 936 } … … 1000 938 { 1001 939 dma_base[loc_id*DMA_SPAN + DMA_SRC] = (unsigned int)user_pbase; 1002 dma_base[loc_id*DMA_SPAN + DMA_DST] = (unsigned int) fb_pbase;940 dma_base[loc_id*DMA_SPAN + DMA_DST] = (unsigned int)device_pbase; 1003 941 } 1004 942 dma_base[loc_id*DMA_SPAN + DMA_LEN] = (unsigned int)length; … … 1007 945 1008 946 #else //NB_DMAS_MAX == 0 947 1009 948 return -1; 1010 #endif 1011 } 949 950 #endif 951 } // end _dma_transfer() 952 953 ////////////////////////////////////////////////////////////////////////////////// 954 // _dma_completed() 955 // This function checks completion of a DMA transfer to or from a peripheral 956 // device (Frame Buffer or Multi-Nic). 957 // As it is a blocking call, the processor is busy waiting. 958 // Returns 0 if success, > 0 if error 959 // (1 == read error / 2 == DMA idle error / 3 == write error) 960 ////////////////////////////////////////////////////////////////////////////////// 961 unsigned int _dma_completed() 962 { 963 #if NB_DMAS_MAX > 0 964 unsigned int task_id = _get_current_task_id(); 965 unsigned int dma_id = _get_context_slot( task_id, CTX_DMA_ID ); 966 967 // busy waiting with a pseudo random delay between bus access 968 while (_dma_done[dma_id] == 0) 969 { 970 unsigned int delay = (( _proctime() ^ _procid()<<4 ) & 0x3F) + 1; 971 asm volatile("move $3, %0 \n" 972 "loop_nic_completed: \n" 973 "addi $3, $3, -1 \n" 974 "bnez $3, loop_nic_completed \n" 975 "nop \n" 976 : 977 : "r"(delay) 978 : "$3" ); 979 } 980 981 /* draft support for IOMMU 982 // unmap the buffer from IOMMU page table if IOMMU is activated 983 if ( GIET_IOMMU_ACTIVE ) 984 { 985 unsigned int* iob_address = (unsigned int*)&seg_iob_base; 986 987 unsigned int ix1 = _dma_iommu_ix1 + dma_id; 988 unsigned int ix2; 989 990 for ( ix2 = 0 ; ix2 < _dma_iommu_npages[dma_id] ; ix2++ ) 991 { 992 // unmap the page in IOMMU page table 993 _iommu_inval_pte2( ix1, // PT1 index 994 ix2 ); // PT2 index 995 996 // clear IOMMU TLB 997 iob_address[IOB_INVAL_PTE] = (ix1 << 21) | (ix2 << 12); 998 } 999 } 1000 */ 1001 1002 // reset synchronization variables 1003 _dma_lock[dma_id] = 0; 1004 _dma_done[dma_id] = 0; 1005 1006 return _dma_status[dma_id]; 1007 1008 #else //NB_DMAS_MAX == 0 1009 return -1; 1010 #endif 1011 } // end _dma_completed 1012 1013 ////////////////////////////////////////////////////////////////////////////////// 1014 // VciFrameBuffer driver 1015 ////////////////////////////////////////////////////////////////////////////////// 1016 // The vci_frame_buffer device can be accessed directly by software with memcpy(), 1017 // or it can be accessed through a multi-channels DMA component: 1018 // 1019 // The '_fb_sync_write' and '_fb_sync_read' functions use a memcpy strategy to 1020 // implement the transfer between a data buffer (user space) and the frame 1021 // buffer (kernel space). They are blocking until completion of the transfer. 1022 // 1023 // The '_fb_write()', '_fb_read()' and '_fb_completed()' functions use the 1024 // VciMultiDma components (distributed in the clusters) to transfer data 1025 // between the user buffer and the frame buffer. A FBDMA channel is 1026 // allocated to each task requesting it in the mapping_info data structure. 1027 ////////////////////////////////////////////////////////////////////////////////// 1028 1029 ////////////////////////////////////////////////////////////////////////////////// 1030 // _fb_sync_write() 1031 // Transfer data from an memory buffer to the frame_buffer device using a memcpy. 1032 // - offset : offset (in bytes) in the frame buffer. 1033 // - buffer : base address of the memory buffer. 1034 // - length : number of bytes to be transfered. 1035 ////////////////////////////////////////////////////////////////////////////////// 1036 unsigned int _fb_sync_write( unsigned int offset, 1037 const void* buffer, 1038 unsigned int length ) 1039 { 1040 unsigned char *fb_address = (unsigned char*)&seg_fbf_base + offset; 1041 memcpy((void*)fb_address, (void*)buffer, length); 1042 return 0; 1043 } 1044 1045 ////////////////////////////////////////////////////////////////////////////////// 1046 // _fb_sync_read() 1047 // Transfer data from the frame_buffer device to a memory buffer using a memcpy. 1048 // - offset : offset (in bytes) in the frame buffer. 1049 // - buffer : base address of the memory buffer. 1050 // - length : number of bytes to be transfered. 1051 ////////////////////////////////////////////////////////////////////////////////// 1052 unsigned int _fb_sync_read( unsigned int offset, 1053 const void* buffer, 1054 unsigned int length ) 1055 { 1056 unsigned char *fb_address = (unsigned char*)&seg_fbf_base + offset; 1057 memcpy((void*)buffer, (void*)fb_address, length); 1058 return 0; 1059 } 1060 1012 1061 ////////////////////////////////////////////////////////////////////////////////// 1013 1062 // _fb_write() … … 1019 1068 ////////////////////////////////////////////////////////////////////////////////// 1020 1069 unsigned int _fb_write( unsigned int offset, 1021 const void*buffer,1070 const void* buffer, 1022 1071 unsigned int length ) 1023 1072 { 1024 return _fb_dma_access( 0, // write to frame buffer 1025 offset, 1026 (unsigned int)buffer, 1027 length ); 1073 return _dma_transfer( 0, // frame buffer 1074 0, // write 1075 offset, 1076 (unsigned int)buffer, 1077 length ); 1028 1078 } 1029 1079 … … 1040 1090 unsigned int length ) 1041 1091 { 1042 return _fb_dma_access( 1, // read from frame buffer 1043 offset, 1044 (unsigned int)buffer, 1045 length ); 1092 return _dma_transfer( 0, // frame buffer 1093 1, // read 1094 offset, 1095 (unsigned int)buffer, 1096 length ); 1046 1097 } 1047 1098 … … 1055 1106 unsigned int _fb_completed() 1056 1107 { 1057 #if NB_DMAS_MAX > 0 1058 unsigned int task_id = _get_current_task_id(); 1059 unsigned int dma_id = _get_context_slot( task_id, CTX_FBDMA_ID ); 1060 1061 // busy waiting with a pseudo random delay between bus access 1062 while (_dma_done[dma_id] == 0) 1063 { 1064 unsigned int i; 1065 unsigned int delay = ( _proctime() ^ _procid()<<4 ) & 0xFF; 1066 for (i = 0; i < delay; i++) 1067 asm volatile("nop"); 1068 } 1069 1070 // unmap the buffer from IOMMU page table if IOMMU is activated 1071 if ( IOMMU_ACTIVE ) 1072 { 1073 unsigned int* iob_address = (unsigned int*) &seg_iob_base; 1074 1075 unsigned int ix1 = _dma_iommu_ix1 + dma_id; 1076 unsigned int ix2; 1077 1078 for ( ix2 = 0 ; ix2 < _dma_iommu_npages[dma_id] ; ix2++ ) 1079 { 1080 // unmap the page in IOMMU page table 1081 _iommu_inval_pte2( ix1, // PT1 index 1082 ix2 ); // PT2 index 1083 1084 // clear IOMMU TLB 1085 iob_address[IOB_INVAL_PTE] = (ix1 << 21) | (ix2 << 12); 1086 } 1087 } 1088 1089 // reset synchronization variables 1090 _dma_lock[dma_id] = 0; 1091 _dma_done[dma_id] = 0; 1092 1093 return _dma_status[dma_id]; 1094 1095 #else //NB_DMAS_MAX == 0 1096 1097 return -1; 1098 1099 #endif 1100 } 1101 1108 return _dma_completed(); 1109 } 1110 1111 ////////////////////////////////////////////////////////////////////////////////// 1112 // VciMultiNic driver 1113 ////////////////////////////////////////////////////////////////////////////////// 1114 // The VciMultiNic device can be accessed directly by software with memcpy(), 1115 // or it can be accessed through a multi-channels DMA component: 1116 // 1117 // The '_nic_sync_write' and '_nic_sync_read' functions use a memcpy strategy to 1118 // implement the transfer between a data buffer (user space) and the NIC 1119 // buffer (kernel space). They are blocking until completion of the transfer. 1120 // 1121 // The '_nic_write()', '_nic_read()' and '_nic_completed()' functions use the 1122 // VciMultiDma components (distributed in the clusters) to transfer data 1123 // between the user buffer and the NIC. A NIDMA channel is allocated to each 1124 // task requesting it in the mapping_info data structure. 1125 ////////////////////////////////////////////////////////////////////////////////// 1126 1127 ////////////////////////////////////////////////////////////////////////////////// 1128 // _nic_sync_write() 1129 // Transfer data from an memory buffer to the NIC device using a memcpy. 1130 // - offset : offset (in bytes) in the frame buffer. 1131 // - buffer : base address of the memory buffer. 1132 // - length : number of bytes to be transfered. 1133 ////////////////////////////////////////////////////////////////////////////////// 1134 unsigned int _nic_sync_write( unsigned int offset, 1135 const void* buffer, 1136 unsigned int length ) 1137 { 1138 unsigned char *nic_address = (unsigned char*)&seg_nic_base + offset; 1139 memcpy((void*)nic_address, (void*)buffer, length); 1140 return 0; 1141 } 1142 1143 ////////////////////////////////////////////////////////////////////////////////// 1144 // _nic_sync_read() 1145 // Transfer data from the NIC device to a memory buffer using a memcpy. 1146 // - offset : offset (in bytes) in the frame buffer. 1147 // - buffer : base address of the memory buffer. 1148 // - length : number of bytes to be transfered. 1149 ////////////////////////////////////////////////////////////////////////////////// 1150 unsigned int _nic_sync_read( unsigned int offset, 1151 const void* buffer, 1152 unsigned int length ) 1153 { 1154 unsigned char *nic_address = (unsigned char*)&seg_nic_base + offset; 1155 memcpy((void*)buffer, (void*)nic_address, length); 1156 return 0; 1157 } 1158 1159 ////////////////////////////////////////////////////////////////////////////////// 1160 // _nic_write() 1161 // Transfer data from a memory buffer to the NIC device using DMA. 1162 // - offset : offset (in bytes) in the frame buffer. 1163 // - buffer : base address of the memory buffer. 1164 // - length : number of bytes to be transfered. 1165 // Returns 0 if success, > 0 if error. 1166 ////////////////////////////////////////////////////////////////////////////////// 1167 unsigned int _nic_write( unsigned int offset, 1168 const void* buffer, 1169 unsigned int length ) 1170 { 1171 return _dma_transfer( 1, // NIC 1172 0, // write 1173 offset, 1174 (unsigned int)buffer, 1175 length ); 1176 } 1177 1178 ////////////////////////////////////////////////////////////////////////////////// 1179 // _nic_read() 1180 // Transfer data from the NIC device to a memory buffer using DMA. 1181 // - offset : offset (in bytes) in the frame buffer. 1182 // - buffer : base address of the memory buffer. 1183 // - length : number of bytes to be transfered. 1184 // Returns 0 if success, > 0 if error. 1185 ////////////////////////////////////////////////////////////////////////////////// 1186 unsigned int _nic_read( unsigned int offset, 1187 const void* buffer, 1188 unsigned int length ) 1189 { 1190 return _dma_transfer( 1, // NIC 1191 1, // read 1192 offset, 1193 (unsigned int)buffer, 1194 length ); 1195 } 1196 1197 ////////////////////////////////////////////////////////////////////////////////// 1198 // _nic_completed() 1199 // This function checks completion of a DMA transfer to or fom a NIC channel. 1200 // As it is a blocking call, the processor is busy waiting. 1201 // Returns 0 if success, > 0 if error 1202 // (1 == read error / 2 == DMA idle error / 3 == write error) 1203 ////////////////////////////////////////////////////////////////////////////////// 1204 unsigned int _nic_completed() 1205 { 1206 return _dma_completed(); 1207 } 1208 -
soft/giet_vm/sys/drivers.h
r207 r218 8 8 #ifndef _GIET_SYS_DRIVERS_H_ 9 9 #define _GIET_SYS_DRIVERS_H_ 10 10 11 11 12 /////////////////////////////////////////////////////////////////////////////////// … … 96 97 unsigned int* status ); 97 98 99 unsigned int _dma_transfer( unsigned int dev_type, 100 unsigned int to_user, 101 unsigned int offset, 102 unsigned int user_vaddr, 103 unsigned int length ); 104 105 unsigned int _dma_completed(); 106 98 107 /////////////////////////////////////////////////////////////////////////////////// 99 108 // Frame Buffer access functions (vci_frame_buffer) … … 119 128 120 129 /////////////////////////////////////////////////////////////////////////////////// 130 // NIC device access functions (vci_multi_nic) 131 /////////////////////////////////////////////////////////////////////////////////// 132 133 unsigned int _nic_sync_write(unsigned int offset, 134 const void* buffer, 135 unsigned int length); 136 137 unsigned int _nic_sync_read( unsigned int offset, 138 const void* buffer, 139 unsigned int length); 140 141 142 unsigned int _nic_write( unsigned int offset, 143 const void* buffer, 144 unsigned int length); 145 146 unsigned int _nic_read( unsigned int offset, 147 const void* buffer, 148 unsigned int length); 149 150 unsigned int _nic_completed(); 151 152 /////////////////////////////////////////////////////////////////////////////////// 121 153 // GCD access functions 122 154 /////////////////////////////////////////////////////////////////////////////////// -
soft/giet_vm/sys/exc_handler.c
r207 r218 68 68 static void _display_cause(unsigned int type) 69 69 { 70 _get_lock(&_tty_put_lock); 70 71 _puts("\n[GIET] Exception for task "); 71 72 _putd( _get_current_task_id() ); … … 81 82 _putx( _get_bvar() ); 82 83 _puts("\n"); 84 _puts("...Task desactivated\n"); 85 _release_lock(&_tty_put_lock); 83 86 84 87 // goes to sleeping state -
soft/giet_vm/sys/kernel_init.c
r216 r218 33 33 34 34 /////////////////////////////////////////////////////////////////////////////////// 35 // Kernel Global variables35 // array of pointers on the page tables (both virtual and physical addresses) 36 36 /////////////////////////////////////////////////////////////////////////////////// 37 37 … … 42 42 unsigned int _ptabs_vaddr[GIET_NB_VSPACE_MAX]; 43 43 44 /////////////////////////////////////////////////////////////////////////////////// 45 // array of pointers on the schedulers (physical addresses) 46 /////////////////////////////////////////////////////////////////////////////////// 47 44 48 __attribute__((section (".kdata"))) 45 49 static_scheduler_t* _schedulers_paddr[NB_CLUSTERS*NB_PROCS_MAX]; 50 51 /////////////////////////////////////////////////////////////////////////////////// 52 // staks for the "idle" tasks (256 bytes for each processor) 53 /////////////////////////////////////////////////////////////////////////////////// 46 54 47 55 __attribute__((section (".kdata"))) … … 201 209 } 202 210 203 // step 5 : initialise the "idle" task context211 // step 5 : initialise, for each processor, the "idle" task context: 204 212 // the SR initialisation value is 0xFF03 because 205 // the task _ctx_idle() executes in kernel mode. ..213 // the task _ctx_idle() executes in kernel mode. 206 214 // it uses the page table of vspace[0] 215 // the stack size is 256 bytes 207 216 208 217 _set_context_slot( IDLE_TASK_INDEX, CTX_RUN_ID, 1 ); 209 218 _set_context_slot( IDLE_TASK_INDEX, CTX_SR_ID, 0xFF03 ); 210 _set_context_slot( IDLE_TASK_INDEX, CTX_SP_ID, (unsigned int) &_idle_stack[global_pid] + 64);219 _set_context_slot( IDLE_TASK_INDEX, CTX_SP_ID, (unsigned int)_idle_stack + (global_pid<<8) ); 211 220 _set_context_slot( IDLE_TASK_INDEX, CTX_RA_ID, (unsigned int)&_ctx_eret ); 212 221 _set_context_slot( IDLE_TASK_INDEX, CTX_EPC_ID, (unsigned int)&_ctx_idle ); … … 233 242 234 243 _get_lock( &_tty_put_lock ); 235 _puts("\n 244 _puts("\n[GIET WARNING] No task allocated to processor "); 236 245 _putd( global_pid ); 237 246 _puts(" => idle\n"); -
soft/giet_vm/sys/sys_handler.c
r215 r218 49 49 &_sys_ukn, /* 0x19 */ 50 50 &_vobj_get_vbase, /* 0x1A */ 51 &_ sys_ukn,/* 0x1B */52 &_ sys_ukn,/* 0x1C */53 &_ sys_ukn,/* 0x1D */51 &_nic_write, /* 0x1B */ 52 &_nic_read, /* 0x1C */ 53 &_nic_completed, /* 0x1D */ 54 54 &_sys_ukn, /* 0x1E */ 55 55 &_sys_ukn, /* 0x1F */ -
soft/giet_vm/xml/xml_parser.c
r217 r218 138 138 unsigned int dma_base_offset = 0xFFFFFFFF; 139 139 unsigned int ioc_base_offset = 0xFFFFFFFF; 140 unsigned int nic_base_offset = 0xFFFFFFFF; 140 141 unsigned int fbf_base_offset = 0xFFFFFFFF; 141 142 unsigned int icu_base_offset = 0xFFFFFFFF; … … 1094 1095 else error = 1; 1095 1096 1096 //nic_base_offset = pseg[ periph[periph_index]->psegid ]->base;1097 nic_base_offset = pseg[ periph[periph_index]->psegid ]->base; 1097 1098 nb_nic_channel = periph[periph_index]->channels; 1098 1099 } … … 2165 2166 ld_write(fdout, "seg_icu_base" , icu_base_offset); 2166 2167 ld_write(fdout, "seg_ioc_base" , ioc_base_offset); 2168 ld_write(fdout, "seg_nic_base" , nic_base_offset); 2167 2169 ld_write(fdout, "seg_tty_base" , tty_base_offset); 2168 2170 ld_write(fdout, "seg_dma_base" , dma_base_offset);
Note: See TracChangeset
for help on using the changeset viewer.