- Timestamp:
- Apr 26, 2017, 2:29:23 PM (8 years ago)
- Location:
- trunk/kernel
- Files:
-
- 2 deleted
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/arch/ibmpc/arch.c
r1 r11 25 25 #include <kdmsg.h> 26 26 #include <cpu.h> 27 #include < device.h>27 #include <chdev.h> 28 28 #include <system.h> 29 29 -
trunk/kernel/arch/ibmpc/arch_init.c
r1 r11 25 25 #include <hardware.h> 26 26 #include <cpu.h> 27 #include < device.h>27 #include <chdev.h> 28 28 #include <driver.h> 29 29 #include <list.h> -
trunk/kernel/arch/ibmpc/kdmsg.c
r1 r11 25 25 #include <hardware.h> 26 26 #include <cpu.h> 27 #include < device.h>27 #include <chdev.h> 28 28 #include <tty.h> 29 29 #include <libk.h> -
trunk/kernel/arch/ibmpc/rt_timer.c
r1 r11 24 24 #include <rt_timer.h> 25 25 #include <cpu.h> 26 #include < device.h>26 #include <chdev.h> 27 27 #include <driver.h> 28 28 #include <sysio.h> -
trunk/kernel/arch/tsar/arch_init.c
r1 r11 31 31 #include <system.h> 32 32 #include <cluster.h> 33 #include < device.h>33 #include <chdev.h> 34 34 #include <driver.h> 35 35 #include <thread.h> -
trunk/kernel/arch/tsar/kdmsg.c
r1 r11 24 24 #include <types.h> 25 25 #include <cpu.h> 26 #include < device.h>26 #include <chdev.h> 27 27 #include <soclib_tty.h> 28 28 #include <arch-config.h> -
trunk/kernel/arch/tsar/rt_timer.c
r1 r11 25 25 #include <rt_timer.h> 26 26 #include <cpu.h> 27 #include < device.h>27 #include <chdev.h> 28 28 #include <driver.h> 29 29 -
trunk/kernel/kernel.ld
r1 r11 6 6 /* define the kernel code base address */ 7 7 8 kernel_base = 0x4000 00;8 kernel_base = 0x4000; 9 9 10 10 /* Set the entry point of the boot-loader (e_entry field in the "boot.elf" file header) */ … … 17 17 { 18 18 . = kernel_base; 19 .text:19 seg_kcode : 20 20 { 21 21 *(.text) … … 23 23 } 24 24 . = ALIGN(0x1000); 25 .data :25 seg_kdata : 26 26 { 27 *(.kinfo) 28 *(.kdata*) 27 29 *(.data*) 28 30 } 29 .bss :30 {31 *(.bss)32 }33 31 } -
trunk/kernel/ksh/ksh_set_tty.c
r1 r11 22 22 #include <kminiShell.h> 23 23 #include <system.h> 24 #include < device.h>24 #include <chdev.h> 25 25 26 26 error_t ksh_set_tty_func(void *param) -
trunk/kernel/ksh/miniShellIo.c
r1 r11 27 27 #include <sys-vfs.h> 28 28 #include <driver.h> 29 #include < device.h>29 #include <chdev.h> 30 30 #include <kminiShell.h> 31 31 #include <stdarg.h> -
trunk/kernel/libk/bits.c
r1 r11 81 81 } 82 82 } 83 } 83 } // bitmap_set_range() 84 84 85 85 /////////////////////////////////////////// … … 108 108 } 109 109 } 110 } 110 } // bitmap_clear_range() 111 111 112 112 /////////////////////////////////////// … … 115 115 uint32_t size ) 116 116 { 117 uint32_t max_word; 117 118 uint32_t word = index / 32; 118 119 uint32_t bit = index % 32; 119 120 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() 141 149 142 150 /////////////////////////////////////// … … 145 153 uint32_t size ) 146 154 { 155 uint32_t max_word; 147 156 uint32_t word = index / 32; 148 157 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() 171 187 172 188 ////////////////////////////////////// … … 174 190 uint32_t size ) 175 191 { 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 ////////////////////////////////////// 217 uint32_t bitmap_ffc( bitmap_t * bitmap, 218 uint32_t size ) 219 { 220 uint32_t max_word; 176 221 uint32_t word; 177 222 uint32_t bit; 178 223 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 95 95 * This function set a specific bit in a bitmap. 96 96 ********************************************************************************************** 97 98 97 * @ bitmap : pointer on the bitmap 99 98 * @ index : bit index in the bitmap -
trunk/kernel/libk/memcpy.c
r1 r11 23 23 24 24 #include <hal_types.h> 25 #include <printk.h> 25 26 26 27 ///////////////////////////////// … … 32 33 const uint32_t * wsrc = src; 33 34 35 // word per word copy if both addresses aligned 34 36 if (!((uint32_t) wdst & 3) && !((uint32_t) wsrc & 3) ) 35 37 { … … 44 46 unsigned char *csrc = (unsigned char*)wsrc; 45 47 48 // byte per byte for last bytes (or not aligned) 46 49 while (size--) 47 50 { … … 51 54 } 52 55 53 /////////////////////////// 54 void * memset( void * dst,55 int s,56 uint32_t size)56 ////////////////////////////// 57 void * memset( void * dst, 58 uint32_t val, 59 uint32_t size) 57 60 { 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 ) 60 69 { 61 *a++ = (char)s; 70 while( size > 3 ) 71 { 72 *wdst++ = word; 73 size -= 4; 74 } 62 75 } 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 63 85 return dst; 64 86 } -
trunk/kernel/libk/memcpy.h
r1 r11 35 35 * @ return pointer on destination buffer. 36 36 ******************************************************************************************/ 37 void * memcpy( void * _dst,38 const void * _src,37 void * memcpy( void * dst, 38 const void * src, 39 39 uint32_t size ); 40 40 … … 43 43 ******************************************************************************************* 44 44 * @ dst : pointer on destination buffer. 45 * @ s : constant value (casted to a char).45 * @ val : constant value (casted to uint8_t). 46 46 * @ size : number of bytes. 47 47 * @ return pointer on destination buffer. 48 48 ******************************************************************************************/ 49 void * memset( void * dst,50 int s,49 void * memset( void * dst, 50 uint32_t val, 51 51 uint32_t size); 52 52 -
trunk/kernel/libk/remote_spinlock.c
r1 r11 31 31 #include <remote_spinlock.h> 32 32 33 //////////////////////////////////////// 34 void remote_spinlock_init( xptr_t lock )33 /////////////////////////////////////////// 34 void remote_spinlock_init( xptr_t lock_xp ) 35 35 { 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 ); 38 38 39 39 hal_remote_sw ( XPTR( cxy , &ptr->taken ) , 0 ); … … 42 42 } 43 43 44 /////////////////////////////////////////////// 45 uint32_t remote_spinlock_trylock( xptr_t lock)44 ///////////////////////////////////////////////// 45 error_t remote_spinlock_trylock( xptr_t lock_xp ) 46 46 { 47 47 uint32_t mode; … … 49 49 50 50 // 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 ); 53 53 54 54 // get cluster and local pointer on local thread … … 84 84 } 85 85 86 //////////////////////////////////////// 87 void remote_spinlock_lock( xptr_t lock ) 86 /////////////////////////////////////////////////// 87 void remote_spinlock_lock_busy( xptr_t lock_xp, 88 uint32_t * irq_state ) 88 89 { 89 90 bool_t isAtomic = false; … … 92 93 93 94 // 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 //////////////////////////////////////////////////// 132 void 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 /////////////////////////////////////////// 154 void 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 ); 96 163 97 164 // get cluster and local pointer on local thread … … 133 200 } 134 201 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 ///////////////////////////////////////////// 203 void 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 ); 141 208 142 209 // get pointer on local thread -
trunk/kernel/libk/remote_spinlock.h
r1 r11 48 48 * This function initializes a remote spinlock. 49 49 *************************************************************************************** 50 * @ lock 50 * @ lock_xp : extended pointer on the remote spinlock 51 51 **************************************************************************************/ 52 void remote_spinlock_init( xptr_t lock ); 52 void 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 ******************************************************************************************/ 63 void 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 ******************************************************************************************/ 73 void remote_spinlock_unlock_busy( xptr_t lock_xp, 74 uint32_t irq_state ); 53 75 54 76 /*************************************************************************************** … … 58 80 * It increments the calling thread locks count when the lock has been taken. 59 81 *************************************************************************************** 60 * @ lock 82 * @ lock_xp : extended pointer on the remote spinlock 61 83 **************************************************************************************/ 62 void remote_spinlock_lock( xptr_t lock );84 void remote_spinlock_lock( xptr_t lock_xp ); 63 85 64 86 /*************************************************************************************** … … 66 88 * It increments the calling thread locks count in case of success. 67 89 *************************************************************************************** 68 * @ lock : extended pointer on the remote spinlock90 * @ lock_xp : extended pointer on the remote spinlock 69 91 * @ returns O if success / returns non zero if lock already taken. 70 92 **************************************************************************************/ 71 uint32_t remote_spinlock_trylock( xptr_t lock);93 error_t remote_spinlock_trylock( xptr_t lock_xp ); 72 94 73 95 /*************************************************************************************** 74 96 * This function releases a remote spinlock. 75 97 *************************************************************************************** 76 * @ lock : extended pointer on the remote spinlock98 * @ lock_xp : extended pointer on the remote spinlock 77 99 **************************************************************************************/ 78 void remote_spinlock_unlock( xptr_t lock);100 void remote_spinlock_unlock( xptr_t lock_xp ); 79 101 80 102 #endif -
trunk/kernel/libk/spinlock.c
r1 r11 58 58 taken = lock->taken; 59 59 60 // try to take the lock if not already taken 60 61 if( taken == 0 ) 61 62 { 62 // try to take the lock if not already taken63 63 isAtomic = hal_atomic_cas( &lock->taken , 0 , 1 ); 64 64 } … … 69 69 list_add_first( &this->locks_root , &lock->list ); 70 70 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; 74 73 } 75 74 76 75 ////////////////////////////////////////////// 77 76 void spinlock_unlock_busy( spinlock_t * lock, 78 bool_t restore,79 77 uint32_t irq_state ) 80 78 { … … 86 84 list_unlink( &lock->list ); 87 85 88 if( restore )hal_restore_irq( irq_state );86 hal_restore_irq( irq_state ); 89 87 } 90 88 … … 126 124 } 127 125 128 ///////////////////////////////////////////// /129 uint32_t spinlock_trylock( spinlock_t * lock )126 ///////////////////////////////////////////// 127 error_t spinlock_trylock( spinlock_t * lock ) 130 128 { 131 129 uint32_t mode; -
trunk/kernel/libk/spinlock.h
r1 r11 75 75 * This blocking function uses a busy waiting strategy to lock a local spinlock. 76 76 * 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. 80 78 * It increments the calling thread local_locks count when the lock has been taken. 81 79 ******************************************************************************************* … … 88 86 /******************************************************************************************* 89 87 * 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. 91 89 ******************************************************************************************* 92 90 * @ lock : pointer on spinlock 93 * @ restore : restore the CPU SR (from irq_state) if true94 91 * @ irq_state : value to be resrored in CPU SR 95 92 ******************************************************************************************/ 96 93 void spinlock_unlock_busy( spinlock_t * lock, 97 bool_t restore,98 94 uint32_t irq_state ); 99 95 … … 115 111 * @ returns 0 if success / returns non zero if lock already taken. 116 112 ******************************************************************************************/ 117 uint32_t spinlock_trylock( spinlock_t * lock );113 error_t spinlock_trylock( spinlock_t * lock ); 118 114 119 115 /******************************************************************************************* -
trunk/kernel/syscalls/sys_chdir.c
r1 r11 22 22 23 23 #include <cpu.h> 24 #include < device.h>24 #include <chdev.h> 25 25 #include <driver.h> 26 26 #include <rwlock.h> -
trunk/kernel/syscalls/sys_chmod.c
r1 r11 21 21 22 22 #include <cpu.h> 23 #include < device.h>23 #include <chdev.h> 24 24 #include <driver.h> 25 25 #include <rwlock.h> -
trunk/kernel/syscalls/sys_close.c
r1 r11 22 22 23 23 #include <cpu.h> 24 #include < device.h>24 #include <chdev.h> 25 25 #include <driver.h> 26 26 #include <vfs.h> -
trunk/kernel/syscalls/sys_dma_memcpy.c
r1 r11 24 24 #include <types.h> 25 25 #include <event.h> 26 #include < device.h>26 #include <chdev.h> 27 27 #include <driver.h> 28 28 #include <kmem.h>
Note: See TracChangeset
for help on using the changeset viewer.