Re: Remove DM* modem control commands

2018-02-14 Thread Martin Pieuchot
On 14/02/18(Wed) 00:48, Tobias Ulmer wrote:
> Remove the ancient tty.h DMSET etc. modem control commands. They're confusing
> to someone without the historical background. No documentation doesn't help
> either.
> 
> TIOCM* serve the same purpose, are documented in tty(4) and the various *ctl()
> functions use the TTYCM_ register definitions, making this mix particularly 
> odd
> looking.
> 
> I've modified the *ctl() functions to use the same type and name as ioctl for
> clarity and correctness. Not strictly necessary, but makes me sleep better :)
> 
> Tested lightly on sparc64. sab still works. No luna88k, sorry.
> 
> 
> ## Background blah blah, skip if you just don't care :)
> 
> I've noticed these odd DM{SET,GET,BIC,BIS} constants in serial drivers all
> over the place and got curious. What do they mean?
> 
> Turns out, "DM" is a bolt-in add-on modem by DEC you would connect to
> your DH-11, apparently a 16 port serial port multiplexer for your VAX or
> PDP-11. As far as I can tell, the drivers were last included in 4.3BSD.
> You grey beards correct me on this.
> 
> The DM constants and the dmctl() function to manipulate the modem
> control register were added to dh in 1980 in order to support this fancy
> new modem.
> 
> Since then, just about every BSD serial driver has copied the basic structure,
> spreading DM* absolutely everywhere.
> 
> In 1982, Bill Shannon wanted to play with this control register in userspace
> (tip) and the ioctl interface was expanded by TIOCM{SET,GET,BIS,BIC}, hard
> coding the interface and register layout of that modem family for decades to 
> come.
> 
> dh gains dm support:
> https://github.com/weiss/original-bsd/commit/b47c3865305da4a404343aeedf0e3561071aae10
> 
> TIOCM modem control register bits show up:
> https://github.com/weiss/original-bsd/commit/d9d9928137170ec2f49e62509b12d012cac154de
> https://github.com/weiss/original-bsd/commit/c849aa74bd3aaa1d644d74d9628ba0e1be028e1a
> 
> http://gunkies.org/wiki/DH11_asynchronous_serial_line_interface
> http://bitsavers.trailing-edge.com/pdf/dec/unibus/ datasheets..
> 
> Who needs TV when you can dig up amusing trivia about early BSD development!

Your diff contains a duplicated chunk: the one in sys/tty.h.

No software on codesearch.debian.net rely on the defines you're removing,
so ok with me :)

> Index: sys/tty.h
> ===
> RCS file: /home/vcs/cvs/openbsd/src/sys/sys/tty.h,v
> retrieving revision 1.37
> diff -u -p -r1.37 tty.h
> --- sys/tty.h 24 May 2016 16:09:07 -  1.37
> +++ sys/tty.h 13 Feb 2018 20:39:54 -
> @@ -215,12 +215,6 @@ struct speedtab {
>   int sp_code;/* Code. */
>  };
>  
> -/* Modem control commands (driver). */
> -#define  DMSET   0
> -#define  DMBIS   1
> -#define  DMBIC   2
> -#define  DMGET   3
> -
>  /* Flags on a character passed to ttyinput. */
>  #define  TTY_CHARMASK0x00ff  /* Character mask */
>  #define  TTY_QUOTE   0x0100  /* Character quoted */
>  
> Index: arch/armv7/exynos/exuart.c
> ===
> RCS file: /home/vcs/cvs/openbsd/src/sys/arch/armv7/exynos/exuart.c,v
> retrieving revision 1.13
> diff -u -p -r1.13 exuart.c
> --- arch/armv7/exynos/exuart.c27 Oct 2017 11:23:28 -  1.13
> +++ arch/armv7/exynos/exuart.c13 Feb 2018 20:38:56 -
> @@ -784,37 +784,37 @@ exuartioctl( dev_t dev, u_long cmd, cadd
>  
>   case TIOCSDTR:
>  #if 0
> - (void) clmctl(dev, TIOCM_DTR | TIOCM_RTS, DMBIS);
> + (void) clmctl(dev, TIOCM_DTR | TIOCM_RTS, TIOCMBIS);
>  #endif
>   break;
>  
>   case TIOCCDTR:
>  #if 0
> - (void) clmctl(dev, TIOCM_DTR | TIOCM_RTS, DMBIC);
> + (void) clmctl(dev, TIOCM_DTR | TIOCM_RTS, TIOCMBIC);
>  #endif
>   break;
>  
>   case TIOCMSET:
>  #if 0
> - (void) clmctl(dev, *(int *) data, DMSET);
> + (void) clmctl(dev, *(int *) data, TIOCMSET);
>  #endif
>   break;
>  
>   case TIOCMBIS:
>  #if 0
> - (void) clmctl(dev, *(int *) data, DMBIS);
> + (void) clmctl(dev, *(int *) data, TIOCMBIS);
>  #endif
>   break;
>  
>   case TIOCMBIC:
>  #if 0
> - (void) clmctl(dev, *(int *) data, DMBIC);
> + (void) clmctl(dev, *(int *) data, TIOCMBIC);
>  #endif
>   break;
>  
>  case TIOCMGET:
>  #if 0
> - *(int *)data = clmctl(dev, 0, DMGET);
> + *(int *)data = clmctl(dev, 0, TIOCMGET);
>  #endif
>   break;
>  
> Index: arch/armv7/imx/imxuart.c
> ===
> RCS file: /home/vcs/cvs/openbsd/src/sys/arch/armv7/imx/imxuart.c,v
> retrieving revision 1.17
> diff -u -p -r1.17 imxuart.c
> --- arch/armv7/imx/imxuart.c  30 Dec 2017 13:34:56 -  1.17
> +++ a

Remove DM* modem control commands

2018-02-13 Thread Tobias Ulmer
Remove the ancient tty.h DMSET etc. modem control commands. They're confusing
to someone without the historical background. No documentation doesn't help
either.

TIOCM* serve the same purpose, are documented in tty(4) and the various *ctl()
functions use the TTYCM_ register definitions, making this mix particularly odd
looking.

I've modified the *ctl() functions to use the same type and name as ioctl for
clarity and correctness. Not strictly necessary, but makes me sleep better :)

