Changeset 518 for soft/giet_vm
- Timestamp:
- Mar 10, 2015, 2:58:59 PM (10 years ago)
- Location:
- soft/giet_vm/giet_drivers
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_drivers/dma_driver.h
r437 r518 1 ////////////////////////////////////////////////////////////////////////////////// /1 ////////////////////////////////////////////////////////////////////////////////// 2 2 // File : dma_driver.h 3 3 // Date : 01/11/2013 4 4 // Author : alain greiner 5 5 // Copyright (c) UPMC-LIP6 6 ////////////////////////////////////////////////////////////////////////////////// /6 ////////////////////////////////////////////////////////////////////////////////// 7 7 // The dma_driver.c and dma_driver.h files are part ot the GIET-VM nano-kernel. 8 8 // This driver supports the SoCLib vci_multi_dma component. … … 24 24 // 25 25 // The SEG_DMA_BASE virtual address mus be defined in the hard_config.h file. 26 ////////////////////////////////////////////////////////////////////////////////// //26 ////////////////////////////////////////////////////////////////////////////////// 27 27 28 28 #ifndef _GIET_DMA_DRIVER_H_ 29 29 #define _GIET_DMA_DRIVER_H_ 30 30 31 ////////////////////////////////////////////////////////////////////////////////// /31 ////////////////////////////////////////////////////////////////////////////////// 32 32 // Multi DMA registers offset 33 ////////////////////////////////////////////////////////////////////////////////// /33 ////////////////////////////////////////////////////////////////////////////////// 34 34 35 35 enum DMA_registers … … 57 57 58 58 59 /////////////////////////////////////////////////////////////////////////////// 59 ////////////////////////////////////////////////////////////////////////////////// 60 60 // low-level access functions 61 /////////////////////////////////////////////////////////////////////////////// 61 ////////////////////////////////////////////////////////////////////////////////// 62 62 63 63 ////////////////////////////////////////////////////////////////////////////////// … … 98 98 ////////////////////////////////////////////////////////////////////////////////// 99 99 100 ////////////////////////////////////////////////////////////////////////////////// /100 ////////////////////////////////////////////////////////////////////////////////// 101 101 // This function copies a source memory buffer to a destination memory buffer, 102 102 // using directly physical addresses. … … 108 108 // In case of error (buffer unmapped, unaligned, or DMA_STATUS error), an error 109 109 // message is displayed on TTY0, and system crash. 110 ////////////////////////////////////////////////////////////////////////////////// /110 ////////////////////////////////////////////////////////////////////////////////// 111 111 extern void _dma_physical_copy( unsigned int cluster_xy, 112 112 unsigned int channel_id, … … 115 115 unsigned int size ); 116 116 117 ////////////////////////////////////////////////////////////////////////////////// /117 ////////////////////////////////////////////////////////////////////////////////// 118 118 // This function copies a source memory buffer to a destination memory buffer, 119 119 // making virtual to physical address translation: the MMU should be activated. … … 125 125 // In case of error (buffer unmapped, unaligned, or DMA_STATUS error), an error 126 126 // message is displayed on TTY0, and system crash. 127 ////////////////////////////////////////////////////////////////////////////////// /127 ////////////////////////////////////////////////////////////////////////////////// 128 128 extern void _dma_copy( unsigned int cluster_xy, 129 129 unsigned int channel_id, … … 133 133 unsigned int size ); 134 134 135 /////////////////////////////////////////////////////////////////////////////// 135 ////////////////////////////////////////////////////////////////////////////////// 136 136 // This ISR should not be used by the GIET_VM, because the DMA is only 137 137 // used by the kernel in the boot phase, with a polling strategy. 138 /////////////////////////////////////////////////////////////////////////////// 138 ////////////////////////////////////////////////////////////////////////////////// 139 139 extern void _dma_isr( unsigned int irq_type, 140 140 unsigned int irq_id, -
soft/giet_vm/giet_drivers/mwr_driver.c
r456 r518 1 1 /////////////////////////////////////////////////////////////////////////////////// 2 2 // File : mwr_driver.c 3 // Date : 2 3/05/20133 // Date : 27/02/2015 4 4 // Author : alain greiner 5 5 // Copyright (c) UPMC-LIP6 6 6 /////////////////////////////////////////////////////////////////////////////////// 7 // The mwmr_driver.c and mwmr_driver.h files are part ot the GIET-VM nano-kernel.8 // This driver supports the SoClib vci_mwmr_controller component.9 //10 // This peripheral can be replicated (at most one component per cluster).11 //12 // The (virtual) base address of the associated segment is:13 // SEG_MWR_BASE + cluster_xy * PERI_CLUSTER_INCREMENT14 //15 // SEG_MWR_BASE and PERI_CLUSTER_INCREMENT must be defined in hard_config.h16 ////////////////////////////////////////////////////////////////////////////////17 7 18 8 #include <giet_config.h> 19 9 #include <hard_config.h> 10 #include <mapping_info.h> 20 11 #include <mwr_driver.h> 21 12 #include <utils.h> 22 13 #include <tty0.h> 14 #include <io.h> 23 15 24 16 #if !defined(X_SIZE) … … 46 38 #endif 47 39 48 ////////////////////////////////////////////////////////////////////////////////// 49 // _mwr_hw_init() 50 // This function initializes one MWMR controller channel (i.e. one coprocessor 51 // port) in a given cluster. 52 // - cluster_xy : cluster index 53 // _ port_id : port index 54 // - way : direction (to_coproc/from_coproc) 55 // - channel_pbase : physical base address of the MWMR channel 56 // TODO : The MWMR controler should be modified to support 40 bits addresses... 57 // Introduce a MWMR_CONFIG_PADDR_EXT register in the MWMR coprocessor 58 ////////////////////////////////////////////////////////////////////////////////// 59 // Returns 0 if success, returns > 0 if error. 60 ////////////////////////////////////////////////////////////////////////////////// 61 unsigned int _mwr_hw_init( unsigned int cluster_xy, 62 unsigned int port_id, 63 unsigned int from_coproc, 64 paddr_t channel_pbase ) 40 extern unsigned int _coproc_done[X_SIZE*Y_SIZE]; 41 42 ///////////////////////////////////////////////////////////////////////////// 43 // This function returns the value contained in a private register 44 // of the coprocessor contained in cluster "cluster_xy". 45 ///////////////////////////////////////////////////////////////////////////// 46 unsigned int _mwr_get_coproc_register( unsigned int cluster_xy, // cluster 47 unsigned int index ) // register 65 48 { 66 _puts(" [GIET_ERROR] _mwr_hw_init() function not supported yet\n"); 67 _exit(); 49 unsigned int vaddr = 50 SEG_MWR_BASE + 51 (cluster_xy * PERI_CLUSTER_INCREMENT) + 52 (index << 2); 68 53 69 /* 70 // parameters checking 71 unsigned int x = cluster_xy >> Y_WIDTH; 72 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 73 if (x >= X_SIZE) return 1; 74 if (y >= Y_SIZE) return 1; 54 return ioread32( (void*)vaddr ); 55 } 75 56 76 // compute base address 77 unsigned int* mwr_address = (unsigned int*) ( SEG_MWR_BASE + 78 (cluster_xy * PERI_CLUSTER_INCREMENT) ); 57 ///////////////////////////////////////////////////////////////////////////// 58 // This function sets a new value in a private register 59 // of the coprocessor contained in cluster "clustenr_xy". 60 ///////////////////////////////////////////////////////////////////////////// 61 void _mwr_set_coproc_register( unsigned int cluster_xy, // cluster index 62 unsigned int index, // register index 63 unsigned int value ) // writte value 64 { 65 unsigned int vaddr = 66 SEG_MWR_BASE + 67 (cluster_xy * PERI_CLUSTER_INCREMENT) + 68 (index << 2); 69 70 iowrite32( (void*)vaddr, value ); 71 } 79 72 80 unsigned int lsb = (unsigned int)channel_pbase; 81 unsigned int msb = (unsigned int)(channel_pbase>>32); 73 ///////////////////////////////////////////////////////////////////////////// 74 // This function returns the value contained in a channel register 75 // defined by the "index" and "channel" arguments, in the MWMR_DMA component 76 // contained in cluster "cluster_xy". 77 ///////////////////////////////////////////////////////////////////////////// 78 unsigned int _mwr_get_channel_register( unsigned int cluster_xy, // cluster 79 unsigned int channel, // channel 80 unsigned int index ) // register 81 { 82 unsigned int vaddr = 83 SEG_MWR_BASE + 84 (cluster_xy * PERI_CLUSTER_INCREMENT) + 85 ((channel + 1) * (CHANNEL_SPAN << 2)) + 86 (index << 2); 82 87 83 // get depth and width from channel itself 84 unsigned int depth = _physical_read( channel_pbase + 16 ); 85 unsigned int width = _physical_read( channel_pbase + 20 ); 88 return ioread32( (void*)vaddr ); 89 } 86 90 87 // initializes and launches mwmr controler 88 mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_FIFO_WAY] = from_coproc; 89 mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_FIFO_NO] = port_id; 90 mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_WIDTH] = width; 91 mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_DEPTH] = depth; 92 mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_STATUS] = lsb; 93 mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_DATA] = lsb + 24; 94 mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_EXT] = msb; 95 mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_RUNNING] = 1; 96 */ 97 return 0; 91 ///////////////////////////////////////////////////////////////////////////// 92 // This function sets a new value in a channel register 93 // defined by the "index" and "channel") arguments, in the MWMR_DMA component 94 // contained in cluster "cluster_xy". 95 ///////////////////////////////////////////////////////////////////////////// 96 void _mwr_set_channel_register( unsigned int cluster_xy, // cluster index 97 unsigned int channel, // channel index 98 unsigned int index, // register index 99 unsigned int value ) // written value 100 { 101 unsigned int vaddr = 102 SEG_MWR_BASE + 103 (cluster_xy * PERI_CLUSTER_INCREMENT) + 104 ((channel + 1) * (CHANNEL_SPAN << 2)) + 105 (index << 2); 106 107 iowrite32( (void*)vaddr, value ); 98 108 } 109 110 /////////////////////////////////////////////////////// 111 void _mwr_isr( unsigned int irq_type, // should be HWI 112 unsigned int irq_id, // index returned by XCU 113 unsigned int channel ) // MWMR_DMA channel 114 { 115 unsigned int gpid = _get_procid(); 116 unsigned int cluster_xy = gpid >> P_WIDTH; 117 unsigned int x = cluster_xy >> Y_WIDTH; 118 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 119 120 // acknowledge IRQ 121 _mwr_set_channel_register( cluster_xy, channel, CHANNEL_RUNNING, 0 ); 122 123 // compute coproc_id from cluster coordinates 124 unsigned int coproc_id = x * Y_SIZE + y; 125 126 // set synchronisation variable 127 _coproc_done[coproc_id] = 1; 128 } 129 99 130 100 131 -
soft/giet_vm/giet_drivers/mwr_driver.h
r263 r518 4 4 // Author : alain greiner 5 5 // Copyright (c) UPMC-LIP6 6 /////////////////////////////////////////////////////////////////////////////////// 6 /////////////////////////////////////////////////////////////////////////////// 7 // The mwr_driver.c and mwr_driver.h files are part ot the GIET-VM OS. 8 // This driver supports the SoCLib vci_mwmr_dma component. 9 // 10 // It can exist several MWMR_DMA controlers in the architecture 11 // (one per cluster), and each controller can contain several ports. 12 // Each port defines a TO_COPROC or FROM_COPROC communication channel. 13 // Each channel can be configured to run in one of three predefined modes 14 // (MWMR / DMA_IRQ / DMA_NO_IRQ). 15 // The MWMR_DMA controler is a private ressource, allocated to a given task. 16 // 17 // The virtual base address of the segment associated to the coprocessor 18 // addressable registers is: 19 // SEG_MWR_BASE + cluster_xy*PERI_CLUSTER_INCREMENT 20 // 21 // The virtual base address of the segments associated to a channel is: 22 // SEG_MWR_BASE + 23 // cluster_xy * PERI_CLUSTER_INCREMENT + 24 // 4 * CHANNEL_SPAN * (channel+1) 25 // 26 // The SEG_MWR_BASE virtual address mus be defined in the hard_config.h file. 27 /////////////////////////////////////////////////////////////////////////////// 7 28 8 29 #ifndef _GIET_MWR_DRIVERS_H_ 9 30 #define _GIET_MWR_DRIVERS_H_ 10 31 11 /////////////////////////////////////////////////////////////////////////////// ////32 /////////////////////////////////////////////////////////////////////////////// 12 33 // MWMR controler registers offsets 13 /////////////////////////////////////////////////////////////////////////////// ////34 /////////////////////////////////////////////////////////////////////////////// 14 35 15 enum SoclibMwmrRegisters36 enum MwmrDmaRegisters 16 37 { 17 MWMR_IOREG_MAX = 16, 18 MWMR_RESET = MWMR_IOREG_MAX, 19 MWMR_CONFIG_FIFO_WAY, 20 MWMR_CONFIG_FIFO_NO, 21 MWMR_CONFIG_STATUS, 22 MWMR_CONFIG_DEPTH, 23 MWMR_CONFIG_BUFFER_ADDR, 24 MWMR_CONFIG_RUNNING, 25 MWMR_CONFIG_WIDTH, 26 MWMR_CONFIG_DATA, 27 MWMR_CONFIG_EXT, 28 /***/ 29 MWMR_SPAN, 38 CHANNEL_BUFFER_LSB = 0, // Data buffer paddr 32 LSB bits 39 CHANNEL_BUFFER_MSB = 1, // Data buffer paddr extension 40 CHANNEL_MWMR_LSB = 2, // MWMR descriptor paddr 32 LSB bits 41 CHANNEL_MWMR_MSB = 3, // MWMR descriptor paddr extension 42 CHANNEL_LOCK_LSB = 4, // MWMR lock paddr 32 LSB bits 43 CHANNEL_LOCK_MSB = 5, // MWMR lock paddr extension 44 CHANNEL_WAY = 6, // TO_COPROC / FROMCOPROC (Read-only) 45 CHANNEL_MODE = 7, // MWMR / DMA / DMA_IRQ 46 CHANNEL_SIZE = 8, // Data Buffer size (bytes) 47 CHANNEL_RUNNING = 9, // channel running 48 CHANNEL_STATUS = 10, // channel FSM state (Read-Only) 49 CHANNEL_INFO = 11, // STS | CFG | FROM | TO (Read-Only) 50 // 51 CHANNEL_SPAN = 16, 30 52 }; 31 53 32 enum SoclibMwmrWay 33 { 34 MWMR_TO_COPROC, 35 MWMR_FROM_COPROC, 36 }; 54 /////////////////////////////////////////////////////////////////////////////// 55 // Low-level access functions 56 /////////////////////////////////////////////////////////////////////////////// 37 57 38 /////////////////////////////////////////////////////////////////////////////////// 39 // MWMR controller access functions 40 /////////////////////////////////////////////////////////////////////////////////// 58 extern void _mwr_set_channel_register( unsigned int cluster_xy, 59 unsigned int channel, 60 unsigned int index, 61 unsigned int value ); 41 62 42 extern unsigned int _mwr_hw_init( unsigned int cluster_xy, 43 unsigned int port_id, 44 unsigned int from_coproc, 45 unsigned long long channel_pbase); 63 extern unsigned int _mwr_get_channel_register( unsigned int cluster_xy, 64 unsigned int channel, 65 unsigned int index ); 46 66 47 /////////////////////////////////////////////////////////////////////////////////// 67 extern void _mwr_set_coproc_register( unsigned int cluster_xy, 68 unsigned int index, 69 unsigned int value ); 48 70 71 extern unsigned int _mwr_get_coproc_register( unsigned int cluster_xy, 72 unsigned int index ); 49 73 74 /////////////////////////////////////////////////////////////////////////////// 75 // Interrupt Service Routine 76 /////////////////////////////////////////////////////////////////////////////// 77 78 extern void _mwr_isr( unsigned int irq_type, 79 unsigned int irq_id, 80 unsigned int channel ); 50 81 #endif 51 82
Note: See TracChangeset
for help on using the changeset viewer.