Changeset 565 for trunk/kernel/devices
- Timestamp:
- Oct 4, 2018, 11:48:51 PM (6 years ago)
- Location:
- trunk/kernel/devices
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/devices/dev_dma.c
r492 r565 29 29 #include <printk.h> 30 30 #include <memcpy.h> 31 #include <spinlock.h>32 31 #include <dev_dma.h> 33 32 #include <hal_drivers.h> -
trunk/kernel/devices/dev_dma.h
r457 r565 27 27 #include <kernel_config.h> 28 28 #include <hal_kernel_types.h> 29 #include <spinlock.h>30 29 31 30 /***************************************************************************************** -
trunk/kernel/devices/dev_fbf.c
r492 r565 55 55 if( impl == IMPL_FBF_SCL ) 56 56 { 57 // TODO57 printk("\n[WARNING] Soclib FBF driver not implemented yet\n"); 58 58 } 59 59 else … … 78 78 79 79 // return values 80 *width = hal_remote_l w( XPTR( dev_cxy , &dev_ptr->ext.fbf.width ) );81 *height = hal_remote_l w( XPTR( dev_cxy , &dev_ptr->ext.fbf.height ) );80 *width = hal_remote_l32( XPTR( dev_cxy , &dev_ptr->ext.fbf.width ) ); 81 *height = hal_remote_l32( XPTR( dev_cxy , &dev_ptr->ext.fbf.height ) ); 82 82 83 83 } // end dev_fbf_get_size() 84 84 85 /////////////////////// 85 ///////////////////////////// 86 86 error_t dev_fbf_alloc( void ) 87 87 { 88 88 // get extended pointer on FBF chdev descriptor 89 xptr_t dev_xp = chdev_dir.fbf[0];90 91 assert( (dev_xp != XPTR_NULL) , "undefined FBF chdev descriptor" );92 93 // get FBF chdev cluster and local pointer 94 cxy_t dev_cxy = GET_CXY( dev_xp );95 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );89 // xptr_t dev_xp = chdev_dir.fbf[0]; 90 91 // assert( (dev_xp != XPTR_NULL) , "undefined FBF chdev descriptor" ); 92 93 // get FBF chdev cluster and local pointer 94 // cxy_t dev_cxy = GET_CXY( dev_xp ); 95 // chdev_t * dev_ptr = GET_PTR( dev_xp ); 96 96 97 97 // try to get FBF ownership 98 return remote_spinlock_trylock( XPTR( dev_cxy , &dev_ptr->wait_lock ) ); 98 99 assert( false , "not implemented yet" ); 99 100 100 101 } // end dev_fbf_alloc() 101 102 102 /////////////////// 103 ///////////////////////// 103 104 void dev_fbf_free( void ) 104 105 { 105 106 // get extended pointer on FBF chdev descriptor 106 xptr_t dev_xp = chdev_dir.fbf[0];107 108 assert( (dev_xp != XPTR_NULL) , "undefined FBF chdev descriptor" );109 110 // get FBF chdev cluster and local pointer 111 cxy_t dev_cxy = GET_CXY( dev_xp );112 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );107 // xptr_t dev_xp = chdev_dir.fbf[0]; 108 109 // assert( (dev_xp != XPTR_NULL) , "undefined FBF chdev descriptor" ); 110 111 // get FBF chdev cluster and local pointer 112 // cxy_t dev_cxy = GET_CXY( dev_xp ); 113 // chdev_t * dev_ptr = (GET_PTR( dev_xp ); 113 114 114 115 // release FBF ownership 115 remote_spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) ); 116 117 assert( false , "not implemented yet" ); 116 118 117 119 } // end dev_fbf_free() … … 139 141 140 142 // get frame buffer base address, width and height 141 xptr_t base = hal_remote_l wd( XPTR( fbf_cxy , &fbf_ptr->base ) );142 uint32_t width = hal_remote_l w( XPTR( fbf_cxy , &fbf_ptr->ext.fbf.width ) );143 uint32_t height = hal_remote_l w( XPTR( fbf_cxy , &fbf_ptr->ext.fbf.height ) );143 xptr_t base = hal_remote_l64( XPTR( fbf_cxy , &fbf_ptr->base ) ); 144 uint32_t width = hal_remote_l32 ( XPTR( fbf_cxy , &fbf_ptr->ext.fbf.width ) ); 145 uint32_t height = hal_remote_l32 ( XPTR( fbf_cxy , &fbf_ptr->ext.fbf.height ) ); 144 146 145 147 // check offset and length versus FBF size -
trunk/kernel/devices/dev_iob.c
r457 r565 2 2 * dev_iob.c - IOB (bridge to external I/O) generic device API implementation. 3 3 * 4 * Authors Alain Greiner (201 7)4 * Authors Alain Greiner (2016,2017,2018) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 25 25 #include <hal_kernel_types.h> 26 26 #include <hal_special.h> 27 #include <remote_ spinlock.h>27 #include <remote_busylock.h> 28 28 #include <chdev.h> 29 29 #include <printk.h> … … 50 50 // get IOB chdev descriptor cluster and local pointer 51 51 cxy_t dev_cxy = GET_CXY( dev_xp ); 52 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );52 chdev_t * dev_ptr = GET_PTR( dev_xp ); 53 53 54 54 // get pointer on set_active function … … 56 56 57 57 // call relevant driver function 58 remote_ spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );58 remote_busylock_acquire( XPTR( dev_cxy , &dev_ptr->wait_lock ) ); 59 59 f( dev_xp , 1 ); 60 remote_ spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );60 remote_busylock_release( XPTR( dev_cxy , &dev_ptr->wait_lock ) ); 61 61 } 62 62 … … 66 66 // get IOB chdev descriptor cluster and local pointer 67 67 cxy_t dev_cxy = GET_CXY( dev_xp ); 68 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );68 chdev_t * dev_ptr = GET_PTR( dev_xp ); 69 69 70 70 // get pointer on set_active function … … 72 72 73 73 // call driver function 74 remote_ spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );74 remote_busylock_acquire( XPTR( dev_cxy , &dev_ptr->wait_lock ) ); 75 75 f( dev_xp , 0 ); 76 remote_ spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );76 remote_busylock_release( XPTR( dev_cxy , &dev_ptr->wait_lock ) ); 77 77 } 78 78 … … 83 83 // get IOB chdev descriptor cluster and local pointer 84 84 cxy_t dev_cxy = GET_CXY( dev_xp ); 85 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );85 chdev_t * dev_ptr = GET_PTR( dev_xp ); 86 86 87 87 // get pointer on set_ptpr function … … 89 89 90 90 // call driver function 91 remote_ spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );91 remote_busylock_acquire( XPTR( dev_cxy , &dev_ptr->wait_lock ) ); 92 92 f( dev_xp , wdata ); 93 remote_ spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );93 remote_busylock_release( XPTR( dev_cxy , &dev_ptr->wait_lock ) ); 94 94 95 95 } … … 101 101 // get IOB chdev descriptor cluster and local pointer 102 102 cxy_t dev_cxy = GET_CXY( dev_xp ); 103 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );103 chdev_t * dev_ptr = GET_PTR( dev_xp ); 104 104 105 105 // get pointer on inval_page function … … 107 107 108 108 // call driver function 109 remote_ spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );109 remote_busylock_acquire( XPTR( dev_cxy , &dev_ptr->wait_lock ) ); 110 110 f( dev_xp , vpn ); 111 remote_ spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );111 remote_busylock_release( XPTR( dev_cxy , &dev_ptr->wait_lock ) ); 112 112 } 113 113 … … 120 120 // get IOB chdev descriptor cluster and local pointer 121 121 cxy_t dev_cxy = GET_CXY( dev_xp ); 122 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );122 chdev_t * dev_ptr = GET_PTR( dev_xp ); 123 123 124 124 // get pointer on the functions … … 128 128 129 129 // call driver function 130 remote_ spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );130 remote_busylock_acquire( XPTR( dev_cxy , &dev_ptr->wait_lock ) ); 131 131 *error = f_get_error( dev_xp ); 132 132 *srcid = f_get_srcid( dev_xp ); 133 133 *bvar = f_get_bvar( dev_xp ); 134 remote_ spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );134 remote_busylock_release( XPTR( dev_cxy , &dev_ptr->wait_lock ) ); 135 135 } 136 136 -
trunk/kernel/devices/dev_iob.h
r457 r565 27 27 #include <kernel_config.h> 28 28 #include <hal_kernel_types.h> 29 #include <spinlock.h>30 29 31 30 /***************************************************************************************** -
trunk/kernel/devices/dev_ioc.c
r492 r565 216 216 thread_t * server = (thread_t *)hal_remote_lpt( XPTR( ioc_cxy , &ioc_ptr->server ) ); 217 217 core_t * core = (core_t *)hal_remote_lpt( XPTR( ioc_cxy , &server->core ) ); 218 lid_t lid = (lid_t)hal_remote_l w( XPTR( ioc_cxy , &core->lid ) );218 lid_t lid = (lid_t)hal_remote_l32( XPTR( ioc_cxy , &core->lid ) ); 219 219 220 220 // mask the IRQ -
trunk/kernel/devices/dev_mmc.c
r492 r565 28 28 #include <chdev.h> 29 29 #include <thread.h> 30 #include <remote_busylock.h> 30 31 #include <dev_mmc.h> 31 32 … … 76 77 dev_cmd_t * cmd = (dev_cmd_t *)hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->cmd ) ); 77 78 78 // get the MMC device remote spinlock79 remote_ spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );79 // get the MMC device remote busylock 80 remote_busylock_acquire( XPTR( dev_cxy , &dev_ptr->wait_lock ) ); 80 81 81 82 // call driver command 82 83 cmd( XPTR( local_cxy , this ) ); 83 84 84 // release the MMC device remote spinlock85 remote_ spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );85 // release the MMC device remote busylock 86 remote_busylock_release( XPTR( dev_cxy , &dev_ptr->wait_lock ) ); 86 87 87 88 // return operation status -
trunk/kernel/devices/dev_mmc.h
r457 r565 27 27 #include <kernel_config.h> 28 28 #include <hal_kernel_types.h> 29 #include <spinlock.h>30 29 31 30 /***************************************************************************************** … … 46 45 * As these operations consume few cycles, and access conflicts are expected to be 47 46 * rare events, the calling threads use a busy waiting strategy to get the device 48 * spinlock, but do not register in the device waiting queue, and no server thread47 * busylock, but do not register in the device waiting queue, and no server thread 49 48 * is used for this device. 50 49 ****************************************************************************************/ -
trunk/kernel/devices/dev_nic.c
r492 r565 99 99 core_t * core = thread_ptr->core; 100 100 101 // check thread can yield 102 assert( (thread_ptr->busylocks == 0), 103 "cannot yield : busylocks = %d\n", thread_ptr->busylocks ); 104 101 105 #if DEBUG_DEV_NIC_RX 102 106 uint32_t cycle = (uint32_t)hal_get_cycles(); … … 133 137 dev_pic_enable_irq( core->lid , dev_xp ); 134 138 135 // block on THREAD_BLOCKED_IO condition and deschedule139 // block client thread on THREAD_BLOCKED_IO 136 140 thread_block( XPTR( local_cxy , thread_ptr ) , THREAD_BLOCKED_IO ); 141 142 // deschedule client thread 137 143 sched_yield("client blocked on I/O"); 138 144 … … 176 182 // get local pointer on core running this kernel thead 177 183 core_t * core = thread_ptr->core; 184 185 // check thread can yield 186 assert( (thread_ptr->busylocks == 0), 187 "cannot yield : busylocks = %d\n", thread_ptr->busylocks ); 178 188 179 189 #if DEBUG_DEV_NIC_RX … … 211 221 dev_pic_enable_irq( core->lid ,dev_xp ); 212 222 213 // block on THREAD_BLOCKED I/O condition and deschedule223 // block client thread on THREAD_BLOCKED I/O condition 214 224 thread_block( XPTR( local_cxy , thread_ptr ) , THREAD_BLOCKED_IO ); 225 226 // deschedule client thread 215 227 sched_yield("client blocked on I/O"); 216 228 -
trunk/kernel/devices/dev_pic.c
r483 r565 28 28 #include <string.h> 29 29 #include <thread.h> 30 #include <remote_busylock.h> 30 31 #include <hal_drivers.h> 31 32 #include <dev_pic.h> … … 216 217 } 217 218 218 ///////////////////////////// 219 /////////////////////////////////// 219 220 void dev_pic_inputs_display( void ) 220 221 { 221 222 uint32_t k; 222 uint32_t save_sr;223 223 224 224 // get pointers on TXT0 chdev … … 231 231 232 232 // get TXT0 lock in busy waiting mode 233 remote_ spinlock_lock_busy( lock_xp , &save_sr);233 remote_busylock_acquire( lock_xp ); 234 234 235 235 nolock_printk("\n***** iopic_inputs\n"); … … 253 253 254 254 // release TXT0 lock 255 remote_ spinlock_unlock_busy( lock_xp , save_sr);256 } 257 258 255 remote_busylock_release( lock_xp ); 256 } 257 258 -
trunk/kernel/devices/dev_txt.c
r540 r565 2 2 * dev_txt.c - TXT (Text Terminal) generic device API implementation. 3 3 * 4 * Author Alain Greiner (2016 )4 * Author Alain Greiner (2016,2017,2018) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 27 27 #include <hal_drivers.h> 28 28 #include <thread.h> 29 #include <remote_busylock.h> 29 30 #include <chdev.h> 30 31 #include <rpc.h> … … 38 39 extern chdev_directory_t chdev_dir; // allocated in kernel_init.c 39 40 41 40 42 #if (DEBUG_SYS_READ & 1) 41 43 extern uint32_t enter_txt_read; … … 48 50 #endif 49 51 50 //////////////////////////////////////// 52 /////////////////////////////////////////////////// 51 53 const char * dev_txt_type_str( dev_txt_cmd_t type ) 52 54 { … … 81 83 txt->ext.txt.owner_xp = XPTR_NULL; 82 84 xlist_root_init( XPTR( local_cxy, &txt->ext.txt.root ) ); 83 remote_ spinlock_init( XPTR( local_cxy , &txt->ext.txt.lock ));85 remote_busylock_init( XPTR( local_cxy , &txt->ext.txt.lock ), LOCK_CHDEV_TXTLIST ); 84 86 85 87 // call driver init function … … 257 259 } 258 260 259 ////////////////////////////////////////////// 260 error_t dev_txt_sync_write( c har* buffer,261 uint32_t count )261 //////////////////////////////////////////////// 262 error_t dev_txt_sync_write( const char * buffer, 263 uint32_t count ) 262 264 { 263 265 // get extended pointer on TXT[0] chdev … … 269 271 // get TXTO chdev cluster and local pointer 270 272 cxy_t dev_cxy = GET_CXY( dev_xp ); 271 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );273 chdev_t * dev_ptr = GET_PTR( dev_xp ); 272 274 273 275 // get driver command function -
trunk/kernel/devices/dev_txt.h
r539 r565 28 28 #include <hal_kernel_types.h> 29 29 #include <xlist.h> 30 #include <remote_ spinlock.h>30 #include <remote_busylock.h> 31 31 32 32 /**** Forward declarations ****/ … … 57 57 { 58 58 xptr_t owner_xp; /*! ext. pointer on current process owner (reference) */ 59 xlist_entry_t root; /*! root of list of processes attached to same TXT*/60 remote_ spinlock_t lock; /*! lock protecting this list */59 xlist_entry_t root; /*! root of list of processes attached to same TXT */ 60 remote_busylock_t lock; /*! lock protecting this list */ 61 61 } 62 62 txt_extend_t; … … 103 103 typedef struct txt_sync_args_s 104 104 { 105 xptr_t dev_xp; /*! extended pointer on the TXT0_TX device descriptor*/106 c har * buffer; /*! local pointer on characters array*/107 uint32_t count; /*! number of characters in buffer*/105 xptr_t dev_xp; /*! extended pointer on the TXT0_TX device descriptor */ 106 const char * buffer; /*! local pointer on characters array */ 107 uint32_t count; /*! number of characters in buffer */ 108 108 uint32_t channel; /*! channel, aka which tty to write to */ 109 109 } … … 172 172 * @ returns 0 if success / returns EINVAL if error. 173 173 ***************************************************************************************/ 174 error_t dev_txt_sync_write( c har * buffer,175 uint32_t count );174 error_t dev_txt_sync_write( const char * buffer, 175 uint32_t count ); 176 176 177 177 #endif /* _DEV_TXT_H_ */
Note: See TracChangeset
for help on using the changeset viewer.