Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
898ab8da
Commit
898ab8da
authored
Mar 03, 2024
by
Kirill Zhumarin
Committed by
Alexandre Julliard
Apr 30, 2024
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Use termios2 for serial when possible.
parent
b5b22136
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
165 additions
and
3 deletions
+165
-3
configure
configure
+6
-0
configure.ac
configure.ac
+1
-0
serial.c
dlls/ntdll/unix/serial.c
+155
-3
config.h.in
include/config.h.in
+3
-0
No files found.
configure
View file @
898ab8da
...
...
@@ -7890,6 +7890,12 @@ then :
printf
"%s
\n
"
"#define HAVE_ARPA_NAMESER_H 1"
>>
confdefs.h
fi
ac_fn_c_check_header_compile
"
$LINENO
"
"asm/termbits.h"
"ac_cv_header_asm_termbits_h"
"
$ac_includes_default
"
if
test
"x
$ac_cv_header_asm_termbits_h
"
=
xyes
then
:
printf
"%s
\n
"
"#define HAVE_ASM_TERMBITS_H 1"
>>
confdefs.h
fi
ac_fn_c_check_header_compile
"
$LINENO
"
"asm/types.h"
"ac_cv_header_asm_types_h"
"
$ac_includes_default
"
if
test
"x
$ac_cv_header_asm_types_h
"
=
xyes
then
:
...
...
configure.ac
View file @
898ab8da
...
...
@@ -368,6 +368,7 @@ AC_CHECK_HEADERS(\
OpenCL/opencl.h \
arpa/inet.h \
arpa/nameser.h \
asm/termbits.h \
asm/types.h \
asm/user.h \
elf.h \
...
...
dlls/ntdll/unix/serial.c
View file @
898ab8da
...
...
@@ -31,7 +31,11 @@
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <termios.h>
#ifdef HAVE_ASM_TERMBITS_H
# include <asm/termbits.h>
#else
# include <termios.h>
#endif
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
...
...
@@ -119,6 +123,18 @@ static const char* iocode2str(UINT ioc)
static
NTSTATUS
get_baud_rate
(
int
fd
,
SERIAL_BAUD_RATE
*
sbr
)
{
#ifdef HAVE_ASM_TERMBITS_H
struct
termios2
port
;
if
(
ioctl
(
fd
,
TCGETS2
,
&
port
)
==
-
1
)
{
ERR
(
"ioctl TCGETS2 error '%s'
\n
"
,
strerror
(
errno
));
return
errno_to_status
(
errno
);
}
/* TERMIOS2 supports separate input and output baudrate, but wine supports only the common baudrate. */
sbr
->
BaudRate
=
port
.
c_ospeed
;
#else
struct
termios
port
;
int
speed
;
...
...
@@ -192,12 +208,22 @@ static NTSTATUS get_baud_rate(int fd, SERIAL_BAUD_RATE* sbr)
ERR
(
"unknown speed %x
\n
"
,
speed
);
return
STATUS_INVALID_PARAMETER
;
}
#endif
return
STATUS_SUCCESS
;
}
static
NTSTATUS
get_hand_flow
(
int
fd
,
SERIAL_HANDFLOW
*
shf
)
{
int
stat
=
0
;
#ifdef HAVE_ASM_TERMBITS_H
struct
termios2
port
;
if
(
ioctl
(
fd
,
TCGETS2
,
&
port
)
==
-
1
)
{
ERR
(
"ioctl TCGETS2 error '%s'
\n
"
,
strerror
(
errno
));
return
errno_to_status
(
errno
);
}
#else
struct
termios
port
;
if
(
tcgetattr
(
fd
,
&
port
)
==
-
1
)
...
...
@@ -205,6 +231,7 @@ static NTSTATUS get_hand_flow(int fd, SERIAL_HANDFLOW* shf)
ERR
(
"tcgetattr error '%s'
\n
"
,
strerror
(
errno
));
return
errno_to_status
(
errno
);
}
#endif
/* termios does not support DTR/DSR flow control */
shf
->
ControlHandShake
=
0
;
shf
->
FlowReplace
=
0
;
...
...
@@ -250,6 +277,15 @@ static NTSTATUS get_hand_flow(int fd, SERIAL_HANDFLOW* shf)
static
NTSTATUS
get_line_control
(
int
fd
,
SERIAL_LINE_CONTROL
*
slc
)
{
#ifdef HAVE_ASM_TERMBITS_H
struct
termios2
port
;
if
(
ioctl
(
fd
,
TCGETS2
,
&
port
)
==
-
1
)
{
ERR
(
"ioctl TCGETS2 error '%s'
\n
"
,
strerror
(
errno
));
return
errno_to_status
(
errno
);
}
#else
struct
termios
port
;
if
(
tcgetattr
(
fd
,
&
port
)
==
-
1
)
...
...
@@ -257,6 +293,7 @@ static NTSTATUS get_line_control(int fd, SERIAL_LINE_CONTROL* slc)
ERR
(
"tcgetattr error '%s'
\n
"
,
strerror
(
errno
));
return
errno_to_status
(
errno
);
}
#endif
#ifdef CMSPAR
switch
(
port
.
c_cflag
&
(
PARENB
|
PARODD
|
CMSPAR
))
...
...
@@ -356,6 +393,15 @@ static NTSTATUS get_properties(int fd, SERIAL_COMMPROP *prop)
static
NTSTATUS
get_special_chars
(
int
fd
,
SERIAL_CHARS
*
sc
)
{
#ifdef HAVE_ASM_TERMBITS_H
struct
termios2
port
;
if
(
ioctl
(
fd
,
TCGETS2
,
&
port
)
==
-
1
)
{
ERR
(
"ioctl TCGETS2 error '%s'
\n
"
,
strerror
(
errno
));
return
errno_to_status
(
errno
);
}
#else
struct
termios
port
;
if
(
tcgetattr
(
fd
,
&
port
)
==
-
1
)
...
...
@@ -363,6 +409,8 @@ static NTSTATUS get_special_chars(int fd, SERIAL_CHARS* sc)
ERR
(
"tcgetattr error '%s'
\n
"
,
strerror
(
errno
));
return
errno_to_status
(
errno
);
}
#endif
sc
->
EofChar
=
port
.
c_cc
[
VEOF
];
sc
->
ErrorChar
=
0xFF
;
sc
->
BreakChar
=
0
;
/* FIXME */
...
...
@@ -444,15 +492,45 @@ static NTSTATUS purge(int fd, DWORD flags)
** Perhaps if we had our own internal queues, one flushes them
** and the other flushes the kernel's buffers.
*/
#ifdef HAVE_ASM_TERMBITS_H
if
(
flags
&
PURGE_TXABORT
)
ioctl
(
fd
,
TCFLSH
,
TCOFLUSH
);
if
(
flags
&
PURGE_RXABORT
)
ioctl
(
fd
,
TCFLSH
,
TCIFLUSH
);
if
(
flags
&
PURGE_TXCLEAR
)
ioctl
(
fd
,
TCFLSH
,
TCOFLUSH
);
if
(
flags
&
PURGE_RXCLEAR
)
ioctl
(
fd
,
TCFLSH
,
TCIFLUSH
);
#else
if
(
flags
&
PURGE_TXABORT
)
tcflush
(
fd
,
TCOFLUSH
);
if
(
flags
&
PURGE_RXABORT
)
tcflush
(
fd
,
TCIFLUSH
);
if
(
flags
&
PURGE_TXCLEAR
)
tcflush
(
fd
,
TCOFLUSH
);
if
(
flags
&
PURGE_RXCLEAR
)
tcflush
(
fd
,
TCIFLUSH
);
#endif
return
STATUS_SUCCESS
;
}
static
NTSTATUS
set_baud_rate
(
int
fd
,
const
SERIAL_BAUD_RATE
*
sbr
)
{
#ifdef HAVE_ASM_TERMBITS_H
struct
termios2
port
;
if
(
ioctl
(
fd
,
TCGETS2
,
&
port
)
==
-
1
)
{
ERR
(
"ioctl TCGETS2 error '%s'
\n
"
,
strerror
(
errno
));
return
errno_to_status
(
errno
);
}
port
.
c_cflag
&=
~
CBAUD
;
port
.
c_cflag
|=
BOTHER
;
port
.
c_ospeed
=
sbr
->
BaudRate
;
port
.
c_cflag
&=
~
(
CBAUD
<<
IBSHIFT
);
port
.
c_cflag
|=
BOTHER
<<
IBSHIFT
;
port
.
c_ispeed
=
sbr
->
BaudRate
;
if
(
ioctl
(
fd
,
TCSETS2
,
&
port
)
==
-
1
)
{
ERR
(
"ioctl TCSETS2 error '%s'
\n
"
,
strerror
(
errno
));
return
errno_to_status
(
errno
);
}
#else
struct
termios
port
;
if
(
tcgetattr
(
fd
,
&
port
)
==
-
1
)
...
...
@@ -564,6 +642,7 @@ static NTSTATUS set_baud_rate(int fd, const SERIAL_BAUD_RATE* sbr)
ERR
(
"tcsetattr error '%s'
\n
"
,
strerror
(
errno
));
return
errno_to_status
(
errno
);
}
#endif
return
STATUS_SUCCESS
;
}
...
...
@@ -583,17 +662,29 @@ static int whack_modem(int fd, unsigned int andy, unsigned int orrie)
static
NTSTATUS
set_handflow
(
int
fd
,
const
SERIAL_HANDFLOW
*
shf
)
{
#ifdef HAVE_ASM_TERMBITS_H
struct
termios2
port
;
#else
struct
termios
port
;
#endif
if
((
shf
->
FlowReplace
&
(
SERIAL_RTS_CONTROL
|
SERIAL_RTS_HANDSHAKE
))
==
(
SERIAL_RTS_CONTROL
|
SERIAL_RTS_HANDSHAKE
))
return
STATUS_NOT_SUPPORTED
;
#ifdef HAVE_ASM_TERMBITS_H
if
(
ioctl
(
fd
,
TCGETS2
,
&
port
)
==
-
1
)
{
ERR
(
"ioctl TCGETS2 error '%s'
\n
"
,
strerror
(
errno
));
return
errno_to_status
(
errno
);
}
#else
if
(
tcgetattr
(
fd
,
&
port
)
==
-
1
)
{
ERR
(
"tcgetattr error '%s'
\n
"
,
strerror
(
errno
));
return
errno_to_status
(
errno
);
}
#endif
#ifdef CRTSCTS
if
((
shf
->
ControlHandShake
&
SERIAL_CTS_HANDSHAKE
)
||
...
...
@@ -632,25 +723,44 @@ static NTSTATUS set_handflow(int fd, const SERIAL_HANDFLOW* shf)
port
.
c_iflag
|=
IXON
;
else
port
.
c_iflag
&=
~
IXON
;
#ifdef HAVE_ASM_TERMBITS_H
if
(
ioctl
(
fd
,
TCSETS2
,
&
port
)
==
-
1
)
{
ERR
(
"ioctl TCSETS2 error '%s'
\n
"
,
strerror
(
errno
));
return
errno_to_status
(
errno
);
}
#else
if
(
tcsetattr
(
fd
,
TCSANOW
,
&
port
)
==
-
1
)
{
ERR
(
"tcsetattr error '%s'
\n
"
,
strerror
(
errno
));
return
errno_to_status
(
errno
);
}
#endif
return
STATUS_SUCCESS
;
}
static
NTSTATUS
set_line_control
(
int
fd
,
const
SERIAL_LINE_CONTROL
*
slc
)
{
struct
termios
port
;
unsigned
bytesize
,
stopbits
;
#ifdef HAVE_ASM_TERMBITS_H
struct
termios2
port
;
if
(
ioctl
(
fd
,
TCGETS2
,
&
port
)
==
-
1
)
{
ERR
(
"ioctl TCGETS2 error '%s'
\n
"
,
strerror
(
errno
));
return
errno_to_status
(
errno
);
}
#else
struct
termios
port
;
if
(
tcgetattr
(
fd
,
&
port
)
==
-
1
)
{
ERR
(
"tcgetattr error '%s'
\n
"
,
strerror
(
errno
));
return
errno_to_status
(
errno
);
}
#endif
#ifdef IMAXBEL
port
.
c_iflag
&=
~
(
ISTRIP
|
BRKINT
|
IGNCR
|
ICRNL
|
INLCR
|
PARMRK
|
IMAXBEL
);
...
...
@@ -745,11 +855,19 @@ static NTSTATUS set_line_control(int fd, const SERIAL_LINE_CONTROL* slc)
return
STATUS_NOT_SUPPORTED
;
}
/* otherwise it hangs with pending input*/
#ifdef HAVE_ASM_TERMBITS_H
if
(
ioctl
(
fd
,
TCSETS2
,
&
port
)
==
-
1
)
{
ERR
(
"ioctl TCSETS2 error '%s'
\n
"
,
strerror
(
errno
));
return
errno_to_status
(
errno
);
}
#else
if
(
tcsetattr
(
fd
,
TCSANOW
,
&
port
)
==
-
1
)
{
ERR
(
"tcsetattr error '%s'
\n
"
,
strerror
(
errno
));
return
errno_to_status
(
errno
);
}
#endif
return
STATUS_SUCCESS
;
}
...
...
@@ -761,6 +879,15 @@ static NTSTATUS set_queue_size(int fd, const SERIAL_QUEUE_SIZE* sqs)
static
NTSTATUS
set_special_chars
(
int
fd
,
const
SERIAL_CHARS
*
sc
)
{
#ifdef HAVE_ASM_TERMBITS_H
struct
termios2
port
;
if
(
ioctl
(
fd
,
TCGETS2
,
&
port
)
==
-
1
)
{
ERR
(
"ioctl TCGETS2 error '%s'
\n
"
,
strerror
(
errno
));
return
errno_to_status
(
errno
);
}
#else
struct
termios
port
;
if
(
tcgetattr
(
fd
,
&
port
)
==
-
1
)
...
...
@@ -768,6 +895,7 @@ static NTSTATUS set_special_chars(int fd, const SERIAL_CHARS* sc)
ERR
(
"tcgetattr error '%s'
\n
"
,
strerror
(
errno
));
return
errno_to_status
(
errno
);
}
#endif
port
.
c_cc
[
VEOF
]
=
sc
->
EofChar
;
/* FIXME: sc->ErrorChar is not supported */
...
...
@@ -776,11 +904,19 @@ static NTSTATUS set_special_chars(int fd, const SERIAL_CHARS* sc)
port
.
c_cc
[
VSTART
]
=
sc
->
XonChar
;
port
.
c_cc
[
VSTOP
]
=
sc
->
XoffChar
;
#ifdef HAVE_ASM_TERMBITS_H
if
(
ioctl
(
fd
,
TCSETS2
,
&
port
)
==
-
1
)
{
ERR
(
"ioctl TCSETS2 error '%s'
\n
"
,
strerror
(
errno
));
return
errno_to_status
(
errno
);
}
#else
if
(
tcsetattr
(
fd
,
TCSANOW
,
&
port
)
==
-
1
)
{
ERR
(
"tcsetattr error '%s'
\n
"
,
strerror
(
errno
));
return
errno_to_status
(
errno
);
}
#endif
return
STATUS_SUCCESS
;
}
...
...
@@ -789,10 +925,18 @@ static NTSTATUS set_special_chars(int fd, const SERIAL_CHARS* sc)
*/
static
NTSTATUS
set_XOff
(
int
fd
)
{
#ifdef HAVE_ASM_TERMBITS_H
if
(
ioctl
(
fd
,
TCXONC
,
TCOOFF
)
==
-
1
)
{
ERR
(
"ioctl TCXONC error '%s'
\n
"
,
strerror
(
errno
));
return
errno_to_status
(
errno
);
}
#else
if
(
tcflow
(
fd
,
TCOOFF
))
{
return
errno_to_status
(
errno
);
}
#endif
return
STATUS_SUCCESS
;
}
...
...
@@ -801,10 +945,18 @@ static NTSTATUS set_XOff(int fd)
*/
static
NTSTATUS
set_XOn
(
int
fd
)
{
#ifdef HAVE_ASM_TERMBITS_H
if
(
ioctl
(
fd
,
TCXONC
,
TCOON
)
==
-
1
)
{
ERR
(
"ioctl TCXONC error '%s'
\n
"
,
strerror
(
errno
));
return
errno_to_status
(
errno
);
}
#else
if
(
tcflow
(
fd
,
TCOON
))
{
return
errno_to_status
(
errno
);
}
#endif
return
STATUS_SUCCESS
;
}
...
...
@@ -1364,7 +1516,7 @@ NTSTATUS serial_DeviceIoControl( HANDLE device, HANDLE event, PIO_APC_ROUTINE ap
NTSTATUS
serial_FlushBuffersFile
(
int
fd
)
{
#if
def HAVE_TCDRAIN
#if
defined(HAVE_TCDRAIN) && !defined(HAVE_ASM_TERMBITS_H)
while
(
tcdrain
(
fd
)
==
-
1
)
{
if
(
errno
!=
EINTR
)
return
errno_to_status
(
errno
);
...
...
include/config.h.in
View file @
898ab8da
...
...
@@ -12,6 +12,9 @@
/* Define to 1 if you have the <arpa/nameser.h> header file. */
#undef HAVE_ARPA_NAMESER_H
/* Define to 1 if you have the <asm/termbits.h> header file. */
#undef HAVE_ASM_TERMBITS_H
/* Define to 1 if you have the <asm/types.h> header file. */
#undef HAVE_ASM_TYPES_H
...
...
Vitaly Lipatov
@lav
mentioned in commit
24ca848c
·
May 08, 2024
mentioned in commit
24ca848c
mentioned in commit 24ca848c568d5a2786abd26f2e7314b2e3f509f3
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment