Changeset 437 for trunk/kernel/devices


Ignore:
Timestamp:
Mar 28, 2018, 2:40:29 PM (7 years ago)
Author:
alain
Message:

Fix various bugs

Location:
trunk/kernel/devices
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/devices/dev_dma.c

    r408 r437  
    22 * dev_dma.c - DMA (Interrupt Controler Unit) generic device API implementation.
    33 *
    4  * Authors   Alain Greiner  (2017)
     4 * Authors   Alain Greiner  (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    9090    thread_t * this = CURRENT_THREAD;
    9191
    92     dma_dmsg("\n[DBG] %s : enters for thread %x / dst = %l /src = %l / size = %x\n",
    93               __FUNCTION__ , this->trdid , dst_xp , src_xp , size );
     92#if CONGIG_DEBUG_DEV_DMA
     93uint32_t cycle = (uint32_t)hal_get_cycles();
     94if( CONGIG_DEBUG_DEV_DMA < cycle )
     95printk("\n[DBG] %s : thread %x enters / dst %l / src %l / size = %x\n",
     96__FUNCTION__ , this, dst_xp, src_xp, size );
     97#endif
    9498
    9599    // select DMA channel corresponding to core lid
     
    112116    chdev_register_command( dev_xp );
    113117
    114     dma_dmsg("\n[DBG] %s : completes for thread %x / error = %d\n",
    115              __FUNCTION__ ,  this->trdid , this->dma_cmd.error );
     118#if CONGIG_DEBUG_DEV_DMA
     119cycle = (uint32_t)hal_get_cycles();
     120if( CONGIG_DEBUG_DEV_DMA < cycle )
     121printk("\n[DBG] %s : thread %x exit / dst %l / src %l / size = %x\n",
     122__FUNCTION__ , this, dst_xp, src_xp, size );
     123#endif
    116124
    117125    // return I/O operation status from calling thread descriptor
  • trunk/kernel/devices/dev_dma.h

    r14 r437  
    22 * dev_dma.h - DMA (Direct Memory Access) generic device API definition.
    33 *
    4  * Authors   Alain Greiner  (2017)
     4 * Authors   Alain Greiner  (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
  • trunk/kernel/devices/dev_fbf.c

    r422 r437  
    22 * dev_fbf.c - FBF (Block Device Controler) generic device API implementation.
    33 *
    4  * Author  Alain Greiner    (2016)
     4 * Author  Alain Greiner    (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    137137    error = vmm_v2p_translate( CONFIG_KERNEL_IDENTITY_MAP , buffer , &buf_paddr );
    138138 
    139     if( error )
    140     {
    141         printk("\n[ERROR] in %s : cannot translate vaddr = %p in process %x\n",
    142                __FUNCTION__ , buffer , this->process->pid );
    143         return EINVAL;
    144     }
    145 
    146     fbf_dmsg("\n[DBG] %s : thread %x in process %x / vaddr = %p / paddr = %l\n",
    147              __FUNCTION__ , this->trdid , this->process->pid , buffer , buf_paddr );
     139    // check buffer is mapped
     140    assert( (error == 0) , __FUNCTION__ ,
     141    "cannot translate vaddr = %p in process %x\n", buffer, this->process->pid );
    148142
    149143    // get extended pointer on FBF chdev descriptor
     
    162156
    163157    // check offset and length versus FBF size
    164     if( (offset + length) > (width * height) )
    165     {
    166         printk("\n[ERROR] in %s : offset = %d / length = %d / width = %d / height = %d\n",
    167                __FUNCTION__ , offset , length , width , height );
    168         return EINVAL;
    169     }
     158    assert( ((offset + length) <= (width * height)) , __FUNCTION__ ,
     159    "offset %d / length %d / width %d / height %d\n", offset, length, width, height );
    170160
    171161    // compute extended pointers on frame buffer and memory buffer
     
    186176                      uint32_t       offset )
    187177{
     178
     179#if CONFIG_DEBUG_DEV_FBF_RX
     180uint32_t cycle = (uint32_t)hal_get_cycle();
     181if( CONFIG_DEBUG_DEV_FBF_RX < cycle )
     182printk("\n[DBG] %s : thread %x enter / process %x / vaddr %x / size %x\n",
     183__FUNCTION__ , this, this->process->pid , buffer , buf_paddr );
     184#endif
     185
    188186    return dev_fbf_access( false , buffer , length , offset );
     187
     188#if CONFIG_DEBUG_DEV_FBF_RX
     189cycle = (uint32_t)hal_get_cycle();
     190if( CONFIG_DEBUG_DEV_FBF_RX < cycle )
     191printk("\n[DBG] %s : thread %x exit / process %x / vaddr %x / size %x\n",
     192__FUNCTION__ , this, this->process->pid , buffer , buf_paddr );
     193#endif
     194
    189195
    190196
     
    194200                       uint32_t       offset )
    195201{
     202
     203#if CONFIG_DEBUG_DEV_FBF_TX
     204uint32_t cycle = (uint32_t)hal_get_cycle();
     205if( CONFIG_DEBUG_DEV_FBF_TX < cycle )
     206printk("\n[DBG] %s : thread %x enter / process %x / vaddr %x / size %x\n",
     207__FUNCTION__ , this, this->process->pid , buffer , buf_paddr );
     208#endif
     209
    196210    return dev_fbf_access( true , buffer , length , offset );
     211
     212#if CONFIG_DEBUG_DEV_FBF_RX
     213cycle = (uint32_t)hal_get_cycle();
     214if( CONFIG_DEBUG_DEV_FBF_RX < cycle )
     215printk("\n[DBG] %s : thread %x exit / process %x / vaddr %x / size %x\n",
     216__FUNCTION__ , this, this->process->pid , buffer , buf_paddr );
     217#endif
     218
    197219}
  • trunk/kernel/devices/dev_ioc.c

    r408 r437  
    22 * dev_ioc.c - IOC (Block Device Controler) generic device API implementation.
    33 *
    4  * Author  Alain Greiner    (2016)
     4 * Author  Alain Greiner    (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    101101    thread_t * this = CURRENT_THREAD;              // pointer on client thread
    102102
    103     ioc_dmsg("\n[DBG] %s : thread %x in process %x"
    104              " for lba = %x / buffer = %x / at cycle %d\n",
    105              __FUNCTION__ , this->trdid , this->process->pid ,
    106              lba , (intptr_t)buffer , hal_get_cycles() );
    107 
    108103    // software L2/L3 cache coherence for memory buffer
    109104    if( chdev_dir.iob )
     
    130125    chdev_register_command( dev_xp );
    131126
    132     ioc_dmsg("\n[DBG] in %s : thread %x in process %x"
    133              " completes / error = %d / at cycle %d\n",
    134              __FUNCTION__ , this->trdid , this->process->pid ,
    135              this->ioc_cmd.error , hal_get_cycles() );
    136 
    137127    // return I/O operation status
    138128    return this->ioc_cmd.error;
     
    145135                      uint32_t       count )
    146136{
     137
     138#if CONFIG_DEBUG_DEV_IOC_RX
     139uint32_t cycle = (uint32_t)hal_get_cycles();
     140if( CONFIG_DEBUG_DEV_IOC_RX < cycle )
     141printk("\n[DBG] %s : thread %x enters / lba  %x / buffer %x / cycle %d\n",
     142__FUNCTION__ , this, lba, buffer, cycle );
     143#endif
     144
    147145    return dev_ioc_access( IOC_READ , buffer , lba , count );
     146
     147#if CONFIG_DEBUG_DEV_IOC_RX
     148cycle = (uint32_t)hal_get_cycles();
     149if( CONFIG_DEBUG_DEV_IOC_RX < cycle )
     150printk("\n[DBG] %s : thread %x exit / lba  %x / buffer %x / cycle %d\n",
     151__FUNCTION__ , this, lba, buffer, cycle );
     152#endif
     153
    148154}
    149155
     
    153159                       uint32_t      count )
    154160{
     161
     162#if CONFIG_DEBUG_DEV_IOC_TX
     163uint32_t cycle = (uint32_t)hal_get_cycles();
     164if( CONFIG_DEBUG_DEV_IOC_TX < cycle )
     165printk("\n[DBG] %s : thread %x enters / lba  %x / buffer %x / cycle %d\n",
     166__FUNCTION__ , this, lba, buffer, cycle );
     167#endif
     168
    155169    return dev_ioc_access( IOC_WRITE , buffer , lba , count );
     170
     171#if CONFIG_DEBUG_DEV_IOC_TX
     172cycle = (uint32_t)hal_get_cycles();
     173if( CONFIG_DEBUG_DEV_IOC_TX < cycle )
     174printk("\n[DBG] %s : thread %x exit / lba  %x / buffer %x / cycle %d\n",
     175__FUNCTION__ , this, lba, buffer, cycle );
     176#endif
     177
    156178}
    157179
     
    164186    thread_t * this = CURRENT_THREAD;
    165187
    166     ioc_dmsg("\n[DBG] %s : core[%x,%d] enter for %d blocks / lba = %x / cycle %d\n",
    167     __FUNCTION__ , local_cxy , this->core->lid , count , lba , hal_time_stamp() );
     188#if CONFIG_DEBUG_DEV_IOC_RX
     189uint32_t cycle = (uint32_t)hal_get_cycles();
     190if( CONFIG_DEBUG_DEV_IOC_RX < cycle )
     191printk("\n[DBG] %s : thread %x enters / lba  %x / buffer %x / cycle %d\n",
     192__FUNCTION__ , this, lba, buffer, cycle );
     193#endif
    168194
    169195    // software L2/L3 cache coherence for memory buffer
     
    201227    dev_pic_enable_irq( lid , ioc_xp );
    202228
    203     ioc_dmsg("\n[DBG] %s : core[%x,%d] exit / error = %d / cycle %d\n",
    204     __FUNCTION__ , local_cxy , this->core->lid , this->ioc_cmd.error , hal_time_stamp() );
     229#if CONFIG_DEBUG_DEV_IOC_RX
     230cycle = (uint32_t)hal_get_cycles();
     231if( CONFIG_DEBUG_DEV_IOC_RX < cycle )
     232printk("\n[DBG] %s : thread %x exit / lba  %x / buffer %x / cycle %d\n",
     233__FUNCTION__ , this, lba, buffer, cycle );
     234#endif
    205235
    206236    // return I/O operation status from calling thread descriptor
  • trunk/kernel/devices/dev_ioc.h

    r246 r437  
    22 * dev_ioc.h - IOC (Block Device Controler) generic device API definition.
    33 *
    4  * Author  Alain Greiner    (2016)
     4 * Author  Alain Greiner    (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
  • trunk/kernel/devices/dev_mmc.c

    r407 r437  
    22 * dev_mmc.c - MMC (Memory Cache Controler) generic device API implementation.
    33 *
    4  * Author  Alain Greiner    (2016)
     4 * Author  Alain Greiner    (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    9999    thread_t * this = CURRENT_THREAD;
    100100
    101     mmc_dmsg("\n[DBG] %s enters for thread %x in process %x / buf_xp = %l\n",
    102                  __FUNCTION__ , this->trdid , this->process->pid , buf_xp );
     101#if CONFIG_DEBUG_DEV_MMC
     102uint32_t cycle = (uint32_t)hal_get_cycles();
     103if( CONFIG_DEBUG_DEV_MMC < cycle )
     104printk("\n[DBG] %s : thread %x enters / process %x / buf_xp = %l\n",
     105__FUNCTION__, this, this->process->pid , buf_xp );
     106#endif
    103107
    104108    // get buffer cluster and local pointer
     
    124128    error = dev_mmc_access( this );
    125129
    126     mmc_dmsg("\n[DBG] %s completes for thread %x in process %x / error = %d\n",
    127              __FUNCTION__ , this->trdid , this->process->pid , error );
     130#if CONFIG_DEBUG_DEV_MMC
     131cycle = (uint32_t)hal_get_cycles();
     132if( CONFIG_DEBUG_DEV_MMC < cycle )
     133printk("\n[DBG] %s : thread %x exit / process %x / buf_xp = %l\n",
     134__FUNCTION__, this, this->process->pid , buf_xp );
     135#endif
    128136
    129137    return error;
     
    139147    thread_t * this = CURRENT_THREAD;
    140148
    141     mmc_dmsg("\n[DBG] %s enters for thread %x in process %x / buf_xp = %l\n",
    142                  __FUNCTION__ , this->trdid , this->process->pid , buf_xp );
     149#if CONFIG_DEBUG_DEV_MMC
     150uint32_t cycle = (uint32_t)hal_get_cycles();
     151if( CONFIG_DEBUG_DEV_MMC < cycle )
     152printk("\n[DBG] %s : thread %x enters / process %x / buf_xp = %l\n",
     153__FUNCTION__, this, this->process->pid , buf_xp );
     154#endif
    143155
    144156    // get buffer cluster and local pointer
     
    164176    error = dev_mmc_access( this );
    165177
    166     mmc_dmsg("\n[DBG] %s completes for thread %x in process %x / error = %d\n",
    167                  __FUNCTION__ , this->trdid , this->process->pid , error );
     178#if CONFIG_DEBUG_DEV_MMC
     179cycle = (uint32_t)hal_get_cycles();
     180if( CONFIG_DEBUG_DEV_MMC < cycle )
     181printk("\n[DBG] %s : thread %x exit / process %x / buf_xp = %l\n",
     182__FUNCTION__, this, this->process->pid , buf_xp );
     183#endif
    168184
    169185    return error;
  • trunk/kernel/devices/dev_mmc.h

    r23 r437  
    22 * dev_mmc.h - MMC (Generic L2 cache controller) device API definition.
    33 *
    4  * Authors   Alain Greiner  (2016)
     4 * Authors   Alain Greiner  (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
  • trunk/kernel/devices/dev_nic.c

    r436 r437  
    22 * dev_nic.c - NIC (Network Controler) generic device API implementation.
    33 *
    4  * Author  Alain Greiner    (2016,2017)
     4 * Author  Alain Greiner    (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    9999    core_t * core = thread_ptr->core;
    100100
    101     nic_dmsg("\n[DBG] %s enters for NIC-RX thread on core %d in cluster %x\n",
    102                  __FUNCTION__ , core->lid , local_cxy );
     101#if CONFIG_DEBUG_DEV_NIC_RX
     102uint32_t cycle = (uint32_t)hal_get_cycles();
     103if( CONFIG_DEBUG_DEV_NIC_RX < cycle )
     104printk("\n[DBG] %s : thread %x enters for packet %x in cluster %x\n",
     105__FUNCTION__ , thread_ptr , pkd , local_cxy );
     106#endif
    103107
    104108    // get pointer on NIC-RX chdev descriptor
     
    149153    pkd->length = thread_ptr->nic_cmd.length;
    150154
    151     nic_dmsg("\n[DBG] %s exit for NIC-RX thread on core %d in cluster %x\n",
    152              __FUNCTION__ , core->lid , local_cxy );
     155#if CONFIG_DEBUG_DEV_NIC_RX
     156cycle = (uint32_t)hal_get_cycles();
     157if( CONFIG_DEBUG_DEV_NIC_RX < cycle )
     158printk("\n[DBG] %s : thread %x exit for packet %x in cluster %x\n",
     159__FUNCTION__ , thread_ptr , pkd , local_cxy );
     160#endif
    153161
    154162    return 0;
     
    169177    core_t * core = thread_ptr->core;
    170178
    171     nic_dmsg("\n[DBG] %s enters for NIC-RX thread on core %d in cluster %x\n",
    172                  __FUNCTION__ , core->lid , local_cxy );
     179#if CONFIG_DEBUG_DEV_NIC_RX
     180uint32_t cycle = (uint32_t)hal_get_cycles();
     181if( CONFIG_DEBUG_DEV_NIC_RX < cycle )
     182printk("\n[DBG] %s : thread %x enters for packet %x in cluster %x\n",
     183__FUNCTION__ , thread_ptr , pkd , local_cxy );
     184#endif
    173185
    174186    // get pointer on NIC-TX chdev descriptor
     
    217229    if( error ) return error;
    218230
    219     nic_dmsg("\n[DBG] %s exit for NIC-TX thread on core %d in cluster %x\n",
    220              __FUNCTION__ , core->lid , local_cxy );
     231#if CONFIG_DEBUG_DEV_NIC_RX
     232cycle = (uint32_t)hal_get_cycles();
     233if( CONFIG_DEBUG_DEV_NIC_RX < cycle )
     234printk("\n[DBG] %s : thread %x exit for packet %x in cluster %x\n",
     235__FUNCTION__ , thread_ptr , pkd , local_cxy );
     236#endif
    221237
    222238    return 0;
  • trunk/kernel/devices/dev_nic.h

    r407 r437  
    22 * dev_nic.h - NIC (Network Controler) generic device API definition.
    33 *
    4  * Author  Alain Greiner    (2016)
     4 * Author  Alain Greiner    (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
  • trunk/kernel/devices/dev_pic.c

    r422 r437  
    22 * dev_pic.c - PIC (External Interrupt Controler) generic device API implementation.
    33 *
    4  * Authors   Alain Greiner  (2016)
     4 * Authors   Alain Greiner  (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    8686{
    8787
    88 irq_dmsg("\n[DBG] %s : core = [%x,%d] / src_chdev_cxy = %x / src_chdev_ptr = %x\n",
    89 __FUNCTION__ , local_cxy , lid , GET_CXY(src_chdev_xp) , GET_PTR(src_chdev_xp) );
     88#if CONFIG_DEBUG_DEV_PIC
     89uint32_t cycle = (uint32_t)hal_get_cycles();
     90if( CONFIG_DEBUG_DEV_PIC < cycle )
     91printk("\n[DBG] %s : core[%x,%d] / src_chdev_cxy %x / src_chdev_ptr %x / cycle %d\n",
     92__FUNCTION__, local_cxy, lid, GET_CXY(src_chdev_xp), GET_PTR(src_chdev_xp), cycle );
     93#endif
    9094
    9195    // get pointer on PIC chdev
     
    105109{
    106110
    107 irq_dmsg("\n[DBG] %s : core = [%x,%d] / src_chdev_cxy = %x / src_chdev_ptr = %x\n",
    108 __FUNCTION__ , local_cxy , lid , GET_CXY(src_chdev_xp) , GET_PTR(src_chdev_xp) );
     111#if CONFIG_DEBUG_DEV_PIC
     112uint32_t cycle = (uint32_t)hal_get_cycles();
     113if( CONFIG_DEBUG_DEV_PIC < cycle )
     114printk("\n[DBG] %s : core[%x,%d] / src_chdev_cxy %x / src_chdev_ptr %x / cycle %d\n",
     115__FUNCTION__, local_cxy, lid, GET_CXY(src_chdev_xp), GET_PTR(src_chdev_xp), cycle );
     116#endif
    109117
    110118    // get pointer on PIC chdev
     
    123131{
    124132
    125 irq_dmsg("\n[DBG] %s : core = [%x,%d] / period = %d\n",
    126 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , period );
     133#if CONFIG_DEBUG_DEV_PIC
     134uint32_t cycle = (uint32_t)hal_get_cycles();
     135if( CONFIG_DEBUG_DEV_PIC < cycle )
     136printk("\n[DBG] %s : core[%x,%d] / period %d / cycle %d\n",
     137__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , period, cycle );
     138#endif
    127139
    128140    // get pointer on PIC chdev
     
    141153{
    142154
    143 irq_dmsg("\n[DBG] %s : core = [%x,%d] / cycle %d\n",
    144 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , hal_time_stamp() );
     155#if CONFIG_DEBUG_DEV_PIC
     156uint32_t cycle = (uint32_t)hal_get_cycles();
     157if( CONFIG_DEBUG_DEV_PIC < cycle )
     158printk("\n[DBG] %s : core[%x,%d] / cycle %d\n",
     159__FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , cycle );
     160#endif
    145161
    146162    // get pointer on PIC chdev
     
    160176{
    161177
    162 irq_dmsg("\n[DBG] %s : src_core = [%x,%d] / dst_core = [%x,%d] / cycle %d\n",
    163 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, cxy, lid, hal_time_stamp() );
     178#if CONFIG_DEBUG_DEV_PIC
     179uint32_t cycle = (uint32_t)hal_get_cycles();
     180if( CONFIG_DEBUG_DEV_PIC < cycle )
     181printk("\n[DBG] %s : src_core[%x,%d] / dst_core[%x,%d] / cycle %d\n",
     182__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, cxy, lid, cycle );
     183#endif
    164184
    165185    // get pointer on PIC chdev
     
    178198{
    179199
    180 irq_dmsg("\n[DBG] %s : core = [%x,%d] / cycle %d\n",
    181 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, hal_time_stamp() );
     200#if CONFIG_DEBUG_DEV_PIC
     201uint32_t cycle = (uint32_t)hal_get_cycles();
     202if( CONFIG_DEBUG_DEV_PIC < cycle )
     203printk("\n[DBG] %s : core[%x,%d] / cycle %d\n",
     204__FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, cycle );
     205#endif
    182206
    183207    // get pointer on PIC chdev
  • trunk/kernel/devices/dev_pic.h

    r407 r437  
    22 * dev_pic.h - PIC (Programmable Interrupt Controler) generic device API definition.
    33 *
    4  * Authors   Alain Greiner  (2016)
     4 * Authors   Alain Greiner  (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
Note: See TracChangeset for help on using the changeset viewer.