hrev47705 adds 4 changesets to branch 'master' old head: 13b28a29b88e107f60c1432adefc16cf146ce3df new head: ab325d984f46398102dc5de8f1c2ccf494a41b27 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=ab325d9+%5E13b28a2 ---------------------------------------------------------------------------- 8e03cf4: pc_serial: Fix TTYSETRTS Same fix as hrev42151 for usb_serial: When determining the bit to be set for RTS/DTR there was a missing comparison to op which would've caused a wrong line state to be set. c8b6d08: pc_serial: This one really is B31250 2ab4db4: pc_serial: Use two tty cookies ab325d9: pc_serial: Drop BeOS stuff Even I don't use it anymore... [ François Revol <revol@xxxxxxx> ] ---------------------------------------------------------------------------- 7 files changed, 36 insertions(+), 580 deletions(-) .../drivers/ports/pc_serial/BeOSCompatibility.h | 54 ---- .../kernel/drivers/ports/pc_serial/Driver.cpp | 92 +----- .../kernel/drivers/ports/pc_serial/Driver.h | 75 +---- .../drivers/ports/pc_serial/SerialDevice.cpp | 299 ++----------------- .../drivers/ports/pc_serial/SerialDevice.h | 19 +- .../kernel/drivers/ports/pc_serial/Tracing.cpp | 70 ----- .../kernel/drivers/ports/pc_serial/Tracing.h | 7 - ############################################################################ Commit: 8e03cf4b31d71334c51811504cb306883a167a5a URL: http://cgit.haiku-os.org/haiku/commit/?id=8e03cf4 Author: François Revol <revol@xxxxxxx> Date: Sat Aug 16 22:20:55 2014 UTC pc_serial: Fix TTYSETRTS Same fix as hrev42151 for usb_serial: When determining the bit to be set for RTS/DTR there was a missing comparison to op which would've caused a wrong line state to be set. ---------------------------------------------------------------------------- diff --git a/src/add-ons/kernel/drivers/ports/pc_serial/SerialDevice.cpp b/src/add-ons/kernel/drivers/ports/pc_serial/SerialDevice.cpp index c90a73b..2e8a58d 100644 --- a/src/add-ons/kernel/drivers/ports/pc_serial/SerialDevice.cpp +++ b/src/add-ons/kernel/drivers/ports/pc_serial/SerialDevice.cpp @@ -314,7 +314,7 @@ SerialDevice::Service(struct tty *tty, uint32 op, void *buffer, size_t length) case TTYSETRTS: { bool set = *(bool *)buffer; - uint8 bit = TTYSETDTR ? MCR_DTR : MCR_RTS; + uint8 bit = op == TTYSETDTR ? MCR_DTR : MCR_RTS; if (set) OrReg8(MCR, bit); else ############################################################################ Commit: c8b6d087f39657dfedc44a0b6145eb84377854ec URL: http://cgit.haiku-os.org/haiku/commit/?id=c8b6d08 Author: François Revol <revol@xxxxxxx> Date: Sat Aug 16 22:41:12 2014 UTC pc_serial: This one really is B31250 ---------------------------------------------------------------------------- diff --git a/src/add-ons/kernel/drivers/ports/pc_serial/Driver.cpp b/src/add-ons/kernel/drivers/ports/pc_serial/Driver.cpp index 0d1ca89..07d0b1a 100644 --- a/src/add-ons/kernel/drivers/ports/pc_serial/Driver.cpp +++ b/src/add-ons/kernel/drivers/ports/pc_serial/Driver.cpp @@ -58,7 +58,7 @@ static const uint32 sDefaultRates[] = { 2, //B57600 1, //B115200 0, //B230400 - 4, //460800 !? B31250! + 4, //B31250 0, //921600 !? }; ############################################################################ Commit: 2ab4db4781b09bdc39bdf6e11e03b2700ff7712b URL: http://cgit.haiku-os.org/haiku/commit/?id=2ab4db4 Author: François Revol <revol@xxxxxxx> Date: Sat Aug 16 23:11:55 2014 UTC pc_serial: Use two tty cookies ---------------------------------------------------------------------------- diff --git a/src/add-ons/kernel/drivers/ports/pc_serial/SerialDevice.cpp b/src/add-ons/kernel/drivers/ports/pc_serial/SerialDevice.cpp index 2e8a58d..fd0fd14 100644 --- a/src/add-ons/kernel/drivers/ports/pc_serial/SerialDevice.cpp +++ b/src/add-ons/kernel/drivers/ports/pc_serial/SerialDevice.cpp @@ -41,7 +41,8 @@ SerialDevice::SerialDevice(const struct serial_support_descriptor *device, #ifdef __HAIKU__ fMasterTTY(NULL), fSlaveTTY(NULL), - fTTYCookie(NULL), + fSystemTTYCookie(NULL), + fDeviceTTYCookie(NULL), #endif /* __HAIKU__ */ fDeviceThread(-1), fStopDeviceThread(false) @@ -569,16 +570,27 @@ SerialDevice::Open(uint32 flags) return B_NO_MEMORY; } - fSlaveTTY = gTTYModule->tty_create(NULL, false); + fSlaveTTY = gTTYModule->tty_create(pc_serial_service, false); if (fSlaveTTY == NULL) { TRACE_ALWAYS("open: failed to init slave tty\n"); gTTYModule->tty_destroy(fMasterTTY); return B_NO_MEMORY; } - fTTYCookie = gTTYModule->tty_create_cookie(fMasterTTY, fSlaveTTY, flags); - if (fTTYCookie == NULL) { - TRACE_ALWAYS("open: failed to init tty cookie\n"); + fSystemTTYCookie = gTTYModule->tty_create_cookie(fMasterTTY, fSlaveTTY, + O_RDWR); + if (fSystemTTYCookie == NULL) { + TRACE_ALWAYS("open: failed to init system tty cookie\n"); + gTTYModule->tty_destroy(fMasterTTY); + gTTYModule->tty_destroy(fSlaveTTY); + return B_NO_MEMORY; + } + + fDeviceTTYCookie = gTTYModule->tty_create_cookie(fSlaveTTY, fMasterTTY, + O_RDWR); + if (fDeviceTTYCookie == NULL) { + TRACE_ALWAYS("open: failed to init device tty cookie\n"); + gTTYModule->tty_destroy_cookie(fSystemTTYCookie); gTTYModule->tty_destroy(fMasterTTY); gTTYModule->tty_destroy(fSlaveTTY); return B_NO_MEMORY; @@ -654,7 +666,7 @@ SerialDevice::Read(char *buffer, size_t *numBytes) return status; } - status = gTTYModule->tty_read(fTTYCookie, buffer, numBytes); + status = gTTYModule->tty_read(fSystemTTYCookie, buffer, numBytes); mutex_unlock(&fReadLock); @@ -692,7 +704,7 @@ SerialDevice::Write(const char *buffer, size_t *numBytes) } //XXX: WTF tty_write() is not for write() hook ? - //status = gTTYModule->tty_write(fTTYCookie, buffer, numBytes); + //status = gTTYModule->tty_write(fSystemTTYCookie, buffer, numBytes); mutex_unlock(&fWriteLock); #else /* __HAIKU__ */ @@ -771,7 +783,7 @@ SerialDevice::Control(uint32 op, void *arg, size_t length) #ifdef __HAIKU__ - status = gTTYModule->tty_control(fTTYCookie, op, arg, length); + status = gTTYModule->tty_control(fSystemTTYCookie, op, arg, length); #else /* __HAIKU__ */ @@ -796,7 +808,7 @@ SerialDevice::Select(uint8 event, uint32 ref, selectsync *sync) #ifdef __HAIKU__ - return gTTYModule->tty_select(fTTYCookie, event, ref, sync); + return gTTYModule->tty_select(fSystemTTYCookie, event, ref, sync); #else /* __HAIKU__ */ @@ -821,7 +833,7 @@ SerialDevice::DeSelect(uint8 event, selectsync *sync) #ifdef __HAIKU__ - return gTTYModule->tty_deselect(fTTYCookie, event, sync); + return gTTYModule->tty_deselect(fSystemTTYCookie, event, sync); #else /* __HAIKU__ */ @@ -854,7 +866,8 @@ SerialDevice::Close() } #ifdef __HAIKU__ - gTTYModule->tty_destroy_cookie(fTTYCookie); + gTTYModule->tty_destroy_cookie(fSystemTTYCookie); + gTTYModule->tty_destroy_cookie(fDeviceTTYCookie); #else /* __HAIKU__ */ struct ddrover *ddr = gTTYModule->ddrstart(NULL); if (!ddr) @@ -945,7 +958,7 @@ status_t SerialDevice::SignalControlLineState(int line, bool enable) { #ifdef __HAIKU__ - gTTYModule->tty_hardware_signal(fTTYCookie, line, enable); + gTTYModule->tty_hardware_signal(fSystemTTYCookie, line, enable); #else // XXX: only works for interrupt handler, Service func must pass the ddrover gTTYModule->ttyhwsignal(&fTTY, &fRover, line, enable); diff --git a/src/add-ons/kernel/drivers/ports/pc_serial/SerialDevice.h b/src/add-ons/kernel/drivers/ports/pc_serial/SerialDevice.h index dbb6274..5d9ade7 100644 --- a/src/add-ons/kernel/drivers/ports/pc_serial/SerialDevice.h +++ b/src/add-ons/kernel/drivers/ports/pc_serial/SerialDevice.h @@ -150,7 +150,8 @@ static void InterruptCallbackFunction(void *cookie, #ifdef __HAIKU__ struct tty * fMasterTTY; struct tty * fSlaveTTY; - struct tty_cookie * fTTYCookie; + struct tty_cookie * fSystemTTYCookie; + struct tty_cookie * fDeviceTTYCookie; #else struct ttyfile fTTYFile; struct tty fTTY; ############################################################################ Revision: hrev47705 Commit: ab325d984f46398102dc5de8f1c2ccf494a41b27 URL: http://cgit.haiku-os.org/haiku/commit/?id=ab325d9 Author: François Revol <revol@xxxxxxx> Date: Sat Aug 16 23:31:41 2014 UTC pc_serial: Drop BeOS stuff Even I don't use it anymore... ---------------------------------------------------------------------------- diff --git a/src/add-ons/kernel/drivers/ports/pc_serial/BeOSCompatibility.h b/src/add-ons/kernel/drivers/ports/pc_serial/BeOSCompatibility.h deleted file mode 100644 index 62760f3..0000000 --- a/src/add-ons/kernel/drivers/ports/pc_serial/BeOSCompatibility.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef _BEOS_COMPATIBILITY_H_ -#define _BEOS_COMPATIBILITY_H_ -#ifndef HAIKU_TARGET_PLATFORM_HAIKU - -typedef struct mutex { - sem_id sem; - int32 count; -} mutex; - - -static inline status_t -mutex_init(mutex *ben, const char *name) -{ - if (ben == NULL || name == NULL) - return B_BAD_VALUE; - - ben->count = 1; - ben->sem = create_sem(0, name); - if (ben->sem >= B_OK) - return B_OK; - - return ben->sem; -} - - -static inline void -mutex_destroy(mutex *ben) -{ - delete_sem(ben->sem); - ben->sem = -1; -} - - -static inline status_t -mutex_lock(mutex *ben) -{ - if (atomic_add(&ben->count, -1) <= 0) - return acquire_sem(ben->sem); - - return B_OK; -} - - -static inline status_t -mutex_unlock(mutex *ben) -{ - if (atomic_add(&ben->count, 1) < 0) - return release_sem(ben->sem); - - return B_OK; -} - -#endif // HAIKU_TARGET_PLATFORM_HAIKU -#endif // _BEOS_COMPATIBILITY_H_ diff --git a/src/add-ons/kernel/drivers/ports/pc_serial/Driver.cpp b/src/add-ons/kernel/drivers/ports/pc_serial/Driver.cpp index 07d0b1a..e0a56a7 100644 --- a/src/add-ons/kernel/drivers/ports/pc_serial/Driver.cpp +++ b/src/add-ons/kernel/drivers/ports/pc_serial/Driver.cpp @@ -26,14 +26,7 @@ char *gDeviceNames[DEVICES_COUNT + 1]; config_manager_for_driver_module_info *gConfigManagerModule = NULL; isa_module_info *gISAModule = NULL; pci_module_info *gPCIModule = NULL; -#ifdef __HAIKU__ tty_module_info *gTTYModule = NULL; -#else -tty_module_info_v1_bone *gTTYModule = NULL; -#endif -#ifdef __BEOS__ -struct ddomain gSerialDomain; -#endif sem_id gDriverLock = -1; bool gHandleISA = false; @@ -470,11 +463,8 @@ next_split: supported->name); -#ifdef __HAIKU__ device = new(std::nothrow) SerialDevice(supported, ioport, irq, master); -#else - device = new SerialDevice(supported, ioport, irq, master); -#endif + if (pc_serial_insert_device(device) < B_OK) { TRACE_ALWAYS("can't insert device\n"); continue; @@ -620,11 +610,8 @@ next_split_alt: /**/ -#ifdef __HAIKU__ device = new(std::nothrow) SerialDevice(supported, ioport, irq, master); -#else - device = new SerialDevice(supported, ioport, irq, master); -#endif + if (pc_serial_insert_device(device) < B_OK) { TRACE_ALWAYS("can't insert device\n"); continue; @@ -670,52 +657,6 @@ init_driver() if (status < B_OK) goto err_tty; -#ifndef __HAIKU__ - // due to BONE having a different function count and ordering, - // but the same version, to avoid crashing we detect it at runtime. - { - static tty_module_info_v1_bone sTTYModuleBONE; - static tty_module_info_v1_r5 *ttyModuleR5 = - (tty_module_info_v1_r5 *)gTTYModule; - image_info info; - int32 cookie = 0; - while (get_next_image_info(/*B_KERNEL_TEAM*/1, &cookie, &info) == B_OK) { - //dprintf(DRIVER_NAME ": checking image %32s\n", info.name); - if ((char *)(gTTYModule->ttyopen) >= (char *)info.text - && (char *)(gTTYModule->ttyopen) < ((char *)info.text + info.text_size)) { - void *symbol; - dprintf(DRIVER_NAME ": detected tty module %32s\n", info.name); - if (get_image_symbol(info.id, "ttydeselect", - B_SYMBOL_TYPE_ANY, &symbol) != B_OK) { - dprintf(DRIVER_NAME ": no ttydeselect() in tty module, assuming R5\n"); - // let's fake a BONE module with NULL select hooks - memcpy(&sTTYModuleBONE.mi, &ttyModuleR5->mi, sizeof(ttyModuleR5->mi)); - sTTYModuleBONE.ttyopen = ttyModuleR5->ttyopen; - sTTYModuleBONE.ttyclose = ttyModuleR5->ttyclose; - sTTYModuleBONE.ttyfree = ttyModuleR5->ttyfree; - sTTYModuleBONE.ttyread = ttyModuleR5->ttyread; - sTTYModuleBONE.ttywrite = ttyModuleR5->ttywrite; - sTTYModuleBONE.ttycontrol = ttyModuleR5->ttycontrol; - sTTYModuleBONE.ttyinit = ttyModuleR5->ttyinit; - sTTYModuleBONE.ttyilock = ttyModuleR5->ttyilock; - sTTYModuleBONE.ttyhwsignal = ttyModuleR5->ttyhwsignal; - sTTYModuleBONE.ttyin = ttyModuleR5->ttyin; - sTTYModuleBONE.ttyout = ttyModuleR5->ttyout; - sTTYModuleBONE.ddrstart = ttyModuleR5->ddrstart; - sTTYModuleBONE.ddrdone = ttyModuleR5->ddrdone; - sTTYModuleBONE.ddacquire = ttyModuleR5->ddacquire; - // no select hooks - sTTYModuleBONE.ttyselect = NULL; - sTTYModuleBONE.ttydeselect = NULL; - - gTTYModule = &sTTYModuleBONE; - } - break; - } - } - } -#endif - status = get_module(B_PCI_MODULE_NAME, (module_info **)&gPCIModule); if (status < B_OK) goto err_pci; @@ -742,11 +683,6 @@ init_driver() status = ENOENT; -#ifdef __BEOS__ - memset(&gSerialDomain, 0, sizeof(gSerialDomain)); - ddbackground(&gSerialDomain); -#endif - scan_bus(B_ISA_BUS); //scan_bus(B_PCI_BUS); scan_pci_alt(); @@ -808,7 +744,6 @@ uninit_driver() } -#ifdef __HAIKU__ bool pc_serial_service(struct tty *tty, uint32 op, void *buffer, size_t length) { @@ -827,23 +762,6 @@ pc_serial_service(struct tty *tty, uint32 op, void *buffer, size_t length) TRACE_FUNCRET("< pc_serial_service() returns: false\n"); return false; } -#else /* __HAIKU__ */ -bool -pc_serial_service(struct tty *ptty, struct ddrover *ddr, uint flags) -{ - TRACE_FUNCALLS("> pc_serial_service(0x%08x, 0x%08x, 0x%08x)\n", ptty, ddr, flags); - - for (int32 i = 0; i < DEVICES_COUNT; i++) { - if (gSerialDevices[i] && gSerialDevices[i]->Service(ptty, ddr, flags)) { - TRACE_FUNCRET("< pc_serial_service() returns: true\n"); - return true; - } - } - - TRACE_FUNCRET("< pc_serial_service() returns: false\n"); - return false; -} -#endif /* __HAIKU__ */ int32 @@ -931,7 +849,6 @@ pc_serial_control(void *cookie, uint32 op, void *arg, size_t length) } -#if defined(B_BEOS_VERSION_DANO) || defined(__HAIKU__) /* pc_serial_select - handle select start */ status_t pc_serial_select(void *cookie, uint8 event, uint32 ref, selectsync *sync) @@ -952,7 +869,6 @@ pc_serial_deselect(void *cookie, uint8 event, selectsync *sync) SerialDevice *device = (SerialDevice *)cookie; return device->DeSelect(event, sync); } -#endif // DANO, HAIKU /* pc_serial_close - handle close() calls */ @@ -1028,10 +944,8 @@ find_device(const char *name) pc_serial_control, /* -> control entry point */ pc_serial_read, /* -> read entry point */ pc_serial_write, /* -> write entry point */ -#if defined(B_BEOS_VERSION_DANO) || defined(__HAIKU__) pc_serial_select, /* -> select entry point */ pc_serial_deselect /* -> deselect entry point */ -#endif }; TRACE_FUNCALLS("> find_device(%s)\n", name); diff --git a/src/add-ons/kernel/drivers/ports/pc_serial/Driver.h b/src/add-ons/kernel/drivers/ports/pc_serial/Driver.h index abadbca..51b2f70 100644 --- a/src/add-ons/kernel/drivers/ports/pc_serial/Driver.h +++ b/src/add-ons/kernel/drivers/ports/pc_serial/Driver.h @@ -20,29 +20,18 @@ #include <config_manager.h> #include <string.h> -#ifdef __HAIKU__ #include <lock.h> #include <new> -#else -#include "BeOSCompatibility.h" -#include "kernel_cpp.h" -#endif + #include "Tracing.h" extern "C" { -#ifdef __HAIKU__ #include <tty_module.h> -#else -#include <ttylayer.h> -#endif } // whether we should handle default COM ports -// not for BeOS, it has a "zz" driver for this. -#ifdef __HAIKU__ #define HANDLE_ISA_COM -#endif #define DRIVER_NAME "pc_serial" // driver name for debug output #define DEVICES_COUNT 20 // max simultaneously open devices @@ -139,67 +128,10 @@ typedef struct pc_serial_line_coding_s { #define CLS_LINE_RTS 0x0002 - -#ifdef __BEOS__ - -// All this mess is due to BeOS R5 and BONE having -// an incompatible module API for the same version - -typedef bool (*beos_tty_service_func)(struct tty *tty, struct ddrover *rover, uint op); - -// this version is compatible with BeOS R5 -struct tty_module_info_v1_r5 { - // not a real bus manager... no rescan() ! - module_info mi; - status_t (*ttyopen)(struct ttyfile *, struct ddrover *, beos_tty_service_func); - status_t (*ttyclose)(struct ttyfile *, struct ddrover *); - status_t (*ttyfree)(struct ttyfile *, struct ddrover *); - status_t (*ttyread)(struct ttyfile *, struct ddrover *, char *, size_t *); - status_t (*ttywrite)(struct ttyfile *, struct ddrover *, const char *, size_t *); - status_t (*ttycontrol)(struct ttyfile *, struct ddrover *, ulong, void *, size_t); - void (*ttyinit)(struct tty *, bool); - void (*ttyilock)(struct tty *, struct ddrover *, bool ); - void (*ttyhwsignal)(struct tty *, struct ddrover *, int, bool); - int (*ttyin)(struct tty *, struct ddrover *, int); - int (*ttyout)(struct tty *, struct ddrover *); - struct ddrover *(*ddrstart)(struct ddrover *); - void (*ddrdone)(struct ddrover *); - void (*ddacquire)(struct ddrover *, struct ddomain *); -}; - -// BeOS BONE has a different module with the same version... -struct tty_module_info_v1_bone { - // not a real bus manager... no rescan() ! - module_info mi; - status_t (*ttyopen)(struct ttyfile *, struct ddrover *, beos_tty_service_func); - status_t (*ttyclose)(struct ttyfile *, struct ddrover *); - status_t (*ttyfree)(struct ttyfile *, struct ddrover *); - status_t (*ttyread)(struct ttyfile *, struct ddrover *, char *, size_t *); - status_t (*ttywrite)(struct ttyfile *, struct ddrover *, const char *, size_t *); - status_t (*ttycontrol)(struct ttyfile *, struct ddrover *, ulong, void *, size_t); - status_t (*ttyselect)(struct ttyfile *, struct ddrover *, uint8, uint32, selectsync *); - status_t (*ttydeselect)(struct ttyfile *, struct ddrover *, uint8, selectsync *); - - void (*ttyinit)(struct tty *, bool); - void (*ttyilock)(struct tty *, struct ddrover *, bool ); - void (*ttyhwsignal)(struct tty *, struct ddrover *, int, bool); - int (*ttyin)(struct tty *, struct ddrover *, int); - int (*ttyout)(struct tty *, struct ddrover *); - struct ddrover *(*ddrstart)(struct ddrover *); - void (*ddrdone)(struct ddrover *); - void (*ddacquire)(struct ddrover *, struct ddomain *); -}; -#endif /* __BEOS__ */ - - extern config_manager_for_driver_module_info *gConfigManagerModule; extern isa_module_info *gISAModule; extern pci_module_info *gPCIModule; -#ifdef __HAIKU__ extern tty_module_info *gTTYModule; -#else -extern tty_module_info_v1_bone *gTTYModule; -#endif extern struct ddomain gSerialDomain; extern "C" { @@ -207,12 +139,9 @@ extern "C" { status_t init_hardware(); void uninit_driver(); -#ifdef __BEOS__ -bool pc_serial_service(struct tty *ptty, struct ddrover *ddr, uint flags); -#else bool pc_serial_service(struct tty *tty, uint32 op, void *buffer, size_t length); -#endif /* __BEOS__ */ + int32 pc_serial_interrupt(void *arg); status_t pc_serial_open(const char *name, uint32 flags, void **cookie); diff --git a/src/add-ons/kernel/drivers/ports/pc_serial/SerialDevice.cpp b/src/add-ons/kernel/drivers/ports/pc_serial/SerialDevice.cpp index fd0fd14..e311343 100644 --- a/src/add-ons/kernel/drivers/ports/pc_serial/SerialDevice.cpp +++ b/src/add-ons/kernel/drivers/ports/pc_serial/SerialDevice.cpp @@ -38,20 +38,13 @@ SerialDevice::SerialDevice(const struct serial_support_descriptor *device, fDoneWrite(-1), fControlOut(0), fInputStopped(false), -#ifdef __HAIKU__ fMasterTTY(NULL), fSlaveTTY(NULL), fSystemTTYCookie(NULL), fDeviceTTYCookie(NULL), -#endif /* __HAIKU__ */ fDeviceThread(-1), fStopDeviceThread(false) { -#ifdef __BEOS__ - memset(&fTTYFile, 0, sizeof(ttyfile)); - memset(&fTTY, 0, sizeof(tty)); - memset(&fRover, 0, sizeof(ddrover)); -#endif /* __BEOS__ */ } @@ -95,17 +88,6 @@ SerialDevice::Init() } -#ifdef __BEOS__ -void -SerialDevice::SetModes() -{ - struct termios tios; - memcpy(&tios, &fTTY.t, sizeof(struct termios)); - SetModes(&tios); -} -#endif /* __BEOS__ */ - - void SerialDevice::SetModes(struct termios *tios) { @@ -233,9 +215,6 @@ SerialDevice::SetModes(struct termios *tios) } -#ifdef __HAIKU__ - - bool SerialDevice::Service(struct tty *tty, uint32 op, void *buffer, size_t length) { @@ -351,121 +330,11 @@ SerialDevice::Service(struct tty *tty, uint32 op, void *buffer, size_t length) } -#else /* __HAIKU__ */ - - -bool -SerialDevice::Service(struct tty *ptty, struct ddrover *ddr, uint flags) -{ - uint8 msr; - status_t err; - - if (&fTTY != ptty) - return false; - - TRACE("%s(,,0x%08lx)\n", __FUNCTION__, flags); - - switch (flags) { - case TTYENABLE: - TRACE("TTYENABLE\n"); - - SetModes(); - err = install_io_interrupt_handler(IRQ(), pc_serial_interrupt, this, 0); - TRACE("installing irq handler for %d: %s\n", IRQ(), strerror(err)); - msr = ReadReg8(MSR); - gTTYModule->ttyhwsignal(ptty, ddr, TTYHWDCD, msr & MSR_DCD); - gTTYModule->ttyhwsignal(ptty, ddr, TTYHWCTS, msr & MSR_CTS); - // - WriteReg8(MCR, MCR_DTR | MCR_RTS | MCR_IRQ_EN /*| MCR_LOOP*//*XXXXXXX*/); - // enable irqs - WriteReg8(IER, IER_RLS | IER_MS | IER_RDA); - //WriteReg8(IER, IER_RDA); - break; - - case TTYDISABLE: - TRACE("TTYDISABLE\n"); - // remove the handler - remove_io_interrupt_handler(IRQ(), pc_serial_interrupt, this); - // disable IRQ - WriteReg8(IER, 0); - WriteReg8(MCR, 0); - msr = ReadReg8(MSR); - gTTYModule->ttyhwsignal(ptty, ddr, TTYHWDCD, msr & MSR_DCD); - break; - - case TTYISTOP: - TRACE("TTYISTOP\n"); - MaskReg8(MCR, MCR_RTS); - //fInputStopped = true; - //gTTYModule->ttyhwsignal(ptty, ddr, TTYHWCTS, false); - break; - - case TTYIRESUME: - TRACE("TTYIRESUME\n"); - OrReg8(MCR, MCR_RTS); - //gTTYModule->ttyhwsignal(ptty, ddr, TTYHWCTS, true); - //fInputStopped = false; - break; - - case TTYGETSIGNALS: - TRACE("TTYGETSIGNALS\n"); - msr = ReadReg8(MSR); - gTTYModule->ttyhwsignal(ptty, ddr, TTYHWDCD, msr & MSR_DCD); - gTTYModule->ttyhwsignal(ptty, ddr, TTYHWCTS, msr & MSR_CTS); - gTTYModule->ttyhwsignal(ptty, ddr, TTYHWDSR, msr & MSR_DSR); - gTTYModule->ttyhwsignal(ptty, ddr, TTYHWRI, msr & MSR_RI); - break; - - case TTYSETMODES: - TRACE("TTYSETMODES\n"); - SetModes(); -//WriteReg8(IER, IER_RLS | IER_MS | IER_RDA); - break; - - case TTYOSTART: - TRACE("TTYOSTART\n"); - // enable irqs - WriteReg8(IER, IER_RLS | IER_MS | IER_RDA | IER_THRE); - break; - case TTYOSYNC: - TRACE("TTYOSYNC\n"); - return (ReadReg8(LSR) & (LSR_THRE | LSR_TSRE)) == (LSR_THRE | LSR_TSRE); - break; - case TTYSETBREAK: - TRACE("TTYSETBREAK\n"); - OrReg8(LCR, LCR_BREAK); - break; - case TTYCLRBREAK: - TRACE("TTYCLRBREAK\n"); - MaskReg8(LCR, LCR_BREAK); - break; - case TTYSETDTR: - TRACE("TTYSETDTR\n"); - OrReg8(MCR, MCR_DTR); - break; - case TTYCLRDTR: - TRACE("TTYCLRDTR\n"); - MaskReg8(MCR, MCR_DTR); - break; - default: - return false; - } - - return false; -} -#endif /* __HAIKU__ */ - - int32 SerialDevice::InterruptHandler() { int32 ret = B_UNHANDLED_INTERRUPT; -#ifdef __HAIKU__ //XXX: what should we do here ? (certainly not use a mutex !) -#else /* __HAIKU__ */ - gTTYModule->ddrstart(&fRover); - gTTYModule->ttyilock(&fTTY, &fRover, true); -#endif /* __HAIKU__ */ uint8 iir, lsr, msr; @@ -487,11 +356,7 @@ SerialDevice::InterruptHandler() fifoavail = 64; for (int i = 0; i < fifoavail; i++) { int chr; -#ifdef __HAIKU__ chr = 'H';//XXX: what should we do here ? (certainly not call tty_read() !) -#else /* __HAIKU__ */ - chr = gTTYModule->ttyout(&fTTY, &fRover); -#endif /* __HAIKU__ */ if (chr < 0) { //WriteReg8(THB, (uint8)chr); break; @@ -506,11 +371,7 @@ SerialDevice::InterruptHandler() TRACE(("IIR_TO/RDA\n")); // while data is ready... get it while (ReadReg8(LSR) & LSR_DR) -#ifdef __HAIKU__ ReadReg8(RBR);//XXX: what should we do here ? (certainly not call tty_write() !) -#else /* __HAIKU__ */ - gTTYModule->ttyin(&fTTY, &fRover, ReadReg8(RBR)); -#endif /* __HAIKU__ */ break; case IIR_RLS: TRACE(("IIR_RLS\n")); @@ -541,12 +402,7 @@ SerialDevice::InterruptHandler() } -#ifdef __HAIKU__ //XXX: what should we do here ? (certainly not use a mutex !) -#else /* __HAIKU__ */ - gTTYModule->ttyilock(&fTTY, &fRover, false); - gTTYModule->ddrdone(&fRover); -#endif /* __HAIKU__ */ TRACE_FUNCRET("< IRQ:%d\n", ret); return ret; } @@ -563,7 +419,6 @@ SerialDevice::Open(uint32 flags) if (fDeviceRemoved) return B_DEV_NOT_READY; -#ifdef __HAIKU__ fMasterTTY = gTTYModule->tty_create(pc_serial_service, true); if (fMasterTTY == NULL) { TRACE_ALWAYS("open: failed to init master tty\n"); @@ -598,25 +453,6 @@ SerialDevice::Open(uint32 flags) ResetDevice(); -#else /* __HAIKU__ */ - - gTTYModule->ttyinit(&fTTY, false); - fTTYFile.tty = &fTTY; - fTTYFile.flags = flags; - - - ResetDevice(); - - struct ddrover *ddr = gTTYModule->ddrstart(NULL); - if (!ddr) - return B_NO_MEMORY; - - gTTYModule->ddacquire(ddr, &gSerialDomain); - status = gTTYModule->ttyopen(&fTTYFile, ddr, pc_serial_service); - gTTYModule->ddrdone(ddr); - -#endif /* __HAIKU__ */ - if (status < B_OK) { TRACE_ALWAYS("open: failed to open tty\n"); return status; @@ -657,8 +493,6 @@ SerialDevice::Read(char *buffer, size_t *numBytes) status_t status; -#ifdef __HAIKU__ - status = mutex_lock(&fReadLock); if (status != B_OK) { TRACE_ALWAYS("read: failed to get read lock\n"); @@ -670,19 +504,6 @@ SerialDevice::Read(char *buffer, size_t *numBytes) mutex_unlock(&fReadLock); -#else /* __HAIKU__ */ - - struct ddrover *ddr = gTTYModule->ddrstart(NULL); - if (!ddr) { - *numBytes = 0; - return B_NO_MEMORY; - } - - status = gTTYModule->ttyread(&fTTYFile, ddr, buffer, numBytes); - gTTYModule->ddrdone(ddr); - -#endif /* __HAIKU__ */ - return status; } @@ -695,8 +516,6 @@ SerialDevice::Write(const char *buffer, size_t *numBytes) status_t status = EINVAL; -#ifdef __HAIKU__ - status = mutex_lock(&fWriteLock); if (status != B_OK) { TRACE_ALWAYS("write: failed to get write lock\n"); @@ -707,19 +526,6 @@ SerialDevice::Write(const char *buffer, size_t *numBytes) //status = gTTYModule->tty_write(fSystemTTYCookie, buffer, numBytes); mutex_unlock(&fWriteLock); -#else /* __HAIKU__ */ - - struct ddrover *ddr = gTTYModule->ddrstart(NULL); - if (!ddr) { - *numBytes = 0; - return B_ERROR; - } - - status = gTTYModule->ttywrite(&fTTYFile, ddr, buffer, numBytes); - gTTYModule->ddrdone(ddr); - -#endif /* __HAIKU__ */ - #if 0 status_t status = mutex_lock(&fWriteLock); if (status != B_OK) { @@ -781,21 +587,8 @@ SerialDevice::Control(uint32 op, void *arg, size_t length) if (fDeviceRemoved) return B_DEV_NOT_READY; -#ifdef __HAIKU__ - status = gTTYModule->tty_control(fSystemTTYCookie, op, arg, length); -#else /* __HAIKU__ */ - - struct ddrover *ddr = gTTYModule->ddrstart(NULL); - if (!ddr) - return B_NO_MEMORY; - - status = gTTYModule->ttycontrol(&fTTYFile, ddr, op, arg, length); - gTTYModule->ddrdone(ddr); - -#endif /* __HAIKU__ */ - return status; } @@ -806,22 +599,7 @@ SerialDevice::Select(uint8 event, uint32 ref, selectsync *sync) if (fDeviceRemoved) return B_DEV_NOT_READY; -#ifdef __HAIKU__ - return gTTYModule->tty_select(fSystemTTYCookie, event, ref, sync); - -#else /* __HAIKU__ */ - - struct ddrover *ddr = gTTYModule->ddrstart(NULL); - if (!ddr) - return B_NO_MEMORY; - - status_t status = gTTYModule->ttyselect(&fTTYFile, ddr, event, ref, sync); - gTTYModule->ddrdone(ddr); - - return status; - -#endif /* __HAIKU__ */ } @@ -831,22 +609,7 @@ SerialDevice::DeSelect(uint8 event, selectsync *sync) if (fDeviceRemoved) return B_DEV_NOT_READY; -#ifdef __HAIKU__ - return gTTYModule->tty_deselect(fSystemTTYCookie, event, sync); - -#else /* __HAIKU__ */ - - struct ddrover *ddr = gTTYModule->ddrstart(NULL); - if (!ddr) - return B_NO_MEMORY; - - status_t status = gTTYModule->ttydeselect(&fTTYFile, ddr, event, sync); - gTTYModule->ddrdone(ddr); - - return status; - -#endif /* __HAIKU__ */ } @@ -865,18 +628,8 @@ SerialDevice::Close() #endif } -#ifdef __HAIKU__ gTTYModule->tty_destroy_cookie(fSystemTTYCookie); gTTYModule->tty_destroy_cookie(fDeviceTTYCookie); -#else /* __HAIKU__ */ - struct ddrover *ddr = gTTYModule->ddrstart(NULL); - if (!ddr) - return B_NO_MEMORY; - - status = gTTYModule->ttyclose(&fTTYFile, ddr); - gTTYModule->ddrdone(ddr); - -#endif /* __HAIKU__ */ fDeviceOpen = false; return status; @@ -887,17 +640,10 @@ status_t SerialDevice::Free() { status_t status = B_OK; -#ifdef __HAIKU__ + gTTYModule->tty_destroy(fMasterTTY); gTTYModule->tty_destroy(fSlaveTTY); -#else /* __HAIKU__ */ - struct ddrover *ddr = gTTYModule->ddrstart(NULL); - if (!ddr) - return B_NO_MEMORY; - status = gTTYModule->ttyfree(&fTTYFile, ddr); - gTTYModule->ddrdone(ddr); -#endif /* __HAIKU__ */ return status; } @@ -957,12 +703,8 @@ SerialDevice::SetLineCoding(usb_serial_line_coding *coding) status_t SerialDevice::SignalControlLineState(int line, bool enable) { -#ifdef __HAIKU__ gTTYModule->tty_hardware_signal(fSystemTTYCookie, line, enable); -#else - // XXX: only works for interrupt handler, Service func must pass the ddrover - gTTYModule->ttyhwsignal(&fTTY, &fRover, line, enable); -#endif + return B_OK; } diff --git a/src/add-ons/kernel/drivers/ports/pc_serial/SerialDevice.h b/src/add-ons/kernel/drivers/ports/pc_serial/SerialDevice.h index 5d9ade7..fe910d6 100644 --- a/src/add-ons/kernel/drivers/ports/pc_serial/SerialDevice.h +++ b/src/add-ons/kernel/drivers/ports/pc_serial/SerialDevice.h @@ -43,17 +43,10 @@ static SerialDevice * MakeDevice(struct serial_config_descriptor char * WriteBuffer() { return fWriteBuffer; }; size_t WriteBufferSize() { return fWriteBufferSize; }; -#ifdef __BEOS__ - void SetModes(); -#endif void SetModes(struct termios *tios); -#ifdef __HAIKU__ + bool Service(struct tty *tty, uint32 op, void *buffer, size_t length); -#else - bool Service(struct tty *ptty, struct ddrover *ddr, - uint flags); -#endif int32 InterruptHandler(); @@ -147,16 +140,11 @@ static void InterruptCallbackFunction(void *cookie, uint16 fControlOut; bool fInputStopped; -#ifdef __HAIKU__ + struct tty * fMasterTTY; struct tty * fSlaveTTY; struct tty_cookie * fSystemTTYCookie; struct tty_cookie * fDeviceTTYCookie; -#else - struct ttyfile fTTYFile; - struct tty fTTY; - struct ddrover fRover; -#endif /* device thread management */ thread_id fDeviceThread; diff --git a/src/add-ons/kernel/drivers/ports/pc_serial/Tracing.cpp b/src/add-ons/kernel/drivers/ports/pc_serial/Tracing.cpp index 1c56703..fd3be83 100644 --- a/src/add-ons/kernel/drivers/ports/pc_serial/Tracing.cpp +++ b/src/add-ons/kernel/drivers/ports/pc_serial/Tracing.cpp @@ -119,73 +119,3 @@ trace_termios(struct termios *tios) tios->c_cc[8], tios->c_cc[9], tios->c_cc[10]); } - -#ifdef __BEOS__ - - -void -trace_ddomain(struct ddomain *dd) -{ - TRACE("struct ddomain:\n" - "\tddrover: 0x%08x\n" - "\tbg: %d, locked: %d\n", dd->r, dd->bg, dd->locked); -} - - -void -trace_str(struct str *str) -{ - TRACE("struct str:\n" - "\tbuffer: 0x%08x\n" - "\tbufsize: %d\n" - "\tcount: %d\n" - "\ttail: %d\n" - "\tallocated: %d\n", - str->buffer, str->bufsize, str->count, str->tail, str->allocated); -} - - -void -trace_winsize(struct winsize *ws) -{ - TRACE("struct winsize:\n" - "\tws_row: %d\n" - "\tws_col: %d\n" - "\tws_xpixel: %d\n" - "\tws_ypixel: %d\n", - ws->ws_row, ws->ws_col, ws->ws_xpixel, ws->ws_ypixel); -} - - -void -trace_tty(struct tty *tty) -{ - TRACE("struct tty:\n" - "\tnopen: %d, flags: 0x%08x,\n", tty->nopen, tty->flags); - - TRACE("ddomain dd:\n"); - trace_ddomain(&tty->dd); - TRACE("ddomain ddi:\n"); - trace_ddomain(&tty->ddi); - - TRACE("\tpgid: %08x\n", tty->pgid); - TRACE("termios t:"); - trace_termios(&tty->t); - - TRACE("\tiactivity: %d, ibusy: %d\n", tty->iactivity, tty->ibusy); - - TRACE("str istr:\n"); - trace_str(&tty->istr); - TRACE("str rstr:\n"); - trace_str(&tty->rstr); - TRACE("str ostr:\n"); - trace_str(&tty->ostr); - - TRACE("winsize wsize:\n"); - trace_winsize(&tty->wsize); - - TRACE("\tservice: 0x%08x\n", tty->service); -} - - -#endif /* __BEOS__ */ diff --git a/src/add-ons/kernel/drivers/ports/pc_serial/Tracing.h b/src/add-ons/kernel/drivers/ports/pc_serial/Tracing.h index bf8c987..422550a 100644 --- a/src/add-ons/kernel/drivers/ports/pc_serial/Tracing.h +++ b/src/add-ons/kernel/drivers/ports/pc_serial/Tracing.h @@ -32,11 +32,4 @@ extern bool gLogFunctionResults; void trace_termios(struct termios *tios); -#ifdef __BEOS__ -void trace_ddomain(struct ddomain *dd); -void trace_str(struct str *str); -void trace_winsize(struct winsize *ws); -void trace_tty(struct tty *tty); -#endif /* __BEOS__ */ - #endif //_PC_SERIAL_TRACING_H_