Changeset 570 for trunk/hal/tsar_mips32/drivers/soclib_tty.c
- Timestamp:
- Oct 5, 2018, 12:08:35 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/tsar_mips32/drivers/soclib_tty.c
r492 r570 6 6 * Copyright (c) UPMC Sorbonne Universites 7 7 * 8 * This file is part of ALMOS-MKH. .8 * This file is part of ALMOS-MKH. 9 9 * 10 10 * ALMOS-MKH. is free software; you can redistribute it and/or modify it … … 12 12 * the Free Software Foundation; version 2.0 of the License. 13 13 * 14 * ALMOS-MKH .is distributed in the hope that it will be useful, but14 * ALMOS-MKH is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of 16 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU … … 18 18 * 19 19 * You should have received a copy of the GNU General Public License 20 * along with ALMOS-MKH .; if not, write to the Free Software Foundation,20 * along with ALMOS-MKH; if not, write to the Free Software Foundation, 21 21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 22 */ … … 27 27 #include <chdev.h> 28 28 #include <soclib_tty.h> 29 #include <remote_spinlock.h>30 29 #include <thread.h> 31 30 #include <printk.h> … … 50 49 //////////////////////////////////////////////////////////////////////////////////// 51 50 // These global variables implement the TTY_RX FIFOs (one per channel) 51 //////////////////////////////////////////////////////////////////////////////////// 52 // Implementation note: 53 // We allocate - in each cluster - two arrays of FIFOs containing as many entries 54 // as the total number of TXT channels, but all entries are not used in all 55 // clusters: for a given cluster K, a given entry corresponding to a given channel 56 // and a given direction is only used if the associated chdev is in cluster K. 57 // With this policy, the driver can ignore the actual placement of chdevs. 52 58 //////////////////////////////////////////////////////////////////////////////////// 53 59 … … 79 85 // set TTY_RX_IRQ_ENABLE 80 86 reg_xp = XPTR( tty_cxy , tty_ptr + (channel * TTY_SPAN) + TTY_RX_IRQ_ENABLE ); 81 hal_remote_s w( reg_xp , 1 );87 hal_remote_s32( reg_xp , 1 ); 82 88 83 89 // reset TTY_TX_IRQ_ENABLE 84 90 reg_xp = XPTR( tty_cxy , tty_ptr + (channel * TTY_SPAN) + TTY_TX_IRQ_ENABLE ); 85 hal_remote_s w( reg_xp , 0 );91 hal_remote_s32( reg_xp , 0 ); 86 92 87 93 // reset relevant FIFO … … 112 118 113 119 // get command arguments 114 uint32_t type = hal_remote_l w( XPTR( th_cxy , &th_ptr->txt_cmd.type ) );115 xptr_t buf_xp = hal_remote_l wd( XPTR( th_cxy , &th_ptr->txt_cmd.buf_xp ) );116 uint32_t count = hal_remote_l w( XPTR( th_cxy , &th_ptr->txt_cmd.count ) );120 uint32_t type = hal_remote_l32 ( XPTR( th_cxy , &th_ptr->txt_cmd.type ) ); 121 xptr_t buf_xp = hal_remote_l64( XPTR( th_cxy , &th_ptr->txt_cmd.buf_xp ) ); 122 uint32_t count = hal_remote_l32 ( XPTR( th_cxy , &th_ptr->txt_cmd.count ) ); 117 123 xptr_t error_xp = XPTR( th_cxy , &th_ptr->txt_cmd.error ); 118 124 … … 126 132 127 133 // get TXT device cluster and pointers 128 xptr_t dev_xp = (xptr_t)hal_remote_l wd( XPTR( th_cxy , &th_ptr->txt_cmd.dev_xp ) );134 xptr_t dev_xp = (xptr_t)hal_remote_l64( XPTR( th_cxy , &th_ptr->txt_cmd.dev_xp ) ); 129 135 cxy_t dev_cxy = GET_CXY( dev_xp ); 130 136 chdev_t * dev_ptr = GET_PTR( dev_xp ); 131 137 132 138 // get cluster and pointers for SOCLIB_TTY peripheral base segment 133 xptr_t tty_xp = (xptr_t)hal_remote_l wd( XPTR( dev_cxy , &dev_ptr->base ) );139 xptr_t tty_xp = (xptr_t)hal_remote_l64( XPTR( dev_cxy , &dev_ptr->base ) ); 134 140 cxy_t tty_cxy = GET_CXY( tty_xp ); 135 141 uint32_t * tty_ptr = GET_PTR( tty_xp ); 136 142 137 143 // get TTY channel index and channel base address 138 uint32_t channel = hal_remote_l w( XPTR( dev_cxy , &dev_ptr->channel ) );144 uint32_t channel = hal_remote_l32( XPTR( dev_cxy , &dev_ptr->channel ) ); 139 145 uint32_t * base = tty_ptr + TTY_SPAN * channel; 140 146 … … 173 179 174 180 // enable TX_IRQ 175 hal_remote_s w( XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE ) , 1 );181 hal_remote_s32( XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE ) , 1 ); 176 182 } 177 183 else // block & deschedule if TX_FIFO full … … 186 192 187 193 // set error status in command and return 188 hal_remote_s w( error_xp , 0 );194 hal_remote_s32( error_xp , 0 ); 189 195 } 190 196 /////////////////////////// … … 229 235 230 236 // set error status in command 231 hal_remote_s w( error_xp , 0 );237 hal_remote_s32( error_xp , 0 ); 232 238 } 233 239 else … … 268 274 cxy_t parent_cxy; // parent process cluster 269 275 process_t * parent_ptr; // local pointer on parent process 270 xptr_t children_lock_xp; // extended pointer on children processes lock271 276 thread_t * parent_main_ptr; // extended pointer on parent process main thread 272 277 xptr_t parent_main_xp; // local pointer on parent process main thread … … 312 317 313 318 // try to move bytes until TTY_READ register empty 314 while( hal_remote_l w( status_xp ) & TTY_STATUS_RX_FULL )319 while( hal_remote_l32( status_xp ) & TTY_STATUS_RX_FULL ) 315 320 { 316 321 // get one byte from TTY_READ register & acknowledge RX_IRQ … … 335 340 owner_cxy = GET_CXY( owner_xp ); 336 341 owner_ptr = GET_PTR( owner_xp ); 337 owner_pid = hal_remote_l w( XPTR( owner_cxy , &owner_ptr->pid ) );342 owner_pid = hal_remote_l32( XPTR( owner_cxy , &owner_ptr->pid ) ); 338 343 339 344 // block TXT owner process only if it is not the INIT process … … 341 346 { 342 347 // get parent process descriptor pointers 343 parent_xp = hal_remote_l wd( XPTR( owner_cxy , &owner_ptr->parent_xp ) );348 parent_xp = hal_remote_l64( XPTR( owner_cxy , &owner_ptr->parent_xp ) ); 344 349 parent_cxy = GET_CXY( parent_xp ); 345 350 parent_ptr = GET_PTR( parent_xp ); 346 347 // get extended pointer on lock protecting children list in parent process348 children_lock_xp = XPTR( parent_cxy , &parent_ptr->children_lock );349 351 350 352 // get pointers on the parent process main thread … … 366 368 PROCESS_TERM_STOP ); 367 369 368 // take the children lock and unblock the parent process main thread 369 remote_spinlock_lock( children_lock_xp ); 370 // unblock the parent process main thread 370 371 thread_unblock( parent_main_xp , THREAD_BLOCKED_WAIT ); 371 remote_spinlock_unlock( children_lock_xp );372 372 373 373 return; … … 393 393 owner_cxy = GET_CXY( owner_xp ); 394 394 owner_ptr = GET_PTR( owner_xp ); 395 owner_pid = hal_remote_l w( XPTR( owner_cxy , &owner_ptr->pid ) );395 owner_pid = hal_remote_l32( XPTR( owner_cxy , &owner_ptr->pid ) ); 396 396 397 397 // kill TXT owner process only if it is not the INIT process … … 399 399 { 400 400 // get parent process descriptor pointers 401 parent_xp = hal_remote_l wd( XPTR( owner_cxy , &owner_ptr->parent_xp ) );401 parent_xp = hal_remote_l64( XPTR( owner_cxy , &owner_ptr->parent_xp ) ); 402 402 parent_cxy = GET_CXY( parent_xp ); 403 403 parent_ptr = GET_PTR( parent_xp ); 404 405 // get extended pointer on lock protecting children list in parent process406 children_lock_xp = XPTR( parent_cxy , &parent_ptr->children_lock );407 404 408 405 // get pointers on the parent process main thread … … 424 421 PROCESS_TERM_KILL ); 425 422 426 // take the children lock and unblock the parent process main thread 427 remote_spinlock_lock( children_lock_xp ); 423 // unblock the parent process main thread 428 424 thread_unblock( parent_main_xp , THREAD_BLOCKED_WAIT ); 429 remote_spinlock_unlock( children_lock_xp );430 425 431 426 return; … … 479 474 { 480 475 // write one byte to TTY_WRITE register if empty / exit loop if full 481 if( (hal_remote_l w( status_xp ) & TTY_STATUS_TX_FULL) == 0 )476 if( (hal_remote_l32( status_xp ) & TTY_STATUS_TX_FULL) == 0 ) 482 477 { 483 478 // get one byte from TX_FIFO … … 499 494 500 495 // disable TX_IRQ 501 hal_remote_s w( XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE ) , 0 );496 hal_remote_s32( XPTR( tty_cxy , base + TTY_TX_IRQ_ENABLE ) , 0 ); 502 497 503 498 // unblock TXT_TX server thread … … 531 526 uint32_t i; 532 527 533 xptr_t dev_xp = ((txt_sync_args_t *)args)->dev_xp;534 c har* buffer = ((txt_sync_args_t *)args)->buffer;535 uint32_t count = ((txt_sync_args_t *)args)->count;528 xptr_t dev_xp = ((txt_sync_args_t *)args)->dev_xp; 529 const char * buffer = ((txt_sync_args_t *)args)->buffer; 530 uint32_t count = ((txt_sync_args_t *)args)->count; 536 531 537 // get TXT0chdev cluster and local pointer532 // get chdev cluster and local pointer 538 533 cxy_t dev_cxy = GET_CXY( dev_xp ); 539 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );534 chdev_t * dev_ptr = GET_PTR( dev_xp ); 540 535 541 536 // get extended pointer on TTY channel base address 542 xptr_t tty_xp = (xptr_t)hal_remote_l wd( XPTR( dev_cxy , &dev_ptr->base ) );537 xptr_t tty_xp = (xptr_t)hal_remote_l64( XPTR( dev_cxy , &dev_ptr->base ) ); 543 538 544 539 // get TTY channel segment cluster and local pointer 545 540 cxy_t tty_cxy = GET_CXY( tty_xp ); 546 uint32_t * tty_ptr = (uint32_t *)GET_PTR( tty_xp );541 uint32_t * tty_ptr = GET_PTR( tty_xp ); 547 542 548 543 // get extended pointers on TTY_WRITE & TTY_STATUS registers … … 550 545 xptr_t status_xp = XPTR( tty_cxy , tty_ptr + TTY_STATUS ); 551 546 552 // loop on characters (busy waiting policy)547 // loop on characters 553 548 for( i = 0 ; i < count ; i++ ) 554 549 { 550 // busy waiting policy on TTY_STATUS register 555 551 do 556 552 { 557 553 // get TTY_STATUS 558 status = hal_remote_l w( status_xp );554 status = hal_remote_l32( status_xp ); 559 555 empty = ( (status & TTY_STATUS_TX_FULL) == 0 ); 560 556
Note: See TracChangeset
for help on using the changeset viewer.