Changeset 4 for trunk/kernel/drivers
- Timestamp:
- Apr 26, 2017, 2:10:21 PM (8 years ago)
- Location:
- trunk/kernel/drivers
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/drivers/ibmpc/ata.c
r1 r4 21 21 */ 22 22 23 #include < device.h>23 #include <chdev.h> 24 24 #include <driver.h> 25 25 #include <cpu.h> -
trunk/kernel/drivers/ibmpc/pic.c
r1 r4 23 23 #include <types.h> 24 24 #include <cpu.h> 25 #include < device.h>25 #include <chdev.h> 26 26 #include <driver.h> 27 27 #include <cpu-io.h> -
trunk/kernel/drivers/ibmpc/tty.c
r1 r4 24 24 #include <system.h> 25 25 #include <cpu.h> 26 #include < device.h>26 #include <chdev.h> 27 27 #include <driver.h> 28 28 #include <cpu-io.h> -
trunk/kernel/drivers/soclib/drvdb.c
r1 r4 27 27 #include <libk.h> 28 28 #include <event.h> 29 #include < device.h>29 #include <chdev.h> 30 30 #include <driver.h> 31 31 #include <drvdb.h> -
trunk/kernel/drivers/soclib/soclib_bdv.c
r1 r4 22 22 */ 23 23 24 #include < device.h>24 #include <chdev.h> 25 25 #include <dev_ioc.h> 26 26 #include <soclib_bdv.h> … … 29 29 30 30 31 ///////////////////////////////////// 32 void soclib_bdv_init( xptr_t dev_xp)31 /////////////////////////////////////// 32 void soclib_bdv_init( chdev_t * chdev ) 33 33 { 34 // get IOC device descriptor cluster and local pointer35 cxy_t dev_cxy = GET_CXY( dev_xp );36 device_t * dev_ptr = (device_t *)GET_PTR( dev_xp );37 38 34 // get extended pointer on SOCLIB_BDV peripheral base address 39 xptr_t bdv_xp = hal_remote_lwd( XPTR( dev_cxy , &dev_ptr->base ) );35 xptr_t bdv_xp = chdev->base; 40 36 41 37 // get hardware device cluster and local pointer … … 48 44 49 45 // set IOC device descriptor extension 50 hal_remote_sw( XPTR( dev_cxy , &dev_ptr->ext.ioc.size ) , block_size );51 hal_remote_sw( XPTR( dev_cxy , &dev_ptr->ext.ioc.count ) , block_count );46 chdev->ext.ioc.size = block_size; 47 chdev->ext.ioc.count = block_count; 52 48 53 49 } // end soclib_bdv_init() 54 50 55 51 56 ////////////////////////////////////////////////////////////// ////57 void __attribute__ ((noinline)) soclib_bdv_c ommand( xptr_t th_xp )52 ////////////////////////////////////////////////////////////// 53 void __attribute__ ((noinline)) soclib_bdv_cmd( xptr_t th_xp ) 58 54 { 59 55 uint32_t to_mem; // command argument … … 68 64 69 65 // get command arguments and extended pointer on IOC device 70 to_mem = hal_remote_lw ( XPTR( th_cxy , &th_ptr-> dev.ioc.to_mem ) );71 lba = hal_remote_lw ( XPTR( th_cxy , &th_ptr-> dev.ioc.lba ) );72 count = hal_remote_lw ( XPTR( th_cxy , &th_ptr-> dev.ioc.count ) );73 buf_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr-> dev.ioc.buf_xp ) );74 dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr-> dev.ioc.dev_xp ) );66 to_mem = hal_remote_lw ( XPTR( th_cxy , &th_ptr->command.ioc.to_mem ) ); 67 lba = hal_remote_lw ( XPTR( th_cxy , &th_ptr->command.ioc.lba ) ); 68 count = hal_remote_lw ( XPTR( th_cxy , &th_ptr->command.ioc.count ) ); 69 buf_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->command.ioc.buf_xp ) ); 70 dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->command.ioc.dev_xp ) ); 75 71 76 72 // get IOC device cluster and local pointer 77 73 cxy_t dev_cxy = GET_CXY( dev_xp ); 78 device_t * dev_ptr = (device_t *)GET_PTR( dev_xp );74 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp ); 79 75 80 76 // get extended pointer on SOCLIB-BDV peripheral … … 107 103 108 104 109 //////////////////////////////////////////////////////////////// 110 void __attribute__ ((noinline)) soclib_bdv_isr( device_t *dev )105 ///////////////////////////////////////////////////////////////// 106 void __attribute__ ((noinline)) soclib_bdv_isr( chdev_t * chdev ) 111 107 { 112 108 // get extended pointer on client thread 113 xptr_t root = XPTR( local_cxy , & dev->wait_root );109 xptr_t root = XPTR( local_cxy , &chdev->wait_root ); 114 110 xptr_t client_xp = XLIST_FIRST_ELEMENT( root , thread_t , wait_list ); 115 111 116 112 // get extended pointer on server thread 117 xptr_t server_xp = XPTR( local_cxy , & dev->server );113 xptr_t server_xp = XPTR( local_cxy , &chdev->server ); 118 114 119 115 // get client thread cluster and local pointer … … 122 118 123 119 // get SOCLIB_BDV device cluster and local pointer 124 cxy_t bdv_cxy = GET_CXY( dev->base );125 uint32_t * bdv_ptr = (uint32_t *)GET_PTR( dev->base );120 cxy_t bdv_cxy = GET_CXY( chdev->base ); 121 uint32_t * bdv_ptr = (uint32_t *)GET_PTR( chdev->base ); 126 122 127 123 // get BDV status register and acknowledge IRQ … … 131 127 if((status != BDV_READ_SUCCESS) && (status != BDV_WRITE_SUCCESS)) 132 128 { 133 hal_remote_sw( XPTR( client_cxy , &client_ptr-> dev.ioc.error ) , 1 );129 hal_remote_sw( XPTR( client_cxy , &client_ptr->command.ioc.error ) , 1 ); 134 130 } 135 131 else 136 132 { 137 hal_remote_sw( XPTR( client_cxy , &client_ptr-> dev.ioc.error ) , 0 );133 hal_remote_sw( XPTR( client_cxy , &client_ptr->command.ioc.error ) , 0 ); 138 134 } 139 135 -
trunk/kernel/drivers/soclib/soclib_bdv.h
r1 r4 25 25 #define _SOCLIB_BDV_H_ 26 26 27 #include < device.h>27 #include <chdev.h> 28 28 #include <hal_types.h> 29 29 … … 75 75 * number of blocks, and initialises the "extension" field of the IOC device descriptor. 76 76 ******************************************************************************************** 77 * @ dev_xp : extended pointer on the generic IOC devicedescriptor.77 * @ chdev : local pointer on the generic IOC chdev descriptor. 78 78 *******************************************************************************************/ 79 extern void soclib_bdv_init( xptr_t dev_xp);79 extern void soclib_bdv_init( chdev_t * chdev ); 80 80 81 81 /******************************************************************************************** … … 90 90 * @ thread_xp : extended pointer on the client thread. 91 91 *******************************************************************************************/ 92 extern void soclib_bdv_c ommand( xptr_t thread_xp );92 extern void soclib_bdv_cmd( xptr_t thread_xp ); 93 93 94 94 /******************************************************************************************** … … 98 98 * can starts execution of a new command if the waiting queue is not emppty. 99 99 ******************************************************************************************** 100 * @ dev : local pointer on the generic IOC device descriptor.100 * @ chdev : local pointer on the generic IOC device descriptor. 101 101 *******************************************************************************************/ 102 extern void soclib_bdv_isr( device_t *dev );102 extern void soclib_bdv_isr( chdev_t * chdev ); 103 103 104 104 -
trunk/kernel/drivers/soclib/soclib_cma.c
r1 r4 22 22 */ 23 23 24 #include < device.h>24 #include <chdev.h> 25 25 #include <dev_nic.h> 26 26 #include <soclib_nic.h> -
trunk/kernel/drivers/soclib/soclib_dma.c
r1 r4 1 1 /* 2 * soclib_dma.c - soclib DMA driver2 * soclib_dma.c - soclib Multi Channels DMA driver implementation 3 3 * 4 * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless 5 * Copyright (c) 2011,2012 UPMC Sorbonne Universites 4 * Author Alain Greiner (2017) 5 6 * Copyright (c) UPMC Sorbonne Universites 6 7 * 7 * This file is part of ALMOS- kernel.8 * This file is part of ALMOS-MKH. 8 9 * 9 * ALMOS- kernelis free software; you can redistribute it and/or modify it10 * ALMOS-MKH is free software; you can redistribute it and/or modify it 10 11 * under the terms of the GNU General Public License as published by 11 12 * the Free Software Foundation; version 2.0 of the License. 12 13 * 13 * ALMOS- kernelis distributed in the hope that it will be useful, but14 * ALMOS-MKH is distributed in the hope that it will be useful, but 14 15 * WITHOUT ANY WARRANTY; without even the implied warranty of 15 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU … … 17 18 * 18 19 * You should have received a copy of the GNU General Public License 19 * along with ALMOS- kernel; if not, write to the Free Software Foundation,20 * along with ALMOS-MKH; if not, write to the Free Software Foundation, 20 21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 22 */ 22 23 23 #include <errno.h> 24 #include <cpu.h> 25 #include <device.h> 26 #include <driver.h> 27 #include <drvdb.h> 28 #include <kmem.h> 29 #include <scheduler.h> 24 #include <hal_types.h> 25 #include <chdev.h> 26 #include <dev_dma.h> 30 27 #include <thread.h> 31 #include <task.h>32 #include <list.h>33 #include <event.h>34 28 #include <soclib_dma.h> 35 #include <string.h>36 29 37 / * DMA mapped registers offset */38 #define DMA_SRC_REG 0 39 #define DMA_DST_REG 1 40 #define DMA_LEN_REG 2 41 #define DMA_RESET_REG 3 42 #define DMA_IRQ_DISABLED 4 30 /////////////////////////////////////// 31 void soclib_dma_init( chdev_t * chdev ) 32 { 33 // get hardware device cluster and local pointer 34 cxy_t dma_cxy = GET_CXY( chdev->base ); 35 uint32_t * dma_ptr = (uint32_t *)GET_PTR( chdev->base ); 43 36 44 struct dma_context_s 37 // enable interrupts 38 hal_remote_sw( XPTR( dma_cxy , dma_ptr + DMA_IRQ_DISABLED ) , 0 ); 39 40 } // soclib_dma_init() 41 42 ////////////////////////////////////////////////////////////////// 43 void __attribute__ ((noinline)) soclib_dma_cmd( xptr_t thread_xp ) 45 44 { 46 struct list_entry request_queue; 47 struct wait_queue_s pending; 48 }; 45 xptr_t dev_xp; // extended pointer on DMA devive 46 xptr_t dst_xp; // extended pointer on destination buffer 47 xptr_t src_xp; // extended pointer on source buffer 48 uint32_t size; // buffer size 49 49 50 static void dma_start_request(struct device_s *dma, dev_request_t *ptr) 50 // get client thread cluster and local pointer 51 cxy_t thread_cxy = GET_CXY( thread_xp ); 52 thread_t * thread_ptr = (thread_t *)GET_PTR( thread_xp ); 53 54 // get command arguments and extended pointer on DMA device 55 dev_xp = (xptr_t)hal_remote_lwd( XPTR( thread_cxy , &thread_ptr->command.dma.dev_xp ) ); 56 dst_xp = (xptr_t)hal_remote_lwd( XPTR( thread_cxy , &thread_ptr->command.dma.dst_xp ) ); 57 src_xp = (xptr_t)hal_remote_lwd( XPTR( thread_cxy , &thread_ptr->command.dma.src_xp ) ); 58 size = hal_remote_lw ( XPTR( thread_cxy , &thread_ptr->command.dma.size ) ); 59 60 // get DMA device cluster and local pointer 61 cxy_t dev_cxy = GET_CXY( dev_xp ); 62 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp ); 63 64 // get extended pointer on SOCLIB-DMA peripheral 65 xptr_t dma_xp = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->base ) ); 66 67 // get SOCLIB_DMA device cluster and local pointer 68 cxy_t dma_cxy = GET_CXY( dma_xp ); 69 uint32_t * dma_ptr = (uint32_t *)GET_PTR( dma_xp ); 70 71 // get DMA channel index and channel base address 72 uint32_t * base = dma_ptr + DMA_SPAN * dev_ptr->channel; 73 74 // split dst and src buffers addresses in two 32 bits words 75 uint32_t dst_lsb = (uint32_t)(dst_xp); 76 uint32_t dst_msb = (uint32_t)(dst_xp>>32); 77 uint32_t src_lsb = (uint32_t)(src_xp); 78 uint32_t src_msb = (uint32_t)(src_xp>>32); 79 80 // set SOCLIB_DMA registers to start tranfer operation 81 hal_remote_sw( XPTR( dma_cxy , base + DMA_SRC ) , src_lsb ); 82 hal_remote_sw( XPTR( dma_cxy , base + DMA_SRC_EXT ) , src_msb ); 83 hal_remote_sw( XPTR( dma_cxy , base + DMA_DST ) , dst_lsb ); 84 hal_remote_sw( XPTR( dma_cxy , base + DMA_DST_EXT ) , dst_msb ); 85 hal_remote_sw( XPTR( dma_cxy , base + DMA_LEN ) , size ); 86 87 // Block and deschedule server thread 88 thread_block( CURRENT_THREAD , THREAD_BLOCKED_DEV_ISR ); 89 sched_yield(); 90 91 } // soclib_dma_cmd() 92 93 ///////////////////////////////////////////////////////////////// 94 void __attribute__ ((noinline)) soclib_dma_isr( chdev_t * chdev ) 51 95 { 52 volatile uint32_t *base = dma->base; 53 dev_request_t *rq; 96 // get extended pointer on client thread 97 xptr_t root = XPTR( local_cxy , &chdev->wait_root ); 98 xptr_t client_xp = XLIST_FIRST_ELEMENT( root , thread_t , wait_list ); 54 99 55 rq = (ptr->flags & DEV_RQ_NESTED) ? ptr->data : ptr; 100 // get extended pointer on server thread 101 xptr_t server_xp = XPTR( local_cxy , &chdev->server ); 56 102 57 base[DMA_SRC_REG] = (unsigned int)rq->src; 58 base[DMA_DST_REG] = (unsigned int)rq->dst; 59 base[DMA_IRQ_DISABLED] = 0; 60 base[DMA_LEN_REG] = rq->count; 61 } 103 // get client thread cluster and local pointer 104 cxy_t client_cxy = GET_CXY( client_xp ); 105 thread_t * client_ptr = (thread_t *)GET_PTR( client_xp ); 62 106 63 static void dma_irq_handler(struct irq_action_s *action) 64 { 65 struct dma_context_s *ctx; 66 struct device_s *dma; 67 dev_request_t *rq; 68 dev_request_t *frag; 69 dev_request_t *new_rq; 70 error_t err; 71 volatile uint32_t *base; 72 struct thread_s *this; 107 // get SOCLIB_DMA peripheral cluster and local pointer 108 cxy_t dma_cxy = GET_CXY( chdev->base ); 109 uint32_t * dma_ptr = (uint32_t *)GET_PTR( chdev->base ); 73 110 74 dma = action->dev; 75 base = dma->base; 76 ctx = (struct dma_context_s*)dma->data; 111 // get DMA channel base address 112 uint32_t * base = dma_ptr + (DMA_SPAN * chdev->channel); 77 113 78 cpu_spinlock_lock(&dma->lock.val); 79 80 err = base[DMA_LEN_REG]; 81 base[DMA_RESET_REG] = 0; 114 // get DMA status register 115 uint32_t status = hal_remote_lw( XPTR( dma_cxy , base + DMA_LEN ) ); 82 116 83 /* even if this case is realy low probable, we have to check for empty list ! */ 84 if(list_empty(&ctx->request_queue)) 85 { 86 cpu_spinlock_unlock(&dma->lock.val); 87 return; 88 } 117 // acknowledge IRQ 118 hal_remote_sw( XPTR( dma_cxy , base + DMA_RESET ) , 0 ); 89 119 90 rq = list_first(&ctx->request_queue, dev_request_t, list); 120 // set operation status in command 121 error_t error = ( status != DMA_SUCCESS ); 122 hal_remote_sw( XPTR( client_cxy , &client_ptr->command.dma.error ) , error ); 91 123 92 if(rq->flags & DEV_RQ_NESTED) 93 { 94 frag = rq->data; 124 // unblock server thread 125 thread_unblock( server_xp , THREAD_BLOCKED_DEV_ISR ); 95 126 96 event_set_error(&frag->event, err); 97 event_set_senderId(&frag->event, dma); 98 event_send(&frag->event, current_cpu->gid); 127 // unblock client thread 128 thread_unblock( client_xp , THREAD_BLOCKED_IO ); 99 129 100 if((err == 0) && (frag->data != NULL)) 101 { 102 rq->data = frag->data; 103 dma_start_request(dma,frag->data); 104 cpu_spinlock_unlock(&dma->lock.val); 105 return; 106 } 107 } 108 109 list_unlink(&rq->list); 110 111 if(!(list_empty(&ctx->request_queue))) 112 { 113 new_rq = list_first(&ctx->request_queue, dev_request_t, list); 114 dma_start_request(dma,new_rq); 115 } 116 117 if(!(rq->flags & DEV_RQ_NOBLOCK)) 118 { 119 rq->err = err; 120 wakeup_one(&ctx->pending, WAIT_FIRST); 121 cpu_spinlock_unlock(&dma->lock.val); 122 return; 123 } 124 125 cpu_spinlock_unlock(&dma->lock.val); 126 127 this = CURRENT_THREAD; 128 129 event_set_error(&rq->event, err); 130 event_set_senderId(&rq->event, dma); 131 event_send(&rq->event, current_cpu->gid); 132 } 133 134 static void dma_fraglist_destroy(dev_request_t *ptr) 135 { 136 kmem_req_t req; 137 dev_request_t *frag; 138 139 req.type = KMEM_DMA_REQUEST; 140 frag = ptr; 141 142 while(frag != NULL); 143 { 144 req.ptr = frag; 145 frag = frag->data; 146 147 kmem_free(&req); 148 } 149 } 150 151 static EVENT_HANDLER(dma_async_frag_event) 152 { 153 dev_request_t *frag; 154 kmem_req_t req; 155 error_t err; 156 157 frag = event_get_argument(event); 158 err = event_get_error(event); 159 160 assert(frag != NULL && "corrupted frag"); 161 162 if(err) 163 { 164 dma_fraglist_destroy(frag); 165 return 0; 166 } 167 168 req.type = KMEM_DMA_REQUEST; 169 req.ptr = frag; 170 171 kmem_free(&req); 172 return 0; 173 } 174 175 static error_t dma_frag_init(dev_request_t *frag, uint_t src_start, uint_t dst_start, uint_t count) 176 { 177 //FIXME(40) use extent registers 178 frag->src = task_vaddr2paddr(current_task, (void*)src_start); 179 frag->dst = task_vaddr2paddr(current_task, (void*)dst_start); 180 frag->count = count; 181 frag->flags = 0; 182 183 if((frag->src == NULL) || (frag->dst == NULL)) 184 return EPERM; 185 186 event_set_priority(&frag->event, E_FUNC); 187 event_set_handler(&frag->event, &dma_async_frag_event); 188 event_set_argument(&frag->event, frag); 189 return 0; 190 } 191 192 static error_t dma_fraglist_build(dev_request_t *rq) 193 { 194 kmem_req_t req; 195 dev_request_t *frag; 196 dev_request_t *parent_frag; 197 struct slist_entry *root; 198 struct slist_entry *iter; 199 uint_t src_start; 200 uint_t dst_start; 201 uint_t count; 202 error_t err; 203 204 if(rq->count == 0) 205 return EINVAL; 206 207 src_start = (uint_t)rq->src; 208 dst_start = (uint_t)rq->dst; 209 210 if((src_start + rq->count) <= ((src_start & ~PMM_PAGE_MASK) + PMM_PAGE_SIZE) && 211 (dst_start + rq->count) <= ((dst_start & ~PMM_PAGE_MASK) + PMM_PAGE_SIZE)) 212 { 213 //FIXME(40) use extent registers 214 rq->src = task_vaddr2paddr(current_task, rq->src); 215 rq->dst = task_vaddr2paddr(current_task, rq->dst); 216 217 if((rq->src == NULL) || (rq->dst == NULL)) 218 return EPERM; 219 220 return 0; 221 } 222 223 if((src_start & PMM_PAGE_MASK) || (dst_start & PMM_PAGE_MASK)) { 224 return ENOSYS; 225 } 226 227 req.type = KMEM_DMA_REQUEST; 228 req.size = sizeof(*rq); 229 req.flags = AF_KERNEL; 230 root = (struct slist_entry *)&rq->data; 231 iter = (struct slist_entry *)&rq->list; 232 count = rq->count; 233 rq->data = NULL; 234 rq->flags &= ~DEV_RQ_NESTED; 235 parent_frag = rq; 236 237 while(count) 238 { 239 frag = kmem_alloc(&req); 240 241 if(frag == NULL) 242 { 243 err = ENOMEM; 244 goto fail_nomem; 245 } 246 247 if(count >= PMM_PAGE_SIZE) 248 { 249 err = dma_frag_init(frag, src_start, dst_start, PMM_PAGE_SIZE); 250 251 if(err) 252 goto fail_init; 253 254 src_start += PMM_PAGE_SIZE; 255 dst_start += PMM_PAGE_SIZE; 256 count -= PMM_PAGE_SIZE; 257 } 258 else 259 { 260 err = dma_frag_init(frag, src_start, dst_start, count); 261 262 if(err) 263 goto fail_init; 264 265 count -= count; 266 } 267 268 parent_frag->data = frag; 269 frag->data = NULL; 270 parent_frag = frag; 271 } 272 273 rq->flags |= DEV_RQ_NESTED; 274 return 0; 275 276 fail_init: 277 fail_nomem: 278 dma_fraglist_destroy(rq->data); 279 return err; 280 } 130 } // soclib_dma_isr() 281 131 282 132 283 static sint_t dma_request(struct device_s *dma, dev_request_t *rq)284 {285 struct dma_context_s *ctx;286 uint_t irq_state;287 sint_t err;288 133 289 rq->err = 0;290 ctx = (struct dma_context_s*)dma->data;291 292 err = dma_fraglist_build(rq);293 294 if(err)295 return err;296 297 spinlock_lock_noirq(&dma->lock,&irq_state);298 299 if(list_empty(&ctx->request_queue))300 {301 list_add(&ctx->request_queue, &rq->list);302 dma_start_request(dma, rq);303 }304 else305 list_add_last(&ctx->request_queue, &rq->list);306 307 if(rq->flags & DEV_RQ_NOBLOCK)308 {309 spinlock_unlock_noirq(&dma->lock, irq_state);310 return 0;311 }312 313 wait_on(&ctx->pending, WAIT_LAST);314 spinlock_unlock_noirq(&dma->lock,irq_state);315 sched_sleep(CURRENT_THREAD);316 317 return rq->err;318 }319 320 static sint_t dma_open(struct device_s *dma, dev_request_t *rq)321 {322 return EPERM;323 }324 325 struct device_s *__sys_dma;326 static uint_t dma_count = 0;327 328 error_t soclib_dma_init(struct device_s *dma)329 {330 kmem_req_t req;331 struct dma_context_s *ctx;332 333 spinlock_init(&dma->lock,"DevDMA (SoCLib)");334 dma->type = DEV_BLK;335 336 dma->action.dev = dma;337 dma->action.irq_handler = &dma_irq_handler;338 dma->action.data = NULL;339 340 if(dma_count == 0)341 __sys_dma = dma;342 343 sprintk(dma->name,344 #if CONFIG_ROOTFS_IS_VFAT345 "DMA%d"346 #else347 "dma%d"348 #endif349 ,dma_count++);350 351 metafs_init(&dma->node, dma->name);352 353 dma->op.dev.open = &dma_open;354 dma->op.dev.read = &dma_request;355 dma->op.dev.write = &dma_request;356 dma->op.dev.close = NULL;357 dma->op.dev.lseek = NULL;358 dma->op.dev.mmap = NULL;359 dma->op.dev.munmap = NULL;360 dma->op.dev.set_params = NULL;361 dma->op.dev.get_params = NULL;362 dma->op.drvid = SOCLIB_DMA_ID;363 364 req.type = KMEM_GENERIC;365 req.size = sizeof(*ctx);366 req.flags = AF_BOOT | AF_ZERO;367 368 if((ctx = kmem_alloc(&req)) == NULL)369 return ENOMEM;370 371 wait_queue_init(&ctx->pending, dma->name);372 list_root_init(&ctx->request_queue);373 dma->data = (void *)ctx;374 return 0;375 }376 377 driver_t soclib_dma_driver = { .init = &soclib_dma_init }; -
trunk/kernel/drivers/soclib/soclib_dma.h
r1 r4 1 1 /* 2 * soclib_dma. c - soclib DMA driver2 * soclib_dma.h - soclib Multi Channels DMA driver definition. 3 3 * 4 * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless 5 * Copyright (c) 2011,2012 UPMC Sorbonne Universites 4 * Author Alain Greiner (2017) 6 5 * 7 * This file is part of ALMOS-kernel.6 * Copyright (c) UPMC Sorbonne Universites 8 7 * 9 * ALMOS-kernel is free software; you can redistribute it and/or modify it 8 * This file is part of ALMOS-MKH. 9 * 10 * ALMOS-MKH is free software; you can redistribute it and/or modify it 10 11 * under the terms of the GNU General Public License as published by 11 12 * the Free Software Foundation; version 2.0 of the License. 12 13 * 13 * ALMOS- kernelis distributed in the hope that it will be useful, but14 * ALMOS-MKH is distributed in the hope that it will be useful, but 14 15 * WITHOUT ANY WARRANTY; without even the implied warranty of 15 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU … … 17 18 * 18 19 * You should have received a copy of the GNU General Public License 19 * along with ALMOS- kernel; if not, write to the Free Software Foundation,20 * along with ALMOS-MKH; if not, write to the Free Software Foundation, 20 21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 22 */ … … 24 25 #define _SOCLIB_DMA_H_ 25 26 26 extern struct driver_s soclib_dma_driver; 27 /******************************************************************************************** 28 * This driver supports the SocLib VciBlockDevice component, that is a simgle channel, 29 * block oriented, external storage controler, supporting only one I/O transaction, 30 * at a given time. 31 *******************************************************************************************/ 32 33 /******************************************************************************************** 34 * SOCLIB_DMA registers offset 35 *******************************************************************************************/ 36 37 enum SoclibDmaRegisters 38 { 39 DMA_SRC = 0, /*! source buffer 32 LSB address bits */ 40 DMA_DST = 1, /*! source buffer 32 LSB address bits */ 41 DMA_LEN = 2, /*! number of bytes (on write) / transfer status (on read) */ 42 DMA_RESET = 3, /*! desactivate channel (can be usde to acknowledge IRQ) */ 43 DMA_IRQ_DISABLED = 4, /*! no IRQ generated if non zero */ 44 DMA_SRC_EXT = 5, /*! source buffer 32 MSB address bits */ 45 DMA_DST_EXT = 6, /*! source buffer 32 MSB address bits */ 46 47 DMA_SPAN = 8, /*! number of registers per channel */ 48 }; 49 50 /******************************************************************************************** 51 * SOCLIB_DMA status values 52 *******************************************************************************************/ 53 54 #define DMA_SUCCESS 0 55 #define DMA_IDLE 2 56 #define DMA_ERROR_READ 1 57 #define DMA_ERROR_WRITE 3 58 #define DMA_BUSY 4 // or any value larger than 3 59 60 61 /******************************************************************************************** 62 * This function access the SOCLIB_DMA hardware register to enable interrupts. 63 ******************************************************************************************** 64 * @ chdev : pointer on DMA chdev descriptor. 65 *******************************************************************************************/ 66 extern void soclib_dma_init( chdev_t * chdev ); 67 68 /******************************************************************************************** 69 * This function is called by the server thread associated to the DMA device. 70 * It access the command embedded in the calling thread descriptor, (format defined in the 71 * dev_dma.h file) and access the SOCLIB_DMA hardware registers to start command execution. 72 * Then it blocks on the THREAD_BLOCKED_DEV_ISR and deschedules, because each DMA channel 73 * can only execute one command at a given time. 74 * It is re-activated by the ISR signaling the transfer completion. 75 ******************************************************************************************** 76 * @ thread_xp : extended pointer on the client thread. 77 *******************************************************************************************/ 78 extern void soclib_dma_cmd( xptr_t thread_xp ); 79 80 /******************************************************************************************** 81 * This Interrupt Service Routine is executed when the IRQ signaling the completion of 82 * a DMA command is received by a core. It acknowledge the IRQ by accessing the proper 83 * SOCLIB_DMA register, unblock the client thread, and unblock the server thread that 84 * can starts execution of a new command if the waiting queue is not emppty. 85 ******************************************************************************************** 86 * @ chdev : pointer on DMA chdev descriptor. 87 *******************************************************************************************/ 88 extern void soclib_dma_isr( chdev_t * chdev ); 89 27 90 28 91 #endif /* _SOCLIB_DMA_H_ */ -
trunk/kernel/drivers/soclib/soclib_hba.c
r1 r4 24 24 #include <printk.h> 25 25 #include <hal_special.h> 26 #include < device.h>26 #include <chdev.h> 27 27 #include <dev_ioc.h> 28 28 #include <soclib_hba.h> … … 54 54 spinlock_t hba_lock; 55 55 56 ///////////////////////////////////// 57 void soclib_hba_init( xptr_t dev_xp)56 /////////////////////////////////////// 57 void soclib_hba_init( chdev_t * chdev ) 58 58 { 59 // get IOC device descriptor cluster and local pointer60 cxy_t dev_cxy = GET_CXY( dev_xp );61 device_t * dev_ptr = (device_t *)GET_PTR( dev_xp );62 63 59 // get hardware device base address 64 xptr_t hba_xp = (xptr_t)hal_remote_lwd( XPTR( dev_cxy , &dev_ptr->base ) );60 xptr_t hba_xp = chdev->base; 65 61 66 62 // get hardware device cluster and local pointer … … 73 69 74 70 // set device descriptor extension 75 hal_remote_sw( XPTR( dev_cxy , &dev_ptr->ext.ioc.size ) , block_size );76 hal_remote_sw( XPTR( dev_cxy , &dev_ptr->ext.ioc.count ) , block_count );71 chdev->ext.ioc.size = block_size; 72 chdev->ext.ioc.count = block_count; 77 73 78 74 // reset SOCLIB_HBA driver global variables … … 102 98 103 99 // get command arguments and extended pointer on IOC device 104 to_mem = hal_remote_lw ( XPTR( th_cxy , &th_ptr-> dev.ioc.to_mem ) );105 lba = hal_remote_lw ( XPTR( th_cxy , &th_ptr-> dev.ioc.lba ) );106 count = hal_remote_lw ( XPTR( th_cxy , &th_ptr-> dev.ioc.count ) );107 buf_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr-> dev.ioc.buf_xp ) );108 dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr-> dev.ioc.dev_xp ) );100 to_mem = hal_remote_lw ( XPTR( th_cxy , &th_ptr->command.ioc.to_mem ) ); 101 lba = hal_remote_lw ( XPTR( th_cxy , &th_ptr->command.ioc.lba ) ); 102 count = hal_remote_lw ( XPTR( th_cxy , &th_ptr->command.ioc.count ) ); 103 buf_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->command.ioc.buf_xp ) ); 104 dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->command.ioc.dev_xp ) ); 109 105 110 106 // get IOC device cluster and local pointer 111 cxy_t 112 device_t * dev_ptr = (device_t *)GET_PTR( dev_xp );107 cxy_t dev_cxy = GET_CXY( dev_xp ); 108 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp ); 113 109 114 110 // get extended pointer on SOCLIB-HBA peripheral … … 218 214 219 215 220 //////////////////////////////////////////////////////////////// 221 void __attribute__ ((noinline)) soclib_hba_isr( device_t *dev )216 ///////////////////////////////////////////////////////////////// 217 void __attribute__ ((noinline)) soclib_hba_isr( chdev_t * chdev ) 222 218 { 223 219 // get extended pointer on client thread 224 xptr_t root = XPTR( local_cxy , & dev->wait_root );220 xptr_t root = XPTR( local_cxy , &chdev->wait_root ); 225 221 xptr_t client_xp = XLIST_FIRST_ELEMENT( root , thread_t , wait_list ); 226 222 … … 230 226 231 227 // get SOCLIB_HBA device cluster and local pointer 232 cxy_t hba_cxy = GET_CXY( dev->base );233 uint32_t * hba_ptr = (uint32_t *)GET_PTR( dev->base );228 cxy_t hba_cxy = GET_CXY( chdev->base ); 229 uint32_t * hba_ptr = (uint32_t *)GET_PTR( chdev->base ); 234 230 235 231 // get HBA_PXIS_REG and HBA_PXIS_REG current values … … 253 249 if( error && (iter == fault_id ) ) 254 250 { 255 hal_remote_sw( XPTR( client_cxy , &client_ptr-> dev.ioc.error ) , 1 );251 hal_remote_sw( XPTR( client_cxy , &client_ptr->command.ioc.error ) , 1 ); 256 252 } 257 253 else 258 254 { 259 hal_remote_sw( XPTR( client_cxy , &client_ptr-> dev.ioc.error ) , 0 );255 hal_remote_sw( XPTR( client_cxy , &client_ptr->command.ioc.error ) , 0 ); 260 256 } 261 257 -
trunk/kernel/drivers/soclib/soclib_hba.h
r1 r4 25 25 #define _SOCLIB_HBA_H_ 26 26 27 #include < device.h>27 #include <chdev.h> 28 28 #include <hal_types.h> 29 29 … … 129 129 * number of blocks, and initialises the "extension" field of the IOC device descriptor. 130 130 ******************************************************************************************** 131 * @ dev_xp : extended pointer on the generic IOC devicedescriptor.131 * @ chdev : local pointer on the generic IOC chdev descriptor. 132 132 *******************************************************************************************/ 133 extern void soclib_hba_init( xptr_t dev_xp);133 extern void soclib_hba_init( chdev_t * chdev ); 134 134 135 135 /******************************************************************************************** … … 153 153 * all client thread that have an I/O operation completed. 154 154 ******************************************************************************************** 155 * @ dev : local pointer on the generic IOC device descriptor.155 * @ chdev : local pointer on the generic IOC device descriptor. 156 156 *******************************************************************************************/ 157 extern void soclib_hba_isr( device_t *dev );157 extern void soclib_hba_isr( chdev_t * chdev ); 158 158 159 159 -
trunk/kernel/drivers/soclib/soclib_iob.c
r1 r4 27 27 #include <soclib_iob.h> 28 28 29 ///////////////////////////////////// 30 void soclib_iob_init( xptr_t iox_xp)29 /////////////////////////////////////// 30 void soclib_iob_init( chdev_t * chdev ) 31 31 { 32 // get IOX device cluster and local pointer33 cxy_t iox_cxy = GET_CXY( iox_xp );34 device_t * iox_ptr = (device_t *)GET_PTR( iox_xp );35 36 // get extended pointer on SOCLIB_IOB base_xp segment37 xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iox_cxy , &iox_ptr->base ) );38 39 32 // desactivate IOMMU 40 hal_remote_sw( base_xp+ (IOB_IOMMU_ACTIVE<<2) , 0 );33 hal_remote_sw( chdev->base + (IOB_IOMMU_ACTIVE<<2) , 0 ); 41 34 } 42 35 43 36 //////////////////////////////////////////// 44 void soclib_iob_set_active( xptr_t io x_xp,37 void soclib_iob_set_active( xptr_t iob_xp, 45 38 uint32_t value ) 46 39 { 47 40 // get IOX device cluster and local pointer 48 cxy_t iox_cxy = GET_CXY( iox_xp );49 device_t * iox_ptr = (device_t *)GET_PTR( iox_xp );41 cxy_t iob_cxy = GET_CXY( iob_xp ); 42 chdev_t * iob_ptr = (chdev_t *)GET_PTR( iob_xp ); 50 43 51 44 // get extended pointer on SOCLIB_IOB base_xp segment 52 xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( io x_cxy , &iox_ptr->base ) );45 xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) ); 53 46 54 47 // set ACTIVE register … … 57 50 58 51 ////////////////////////////////////////// 59 void soclib_iob_set_ptpr( xptr_t io x_xp,52 void soclib_iob_set_ptpr( xptr_t iob_xp, 60 53 uint32_t value ) 61 54 { 62 55 // get IOX device cluster and local pointer 63 cxy_t iox_cxy = GET_CXY( iox_xp );64 device_t * iox_ptr = (device_t *)GET_PTR( iox_xp );56 cxy_t iob_cxy = GET_CXY( iob_xp ); 57 chdev_t * iob_ptr = (chdev_t *)GET_PTR( iob_xp ); 65 58 66 59 // get extended pointer on SOCLIB_IOB base_xp segment 67 xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( io x_cxy , &iox_ptr->base ) );60 xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) ); 68 61 69 62 // set PTPR register … … 72 65 73 66 /////////////////////////////////////////// 74 void soclib_iob_inval_page( xptr_t io x_xp,67 void soclib_iob_inval_page( xptr_t iob_xp, 75 68 vpn_t vpn ) 76 69 { 77 70 // get IOX device cluster and local pointer 78 cxy_t iox_cxy = GET_CXY( iox_xp );79 device_t * iox_ptr = (device_t *)GET_PTR( iox_xp );71 cxy_t iob_cxy = GET_CXY( iob_xp ); 72 chdev_t * iob_ptr = (chdev_t *)GET_PTR( iob_xp ); 80 73 81 74 // get extended pointer on SOCLIB_IOB base_xp segment 82 xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( io x_cxy , &iox_ptr->base ) );75 xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) ); 83 76 84 77 // invalidate TLB entry … … 87 80 88 81 ////////////////////////////////////////////// 89 uint32_t soclib_iob_get_bvar( xptr_t io x_xp )82 uint32_t soclib_iob_get_bvar( xptr_t iob_xp ) 90 83 { 91 84 // get IOX device cluster and local pointer 92 cxy_t iox_cxy = GET_CXY( iox_xp );93 device_t * iox_ptr = (device_t *)GET_PTR( iox_xp );85 cxy_t iob_cxy = GET_CXY( iob_xp ); 86 chdev_t * iob_ptr = (chdev_t *)GET_PTR( iob_xp ); 94 87 95 88 // get extended pointer on SOCLIB_IOB base_xp segment 96 xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( io x_cxy , &iox_ptr->base ) );89 xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) ); 97 90 98 91 // get BVAR register … … 101 94 102 95 /////////////////////////////////////////////// 103 uint32_t soclib_iob_get_srcid( xptr_t io x_xp )96 uint32_t soclib_iob_get_srcid( xptr_t iob_xp ) 104 97 { 105 98 // get IOX device cluster and local pointer 106 cxy_t iox_cxy = GET_CXY( iox_xp );107 device_t * iox_ptr = (device_t *)GET_PTR( iox_xp );99 cxy_t iob_cxy = GET_CXY( iob_xp ); 100 chdev_t * iob_ptr = (chdev_t *)GET_PTR( iob_xp ); 108 101 109 102 // get extended pointer on SOCLIB_IOB base_xp segment 110 xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( io x_cxy , &iox_ptr->base ) );103 xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) ); 111 104 112 105 // get BVAR register … … 115 108 116 109 /////////////////////////////////////////////// 117 uint32_t soclib_iob_get_error( xptr_t io x_xp )110 uint32_t soclib_iob_get_error( xptr_t iob_xp ) 118 111 { 119 112 // get IOX device cluster and local pointer 120 cxy_t iox_cxy = GET_CXY( iox_xp );121 device_t * iox_ptr = (device_t *)GET_PTR( iox_xp );113 cxy_t iob_cxy = GET_CXY( iob_xp ); 114 chdev_t * iob_ptr = (chdev_t *)GET_PTR( iob_xp ); 122 115 123 116 // get extended pointer on SOCLIB_IOB base_xp segment 124 xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( io x_cxy , &iox_ptr->base ) );117 xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) ); 125 118 126 119 // get BVAR register -
trunk/kernel/drivers/soclib/soclib_iob.h
r1 r4 26 26 27 27 #include <hal_types.h> 28 #include < device.h>28 #include <chdev.h> 29 29 30 30 /****************************************************************************************** … … 61 61 * This function initializes the SOCLIB IOB component: 62 62 ****************************************************************************************** 63 * @ iob_xp : extended pointer on the remote IOX devicedescriptor.63 * @ chdev : local pointer on IOB chdev descriptor. 64 64 *****************************************************************************************/ 65 void soclib_iob_init( xptr_t iox_xp);65 void soclib_iob_init( chdev_t * chdev ); 66 66 67 67 /****************************************************************************************** -
trunk/kernel/drivers/soclib/soclib_memc.c
r1 r4 22 22 23 23 #include <bits.h> 24 #include < device.h>24 #include <chdev.h> 25 25 #include <driver.h> 26 26 #include <drvdb.h> -
trunk/kernel/drivers/soclib/soclib_mmc.c
r1 r4 24 24 25 25 #include <hal_types.h> 26 #include < device.h>26 #include <chdev.h> 27 27 #include <dev_mmc.h> 28 28 #include <soclib_mmc.h> … … 32 32 33 33 34 ///////////////////////////////////// 35 void soclib_mmc_init( xptr_t dev_xp)34 /////////////////////////////////////// 35 void soclib_mmc_init( chdev_t * chdev ) 36 36 { 37 // get local pointer on MMC device descriptor 38 device_t * dev_ptr = (device_t *)GET_PTR( dev_xp ); 39 40 // get extended pointer on MMC peripheral from MMC device 41 xptr_t mmc_xp = dev_ptr->base; 42 43 // get local pointer on MMC segment base 44 uint32_t * base = (uint32_t *)GET_PTR( mmc_xp ); 37 // get pointer on MMC segment base 38 uint32_t * base = (uint32_t *)GET_PTR( chdev->base ); 45 39 46 40 // enable MMC IRQ … … 49 43 50 44 51 ////////////////////////////////////////////////////////////// ////52 void __attribute__ ((noinline)) soclib_mmc_c ommand( xptr_t th_xp )45 ////////////////////////////////////////////////////////////// 46 void __attribute__ ((noinline)) soclib_mmc_cmd( xptr_t th_xp ) 53 47 { 54 48 xptr_t dev_xp; // extended pointer on MMC device … … 64 58 65 59 // get command type and extended pointer on MMC device 66 type = hal_remote_lw ( XPTR( th_cxy , &th_ptr-> dev.mmc.type ) );67 dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr-> dev.mmc.dev_xp ) );60 type = hal_remote_lw ( XPTR( th_cxy , &th_ptr->command.mmc.type ) ); 61 dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->command.mmc.dev_xp ) ); 68 62 69 63 // get MMC device cluster and local pointer 70 cxy_t 71 device_t * dev_ptr = (device_t *)GET_PTR( dev_xp );64 cxy_t dev_cxy = GET_CXY( dev_xp ); 65 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp ); 72 66 73 67 // get extended pointer on SOCLIB-MMC peripheral … … 81 75 { 82 76 // get buffer paddr 83 buf_paddr = hal_remote_lwd( XPTR( th_cxy , &th_ptr-> dev.mmc.buf_paddr ) );77 buf_paddr = hal_remote_lwd( XPTR( th_cxy , &th_ptr->command.mmc.buf_paddr ) ); 84 78 85 79 // split buffer paddr in two 32 bits words … … 88 82 89 83 // get buffer size 90 buf_size = hal_remote_lw( XPTR( th_cxy , &th_ptr-> dev.mmc.buf_size ) );84 buf_size = hal_remote_lw( XPTR( th_cxy , &th_ptr->command.mmc.buf_size ) ); 91 85 92 86 // get command type … … 102 96 { 103 97 // get src/dst buffer local pointer and register index 104 reg_ptr = (uint32_t *)hal_remote_lpt( XPTR( th_cxy , &th_ptr-> dev.mmc.reg_ptr ) );105 reg_index = hal_remote_lw( XPTR( th_cxy , &th_ptr-> dev.mmc.reg_index ) );98 reg_ptr = (uint32_t *)hal_remote_lpt( XPTR( th_cxy , &th_ptr->command.mmc.reg_ptr ) ); 99 reg_index = hal_remote_lw( XPTR( th_cxy , &th_ptr->command.mmc.reg_index ) ); 106 100 107 101 // move register to/from local buffer … … 119 113 120 114 //////////////////////////////////////////////////////////////// 121 void __attribute__ ((noinline)) soclib_mmc_isr( device_t *dev )115 void __attribute__ ((noinline)) soclib_mmc_isr( chdev_t * chdev ) 122 116 { 123 // get extended pointer on MMC peripheral from MMC device 124 xptr_t mmc_xp = dev->base; 125 126 // get local pointer on MMC segment base 127 uint32_t * base = (uint32_t *)GET_PTR( mmc_xp ); 117 // get pointer on MMC segment base 118 uint32_t * base = (uint32_t *)GET_PTR( chdev->base ); 128 119 129 120 // get faulty ADDRESS and SRCID from MMC registers -
trunk/kernel/drivers/soclib/soclib_mmc.h
r1 r4 25 25 #define _SOCLIB_MMC_H_ 26 26 27 #include < device.h>27 #include <chdev.h> 28 28 #include <dev_mmc.h> 29 29 #include <hal_types.h> … … 158 158 /******************************************************************************************** 159 159 * This function initializes the SOCLIB_MMC peripheral hardware registers related 160 * to error signaling to enablethe MMC peripheral IRQ.160 * to error signaling. It enables the MMC peripheral IRQ. 161 161 ******************************************************************************************** 162 * @ dev_xp : extended pointer on the generic MMC devicedescriptor.162 * @ chdev : local pointer on the MMC chdev descriptor. 163 163 *******************************************************************************************/ 164 extern void soclib_mmc_init( xptr_t dev_xp);164 extern void soclib_mmc_init( chdev_t * chdev ); 165 165 166 166 /******************************************************************************************** … … 171 171 * @ thread_xp : extended pointer on the client thread. 172 172 *******************************************************************************************/ 173 extern void soclib_mmc_c ommand( xptr_t thread_xp );173 extern void soclib_mmc_cmd( xptr_t thread_xp ); 174 174 175 175 /******************************************************************************************** … … 178 178 * and the associated SRCID, and acknowledges the IRQ. 179 179 ******************************************************************************************** 180 * @ dev : local pointer on the generic MMC devicedescriptor.180 * @ chdev : local pointer on the MMC chdev descriptor. 181 181 *******************************************************************************************/ 182 extern void soclib_mmc_isr( device_t *dev );182 extern void soclib_mmc_isr( chdev_t * chdev ); 183 183 184 184 -
trunk/kernel/drivers/soclib/soclib_nic.c
r1 r4 25 25 #include <hal_remote.h> 26 26 #include <hal_special.h> 27 #include < device.h>27 #include <chdev.h> 28 28 #include <dev_nic.h> 29 29 #include <spinlock.h> … … 34 34 #include <soclib_nic.h> 35 35 36 37 ///////////////////////////////////// 38 void soclib_nic_init( xptr_t dev_xp ) 36 /////////////////////////////////////// 37 void soclib_nic_init( chdev_t * chdev ) 39 38 { 40 39 uint32_t i; 41 40 kmem_req_t req; 42 41 43 // get NIC device descriptor cluster and local pointer44 cxy_t dev_cxy = GET_CXY( dev_xp );45 device_t * dev_ptr = (device_t *)GET_PTR( dev_xp );46 47 // get hardware device base address48 xptr_t base = hal_remote_lwd( XPTR( dev_cxy , &dev_ptr->base ) );49 50 42 // get hardware device cluster and local pointer 51 cxy_t nic_cxy = GET_CXY( base );52 uint32_t * nic_ptr = (uint32_t *)GET_PTR( base );43 cxy_t nic_cxy = GET_CXY( chdev->base ); 44 uint32_t * nic_ptr = (uint32_t *)GET_PTR( chdev->base ); 53 45 54 46 // initialize Soclib NIC global registers … … 57 49 58 50 // allocate memory for chbuf descriptor (one page) 59 if( sizeof(nic_chbuf_t) > CONFIG_PPM_PAGE_SIZE ) 60 { 61 printk("\n[PANIC] in %s : chbuf descriptor exceeds one page\n", __FUNCTION__ ); 62 hal_core_sleep(); 63 } 51 assert( (sizeof(nic_chbuf_t) <= CONFIG_PPM_PAGE_SIZE ) , __FUNCTION__ , 52 "chbuf descriptor exceeds one page" ); 64 53 65 54 req.type = KMEM_PAGE; … … 69 58 nic_chbuf_t * chbuf = (nic_chbuf_t *)kmem_alloc( &req ); 70 59 71 if( chbuf == NULL ) 72 { 73 hal_core_sleep("%s : no more memory for chbuf desccriptor\n", __FUNCTION__ ); 74 } 60 assert( (chbuf != NULL) , __FUNCTION__ , 61 "cannot allocate chbuf descriptor" ); 75 62 76 63 // initialise chbuf state … … 81 68 // allocate containers (one page per container) 82 69 // and complete chbuf descriptor initialization 83 if( CONFIG_PPM_PAGE_SIZE != 4096 ) 84 { 85 hal_core_sleep("%s : chbuf container must be 4 Kbytes\n", __FUNCTION__ ); 86 } 70 assert( (CONFIG_PPM_PAGE_SIZE == 4096) , __FUNCTION__ , 71 "chbuf container must be 4 Kbytes" ); 87 72 88 73 for( i = 0 ; i < CONFIG_NIC_CHBUF_DEPTH ; i++ ) … … 90 75 uint32_t * container = (uint32_t *)kmem_alloc( &req ); 91 76 92 if( container == NULL ) 93 { 94 hal_core_sleep("%s : no more memory for container\n", __FUNCTION__ ); 95 } 77 assert( (container != NULL) , __FUNCTION__ , 78 "cannot allocate container" ); 96 79 97 80 chbuf->cont[i] = container; 98 81 chbuf->full[i] = (paddr_t)XPTR( local_cxy , container ); 99 82 } 100 101 83 } // end soclib_nic_init() 102 84 … … 121 103 122 104 // get command arguments 123 cmd = thread_ptr-> dev.nic.cmd;124 buffer = thread_ptr-> dev.nic.buffer;125 length = thread_ptr-> dev.nic.length;126 dev_xp = thread_ptr-> dev.nic.dev_xp;105 cmd = thread_ptr->command.nic.cmd; 106 buffer = thread_ptr->command.nic.buffer; 107 length = thread_ptr->command.nic.length; 108 dev_xp = thread_ptr->command.nic.dev_xp; 127 109 128 110 // get local pointer for device 129 device_t * dev_ptr = (device_t *)GET_PTR( dev_xp );111 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp ); 130 112 131 113 // get chbuf descriptor pointer … … 226 208 { 227 209 // return chbuf writable 228 thread_ptr-> dev.nic.status = true;210 thread_ptr->command.nic.status = true; 229 211 } 230 212 else // current container not writable … … 244 226 245 227 // return chbuf writable 246 thread_ptr-> dev.nic.status = true;228 thread_ptr->command.nic.status = true; 247 229 } 248 230 else // next container full 249 231 { 250 232 // return chbuf non writable 251 thread_ptr-> dev.nic.status = false;233 thread_ptr->command.nic.status = false; 252 234 } 253 235 } … … 270 252 { 271 253 // return chbuf readable 272 thread_ptr-> dev.nic.status = true;254 thread_ptr->command.nic.status = true; 273 255 } 274 256 else // current container non readable … … 288 270 289 271 // return chbuf readable 290 thread_ptr-> dev.nic.status = true;272 thread_ptr->command.nic.status = true; 291 273 } 292 274 else // next container empty 293 275 { 294 276 // return chbuf non readable 295 thread_ptr-> dev.nic.status = false;277 thread_ptr->command.nic.status = false; 296 278 } 297 279 } … … 303 285 304 286 305 //////////////////////////////////////////////////////////////// 306 void __attribute__ ((noinline)) soclib_nic_isr( device_t *dev )287 ///////////////////////////////////////////////////////////////// 288 void __attribute__ ((noinline)) soclib_nic_isr( chdev_t * chdev ) 307 289 { 308 290 // get base, size, channel, is_rx from NIC channel device NIC 309 xptr_t base = dev->base;310 uint32_t channel = dev->channel;311 bool_t is_rx = dev->is_rx;291 xptr_t base = chdev->base; 292 uint32_t channel = chdev->channel; 293 bool_t is_rx = chdev->is_rx; 312 294 313 295 // get NIC peripheral cluster and local pointer … … 326 308 327 309 // unblock server thread 328 thread_t * server = dev->server;310 thread_t * server = chdev->server; 329 311 thread_unblock( XPTR( local_cxy , server ) , THREAD_BLOCKED_IO ); 330 312 -
trunk/kernel/drivers/soclib/soclib_nic.h
r1 r4 25 25 #define _SOCLIB_NIC_H_ 26 26 27 #include < device.h>27 #include <chdev.h> 28 28 #include <hal_types.h> 29 29 … … 152 152 * or a TX empty container, and route the WTI IRQ to the core running the server thread. 153 153 ******************************************************************************************** 154 * @ dev_xp : extended pointer on the generic NIC devicedescriptor.155 *******************************************************************************************/ 156 extern void soclib_nic_init( xptr_t dev_xp);154 * @ chdev : pointer on NIC chdev descriptor. 155 *******************************************************************************************/ 156 extern void soclib_nic_init( chdev_t * chdev ); 157 157 158 158 /******************************************************************************************** … … 196 196 * it goes to kernel panic. 197 197 ******************************************************************************************** 198 * @ dev : local pointer on the generic IOC devicedescriptor.199 *******************************************************************************************/ 200 extern void soclib_nic_isr( device_t *dev );198 * @ chdev : local pointer on NIC chdev descriptor. 199 *******************************************************************************************/ 200 extern void soclib_nic_isr( chdev_t * chdev ); 201 201 202 202 -
trunk/kernel/drivers/soclib/soclib_pic.c
r1 r4 23 23 24 24 #include <hal_types.h> 25 #include < device.h>25 #include <chdev.h> 26 26 #include <soclib_pic.h> 27 27 #include <soclib_xcu.h> … … 31 31 32 32 33 ////////////////////////////////////// 34 void soclib_pic_init( xptr_t dev_xp)33 //////////////////////////////////////// 34 void soclib_pic_init( chdev_t * chdev ) 35 35 { 36 // get PIC device descriptor cluster and local pointer37 cxy_t dev_cxy = GET_CXY( dev_xp );38 device_t * dev_ptr = (device_t *)GET_PTR( dev_xp );39 40 // get extended pointer on PIC segment base from PIC device descriptor41 xptr_t seg_xp = (xptr_t)hal_remote_lwd( XPTR( dev_cxy , &dev_ptr->base ) );42 43 36 // get PIC controller segment cluster and local pointer 44 cxy_t seg_cxy = (cxy_t)GET_CXY( seg_xp);45 uint32_t * seg_ptr = (uint32_t *)GET_PTR( seg_xp);37 cxy_t seg_cxy = (cxy_t)GET_CXY( chdev->base ); 38 uint32_t * seg_ptr = (uint32_t *)GET_PTR( chdev->base ); 46 39 uint32_t i; 47 40 … … 59 52 { 60 53 // get PIC device descriptor cluster and local pointer 61 cxy_t 62 device_t * dev_ptr = (device_t *)GET_PTR( dev_xp );54 cxy_t dev_cxy = GET_CXY( dev_xp ); 55 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp ); 63 56 64 57 // get extended pointer on PIC segment base from PIC device descriptor … … 85 78 { 86 79 // get PIC device descriptor cluster and local pointer 87 cxy_t 88 device_t * dev_ptr = (device_t *)GET_PTR( dev_xp );80 cxy_t dev_cxy = GET_CXY( dev_xp ); 81 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp ); 89 82 90 83 // get extended pointer on PIC segment base from PIC device descriptor … … 105 98 { 106 99 // get PIC device descriptor cluster and local pointer 107 cxy_t 108 device_t * dev_ptr = (device_t *)GET_PTR( dev_xp );100 cxy_t dev_cxy = GET_CXY( dev_xp ); 101 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp ); 109 102 110 103 // get extended pointer on PIC segment base from PIC device descriptor -
trunk/kernel/drivers/soclib/soclib_pic.h
r1 r4 38 38 39 39 /****************************************************************************************** 40 * This blocking function desactivates all input IRQs in a remotePIC controler.41 * It can be called by any thread running on any cluster.40 * This blocking function desactivates all input IRQs in PIC controler. 41 * It must be called by a local thread. 42 42 ****************************************************************************************** 43 * @ dev_xp : extended pointer on the PIC devicedescriptor.43 * @ chdev : pointer on PIC chdev descriptor. 44 44 *****************************************************************************************/ 45 void soclib_pic_init( xptr_t dev_xp);45 void soclib_pic_init( chdev_t * chdev ); 46 46 47 47 /****************************************************************************************** -
trunk/kernel/drivers/soclib/soclib_tty.c
r1 r4 23 23 24 24 #include <dev_txt.h> 25 #include < device.h>25 #include <chdev.h> 26 26 #include <soclib_tty.h> 27 27 #include <remote_spinlock.h> … … 29 29 #include <hal_special.h> 30 30 31 ///////////////////////////////////// 32 void soclib_tty_init( xptr_t dev_xp)31 /////////////////////////////////////// 32 void soclib_tty_init( chdev_t * chdev ) 33 33 { 34 // get TXT device cluster and local pointer35 cxy_t dev_cxy = GET_CXY( dev_xp );36 device_t * dev_ptr = (device_t *)GET_PTR( dev_xp );37 38 34 // get extended pointer on TTY-SOCLIB peripheral base address 39 xptr_t tty_xp = (xptr_t)hal_remote_lwd( XPTR( dev_cxy , &dev_ptr->base ) );35 xptr_t tty_xp = chdev->base; 40 36 41 37 // get SOCLIB_TTY device cluster and local pointer … … 46 42 hal_remote_sw( XPTR( tty_cxy , tty_ptr + TTY_CONFIG_REG ) , 0 ); 47 43 48 } // endsoclib_tty_init()49 50 ////////////////////////////////////////////////////////////// ////51 void __attribute__ ((noinline)) soclib_tty_c ommand( xptr_t th_xp )44 } // soclib_tty_init() 45 46 ////////////////////////////////////////////////////////////// 47 void __attribute__ ((noinline)) soclib_tty_cmd( xptr_t th_xp ) 52 48 { 53 49 // get client thread cluster and local pointer … … 56 52 57 53 // get command type and extended pointer on TXT device 58 uint32_t type = hal_remote_lw ( XPTR( th_cxy , &th_ptr-> dev.txt.type ) );59 xptr_t dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr-> dev.txt.dev_xp ) );54 uint32_t type = hal_remote_lw ( XPTR( th_cxy , &th_ptr->command.txt.type ) ); 55 xptr_t dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->command.txt.dev_xp ) ); 60 56 61 57 // get TXT device cluster and local pointer 62 cxy_t 63 device_t * dev_ptr = (device_t *)GET_PTR( dev_xp );58 cxy_t dev_cxy = GET_CXY( dev_xp ); 59 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp ); 64 60 65 61 // get extended pointer on SOCLIB_TTY base segment … … 70 66 uint32_t * tty_ptr = (uint32_t *)GET_PTR( tty_xp ); 71 67 68 // get TTY channel index and channel base address 69 uint32_t channel = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->channel ) ); 70 uint32_t * base = tty_ptr + TTY_SPAN * channel; 71 72 72 if( type == TXT_READ ) // descheduling strategy for calling thead 73 73 { 74 74 // unmask RX_IRQ (data transfer will be done by the TTY_RX ISR) 75 xptr_t config_xp = XPTR( tty_cxy , tty_ptr+ TTY_CONFIG_REG );75 xptr_t config_xp = XPTR( tty_cxy , base + TTY_CONFIG_REG ); 76 76 uint32_t old = hal_remote_lw( config_xp ); 77 77 uint32_t new = old | TTY_CONFIG_RX_ENABLE; … … 85 85 { 86 86 // unmask TX_IRQ (data transfer will be done by the TTY_TX ISR) 87 xptr_t config_xp = XPTR( tty_cxy , tty_ptr+ TTY_CONFIG_REG );87 xptr_t config_xp = XPTR( tty_cxy , base + TTY_CONFIG_REG ); 88 88 uint32_t old = hal_remote_lw( config_xp ); 89 89 uint32_t new = old | TTY_CONFIG_TX_ENABLE; … … 101 101 102 102 // get source buffer extended pointer & bytes count 103 uint32_t count = hal_remote_lw ( XPTR( th_cxy , &th_ptr-> dev.txt.count ) );104 xptr_t buf_xp = hal_remote_lwd( XPTR( th_cxy , &th_ptr-> dev.txt.buf_xp ) );103 uint32_t count = hal_remote_lw ( XPTR( th_cxy , &th_ptr->command.txt.count ) ); 104 xptr_t buf_xp = hal_remote_lwd( XPTR( th_cxy , &th_ptr->command.txt.buf_xp ) ); 105 105 106 106 // loop on characters … … 110 110 { 111 111 // get TTY_STATUS_REG 112 status = hal_remote_lw( XPTR( tty_cxy , tty_ptr+ TTY_STATUS_REG ) );112 status = hal_remote_lw( XPTR( tty_cxy , base + TTY_STATUS_REG ) ); 113 113 empty = ( (status & TTY_STATUS_TX_FULL) == 0 ); 114 114 … … 119 119 120 120 // write byte to TTY_WRITE_REG in TTY cluster 121 hal_remote_sb( XPTR( tty_cxy , tty_ptr+ TTY_WRITE_REG ) , byte );121 hal_remote_sb( XPTR( tty_cxy , base + TTY_WRITE_REG ) , byte ); 122 122 } 123 123 } … … 125 125 } 126 126 } 127 } // endsoclib_tty_command()128 129 130 //////////////////////////////////////////////////////////////// 131 void __attribute__ ((noinline)) soclib_tty_isr( device_t *dev )127 } // soclib_tty_command() 128 129 130 ///////////////////////////////////////////////////////////////// 131 void __attribute__ ((noinline)) soclib_tty_isr( chdev_t * chdev ) 132 132 { 133 133 uint32_t type; // command type … … 138 138 uint32_t i; 139 139 140 141 140 // get extended pointer on client thread 142 xptr_t root = XPTR( local_cxy , &dev->wait_root );141 xptr_t root = XPTR( local_cxy , &chdev->wait_root ); 143 142 xptr_t client_xp = XLIST_FIRST_ELEMENT( root , thread_t , wait_list ); 144 143 … … 148 147 149 148 // get command arguments 150 type = hal_remote_lw ( XPTR( client_cxy , &client_ptr-> dev.txt.type ) );151 count = hal_remote_lw ( XPTR( client_cxy , &client_ptr-> dev.txt.count ) );152 buf_xp = hal_remote_lwd( XPTR( client_cxy , &client_ptr-> dev.txt.buf_xp ) );149 type = hal_remote_lw ( XPTR( client_cxy , &client_ptr->command.txt.type ) ); 150 count = hal_remote_lw ( XPTR( client_cxy , &client_ptr->command.txt.count ) ); 151 buf_xp = hal_remote_lwd( XPTR( client_cxy , &client_ptr->command.txt.buf_xp ) ); 153 152 154 153 // get SOCLIB_TTY peripheral cluster and local pointer 155 cxy_t tty_cxy = GET_CXY( dev->base ); 156 uint32_t * tty_ptr = (uint32_t *)GET_PTR( dev->base ); 154 cxy_t tty_cxy = GET_CXY( chdev->base ); 155 uint32_t * tty_ptr = (uint32_t *)GET_PTR( chdev->base ); 156 157 // get channel base address 158 uint32_t * base = tty_ptr + TTY_SPAN * chdev->channel; 157 159 158 160 if( type == TXT_READ ) // read one single character 159 161 { 160 162 // get TTY_STATUS_REG 161 status = hal_remote_lw( XPTR( tty_cxy , tty_ptr+ TTY_STATUS_REG ) );163 status = hal_remote_lw( XPTR( tty_cxy , base + TTY_STATUS_REG ) ); 162 164 163 165 if( status & TTY_STATUS_RX_FULL ) // TTY_RX full => transfer one byte 164 166 { 165 167 // get a byte from TTY_READ_REG, and acknowledge RX_IRQ 166 byte = (char)hal_remote_lb( XPTR( tty_cxy , tty_ptr+ TTY_READ_REG ) );168 byte = (char)hal_remote_lb( XPTR( tty_cxy , base + TTY_READ_REG ) ); 167 169 168 170 // write it to command buffer … … 174 176 if( (byte == '\b') || (byte == 0x7F) ) 175 177 { 176 hal_remote_sb( XPTR( tty_cxy , tty_ptr+ TTY_WRITE_REG ) , '\b' );177 hal_remote_sb( XPTR( tty_cxy , tty_ptr+ TTY_WRITE_REG ) , ' ' );178 hal_remote_sb( XPTR( tty_cxy , tty_ptr+ TTY_WRITE_REG ) , '\b' );178 hal_remote_sb( XPTR( tty_cxy , base + TTY_WRITE_REG ) , '\b' ); 179 hal_remote_sb( XPTR( tty_cxy , base + TTY_WRITE_REG ) , ' ' ); 180 hal_remote_sb( XPTR( tty_cxy , base + TTY_WRITE_REG ) , '\b' ); 179 181 } 180 182 else 181 183 { 182 hal_remote_sw( XPTR( tty_cxy , tty_ptr+ TTY_WRITE_REG ) , byte );184 hal_remote_sw( XPTR( tty_cxy , base + TTY_WRITE_REG ) , byte ); 183 185 } 184 186 } … … 195 197 { 196 198 // get TTY_STATUS_REG 197 status = hal_remote_lw( XPTR( tty_cxy , tty_ptr+ TTY_STATUS_REG ) );199 status = hal_remote_lw( XPTR( tty_cxy , base + TTY_STATUS_REG ) ); 198 200 199 201 if( (status & TTY_STATUS_TX_FULL) == 0 ) // TTY_TX empty => transfer one byte … … 203 205 204 206 // write byte to TTY_WRITE_REG, and acknowledge TX_IRQ 205 hal_remote_sb( XPTR( tty_cxy , tty_ptr+ TTY_STATUS_REG ) , byte );207 hal_remote_sb( XPTR( tty_cxy , base + TTY_STATUS_REG ) , byte ); 206 208 } 207 209 else // TTY_TX full => update command arguments and exit ISR for retry 208 210 { 209 // update arguments in command for retry 210 hal_remote_sw ( XPTR( client_cxy , &client_ptr->dev.txt.count ) , count - i ); 211 hal_remote_swd( XPTR( client_cxy , &client_ptr->dev.txt.buf_xp ) , buf_xp + i ); 211 hal_remote_sw ( XPTR( client_cxy , &client_ptr->command.txt.count ), count-i ); 212 hal_remote_swd( XPTR( client_cxy , &client_ptr->command.txt.buf_xp ), buf_xp+i ); 212 213 return; 213 214 } … … 218 219 219 220 // mask both TTY_RX_IRQ and TTY_TX_IRQ 220 hal_remote_sw( XPTR( tty_cxy , tty_ptr+ TTY_CONFIG_REG ) , 0 );221 hal_remote_sw( XPTR( tty_cxy , base + TTY_CONFIG_REG ) , 0 ); 221 222 222 223 // set I/O operation status in command 223 hal_remote_sw( XPTR( client_cxy , &client_ptr-> dev.txt.error ) , 0 );224 hal_remote_sw( XPTR( client_cxy , &client_ptr->command.txt.error ) , 0 ); 224 225 225 226 // unblock server thread 226 thread_unblock( XPTR( local_cxy , & dev->server ) , THREAD_BLOCKED_DEV_ISR );227 thread_unblock( XPTR( local_cxy , &chdev->server ) , THREAD_BLOCKED_DEV_ISR ); 227 228 228 229 // unblock client thread 229 230 thread_unblock( client_xp , THREAD_BLOCKED_IO ); 230 231 231 } // endsoclib_tty_isr()232 233 232 } // soclib_tty_isr() 233 234 -
trunk/kernel/drivers/soclib/soclib_tty.h
r1 r4 23 23 24 24 #include <dev_txt.h> 25 #include < device.h>25 #include <chdev.h> 26 26 #include <spinlock.h> 27 27 … … 60 60 61 61 /**************************************************************************************** 62 * This function masks both the TTY_RX and TTY_TX IRQs from the SOCLIB_TTY device.62 * This function masks both the TTY_RX and TTY_TX IRQs. 63 63 * Thes IRQs are unmasked by the soclib_tty_cmd() function. 64 64 **************************************************************************************** 65 * @ dev : extended pointer on the generic TXT devicedescriptor.65 * @ chdev : pointer on the TXT chdev descriptor. 66 66 ***************************************************************************************/ 67 extern void soclib_tty_init( xptr_t dev_xp);67 void soclib_tty_init( chdev_t * chdev ); 68 68 69 69 /**************************************************************************************** … … 77 77 * a busy waiting policy if required. 78 78 **************************************************************************************** 79 * @ xp_thread: extended pointer on client thread descriptor.79 * @ thread_xp : extended pointer on client thread descriptor. 80 80 ***************************************************************************************/ 81 extern void soclib_tty_command( xptr_t thread_xp );81 void soclib_tty_cmd( xptr_t thread_xp ); 82 82 83 83 /**************************************************************************************** 84 84 * This ISR should be executed only for the TXT_READ and TXT_WRITE commands. 85 * It get the command arguments from the first client thread in the TXT devicequeue:85 * It get the command arguments from the first client thread in the TXT chdev queue: 86 86 * - if TXT_READ, it transfer one byte from the TTY_READ_REG to the command buffer. 87 87 * It simply returns for retry if TTY_READ_REG is empty. … … 92 92 * the server thread, and unblock the client thread. 93 93 **************************************************************************************** 94 * @ dev : local pointer on generic TXT devicedescriptor.94 * @ chdev : local pointer on TXT chdev descriptor. 95 95 ***************************************************************************************/ 96 extern void soclib_tty_isr( device_t *dev );96 void soclib_tty_isr( chdev_t * chdev ); 97 97 -
trunk/kernel/drivers/soclib/soclib_xcu.c
r1 r4 25 25 #include <hal_types.h> 26 26 #include <core.h> 27 #include < device.h>27 #include <chdev.h> 28 28 29 29 30 30 31 //////////////////////////////////// /32 void soclib_xcu_init( device_t * icu,33 lid_t 31 //////////////////////////////////// 32 void soclib_xcu_init( chdev_t * icu, 33 lid_t lid ) 34 34 { 35 35 // get local ICU segment base address … … 42 42 } 43 43 44 //////////////////////////////////////////// ///45 void soclib_xcu_disable_irq( xptr_t icu_xp,44 //////////////////////////////////////////// 45 void soclib_xcu_disable_irq( chdev_t * icu, 46 46 uint32_t mask, 47 47 uint32_t type, 48 48 lid_t lid ) 49 49 { 50 // get remote ICU cluster and local pointer 51 cxy_t icu_cxy = GET_CXY( icu_xp ); 52 device_t * icu_ptr = (device_t *)GET_PTR( icu_xp ); 50 // get XCU segment base address 51 uint32_t * base = (uint32_t *)GET_PTR( icu->base ); 53 52 54 // get remote XCU segment base address 55 xptr_t base = (xptr_t)hal_remote_lwd( XPTR( icu_cxy , &icu_ptr->base ) ); 56 57 // compute xptr on relevant XCU mask register 58 xptr_t reg_xp; 59 if ( type == WTI_TYPE ) reg_xp = base + ((XCU_MSK_WTI_DISABLE << 5 | lid)<<2); 60 else if( type == HWI_TYPE ) reg_xp = base + ((XCU_MSK_HWI_DISABLE << 5 | lid)<<2); 61 else reg_xp = base + ((XCU_MSK_PTI_DISABLE << 5 | lid)<<2); 62 63 // reset relevant XCU mask register 64 hal_remote_sw( reg_xp , mask ); 53 // write into register 54 if ( type == WTI_TYPE ) base[XCU_MSK_WTI_DISABLE << 5 | lid] = mask; 55 else if( type == HWI_TYPE ) base[XCU_MSK_HWI_DISABLE << 5 | lid] = mask; 56 else base[XCU_MSK_PTI_DISABLE << 5 | lid] = mask; 65 57 } 66 58 67 /////////////////////////////////////////// ///68 void soclib_xcu_enable_irq( xptr_t icu_xp,59 /////////////////////////////////////////// 60 void soclib_xcu_enable_irq( chdev_t * icu, 69 61 uint32_t mask, 70 62 uint32_t type, 71 63 lid_t lid ) 72 64 { 73 // get remote ICU cluster and local pointer 74 cxy_t icu_cxy = GET_CXY( icu_xp ); 75 device_t * icu_ptr = (device_t *)GET_PTR( icu_xp ); 65 // get XCU segment base address 66 uint32_t * base = (uint32_t *)GET_PTR( icu->base ); 76 67 77 // get remote XCU segment base address 78 xptr_t base = (xptr_t)hal_remote_lwd( XPTR( icu_cxy , &icu_ptr->base ) ); 79 80 // compute xptr on relevant XCU mask register 81 xptr_t reg_xp; 82 if ( type == WTI_TYPE ) reg_xp = base + ((XCU_MSK_WTI_ENABLE << 5 | lid)<<2); 83 else if( type == HWI_TYPE ) reg_xp = base + ((XCU_MSK_HWI_ENABLE << 5 | lid)<<2); 84 else reg_xp = base + ((XCU_MSK_PTI_ENABLE << 5 | lid)<<2); 85 86 // set relevant XCU mask register 87 hal_remote_sw( reg_xp , mask ); 68 // write into register 69 if ( type == WTI_TYPE ) base[XCU_MSK_WTI_ENABLE << 5 | lid] = mask; 70 else if( type == HWI_TYPE ) base[XCU_MSK_HWI_ENABLE << 5 | lid] = mask; 71 else base[XCU_MSK_PTI_ENABLE << 5 | lid] = mask; 88 72 } 89 73 90 ////////////////////////////////////////// /91 void soclib_xcu_set_period( device_t * icu,92 uint32_t 93 uint32_t 74 ////////////////////////////////////////// 75 void soclib_xcu_set_period( chdev_t * icu, 76 uint32_t index, 77 uint32_t period ) 94 78 { 95 79 // get local ICU segment base address … … 100 84 } 101 85 102 ///////////////////////////////////////////// /103 uint32_t soclib_xcu_ack_timer( device_t * icu,104 uint32_t 86 ///////////////////////////////////////////// 87 uint32_t soclib_xcu_ack_timer( chdev_t * icu, 88 uint32_t index ) 105 89 { 106 90 // get local ICU segment base address … … 111 95 } 112 96 113 /////////////////////////////////////////// ////114 void soclib_xcu_get_status( device_t* icu,97 /////////////////////////////////////////// 98 void soclib_xcu_get_status( chdev_t * icu, 115 99 lid_t lid, 116 100 uint32_t * hwi_status, … … 130 114 131 115 ///////////////////////////////////////// 132 void soclib_xcu_send_ipi( xptr_t xp_icu,116 void soclib_xcu_send_ipi( xptr_t icu_xp, 133 117 lid_t lid ) 134 118 { 135 119 // get target ICU device cluster and local pointer 136 cxy_t cxy_icu = GET_CXY( xp_icu);137 device_t * ptr_icu = (device_t *)GET_PTR( xp_icu);120 cxy_t cxy_icu = GET_CXY( icu_xp ); 121 chdev_t * ptr_icu = (chdev_t *)GET_PTR( icu_xp ); 138 122 139 123 // get extended pointer on target ICU segment base … … 148 132 149 133 ////////////////////////////////////////////// 150 uint32_t * soclib_xcu_wti_ptr( device_t* icu,134 uint32_t * soclib_xcu_wti_ptr( chdev_t * icu, 151 135 uint32_t index ) 152 136 { -
trunk/kernel/drivers/soclib/soclib_xcu.h
r1 r4 26 26 27 27 #include <hal_types.h> 28 #include < device.h>28 #include <chdev.h> 29 29 30 30 /****************************************************************************************** … … 52 52 53 53 /****************************************************************************************** 54 * This function initialises the local XCU devicemasks registers for a given54 * This function initialises the local XCU masks registers for a given 55 55 * core identified by its local index. 56 56 ****************************************************************************************** 57 * @ icu : pointer on the local ICU device descriptor58 * @ lid : core local index 57 * @ icu : pointer on the local ICU chdev descriptor. 58 * @ lid : core local index. 59 59 *****************************************************************************************/ 60 void soclib_xcu_init( device_t * icu,61 lid_t 60 void soclib_xcu_init( chdev_t * icu, 61 lid_t lid ); 62 62 63 63 /****************************************************************************************** 64 * This function set bits in a remoteXCU mask register for a given IRQ type,65 * and a given core. As it uses remote accesses, it can be callet in any cluster.64 * This function set bits in the local XCU mask register for a given IRQ type, 65 * and a given core. It must be called by a local thread. 66 66 * Only the bits with "1" value in mask argument are set, other bits are not modified. 67 67 * All input IRQs of requested types corresponding to "1" bits in mask are enabled. 68 68 ****************************************************************************************** 69 * @ icu _xp : extended pointer on the remote XCU device descriptor.70 * @ mask 71 * @ type 72 * @ lid 69 * @ icu : pointer on local XCU chdev descriptor 70 * @ mask : mask value 71 * @ type : HWI_TYPE / PTI_TYPE / WTI_TYPE 72 * @ lid : local core index == output IRQ index 73 73 *****************************************************************************************/ 74 void soclib_xcu_enable_irq( xptr_t icu_xp,74 void soclib_xcu_enable_irq( chdev_t * icu, 75 75 uint32_t mask, 76 76 uint32_t type, … … 78 78 79 79 /****************************************************************************************** 80 * This function clear bits in a remoteXCU mask register for a given IRQ type,81 * and a given core. As it uses remote accesses, it can be callet in any cluster.80 * This function clear bits in the local XCU mask register for a given IRQ type, 81 * and a given core. It must be called by a local thread. 82 82 * Only the bits with "1" value in mask argument are cleared, other bits are not modified. 83 83 * All input IRQs of requested types corresponding to "1" bits in mask are disabled. 84 84 ****************************************************************************************** 85 * @ icu _xp : extended pointer on the remote XCU device descriptor.86 * @ mask 87 * @ type 88 * @ lid 85 * @ icu : pointer on local XCU chdev descriptor 86 * @ mask : mask value 87 * @ type : HWI_TYPE / PTI_TYPE / WTI_TYPE 88 * @ lid : local core index == output IRQ index 89 89 *****************************************************************************************/ 90 void soclib_xcu_disable_irq( xptr_t icu_xp,90 void soclib_xcu_disable_irq( chdev_t * icu, 91 91 uint32_t mask, 92 92 uint32_t type, … … 96 96 * This function set the period value for a local XCU timer. 97 97 ****************************************************************************************** 98 * @ icu : pointer on the local ICU devicedescriptor98 * @ icu : pointer on the local XCU chdev descriptor 99 99 * @ index : timer index = PTI index 100 100 * @ period : Value to be written 101 101 *****************************************************************************************/ 102 void soclib_xcu_set_period( device_t* icu,102 void soclib_xcu_set_period( chdev_t * icu, 103 103 uint32_t index, 104 104 uint32_t period ); … … 107 107 * This function acknowledge a PTI IRQ for a local XCU timer. 108 108 ****************************************************************************************** 109 * @ icu : pointer on the local ICU devicedescriptor109 * @ icu : pointer on the local XCU chdev descriptor 110 110 * @ index : timer index = PTI index 111 111 * @ the returned value in not significant, but acknowledge requires a read. 112 112 *****************************************************************************************/ 113 uint32_t soclib_xcu_ack_timer( device_t* icu,113 uint32_t soclib_xcu_ack_timer( chdev_t * icu, 114 114 uint32_t index ); 115 115 … … 118 118 * If no active interrupt => status == 0 / else => status = index + 1 119 119 ****************************************************************************************** 120 * @ icu : pointer on the local ICU device descriptor.120 * @ icu : pointer on the local XCU chdev descriptor 121 121 * @ lid : core local index. 122 122 * @ hwi_status : buffer for returned HWI status … … 124 124 * @ pti_status : buffer for returned PTI status 125 125 *****************************************************************************************/ 126 void soclib_xcu_get_status( device_t* icu,126 void soclib_xcu_get_status( chdev_t * icu, 127 127 lid_t lid, 128 128 uint32_t * hwi_status, … … 144 144 * This function does not access the SOCLIB_XCU hardware device. 145 145 ****************************************************************************************** 146 * @ icu : pointer on the local ICU device descriptor.146 * @ icu : pointer on the local XCU chdev descriptor 147 147 * @ index : WTI mailbox index. 148 148 *****************************************************************************************/ 149 uint32_t * soclib_xcu_wti_ptr( device_t* icu,149 uint32_t * soclib_xcu_wti_ptr( chdev_t * icu, 150 150 uint32_t index ); 151 151
Note: See TracChangeset
for help on using the changeset viewer.