/** * Initializes the serial controller. */ void sio_init( void ) { /* ** Select bank 1 and set the data rate. */ __outb( UA4_LCR, UA4_LCR_BANK1 ); __outb( UA4_LBGD_L, BAUD_LOW_BYTE( BAUD_9600 ) ); __outb( UA4_LBGD_H, BAUD_HIGH_BYTE( BAUD_9600 ) ); /* ** Select bank 0, and at the same time set the LCR for our ** data characteristics. */ __outb( UA4_LCR, UA4_LCR_BANK0 | UA4_LCR_BITS_8 | UA4_LCR_1_STOP_BIT | UA4_LCR_NO_PARITY ); /* ** Set Modem Control Register to send and receive ** This is necessary to receive data from the ADDS terminals */ __outb( UA4_MCR, UA4_MCR_DTR | UA4_MCR_RTS | UA4_MCR_ISEN ); __install_isr(INT_VEC_SERIAL_PORT_1, io_interrupt_handler); __outb(UA4_IER, UA4_IER_RX_INT_ENABLE | UA4_IER_TX_INT_ENABLE); }
/* ** _init_sio ** ** Initialize the UART chip. */ void _init_sio( void ) { // // Initialize SIO variables. // _memclr( (void *) g_inbuffer, sizeof(g_inbuffer) ); g_inlast = g_innext = g_inbuffer; g_incount = 0; _memclr( (void *) g_outbuffer, sizeof(g_outbuffer) ); g_outlast = g_outnext = g_outbuffer; g_outcount = 0; g_sending = 0; // // Next, initialize the UART. // // Initialize the FIFOs // // this is a bizarre little sequence of operations __outb( UA4_FCR, 0x20 ); __outb( UA4_FCR, 0x00 ); // reset __outb( UA4_FCR, UA5_FCR_FIFO_EN ); // 0x01 __outb( UA4_FCR, UA5_FCR_FIFO_EN | UA5_FCR_RXSR ); // 0x03 __outb( UA4_FCR, UA5_FCR_FIFO_EN | UA5_FCR_RXSR | UA5_FCR_TXSR ); // 0x07 // disable interrupts __outb( UA4_IER, 0 ); // select bank 1 and set the data rate __outb( UA4_LCR, UA4_LCR_BANK1 ); __outb( UA4_LBGD_L, BAUD_LOW_BYTE( BAUD_9600 ) ); __outb( UA4_LBGD_H, BAUD_HIGH_BYTE( BAUD_9600 ) ); // Select bank 0, and at the same time set the LCR for our // data characteristics. __outb( UA4_LCR, UA4_LCR_BANK0 | UA4_LCR_BITS_8 | UA4_LCR_1_STOP_BIT | UA4_LCR_NO_PARITY ); // Set the ISEN bit to enable the interrupt request signal. __outb( UA4_MCR, UA4_MCR_ISEN | UA4_MCR_DTR | UA4_MCR_RTS ); // Install our ISR __install_isr( INT_VEC_SERIAL_PORT_1, _isr_sio ); // Enable device interrupts. __outb( UA4_IER, UA4_IER_TX_INT_ENABLE | UA4_IER_RX_INT_ENABLE ); // Report that we're done. c_puts( " sio" ); }