Changeset 66
- Timestamp:
- Jun 27, 2017, 9:56:10 AM (7 years ago)
- Location:
- trunk/kernel/drivers/soclib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/drivers/soclib/soclib_tty.c
r4 r66 33 33 { 34 34 // get extended pointer on TTY-SOCLIB peripheral base address 35 xptr_t tty_xp = chdev->base; 35 xptr_t tty_xp = chdev->base; 36 36 37 37 // get SOCLIB_TTY device cluster and local pointer 38 38 cxy_t tty_cxy = GET_CXY( tty_xp ); 39 39 uint32_t * tty_ptr = (uint32_t *)GET_PTR( tty_xp ); 40 40 41 41 // mask both TTY_RX_IRQ and TTY_TX_IRQ 42 42 hal_remote_sw( XPTR( tty_cxy , tty_ptr + TTY_CONFIG_REG ) , 0 ); 43 44 } // soclib_tty_init() 43 } 45 44 46 45 ////////////////////////////////////////////////////////////// … … 54 53 uint32_t type = hal_remote_lw ( XPTR( th_cxy , &th_ptr->command.txt.type ) ); 55 54 xptr_t dev_xp = (xptr_t)hal_remote_lwd( XPTR( th_cxy , &th_ptr->command.txt.dev_xp ) ); 56 55 57 56 // get TXT device cluster and local pointer 58 57 cxy_t dev_cxy = GET_CXY( dev_xp ); … … 70 69 uint32_t * base = tty_ptr + TTY_SPAN * channel; 71 70 72 if( type == TXT_READ ) // descheduling strategy for calling th ead71 if( type == TXT_READ ) // descheduling strategy for calling thread 73 72 { 74 73 // unmask RX_IRQ (data transfer will be done by the TTY_RX ISR) … … 78 77 hal_remote_atomic_cas( config_xp , old , new ); 79 78 80 // Block and deschedule server thread 79 // Block and deschedule server thread 81 80 thread_block( CURRENT_THREAD , THREAD_BLOCKED_DEV_ISR ); 82 81 sched_yield(); … … 90 89 hal_remote_atomic_cas( config_xp , old , new ); 91 90 92 // Block and deschedule server thread 91 // Block and deschedule server thread 93 92 thread_block( CURRENT_THREAD , THREAD_BLOCKED_DEV_ISR ); 94 93 sched_yield(); … … 96 95 else if( type == TXT_SYNC_WRITE ) // busy waiting strategy for calling thread 97 96 { 98 uint32_t status; 97 uint32_t status; 99 98 bool_t empty; 100 99 uint32_t i; … … 104 103 xptr_t buf_xp = hal_remote_lwd( XPTR( th_cxy , &th_ptr->command.txt.buf_xp ) ); 105 104 106 // loop on characters 105 // loop on characters 107 106 for( i = 0 ; i < count ; i++ ) 108 { 107 { 109 108 do 110 109 { … … 121 120 hal_remote_sb( XPTR( tty_cxy , base + TTY_WRITE_REG ) , byte ); 122 121 } 123 } 122 } 124 123 while ( empty == false ); 125 124 } 126 125 } 127 } // soclib_tty_command() 128 126 } 129 127 130 128 ///////////////////////////////////////////////////////////////// … … 193 191 else if( type == TXT_WRITE ) // write a string 194 192 { 195 // loop on characters 193 // loop on characters 196 194 for( i = 0 ; i < count ; i++ ) 197 { 195 { 198 196 // get TTY_STATUS_REG 199 197 status = hal_remote_lw( XPTR( tty_cxy , base + TTY_STATUS_REG ) ); … … 209 207 else // TTY_TX full => update command arguments and exit ISR for retry 210 208 { 211 hal_remote_sw ( XPTR( client_cxy , &client_ptr->command.txt.count ), count-i ); 209 hal_remote_sw ( XPTR( client_cxy , &client_ptr->command.txt.count ), count-i ); 212 210 hal_remote_swd( XPTR( client_cxy , &client_ptr->command.txt.buf_xp ), buf_xp+i ); 213 211 return; … … 229 227 // unblock client thread 230 228 thread_unblock( client_xp , THREAD_BLOCKED_IO ); 231 232 } // soclib_tty_isr() 233 234 229 } 230 -
trunk/kernel/drivers/soclib/soclib_tty.h
r4 r66 35 35 36 36 /**************************************************************************************** 37 * SOCLIB_TTY registers offsets 37 * SOCLIB_TTY registers offsets 38 38 ***************************************************************************************/ 39 39 … … 46 46 47 47 /**************************************************************************************** 48 * masks for TTY_STATUS_REG 48 * masks for TTY_STATUS_REG 49 49 ***************************************************************************************/ 50 50 … … 53 53 54 54 /**************************************************************************************** 55 * masks for TTY_CONFIG_REG 55 * masks for TTY_CONFIG_REG 56 56 ***************************************************************************************/ 57 57 … … 61 61 /**************************************************************************************** 62 62 * This function masks both the TTY_RX and TTY_TX IRQs. 63 * Thes IRQs are unmasked by the soclib_tty_cmd() function.63 * These IRQs are unmasked by the soclib_tty_cmd() function. 64 64 **************************************************************************************** 65 65 * @ chdev : pointer on the TXT chdev descriptor. … … 83 83 /**************************************************************************************** 84 84 * 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 chdev queue:86 * - if TXT_READ, it transfer one byte from the TTY_READ_REG to the command buffer.85 * It gets the command arguments from the first client thread in the TXT chdev queue: 86 * - if TXT_READ, it transfers one byte from the TTY_READ_REG to the command buffer. 87 87 * It simply returns for retry if TTY_READ_REG is empty. 88 * - if TXT_WRITE, it tries to transfer several bytes from the command buffer to the 89 * TTY_WRITE_REG. If the TTY_WRITE_REG is full, it updates the "count" and "buffer" 88 * - if TXT_WRITE, it tries to transfer several bytes from the command buffer to the 89 * TTY_WRITE_REG. If the TTY_WRITE_REG is full, it updates the "count" and "buffer" 90 90 * command arguments and returns for retry. 91 * When the I/O operation is completed, it set the status field in the command, unblock92 * the server thread, and unblock the client thread.91 * When the I/O operation is completed, it sets the status field in the command, unblocks 92 * the server thread, and unblocks the client thread. 93 93 **************************************************************************************** 94 94 * @ chdev : local pointer on TXT chdev descriptor.
Note: See TracChangeset
for help on using the changeset viewer.