1 |
|
/* |
2 |
|
* serial_unix.cpp - Serial device driver, Unix specific stuff |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-1999 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2002 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
67 |
|
fd = -1; |
68 |
|
input_thread_active = output_thread_active = false; |
69 |
|
|
70 |
< |
pthread_attr_init(&thread_attr); |
71 |
< |
#if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) |
72 |
< |
if (geteuid() == 0) { |
73 |
< |
pthread_attr_setinheritsched(&thread_attr, PTHREAD_EXPLICIT_SCHED); |
74 |
< |
pthread_attr_setschedpolicy(&thread_attr, SCHED_FIFO); |
75 |
< |
struct sched_param fifo_param; |
76 |
< |
fifo_param.sched_priority = (sched_get_priority_min(SCHED_FIFO) + sched_get_priority_max(SCHED_FIFO)) / 2 + 2; |
77 |
< |
pthread_attr_setschedparam(&thread_attr, &fifo_param); |
78 |
< |
} |
79 |
< |
#endif |
70 |
> |
Set_pthread_attr(&thread_attr, 2); |
71 |
|
} |
72 |
|
|
73 |
|
virtual ~XSERDPort() |
168 |
|
quitting = false; |
169 |
|
|
170 |
|
// Open port |
171 |
< |
fd = open(device_name, O_RDWR); |
171 |
> |
fd = ::open(device_name, O_RDWR); |
172 |
|
if (fd < 0) |
173 |
|
goto open_error; |
174 |
|
|
199 |
|
configure(config); |
200 |
|
|
201 |
|
// Start input/output threads |
202 |
+ |
input_thread_cancel = false; |
203 |
+ |
output_thread_cancel = false; |
204 |
|
if (sem_init(&input_signal, 0, 0) < 0) |
205 |
|
goto open_error; |
206 |
|
if (sem_init(&output_signal, 0, 0) < 0) |
231 |
|
output_thread_active = false; |
232 |
|
} |
233 |
|
if (fd > 0) { |
234 |
< |
close(fd); |
234 |
> |
::close(fd); |
235 |
|
fd = -1; |
236 |
|
} |
237 |
|
return openErr; |
506 |
|
|
507 |
|
// Close port |
508 |
|
if (fd > 0) |
509 |
< |
close(fd); |
509 |
> |
::close(fd); |
510 |
|
fd = -1; |
511 |
|
return noErr; |
512 |
|
} |
656 |
|
// KillIO called? Then simply return |
657 |
|
if (s->io_killed) { |
658 |
|
|
659 |
< |
WriteMacInt16(s->input_pb + ioResult, abortErr); |
659 |
> |
WriteMacInt16(s->input_pb + ioResult, uint16(abortErr)); |
660 |
|
WriteMacInt32(s->input_pb + ioActCount, 0); |
661 |
|
s->read_pending = s->read_done = false; |
662 |
|
|
668 |
|
WriteMacInt32(s->input_dt + serdtResult, noErr); |
669 |
|
} else { |
670 |
|
WriteMacInt32(s->input_pb + ioActCount, 0); |
671 |
< |
WriteMacInt32(s->input_dt + serdtResult, readErr); |
671 |
> |
WriteMacInt32(s->input_dt + serdtResult, uint16(readErr)); |
672 |
|
} |
673 |
|
|
674 |
|
// Trigger serial interrupt |
716 |
|
// KillIO called? Then simply return |
717 |
|
if (s->io_killed) { |
718 |
|
|
719 |
< |
WriteMacInt16(s->output_pb + ioResult, abortErr); |
719 |
> |
WriteMacInt16(s->output_pb + ioResult, uint16(abortErr)); |
720 |
|
WriteMacInt32(s->output_pb + ioActCount, 0); |
721 |
|
s->write_pending = s->write_done = false; |
722 |
|
|
728 |
|
WriteMacInt32(s->output_dt + serdtResult, noErr); |
729 |
|
} else { |
730 |
|
WriteMacInt32(s->output_pb + ioActCount, 0); |
731 |
< |
WriteMacInt32(s->output_dt + serdtResult, writErr); |
731 |
> |
WriteMacInt32(s->output_dt + serdtResult, uint16(writErr)); |
732 |
|
} |
733 |
|
|
734 |
|
// Trigger serial interrupt |