static void undump_pra(riot_context_t *riot_context, BYTE byte) { drive_context_t *drive_context; drive_context = (drive_context_t *)(riot_context->context); /* bit 0 = atna */ set_handshake(riot_context, byte); drive_context->func->parallel_set_eoi((BYTE)(!(byte & 0x08))); drive_context->func->parallel_set_dav((BYTE)(!(byte & 0x10))); }
static void store_pra(riot_context_t *riot_context, BYTE byte) { drive_context_t *drive_context; drive_context = (drive_context_t *)(riot_context->context); /* bit 0 = atna */ /* bit 1 = /daco */ /* bit 2 = rfdo */ /* bit 3 = eoio */ /* bit 4 = davo */ set_handshake(riot_context, byte); /* handle atna, nrfd, ndac */ drive_context->func->parallel_set_eoi((BYTE)(!(byte & 0x08))); drive_context->func->parallel_set_dav((BYTE)(!(byte & 0x10))); }
static void reset(riot_context_t *riot_context) { drive_context_t *drive_context; driveriot2_context_t *riot2p; drive_context = (drive_context_t *)(riot_context->context); riot2p = (driveriot2_context_t *)(riot_context->prv); riot2p->r_atn_active = 0; drive_context->func->parallel_set_dav(0); drive_context->func->parallel_set_eoi(0); set_handshake(riot_context, riot_context->old_pa); /* 1001 only needs LED 0 and Error LED */ riot2p->drive->led_status = 3; }
void riot2_set_atn(riot_context_t *riot_context, int state) { drive_context_t *drive_context; driveriot2_context_t *riot2p; drive_context = (drive_context_t *)(riot_context->context); riot2p = (driveriot2_context_t *)(riot_context->prv); if (drive_check_old(riot2p->drive->type)) { if (riot2p->r_atn_active && !state) { riotcore_signal(riot_context, RIOT_SIG_PA7, RIOT_SIG_FALL); } else if (state && !(riot2p->r_atn_active)) { riotcore_signal(riot_context, RIOT_SIG_PA7, RIOT_SIG_RISE); } riot2p->r_atn_active = state; riot1_set_pardata(drive_context->riot1); set_handshake(riot_context, riot_context->old_pa); } }
int16 ASERDPort::control(uint32 pb, uint32 dce, uint16 code) { D(bug("control(%ld)\n", (uint32)code)); switch (code) { case 1: // KillIO send_to_proc(MSG_KILL_IO); return noErr; case kSERDConfiguration: if (configure(ReadMacInt16(pb + csParam))) return noErr; else return paramErr; case kSERDInputBuffer: { if (is_parallel) return noErr; int buf = ReadMacInt16(pb + csParam + 4) & 0xffffffc0; if (buf < 1024) // 1k minimum buf = 1024; D(bug(" buffer size is now %08lx\n", buf)); control_io->io_RBufLen = buf; return set_params() ? noErr : paramErr; } case kSERDSerHShake: set_handshake(pb + csParam, false); return noErr; case kSERDSetBreak: if (!is_parallel) send_to_proc(MSG_BREAK); return noErr; case kSERDClearBreak: return noErr; case kSERDBaudRate: if (is_parallel) return noErr; control_io->io_Baud = ReadMacInt16(pb + csParam); D(bug(" baud rate %ld\n", control_io->io_Baud)); return set_params() ? noErr : paramErr; case kSERDHandshake: case kSERDHandshakeRS232: set_handshake(pb + csParam, true); return noErr; case kSERDClockMIDI: if (is_parallel) return noErr; control_io->io_Baud = 31250; control_io->io_SerFlags = SERF_XDISABLED | SERF_SHARED; control_io->io_StopBits = 1; control_io->io_ReadLen = control_io->io_WriteLen = 8; return set_params() ? noErr : paramErr; case kSERDMiscOptions: case kSERDAssertDTR: case kSERDNegateDTR: case kSERDSetPEChar: case kSERDSetPEAltChar: case kSERDAssertRTS: case kSERDNegateRTS: return noErr; // Not supported under AmigaOS case kSERD115KBaud: if (is_parallel) return noErr; control_io->io_Baud = 115200; return set_params() ? noErr : paramErr; case kSERD230KBaud: case kSERDSetHighSpeed: if (is_parallel) return noErr; control_io->io_Baud = 230400; return set_params() ? noErr : paramErr; case kSERDResetChannel: send_to_proc(MSG_RESET); return noErr; default: printf("WARNING: SerialControl(): unimplemented control code %d\n", code); return controlErr; } }
int16 XSERDPort::control(uint32 pb, uint32 dce, uint16 code) { switch (code) { case 1: // KillIO io_killed = true; if (protocol == serial) tcflush(fd, TCIOFLUSH); while (read_pending || write_pending) usleep(10000); io_killed = false; return noErr; case kSERDConfiguration: if (configure(ReadMacInt16(pb + csParam))) return noErr; else return paramErr; case kSERDInputBuffer: return noErr; // Not supported under Unix case kSERDSerHShake: set_handshake(pb + csParam, false); return noErr; case kSERDSetBreak: if (protocol == serial) tcsendbreak(fd, 0); return noErr; case kSERDClearBreak: return noErr; case kSERDBaudRate: { if (protocol != serial) return noErr; uint16 rate = ReadMacInt16(pb + csParam); speed_t baud_rate; if (rate <= 50) { rate = 50; baud_rate = B50; } else if (rate <= 75) { rate = 75; baud_rate = B75; } else if (rate <= 110) { rate = 110; baud_rate = B110; } else if (rate <= 134) { rate = 134; baud_rate = B134; } else if (rate <= 150) { rate = 150; baud_rate = B150; } else if (rate <= 200) { rate = 200; baud_rate = B200; } else if (rate <= 300) { rate = 300; baud_rate = B300; } else if (rate <= 600) { rate = 600; baud_rate = B600; } else if (rate <= 1200) { rate = 1200; baud_rate = B1200; } else if (rate <= 1800) { rate = 1800; baud_rate = B1800; } else if (rate <= 2400) { rate = 2400; baud_rate = B2400; } else if (rate <= 4800) { rate = 4800; baud_rate = B4800; } else if (rate <= 9600) { rate = 9600; baud_rate = B9600; } else if (rate <= 19200) { rate = 19200; baud_rate = B19200; } else if (rate <= 38400) { rate = 38400; baud_rate = B38400; } else if (rate <= 57600) { rate = 57600; baud_rate = B57600; } else { // Just for safety in case someone wants a rate between 57600 and 65535 rate = 57600; baud_rate = B57600; } WriteMacInt16(pb + csParam, rate); cfsetispeed(&mode, baud_rate); cfsetospeed(&mode, baud_rate); tcsetattr(fd, TCSANOW, &mode); return noErr; } case kSERDHandshake: case kSERDHandshakeRS232: set_handshake(pb + csParam, true); return noErr; case kSERDMiscOptions: if (protocol != serial) return noErr; if (ReadMacInt8(pb + csParam) & kOptionPreserveDTR) mode.c_cflag &= ~HUPCL; else mode.c_cflag |= HUPCL; tcsetattr(fd, TCSANOW, &mode); return noErr; case kSERDAssertDTR: { if (protocol != serial) return noErr; unsigned int status = TIOCM_DTR; ioctl(fd, TIOCMBIS, &status); return noErr; } case kSERDNegateDTR: { if (protocol != serial) return noErr; unsigned int status = TIOCM_DTR; ioctl(fd, TIOCMBIC, &status); return noErr; } case kSERDSetPEChar: case kSERDSetPEAltChar: return noErr; // Not supported under Unix case kSERDResetChannel: if (protocol == serial) tcflush(fd, TCIOFLUSH); return noErr; case kSERDAssertRTS: { if (protocol != serial) return noErr; unsigned int status = TIOCM_RTS; ioctl(fd, TIOCMBIS, &status); return noErr; } case kSERDNegateRTS: { if (protocol != serial) return noErr; unsigned int status = TIOCM_RTS; ioctl(fd, TIOCMBIC, &status); return noErr; } case kSERD115KBaud: if (protocol != serial) return noErr; cfsetispeed(&mode, B115200); cfsetospeed(&mode, B115200); tcsetattr(fd, TCSANOW, &mode); return noErr; case kSERD230KBaud: case kSERDSetHighSpeed: if (protocol != serial) return noErr; cfsetispeed(&mode, B230400); cfsetospeed(&mode, B230400); tcsetattr(fd, TCSANOW, &mode); return noErr; default: printf("WARNING: SerialControl(): unimplemented control code %d\n", code); return controlErr; } }