ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/serial_unix.cpp
(Generate patch)

Comparing BasiliskII/src/Unix/serial_unix.cpp (file contents):
Revision 1.1 by cebix, 1999-10-03T14:16:25Z vs.
Revision 1.10 by cebix, 2002-02-07T16:10:55Z

# Line 1 | Line 1
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
# Line 67 | Line 67 | public:
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()
# Line 101 | Line 92 | public:
92                  }
93          }
94  
95 <        virtual int16 Open(uint16 config);
96 <        virtual int16 PrimeIn(uint32 pb, uint32 dce);
97 <        virtual int16 PrimeOut(uint32 pb, uint32 dce);
98 <        virtual int16 Control(uint32 pb, uint32 dce, uint16 code);
99 <        virtual int16 Status(uint32 pb, uint32 dce, uint16 code);
100 <        virtual int16 Close(void);
95 >        virtual int16 open(uint16 config);
96 >        virtual int16 prime_in(uint32 pb, uint32 dce);
97 >        virtual int16 prime_out(uint32 pb, uint32 dce);
98 >        virtual int16 control(uint32 pb, uint32 dce, uint16 code);
99 >        virtual int16 status(uint32 pb, uint32 dce, uint16 code);
100 >        virtual int16 close(void);
101  
102   private:
103          bool configure(uint16 config);
# Line 166 | Line 157 | void SerialExit(void)
157   *  Open serial port
158   */
159  
160 < int16 XSERDPort::Open(uint16 config)
160 > int16 XSERDPort::open(uint16 config)
161   {
162          // Don't open NULL name devices
163          if (device_name == NULL)
# Line 177 | Line 168 | int16 XSERDPort::Open(uint16 config)
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  
175 < #ifdef __linux__
175 > #if defined(__linux__)
176          // Parallel port?
177          struct stat st;
178          if (fstat(fd, &st) == 0)
179                  if (S_ISCHR(st.st_mode))
180                          is_parallel = (MAJOR(st.st_rdev) == LP_MAJOR);
181 < #elif defined(__FreeBSD__)
181 > #elif defined(__FreeBSD__) || defined(__NetBSD__)
182          // Parallel port?
183          struct stat st;
184          if (fstat(fd, &st) == 0)
# Line 208 | Line 199 | int16 XSERDPort::Open(uint16 config)
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)
# Line 238 | Line 231 | open_error:
231                  output_thread_active = false;
232          }
233          if (fd > 0) {
234 <                close(fd);
234 >                ::close(fd);
235                  fd = -1;
236          }
237          return openErr;
# Line 249 | Line 242 | open_error:
242   *  Read data from port
243   */
244  
245 < int16 XSERDPort::PrimeIn(uint32 pb, uint32 dce)
245 > int16 XSERDPort::prime_in(uint32 pb, uint32 dce)
246   {
247          // Send input command to input_thread
248          read_done = false;
# Line 265 | Line 258 | int16 XSERDPort::PrimeIn(uint32 pb, uint
258   *  Write data to port
259   */
260  
261 < int16 XSERDPort::PrimeOut(uint32 pb, uint32 dce)
261 > int16 XSERDPort::prime_out(uint32 pb, uint32 dce)
262   {
263          // Send output command to output_thread
264          write_done = false;
# Line 281 | Line 274 | int16 XSERDPort::PrimeOut(uint32 pb, uin
274   *      Control calls
275   */
276  
277 < int16 XSERDPort::Control(uint32 pb, uint32 dce, uint16 code)
277 > int16 XSERDPort::control(uint32 pb, uint32 dce, uint16 code)
278   {
279          switch (code) {
280                  case 1:                 // KillIO
# Line 446 | Line 439 | int16 XSERDPort::Control(uint32 pb, uint
439   *      Status calls
440   */
441  
442 < int16 XSERDPort::Status(uint32 pb, uint32 dce, uint16 code)
442 > int16 XSERDPort::status(uint32 pb, uint32 dce, uint16 code)
443   {
444          switch (code) {
445                  case kSERDInputCount: {
# Line 493 | Line 486 | int16 XSERDPort::Status(uint32 pb, uint3
486   *      Close serial port
487   */
488  
489 < int16 XSERDPort::Close()
489 > int16 XSERDPort::close()
490   {
491          // Kill threads
492          if (input_thread_active) {
# Line 513 | Line 506 | int16 XSERDPort::Close()
506  
507          // Close port
508          if (fd > 0)
509 <                close(fd);
509 >                ::close(fd);
510          fd = -1;
511          return noErr;
512   }
# Line 663 | Line 656 | void *XSERDPort::input_func(void *arg)
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  
# Line 675 | Line 668 | void *XSERDPort::input_func(void *arg)
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
# Line 723 | Line 716 | void *XSERDPort::output_func(void *arg)
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  
# Line 735 | Line 728 | void *XSERDPort::output_func(void *arg)
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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines