Changeset 11


Ignore:
Timestamp:
Apr 26, 2017, 2:29:23 PM (5 years ago)
Author:
alain
Message:

Merge all FS related files in one single vfs directory.

Location:
trunk/kernel
Files:
2 deleted
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/arch/ibmpc/arch.c

    r1 r11  
    2525#include <kdmsg.h>
    2626#include <cpu.h>
    27 #include <device.h>
     27#include <chdev.h>
    2828#include <system.h>
    2929
  • trunk/kernel/arch/ibmpc/arch_init.c

    r1 r11  
    2525#include <hardware.h>
    2626#include <cpu.h>
    27 #include <device.h>
     27#include <chdev.h>
    2828#include <driver.h>
    2929#include <list.h>
  • trunk/kernel/arch/ibmpc/kdmsg.c

    r1 r11  
    2525#include <hardware.h>
    2626#include <cpu.h>
    27 #include <device.h>
     27#include <chdev.h>
    2828#include <tty.h>
    2929#include <libk.h>
  • trunk/kernel/arch/ibmpc/rt_timer.c

    r1 r11  
    2424#include <rt_timer.h>
    2525#include <cpu.h>
    26 #include <device.h>
     26#include <chdev.h>
    2727#include <driver.h>
    2828#include <sysio.h>
  • trunk/kernel/arch/tsar/arch_init.c

    r1 r11  
    3131#include <system.h>
    3232#include <cluster.h>
    33 #include <device.h>
     33#include <chdev.h>
    3434#include <driver.h>
    3535#include <thread.h>
  • trunk/kernel/arch/tsar/kdmsg.c

    r1 r11  
    2424#include <types.h>
    2525#include <cpu.h>
    26 #include <device.h>
     26#include <chdev.h>
    2727#include <soclib_tty.h>
    2828#include <arch-config.h>
  • trunk/kernel/arch/tsar/rt_timer.c

    r1 r11  
    2525#include <rt_timer.h>
    2626#include <cpu.h>
    27 #include <device.h>
     27#include <chdev.h>
    2828#include <driver.h>
    2929
  • trunk/kernel/kernel.ld

    r1 r11  
    66/* define the kernel code base address */
    77
    8 kernel_base = 0x400000;
     8kernel_base = 0x4000;
    99
    1010/* Set the entry point of the boot-loader (e_entry field in the "boot.elf" file header) */
     
    1717{
    1818    . = kernel_base;
    19     .text :
     19    seg_kcode :
    2020    {
    2121        *(.text)
     
    2323    }
    2424    . = ALIGN(0x1000);
    25     .data :
     25    seg_kdata :
    2626    {
     27        *(.kinfo)
     28        *(.kdata*)
    2729        *(.data*)
    2830    }
    29     .bss :
    30     {
    31         *(.bss)
    32     }
    3331}
  • trunk/kernel/ksh/ksh_set_tty.c

    r1 r11  
    2222#include <kminiShell.h>
    2323#include <system.h>
    24 #include <device.h>
     24#include <chdev.h>
    2525
    2626error_t ksh_set_tty_func(void *param)
  • trunk/kernel/ksh/miniShellIo.c

    r1 r11  
    2727#include <sys-vfs.h>
    2828#include <driver.h>
    29 #include <device.h>
     29#include <chdev.h>
    3030#include <kminiShell.h>
    3131#include <stdarg.h>
  • trunk/kernel/libk/bits.c

    r1 r11  
    8181                }
    8282        }
    83 }
     83}  // bitmap_set_range()
    8484
    8585///////////////////////////////////////////
     
    108108                }
    109109        }
    110 }
     110}  // bitmap_clear_range()
    111111
    112112///////////////////////////////////////
     
    115115                      uint32_t   size )
    116116{
     117    uint32_t max_word;
    117118        uint32_t word = index / 32; 
    118119        uint32_t bit  = index % 32;
    119120 
    120         if(bit != 0)
    121         {
    122                 for(; bit < 32; bit++)
    123                 {
    124                         if(bitmap[word] & (1 << bit)) return (word*32 + bit);
    125                 }
    126                 word++;
    127         }
    128 
    129         for(; word < size/32; word++)
    130         {
    131                 if(bitmap[word] != 0)
    132                 {
    133                         for(bit = 0; bit < 32; bit++)
    134                         {
    135                                 if(bitmap[word] & (1 << bit)) return (word*32 + bit);
    136                         }
    137                 }
    138         }
    139         return 0xFFFFFFFF;
    140 }
     121    if( index < size )
     122    {
     123            if( bit != 0 )
     124            {
     125                    for( ; bit < 32; bit++)
     126                    {
     127                            if((bitmap[word] & (1 << bit)) ) return (word*32 + bit);
     128                    }
     129                    word++;
     130            }
     131
     132        max_word = ( (size-1) >>5 ) + 1;
     133
     134        for( ; word < max_word ; word++ )
     135            {
     136                    if(bitmap[word] != 0)
     137                    {
     138                            for(bit = 0 ; bit < 32 ; bit++)
     139                            {
     140                                    if( bitmap[word] & (1 << bit) ) return (word*32 + bit);
     141                            }
     142            }
     143                }
     144        }
     145
     146        return -1;
     147
     148}  // bitmap_ffs2()
    141149
    142150///////////////////////////////////////
     
    145153                      uint32_t   size )
    146154{
     155    uint32_t max_word;
    147156        uint32_t word = index / 32;
    148157        uint32_t bit  = index % 32;
    149  
    150         if(bit != 0)
    151         {
    152                 for(; bit < 32; bit++)
    153                 {
    154                         if((bitmap[word] & (1 << bit)) == 0) return (word*32 + bit);
    155                 }
    156                 word++;
    157         }
    158 
    159         for(; word < size/32; word++)
    160         {
    161                 if(bitmap[word] != 0xFFFFFFFF)
    162                 {
    163                         for(bit = 0; bit < 32; bit++)
    164                         {
    165                                 if((bitmap[word] & (1 << bit)) == 0) return (word*32 + bit);
    166                         }
    167                 }
    168         }
    169         return 0xFFFFFFFF;
    170 }
     158   
     159    if( index < size )
     160    {
     161            if( bit != 0 )
     162            {
     163                    for( ; bit < 32; bit++)
     164                    {
     165                            if( (bitmap[word] & (1 << bit)) == 0) return (word*32 + bit);
     166                    }
     167                    word++;
     168            }
     169
     170        max_word = ( (size-1) >>5 ) + 1;
     171
     172        for( ; word < max_word ; word++ )
     173            {
     174                    if(bitmap[word] != 0xFFFFFFFF)
     175                    {
     176                            for(bit = 0 ; bit < 32 ; bit++)
     177                            {
     178                                    if( (bitmap[word] & (1 << bit)) == 0 ) return (word*32 + bit);
     179                            }
     180            }
     181                }
     182        }
     183
     184        return -1;
     185
     186}  // bitmap_ffc2()
    171187
    172188//////////////////////////////////////
     
    174190                     uint32_t   size )
    175191{
     192    uint32_t max_word;
     193        uint32_t word;
     194        uint32_t bit;
     195
     196    if( size )
     197    {
     198        max_word = ( (size-1) >>5 ) + 1;
     199
     200        for( word = 0 ; word < max_word ; word++ )
     201            {
     202                    if(bitmap[word] != 0)
     203                    {
     204                            for(bit = 0 ; bit < 32 ; bit++)
     205                            {
     206                                    if( bitmap[word] & (1 << bit) ) return (word*32 + bit);
     207                            }
     208            }
     209                }
     210        }
     211
     212        return -1;
     213
     214}  // bitmap_ffs()
     215
     216//////////////////////////////////////
     217uint32_t bitmap_ffc( bitmap_t * bitmap,
     218                     uint32_t   size )
     219{
     220    uint32_t max_word;
    176221        uint32_t word;
    177222        uint32_t bit;
    178223 
    179         for(word = 0 ; word < size/32 ; word++)
    180         {
    181                 if(bitmap[word] != 0)
    182                 {
    183                         for(bit = 0 ; bit < 32 ; bit++)
    184                         {
    185                                 if( bitmap[word] & (1 << bit) ) return (word*32 + bit);
    186                         }
    187                 }
    188         }
    189         return 0xFFFFFFFF;
    190 }
    191 
    192 //////////////////////////////////////
    193 uint32_t bitmap_ffc( bitmap_t * bitmap,
    194                      uint32_t   size )
    195 {
    196         uint32_t word;
    197         uint32_t bit;
    198  
    199         for(word = 0 ; word < size/32 ; word++)
    200         {
    201                 if(bitmap[word] != 0)
    202                 {
    203                         for(bit = 0 ; bit < 32 ; bit++)
    204                         {
    205                                 if( (bitmap[word] & (1 << bit)) == 0 ) return (word*32 + bit);
    206                         }
    207                 }
    208         }
    209         return 0xFFFFFFFF;
    210 }
    211 
     224    if( size )
     225    {
     226        max_word = ( (size-1) >>5 ) + 1;
     227
     228        for( word = 0 ; word < max_word ; word++ )
     229            {
     230                    if(bitmap[word] != 0XFFFFFFFF)
     231                    {
     232                            for(bit = 0 ; bit < 32 ; bit++)
     233                            {
     234                                    if( (bitmap[word] & (1 << bit)) == 0 ) return (word*32 + bit);
     235                            }
     236            }
     237                }
     238        }
     239
     240        return -1;
     241
     242}  // bitmap_ffc()
     243
  • trunk/kernel/libk/bits.h

    r1 r11  
    9595 * This function set a specific bit in a bitmap.
    9696 **********************************************************************************************
    97 
    9897 * @ bitmap  : pointer on the bitmap
    9998 * @ index   : bit index in the bitmap
  • trunk/kernel/libk/memcpy.c

    r1 r11  
    2323
    2424#include <hal_types.h>
     25#include <printk.h>
    2526
    2627/////////////////////////////////
     
    3233    const uint32_t * wsrc = src;
    3334
     35    // word per word copy if both addresses aligned
    3436    if (!((uint32_t) wdst & 3) && !((uint32_t) wsrc & 3) )
    3537    {
     
    4446    unsigned char *csrc = (unsigned char*)wsrc;
    4547
     48    // byte per byte for last bytes (or not aligned)
    4649    while (size--)
    4750    {
     
    5154}
    5255
    53 ///////////////////////////
    54 void * memset( void   * dst,
    55                int      s,
    56                uint32_t size)
     56//////////////////////////////
     57void * memset( void     * dst,
     58               uint32_t   val,
     59               uint32_t   size)
    5760{
    58     char * a = (char *) dst;
    59     while (size--)
     61    // build 8 bits and 32 bits values
     62    uint8_t    byte = (uint8_t)(val & 0xFF);
     63    uint32_t   word = (val<<24) | (val<<16) | (val<<8) | val;
     64
     65    // word per word if address aligned
     66    uint32_t * wdst = (uint32_t *)dst;
     67
     68    if( (((uint32_t)dst) & 0x3) == 0 )
    6069    {
    61         *a++ = (char)s;
     70        while( size > 3 )
     71        {
     72            *wdst++ = word;
     73            size -= 4;
     74        }
    6275    }
     76
     77    // byte per byte for last bytes (or not aligned)
     78    char * cdst = (char *)wdst;
     79
     80    while( size-- )
     81    {
     82        *cdst++ = byte;
     83    }
     84
    6385    return dst;
    6486}
  • trunk/kernel/libk/memcpy.h

    r1 r11  
    3535 * @ return pointer on destination buffer.
    3636 ******************************************************************************************/
    37 void * memcpy( void       * _dst,
    38                const void * _src,
     37void * memcpy( void       * dst,
     38               const void * src,
    3939               uint32_t     size );
    4040
     
    4343 *******************************************************************************************
    4444 * @ dst     : pointer on destination buffer.
    45  * @ s       : constant value (casted to a char).
     45 * @ val     : constant value (casted to uint8_t).
    4646 * @ size    : number of bytes.
    4747 * @ return pointer on destination buffer.
    4848 ******************************************************************************************/
    49 void * memset( void   * dst,
    50                int      s,
     49void * memset( void     * dst,
     50               uint32_t   val,
    5151               uint32_t size);
    5252
  • trunk/kernel/libk/remote_spinlock.c

    r1 r11  
    3131#include <remote_spinlock.h>
    3232
    33 ////////////////////////////////////////
    34 void remote_spinlock_init( xptr_t lock )
     33///////////////////////////////////////////
     34void remote_spinlock_init( xptr_t lock_xp )
    3535{
    36     remote_spinlock_t * ptr = (remote_spinlock_t *)GET_PTR( lock );
    37     cxy_t               cxy = GET_CXY( lock );
     36    remote_spinlock_t * ptr = (remote_spinlock_t *)GET_PTR( lock_xp );
     37    cxy_t               cxy = GET_CXY( lock_xp );
    3838
    3939    hal_remote_sw ( XPTR( cxy , &ptr->taken ) , 0 );
     
    4242}
    4343
    44 ///////////////////////////////////////////////
    45 uint32_t remote_spinlock_trylock( xptr_t lock )
     44/////////////////////////////////////////////////
     45error_t remote_spinlock_trylock( xptr_t lock_xp )
    4646{
    4747        uint32_t            mode;
     
    4949
    5050    // get cluster and local pointer on remote_spinlock
    51     remote_spinlock_t * lock_ptr = (remote_spinlock_t *)GET_PTR( lock );
    52     cxy_t               lock_cxy = GET_CXY( lock );
     51    remote_spinlock_t * lock_ptr = (remote_spinlock_t *)GET_PTR( lock_xp );
     52    cxy_t               lock_cxy = GET_CXY( lock_xp );
    5353
    5454    // get cluster and local pointer on local thread
     
    8484}
    8585
    86 ////////////////////////////////////////
    87 void remote_spinlock_lock( xptr_t lock )
     86///////////////////////////////////////////////////
     87void remote_spinlock_lock_busy( xptr_t     lock_xp,
     88                                uint32_t * irq_state )
    8889{
    8990    bool_t              isAtomic = false;
     
    9293
    9394    // get cluster and local pointer on remote_spinlock
    94     remote_spinlock_t * lock_ptr = (remote_spinlock_t *)GET_PTR( lock );
    95     cxy_t               lock_cxy = GET_CXY( lock );
     95    remote_spinlock_t * lock_ptr = (remote_spinlock_t *)GET_PTR( lock_xp );
     96    cxy_t               lock_cxy = GET_CXY( lock_xp );
     97
     98    // get cluster and local pointer on local thread
     99    cxy_t               thread_cxy = local_cxy;
     100    thread_t          * thread_ptr = CURRENT_THREAD;
     101
     102    // disable interrupts
     103        hal_disable_irq( &mode );
     104 
     105    // loop until success
     106        while( isAtomic == false )
     107        {
     108                taken = hal_remote_lw( XPTR( lock_cxy , &lock_ptr->taken ) );
     109
     110        // try to take the lock if not already taken
     111                if( taken == 0 )
     112                {
     113                    isAtomic = hal_remote_atomic_cas( XPTR( lock_cxy , &lock_ptr->taken ) , 0 , 1 );
     114        }
     115        }
     116
     117    // register lock in thread
     118        thread_ptr->remote_locks++;
     119
     120    hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) ,
     121                    (uint64_t)XPTR( thread_cxy , thread_ptr) );
     122
     123    xlist_add_first( XPTR( thread_cxy , &thread_ptr->xlocks_root ) ,
     124                     XPTR( lock_cxy , &lock_ptr->list ) );
     125
     126    // irq_state must be restored when lock is released
     127    *irq_state = mode;
     128
     129}  // end remote_spinlock_lock_busy()
     130
     131////////////////////////////////////////////////////
     132void remote_spinlock_unlock_busy( xptr_t    lock_xp,
     133                                  uint32_t  irq_state )
     134{
     135    // get cluster and local pointer on remote_spinlock
     136    remote_spinlock_t * lock_ptr = (remote_spinlock_t *)GET_PTR( lock_xp );
     137    cxy_t               lock_cxy = GET_CXY( lock_xp );
     138
     139    // get pointer on local thread
     140    thread_t          * thread_ptr = CURRENT_THREAD;
     141
     142        hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) , XPTR_NULL );
     143
     144        hal_remote_sw ( XPTR( lock_cxy , &lock_ptr->taken ) , 0 );
     145
     146        thread_ptr->remote_locks--;
     147
     148    xlist_unlink( XPTR( lock_cxy , &lock_ptr->list ) );
     149
     150    hal_restore_irq( irq_state );
     151}
     152
     153///////////////////////////////////////////
     154void remote_spinlock_lock( xptr_t lock_xp )
     155{
     156    bool_t              isAtomic = false;
     157        uint32_t            mode;
     158    volatile uint32_t   taken;
     159
     160    // get cluster and local pointer on remote_spinlock
     161    remote_spinlock_t * lock_ptr = (remote_spinlock_t *)GET_PTR( lock_xp );
     162    cxy_t               lock_cxy = GET_CXY( lock_xp );
    96163
    97164    // get cluster and local pointer on local thread
     
    133200}
    134201
    135 //////////////////////////////////////////
    136 void remote_spinlock_unlock( xptr_t lock )
    137 {
    138     // get cluster and local pointer on remote_spinlock
    139     remote_spinlock_t * lock_ptr = (remote_spinlock_t *)GET_PTR( lock );
    140     cxy_t               lock_cxy = GET_CXY( lock );
     202/////////////////////////////////////////////
     203void remote_spinlock_unlock( xptr_t lock_xp )
     204{
     205    // get cluster and local pointer on remote_spinlock
     206    remote_spinlock_t * lock_ptr = (remote_spinlock_t *)GET_PTR( lock_xp );
     207    cxy_t               lock_cxy = GET_CXY( lock_xp );
    141208
    142209    // get pointer on local thread
  • trunk/kernel/libk/remote_spinlock.h

    r1 r11  
    4848 * This function initializes a remote spinlock.
    4949 ***************************************************************************************
    50  * @ lock    : extended pointer on the remote spinlock
     50 * @ lock_xp : extended pointer on the remote spinlock
    5151 **************************************************************************************/
    52 void remote_spinlock_init( xptr_t   lock );
     52void remote_spinlock_init( xptr_t   lock_xp );
     53
     54/*******************************************************************************************
     55 * This blocking function uses a busy waiting strategy to lock a remote spinlock.
     56 * It polls the lock and returns only when the lock has been taken.
     57 * All IRQs are disabled and will keep disabled until the lock is released.
     58 * It increments the calling thread local_locks count when the lock has been taken.
     59 *******************************************************************************************
     60 * @ lock_xp    : extended pointer on the remote spinlock.
     61 * @ irq_state  : buffer to save the SR state (in the calling thread stack)
     62 ******************************************************************************************/
     63void remote_spinlock_lock_busy( xptr_t     lock_xp,
     64                                uint32_t * irq_state );
     65
     66/*******************************************************************************************
     67 * This function releases a remote busy_waiting spinlock.
     68 * It restores the CPU SR state.
     69 *******************************************************************************************
     70 * @ lock_xp    : extended pointer on remote spinlock.
     71 * @ irq_state  : value to be resrored in CPU SR
     72 ******************************************************************************************/
     73void remote_spinlock_unlock_busy( xptr_t     lock_xp,
     74                                  uint32_t   irq_state );
    5375
    5476/***************************************************************************************
     
    5880 * It increments the calling thread locks count when the lock has been taken.
    5981 ***************************************************************************************
    60  * @ lock    : extended pointer on the remote spinlock
     82 * @ lock_xp   : extended pointer on the remote spinlock
    6183 **************************************************************************************/
    62 void remote_spinlock_lock( xptr_t lock );
     84void remote_spinlock_lock( xptr_t lock_xp );
    6385
    6486/***************************************************************************************
     
    6688 * It increments the calling thread locks count in case of success.
    6789 ***************************************************************************************
    68  * @ lock    : extended pointer on the remote spinlock
     90 * @ lock_xp    : extended pointer on the remote spinlock
    6991 * @ returns O if success / returns non zero if lock already taken.
    7092 **************************************************************************************/
    71 uint32_t remote_spinlock_trylock( xptr_t lock );
     93error_t remote_spinlock_trylock( xptr_t  lock_xp );
    7294
    7395/***************************************************************************************
    7496 * This function releases a remote spinlock.
    7597 ***************************************************************************************
    76  * @ lock    : extended pointer on the remote spinlock
     98 * @ lock_xp    : extended pointer on the remote spinlock
    7799 **************************************************************************************/
    78 void remote_spinlock_unlock( xptr_t lock );
     100void remote_spinlock_unlock( xptr_t  lock_xp );
    79101
    80102#endif
  • trunk/kernel/libk/spinlock.c

    r1 r11  
    5858                taken = lock->taken;
    5959
     60        // try to take the lock if not already taken
    6061                if( taken == 0 )
    6162        {
    62             // try to take the lock if not already taken
    6363                    isAtomic = hal_atomic_cas( &lock->taken , 0 , 1 );
    6464        }
     
    6969    list_add_first( &this->locks_root , &lock->list );
    7070
    71     // enable interrupts if irq_state == NULL
    72         if( irq_state ) *irq_state = mode;
    73         else            hal_restore_irq( mode );
     71    // irq_state must be restored when lock is released
     72    *irq_state = mode;
    7473}
    7574
    7675//////////////////////////////////////////////
    7776void spinlock_unlock_busy( spinlock_t * lock,
    78                            bool_t       restore,
    7977                           uint32_t     irq_state )
    8078{
     
    8684    list_unlink( &lock->list );
    8785 
    88         if( restore ) hal_restore_irq( irq_state );
     86        hal_restore_irq( irq_state );
    8987}
    9088   
     
    126124}
    127125
    128 //////////////////////////////////////////////
    129 uint32_t spinlock_trylock( spinlock_t * lock )
     126/////////////////////////////////////////////
     127error_t spinlock_trylock( spinlock_t * lock )
    130128{
    131129        uint32_t   mode;
  • trunk/kernel/libk/spinlock.h

    r1 r11  
    7575 * This blocking function uses a busy waiting strategy to lock a local spinlock.
    7676 * It polls the lock and returns only when the lock has been taken.
    77  * If the irq_state argument is not NULL, all IRQs are disabled and will keep disabled
    78  * until the lock is released. If irq_state is NULL, the IRQs are only disabled
    79  * during the lock acquisition polling loop.
     77 * All IRQs are disabled and will keep disabled until the lock is released.
    8078 * It increments the calling thread local_locks count when the lock has been taken.
    8179 *******************************************************************************************
     
    8886/*******************************************************************************************
    8987 * This function releases a local busy_waiting spinlock.
    90  * It restores the CPU SR state, if required by the restore argument.
     88 * It restores the CPU SR state.
    9189 *******************************************************************************************
    9290 * @ lock       : pointer on spinlock
    93  * @ restore    : restore the CPU SR (from irq_state) if true
    9491 * @ irq_state  : value to be resrored in CPU SR
    9592 ******************************************************************************************/
    9693void spinlock_unlock_busy( spinlock_t * lock,
    97                            bool_t       restore,
    9894                           uint32_t     irq_state );
    9995
     
    115111 * @ returns 0 if success / returns non zero if lock already taken.
    116112 ******************************************************************************************/
    117 uint32_t spinlock_trylock( spinlock_t * lock );
     113error_t spinlock_trylock( spinlock_t * lock );
    118114
    119115/*******************************************************************************************
  • trunk/kernel/syscalls/sys_chdir.c

    r1 r11  
    2222
    2323#include <cpu.h>
    24 #include <device.h>
     24#include <chdev.h>
    2525#include <driver.h>
    2626#include <rwlock.h>
  • trunk/kernel/syscalls/sys_chmod.c

    r1 r11  
    2121
    2222#include <cpu.h>
    23 #include <device.h>
     23#include <chdev.h>
    2424#include <driver.h>
    2525#include <rwlock.h>
  • trunk/kernel/syscalls/sys_close.c

    r1 r11  
    2222
    2323#include <cpu.h>
    24 #include <device.h>
     24#include <chdev.h>
    2525#include <driver.h>
    2626#include <vfs.h>
  • trunk/kernel/syscalls/sys_dma_memcpy.c

    r1 r11  
    2424#include <types.h>
    2525#include <event.h>
    26 #include <device.h>
     26#include <chdev.h>
    2727#include <driver.h>
    2828#include <kmem.h>
Note: See TracChangeset for help on using the changeset viewer.