From eb01fb72f6d90bf6a083941ace087bdd6803a516 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Thu, 9 Apr 2009 12:35:32 +0000 Subject: [PATCH] * Add the kernel debugger extensions only for the haiku target. * Acknowledge non-enabled interrupts in UHCI as done in EHCI as well. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30063 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../bus_managers/usb/PhysicalMemoryAllocator.cpp | 6 +++--- .../bus_managers/usb/PhysicalMemoryAllocator.h | 2 +- src/add-ons/kernel/bus_managers/usb/usb.cpp | 13 ++++++++++--- src/add-ons/kernel/busses/usb/ehci.cpp | 2 +- src/add-ons/kernel/busses/usb/ohci.cpp | 2 +- src/add-ons/kernel/busses/usb/uhci.cpp | 13 ++++++++++++- 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/add-ons/kernel/bus_managers/usb/PhysicalMemoryAllocator.cpp b/src/add-ons/kernel/bus_managers/usb/PhysicalMemoryAllocator.cpp index f7ec3c984a..a3d0852788 100644 --- a/src/add-ons/kernel/bus_managers/usb/PhysicalMemoryAllocator.cpp +++ b/src/add-ons/kernel/bus_managers/usb/PhysicalMemoryAllocator.cpp @@ -66,7 +66,7 @@ PhysicalMemoryAllocator::PhysicalMemoryAllocator(const char *name, fManagedMemory = fBlockSize[0] * fArrayLength[0]; size_t roundedSize = biggestSize * minCountPerBlock; -#if KDEBUG +#ifdef HAIKU_TARGET_PLATFORM_HAIKU fDebugBase = roundedSize; fDebugChunkSize = 64; fDebugUseMap = 0; @@ -128,7 +128,7 @@ status_t PhysicalMemoryAllocator::Allocate(size_t size, void **logicalAddress, void **physicalAddress) { -#if KDEBUG +#ifdef HAIKU_TARGET_PLATFORM_HAIKU if (debug_debugger_running()) { for (int32 i = 0; i < 64; i++) { uint64 mask = 1LL << i; @@ -222,7 +222,7 @@ status_t PhysicalMemoryAllocator::Deallocate(size_t size, void *logicalAddress, void *physicalAddress) { -#if KDEBUG +#ifdef HAIKU_TARGET_PLATFORM_HAIKU if (debug_debugger_running()) { uint32 index = ((uint8 *)logicalAddress - (uint8 *)fLogicalBase - fDebugBase) / fDebugChunkSize; diff --git a/src/add-ons/kernel/bus_managers/usb/PhysicalMemoryAllocator.h b/src/add-ons/kernel/bus_managers/usb/PhysicalMemoryAllocator.h index a898a4ed39..3d1e801ca3 100644 --- a/src/add-ons/kernel/bus_managers/usb/PhysicalMemoryAllocator.h +++ b/src/add-ons/kernel/bus_managers/usb/PhysicalMemoryAllocator.h @@ -58,7 +58,7 @@ private: size_t *fArrayOffset; uint8 **fArray; -#if KDEBUG +#ifdef HAIKU_TARGET_PLATFORM_HAIKU uint32 fDebugBase; uint32 fDebugChunkSize; uint64 fDebugUseMap; diff --git a/src/add-ons/kernel/bus_managers/usb/usb.cpp b/src/add-ons/kernel/bus_managers/usb/usb.cpp index af13e7d18a..ba44d74a16 100644 --- a/src/add-ons/kernel/bus_managers/usb/usb.cpp +++ b/src/add-ons/kernel/bus_managers/usb/usb.cpp @@ -16,6 +16,7 @@ Stack *gUSBStack = NULL; +#ifdef HAIKU_TARGET_PLATFORM_HAIKU static int debug_get_pipe_for_id(int argc, char **argv) { @@ -33,6 +34,7 @@ debug_get_pipe_for_id(int argc, char **argv) set_debug_variable("_usbPipe", (uint64)object); return 0; } +#endif static int32 @@ -44,7 +46,7 @@ bus_std_ops(int32 op, ...) if (gUSBStack) return B_OK; -#ifndef __HAIKU__ +#ifndef HAIKU_TARGET_PLATFORM_BEOS // This code is to handle plain R5 (non-BONE) where the same module // gets loaded multiple times (once for each exported module // interface, the USB v2 and v3 API in our case). We don't want to @@ -62,7 +64,7 @@ bus_std_ops(int32 op, ...) #ifdef TRACE_USB set_dprintf_enabled(true); -#ifndef __HAIKU__ +#ifndef HAIKU_TARGET_PLATFORM_HAIKU load_driver_symbols("usb"); #endif #endif @@ -77,10 +79,12 @@ bus_std_ops(int32 op, ...) } gUSBStack = stack; + +#ifdef HAIKU_TARGET_PLATFORM_HAIKU add_debugger_command("get_usb_pipe_for_id", &debug_get_pipe_for_id, "Gets the config for a USB pipe"); -#ifndef __HAIKU__ +#elif HAIKU_TARGET_PLATFORM_BEOS // Plain R5 workaround, see comment above. shared = create_area("shared usb stack", &address, B_ANY_KERNEL_ADDRESS, B_PAGE_SIZE, B_NO_LOCK, @@ -95,8 +99,11 @@ bus_std_ops(int32 op, ...) TRACE_MODULE("uninit\n"); delete gUSBStack; gUSBStack = NULL; + +#ifdef HAIKU_TARGET_PLATFORM_HAIKU remove_debugger_command("get_usb_pipe_for_id", &debug_get_pipe_for_id); +#endif break; default: diff --git a/src/add-ons/kernel/busses/usb/ehci.cpp b/src/add-ons/kernel/busses/usb/ehci.cpp index d23afe7509..cb8f2ed1cf 100644 --- a/src/add-ons/kernel/busses/usb/ehci.cpp +++ b/src/add-ons/kernel/busses/usb/ehci.cpp @@ -520,7 +520,7 @@ EHCI::AddTo(Stack *stack) { #ifdef TRACE_USB set_dprintf_enabled(true); -#ifndef __HAIKU__ +#ifndef HAIKU_TARGET_PLATFORM_HAIKU load_driver_symbols("ehci"); #endif #endif diff --git a/src/add-ons/kernel/busses/usb/ohci.cpp b/src/add-ons/kernel/busses/usb/ohci.cpp index 5d007514c0..c67e3f5a62 100644 --- a/src/add-ons/kernel/busses/usb/ohci.cpp +++ b/src/add-ons/kernel/busses/usb/ohci.cpp @@ -511,7 +511,7 @@ OHCI::AddTo(Stack *stack) { #ifdef TRACE_USB set_dprintf_enabled(true); -#ifndef __HAIKU__ +#ifndef HAIKU_TARGET_PLATFORM_HAIKU load_driver_symbols("ohci"); #endif #endif diff --git a/src/add-ons/kernel/busses/usb/uhci.cpp b/src/add-ons/kernel/busses/usb/uhci.cpp index e384348330..9ca7c17577 100644 --- a/src/add-ons/kernel/busses/usb/uhci.cpp +++ b/src/add-ons/kernel/busses/usb/uhci.cpp @@ -22,6 +22,7 @@ pci_module_info *UHCI::sPCIModule = NULL; static int32 sDebuggerCommandAdded = 0; +#ifdef HAIKU_TARGET_PLATFORM_HAIKU static int debug_process_transfer(int argc, char **argv) { @@ -45,6 +46,7 @@ debug_process_transfer(int argc, char **argv) transfer.SetData(data, length); return ((UHCI *)pipe->GetBusManager())->ProcessDebugTransfer(&transfer); } +#endif static int32 @@ -494,11 +496,13 @@ UHCI::UHCI(pci_info *info, Stack *stack) WriteReg16(UHCI_USBINTR, UHCI_USBINTR_CRC | UHCI_USBINTR_IOC | UHCI_USBINTR_SHORT); +#ifdef HAIKU_TARGET_PLATFORM_HAIKU if (atomic_add(&sDebuggerCommandAdded, 1) == 0) { add_debugger_command("uhci_process_transfer", &debug_process_transfer, "Processes a USB transfer with the given variables"); } +#endif TRACE("UHCI host controller driver constructed\n"); fInitOK = true; @@ -507,10 +511,12 @@ UHCI::UHCI(pci_info *info, Stack *stack) UHCI::~UHCI() { +#ifdef HAIKU_TARGET_PLATFORM_HAIKU if (atomic_add(&sDebuggerCommandAdded, -1) == 1) { remove_debugger_command("uhci_process_transfer", &debug_process_transfer); } +#endif int32 result = 0; fStopFinishThread = true; @@ -1674,6 +1680,11 @@ UHCI::Interrupt() // Check if we really had an interrupt uint16 status = ReadReg16(UHCI_USBSTS); if ((status & fEnabledInterrupts) == 0) { + if (status != 0) { + TRACE("discarding not enabled interrupts 0x%08lx\n", status); + WriteReg16(UHCI_USBSTS, status); + } + release_spinlock(&lock); return B_UNHANDLED_INTERRUPT; } @@ -1737,7 +1748,7 @@ UHCI::AddTo(Stack *stack) { #ifdef TRACE_USB set_dprintf_enabled(true); -#ifndef __HAIKU__ +#ifndef HAIKU_TARGET_PLATFORM_HAIKU load_driver_symbols("uhci"); #endif #endif