Changeset 4


Ignore:
Timestamp:
Apr 26, 2017, 2:10:21 PM (8 years ago)
Author:
alain
Message:

Introduce the chdev_t structure in place of device_t.

Location:
trunk/kernel/drivers
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/drivers/ibmpc/ata.c

    r1 r4  
    2121 */
    2222
    23 #include <device.h>
     23#include <chdev.h>
    2424#include <driver.h>
    2525#include <cpu.h>
  • trunk/kernel/drivers/ibmpc/pic.c

    r1 r4  
    2323#include <types.h>
    2424#include <cpu.h>
    25 #include <device.h>
     25#include <chdev.h>
    2626#include <driver.h>
    2727#include <cpu-io.h>
  • trunk/kernel/drivers/ibmpc/tty.c

    r1 r4  
    2424#include <system.h>
    2525#include <cpu.h>
    26 #include <device.h>
     26#include <chdev.h>
    2727#include <driver.h>
    2828#include <cpu-io.h>
  • trunk/kernel/drivers/soclib/drvdb.c

    r1 r4  
    2727#include <libk.h>
    2828#include <event.h>
    29 #include <device.h>
     29#include <chdev.h>
    3030#include <driver.h>
    3131#include <drvdb.h>
  • trunk/kernel/drivers/soclib/soclib_bdv.c

    r1 r4  
    2222 */
    2323
    24 #include <device.h>
     24#include <chdev.h>
    2525#include <dev_ioc.h>
    2626#include <soclib_bdv.h>
     
    2929
    3030
    31 /////////////////////////////////////
    32 void soclib_bdv_init( xptr_t dev_xp )
     31///////////////////////////////////////
     32void soclib_bdv_init( chdev_t * chdev )
    3333{
    34     // get IOC device descriptor cluster and local pointer
    35     cxy_t      dev_cxy  = GET_CXY( dev_xp );
    36     device_t * dev_ptr  = (device_t *)GET_PTR( dev_xp );
    37  
    3834    // 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;
    4036
    4137    // get hardware device cluster and local pointer
     
    4844
    4945    // 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;
    5248
    5349} // end soclib_bdv_init()
    5450
    5551
    56 //////////////////////////////////////////////////////////////////
    57 void __attribute__ ((noinline)) soclib_bdv_command( xptr_t th_xp )
     52//////////////////////////////////////////////////////////////
     53void __attribute__ ((noinline)) soclib_bdv_cmd( xptr_t th_xp )
    5854{
    5955    uint32_t   to_mem;       // command argument
     
    6864
    6965    // 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 ) );
    7571
    7672    // get IOC device cluster and local pointer
    7773    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 );
    7975
    8076    // get extended pointer on SOCLIB-BDV peripheral
     
    107103
    108104
    109 ////////////////////////////////////////////////////////////////
    110 void __attribute__ ((noinline)) soclib_bdv_isr( device_t * dev )
     105/////////////////////////////////////////////////////////////////
     106void __attribute__ ((noinline)) soclib_bdv_isr( chdev_t * chdev )
    111107{
    112108    // 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 );
    114110    xptr_t client_xp = XLIST_FIRST_ELEMENT( root , thread_t , wait_list );
    115111
    116112    // 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 );
    118114
    119115    // get client thread cluster and local pointer
     
    122118
    123119    // 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 );
    126122
    127123    // get BDV status register and acknowledge IRQ
     
    131127        if((status != BDV_READ_SUCCESS) && (status != BDV_WRITE_SUCCESS))
    132128    {
    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 );
    134130    }
    135131        else
    136132    {
    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 );
    138134    }
    139135
  • trunk/kernel/drivers/soclib/soclib_bdv.h

    r1 r4  
    2525#define _SOCLIB_BDV_H_
    2626
    27 #include <device.h>
     27#include <chdev.h>
    2828#include <hal_types.h>
    2929
     
    7575 * number of blocks, and initialises the "extension" field of the IOC device descriptor.
    7676 ********************************************************************************************
    77  * @ dev_xp     : extended pointer on the generic IOC device descriptor.
     77 * @ chdev     : local pointer on the generic IOC chdev descriptor.
    7878 *******************************************************************************************/
    79 extern void soclib_bdv_init( xptr_t dev_xp );
     79extern void soclib_bdv_init( chdev_t * chdev );
    8080
    8181/********************************************************************************************
     
    9090 * @ thread_xp  : extended pointer on the client thread.
    9191 *******************************************************************************************/
    92 extern void soclib_bdv_command( xptr_t thread_xp );
     92extern void soclib_bdv_cmd( xptr_t thread_xp );
    9393
    9494/********************************************************************************************
     
    9898 * can starts execution of a new command if the waiting queue is not emppty.
    9999 ********************************************************************************************
    100  * @ dev     : local pointer on the generic IOC device descriptor.
     100 * @ chdev     : local pointer on the generic IOC device descriptor.
    101101 *******************************************************************************************/
    102 extern void soclib_bdv_isr( device_t * dev );
     102extern void soclib_bdv_isr( chdev_t * chdev );
    103103
    104104
  • trunk/kernel/drivers/soclib/soclib_cma.c

    r1 r4  
    2222 */
    2323
    24 #include <device.h>
     24#include <chdev.h>
    2525#include <dev_nic.h>
    2626#include <soclib_nic.h>
  • trunk/kernel/drivers/soclib/soclib_dma.c

    r1 r4  
    11/*
    2  * soclib_dma.c - soclib DMA driver
     2 * soclib_dma.c - soclib Multi Channels DMA driver implementation
    33 *
    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
    67 *
    7  * This file is part of ALMOS-kernel.
     8 * This file is part of ALMOS-MKH.
    89 *
    9  * ALMOS-kernel is free software; you can redistribute it and/or modify it
     10 * ALMOS-MKH is free software; you can redistribute it and/or modify it
    1011 * under the terms of the GNU General Public License as published by
    1112 * the Free Software Foundation; version 2.0 of the License.
    1213 *
    13  * ALMOS-kernel is distributed in the hope that it will be useful, but
     14 * ALMOS-MKH is distributed in the hope that it will be useful, but
    1415 * WITHOUT ANY WARRANTY; without even the implied warranty of
    1516 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     
    1718 *
    1819 * 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,
    2021 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
    2122 */
    2223
    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>
    3027#include <thread.h>
    31 #include <task.h>
    32 #include <list.h>
    33 #include <event.h>
    3428#include <soclib_dma.h>
    35 #include <string.h>
    3629
    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///////////////////////////////////////
     31void 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 );
    4336
    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//////////////////////////////////////////////////////////////////
     43void __attribute__ ((noinline)) soclib_dma_cmd( xptr_t thread_xp )
    4544{
    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
    4949
    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/////////////////////////////////////////////////////////////////
     94void __attribute__ ((noinline)) soclib_dma_isr( chdev_t * chdev )
    5195{
    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 );
    5499
    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 );
    56102
    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 );
    62106
    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 );
    73110
    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);
    77113
    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 ) );   
    82116
    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 );
    89119
    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 );
    91123
    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 );
    95126
    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 );
    99129
    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()
    281131
    282132
    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;
    288133
    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         else
    305                 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_VFAT
    345                 "DMA%d"
    346 #else
    347                 "dma%d"
    348 #endif
    349                 ,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  
    11/*
    2  * soclib_dma.c - soclib DMA driver
     2 * soclib_dma.h - soclib Multi Channels DMA driver definition.
    33 *
    4  * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless
    5  * Copyright (c) 2011,2012 UPMC Sorbonne Universites
     4 * Author     Alain Greiner (2017)
    65 *
    7  * This file is part of ALMOS-kernel.
     6 * Copyright (c) UPMC Sorbonne Universites
    87 *
    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
    1011 * under the terms of the GNU General Public License as published by
    1112 * the Free Software Foundation; version 2.0 of the License.
    1213 *
    13  * ALMOS-kernel is distributed in the hope that it will be useful, but
     14 * ALMOS-MKH is distributed in the hope that it will be useful, but
    1415 * WITHOUT ANY WARRANTY; without even the implied warranty of
    1516 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     
    1718 *
    1819 * 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,
    2021 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
    2122 */
     
    2425#define _SOCLIB_DMA_H_
    2526
    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
     37enum 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 *******************************************************************************************/
     66extern 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 *******************************************************************************************/
     78extern 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 *******************************************************************************************/
     88extern void soclib_dma_isr( chdev_t * chdev );
     89
    2790
    2891#endif  /* _SOCLIB_DMA_H_ */
  • trunk/kernel/drivers/soclib/soclib_hba.c

    r1 r4  
    2424#include <printk.h>
    2525#include <hal_special.h>
    26 #include <device.h>
     26#include <chdev.h>
    2727#include <dev_ioc.h>
    2828#include <soclib_hba.h>
     
    5454spinlock_t         hba_lock;
    5555
    56 /////////////////////////////////////
    57 void soclib_hba_init( xptr_t dev_xp )
     56///////////////////////////////////////
     57void soclib_hba_init( chdev_t * chdev )
    5858{
    59     // get IOC device descriptor cluster and local pointer
    60     cxy_t      dev_cxy  = GET_CXY( dev_xp );
    61     device_t * dev_ptr  = (device_t *)GET_PTR( dev_xp );
    62  
    6359    // 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;
    6561
    6662    // get hardware device cluster and local pointer
     
    7369
    7470    // 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;
    7773
    7874        // reset SOCLIB_HBA driver global variables
     
    10298
    10399    // 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 ) );
    109105
    110106    // get IOC device cluster and local pointer
    111     cxy_t      dev_cxy = GET_CXY( dev_xp );
    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 );
    113109
    114110    // get extended pointer on SOCLIB-HBA peripheral
     
    218214
    219215
    220 ////////////////////////////////////////////////////////////////
    221 void __attribute__ ((noinline)) soclib_hba_isr( device_t * dev )
     216/////////////////////////////////////////////////////////////////
     217void __attribute__ ((noinline)) soclib_hba_isr( chdev_t * chdev )
    222218{
    223219    // 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 );
    225221    xptr_t client_xp = XLIST_FIRST_ELEMENT( root , thread_t , wait_list );
    226222
     
    230226
    231227    // 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 );
    234230
    235231    // get HBA_PXIS_REG and HBA_PXIS_REG current values
     
    253249            if( error && (iter == fault_id ) )
    254250            {
    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 );
    256252            }
    257253            else
    258254            {
    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 );
    260256            }
    261257
  • trunk/kernel/drivers/soclib/soclib_hba.h

    r1 r4  
    2525#define _SOCLIB_HBA_H_
    2626
    27 #include <device.h>
     27#include <chdev.h>
    2828#include <hal_types.h>
    2929
     
    129129 * number of blocks, and initialises the "extension" field of the IOC device descriptor.
    130130 ********************************************************************************************
    131  * @ dev_xp     : extended pointer on the generic IOC device descriptor.
     131 * @ chdev     : local pointer on the generic IOC chdev descriptor.
    132132 *******************************************************************************************/
    133 extern void soclib_hba_init( xptr_t dev_xp );
     133extern void soclib_hba_init( chdev_t * chdev );
    134134
    135135/********************************************************************************************
     
    153153 * all client thread that have an I/O operation completed.
    154154 ********************************************************************************************
    155  * @ dev     : local pointer on the generic IOC device descriptor.
     155 * @ chdev     : local pointer on the generic IOC device descriptor.
    156156 *******************************************************************************************/
    157 extern void soclib_hba_isr( device_t * dev );
     157extern void soclib_hba_isr( chdev_t * chdev );
    158158
    159159
  • trunk/kernel/drivers/soclib/soclib_iob.c

    r1 r4  
    2727#include <soclib_iob.h>
    2828
    29 /////////////////////////////////////
    30 void soclib_iob_init( xptr_t iox_xp )
     29///////////////////////////////////////
     30void soclib_iob_init( chdev_t * chdev )
    3131{
    32     // get IOX device cluster and local pointer
    33     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 segment
    37     xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iox_cxy , &iox_ptr->base ) );
    38 
    3932    // desactivate IOMMU
    40     hal_remote_sw( base_xp + (IOB_IOMMU_ACTIVE<<2) , 0 );
     33    hal_remote_sw( chdev->base + (IOB_IOMMU_ACTIVE<<2) , 0 );
    4134}
    4235
    4336////////////////////////////////////////////
    44 void soclib_iob_set_active( xptr_t   iox_xp,
     37void soclib_iob_set_active( xptr_t   iob_xp,
    4538                            uint32_t value )
    4639{
    4740    // 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 );
    5043
    5144    // get extended pointer on SOCLIB_IOB base_xp segment
    52     xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iox_cxy , &iox_ptr->base ) );
     45    xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) );
    5346
    5447    // set ACTIVE register
     
    5750
    5851//////////////////////////////////////////
    59 void soclib_iob_set_ptpr( xptr_t   iox_xp,
     52void soclib_iob_set_ptpr( xptr_t   iob_xp,
    6053                          uint32_t value )
    6154{
    6255    // 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 );
    6558
    6659    // get extended pointer on SOCLIB_IOB base_xp segment
    67     xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iox_cxy , &iox_ptr->base ) );
     60    xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) );
    6861
    6962    // set PTPR register
     
    7265
    7366///////////////////////////////////////////
    74 void soclib_iob_inval_page( xptr_t  iox_xp,
     67void soclib_iob_inval_page( xptr_t  iob_xp,
    7568                            vpn_t   vpn )
    7669{
    7770    // 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 );
    8073
    8174    // get extended pointer on SOCLIB_IOB base_xp segment
    82     xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iox_cxy , &iox_ptr->base ) );
     75    xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) );
    8376
    8477    // invalidate TLB entry
     
    8780
    8881//////////////////////////////////////////////
    89 uint32_t soclib_iob_get_bvar( xptr_t  iox_xp )
     82uint32_t soclib_iob_get_bvar( xptr_t  iob_xp )
    9083{
    9184    // 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 );
    9487
    9588    // get extended pointer on SOCLIB_IOB base_xp segment
    96     xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iox_cxy , &iox_ptr->base ) );
     89    xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) );
    9790
    9891    // get BVAR register
     
    10194
    10295///////////////////////////////////////////////
    103 uint32_t soclib_iob_get_srcid( xptr_t  iox_xp )
     96uint32_t soclib_iob_get_srcid( xptr_t  iob_xp )
    10497{
    10598    // 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 );
    108101
    109102    // get extended pointer on SOCLIB_IOB base_xp segment
    110     xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iox_cxy , &iox_ptr->base ) );
     103    xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) );
    111104
    112105    // get BVAR register
     
    115108
    116109///////////////////////////////////////////////
    117 uint32_t soclib_iob_get_error( xptr_t  iox_xp )
     110uint32_t soclib_iob_get_error( xptr_t  iob_xp )
    118111{
    119112    // 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 );
    122115
    123116    // get extended pointer on SOCLIB_IOB base_xp segment
    124     xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iox_cxy , &iox_ptr->base ) );
     117    xptr_t base_xp = (xptr_t)hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) );
    125118
    126119    // get BVAR register
  • trunk/kernel/drivers/soclib/soclib_iob.h

    r1 r4  
    2626
    2727#include <hal_types.h>
    28 #include <device.h>
     28#include <chdev.h>
    2929
    3030/******************************************************************************************
     
    6161 * This function initializes the SOCLIB IOB component:
    6262 ******************************************************************************************
    63  * @ iob_xp     : extended pointer on the remote IOX device descriptor.
     63 * @ chdev   : local pointer on IOB chdev descriptor.
    6464 *****************************************************************************************/
    65 void soclib_iob_init( xptr_t iox_xp );
     65void soclib_iob_init( chdev_t * chdev );
    6666
    6767/******************************************************************************************
  • trunk/kernel/drivers/soclib/soclib_memc.c

    r1 r4  
    2222
    2323#include <bits.h>
    24 #include <device.h>
     24#include <chdev.h>
    2525#include <driver.h>
    2626#include <drvdb.h>
  • trunk/kernel/drivers/soclib/soclib_mmc.c

    r1 r4  
    2424
    2525#include <hal_types.h>
    26 #include <device.h>
     26#include <chdev.h>
    2727#include <dev_mmc.h>
    2828#include <soclib_mmc.h>
     
    3232
    3333
    34 /////////////////////////////////////
    35 void soclib_mmc_init( xptr_t dev_xp )
     34///////////////////////////////////////
     35void soclib_mmc_init( chdev_t * chdev )
    3636{
    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 );
    4539
    4640    // enable MMC IRQ
     
    4943
    5044
    51 //////////////////////////////////////////////////////////////////
    52 void __attribute__ ((noinline)) soclib_mmc_command( xptr_t th_xp )
     45//////////////////////////////////////////////////////////////
     46void __attribute__ ((noinline)) soclib_mmc_cmd( xptr_t th_xp )
    5347{
    5448    xptr_t     dev_xp;       // extended pointer on MMC device
     
    6458
    6559    // 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 ) );
    6862
    6963    // get MMC device cluster and local pointer
    70     cxy_t      dev_cxy = GET_CXY( dev_xp );
    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 );
    7266
    7367    // get extended pointer on SOCLIB-MMC peripheral
     
    8175    {
    8276        // 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 ) );
    8478
    8579        // split buffer paddr in two 32 bits words
     
    8882
    8983        // 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 ) );
    9185
    9286        // get command type
     
    10296    {
    10397        // 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 ) );
    106100
    107101        // move register to/from local buffer
     
    119113
    120114////////////////////////////////////////////////////////////////
    121 void __attribute__ ((noinline)) soclib_mmc_isr( device_t * dev )
     115void __attribute__ ((noinline)) soclib_mmc_isr( chdev_t * chdev )
    122116{
    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 );
    128119
    129120    // get faulty ADDRESS and SRCID from MMC registers
  • trunk/kernel/drivers/soclib/soclib_mmc.h

    r1 r4  
    2525#define _SOCLIB_MMC_H_
    2626
    27 #include <device.h>
     27#include <chdev.h>
    2828#include <dev_mmc.h>
    2929#include <hal_types.h>
     
    158158/********************************************************************************************
    159159 * This function initializes the SOCLIB_MMC peripheral hardware registers related
    160  * to error signaling to enable the MMC peripheral IRQ.
     160 * to error signaling. It enables the MMC peripheral IRQ.
    161161 ********************************************************************************************
    162  * @ dev_xp     : extended pointer on the generic MMC device descriptor.
     162 * @ chdev      : local pointer on the MMC chdev descriptor.
    163163 *******************************************************************************************/
    164 extern void soclib_mmc_init( xptr_t dev_xp );
     164extern void soclib_mmc_init( chdev_t * chdev );
    165165
    166166/********************************************************************************************
     
    171171 * @ thread_xp  : extended pointer on the client thread.
    172172 *******************************************************************************************/
    173 extern void soclib_mmc_command( xptr_t thread_xp );
     173extern void soclib_mmc_cmd( xptr_t thread_xp );
    174174
    175175/********************************************************************************************
     
    178178 * and the associated SRCID, and acknowledges the IRQ.
    179179 ********************************************************************************************
    180  * @ dev     : local pointer on the generic MMC device descriptor.
     180 * @ chdev     : local pointer on the MMC chdev descriptor.
    181181 *******************************************************************************************/
    182 extern void soclib_mmc_isr( device_t * dev );
     182extern void soclib_mmc_isr( chdev_t * chdev );
    183183
    184184
  • trunk/kernel/drivers/soclib/soclib_nic.c

    r1 r4  
    2525#include <hal_remote.h>
    2626#include <hal_special.h>
    27 #include <device.h>
     27#include <chdev.h>
    2828#include <dev_nic.h>
    2929#include <spinlock.h>
     
    3434#include <soclib_nic.h>
    3535
    36 
    37 /////////////////////////////////////
    38 void soclib_nic_init( xptr_t dev_xp )
     36///////////////////////////////////////
     37void soclib_nic_init( chdev_t * chdev )
    3938{
    4039    uint32_t    i;
    4140    kmem_req_t  req;
    4241   
    43     // get NIC device descriptor cluster and local pointer
    44     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 address
    48         xptr_t     base = hal_remote_lwd( XPTR( dev_cxy , &dev_ptr->base ) );
    49 
    5042    // 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 );
    5345
    5446    // initialize Soclib NIC global registers
     
    5749
    5850    // 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" );
    6453
    6554    req.type   = KMEM_PAGE;
     
    6958    nic_chbuf_t * chbuf = (nic_chbuf_t *)kmem_alloc( &req );
    7059
    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" );
    7562
    7663    // initialise chbuf state
     
    8168    // allocate containers (one page per container)
    8269    // 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" );
    8772
    8873    for( i = 0 ; i < CONFIG_NIC_CHBUF_DEPTH ; i++ )
     
    9075        uint32_t * container = (uint32_t *)kmem_alloc( &req );   
    9176
    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" );
    9679       
    9780        chbuf->cont[i] = container;
    9881        chbuf->full[i] = (paddr_t)XPTR( local_cxy , container );
    9982    }
    100 
    10183} // end soclib_nic_init()
    10284
     
    121103
    122104    // 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;
    127109
    128110    // 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 );
    130112
    131113    // get chbuf descriptor pointer
     
    226208            {
    227209                // return chbuf writable
    228                 thread_ptr->dev.nic.status = true;
     210                thread_ptr->command.nic.status = true;
    229211            }
    230212            else                    // current container not writable
     
    244226                     
    245227                    // return chbuf writable
    246                     thread_ptr->dev.nic.status = true;
     228                    thread_ptr->command.nic.status = true;
    247229                }
    248230                else                            // next container full     
    249231                {
    250232                    // return chbuf non writable
    251                     thread_ptr->dev.nic.status = false;
     233                    thread_ptr->command.nic.status = false;
    252234                }
    253235            }
     
    270252            {
    271253                // return chbuf readable     
    272                 thread_ptr->dev.nic.status = true;
     254                thread_ptr->command.nic.status = true;
    273255            }
    274256            else                        // current container non readable
     
    288270                     
    289271                    // return chbuf readable
    290                     thread_ptr->dev.nic.status = true;
     272                    thread_ptr->command.nic.status = true;
    291273                }
    292274                else                            // next container empty   
    293275                {
    294276                    // return chbuf non readable
    295                     thread_ptr->dev.nic.status = false;
     277                    thread_ptr->command.nic.status = false;
    296278                }
    297279            }
     
    303285
    304286
    305 ////////////////////////////////////////////////////////////////
    306 void __attribute__ ((noinline)) soclib_nic_isr( device_t * dev )
     287/////////////////////////////////////////////////////////////////
     288void __attribute__ ((noinline)) soclib_nic_isr( chdev_t * chdev )
    307289{
    308290    // 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;
    312294
    313295    // get NIC peripheral cluster and local pointer
     
    326308   
    327309    // unblock server thread
    328     thread_t * server = dev->server;
     310    thread_t * server = chdev->server;
    329311    thread_unblock( XPTR( local_cxy , server ) , THREAD_BLOCKED_IO );
    330312
  • trunk/kernel/drivers/soclib/soclib_nic.h

    r1 r4  
    2525#define _SOCLIB_NIC_H_
    2626
    27 #include <device.h>
     27#include <chdev.h>
    2828#include <hal_types.h>
    2929
     
    152152 * or a TX empty container, and route the WTI IRQ to the core running the server thread.
    153153 ********************************************************************************************
    154  * @ dev_xp  : extended pointer on the generic NIC device descriptor.
    155  *******************************************************************************************/
    156 extern void soclib_nic_init( xptr_t dev_xp );
     154 * @ chdev  :  pointer on NIC chdev descriptor.
     155 *******************************************************************************************/
     156extern void soclib_nic_init( chdev_t * chdev );
    157157
    158158/********************************************************************************************
     
    196196 * it goes to kernel panic.
    197197 ********************************************************************************************
    198  * @ dev     : local pointer on the generic IOC device descriptor.
    199  *******************************************************************************************/
    200 extern void soclib_nic_isr( device_t * dev );
     198 * @ chdev     : local pointer on NIC chdev descriptor.
     199 *******************************************************************************************/
     200extern void soclib_nic_isr( chdev_t * chdev );
    201201
    202202
  • trunk/kernel/drivers/soclib/soclib_pic.c

    r1 r4  
    2323
    2424#include <hal_types.h>
    25 #include <device.h>
     25#include <chdev.h>
    2626#include <soclib_pic.h>
    2727#include <soclib_xcu.h>
     
    3131
    3232
    33 //////////////////////////////////////
    34 void soclib_pic_init( xptr_t  dev_xp )
     33////////////////////////////////////////
     34void soclib_pic_init( chdev_t  * chdev )
    3535{
    36     // get PIC device descriptor cluster and local pointer
    37     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 descriptor
    41     xptr_t seg_xp = (xptr_t)hal_remote_lwd( XPTR( dev_cxy , &dev_ptr->base ) );
    42  
    4336    // 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 );
    4639    uint32_t   i;
    4740
     
    5952{
    6053    // get PIC device descriptor cluster and local pointer
    61     cxy_t      dev_cxy = GET_CXY( dev_xp );
    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 );
    6356 
    6457    // get extended pointer on PIC segment base from PIC device descriptor
     
    8578{
    8679    // get PIC device descriptor cluster and local pointer
    87     cxy_t      dev_cxy = GET_CXY( dev_xp );
    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 );
    8982 
    9083    // get extended pointer on PIC segment base from PIC device descriptor
     
    10598{
    10699    // get PIC device descriptor cluster and local pointer
    107     cxy_t      dev_cxy = GET_CXY( dev_xp );
    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 );
    109102 
    110103    // get extended pointer on PIC segment base from PIC device descriptor
  • trunk/kernel/drivers/soclib/soclib_pic.h

    r1 r4  
    3838
    3939/******************************************************************************************
    40  * This blocking function desactivates all input IRQs in a remote PIC 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.
    4242 ******************************************************************************************
    43  * @ dev_xp    : extended pointer on the PIC device descriptor.
     43 * @ chdev    : pointer on PIC chdev descriptor.
    4444 *****************************************************************************************/
    45 void   soclib_pic_init( xptr_t dev_xp );
     45void   soclib_pic_init( chdev_t * chdev );
    4646
    4747/******************************************************************************************
  • trunk/kernel/drivers/soclib/soclib_tty.c

    r1 r4  
    2323
    2424#include <dev_txt.h>
    25 #include <device.h>
     25#include <chdev.h>
    2626#include <soclib_tty.h>
    2727#include <remote_spinlock.h>
     
    2929#include <hal_special.h>
    3030
    31 /////////////////////////////////////
    32 void soclib_tty_init( xptr_t dev_xp )
     31///////////////////////////////////////
     32void soclib_tty_init( chdev_t * chdev )
    3333{
    34     // get TXT device cluster and local pointer
    35     cxy_t      dev_cxy = GET_CXY( dev_xp );
    36     device_t * dev_ptr = (device_t *)GET_PTR( dev_xp );
    37 
    3834    // 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;
    4036
    4137    // get SOCLIB_TTY device cluster and local pointer
     
    4642    hal_remote_sw( XPTR( tty_cxy , tty_ptr + TTY_CONFIG_REG ) , 0 );
    4743
    48 }  // end soclib_tty_init()
    49 
    50 //////////////////////////////////////////////////////////////////
    51 void __attribute__ ((noinline)) soclib_tty_command( xptr_t th_xp )
     44}  // soclib_tty_init()
     45
     46//////////////////////////////////////////////////////////////
     47void __attribute__ ((noinline)) soclib_tty_cmd( xptr_t th_xp )
    5248{
    5349    // get client thread cluster and local pointer
     
    5652
    5753    // 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 ) );
    6056   
    6157    // get TXT device cluster and local pointer
    62     cxy_t      dev_cxy = GET_CXY( dev_xp );
    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 );
    6460
    6561    // get extended pointer on SOCLIB_TTY base segment
     
    7066    uint32_t * tty_ptr = (uint32_t *)GET_PTR( tty_xp );
    7167
     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
    7272    if( type == TXT_READ )              // descheduling strategy for calling thead
    7373    {
    7474        // 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 );
    7676        uint32_t old = hal_remote_lw( config_xp );
    7777        uint32_t new = old | TTY_CONFIG_RX_ENABLE;
     
    8585    {
    8686        // 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 );
    8888        uint32_t old = hal_remote_lw( config_xp );
    8989        uint32_t new = old | TTY_CONFIG_TX_ENABLE;
     
    101101
    102102        // 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 ) );
    105105
    106106        // loop on characters
     
    110110            {
    111111                // 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 ) );
    113113                empty  = ( (status & TTY_STATUS_TX_FULL) == 0 );
    114114
     
    119119
    120120                    // 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 );
    122122                }
    123123            }
     
    125125        }
    126126    }
    127 }  // end soclib_tty_command()
    128 
    129 
    130 ////////////////////////////////////////////////////////////////
    131 void __attribute__ ((noinline)) soclib_tty_isr( device_t * dev )
     127}  // soclib_tty_command()
     128
     129
     130/////////////////////////////////////////////////////////////////
     131void __attribute__ ((noinline)) soclib_tty_isr( chdev_t * chdev )
    132132{
    133133    uint32_t   type;         // command type
     
    138138    uint32_t   i;
    139139
    140 
    141140    // 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 );
    143142    xptr_t client_xp = XLIST_FIRST_ELEMENT( root , thread_t , wait_list );
    144143
     
    148147
    149148    // 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 ) );
    153152
    154153    // 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;
    157159
    158160    if( type == TXT_READ )              // read one single character
    159161    {
    160162        // 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 ) );
    162164
    163165        if( status & TTY_STATUS_RX_FULL )   // TTY_RX full => transfer one byte
    164166        {
    165167            // 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 ) );
    167169
    168170            // write it to command buffer
     
    174176                if( (byte == '\b') || (byte == 0x7F) )
    175177                        {
    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' );
    179181                        }
    180182                else
    181183                {
    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 );
    183185                        }
    184186            }
     
    195197        {
    196198            // 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 ) );
    198200
    199201            if( (status & TTY_STATUS_TX_FULL) == 0 ) // TTY_TX empty => transfer one byte
     
    203205
    204206                // 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 );
    206208            }
    207209            else         // TTY_TX full => update command arguments and exit ISR for retry
    208210            {
    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 );
    212213                return;
    213214            }
     
    218219
    219220    // 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 );
    221222
    222223    // 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 );
    224225
    225226    // 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 );
    227228
    228229    // unblock client thread
    229230    thread_unblock( client_xp , THREAD_BLOCKED_IO );
    230231
    231 }  // end soclib_tty_isr()
    232 
    233 
     232}  // soclib_tty_isr()
     233
     234
  • trunk/kernel/drivers/soclib/soclib_tty.h

    r1 r4  
    2323
    2424#include <dev_txt.h>
    25 #include <device.h>
     25#include <chdev.h>
    2626#include <spinlock.h>
    2727
     
    6060
    6161/****************************************************************************************
    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.
    6363 * Thes IRQs are unmasked by the soclib_tty_cmd() function.
    6464 ****************************************************************************************
    65  * @ dev     : extended pointer on the generic TXT device descriptor.
     65 * @ chdev     : pointer on the TXT chdev descriptor.
    6666 ***************************************************************************************/
    67 extern void soclib_tty_init( xptr_t dev_xp );
     67void soclib_tty_init( chdev_t * chdev );
    6868
    6969/****************************************************************************************
     
    7777 *   a busy waiting policy if required.
    7878 ****************************************************************************************
    79  * @ xp_thread : extended pointer on client thread descriptor.
     79 * @ thread_xp : extended pointer on client thread descriptor.
    8080 ***************************************************************************************/
    81 extern void soclib_tty_command( xptr_t thread_xp );
     81void soclib_tty_cmd( xptr_t thread_xp );
    8282
    8383/****************************************************************************************
    8484 * 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 device queue:
     85 * It get the command arguments from the first client thread in the TXT chdev queue:
    8686 * - if TXT_READ, it transfer one byte from the TTY_READ_REG to the command buffer.
    8787 *   It simply returns for retry if TTY_READ_REG is empty.
     
    9292 * the server thread, and unblock the client thread.
    9393 ****************************************************************************************
    94  * @ dev     : local pointer on generic TXT device descriptor.
     94 * @ chdev     : local pointer on TXT chdev descriptor.
    9595 ***************************************************************************************/
    96 extern void soclib_tty_isr( device_t * dev );
     96void soclib_tty_isr( chdev_t * chdev );
    9797
  • trunk/kernel/drivers/soclib/soclib_xcu.c

    r1 r4  
    2525#include <hal_types.h>
    2626#include <core.h>
    27 #include <device.h>
     27#include <chdev.h>
    2828
    2929
    3030
    31 /////////////////////////////////////
    32 void soclib_xcu_init( device_t * icu,
    33                       lid_t      lid )
     31////////////////////////////////////
     32void soclib_xcu_init( chdev_t * icu,
     33                      lid_t     lid )
    3434{
    3535    // get local ICU segment base address
     
    4242}
    4343
    44 ///////////////////////////////////////////////
    45 void soclib_xcu_disable_irq( xptr_t     icu_xp,
     44////////////////////////////////////////////
     45void soclib_xcu_disable_irq( chdev_t  * icu,
    4646                             uint32_t   mask,
    4747                             uint32_t   type,
    4848                             lid_t      lid )
    4949{
    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 );
    5352
    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;
    6557}
    6658
    67 //////////////////////////////////////////////
    68 void soclib_xcu_enable_irq( xptr_t     icu_xp,
     59///////////////////////////////////////////
     60void soclib_xcu_enable_irq( chdev_t  * icu,
    6961                            uint32_t   mask,
    7062                            uint32_t   type,
    7163                            lid_t      lid )
    7264{
    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 );
    7667
    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;
    8872}
    8973
    90 ///////////////////////////////////////////
    91 void soclib_xcu_set_period( device_t * icu,
    92                             uint32_t   index,
    93                             uint32_t   period )
     74//////////////////////////////////////////
     75void soclib_xcu_set_period( chdev_t * icu,
     76                            uint32_t  index,
     77                            uint32_t  period )
    9478{
    9579    // get local ICU segment base address
     
    10084}
    10185
    102 //////////////////////////////////////////////
    103 uint32_t soclib_xcu_ack_timer( device_t * icu,
    104                                uint32_t   index )
     86/////////////////////////////////////////////
     87uint32_t soclib_xcu_ack_timer( chdev_t * icu,
     88                               uint32_t  index )
    10589{
    10690    // get local ICU segment base address
     
    11195}
    11296
    113 ///////////////////////////////////////////////
    114 void soclib_xcu_get_status( device_t * icu,
     97///////////////////////////////////////////
     98void soclib_xcu_get_status( chdev_t * icu,
    11599                            lid_t      lid,
    116100                            uint32_t * hwi_status,
     
    130114
    131115/////////////////////////////////////////
    132 void soclib_xcu_send_ipi( xptr_t  xp_icu,
     116void soclib_xcu_send_ipi( xptr_t  icu_xp,
    133117                          lid_t   lid )
    134118{
    135119    // 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 );
    138122
    139123    // get extended pointer on target ICU segment base
     
    148132
    149133//////////////////////////////////////////////
    150 uint32_t * soclib_xcu_wti_ptr( device_t * icu,
     134uint32_t * soclib_xcu_wti_ptr( chdev_t * icu,
    151135                               uint32_t   index )
    152136{
  • trunk/kernel/drivers/soclib/soclib_xcu.h

    r1 r4  
    2626
    2727#include <hal_types.h>
    28 #include <device.h>
     28#include <chdev.h>
    2929
    3030/******************************************************************************************
     
    5252
    5353/******************************************************************************************
    54  * This function initialises the local XCU device masks registers for a given
     54 * This function initialises the local XCU masks registers for a given
    5555 * core identified by its local index.
    5656 ******************************************************************************************
    57  * @ icu       : pointer on the local ICU device descriptor
    58  * @ lid       : core local index
     57 * @ icu       : pointer on the local ICU chdev descriptor.
     58 * @ lid       : core local index.
    5959 *****************************************************************************************/
    60 void soclib_xcu_init( device_t * icu,
    61                       lid_t      lid );
     60void soclib_xcu_init( chdev_t * icu,
     61                      lid_t     lid );
    6262
    6363/******************************************************************************************
    64  * This function set bits in a remote XCU 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.
    6666 * Only the bits with "1" value in mask argument are set, other bits are not modified.
    6767 * All input IRQs of requested types corresponding to "1" bits in mask are enabled.
    6868 ******************************************************************************************
    69  * @ icu_xp     : extended pointer on the remote XCU device descriptor.
    70  * @ mask       : mask value
    71  * @ type       : HWI_TYPE / PTI_TYPE / WTI_TYPE
    72  * @ lid        : local core index == output IRQ index
     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
    7373 *****************************************************************************************/
    74 void  soclib_xcu_enable_irq( xptr_t     icu_xp,
     74void  soclib_xcu_enable_irq( chdev_t  * icu,
    7575                             uint32_t   mask,
    7676                             uint32_t   type,
     
    7878
    7979/******************************************************************************************
    80  * This function clear bits in a remote XCU 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.
    8282 * Only the bits with "1" value in mask argument are cleared, other bits are not modified.
    8383 * All input IRQs of requested types corresponding to "1" bits in mask are disabled.
    8484 ******************************************************************************************
    85  * @ icu_xp     : extended pointer on the remote XCU device descriptor.
    86  * @ mask       : mask value
    87  * @ type       : HWI_TYPE / PTI_TYPE / WTI_TYPE
    88  * @ lid        : local core index == output IRQ index
     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
    8989 *****************************************************************************************/
    90 void  soclib_xcu_disable_irq( xptr_t     icu_xp,
     90void  soclib_xcu_disable_irq( chdev_t  * icu,
    9191                              uint32_t   mask,
    9292                              uint32_t   type,
     
    9696 * This function set the period value for a local XCU timer.
    9797 ******************************************************************************************
    98  * @ icu        : pointer on the local ICU device descriptor
     98 * @ icu        : pointer on the local XCU chdev descriptor
    9999 * @ index      : timer index = PTI index
    100100 * @ period     : Value to be written
    101101 *****************************************************************************************/
    102 void  soclib_xcu_set_period( device_t * icu,
     102void  soclib_xcu_set_period( chdev_t * icu,
    103103                             uint32_t   index,
    104104                             uint32_t   period );
     
    107107 * This function acknowledge a PTI IRQ for a local XCU timer.
    108108 ******************************************************************************************
    109  * @ icu        : pointer on the local ICU device descriptor
     109 * @ icu        : pointer on the local XCU chdev descriptor
    110110 * @ index      : timer index = PTI index
    111111 * @ the returned value in not significant, but acknowledge requires a read.
    112112 *****************************************************************************************/
    113 uint32_t soclib_xcu_ack_timer( device_t * icu,
     113uint32_t soclib_xcu_ack_timer( chdev_t * icu,
    114114                               uint32_t   index );
    115115
     
    118118 * If no active interrupt => status == 0 / else => status = index + 1
    119119 ******************************************************************************************
    120  * @ icu        : pointer on the local ICU device descriptor.
     120 * @ icu        : pointer on the local XCU chdev descriptor
    121121 * @ lid        : core local index.
    122122 * @ hwi_status : buffer for returned HWI status
     
    124124 * @ pti_status : buffer for returned PTI status
    125125 *****************************************************************************************/
    126 void  soclib_xcu_get_status( device_t * icu,
     126void  soclib_xcu_get_status( chdev_t * icu,
    127127                             lid_t      lid,
    128128                             uint32_t * hwi_status,
     
    144144 * This function does not access the SOCLIB_XCU hardware device.
    145145 ******************************************************************************************
    146  * @ icu     : pointer on the local ICU device descriptor.
     146 * @ icu     : pointer on the local XCU chdev descriptor
    147147 * @ index   : WTI mailbox index.
    148148 *****************************************************************************************/
    149 uint32_t * soclib_xcu_wti_ptr( device_t * icu,
     149uint32_t * soclib_xcu_wti_ptr( chdev_t * icu,
    150150                               uint32_t   index );
    151151
Note: See TracChangeset for help on using the changeset viewer.