Implement rudumentry support for the linux TIOC[SG]ETSERIAL ioctl's.
To complete this, some extra state has to be kept somewhere so that the B38400 flag in Linux can be correctly translated to/from either 38400, 57600 or 115200. Submitted by: Robert Sanders <rsanders@mindspring.com>
This commit is contained in:
parent
f7d16bb60b
commit
c1675b0847
@ -25,7 +25,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: linux.h,v 1.6 1996/03/03 19:07:49 peter Exp $
|
||||
* $Id: linux.h,v 1.7 1996/03/10 08:42:47 sos Exp $
|
||||
*/
|
||||
|
||||
#ifndef _I386_LINUX_LINUX_H_
|
||||
@ -215,6 +215,11 @@ struct trapframe;
|
||||
#define LINUX_TIOCGLCKTRMIOS 0x5456
|
||||
#define LINUX_TIOCSLCKTRMIOS 0x5457
|
||||
|
||||
/* arguments for tcflush() and LINUX_TCFLSH */
|
||||
#define LINUX_TCIFLUSH 0
|
||||
#define LINUX_TCOFLUSH 1
|
||||
#define LINUX_TCIOFLUSH 2
|
||||
|
||||
/* line disciplines */
|
||||
#define LINUX_N_TTY 0
|
||||
#define LINUX_N_SLIP 1
|
||||
@ -488,4 +493,33 @@ struct trapframe;
|
||||
#define LINUX_SIOCADDMULTI 0x8931
|
||||
#define LINUX_SIOCDELMULTI 0x8932
|
||||
|
||||
/* serial_struct values for TIOC[GS]SERIAL ioctls */
|
||||
#define LINUX_ASYNC_CLOSING_WAIT_INF 0
|
||||
#define LINUX_ASYNC_CLOSING_WAIT_NONE 65535
|
||||
|
||||
#define LINUX_PORT_UNKNOWN 0
|
||||
#define LINUX_PORT_8250 1
|
||||
#define LINUX_PORT_16450 2
|
||||
#define LINUX_PORT_16550 3
|
||||
#define LINUX_PORT_16550A 4
|
||||
#define LINUX_PORT_CIRRUS 5
|
||||
#define LINUX_PORT_16650 6
|
||||
#define LINUX_PORT_MAX 6
|
||||
|
||||
#define LINUX_ASYNC_HUP_NOTIFY 0x0001
|
||||
#define LINUX_ASYNC_FOURPORT 0x0002
|
||||
#define LINUX_ASYNC_SAK 0x0004
|
||||
#define LINUX_ASYNC_SPLIT_TERMIOS 0x0008
|
||||
#define LINUX_ASYNC_SPD_MASK 0x0030
|
||||
#define LINUX_ASYNC_SPD_HI 0x0010
|
||||
#define LINUX_ASYNC_SPD_VHI 0x0020
|
||||
#define LINUX_ASYNC_SPD_CUST 0x0030
|
||||
#define LINUX_ASYNC_SKIP_TEST 0x0040
|
||||
#define LINUX_ASYNC_AUTO_IRQ 0x0080
|
||||
#define LINUX_ASYNC_SESSION_LOCKOUT 0x0100
|
||||
#define LINUX_ASYNC_PGRP_LOCKOUT 0x0200
|
||||
#define LINUX_ASYNC_CALLOUT_NOHUP 0x0400
|
||||
#define LINUX_ASYNC_FLAGS 0x0FFF
|
||||
|
||||
|
||||
#endif /* !_I386_LINUX_LINUX_H_ */
|
||||
|
@ -25,7 +25,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: linux_ioctl.c,v 1.7 1996/03/03 19:07:50 peter Exp $
|
||||
* $Id: linux_ioctl.c,v 1.8 1996/03/04 11:15:19 peter Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -82,6 +82,24 @@ static struct speedtab sptab[] = {
|
||||
{ 57600, 4097 }, { 115200, 4098 }, {-1, -1 }
|
||||
};
|
||||
|
||||
struct linux_serial_struct {
|
||||
int type;
|
||||
int line;
|
||||
int port;
|
||||
int irq;
|
||||
int flags;
|
||||
int xmit_fifo_size;
|
||||
int custom_divisor;
|
||||
int baud_base;
|
||||
unsigned short close_delay;
|
||||
char reserved_char[2];
|
||||
int hub6;
|
||||
unsigned short closing_wait;
|
||||
unsigned short closing_wait2;
|
||||
int reserved[4];
|
||||
};
|
||||
|
||||
|
||||
static int
|
||||
linux_to_bsd_speed(int code, struct speedtab *table)
|
||||
{
|
||||
@ -411,6 +429,23 @@ linux_to_bsd_termio(struct linux_termio *linux_termio,
|
||||
linux_to_bsd_termios(&tmios, bsd_termios);
|
||||
}
|
||||
|
||||
static void
|
||||
linux_tiocgserial(struct file *fp, struct linux_serial_struct *lss)
|
||||
{
|
||||
if (!fp || !lss)
|
||||
return;
|
||||
|
||||
lss->type = LINUX_PORT_16550A;
|
||||
lss->flags = 0;
|
||||
lss->close_delay = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
linux_tiocsserial(struct file *fp, struct linux_serial_struct *lss)
|
||||
{
|
||||
if (!fp || !lss)
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
linux_ioctl(struct proc *p, struct linux_ioctl_args *args, int *retval)
|
||||
@ -658,6 +693,32 @@ linux_ioctl(struct proc *p, struct linux_ioctl_args *args, int *retval)
|
||||
case LINUX_SNDCTL_DSP_NONBLOCK:
|
||||
args->cmd = SNDCTL_DSP_NONBLOCK;
|
||||
return ioctl(p, (struct ioctl_args *)args, retval);
|
||||
|
||||
case LINUX_TIOCGSERIAL:
|
||||
linux_tiocgserial(fp, (struct linux_serial_struct *)args->arg);
|
||||
return 0;
|
||||
|
||||
case LINUX_TIOCSSERIAL:
|
||||
linux_tiocsserial(fp, (struct linux_serial_struct *)args->arg);
|
||||
return 0;
|
||||
|
||||
case LINUX_TCFLSH:
|
||||
args->cmd = TIOCFLUSH;
|
||||
switch (args->arg) {
|
||||
case LINUX_TCIFLUSH:
|
||||
args->arg = FREAD;
|
||||
break;
|
||||
case LINUX_TCOFLUSH:
|
||||
args->arg = FWRITE;
|
||||
break;
|
||||
case LINUX_TCIOFLUSH:
|
||||
args->arg = FREAD | FWRITE;
|
||||
break;
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
return ioctl(p, (struct ioctl_args *)args, retval);
|
||||
|
||||
}
|
||||
uprintf("LINUX: 'ioctl' fd=%d, typ=0x%x(%c), num=0x%x not implemented\n",
|
||||
args->fd, (args->cmd&0xffff00)>>8,
|
||||
|
@ -25,7 +25,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: linux.h,v 1.6 1996/03/03 19:07:49 peter Exp $
|
||||
* $Id: linux.h,v 1.7 1996/03/10 08:42:47 sos Exp $
|
||||
*/
|
||||
|
||||
#ifndef _I386_LINUX_LINUX_H_
|
||||
@ -215,6 +215,11 @@ struct trapframe;
|
||||
#define LINUX_TIOCGLCKTRMIOS 0x5456
|
||||
#define LINUX_TIOCSLCKTRMIOS 0x5457
|
||||
|
||||
/* arguments for tcflush() and LINUX_TCFLSH */
|
||||
#define LINUX_TCIFLUSH 0
|
||||
#define LINUX_TCOFLUSH 1
|
||||
#define LINUX_TCIOFLUSH 2
|
||||
|
||||
/* line disciplines */
|
||||
#define LINUX_N_TTY 0
|
||||
#define LINUX_N_SLIP 1
|
||||
@ -488,4 +493,33 @@ struct trapframe;
|
||||
#define LINUX_SIOCADDMULTI 0x8931
|
||||
#define LINUX_SIOCDELMULTI 0x8932
|
||||
|
||||
/* serial_struct values for TIOC[GS]SERIAL ioctls */
|
||||
#define LINUX_ASYNC_CLOSING_WAIT_INF 0
|
||||
#define LINUX_ASYNC_CLOSING_WAIT_NONE 65535
|
||||
|
||||
#define LINUX_PORT_UNKNOWN 0
|
||||
#define LINUX_PORT_8250 1
|
||||
#define LINUX_PORT_16450 2
|
||||
#define LINUX_PORT_16550 3
|
||||
#define LINUX_PORT_16550A 4
|
||||
#define LINUX_PORT_CIRRUS 5
|
||||
#define LINUX_PORT_16650 6
|
||||
#define LINUX_PORT_MAX 6
|
||||
|
||||
#define LINUX_ASYNC_HUP_NOTIFY 0x0001
|
||||
#define LINUX_ASYNC_FOURPORT 0x0002
|
||||
#define LINUX_ASYNC_SAK 0x0004
|
||||
#define LINUX_ASYNC_SPLIT_TERMIOS 0x0008
|
||||
#define LINUX_ASYNC_SPD_MASK 0x0030
|
||||
#define LINUX_ASYNC_SPD_HI 0x0010
|
||||
#define LINUX_ASYNC_SPD_VHI 0x0020
|
||||
#define LINUX_ASYNC_SPD_CUST 0x0030
|
||||
#define LINUX_ASYNC_SKIP_TEST 0x0040
|
||||
#define LINUX_ASYNC_AUTO_IRQ 0x0080
|
||||
#define LINUX_ASYNC_SESSION_LOCKOUT 0x0100
|
||||
#define LINUX_ASYNC_PGRP_LOCKOUT 0x0200
|
||||
#define LINUX_ASYNC_CALLOUT_NOHUP 0x0400
|
||||
#define LINUX_ASYNC_FLAGS 0x0FFF
|
||||
|
||||
|
||||
#endif /* !_I386_LINUX_LINUX_H_ */
|
||||
|
@ -25,7 +25,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: linux_ioctl.c,v 1.7 1996/03/03 19:07:50 peter Exp $
|
||||
* $Id: linux_ioctl.c,v 1.8 1996/03/04 11:15:19 peter Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -82,6 +82,24 @@ static struct speedtab sptab[] = {
|
||||
{ 57600, 4097 }, { 115200, 4098 }, {-1, -1 }
|
||||
};
|
||||
|
||||
struct linux_serial_struct {
|
||||
int type;
|
||||
int line;
|
||||
int port;
|
||||
int irq;
|
||||
int flags;
|
||||
int xmit_fifo_size;
|
||||
int custom_divisor;
|
||||
int baud_base;
|
||||
unsigned short close_delay;
|
||||
char reserved_char[2];
|
||||
int hub6;
|
||||
unsigned short closing_wait;
|
||||
unsigned short closing_wait2;
|
||||
int reserved[4];
|
||||
};
|
||||
|
||||
|
||||
static int
|
||||
linux_to_bsd_speed(int code, struct speedtab *table)
|
||||
{
|
||||
@ -411,6 +429,23 @@ linux_to_bsd_termio(struct linux_termio *linux_termio,
|
||||
linux_to_bsd_termios(&tmios, bsd_termios);
|
||||
}
|
||||
|
||||
static void
|
||||
linux_tiocgserial(struct file *fp, struct linux_serial_struct *lss)
|
||||
{
|
||||
if (!fp || !lss)
|
||||
return;
|
||||
|
||||
lss->type = LINUX_PORT_16550A;
|
||||
lss->flags = 0;
|
||||
lss->close_delay = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
linux_tiocsserial(struct file *fp, struct linux_serial_struct *lss)
|
||||
{
|
||||
if (!fp || !lss)
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
linux_ioctl(struct proc *p, struct linux_ioctl_args *args, int *retval)
|
||||
@ -658,6 +693,32 @@ linux_ioctl(struct proc *p, struct linux_ioctl_args *args, int *retval)
|
||||
case LINUX_SNDCTL_DSP_NONBLOCK:
|
||||
args->cmd = SNDCTL_DSP_NONBLOCK;
|
||||
return ioctl(p, (struct ioctl_args *)args, retval);
|
||||
|
||||
case LINUX_TIOCGSERIAL:
|
||||
linux_tiocgserial(fp, (struct linux_serial_struct *)args->arg);
|
||||
return 0;
|
||||
|
||||
case LINUX_TIOCSSERIAL:
|
||||
linux_tiocsserial(fp, (struct linux_serial_struct *)args->arg);
|
||||
return 0;
|
||||
|
||||
case LINUX_TCFLSH:
|
||||
args->cmd = TIOCFLUSH;
|
||||
switch (args->arg) {
|
||||
case LINUX_TCIFLUSH:
|
||||
args->arg = FREAD;
|
||||
break;
|
||||
case LINUX_TCOFLUSH:
|
||||
args->arg = FWRITE;
|
||||
break;
|
||||
case LINUX_TCIOFLUSH:
|
||||
args->arg = FREAD | FWRITE;
|
||||
break;
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
return ioctl(p, (struct ioctl_args *)args, retval);
|
||||
|
||||
}
|
||||
uprintf("LINUX: 'ioctl' fd=%d, typ=0x%x(%c), num=0x%x not implemented\n",
|
||||
args->fd, (args->cmd&0xffff00)>>8,
|
||||
|
Loading…
Reference in New Issue
Block a user