Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent a serial RX overflow if the port is in FIFO mode #307

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions bochs/iodev/serial.cc
Original file line number Diff line number Diff line change
Expand Up @@ -544,16 +544,17 @@ bx_serial_c::init(void)
if (server) {
// server mode
pipe = CreateNamedPipe( dev,
PIPE_ACCESS_DUPLEX | FILE_FLAG_FIRST_PIPE_INSTANCE,
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
PIPE_ACCESS_DUPLEX,
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_NOWAIT,
1, 4096, 4096, 0, NULL);

if (pipe == INVALID_HANDLE_VALUE) {
BX_PANIC(("com%d: CreateNamedPipe(%s) failed", i+1, dev));
continue;
}
BX_INFO(("com%d: waiting for client to connect to %s", i+1, dev));
if (!ConnectNamedPipe(pipe, NULL) && GetLastError() != ERROR_PIPE_CONNECTED)
if (!ConnectNamedPipe(pipe, NULL) && GetLastError() != ERROR_PIPE_CONNECTED
&& GetLastError() != ERROR_PIPE_LISTENING)
{
CloseHandle(pipe);
pipe = INVALID_HANDLE_VALUE;
Expand Down Expand Up @@ -1538,8 +1539,10 @@ void bx_serial_c::rx_timer(void)
if (BX_SER_THIS s[port].tty_id >= 0) FD_SET(BX_SER_THIS s[port].tty_id, &fds);
#endif
}

// N.B: Throttle inputs if the OS has not yet responded to us.
if ((BX_SER_THIS s[port].line_status.rxdata_ready == 0) ||
(BX_SER_THIS s[port].fifo_cntl.enable)) {
((BX_SER_THIS s[port].fifo_cntl.enable) && (BX_SER_THIS s[port].rx_fifo_end < 15))) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what your thoughts are on applying this to BX_SER_MODE_RAW - that's the only odd one out here.

switch (BX_SER_THIS s[port].io_mode) {
case BX_SER_MODE_SOCKET_CLIENT:
case BX_SER_MODE_SOCKET_SERVER:
Expand Down