| 27 | | |
| 28 | | === unsigned int '''_tty_write'''( const char* buffer, unsigned int length, unsigned int channel ) === |
| 29 | | This non-blocking function writes a character string from a fixed-length buffer to a TTY terminal identified by the channel argument. This function is intended to be used to handle a system call, and should not be used by the kernel for log messages on TTY 0. If channel argument is 0xFFFFFFFF, the TTY index is found in the task context. |
| 30 | | It is non blocking: it tests the TTY_STATUS register, and stops the transfer as soon as the TTY_STATUS[WRITE] bit is set. |
| 31 | | Returns the number of characters that have been written. |
| 32 | | |
| 33 | | === unsigned int '''_tty_read'''( char* buffer, unsigned int length, unsigned int channel ) === |
| 34 | | This non-blocking function fetches one character from the terminal identified by the channel argument. If the channel argument is 0xFFFFFFFF, the channel index is obtained from the current task context. |
| 35 | | It uses the TTY_GET_IRQ[tty_id] interrupt and the buffer must have been filled by the TTY_ISR. |
| 36 | | It test the _tty_rx_full[tty_id] variable, read the _tty_rx_buf[tty_id] buffer, writes this character to the target buffer, and resets the_tty_rx_full[tty_id] register. The length argument is not used. |
| 37 | | Returns the number of characters that have been read (0/1). |
| 38 | | |
| 39 | | === void '''_tty_get_lock'''( unsigned int channel, unsigned int* save_sr_ptr ) === |
| 40 | | This blocking function try to take the lock protecting exclusive access to TTY terminal identified by the "channel" argument. |
| 41 | | It enters a critical section before taking the lock, and save the SR value at address defined by the ''save_sr_ptr'' argument. |
| 42 | | It returns only when the lock has been successfully taken. |
| 43 | | |
| 44 | | === void '''_tty_release_lock'''( unsigned int channel, unsigned int* save_sr_ptr ) === |
| 45 | | This function releases the lock protecting exclusive access to TTY terminal identified by the channel argument. |
| 46 | | It exit the critical section after lock release, and restore SR value from address defined by the ''save_sr_ptr'' argument. |