Tested lightly on sparc64. sab still works. No luna88k, sorry.


## Background blah blah, skip if you just don't care :)

I've noticed these odd DM{SET,GET,BIC,BIS} constants in serial drivers all
over the place and got curious. What do they mean?

Turns out, "DM" is a bolt-in add-on modem by DEC you would connect to
your DH-11, apparently a 16 port serial port multiplexer for your VAX or
PDP-11. As far as I can tell, the drivers were last included in 4.3BSD.
You grey beards correct me on this.

The DM constants and the dmctl() function to manipulate the modem
control register were added to dh in 1980 in order to support this fancy
new modem.

Since then, just about every BSD serial driver has copied the basic structure,
spreading DM* absolutely everywhere.

In 1982, Bill Shannon wanted to play with this control register in userspace
(tip) and the ioctl interface was expanded by TIOCM{SET,GET,BIS,BIC}, hard
coding the interface and register layout of that modem family for decades to 
come.

dh gains dm support:
https://github.com/weiss/original-bsd/commit/b47c3865305da4a404343aeedf0e3561071aae10

TIOCM modem control register bits show up:
https://github.com/weiss/original-bsd/commit/d9d9928137170ec2f49e62509b12d012cac154de
https://github.com/weiss/original-bsd/commit/c849aa74bd3aaa1d644d74d9628ba0e1be028e1a

http://gunkies.org/wiki/DH11_asynchronous_serial_line_interface
http://bitsavers.trailing-edge.com/pdf/dec/unibus/ datasheets..

Who needs TV when you can dig up amusing trivia about early BSD development!

Index: sys/tty.h
===
RCS file: /home/vcs/cvs/openbsd/src/sys/sys/tty.h,v
retrieving revision 1.37
diff -u -p -r1.37 tty.h
--- sys/tty.h   24 May 2016 16:09:07 -  1.37
+++ sys/tty.h   13 Feb 2018 20:39:54 -
@@ -215,12 +215,6 @@ struct speedtab {
int sp_code;/* Code. */
 };
 
-/* Modem control commands (driver). */
-#defineDMSET   0
-#defineDMBIS   1
-#defineDMBIC   2
-#defineDMGET   3
-
 /* Flags on a character passed to ttyinput. */
 #defineTTY_CHARMASK0x00ff  /* Character mask */
 #defineTTY_QUOTE   0x0100  /* Character quoted */
 
Index: arch/armv7/exynos/exuart.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/arch/armv7/exynos/exuart.c,v
retrieving revision 1.13
diff -u -p -r1.13 exuart.c
--- arch/armv7/exynos/exuart.c  27 Oct 2017 11:23:28 -  1.13
+++ arch/armv7/exynos/exuart.c  13 Feb 2018 20:38:56 -
@@ -784,37 +784,37 @@ exuartioctl( dev_t dev, u_long cmd, cadd
 
case TIOCSDTR:
 #if 0
-   (void) clmctl(dev, TIOCM_DTR | TIOCM_RTS, DMBIS);
+   (void) clmctl(dev, TIOCM_DTR | TIOCM_RTS, TIOCMBIS);
 #endif
break;
 
case TIOCCDTR:
 #if 0
-   (void) clmctl(dev, TIOCM_DTR | TIOCM_RTS, DMBIC);
+   (void) clmctl(dev, TIOCM_DTR | TIOCM_RTS, TIOCMBIC);
 #endif
break;
 
case TIOCMSET:
 #if 0
-   (void) clmctl(dev, *(int *) data, DMSET);
+   (void) clmctl(dev, *(int *) data, TIOCMSET);
 #endif
break;
 
case TIOCMBIS:
 #if 0
-   (void) clmctl(dev, *(int *) data, DMBIS);
+   (void) clmctl(dev, *(int *) data, TIOCMBIS);
 #endif
break;
 
case TIOCMBIC:
 #if 0
-   (void) clmctl(dev, *(int *) data, DMBIC);
+   (void) clmctl(dev, *(int *) data, TIOCMBIC);
 #endif
break;
 
 case TIOCMGET:
 #if 0
-   *(int *)data = clmctl(dev, 0, DMGET);
+   *(int *)data = clmctl(dev, 0, TIOCMGET);
 #endif
break;
 
Index: arch/armv7/imx/imxuart.c
===
RCS file: /home/vcs/cvs/openbsd/src/sys/arch/armv7/imx/imxuart.c,v
retrieving revision 1.17
diff -u -p -r1.17 imxuart.c
--- arch/armv7/imx/imxuart.c30 Dec 2017 13:34:56 -  1.17
+++ arch/armv7/imx/imxuart.c13 Feb 2018 20:38:56 -
@@ -701,37 +701,37 @@ imxuartioctl( dev_t dev, u_long cmd, cad
 
case TIOCSDTR:
 #if 0
-   (void) clmctl(dev, TIOCM_DTR | TIOCM_RTS, DMBIS);
+   (void) clmctl(dev, TIOCM_DTR | TIOCM_RTS, TIOCMBIS);
 #endif
break;
 
case TIOCCDTR:
 #if 0
-   (void) clmctl(dev, TIOCM_DTR | TIOCM