1998-06-22 09:28:03 +00:00
|
|
|
/*
|
|
|
|
|
* This file contains the termios TTY driver for the Motorola MC68681.
|
|
|
|
|
*
|
|
|
|
|
* This part is available from a number of secondary sources.
|
|
|
|
|
* In particular, we know about the following:
|
|
|
|
|
*
|
|
|
|
|
* + Exar 88c681 and 68c681
|
|
|
|
|
*
|
1999-11-17 17:51:34 +00:00
|
|
|
* COPYRIGHT (c) 1989-1999.
|
1998-06-22 09:28:03 +00:00
|
|
|
* On-Line Applications Research Corporation (OAR).
|
|
|
|
|
*
|
|
|
|
|
* The license and distribution terms for this file may be
|
|
|
|
|
* found in the file LICENSE in this distribution or at
|
2003-09-04 Joel Sherrill <joel@OARcorp.com>
* ide/ata.c, ide/ata.h, ide/ata_internal.h, ide/ide_controller.c,
ide/ide_ctrl.h, ide/ide_ctrl_cfg.h, ide/ide_ctrl_io.h,
network/cs8900.c, network/cs8900.c.bsp, network/cs8900.h,
network/dec21140.c, network/elnk.c, network/open_eth.c,
network/sonic.c, network/sonic.h, rtc/icm7170.c, rtc/icm7170.h,
rtc/icm7170_reg.c, rtc/icm7170_reg2.c, rtc/icm7170_reg4.c,
rtc/icm7170_reg8.c, rtc/m48t08.c, rtc/m48t08.h, rtc/m48t08_reg.c,
rtc/m48t08_reg2.c, rtc/m48t08_reg4.c, rtc/m48t08_reg8.c, rtc/rtc.h,
rtc/rtcprobe.c, serial/mc68681.c, serial/mc68681.h,
serial/mc68681_p.h, serial/mc68681_reg.c, serial/mc68681_reg2.c,
serial/mc68681_reg4.c, serial/mc68681_reg8.c, serial/serial.h,
serial/z85c30.c, serial/z85c30.h, serial/z85c30_p.h,
serial/z85c30_reg.c: URL for license changed.
2003-09-04 18:53:19 +00:00
|
|
|
* http://www.rtems.com/license/LICENSE.
|
1998-06-22 09:28:03 +00:00
|
|
|
*
|
|
|
|
|
* $Id$
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <rtems.h>
|
|
|
|
|
#include <rtems/libio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
#include <libchip/serial.h>
|
1998-07-16 00:16:11 +00:00
|
|
|
#include <libchip/mc68681.h>
|
2001-03-14 19:42:49 +00:00
|
|
|
#include <libchip/sersupp.h>
|
1998-06-22 09:28:03 +00:00
|
|
|
#include "mc68681_p.h"
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Flow control is only supported when using interrupts
|
|
|
|
|
*/
|
1998-06-22 10:17:14 +00:00
|
|
|
|
1998-06-22 09:28:03 +00:00
|
|
|
console_fns mc68681_fns =
|
|
|
|
|
{
|
1998-07-09 23:30:02 +00:00
|
|
|
libchip_serial_default_probe, /* deviceProbe */
|
1998-06-22 09:28:03 +00:00
|
|
|
mc68681_open, /* deviceFirstOpen */
|
1998-07-15 23:20:33 +00:00
|
|
|
NULL, /* deviceLastClose */
|
1998-06-22 09:28:03 +00:00
|
|
|
NULL, /* deviceRead */
|
|
|
|
|
mc68681_write_support_int, /* deviceWrite */
|
|
|
|
|
mc68681_initialize_interrupts, /* deviceInitialize */
|
|
|
|
|
mc68681_write_polled, /* deviceWritePolled */
|
1998-06-23 14:55:21 +00:00
|
|
|
mc68681_set_attributes, /* deviceSetAttributes */
|
2008-09-07 03:44:14 +00:00
|
|
|
true /* deviceOutputUsesInterrupts */
|
1998-06-22 09:28:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
console_fns mc68681_fns_polled =
|
|
|
|
|
{
|
1998-07-09 23:30:02 +00:00
|
|
|
libchip_serial_default_probe, /* deviceProbe */
|
1998-06-22 09:28:03 +00:00
|
|
|
mc68681_open, /* deviceFirstOpen */
|
|
|
|
|
mc68681_close, /* deviceLastClose */
|
|
|
|
|
mc68681_inbyte_nonblocking_polled, /* deviceRead */
|
|
|
|
|
mc68681_write_support_polled, /* deviceWrite */
|
|
|
|
|
mc68681_init, /* deviceInitialize */
|
|
|
|
|
mc68681_write_polled, /* deviceWritePolled */
|
1998-06-23 14:55:21 +00:00
|
|
|
mc68681_set_attributes, /* deviceSetAttributes */
|
2008-09-07 03:44:14 +00:00
|
|
|
false, /* deviceOutputUsesInterrupts */
|
1998-06-22 09:28:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern void set_vector( rtems_isr_entry, rtems_vector_number, int );
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Console Device Driver Entry Points
|
|
|
|
|
*/
|
1998-06-22 10:17:14 +00:00
|
|
|
|
1998-06-23 16:02:52 +00:00
|
|
|
/*
|
|
|
|
|
* mc68681_baud_rate
|
|
|
|
|
*
|
|
|
|
|
* This routine returns the proper ACR bit and baud rate field values
|
|
|
|
|
* based on the requested baud rate. The baud rate set to be used
|
|
|
|
|
* must be configured by the user.
|
|
|
|
|
*/
|
|
|
|
|
|
1998-07-09 18:45:28 +00:00
|
|
|
MC68681_STATIC int mc68681_baud_rate(
|
1998-06-23 14:55:21 +00:00
|
|
|
int minor,
|
|
|
|
|
int baud,
|
|
|
|
|
unsigned int *baud_mask_p,
|
1998-07-09 18:45:28 +00:00
|
|
|
unsigned int *acr_bit_p,
|
|
|
|
|
unsigned int *command
|
|
|
|
|
);
|
1998-06-23 14:55:21 +00:00
|
|
|
|
1998-06-23 16:02:52 +00:00
|
|
|
/*
|
|
|
|
|
* mc68681_set_attributes
|
|
|
|
|
*
|
|
|
|
|
* This function sets the DUART channel to reflect the requested termios
|
|
|
|
|
* port settings.
|
|
|
|
|
*/
|
|
|
|
|
|
2004-04-20 10:43:39 +00:00
|
|
|
MC68681_STATIC int mc68681_set_attributes(
|
1998-06-23 14:55:21 +00:00
|
|
|
int minor,
|
|
|
|
|
const struct termios *t
|
|
|
|
|
)
|
|
|
|
|
{
|
2004-03-23 Ralf Corsepius <ralf_corsepius@rtems.org>
* libchip/ide/ata.c, libchip/ide/ata_internal.h,
libchip/ide/ide_controller.c, libchip/ide/ide_ctrl_cfg.h,
libchip/ide/ide_ctrl_io.h, libchip/network/cs8900.c,
libchip/network/dec21140.c, libchip/network/elnk.c,
libchip/network/if_fxp.c, libchip/network/open_eth.c,
libchip/network/open_eth.h, libchip/network/sonic.c,
libchip/network/sonic.h, libchip/rtc/icm7170.c, libchip/rtc/icm7170.h,
libchip/rtc/icm7170_reg.c, libchip/rtc/icm7170_reg2.c,
libchip/rtc/icm7170_reg4.c, libchip/rtc/icm7170_reg8.c,
libchip/rtc/m48t08.c, libchip/rtc/m48t08.h, libchip/rtc/m48t08_reg.c,
libchip/rtc/m48t08_reg2.c, libchip/rtc/m48t08_reg4.c,
libchip/rtc/m48t08_reg8.c, libchip/rtc/rtc.h, libchip/serial/mc68681.c,
libchip/serial/mc68681.h, libchip/serial/mc68681_reg.c,
libchip/serial/mc68681_reg2.c, libchip/serial/mc68681_reg4.c,
libchip/serial/mc68681_reg8.c, libchip/serial/ns16550.c,
libchip/serial/ns16550_p.h, libchip/serial/serial.h,
libchip/serial/z85c30.c, libchip/serial/z85c30.h,
libchip/serial/z85c30_p.h, libchip/serial/z85c30_reg.c,
libchip/shmdr/addlq.c, libchip/shmdr/cnvpkt.c, libchip/shmdr/dump.c,
libchip/shmdr/fatal.c, libchip/shmdr/getlq.c, libchip/shmdr/init.c,
libchip/shmdr/initlq.c, libchip/shmdr/intr.c, libchip/shmdr/poll.c,
libchip/shmdr/send.c, libchip/shmdr/shm_driver.h: Convert to using c99
fixed-size types.
2004-03-23 09:59:52 +00:00
|
|
|
uint32_t pMC68681_port;
|
|
|
|
|
uint32_t pMC68681;
|
1998-06-23 14:55:21 +00:00
|
|
|
unsigned int mode1;
|
|
|
|
|
unsigned int mode2;
|
|
|
|
|
unsigned int baud_mask;
|
|
|
|
|
unsigned int acr_bit;
|
2005-05-02 16:24:10 +00:00
|
|
|
unsigned int cmd = 0;
|
1998-06-23 14:55:21 +00:00
|
|
|
setRegister_f setReg;
|
|
|
|
|
rtems_interrupt_level Irql;
|
1998-06-22 09:28:03 +00:00
|
|
|
|
1998-06-23 17:42:46 +00:00
|
|
|
pMC68681 = Console_Port_Tbl[minor].ulCtrlPort1;
|
|
|
|
|
pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2;
|
1998-06-22 11:49:38 +00:00
|
|
|
setReg = Console_Port_Tbl[minor].setRegister;
|
|
|
|
|
|
|
|
|
|
/*
|
1998-06-23 14:55:21 +00:00
|
|
|
* Set the baud rate
|
1998-06-22 11:49:38 +00:00
|
|
|
*/
|
|
|
|
|
|
1998-07-09 18:45:28 +00:00
|
|
|
if (mc68681_baud_rate( minor, t->c_cflag, &baud_mask, &acr_bit, &cmd ) == -1)
|
1998-06-23 14:55:21 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
baud_mask |= baud_mask << 4;
|
|
|
|
|
acr_bit <<= 7;
|
1998-06-22 11:49:38 +00:00
|
|
|
|
|
|
|
|
/*
|
1998-06-23 14:55:21 +00:00
|
|
|
* Parity
|
1998-06-22 11:49:38 +00:00
|
|
|
*/
|
|
|
|
|
|
1998-06-23 14:55:21 +00:00
|
|
|
mode1 = 0;
|
|
|
|
|
mode2 = 0;
|
1998-06-22 11:49:38 +00:00
|
|
|
|
1998-06-23 14:55:21 +00:00
|
|
|
if (t->c_cflag & PARENB) {
|
|
|
|
|
if (t->c_cflag & PARODD)
|
|
|
|
|
mode1 |= 0x04;
|
2003-09-26 20:15:56 +00:00
|
|
|
/* else
|
|
|
|
|
mode1 |= 0x04; */
|
1998-06-23 14:55:21 +00:00
|
|
|
} else {
|
|
|
|
|
mode1 |= 0x10;
|
|
|
|
|
}
|
1998-06-22 09:28:03 +00:00
|
|
|
|
1998-06-23 14:55:21 +00:00
|
|
|
/*
|
|
|
|
|
* Character Size
|
1998-06-22 09:28:03 +00:00
|
|
|
*/
|
|
|
|
|
|
1998-06-23 14:55:21 +00:00
|
|
|
if (t->c_cflag & CSIZE) {
|
|
|
|
|
switch (t->c_cflag & CSIZE) {
|
|
|
|
|
case CS5: break;
|
|
|
|
|
case CS6: mode1 |= 0x01; break;
|
|
|
|
|
case CS7: mode1 |= 0x02; break;
|
|
|
|
|
case CS8: mode1 |= 0x03; break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
mode1 |= 0x03; /* default to 9600,8,N,1 */
|
|
|
|
|
}
|
1998-06-22 09:28:03 +00:00
|
|
|
|
1998-06-23 14:55:21 +00:00
|
|
|
/*
|
|
|
|
|
* Stop Bits
|
|
|
|
|
*/
|
2004-04-20 10:43:39 +00:00
|
|
|
|
1998-06-23 14:55:21 +00:00
|
|
|
if (t->c_cflag & CSTOPB) {
|
2003-09-26 20:15:56 +00:00
|
|
|
mode2 |= 0x0F; /* 2 stop bits */
|
1998-06-23 14:55:21 +00:00
|
|
|
} else {
|
2003-09-26 20:15:56 +00:00
|
|
|
if ((t->c_cflag & CSIZE) == CS5) /* CS5 and 1 stop bits not supported */
|
1998-06-23 14:55:21 +00:00
|
|
|
return -1;
|
2003-09-26 20:15:56 +00:00
|
|
|
mode2 |= 0x07; /* 1 stop bit */
|
1998-06-23 14:55:21 +00:00
|
|
|
}
|
1998-06-22 09:28:03 +00:00
|
|
|
|
2003-09-26 20:15:56 +00:00
|
|
|
/*
|
|
|
|
|
* Hardware Flow Control
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if(t->c_cflag & CRTSCTS) {
|
|
|
|
|
mode1 |= 0x80; /* Enable Rx RTS Control */
|
|
|
|
|
mode2 |= 0x10; /* Enable CTS Enable Tx */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1998-06-23 14:55:21 +00:00
|
|
|
rtems_interrupt_disable(Irql);
|
|
|
|
|
(*setReg)( pMC68681, MC68681_AUX_CTRL_REG, acr_bit );
|
|
|
|
|
(*setReg)( pMC68681_port, MC68681_CLOCK_SELECT, baud_mask );
|
1998-07-09 22:16:27 +00:00
|
|
|
if ( cmd ) {
|
|
|
|
|
(*setReg)( pMC68681_port, MC68681_COMMAND, cmd ); /* RX */
|
|
|
|
|
(*setReg)( pMC68681_port, MC68681_COMMAND, cmd | 0x20 ); /* TX */
|
|
|
|
|
}
|
1998-06-23 14:55:21 +00:00
|
|
|
(*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_MR_PTR );
|
|
|
|
|
(*setReg)( pMC68681_port, MC68681_MODE, mode1 );
|
|
|
|
|
(*setReg)( pMC68681_port, MC68681_MODE, mode2 );
|
|
|
|
|
rtems_interrupt_enable(Irql);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
1998-06-22 09:28:03 +00:00
|
|
|
|
1998-06-23 16:02:52 +00:00
|
|
|
/*
|
|
|
|
|
* mc68681_initialize_context
|
|
|
|
|
*
|
|
|
|
|
* This function sets the default values of the per port context structure.
|
|
|
|
|
*/
|
|
|
|
|
|
1998-07-09 18:45:28 +00:00
|
|
|
MC68681_STATIC void mc68681_initialize_context(
|
1998-06-23 15:54:33 +00:00
|
|
|
int minor,
|
|
|
|
|
mc68681_context *pmc68681Context
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
int port;
|
|
|
|
|
unsigned int pMC68681;
|
1998-07-15 13:58:23 +00:00
|
|
|
unsigned int pMC68681_port;
|
2004-04-20 10:43:39 +00:00
|
|
|
|
1998-07-15 13:58:23 +00:00
|
|
|
pMC68681 = Console_Port_Tbl[minor].ulCtrlPort1;
|
|
|
|
|
pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2;
|
1998-06-23 15:54:33 +00:00
|
|
|
|
|
|
|
|
pmc68681Context->mate = -1;
|
|
|
|
|
|
|
|
|
|
for (port=0 ; port<Console_Port_Count ; port++ ) {
|
2004-04-20 10:43:39 +00:00
|
|
|
if ( Console_Port_Tbl[port].ulCtrlPort1 == pMC68681 &&
|
1998-07-15 13:58:23 +00:00
|
|
|
Console_Port_Tbl[port].ulCtrlPort2 != pMC68681_port ) {
|
1998-06-23 15:54:33 +00:00
|
|
|
pmc68681Context->mate = port;
|
1998-07-15 23:20:33 +00:00
|
|
|
pmc68681Context->imr = 0;
|
1998-06-23 15:54:33 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
1998-06-23 16:02:52 +00:00
|
|
|
/*
|
|
|
|
|
* mc68681_init
|
|
|
|
|
*
|
|
|
|
|
* This function initializes the DUART to a quiecsent state.
|
|
|
|
|
*/
|
|
|
|
|
|
1998-07-09 18:45:28 +00:00
|
|
|
MC68681_STATIC void mc68681_init(int minor)
|
1998-06-23 14:55:21 +00:00
|
|
|
{
|
2004-03-23 Ralf Corsepius <ralf_corsepius@rtems.org>
* libchip/ide/ata.c, libchip/ide/ata_internal.h,
libchip/ide/ide_controller.c, libchip/ide/ide_ctrl_cfg.h,
libchip/ide/ide_ctrl_io.h, libchip/network/cs8900.c,
libchip/network/dec21140.c, libchip/network/elnk.c,
libchip/network/if_fxp.c, libchip/network/open_eth.c,
libchip/network/open_eth.h, libchip/network/sonic.c,
libchip/network/sonic.h, libchip/rtc/icm7170.c, libchip/rtc/icm7170.h,
libchip/rtc/icm7170_reg.c, libchip/rtc/icm7170_reg2.c,
libchip/rtc/icm7170_reg4.c, libchip/rtc/icm7170_reg8.c,
libchip/rtc/m48t08.c, libchip/rtc/m48t08.h, libchip/rtc/m48t08_reg.c,
libchip/rtc/m48t08_reg2.c, libchip/rtc/m48t08_reg4.c,
libchip/rtc/m48t08_reg8.c, libchip/rtc/rtc.h, libchip/serial/mc68681.c,
libchip/serial/mc68681.h, libchip/serial/mc68681_reg.c,
libchip/serial/mc68681_reg2.c, libchip/serial/mc68681_reg4.c,
libchip/serial/mc68681_reg8.c, libchip/serial/ns16550.c,
libchip/serial/ns16550_p.h, libchip/serial/serial.h,
libchip/serial/z85c30.c, libchip/serial/z85c30.h,
libchip/serial/z85c30_p.h, libchip/serial/z85c30_reg.c,
libchip/shmdr/addlq.c, libchip/shmdr/cnvpkt.c, libchip/shmdr/dump.c,
libchip/shmdr/fatal.c, libchip/shmdr/getlq.c, libchip/shmdr/init.c,
libchip/shmdr/initlq.c, libchip/shmdr/intr.c, libchip/shmdr/poll.c,
libchip/shmdr/send.c, libchip/shmdr/shm_driver.h: Convert to using c99
fixed-size types.
2004-03-23 09:59:52 +00:00
|
|
|
uint32_t pMC68681_port;
|
|
|
|
|
uint32_t pMC68681;
|
1998-06-23 14:55:21 +00:00
|
|
|
mc68681_context *pmc68681Context;
|
|
|
|
|
setRegister_f setReg;
|
|
|
|
|
getRegister_f getReg;
|
|
|
|
|
|
|
|
|
|
pmc68681Context = (mc68681_context *) malloc(sizeof(mc68681_context));
|
1998-06-22 09:28:03 +00:00
|
|
|
|
1998-06-23 14:55:21 +00:00
|
|
|
Console_Port_Data[minor].pDeviceContext = (void *)pmc68681Context;
|
1998-06-23 15:54:33 +00:00
|
|
|
|
|
|
|
|
mc68681_initialize_context( minor, pmc68681Context );
|
1998-06-22 09:28:03 +00:00
|
|
|
|
1998-06-23 17:42:46 +00:00
|
|
|
pMC68681 = Console_Port_Tbl[minor].ulCtrlPort1;
|
|
|
|
|
pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2;
|
1998-06-23 14:55:21 +00:00
|
|
|
setReg = Console_Port_Tbl[minor].setRegister;
|
|
|
|
|
getReg = Console_Port_Tbl[minor].getRegister;
|
1998-06-22 09:28:03 +00:00
|
|
|
|
|
|
|
|
/*
|
1998-06-23 14:55:21 +00:00
|
|
|
* Reset everything and leave this port disabled.
|
1998-06-22 09:28:03 +00:00
|
|
|
*/
|
|
|
|
|
|
1998-07-15 23:20:33 +00:00
|
|
|
(*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_RX );
|
|
|
|
|
(*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_TX );
|
|
|
|
|
(*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_ERROR );
|
|
|
|
|
(*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_BREAK );
|
|
|
|
|
(*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_STOP_BREAK );
|
|
|
|
|
(*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_DISABLE_TX );
|
|
|
|
|
(*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_DISABLE_RX );
|
1998-06-22 09:28:03 +00:00
|
|
|
|
1998-06-23 14:55:21 +00:00
|
|
|
|
1998-07-15 23:20:33 +00:00
|
|
|
(*setReg)( pMC68681_port, MC68681_MODE_REG_1A, 0x00 );
|
|
|
|
|
(*setReg)( pMC68681_port, MC68681_MODE_REG_2A, 0x02 );
|
1998-06-23 17:42:46 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Disable interrupts on RX and TX for this port
|
|
|
|
|
*/
|
|
|
|
|
|
1998-07-15 23:20:33 +00:00
|
|
|
mc68681_enable_interrupts( minor, MC68681_IMR_DISABLE_ALL );
|
1998-06-22 09:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
1998-06-23 14:55:21 +00:00
|
|
|
/*
|
1998-06-23 16:02:52 +00:00
|
|
|
* mc68681_open
|
|
|
|
|
*
|
|
|
|
|
* This function opens a port for communication.
|
|
|
|
|
*
|
|
|
|
|
* Default state is 9600 baud, 8 bits, No parity, and 1 stop bit.
|
1998-06-23 14:55:21 +00:00
|
|
|
*/
|
|
|
|
|
|
1998-07-09 18:45:28 +00:00
|
|
|
MC68681_STATIC int mc68681_open(
|
1998-06-22 09:28:03 +00:00
|
|
|
int major,
|
|
|
|
|
int minor,
|
1998-06-23 14:55:21 +00:00
|
|
|
void *arg
|
1998-06-22 09:28:03 +00:00
|
|
|
)
|
|
|
|
|
{
|
2004-03-23 Ralf Corsepius <ralf_corsepius@rtems.org>
* libchip/ide/ata.c, libchip/ide/ata_internal.h,
libchip/ide/ide_controller.c, libchip/ide/ide_ctrl_cfg.h,
libchip/ide/ide_ctrl_io.h, libchip/network/cs8900.c,
libchip/network/dec21140.c, libchip/network/elnk.c,
libchip/network/if_fxp.c, libchip/network/open_eth.c,
libchip/network/open_eth.h, libchip/network/sonic.c,
libchip/network/sonic.h, libchip/rtc/icm7170.c, libchip/rtc/icm7170.h,
libchip/rtc/icm7170_reg.c, libchip/rtc/icm7170_reg2.c,
libchip/rtc/icm7170_reg4.c, libchip/rtc/icm7170_reg8.c,
libchip/rtc/m48t08.c, libchip/rtc/m48t08.h, libchip/rtc/m48t08_reg.c,
libchip/rtc/m48t08_reg2.c, libchip/rtc/m48t08_reg4.c,
libchip/rtc/m48t08_reg8.c, libchip/rtc/rtc.h, libchip/serial/mc68681.c,
libchip/serial/mc68681.h, libchip/serial/mc68681_reg.c,
libchip/serial/mc68681_reg2.c, libchip/serial/mc68681_reg4.c,
libchip/serial/mc68681_reg8.c, libchip/serial/ns16550.c,
libchip/serial/ns16550_p.h, libchip/serial/serial.h,
libchip/serial/z85c30.c, libchip/serial/z85c30.h,
libchip/serial/z85c30_p.h, libchip/serial/z85c30_reg.c,
libchip/shmdr/addlq.c, libchip/shmdr/cnvpkt.c, libchip/shmdr/dump.c,
libchip/shmdr/fatal.c, libchip/shmdr/getlq.c, libchip/shmdr/init.c,
libchip/shmdr/initlq.c, libchip/shmdr/intr.c, libchip/shmdr/poll.c,
libchip/shmdr/send.c, libchip/shmdr/shm_driver.h: Convert to using c99
fixed-size types.
2004-03-23 09:59:52 +00:00
|
|
|
uint32_t pMC68681;
|
|
|
|
|
uint32_t pMC68681_port;
|
1998-06-23 14:55:21 +00:00
|
|
|
unsigned int baud;
|
2003-09-26 20:15:56 +00:00
|
|
|
unsigned int acr_bit;
|
1998-06-23 14:55:21 +00:00
|
|
|
unsigned int vector;
|
2005-05-03 14:42:48 +00:00
|
|
|
unsigned int command = 0;
|
1998-06-23 14:55:21 +00:00
|
|
|
rtems_interrupt_level Irql;
|
|
|
|
|
setRegister_f setReg;
|
2003-09-26 20:15:56 +00:00
|
|
|
unsigned int status;
|
2004-04-20 10:43:39 +00:00
|
|
|
|
|
|
|
|
|
1998-06-23 14:55:21 +00:00
|
|
|
pMC68681 = Console_Port_Tbl[minor].ulCtrlPort1;
|
|
|
|
|
pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2;
|
|
|
|
|
setReg = Console_Port_Tbl[minor].setRegister;
|
|
|
|
|
vector = Console_Port_Tbl[minor].ulIntVector;
|
2004-04-20 10:43:39 +00:00
|
|
|
|
1998-07-09 22:21:54 +00:00
|
|
|
/* XXX default baud rate should be from configuration table */
|
|
|
|
|
|
2003-09-26 20:15:56 +00:00
|
|
|
status = mc68681_baud_rate( minor, B9600, &baud, &acr_bit, &command );
|
|
|
|
|
if (status < 0) rtems_fatal_error_occurred (RTEMS_NOT_DEFINED);
|
1998-06-23 14:55:21 +00:00
|
|
|
|
1998-06-23 14:59:26 +00:00
|
|
|
/*
|
|
|
|
|
* Set the DUART channel to a default useable state
|
|
|
|
|
*/
|
|
|
|
|
|
1998-06-23 14:55:21 +00:00
|
|
|
rtems_interrupt_disable(Irql);
|
2003-09-26 20:15:56 +00:00
|
|
|
(*setReg)( pMC68681, MC68681_AUX_CTRL_REG, acr_bit << 7 );
|
1998-06-23 14:55:21 +00:00
|
|
|
(*setReg)( pMC68681_port, MC68681_CLOCK_SELECT, baud );
|
1998-07-09 22:21:54 +00:00
|
|
|
if ( command ) {
|
|
|
|
|
(*setReg)( pMC68681_port, MC68681_COMMAND, command ); /* RX */
|
|
|
|
|
(*setReg)( pMC68681_port, MC68681_COMMAND, command | 0x20 ); /* TX */
|
|
|
|
|
}
|
1998-06-23 14:55:21 +00:00
|
|
|
(*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_MR_PTR );
|
|
|
|
|
(*setReg)( pMC68681_port, MC68681_MODE, 0x13 );
|
|
|
|
|
(*setReg)( pMC68681_port, MC68681_MODE, 0x07 );
|
|
|
|
|
rtems_interrupt_enable(Irql);
|
|
|
|
|
|
|
|
|
|
(*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_ENABLE_TX );
|
|
|
|
|
(*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_ENABLE_RX );
|
|
|
|
|
|
|
|
|
|
(*setReg)( pMC68681, MC68681_INTERRUPT_VECTOR_REG, vector );
|
|
|
|
|
|
1998-06-23 17:42:46 +00:00
|
|
|
return RTEMS_SUCCESSFUL;
|
1998-06-22 09:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
1998-06-23 16:02:52 +00:00
|
|
|
/*
|
|
|
|
|
* mc68681_close
|
|
|
|
|
*
|
|
|
|
|
* This function shuts down the requested port.
|
|
|
|
|
*/
|
|
|
|
|
|
1998-07-09 18:45:28 +00:00
|
|
|
MC68681_STATIC int mc68681_close(
|
1998-06-22 09:28:03 +00:00
|
|
|
int major,
|
|
|
|
|
int minor,
|
1998-06-23 14:55:21 +00:00
|
|
|
void *arg
|
1998-06-22 09:28:03 +00:00
|
|
|
)
|
|
|
|
|
{
|
2004-03-23 Ralf Corsepius <ralf_corsepius@rtems.org>
* libchip/ide/ata.c, libchip/ide/ata_internal.h,
libchip/ide/ide_controller.c, libchip/ide/ide_ctrl_cfg.h,
libchip/ide/ide_ctrl_io.h, libchip/network/cs8900.c,
libchip/network/dec21140.c, libchip/network/elnk.c,
libchip/network/if_fxp.c, libchip/network/open_eth.c,
libchip/network/open_eth.h, libchip/network/sonic.c,
libchip/network/sonic.h, libchip/rtc/icm7170.c, libchip/rtc/icm7170.h,
libchip/rtc/icm7170_reg.c, libchip/rtc/icm7170_reg2.c,
libchip/rtc/icm7170_reg4.c, libchip/rtc/icm7170_reg8.c,
libchip/rtc/m48t08.c, libchip/rtc/m48t08.h, libchip/rtc/m48t08_reg.c,
libchip/rtc/m48t08_reg2.c, libchip/rtc/m48t08_reg4.c,
libchip/rtc/m48t08_reg8.c, libchip/rtc/rtc.h, libchip/serial/mc68681.c,
libchip/serial/mc68681.h, libchip/serial/mc68681_reg.c,
libchip/serial/mc68681_reg2.c, libchip/serial/mc68681_reg4.c,
libchip/serial/mc68681_reg8.c, libchip/serial/ns16550.c,
libchip/serial/ns16550_p.h, libchip/serial/serial.h,
libchip/serial/z85c30.c, libchip/serial/z85c30.h,
libchip/serial/z85c30_p.h, libchip/serial/z85c30_reg.c,
libchip/shmdr/addlq.c, libchip/shmdr/cnvpkt.c, libchip/shmdr/dump.c,
libchip/shmdr/fatal.c, libchip/shmdr/getlq.c, libchip/shmdr/init.c,
libchip/shmdr/initlq.c, libchip/shmdr/intr.c, libchip/shmdr/poll.c,
libchip/shmdr/send.c, libchip/shmdr/shm_driver.h: Convert to using c99
fixed-size types.
2004-03-23 09:59:52 +00:00
|
|
|
uint32_t pMC68681;
|
|
|
|
|
uint32_t pMC68681_port;
|
1998-06-23 14:59:26 +00:00
|
|
|
setRegister_f setReg;
|
|
|
|
|
|
|
|
|
|
pMC68681 = Console_Port_Tbl[minor].ulCtrlPort1;
|
|
|
|
|
pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2;
|
|
|
|
|
setReg = Console_Port_Tbl[minor].setRegister;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Disable interrupts from this channel and then disable it totally.
|
|
|
|
|
*/
|
|
|
|
|
|
1998-08-13 15:52:40 +00:00
|
|
|
#if 0
|
1998-06-23 14:59:26 +00:00
|
|
|
(*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_DISABLE_TX );
|
|
|
|
|
(*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_DISABLE_RX );
|
1998-08-13 15:52:40 +00:00
|
|
|
#endif
|
1998-06-23 14:59:26 +00:00
|
|
|
|
1998-06-22 09:28:03 +00:00
|
|
|
return(RTEMS_SUCCESSFUL);
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-20 10:43:39 +00:00
|
|
|
/*
|
1998-06-22 09:28:03 +00:00
|
|
|
* mc68681_write_polled
|
1998-06-23 16:02:52 +00:00
|
|
|
*
|
|
|
|
|
* This routine polls out the requested character.
|
1998-06-22 09:28:03 +00:00
|
|
|
*/
|
1998-06-22 10:17:14 +00:00
|
|
|
|
1998-07-09 18:45:28 +00:00
|
|
|
MC68681_STATIC void mc68681_write_polled(
|
2004-04-20 10:43:39 +00:00
|
|
|
int minor,
|
1998-06-22 09:28:03 +00:00
|
|
|
char cChar
|
|
|
|
|
)
|
|
|
|
|
{
|
2004-03-23 Ralf Corsepius <ralf_corsepius@rtems.org>
* libchip/ide/ata.c, libchip/ide/ata_internal.h,
libchip/ide/ide_controller.c, libchip/ide/ide_ctrl_cfg.h,
libchip/ide/ide_ctrl_io.h, libchip/network/cs8900.c,
libchip/network/dec21140.c, libchip/network/elnk.c,
libchip/network/if_fxp.c, libchip/network/open_eth.c,
libchip/network/open_eth.h, libchip/network/sonic.c,
libchip/network/sonic.h, libchip/rtc/icm7170.c, libchip/rtc/icm7170.h,
libchip/rtc/icm7170_reg.c, libchip/rtc/icm7170_reg2.c,
libchip/rtc/icm7170_reg4.c, libchip/rtc/icm7170_reg8.c,
libchip/rtc/m48t08.c, libchip/rtc/m48t08.h, libchip/rtc/m48t08_reg.c,
libchip/rtc/m48t08_reg2.c, libchip/rtc/m48t08_reg4.c,
libchip/rtc/m48t08_reg8.c, libchip/rtc/rtc.h, libchip/serial/mc68681.c,
libchip/serial/mc68681.h, libchip/serial/mc68681_reg.c,
libchip/serial/mc68681_reg2.c, libchip/serial/mc68681_reg4.c,
libchip/serial/mc68681_reg8.c, libchip/serial/ns16550.c,
libchip/serial/ns16550_p.h, libchip/serial/serial.h,
libchip/serial/z85c30.c, libchip/serial/z85c30.h,
libchip/serial/z85c30_p.h, libchip/serial/z85c30_reg.c,
libchip/shmdr/addlq.c, libchip/shmdr/cnvpkt.c, libchip/shmdr/dump.c,
libchip/shmdr/fatal.c, libchip/shmdr/getlq.c, libchip/shmdr/init.c,
libchip/shmdr/initlq.c, libchip/shmdr/intr.c, libchip/shmdr/poll.c,
libchip/shmdr/send.c, libchip/shmdr/shm_driver.h: Convert to using c99
fixed-size types.
2004-03-23 09:59:52 +00:00
|
|
|
uint32_t pMC68681_port;
|
1998-06-22 09:28:03 +00:00
|
|
|
unsigned char ucLineStatus;
|
|
|
|
|
int iTimeout;
|
|
|
|
|
getRegister_f getReg;
|
1998-06-23 14:55:21 +00:00
|
|
|
setRegister_f setReg;
|
1998-06-22 09:28:03 +00:00
|
|
|
|
1998-06-23 14:55:21 +00:00
|
|
|
pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2;
|
|
|
|
|
getReg = Console_Port_Tbl[minor].getRegister;
|
|
|
|
|
setReg = Console_Port_Tbl[minor].setRegister;
|
1998-06-22 09:28:03 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* wait for transmitter holding register to be empty
|
|
|
|
|
*/
|
1998-06-22 11:09:32 +00:00
|
|
|
iTimeout = 1000;
|
1998-06-23 14:55:21 +00:00
|
|
|
ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS);
|
1998-07-09 22:16:27 +00:00
|
|
|
while ((ucLineStatus & (MC68681_TX_READY|MC68681_TX_EMPTY)) == 0) {
|
|
|
|
|
|
|
|
|
|
if ((ucLineStatus & 0xF0))
|
|
|
|
|
(*setReg)( pMC68681_port, MC68681_COMMAND, MC68681_MODE_REG_RESET_ERROR );
|
1998-06-22 11:09:32 +00:00
|
|
|
|
1998-06-22 09:28:03 +00:00
|
|
|
/*
|
|
|
|
|
* Yield while we wait
|
|
|
|
|
*/
|
1998-06-22 11:09:32 +00:00
|
|
|
|
1998-08-05 23:57:35 +00:00
|
|
|
#if 0
|
1998-06-22 09:28:03 +00:00
|
|
|
if(_System_state_Is_up(_System_state_Get())) {
|
|
|
|
|
rtems_task_wake_after(RTEMS_YIELD_PROCESSOR);
|
|
|
|
|
}
|
1998-08-05 23:57:35 +00:00
|
|
|
#endif
|
1998-06-23 14:55:21 +00:00
|
|
|
ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS);
|
1998-06-22 09:28:03 +00:00
|
|
|
if(!--iTimeout) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* transmit character
|
|
|
|
|
*/
|
1998-06-22 11:09:32 +00:00
|
|
|
|
1998-06-23 14:55:21 +00:00
|
|
|
(*setReg)(pMC68681_port, MC68681_TX_BUFFER, cChar);
|
1998-06-22 09:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
1998-06-23 17:42:46 +00:00
|
|
|
/*
|
|
|
|
|
* mc68681_isr
|
|
|
|
|
*
|
|
|
|
|
* This is the single interrupt entry point which parcels interrupts
|
|
|
|
|
* out to the various ports.
|
|
|
|
|
*/
|
|
|
|
|
|
1998-07-09 18:45:28 +00:00
|
|
|
MC68681_STATIC rtems_isr mc68681_isr(
|
1998-06-22 09:28:03 +00:00
|
|
|
rtems_vector_number vector
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
int minor;
|
|
|
|
|
|
1998-06-22 11:09:32 +00:00
|
|
|
for(minor=0 ; minor<Console_Port_Count ; minor++) {
|
2004-04-20 10:43:39 +00:00
|
|
|
if(Console_Port_Tbl[minor].ulIntVector == vector &&
|
1998-07-15 23:20:33 +00:00
|
|
|
Console_Port_Tbl[minor].deviceType == SERIAL_MC68681 ) {
|
1998-06-22 09:28:03 +00:00
|
|
|
mc68681_process(minor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1998-06-23 16:02:52 +00:00
|
|
|
/*
|
|
|
|
|
* mc68681_initialize_interrupts
|
|
|
|
|
*
|
|
|
|
|
* This routine initializes the console's receive and transmit
|
|
|
|
|
* ring buffers and loads the appropriate vectors to handle the interrupts.
|
|
|
|
|
*/
|
|
|
|
|
|
1998-07-09 18:45:28 +00:00
|
|
|
MC68681_STATIC void mc68681_initialize_interrupts(int minor)
|
1998-06-22 09:28:03 +00:00
|
|
|
{
|
|
|
|
|
mc68681_init(minor);
|
|
|
|
|
|
|
|
|
|
Console_Port_Data[minor].bActive = FALSE;
|
|
|
|
|
|
|
|
|
|
set_vector(mc68681_isr, Console_Port_Tbl[minor].ulIntVector, 1);
|
|
|
|
|
|
1998-07-15 23:20:33 +00:00
|
|
|
mc68681_enable_interrupts(minor,MC68681_IMR_ENABLE_ALL_EXCEPT_TX);
|
1998-06-22 09:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
2004-04-20 10:43:39 +00:00
|
|
|
/*
|
1998-06-22 09:28:03 +00:00
|
|
|
* mc68681_write_support_int
|
|
|
|
|
*
|
1998-06-23 16:02:52 +00:00
|
|
|
* Console Termios output entry point when using interrupt driven output.
|
1998-06-22 09:28:03 +00:00
|
|
|
*/
|
1998-06-22 11:09:32 +00:00
|
|
|
|
1998-07-09 18:45:28 +00:00
|
|
|
MC68681_STATIC int mc68681_write_support_int(
|
2004-04-20 10:43:39 +00:00
|
|
|
int minor,
|
|
|
|
|
const char *buf,
|
1998-07-15 13:58:23 +00:00
|
|
|
int len
|
1998-06-22 09:28:03 +00:00
|
|
|
)
|
|
|
|
|
{
|
2004-03-23 Ralf Corsepius <ralf_corsepius@rtems.org>
* libchip/ide/ata.c, libchip/ide/ata_internal.h,
libchip/ide/ide_controller.c, libchip/ide/ide_ctrl_cfg.h,
libchip/ide/ide_ctrl_io.h, libchip/network/cs8900.c,
libchip/network/dec21140.c, libchip/network/elnk.c,
libchip/network/if_fxp.c, libchip/network/open_eth.c,
libchip/network/open_eth.h, libchip/network/sonic.c,
libchip/network/sonic.h, libchip/rtc/icm7170.c, libchip/rtc/icm7170.h,
libchip/rtc/icm7170_reg.c, libchip/rtc/icm7170_reg2.c,
libchip/rtc/icm7170_reg4.c, libchip/rtc/icm7170_reg8.c,
libchip/rtc/m48t08.c, libchip/rtc/m48t08.h, libchip/rtc/m48t08_reg.c,
libchip/rtc/m48t08_reg2.c, libchip/rtc/m48t08_reg4.c,
libchip/rtc/m48t08_reg8.c, libchip/rtc/rtc.h, libchip/serial/mc68681.c,
libchip/serial/mc68681.h, libchip/serial/mc68681_reg.c,
libchip/serial/mc68681_reg2.c, libchip/serial/mc68681_reg4.c,
libchip/serial/mc68681_reg8.c, libchip/serial/ns16550.c,
libchip/serial/ns16550_p.h, libchip/serial/serial.h,
libchip/serial/z85c30.c, libchip/serial/z85c30.h,
libchip/serial/z85c30_p.h, libchip/serial/z85c30_reg.c,
libchip/shmdr/addlq.c, libchip/shmdr/cnvpkt.c, libchip/shmdr/dump.c,
libchip/shmdr/fatal.c, libchip/shmdr/getlq.c, libchip/shmdr/init.c,
libchip/shmdr/initlq.c, libchip/shmdr/intr.c, libchip/shmdr/poll.c,
libchip/shmdr/send.c, libchip/shmdr/shm_driver.h: Convert to using c99
fixed-size types.
2004-03-23 09:59:52 +00:00
|
|
|
uint32_t Irql;
|
|
|
|
|
uint32_t pMC68681_port;
|
1998-07-15 23:20:33 +00:00
|
|
|
setRegister_f setReg;
|
|
|
|
|
|
|
|
|
|
pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2;
|
|
|
|
|
setReg = Console_Port_Tbl[minor].setRegister;
|
1998-06-22 09:28:03 +00:00
|
|
|
|
|
|
|
|
/*
|
1998-07-25 16:18:27 +00:00
|
|
|
* We are using interrupt driven output and termios only sends us
|
|
|
|
|
* one character at a time.
|
1998-06-22 09:28:03 +00:00
|
|
|
*/
|
1998-06-22 11:09:32 +00:00
|
|
|
|
1998-07-15 23:20:33 +00:00
|
|
|
if ( !len )
|
|
|
|
|
return 0;
|
1998-06-22 09:28:03 +00:00
|
|
|
|
1998-07-15 23:20:33 +00:00
|
|
|
/*
|
1998-07-25 16:18:27 +00:00
|
|
|
* Put the character out and enable interrupts if necessary.
|
1998-07-15 23:20:33 +00:00
|
|
|
*/
|
1998-07-25 16:18:27 +00:00
|
|
|
|
1998-07-15 23:20:33 +00:00
|
|
|
rtems_interrupt_disable(Irql);
|
1998-07-25 14:51:57 +00:00
|
|
|
if ( Console_Port_Data[minor].bActive == FALSE ) {
|
|
|
|
|
Console_Port_Data[minor].bActive = TRUE;
|
|
|
|
|
mc68681_enable_interrupts(minor, MC68681_IMR_ENABLE_ALL);
|
|
|
|
|
}
|
1998-07-15 23:20:33 +00:00
|
|
|
(*setReg)(pMC68681_port, MC68681_TX_BUFFER, *buf);
|
|
|
|
|
rtems_interrupt_enable(Irql);
|
1998-07-25 16:18:27 +00:00
|
|
|
|
1998-07-15 23:20:33 +00:00
|
|
|
return 1;
|
1998-06-22 09:28:03 +00:00
|
|
|
}
|
|
|
|
|
|
2004-04-20 10:43:39 +00:00
|
|
|
/*
|
1998-06-22 09:28:03 +00:00
|
|
|
* mc68681_write_support_polled
|
|
|
|
|
*
|
1998-06-23 16:02:52 +00:00
|
|
|
* Console Termios output entry point when using polled output.
|
1998-06-22 09:28:03 +00:00
|
|
|
*
|
|
|
|
|
*/
|
1998-06-22 11:09:32 +00:00
|
|
|
|
1998-07-09 18:45:28 +00:00
|
|
|
MC68681_STATIC int mc68681_write_support_polled(
|
2004-04-20 10:43:39 +00:00
|
|
|
int minor,
|
|
|
|
|
const char *buf,
|
1998-06-22 09:28:03 +00:00
|
|
|
int len
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
int nwrite = 0;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* poll each byte in the string out of the port.
|
|
|
|
|
*/
|
|
|
|
|
while (nwrite < len) {
|
|
|
|
|
/*
|
|
|
|
|
* transmit character
|
|
|
|
|
*/
|
|
|
|
|
mc68681_write_polled(minor, *buf++);
|
|
|
|
|
nwrite++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* return the number of bytes written.
|
|
|
|
|
*/
|
|
|
|
|
return nwrite;
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-20 10:43:39 +00:00
|
|
|
/*
|
|
|
|
|
* mc68681_inbyte_nonblocking_polled
|
1998-06-22 09:28:03 +00:00
|
|
|
*
|
|
|
|
|
* Console Termios polling input entry point.
|
|
|
|
|
*/
|
|
|
|
|
|
2004-04-20 10:43:39 +00:00
|
|
|
MC68681_STATIC int mc68681_inbyte_nonblocking_polled(
|
|
|
|
|
int minor
|
1998-06-22 09:28:03 +00:00
|
|
|
)
|
|
|
|
|
{
|
2004-03-23 Ralf Corsepius <ralf_corsepius@rtems.org>
* libchip/ide/ata.c, libchip/ide/ata_internal.h,
libchip/ide/ide_controller.c, libchip/ide/ide_ctrl_cfg.h,
libchip/ide/ide_ctrl_io.h, libchip/network/cs8900.c,
libchip/network/dec21140.c, libchip/network/elnk.c,
libchip/network/if_fxp.c, libchip/network/open_eth.c,
libchip/network/open_eth.h, libchip/network/sonic.c,
libchip/network/sonic.h, libchip/rtc/icm7170.c, libchip/rtc/icm7170.h,
libchip/rtc/icm7170_reg.c, libchip/rtc/icm7170_reg2.c,
libchip/rtc/icm7170_reg4.c, libchip/rtc/icm7170_reg8.c,
libchip/rtc/m48t08.c, libchip/rtc/m48t08.h, libchip/rtc/m48t08_reg.c,
libchip/rtc/m48t08_reg2.c, libchip/rtc/m48t08_reg4.c,
libchip/rtc/m48t08_reg8.c, libchip/rtc/rtc.h, libchip/serial/mc68681.c,
libchip/serial/mc68681.h, libchip/serial/mc68681_reg.c,
libchip/serial/mc68681_reg2.c, libchip/serial/mc68681_reg4.c,
libchip/serial/mc68681_reg8.c, libchip/serial/ns16550.c,
libchip/serial/ns16550_p.h, libchip/serial/serial.h,
libchip/serial/z85c30.c, libchip/serial/z85c30.h,
libchip/serial/z85c30_p.h, libchip/serial/z85c30_reg.c,
libchip/shmdr/addlq.c, libchip/shmdr/cnvpkt.c, libchip/shmdr/dump.c,
libchip/shmdr/fatal.c, libchip/shmdr/getlq.c, libchip/shmdr/init.c,
libchip/shmdr/initlq.c, libchip/shmdr/intr.c, libchip/shmdr/poll.c,
libchip/shmdr/send.c, libchip/shmdr/shm_driver.h: Convert to using c99
fixed-size types.
2004-03-23 09:59:52 +00:00
|
|
|
uint32_t pMC68681_port;
|
1998-06-22 09:28:03 +00:00
|
|
|
unsigned char ucLineStatus;
|
1998-07-09 22:16:27 +00:00
|
|
|
unsigned char cChar;
|
1998-06-22 09:28:03 +00:00
|
|
|
getRegister_f getReg;
|
|
|
|
|
|
1998-06-23 14:55:21 +00:00
|
|
|
pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2;
|
|
|
|
|
getReg = Console_Port_Tbl[minor].getRegister;
|
1998-06-22 09:28:03 +00:00
|
|
|
|
1998-06-23 14:55:21 +00:00
|
|
|
ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS);
|
1998-06-22 11:09:32 +00:00
|
|
|
if(ucLineStatus & MC68681_RX_READY) {
|
1998-06-23 14:55:21 +00:00
|
|
|
cChar = (*getReg)(pMC68681_port, MC68681_RX_BUFFER);
|
1998-06-22 11:09:32 +00:00
|
|
|
return (int)cChar;
|
1998-06-22 09:28:03 +00:00
|
|
|
} else {
|
1998-06-23 14:55:21 +00:00
|
|
|
return -1;
|
1998-06-22 09:28:03 +00:00
|
|
|
}
|
|
|
|
|
}
|
1998-07-09 18:45:28 +00:00
|
|
|
|
1998-07-25 17:22:58 +00:00
|
|
|
/*
|
|
|
|
|
* mc68681_baud_rate
|
|
|
|
|
*/
|
|
|
|
|
|
1998-07-09 18:45:28 +00:00
|
|
|
MC68681_STATIC int mc68681_baud_rate(
|
|
|
|
|
int minor,
|
|
|
|
|
int baud,
|
|
|
|
|
unsigned int *baud_mask_p,
|
|
|
|
|
unsigned int *acr_bit_p,
|
|
|
|
|
unsigned int *command
|
|
|
|
|
)
|
|
|
|
|
{
|
1998-07-16 00:03:01 +00:00
|
|
|
unsigned int baud_mask;
|
|
|
|
|
unsigned int acr_bit;
|
|
|
|
|
int status;
|
|
|
|
|
int is_extended;
|
|
|
|
|
int baud_requested;
|
1998-07-09 18:45:28 +00:00
|
|
|
mc68681_baud_table_t *baud_tbl;
|
|
|
|
|
|
|
|
|
|
baud_mask = 0;
|
|
|
|
|
acr_bit = 0;
|
|
|
|
|
status = 0;
|
|
|
|
|
|
2003-09-26 20:15:56 +00:00
|
|
|
if (Console_Port_Tbl[minor].ulDataPort & MC68681_DATA_BAUD_RATE_SET_2)
|
|
|
|
|
{
|
1998-07-09 18:45:28 +00:00
|
|
|
acr_bit = 1;
|
2003-09-26 20:15:56 +00:00
|
|
|
}
|
1998-07-09 18:45:28 +00:00
|
|
|
|
|
|
|
|
is_extended = 0;
|
|
|
|
|
|
|
|
|
|
switch (Console_Port_Tbl[minor].ulDataPort & MC68681_XBRG_MASK) {
|
|
|
|
|
case MC68681_XBRG_IGNORED:
|
|
|
|
|
*command = 0x00;
|
|
|
|
|
break;
|
|
|
|
|
case MC68681_XBRG_ENABLED:
|
1998-07-09 22:16:27 +00:00
|
|
|
*command = 0x80;
|
1998-07-09 18:45:28 +00:00
|
|
|
is_extended = 1;
|
|
|
|
|
break;
|
|
|
|
|
case MC68681_XBRG_DISABLED:
|
1998-07-09 22:16:27 +00:00
|
|
|
*command = 0x90;
|
1998-07-09 18:45:28 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
baud_requested = baud & CBAUD;
|
|
|
|
|
if (!baud_requested)
|
1998-07-09 22:16:27 +00:00
|
|
|
baud_requested = B9600; /* default to 9600 baud */
|
2004-04-20 10:43:39 +00:00
|
|
|
|
1998-07-09 18:45:28 +00:00
|
|
|
baud_requested = termios_baud_to_index( baud_requested );
|
|
|
|
|
|
|
|
|
|
baud_tbl = (mc68681_baud_table_t *) Console_Port_Tbl[minor].ulClock;
|
|
|
|
|
if (!baud_tbl)
|
1998-07-16 00:16:11 +00:00
|
|
|
rtems_fatal_error_occurred(RTEMS_INVALID_ADDRESS);
|
1998-07-09 18:45:28 +00:00
|
|
|
|
|
|
|
|
if ( is_extended )
|
|
|
|
|
baud_mask = (unsigned int)baud_tbl[ acr_bit + 2 ][ baud_requested ];
|
|
|
|
|
else
|
|
|
|
|
baud_mask = baud_tbl[ acr_bit ][ baud_requested ];
|
|
|
|
|
|
|
|
|
|
if ( baud_mask == MC68681_BAUD_NOT_VALID )
|
|
|
|
|
status = -1;
|
|
|
|
|
|
1998-07-09 22:16:27 +00:00
|
|
|
/*
|
|
|
|
|
* upper nibble is receiver and lower nibble is transmitter
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
*baud_mask_p = (baud_mask << 4) | baud_mask;
|
1998-07-09 18:45:28 +00:00
|
|
|
*acr_bit_p = acr_bit;
|
|
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
|
|
1998-07-15 13:58:23 +00:00
|
|
|
/*
|
|
|
|
|
* mc68681_process
|
|
|
|
|
*
|
|
|
|
|
* This routine is the per port console interrupt handler.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
MC68681_STATIC void mc68681_process(
|
|
|
|
|
int minor
|
|
|
|
|
)
|
|
|
|
|
{
|
2004-03-23 Ralf Corsepius <ralf_corsepius@rtems.org>
* libchip/ide/ata.c, libchip/ide/ata_internal.h,
libchip/ide/ide_controller.c, libchip/ide/ide_ctrl_cfg.h,
libchip/ide/ide_ctrl_io.h, libchip/network/cs8900.c,
libchip/network/dec21140.c, libchip/network/elnk.c,
libchip/network/if_fxp.c, libchip/network/open_eth.c,
libchip/network/open_eth.h, libchip/network/sonic.c,
libchip/network/sonic.h, libchip/rtc/icm7170.c, libchip/rtc/icm7170.h,
libchip/rtc/icm7170_reg.c, libchip/rtc/icm7170_reg2.c,
libchip/rtc/icm7170_reg4.c, libchip/rtc/icm7170_reg8.c,
libchip/rtc/m48t08.c, libchip/rtc/m48t08.h, libchip/rtc/m48t08_reg.c,
libchip/rtc/m48t08_reg2.c, libchip/rtc/m48t08_reg4.c,
libchip/rtc/m48t08_reg8.c, libchip/rtc/rtc.h, libchip/serial/mc68681.c,
libchip/serial/mc68681.h, libchip/serial/mc68681_reg.c,
libchip/serial/mc68681_reg2.c, libchip/serial/mc68681_reg4.c,
libchip/serial/mc68681_reg8.c, libchip/serial/ns16550.c,
libchip/serial/ns16550_p.h, libchip/serial/serial.h,
libchip/serial/z85c30.c, libchip/serial/z85c30.h,
libchip/serial/z85c30_p.h, libchip/serial/z85c30_reg.c,
libchip/shmdr/addlq.c, libchip/shmdr/cnvpkt.c, libchip/shmdr/dump.c,
libchip/shmdr/fatal.c, libchip/shmdr/getlq.c, libchip/shmdr/init.c,
libchip/shmdr/initlq.c, libchip/shmdr/intr.c, libchip/shmdr/poll.c,
libchip/shmdr/send.c, libchip/shmdr/shm_driver.h: Convert to using c99
fixed-size types.
2004-03-23 09:59:52 +00:00
|
|
|
uint32_t pMC68681;
|
|
|
|
|
uint32_t pMC68681_port;
|
2004-04-20 10:43:39 +00:00
|
|
|
volatile uint8_t ucLineStatus;
|
|
|
|
|
volatile uint8_t ucISRStatus;
|
2005-05-06 20:13:44 +00:00
|
|
|
char cChar;
|
1998-07-15 13:58:23 +00:00
|
|
|
getRegister_f getReg;
|
|
|
|
|
setRegister_f setReg;
|
|
|
|
|
|
|
|
|
|
pMC68681 = Console_Port_Tbl[minor].ulCtrlPort1;
|
|
|
|
|
pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2;
|
|
|
|
|
getReg = Console_Port_Tbl[minor].getRegister;
|
|
|
|
|
setReg = Console_Port_Tbl[minor].setRegister;
|
|
|
|
|
|
2004-04-20 10:43:39 +00:00
|
|
|
/* Get ISR at the beginning of the IT routine */
|
2003-09-26 20:15:56 +00:00
|
|
|
ucISRStatus = (*getReg)(pMC68681, MC68681_INTERRUPT_STATUS_REG);
|
2004-04-20 10:43:39 +00:00
|
|
|
|
2003-09-26 20:15:56 +00:00
|
|
|
/* Get good ISR a or b channel */
|
|
|
|
|
if (pMC68681 != pMC68681_port){
|
|
|
|
|
ucISRStatus >>= 4;
|
|
|
|
|
}
|
2004-04-20 10:43:39 +00:00
|
|
|
|
2003-09-26 20:15:56 +00:00
|
|
|
/* See if is usefull to call rtems_termios_dequeue */
|
|
|
|
|
if(Console_Port_Data[minor].bActive == FALSE) {
|
|
|
|
|
ucISRStatus = ucISRStatus & ~MC68681_IR_TX_READY;
|
|
|
|
|
}
|
|
|
|
|
|
1998-07-15 13:58:23 +00:00
|
|
|
/*
|
|
|
|
|
* Deal with any received characters
|
|
|
|
|
*/
|
2008-09-07 03:44:14 +00:00
|
|
|
while(true) {
|
1998-07-15 13:58:23 +00:00
|
|
|
ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS);
|
|
|
|
|
if(!(ucLineStatus & MC68681_RX_READY)) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* If there is a RX error, then dump all the data.
|
|
|
|
|
*/
|
|
|
|
|
if ( ucLineStatus & MC68681_RX_ERRORS ) {
|
|
|
|
|
do {
|
|
|
|
|
cChar = (*getReg)(pMC68681_port, MC68681_RX_BUFFER);
|
|
|
|
|
ucLineStatus = (*getReg)(pMC68681_port, MC68681_STATUS);
|
|
|
|
|
} while ( ucLineStatus & MC68681_RX_READY );
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
cChar = (*getReg)(pMC68681_port, MC68681_RX_BUFFER);
|
2004-04-20 10:43:39 +00:00
|
|
|
rtems_termios_enqueue_raw_characters(
|
1998-07-15 13:58:23 +00:00
|
|
|
Console_Port_Data[minor].termios_data,
|
2004-04-20 10:43:39 +00:00
|
|
|
&cChar,
|
|
|
|
|
1
|
1998-07-15 13:58:23 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Deal with the transmitter
|
|
|
|
|
*/
|
|
|
|
|
|
2003-09-26 20:15:56 +00:00
|
|
|
if (ucISRStatus & MC68681_IR_TX_READY) {
|
|
|
|
|
if (!rtems_termios_dequeue_characters(
|
|
|
|
|
Console_Port_Data[minor].termios_data, 1)) {
|
|
|
|
|
/* If no more char to send, disable TX interrupt */
|
1998-07-25 14:51:57 +00:00
|
|
|
Console_Port_Data[minor].bActive = FALSE;
|
|
|
|
|
mc68681_enable_interrupts(minor, MC68681_IMR_ENABLE_ALL_EXCEPT_TX);
|
|
|
|
|
}
|
1998-07-15 13:58:23 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* mc68681_build_imr
|
|
|
|
|
*
|
|
|
|
|
* This function returns the value for the interrupt mask register for this
|
|
|
|
|
* DUART. Since this is a shared register, we must look at the other port
|
|
|
|
|
* on this chip to determine whether or not it is using interrupts.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
MC68681_STATIC unsigned int mc68681_build_imr(
|
|
|
|
|
int minor,
|
|
|
|
|
int enable_flag
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
int mate;
|
1998-07-15 23:20:33 +00:00
|
|
|
int is_a;
|
1998-07-15 13:58:23 +00:00
|
|
|
unsigned int mask;
|
|
|
|
|
unsigned int mate_mask;
|
|
|
|
|
unsigned int pMC68681;
|
|
|
|
|
unsigned int pMC68681_port;
|
|
|
|
|
mc68681_context *pmc68681Context;
|
1998-07-15 23:20:33 +00:00
|
|
|
mc68681_context *mateContext;
|
2004-04-20 10:43:39 +00:00
|
|
|
|
1998-07-15 13:58:23 +00:00
|
|
|
pMC68681 = Console_Port_Tbl[minor].ulCtrlPort1;
|
|
|
|
|
pMC68681_port = Console_Port_Tbl[minor].ulCtrlPort2;
|
|
|
|
|
pmc68681Context = (mc68681_context *) Console_Port_Data[minor].pDeviceContext;
|
|
|
|
|
mate = pmc68681Context->mate;
|
|
|
|
|
|
1998-07-15 23:20:33 +00:00
|
|
|
mask = 0;
|
1998-07-15 13:58:23 +00:00
|
|
|
mate_mask = 0;
|
|
|
|
|
|
1998-07-15 23:20:33 +00:00
|
|
|
is_a = (pMC68681 == pMC68681_port);
|
2004-04-20 10:43:39 +00:00
|
|
|
|
1998-07-15 13:58:23 +00:00
|
|
|
/*
|
1998-07-15 23:20:33 +00:00
|
|
|
* If there is a mate for this port, get its IMR mask.
|
1998-07-15 13:58:23 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if ( mate != -1 ) {
|
1998-07-15 23:20:33 +00:00
|
|
|
mateContext = Console_Port_Data[mate].pDeviceContext;
|
2004-04-20 10:43:39 +00:00
|
|
|
|
1998-07-15 23:20:33 +00:00
|
|
|
if (mateContext)
|
|
|
|
|
mate_mask = mateContext->imr;
|
|
|
|
|
}
|
1998-07-15 13:58:23 +00:00
|
|
|
|
1998-07-15 23:20:33 +00:00
|
|
|
/*
|
|
|
|
|
* Calculate this port's IMR mask and save it in the context area.
|
|
|
|
|
*/
|
1998-07-15 13:58:23 +00:00
|
|
|
|
1998-07-15 23:20:33 +00:00
|
|
|
if ( Console_Port_Tbl[minor].pDeviceFns->deviceOutputUsesInterrupts )
|
|
|
|
|
mask = enable_flag;
|
|
|
|
|
|
|
|
|
|
pmc68681Context->imr = mask;
|
1998-07-15 13:58:23 +00:00
|
|
|
|
|
|
|
|
/*
|
1998-07-15 23:20:33 +00:00
|
|
|
* Now return the full IMR value
|
1998-07-15 13:58:23 +00:00
|
|
|
*/
|
|
|
|
|
|
1998-07-15 23:20:33 +00:00
|
|
|
if (is_a)
|
|
|
|
|
return (mate_mask << 4) | mask;
|
|
|
|
|
|
|
|
|
|
return (mask << 4) | mate_mask;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* mc68681_enable_interrupts
|
|
|
|
|
*
|
1998-08-13 15:52:40 +00:00
|
|
|
* This function enables specific interrupt sources on the DUART.
|
1998-07-15 23:20:33 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
MC68681_STATIC void mc68681_enable_interrupts(
|
|
|
|
|
int minor,
|
|
|
|
|
int imr_mask
|
|
|
|
|
)
|
|
|
|
|
{
|
2004-03-23 Ralf Corsepius <ralf_corsepius@rtems.org>
* libchip/ide/ata.c, libchip/ide/ata_internal.h,
libchip/ide/ide_controller.c, libchip/ide/ide_ctrl_cfg.h,
libchip/ide/ide_ctrl_io.h, libchip/network/cs8900.c,
libchip/network/dec21140.c, libchip/network/elnk.c,
libchip/network/if_fxp.c, libchip/network/open_eth.c,
libchip/network/open_eth.h, libchip/network/sonic.c,
libchip/network/sonic.h, libchip/rtc/icm7170.c, libchip/rtc/icm7170.h,
libchip/rtc/icm7170_reg.c, libchip/rtc/icm7170_reg2.c,
libchip/rtc/icm7170_reg4.c, libchip/rtc/icm7170_reg8.c,
libchip/rtc/m48t08.c, libchip/rtc/m48t08.h, libchip/rtc/m48t08_reg.c,
libchip/rtc/m48t08_reg2.c, libchip/rtc/m48t08_reg4.c,
libchip/rtc/m48t08_reg8.c, libchip/rtc/rtc.h, libchip/serial/mc68681.c,
libchip/serial/mc68681.h, libchip/serial/mc68681_reg.c,
libchip/serial/mc68681_reg2.c, libchip/serial/mc68681_reg4.c,
libchip/serial/mc68681_reg8.c, libchip/serial/ns16550.c,
libchip/serial/ns16550_p.h, libchip/serial/serial.h,
libchip/serial/z85c30.c, libchip/serial/z85c30.h,
libchip/serial/z85c30_p.h, libchip/serial/z85c30_reg.c,
libchip/shmdr/addlq.c, libchip/shmdr/cnvpkt.c, libchip/shmdr/dump.c,
libchip/shmdr/fatal.c, libchip/shmdr/getlq.c, libchip/shmdr/init.c,
libchip/shmdr/initlq.c, libchip/shmdr/intr.c, libchip/shmdr/poll.c,
libchip/shmdr/send.c, libchip/shmdr/shm_driver.h: Convert to using c99
fixed-size types.
2004-03-23 09:59:52 +00:00
|
|
|
uint32_t pMC68681;
|
1998-07-15 23:20:33 +00:00
|
|
|
setRegister_f setReg;
|
|
|
|
|
|
|
|
|
|
pMC68681 = Console_Port_Tbl[minor].ulCtrlPort1;
|
|
|
|
|
setReg = Console_Port_Tbl[minor].setRegister;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Enable interrupts on RX and TX -- not break
|
|
|
|
|
*/
|
1998-07-15 13:58:23 +00:00
|
|
|
|
1998-07-15 23:20:33 +00:00
|
|
|
(*setReg)(
|
|
|
|
|
pMC68681,
|
|
|
|
|
MC68681_INTERRUPT_MASK_REG,
|
|
|
|
|
mc68681_build_imr(minor, imr_mask)
|
|
|
|
|
);
|
1998-07-15 13:58:23 +00:00
|
|
|
}
|