Changeset 247 for trunk/hal/x86_64/drivers/txt_rs232.h
- Timestamp:
- Jul 20, 2017, 1:04:15 PM (6 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/x86_64/drivers/txt_rs232.h
r239 r247 1 1 /* 2 * soclib_tty.c - soclib tty driver definition.2 * txt_rs232.c - RS232 driver definitions 3 3 * 4 * Author Alain Greiner (2016) 5 * 6 * Copyright (c) UPMC Sorbonne Universites 4 * Copyright (c) 2017 Maxime Villard 7 5 * 8 6 * This file is part of ALMOS-MKH. … … 18 16 * 19 17 * You should have received a copy of the GNU General Public License 20 * along with ALMOS- kernel; if not, write to the Free Software Foundation,18 * along with ALMOS-MKH; if not, write to the Free Software Foundation, 21 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 20 */ … … 24 22 #include <dev_txt.h> 25 23 #include <chdev.h> 26 #include <spinlock.h>27 24 25 void txt_rs232_init(chdev_t *chdev); 26 void txt_rs232_cmd(xptr_t thread_xp); 27 void txt_rs232_isr(chdev_t *chdev); 28 28 29 /****************************************************************************************30 * This driver supports the soclib_multi_tty component.31 * It implements the generic TXT device API:32 * - transfer one single character from TTY to command "buffer" if to_mem is non-zero.33 * - transfer "count" characters from command "buffer" to TTY if "to_mem is zero.34 ***************************************************************************************/35 36 /****************************************************************************************37 * SOCLIB_TTY registers offsets38 ***************************************************************************************/39 40 #define TTY_WRITE_REG 041 #define TTY_STATUS_REG 142 #define TTY_READ_REG 243 #define TTY_CONFIG_REG 344 45 #define TTY_SPAN 4 // number of registers per channel46 47 /****************************************************************************************48 * masks for TTY_STATUS_REG49 ***************************************************************************************/50 51 #define TTY_STATUS_RX_FULL 1 // TTY_READ_REG full if 152 #define TTY_STATUS_TX_FULL 2 // TTY_WRITE_REG full if 153 54 /****************************************************************************************55 * masks for TTY_CONFIG_REG56 ***************************************************************************************/57 58 #define TTY_CONFIG_RX_ENABLE 1 // TTY_RX IRQ enabled if 159 #define TTY_CONFIG_TX_ENABLE 2 // TTY_TX IRQ enabled if 160 61 /****************************************************************************************62 * This function masks both the TTY_RX and TTY_TX IRQs.63 * These IRQs are unmasked by the soclib_tty_cmd() function.64 ****************************************************************************************65 * @ chdev : pointer on the TXT chdev descriptor.66 ***************************************************************************************/67 void soclib_tty_init( chdev_t * chdev );68 69 /****************************************************************************************70 * This function handles the command registered in the thread descriptor identified71 * by the <xp_thread> argument.72 * - For the TXT_READ and TXT_WRITE commands, it only unmask the proper TTY_RX / TTY_TX73 * IRQ, and blocks the TXT device server thread on the THREAD_BLOCKED_DEV_ISR, as the74 * data transfer is done by the ISR.75 * - For the TXT_SYNC_READ command, that should be only used by the kernel do display76 * log or debug messages, it directly access the SOCLIB_TTY registers, using77 * a busy waiting policy if required.78 ****************************************************************************************79 * @ thread_xp : extended pointer on client thread descriptor.80 ***************************************************************************************/81 void soclib_tty_cmd( xptr_t thread_xp );82 83 /****************************************************************************************84 * This ISR should be executed only for the TXT_READ and TXT_WRITE commands.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 * 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 the89 * TTY_WRITE_REG. If the TTY_WRITE_REG is full, it updates the "count" and "buffer"90 * command arguments and returns for retry.91 * When the I/O operation is completed, it sets the status field in the command, unblocks92 * the server thread, and unblocks the client thread.93 ****************************************************************************************94 * @ chdev : local pointer on TXT chdev descriptor.95 ***************************************************************************************/96 void soclib_tty_isr( chdev_t * chdev );97
Note: See TracChangeset
for help on using the changeset viewer.