Changeset 539 for trunk/hal/tsar_mips32
- Timestamp:
- Sep 21, 2018, 10:21:42 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/tsar_mips32/drivers/soclib_mtty.c
r538 r539 48 48 #endif 49 49 50 extern chdev_directory_t chdev_dir; // allocated in the kernel_init.c file. 51 extern spinlock_t txt0_lock; // Initialized in kernel_init.c 50 52 //////////////////////////////////////////////////////////////////////////////////// 51 53 // These global variables implement the MTTY_RX FIFOs (one per channel) … … 538 540 char * buffer = ((txt_sync_args_t *)args)->buffer; 539 541 uint32_t count = ((txt_sync_args_t *)args)->count; 542 uint32_t channel = ((txt_sync_args_t *)args)->channel; 540 543 541 544 // get TXT0 chdev cluster and local pointer … … 554 557 xptr_t status_xp = XPTR( tty_cxy , tty_ptr + MTTY_STATUS ); 555 558 559 reg_t save_sr; 560 556 561 // loop on characters (busy waiting policy) 557 562 for( i = 0 ; i < count ; i++ ) 558 563 { 564 // This is the MTTY multiplexing 565 // Before each character, we send the destination TTY number for this char. 566 // The two bytes (dest number + char) must be sent consecutively, 567 // so to guarantee this atomicity, we use a lock to prevent other 568 // concurrent server DEV threads to write a byte in between our two bytes 569 570 // Get the lock 571 spinlock_lock_busy( &txt0_lock, &save_sr ); 572 573 // Send the destination TTY number 559 574 do 560 575 { … … 564 579 565 580 // transfer one byte if TX buffer empty 581 if ( empty ) hal_remote_sb( write_xp , channel + '0' ); 582 583 } 584 while ( empty == false ); 585 586 // Send the character 587 do 588 { 589 // get MTTY_STATUS 590 status = hal_remote_lw( status_xp ); 591 empty = ( (status & MTTY_STATUS_TX_FULL) == 0 ); 592 593 // transfer one byte if TX buffer empty 566 594 if ( empty ) hal_remote_sb( write_xp , buffer[i] ); 567 595 } 568 596 while ( empty == false ); 597 598 // Release the lock 599 spinlock_unlock_busy( &txt0_lock, save_sr ); 569 600 } 570 601 } // end soclib_mtty_aux()
Note: See TracChangeset
for help on using the changeset viewer.